@import url('https://fonts.googleapis.com/css2?family=Baloo+2:wght@400;500;600;700;800&display=swap');

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box
}

body {
  font-family: 'Baloo 2', sans-serif;
  background: #f0fdf4;
  color: #1e293b;
  overflow: hidden;
  height: 100dvh;
  width: 100vw
}

.screen {
  display: none;
  flex-direction: column;
  height: 100dvh;
  width: 100vw;
  position: absolute;
  top: 0;
  left: 0
}

.screen.active {
  display: flex
}

.screen-enter {
  animation: fadeIn .3s ease
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(12px)
  }

  to {
    opacity: 1;
    transform: translateY(0)
  }
}

/* Buttons */
.btn-3d {
  border: 2px solid;
  border-bottom-width: 6px;
  border-radius: 16px;
  transition: all .1s;
  cursor: pointer;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  width: 100%;
  font-family: inherit
}

.btn-3d:active {
  border-bottom-width: 2px;
  transform: translateY(4px)
}

.btn-3d.green {
  background: #d9f99d;
  border-color: #65a30d;
  color: #365314
}

.btn-3d.blue {
  background: #dbeafe;
  border-color: #3b82f6;
  color: #1e3a5f
}

.btn-3d.red {
  background: #fee2e2;
  border-color: #ef4444;
  color: #7f1d1d
}

.btn-3d.amber {
  background: #fef3c7;
  border-color: #f59e0b;
  color: #78350f
}

.btn-3d.teal {
  background: #ccfbf1;
  border-color: #14b8a6;
  color: #134e4a
}

.btn-3d.slate {
  background: #f1f5f9;
  border-color: #94a3b8;
  color: #334155
}

.btn-3d.purple {
  background: #f3e8ff;
  border-color: #a855f7;
  color: #581c87
}

.btn-3d.disabled {
  opacity: .5;
  pointer-events: none;
  filter: grayscale(.5)
}

.btn-3d .icon {
  font-size: 1.6rem;
  flex-shrink: 0
}

.btn-3d .label {
  font-weight: 800;
  font-size: .95rem;
  line-height: 1.2
}

.btn-3d .desc {
  font-size: .7rem;
  font-weight: 600;
  opacity: .7
}

.btn-cta {
  background: #58cc02;
  color: #fff;
  border: 2px solid #46a302;
  border-bottom: 6px solid #46a302;
  border-radius: 16px;
  padding: 14px;
  width: 100%;
  font-size: 1.1rem;
  font-weight: 800;
  cursor: pointer;
  font-family: inherit;
  transition: all .1s
}

.btn-cta:active {
  border-bottom-width: 2px;
  transform: translateY(4px)
}

/* Zone cards */
.zone-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 0 4px
}

.zone-card {
  border-radius: 20px;
  padding: 20px 16px;
  text-align: center;
  cursor: pointer;
  transition: all .15s;
  border: 3px solid transparent;
  position: relative;
  overflow: hidden
}

.zone-card:active {
  transform: scale(.96)
}

.zone-card .emoji {
  font-size: 2.4rem;
  display: block;
  margin-bottom: 4px
}

.zone-card .name {
  font-weight: 800;
  font-size: 1rem;
  display: block
}

.zone-card .count {
  font-size: .7rem;
  font-weight: 600;
  opacity: .6;
  display: block
}

.zone-card.active {
  background: #dbeafe;
  border-color: #3b82f6
}

.zone-card.wip {
  background: #f1f5f9;
  border-color: #e2e8f0
}

.zone-card.wip::after {
  content: 'IN ARRIVO';
  position: absolute;
  top: 8px;
  right: -20px;
  background: #94a3b8;
  color: #fff;
  font-size: .55rem;
  font-weight: 800;
  padding: 2px 24px;
  transform: rotate(35deg);
  letter-spacing: .5px
}

/* Map */
.map-area {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #e0f2fe;
  touch-action: none;
  cursor: grab
}

.map-area:active {
  cursor: grabbing
}

.map-path {
  fill: #f1f5f9;
  stroke: #94a3b8;
  stroke-width: .3px;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  transition: fill .2s, stroke .2s;
  cursor: pointer
}

.map-path:hover {
  fill: #e2e8f0
}

.map-path.active-typing {
  fill: #c4b5fd !important;
  stroke: #7c3aed;
  stroke-width: .6px
}

.map-path.active-explore {
  fill: #93c5fd !important;
  stroke: #2563eb;
  stroke-width: .6px
}

.map-path.answered {
  fill: #a7f3d0 !important;
  stroke: #059669;
  stroke-width: .5px
}

.map-path.selected {
  fill: #bfdbfe !important;
  stroke: #3b82f6;
  stroke-width: .5px
}

.map-path.correct {
  fill: #86efac !important;
  stroke: #14532d;
  stroke-width: .5px;
  pointer-events: none
}

.map-path.wrong {
  fill: #fca5a5 !important;
  stroke: #991b1b;
  stroke-width: .5px;
  pointer-events: none
}

/* Bottom sheet */
.bottom-sheet {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff;
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -8px 30px rgba(0, 0, 0, .1);
  padding: 16px 20px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 20;
  max-height: 45dvh;
  overflow-y: auto
}

.bottom-sheet .handle {
  width: 40px;
  height: 4px;
  background: #cbd5e1;
  border-radius: 4px;
  margin: 0 auto 12px
}

/* Progress */
.progress-bar {
  width: 100%;
  height: 10px;
  background: #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 12px
}

.progress-fill {
  height: 100%;
  background: #58cc02;
  border-radius: 8px;
  transition: width .4s ease
}

/* Back btn */
.back-btn {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: 12px;
  z-index: 30;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .1);
  transition: all .15s
}

.back-btn:active {
  transform: scale(.9)
}

.back-btn svg {
  width: 20px;
  height: 20px;
  stroke: #1e293b;
  stroke-width: 2.5;
  fill: none
}

/* Results sheet layout */
#sheet-results {
  display: none;
  flex-direction: column;
}

/* Float animation */
@keyframes floatUp {
  0% {
    opacity: 1;
    transform: translateY(0)
  }

  100% {
    opacity: 0;
    transform: translateY(-24px)
  }
}

.time-float {
  position: fixed;
  font-weight: 900;
  font-size: 1.5rem;
  pointer-events: none;
  animation: floatUp .8s ease-out forwards;
  z-index: 99
}

/* Tooltip */
.map-tooltip {
  position: absolute;
  display: none;
  background: rgba(15, 23, 42, .9);
  color: #fff;
  padding: 6px 12px;
  border-radius: 10px;
  font-size: .8rem;
  font-weight: 700;
  pointer-events: none;
  z-index: 40;
  transform: translate(-50%, -100%);
  margin-top: -10px
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 4px
}

::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px
}

/* ============= DESKTOP (768px+) ============= */
@media(min-width:768px) {

  /* Center menu screens */
  #screen-zone>div,
  #screen-mode>div,
  #screen-results>div {
    max-width: 520px;
    margin: 0 auto;
    width: 100%
  }

  /* Zone grid: bigger cards */
  .zone-grid {
    gap: 16px
  }

  .zone-card {
    padding: 28px 20px
  }

  .zone-card .emoji {
    font-size: 3rem
  }

  .zone-card .name {
    font-size: 1.15rem
  }

  .zone-card.active:hover {
    background: #bfdbfe;
    border-color: #2563eb;
    transform: scale(1.03)
  }

  /* Buttons hover */
  .btn-3d:hover {
    filter: brightness(1.04);
    transform: translateY(-1px)
  }

  .btn-3d:active {
    transform: translateY(4px)
  }

  .btn-cta:hover {
    filter: brightness(1.08);
    transform: translateY(-1px)
  }

  /* Game screen: side panel layout */
  #screen-game {
    flex-direction: row
  }

  .map-area {
    flex: 1;
    height: 100%
  }

  /* Bottom sheet becomes side panel */
  .bottom-sheet {
    position: relative;
    bottom: auto;
    left: auto;
    right: auto;
    width: 380px;
    max-height: 100dvh;
    height: 100%;
    border-radius: 0;
    box-shadow: -4px 0 20px rgba(0, 0, 0, .08);
    flex-shrink: 0;
    padding: 24px 28px;
    overflow-y: auto;
  }

  .bottom-sheet .handle {
    display: none
  }

  /* Back button bigger on desktop */
  .back-btn {
    width: 48px;
    height: 48px
  }

  .back-btn:hover {
    background: #f1f5f9;
    border-color: #94a3b8
  }
}

/* ============= LARGE DESKTOP (1200px+) ============= */
@media(min-width:1200px) {

  #screen-zone>div,
  #screen-mode>div,
  #screen-results>div {
    max-width: 600px
  }

  .bottom-sheet {
    width: 420px;
    padding: 28px 32px
  }

  .zone-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    max-width: 480px;
    margin: 0 auto
  }
}

.alignDivCenter {
  justify-self: center;
}

/* ============= EXPLORE ENCYCLOPEDIA ============= */
.exp-section-title {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #94a3b8;
  margin-bottom: 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid #f1f5f9
}

.exp-data-card {
  background: #f8fafc;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid #e2e8f0
}

.exp-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #94a3b8;
  margin-bottom: 2px
}

.exp-value {
  font-weight: 700;
  color: #334155;
  font-size: 13px;
  word-break: break-word
}

.exp-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 14px;
  background: #eff6ff;
  color: #2563eb;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  border: 1px solid #bfdbfe;
  transition: background .2s
}

.exp-link-btn:active, .exp-link-btn:hover {
  background: #dbeafe
}

.exp-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid #e2e8f0;
  border-top-color: #3b82f6;
  border-radius: 50%;
  margin: 0 auto;
  animation: spin .6s linear infinite
}

@keyframes spin {
  to { transform: rotate(360deg) }
}

.col-span-2 {
  grid-column: span 2
}