/* ==========================================================================
   Adivinhe o Pokémon — estilos
   Parte 1: base, moldura da TV e layout responsivo
   ========================================================================== */

:root {
  --ink: #14122b;
  --ink-2: #1f1b43;
  --yellow: #ffcb05;
  --blue: #2a5fb0;
  --blue-deep: #1b3f87;
  --red: #e53b2a;
  --green: #3ddc84;
  --text: #fff;
  --muted: #c9c5e6;
  --panel: rgba(16, 14, 43, 0.84);
  --panel-line: rgba(255, 255, 255, 0.14);
  --ease-pop: cubic-bezier(0.34, 1.56, 0.64, 1);
  --font-display: "Bangers", "Impact", system-ui, sans-serif;
  --font-body: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  --bezel: 0.4rem;
}

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: max(0.5rem, env(safe-area-inset-top)) max(0.5rem, env(safe-area-inset-right))
           max(0.5rem, env(safe-area-inset-bottom)) max(0.5rem, env(safe-area-inset-left));
  font-family: var(--font-body);
  font-weight: 600;
  color: var(--text);
  background:
    radial-gradient(120% 80% at 50% 0%, #2d2566 0%, transparent 60%),
    radial-gradient(90% 70% at 100% 100%, #4a1d4f 0%, transparent 55%),
    var(--ink);
  background-attachment: fixed;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.noscript { text-align: center; padding: 1rem; }

[hidden] { display: none !important; }

/* ---------- TV: moldura ---------- */
.tv { width: min(100%, 34rem); }

.tv__body {
  container-type: inline-size;
  padding: var(--bezel);
  border-radius: 1.4rem;
  background: linear-gradient(150deg, #4a4566 0%, #26233d 45%, #1a182c 100%);
  box-shadow:
    0 1.5rem 3rem rgba(0, 0, 0, 0.55),
    inset 0 0.12rem 0 rgba(255, 255, 255, 0.18),
    inset 0 -0.2rem 0 rgba(0, 0, 0, 0.35);
}

.tv__panel {
  display: none; /* só aparece no modo TV (telas grandes) */
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.55rem 0.9rem 0.15rem;
  color: #8f8ab3;
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.tv__led {
  width: 0.6rem; height: 0.6rem; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0.5rem var(--green);
}

.tv__knobs { display: flex; gap: 0.6rem; }
.tv__knobs i {
  width: 1.4rem; height: 1.4rem; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #8d88ad, #2c2945 70%);
  box-shadow: 0 0.1rem 0.25rem rgba(0, 0, 0, 0.6), inset 0 0 0 0.12rem rgba(0, 0, 0, 0.25);
}

/* ---------- Tela ---------- */
.screen {
  position: relative;
  display: grid;
  overflow: hidden;
  isolation: isolate;
  border-radius: 1.1rem;
  background: #1a1030;
  min-height: min(38rem, calc(100dvh - 2.5rem));
  font-size: clamp(0.8rem, 3.8cqi, 1.1rem);
  line-height: 1.25;
}

/* ---------- Jogo ---------- */
.game {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto 1fr;
  gap: 0.7em;
  padding: 1em;
  min-height: 100%;
}

.screen[data-state="start"] .game,
.screen[data-state="loading"] .game,
.screen[data-state="error"] .game { visibility: hidden; }

.hud {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1em;
}

.sound-toggle {
  flex: 0 0 auto;
  margin-left: auto;
  padding: 0.35em 0.65em;
  font-size: 0.72em;
  white-space: nowrap;
}
.sound-toggle--menu { min-height: 40px; }

.hud__tries { display: flex; gap: 0.35em; }

.hud__stats {
  display: flex;
  gap: 0.5em;
  margin: 0;
}
.hud__stats div {
  min-width: 4.6em;
  padding: 0.25em 0.7em;
  text-align: center;
  border-radius: 0.7em;
  background: var(--panel);
  border: 1px solid var(--panel-line);
}
.hud__stats dt { font-size: 0.62em; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.hud__stats dd { margin: 0; font-weight: 800; font-size: 1.1em; font-variant-numeric: tabular-nums; }

.stage {
  position: relative;
  z-index: 0;
  height: clamp(10em, 27dvh, 18em);
}

.stage__burst {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 150%;
  aspect-ratio: 1;
  translate: -50% -50%;
}

.mon {
  position: absolute;
  inset: 0;
  margin: auto;
  height: 88%;
  width: auto;
  max-width: 94%;
  aspect-ratio: 1;
  object-fit: contain;
}

.stage__name { position: absolute; left: 0; right: 0; bottom: 0.3em; margin: 0; text-align: center; opacity: 0; }

.side {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 0.6em;
  min-width: 0;
}

.qmark {
  position: absolute;
  top: -3.3em;
  right: 0.3em;
  font-family: var(--font-display);
  font-size: 4em;
  line-height: 0.8;
}

.hints { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.35em; }

.hint {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.8em;
  padding: 0.4em 0.75em;
  border-radius: 0.7em;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  font-size: 0.92em;
}
.hint__label { color: var(--muted); font-size: 0.85em; letter-spacing: 0.08em; text-transform: uppercase; }
.hint__value { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.3em; font-weight: 800; text-align: right; }
.hint.is-locked { opacity: 0.5; }

.wrong { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.3em; }
.wrong li {
  padding: 0.15em 0.6em;
  border-radius: 99em;
  background: rgba(229, 59, 42, 0.25);
  border: 1px solid rgba(229, 59, 42, 0.6);
  font-size: 0.8em;
  text-decoration: line-through;
  text-decoration-thickness: 0.1em;
}

.status { margin: 0; min-height: 1.3em; font-size: 0.9em; color: var(--yellow); }

/* ---------- Formulário de palpite ---------- */
.guess { display: grid; gap: 0.5em; }
.guess__field { position: relative; }

.guess__input {
  width: 100%;
  min-height: max(44px, 2.8em);
  padding: 0.5em 0.9em;
  font: inherit;
  font-weight: 800;
  color: #fff;
  background: rgba(8, 6, 28, 0.85);
  border: 0.14em solid var(--panel-line);
  border-radius: 0.8em;
  outline: none;
}
.guess__input::placeholder { color: #9d98c4; font-weight: 600; }
.guess__input:focus-visible { border-color: var(--yellow); box-shadow: 0 0 0 0.2em rgba(255, 203, 5, 0.3); }

.guess__actions { display: flex; gap: 0.5em; }
.guess__actions .btn { flex: 1; }

.suggest {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 0.3em);
  z-index: 6;
  margin: 0;
  padding: 0.25em;
  list-style: none;
  max-height: 13em;
  overflow-y: auto;
  border-radius: 0.8em;
  background: #120f33;
  border: 1px solid var(--panel-line);
  box-shadow: 0 0.6em 1.4em rgba(0, 0, 0, 0.5);
}
.suggest li {
  display: flex;
  align-items: center;
  min-height: max(44px, 2.6em);
  padding: 0.3em 0.8em;
  border-radius: 0.6em;
  cursor: pointer;
  font-weight: 800;
}
.suggest li[aria-selected="true"],
.suggest li:hover { background: var(--blue); }

/* ---------- Resultado ---------- */
.result {
  display: grid;
  gap: 0.5em;
  padding: 0.7em;
  text-align: center;
  border-radius: 1em;
  background: var(--panel);
  border: 1px solid var(--panel-line);
}
.result__title { margin: 0; font-family: var(--font-display); font-size: 2.2em; letter-spacing: 0.04em; line-height: 1; }
.result__text { margin: 0; color: #e8e5fb; }

/* ---------- Botões ---------- */
.btn {
  min-height: max(44px, 2.8em);
  padding: 0.5em 1.1em;
  font: inherit;
  font-weight: 800;
  color: #fff;
  border: 0;
  border-radius: 0.8em;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.15s var(--ease-pop), filter 0.15s ease, background-color 0.15s ease;
}
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: scale(0.96); }
.btn:focus-visible { outline: 0.18em solid #fff; outline-offset: 0.18em; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; filter: none; transform: none; }

.btn--primary {
  color: #2b1b00;
  background: linear-gradient(180deg, #ffe066, var(--yellow));
  box-shadow: 0 0.2em 0 #b88a00;
}
.btn--ghost { background: rgba(255, 255, 255, 0.1); border: 1px solid var(--panel-line); }
.btn--big { font-size: 1.25em; padding-inline: 2em; }

/* ---------- Sobreposições (início, carregando, erro) ---------- */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: none;
  place-items: center;
  padding: 1em;
  overflow: auto;
  background: rgba(8, 6, 28, 0.35);
}
.screen[data-state="start"] .overlay--start,
.screen[data-state="loading"] .overlay--loading,
.screen[data-state="error"] .overlay--error { display: grid; }

.card {
  width: min(100%, 27em);
  margin: auto;
  padding: 1.4em 1.3em;
  display: grid;
  gap: 1em;
  justify-items: center;
  text-align: center;
  border-radius: 1.2em;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  box-shadow: 0 1em 2.5em rgba(0, 0, 0, 0.5);
}
.card p { margin: 0; }
.card--small { width: min(100%, 20em); }
.card__lead { color: var(--muted); }
.card__title { font-family: var(--font-display); font-size: 2.2em; letter-spacing: 0.05em; color: var(--yellow); }
.card__record { font-size: 0.85em; color: var(--muted); min-height: 1.2em; }

.diff { width: 100%; margin: 0; padding: 0; border: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5em; }
.diff legend { grid-column: 1 / -1; padding: 0; margin-bottom: 0.4em; font-size: 0.75em; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.diff label { display: block; cursor: pointer; }
.diff input { position: absolute; opacity: 0; pointer-events: none; }
.diff span {
  display: grid;
  gap: 0.1em;
  min-height: max(44px, 3.4em);
  padding: 0.5em 0.3em;
  place-content: center;
  border-radius: 0.8em;
  background: rgba(255, 255, 255, 0.08);
  border: 0.14em solid transparent;
  font-weight: 800;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
.diff small { font-size: 0.68em; font-weight: 600; color: var(--muted); }
.diff input:checked + span { background: var(--blue); border-color: var(--yellow); }
.diff input:focus-visible + span { outline: 0.18em solid #fff; outline-offset: 0.12em; }

/* ---------- Telas largas: silhueta à esquerda, "?" e dicas à direita ---------- */
@media (min-width: 760px), (min-width: 560px) and (orientation: landscape) {
  .game {
    grid-template-columns: minmax(0, 46fr) minmax(0, 54fr);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas: "hud hud" "stage side";
    column-gap: 1.2em;
  }
  .hud { grid-area: hud; }
  .stage { grid-area: stage; height: auto; min-height: 0; }
  .side { grid-area: side; gap: 0.5em; }
  .stage__burst { width: 160%; }
  .qmark { position: static; align-self: center; font-size: 4.4em; margin-block: -0.1em -0.05em; }
  .hint { padding: 0.3em 0.75em; }
}

/* ---------- Modo TV: proporção 4:3 que sempre cabe na altura da janela ---------- */
@media (min-width: 760px) and (min-height: 560px) {
  :root { --bezel: 0.9rem; }
  .tv__panel { display: flex; }
  .tv { width: min(100%, 72rem, calc((100dvh - 7rem) * 4 / 3 + 2 * var(--bezel))); }
  .screen {
    aspect-ratio: 4 / 3;
    min-height: 0;
    font-size: clamp(0.75rem, 2.15cqi, 1.3rem);
    border-radius: 1.6rem;
  }
  .game { height: 100%; min-height: 0; padding: 1.1em 1.3em; }
}

/* ---------- Celular deitado (pouca altura): sem aspecto fixo, a página rola ---------- */
@media (min-width: 560px) and (max-height: 559px) and (orientation: landscape) {
  :root { --bezel: 0.4rem; }
  body { padding: 0.4rem; }
  .tv { width: min(100%, 64rem); }
  .tv__panel { display: none; }
  .screen { min-height: calc(100dvh - 1rem); font-size: clamp(0.7rem, 1.75cqi, 1rem); border-radius: 0.8rem; }
  .stage { min-height: 13em; }
}

/* ==========================================================================
   Parte 2: visual de programa de TV (raios, silhueta, "?", título)
   ========================================================================== */

.bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background: #a8100c;
}
.bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(70% 60% at 0% 100%, rgba(255, 150, 20, 0.85), transparent 70%),
    radial-gradient(60% 50% at 100% 100%, rgba(255, 120, 20, 0.7), transparent 70%),
    radial-gradient(90% 80% at 50% 0%, rgba(120, 0, 0, 0.45), transparent 70%);
}

/* Só estes elementos giram; o gradiente é desenhado uma única vez. */
.bg__rays {
  position: absolute;
  left: 50%;
  top: 50%;
  width: max(220%, 120dvh);
  aspect-ratio: 1;
  translate: -50% -50%;
  background: repeating-conic-gradient(from 0deg, #f03a22 0 6deg, #c8180f 6deg 12deg);
  animation: spin 70s linear infinite;
}

.stage__burst {
  background:
    repeating-conic-gradient(from 0deg, #eefcff 0 2.6deg, transparent 2.6deg 7.2deg),
    radial-gradient(circle, #f2fdff 0 20%, #9fdbe3 38%, #4aa6b6 68%, #3a8fa3 100%);
  -webkit-mask-image: radial-gradient(circle, #000 0 46%, transparent 71%);
  mask-image: radial-gradient(circle, #000 0 46%, transparent 71%);
  animation: spin 50s linear infinite reverse;
}

.bg__rays,
.stage__burst,
.qmark { will-change: transform; }

/* Silhueta: --reveal vai de 0 (preta e desfocada) a 1 (colorida e nítida). */
.mon {
  filter:
    brightness(var(--reveal))
    blur(calc((1 - var(--reveal)) * 0.3em))
    drop-shadow(0 0.3em 0.4em rgba(0, 0, 0, 0.35));
  transition: filter 0.9s ease;
}
.screen[data-state="loading"] .mon { transition: none; }

.qmark {
  color: var(--yellow);
  -webkit-text-stroke: 0.12em var(--blue-deep);
  paint-order: stroke fill;
  text-shadow: 0.05em 0.07em 0 var(--blue-deep), 0 0.1em 0.3em rgba(0, 0, 0, 0.45);
  rotate: 8deg;
  animation: qpulse 1.6s ease-in-out infinite;
}

/* Título desenhado pelo site (fonte própria, não é o logotipo oficial). */
.logo {
  margin: 0.1em 0 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 3em;
  line-height: 0.95;
  letter-spacing: 0.04em;
  color: var(--yellow);
  -webkit-text-stroke: 0.14em var(--blue-deep);
  paint-order: stroke fill;
  text-shadow: 0 0.07em 0 var(--blue-deep), 0 0.12em 0.25em rgba(0, 0, 0, 0.5);
  rotate: -3deg;
}
.logo span {
  display: block;
  margin-bottom: 0.5em;
  font-size: 0.55em;
  color: #fff;
  -webkit-text-stroke-width: 0.22em;
}

/* Bolas de tentativa */
.ball, .ball-spin {
  border-radius: 50%;
  border: 0.12em solid #1d1d1d;
  background:
    radial-gradient(circle, #fff 0 0.16em, #1d1d1d 0.17em 0.3em, transparent 0.31em),
    linear-gradient(180deg, var(--red) 0 46%, #1d1d1d 46% 54%, #fff 54%);
}
.ball {
  width: 1.5em;
  height: 1.5em;
  transition: transform 0.4s var(--ease-pop), opacity 0.3s ease;
}
.ball.is-used { opacity: 0.3; transform: scale(0.7); filter: grayscale(1); }
.ball-spin { width: 3.4em; height: 3.4em; animation: spin 0.9s linear infinite; }

/* Tipos */
.chip {
  padding: 0.05em 0.65em;
  border-radius: 99em;
  background: var(--c, #777);
  color: #fff;
  font-size: 0.9em;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.45);
}
.t-normal { --c: #8a8a59; }  .t-fire { --c: #e8702a; }    .t-water { --c: #4a79ea; }
.t-electric { --c: #d4a400; } .t-grass { --c: #4fa63a; }  .t-ice { --c: #4fb5b0; }
.t-fighting { --c: #b82a21; } .t-poison { --c: #9a3a9a; } .t-ground { --c: #b0894a; }
.t-flying { --c: #7d6bd6; }   .t-psychic { --c: #e8457a; } .t-bug { --c: #8a9a12; }
.t-rock { --c: #9a8528; }     .t-ghost { --c: #64477a; }   .t-dragon { --c: #5a2cd8; }
.t-dark { --c: #5a4538; }     .t-steel { --c: #7d7da0; }   .t-fairy { --c: #d97a96; }

/* Nome na revelação final */
.stage__name {
  font-family: var(--font-display);
  font-size: 2.1em;
  line-height: 1;
  letter-spacing: 0.04em;
  color: var(--yellow);
  -webkit-text-stroke: 0.14em var(--blue-deep);
  paint-order: stroke fill;
  text-shadow: 0 0.07em 0 var(--blue-deep), 0 0.12em 0.3em rgba(0, 0, 0, 0.5);
  text-wrap: balance;
}
.screen[data-phase="won"] .stage__name,
.screen[data-phase="lost"] .stage__name { opacity: 1; }
.screen[data-phase="won"] .result__title { color: var(--green); }
.screen[data-phase="lost"] .result__title { color: #ff8a7a; }

/* Efeitos de vidro, linhas de varredura e brilho da tela */
.screen::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 7;
  pointer-events: none;
  background: linear-gradient(115deg, rgba(255, 255, 255, 0.09) 0 20%, transparent 20.2%);
}
.screen::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 8;
  pointer-events: none;
  background:
    repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0.13) 0 1px, transparent 1px 3px),
    radial-gradient(120% 100% at 50% 50%, transparent 62%, rgba(0, 0, 0, 0.45) 100%);
  box-shadow: inset 0 0 3em rgba(0, 0, 0, 0.55);
  border-radius: inherit;
}

.flash {
  position: absolute;
  inset: 0;
  z-index: 6;
  background: #fff;
  opacity: 0;
  pointer-events: none;
}

/* ==========================================================================
   Parte 3: animações (somente transform, opacity e propriedades individuais)
   ========================================================================== */

@keyframes spin   { to { rotate: 360deg; } }
@keyframes qpulse { 0%, 100% { scale: 1; } 50% { scale: 1.12; } }

@keyframes tv-on {
  0%   { transform: scale(1, 0.004); opacity: 0; }
  25%  { transform: scale(1, 0.004); opacity: 1; }
  70%  { transform: scale(1, 1.04); }
  100% { transform: scale(1, 1); opacity: 1; }
}
@keyframes power-glow { 0% { opacity: 0.85; } 100% { opacity: 0; } }
@keyframes flash      { 0% { opacity: 0; } 14% { opacity: 1; } 100% { opacity: 0; } }

@keyframes pop-in {
  0%   { opacity: 0; transform: translateX(1.2em) scale(0.95); }
  100% { opacity: 1; transform: none; }
}
@keyframes name-in {
  0%   { opacity: 0; transform: translateY(0.8em) scale(0.4) rotate(-6deg); }
  100% { opacity: 1; transform: none; }
}
@keyframes hop {
  0%, 100% { transform: translateY(0); }
  40%      { transform: translateY(-6%) scale(1.04); }
}
@keyframes wobble {
  0%, 100% { transform: none; }
  25% { transform: translateX(-3%) rotate(-3deg); }
  75% { transform: translateX(3%) rotate(3deg); }
}
@keyframes shake {
  0%, 100% { transform: none; }
  20%, 60% { transform: translateX(-0.4em); }
  40%, 80% { transform: translateX(0.4em); }
}

.screen.is-powering { animation: tv-on 0.85s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.screen.is-powering .flash { animation: power-glow 0.85s ease-out; }

.screen[data-phase="won"] .flash,
.screen[data-phase="lost"] .flash { animation: flash 0.75s ease-out; }

.screen[data-phase="won"] .stage__name,
.screen[data-phase="lost"] .stage__name { animation: name-in 0.7s var(--ease-pop) 0.35s both; }
.screen[data-phase="won"] .mon { animation: hop 0.6s var(--ease-pop) 0.25s; }

.hint.is-open { animation: pop-in 0.45s var(--ease-pop); }
.wrong li { animation: pop-in 0.35s var(--ease-pop); }
.stage.is-wrong .mon { animation: wobble 0.4s ease-in-out; }
.guess.is-shake { animation: shake 0.35s ease-in-out; }

/* Aba em segundo plano: pausa todas as animações contínuas. */
[data-hidden] *,
[data-hidden] *::before,
[data-hidden] *::after { animation-play-state: paused !important; }

/* Menos movimento: sem giro, pulso, flash nem linhas de varredura. */
@media (prefers-reduced-motion: reduce) {
  .bg__rays, .stage__burst, .qmark { animation: none; will-change: auto; }
  .screen.is-powering,
  .screen.is-powering .flash,
  .screen[data-phase] .flash,
  .screen[data-phase] .stage__name,
  .screen[data-phase="won"] .mon,
  .hint.is-open, .wrong li, .stage.is-wrong .mon, .guess.is-shake { animation: none; }
  .flash { display: none; }
  .screen::after { background: radial-gradient(120% 100% at 50% 50%, transparent 62%, rgba(0, 0, 0, 0.45) 100%); }
  .mon { transition-duration: 0.2s; }
  .ball, .btn { transition: none; }
}
