@font-face {
  font-family: 'Fredoka';
  src: url('/fonts/Fredoka.ttf') format('truetype');
  font-weight: 300 700;
  font-display: swap;
}
:root {
  --green: #2b9348;
  --green-d: #1b5e2f;
  --sun: #ffd166;
  --sky: #a8dadc;
  --ink: #1d3557;
  --red: #e63946;
  --cream: #fff8e7;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  font-family: 'Fredoka', 'Arial Rounded MT Bold', system-ui, sans-serif;
  color: var(--ink); background: #0d1b12;
  user-select: none; -webkit-user-select: none; touch-action: none;
  overscroll-behavior: none;
}
button { font-family: inherit; color: inherit; cursor: pointer; border: 0; }

#video, #gl { position: fixed; inset: 0; width: 100%; height: 100%; }
#video { object-fit: cover; display: none; background: #000; }
#video.on { display: block; }
#gl { display: block; }

.screen { position: fixed; inset: 0; display: none; }
.screen.active { display: block; }
.hidden { display: none !important; }

/* ---------- inicio ---------- */
#home {
  background:
    radial-gradient(circle at 50% 120%, #ffd16655 0, transparent 60%),
    linear-gradient(180deg, #8fd3ff 0%, #c9f0c4 60%, #7cc26a 100%);
}
.home-inner {
  height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; padding: calc(24px + var(--safe-t)) 24px calc(24px + var(--safe-b));
}
.logo { text-align: center; margin-bottom: 10px; }
.logo-dino { font-size: 96px; display: inline-block; animation: bob 1.6s ease-in-out infinite; filter: drop-shadow(0 8px 0 #0002); }
.logo h1 {
  margin: 0; font-size: 64px; line-height: .9; font-weight: 700; color: #fff;
  text-shadow: 0 4px 0 var(--green-d), 0 8px 0 #0002; letter-spacing: 1px;
}
.logo h1 span { color: var(--sun); }
@keyframes bob { 50% { transform: translateY(-10px) rotate(-4deg); } }

.big {
  width: min(340px, 90vw); display: flex; align-items: center; justify-content: center; gap: 14px;
  font-size: 34px; padding: 18px 22px; border-radius: 28px;
  background: #fff; box-shadow: 0 7px 0 #0003; transition: transform .08s;
}
.big span { font-size: 28px; font-weight: 600; }
.big.primary { background: var(--sun); box-shadow: 0 7px 0 #c99a2e; }
.big:active { transform: translateY(5px); box-shadow: 0 2px 0 #0003; }
.parent-link { margin-top: 18px; color: var(--green-d); font-size: 15px; opacity: .85; }

/* ---------- barras ---------- */
.bar {
  display: flex; align-items: center; gap: 12px;
  padding: calc(12px + var(--safe-t)) 16px 12px;
}
.bar h2 { margin: 0; font-size: 30px; color: #fff; text-shadow: 0 3px 0 #0003; flex: 1; }
.count { color: #fff; font-size: 20px; font-weight: 600; }
.round {
  width: 56px; height: 56px; border-radius: 50%; font-size: 26px;
  background: #ffffffee; box-shadow: 0 4px 0 #0003; display: grid; place-items: center; flex: none;
}
.round.small { width: 48px; height: 48px; font-size: 20px; }
.round:active { transform: translateY(3px); box-shadow: 0 1px 0 #0003; }

/* ---------- álbum ---------- */
#album { background: linear-gradient(180deg, #2b9348, #55a630); overflow-y: auto; touch-action: pan-y; }
.album-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; padding: 8px 16px 16px;
}
.album-card {
  aspect-ratio: 63 / 88; border-radius: 18px; padding: 10px; background: var(--sun);
  box-shadow: 0 6px 0 #0003; display: flex; flex-direction: column; position: relative;
}
.album-card .art { flex: 1; border-radius: 12px; display: grid; place-items: center; overflow: hidden; }
.album-card img { width: 112%; }
.album-card .nm { font-size: 18px; font-weight: 600; text-align: center; padding-top: 8px; }
.album-card .no { position: absolute; top: 14px; left: 16px; font-size: 13px; font-weight: 600; opacity: .7; }
.album-card.locked { background: #c8d3c5; }
.album-card.locked img { filter: brightness(0) opacity(.55); }
.album-card.locked .nm { opacity: .7; }
.album-card.locked::after {
  content: '?'; position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 80px; font-weight: 700; color: #fff; text-shadow: 0 4px 0 #0003;
}
.album-hint { text-align: center; color: #fff; font-size: 18px; padding: 0 20px calc(20px + var(--safe-b)); }

/* ---------- encontrado ---------- */
#found { background: radial-gradient(circle, #fff6c9 0%, #ffd166 45%, #f4a259 100%); }
.found-inner { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 24px; }
.found-inner img { width: min(80vw, 380px); animation: pop .6s cubic-bezier(.3,1.6,.6,1) both; filter: drop-shadow(0 12px 0 #0002); position: relative; }
.found-inner .big { position: relative; }
.found-inner h2 { margin: 0 0 12px; font-size: 40px; color: #fff; text-align: center; text-shadow: 0 4px 0 #c46a1a; position: relative; }
.burst {
  position: absolute; width: 140vmax; height: 140vmax; left: 50%; top: 42%; translate: -50% -50%;
  background: repeating-conic-gradient(#ffffff40 0 10deg, transparent 10deg 20deg);
  animation: spin 18s linear infinite; pointer-events: none;
}
@keyframes spin { to { rotate: 360deg; } }
@keyframes pop { from { transform: scale(.2) rotate(-20deg); opacity: 0; } }

/* ---------- juego ---------- */
#play { pointer-events: none; }
#hud { position: absolute; inset: 0; pointer-events: none; }
#hud button { pointer-events: auto; }
.hud-top {
  position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 10px;
  padding: calc(10px + var(--safe-t)) 12px 0;
}
.hud-right { display: flex; gap: 8px; }
.name-chip {
  flex: 1; min-width: 0; padding: 8px 14px; border-radius: 22px; background: #ffffffee;
  box-shadow: 0 4px 0 #0003; display: flex; flex-direction: column; align-items: center; line-height: 1.05;
}
.name-chip span { font-size: 21px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.name-chip small { white-space: nowrap; font-size: 13px; font-weight: 600; padding: 2px 10px; border-radius: 10px; margin-top: 3px; color: #fff; }
.name-chip:empty { display: none; }

.zoom { position: absolute; right: 12px; top: calc(84px + var(--safe-t)); display: flex; flex-direction: column; gap: 10px; }

.status {
  position: absolute; left: 50%; top: calc(84px + var(--safe-t)); translate: -50% 0;
  background: #1d3557dd; color: #fff; padding: 10px 18px; border-radius: 20px; font-size: 18px; font-weight: 500;
  white-space: nowrap; animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: .65; } }

.actions {
  position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; gap: 8px;
  padding: 12px 10px calc(14px + var(--safe-b));
  background: linear-gradient(0deg, #0006, transparent);
}
.actions button {
  flex: 1; max-width: 92px; aspect-ratio: 1; border-radius: 24px; background: #ffffffee;
  box-shadow: 0 6px 0 #0003; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  transition: transform .08s;
}
.actions button b { font-size: 34px; line-height: 1; }
.actions button span { font-size: 13px; font-weight: 600; }
.actions button:active { transform: translateY(4px) scale(.96); box-shadow: 0 2px 0 #0003; }
.actions button.on { background: var(--sun); }

/* ---------- ficha ---------- */
.modal { position: fixed; inset: 0; background: #0008; display: flex; align-items: flex-end; justify-content: center; z-index: 20; }
.sheet {
  width: min(560px, 100%); max-height: 92vh; overflow-y: auto; touch-action: pan-y;
  background: var(--cream); border-radius: 28px 28px 0 0; padding: 22px 18px calc(22px + var(--safe-b)); position: relative;
  border-top: 8px solid var(--sun); animation: up .25s ease-out;
}
@keyframes up { from { transform: translateY(40%); opacity: 0; } }
.sheet .close { position: absolute; top: 14px; right: 14px; width: 46px; height: 46px; font-size: 18px; }
.sheet-head { display: flex; align-items: center; gap: 12px; padding-right: 54px; }
.sheet-head > div { flex: 1; }
.num { font-size: 14px; font-weight: 600; opacity: .6; }
.sheet h2 { margin: 0; font-size: 28px; line-height: 1.1; }
.meaning { font-size: 15px; opacity: .75; font-style: italic; }
.listen { background: var(--sun); }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 14px 0; }
.fact { background: #fff; border-radius: 14px; padding: 8px 10px; box-shadow: 0 2px 0 #0001; }
.fact b { display: block; font-size: 12px; opacity: .6; font-weight: 600; }
.fact span { font-size: 17px; font-weight: 600; }
.fact.wide { grid-column: span 2; }
.map-wrap { position: relative; border-radius: 14px; overflow: hidden; box-shadow: 0 2px 0 #0002; }
.map-wrap img { display: block; width: 100%; }
.pin {
  position: absolute; width: 22px; height: 22px; margin: -11px 0 0 -11px; border-radius: 50%;
  background: var(--red); border: 3px solid #fff; box-shadow: 0 0 0 0 #e6394699; animation: ping 1.4s infinite;
}
@keyframes ping { 70% { box-shadow: 0 0 0 16px #e6394600; } }
.map-caption { font-size: 15px; margin: 8px 2px; opacity: .8; }
.trivia { padding-left: 20px; margin: 6px 0 0; font-size: 17px; }
.trivia li { margin: 6px 0; }

.toast {
  position: fixed; left: 50%; bottom: calc(140px + var(--safe-b)); translate: -50% 0; z-index: 30;
  background: #fff; padding: 12px 20px; border-radius: 20px; font-size: 18px; font-weight: 500; box-shadow: 0 6px 0 #0003;
  max-width: 90vw; text-align: center;
}
