:root {
  --ink: #0f1d3d;
  --blue: #2a75bb;
  --blue-dark: #163764;
  --gold: #ffcb05;
  --red: #e3350d;
  --green: #44c267;
  --panel: #cfe3ff;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: #102447;
}

body {
  font-family: 'Courier New', Courier, monospace;
  font-size: 21px;
  color: var(--ink);
  min-height: 100dvh;
  overflow: hidden;
  padding-top: env(safe-area-inset-top);
  padding-right: env(safe-area-inset-right);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  background:
    linear-gradient(180deg, rgba(8, 16, 35, 0.9), rgba(11, 31, 62, 0.86)),
    repeating-linear-gradient(
      0deg,
      rgba(255, 255, 255, 0.03) 0,
      rgba(255, 255, 255, 0.03) 2px,
      transparent 2px,
      transparent 6px
    ),
    radial-gradient(circle at 20% 10%, #3f83ca, transparent 35%),
    radial-gradient(circle at 80% 20%, #f3ca38, transparent 25%),
    #102447;
}

#fx-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 6;
}

#hit-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  z-index: 8;
}

.layout {
  width: min(900px, 100vw);
  height: min(
    calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 12px),
    calc(1206px - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 12px)
  );
  margin: 0 auto;
  padding: 0.3rem 0.5rem 0.5rem;
  display: grid;
  place-items: stretch center;
  position: relative;
  z-index: 3;
}

.card {
  width: 100%;
  background: linear-gradient(180deg, #d9e9ff, #c9deff);
  border: 4px solid var(--gold);
  box-shadow:
    0 0 0 4px var(--blue),
    0 12px 0 #0d2a4f,
    0 24px 48px rgba(0, 0, 0, 0.35);
  border-radius: 12px;
  padding: 0.68rem;
}

.start-card {
  max-width: 720px;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 0.22rem;
  overflow: auto;
  scrollbar-width: none;
}

.start-card::-webkit-scrollbar {
  display: none;
}

#game-screen,
#end-screen {
  max-height: min(100%, calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 1.1rem));
}

#game-screen {
  height: 100%;
  overflow: hidden;
}

#game-card {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.hero-brand {
  text-align: center;
}

.pokemon-mini {
  margin: 0;
  color: #466694;
  letter-spacing: 0.2em;
  font-size: 1rem;
  font-weight: 700;
}

.pokemon-logo {
  margin: 0.25rem 0;
  color: var(--gold);
  font-size: clamp(2.3rem, 10.5vw, 4.2rem);
  text-transform: uppercase;
  text-shadow:
    0 2px 0 #0c2448,
    -2px 0 #0c2448,
    2px 0 #0c2448,
    0 -2px #0c2448,
    0 4px 0 #2a75bb;
}

.lucas-fede-title {
  margin: 0.2rem 0 0.6rem;
  color: #ffdb52;
  font-size: clamp(1.7rem, 8.2vw, 2.7rem);
  text-transform: uppercase;
  text-shadow:
    0 2px 0 #173f74,
    -2px 0 #173f74,
    2px 0 #173f74,
    0 -2px #173f74;
}

.trainers-photo {
  width: min(100%, 430px);
  max-height: 24dvh;
  height: auto;
  border: 3px solid #254c84;
  border-radius: 10px;
  object-fit: cover;
  margin: 0.35rem auto 0.85rem;
  display: block;
}

.setting-group {
  margin: 0.12rem 0;
}

.setting-title {
  margin: 0 0 0.3rem;
  font-size: 1rem;
  letter-spacing: 0.14em;
  color: #3d5f8f;
  font-weight: 700;
}

.button-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.45rem;
}

.setting-btn,
.primary-btn,
.ghost-btn,
.option-btn {
  border: 2px solid #1f3f6b;
  border-radius: 8px;
  padding: 0.64rem 0.5rem;
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
  text-transform: uppercase;
}

.setting-btn {
  background: linear-gradient(180deg, #eef5ff, #dae9fd);
  color: #1e3c66;
  box-shadow: 0 3px 0 #9cb4d2;
  font-size: 1.05rem;
}

.setting-btn.active,
.setting-btn[aria-pressed='true'] {
  background: linear-gradient(180deg, #ffd95f, #ffc30a);
  color: #212121;
  border-color: #936e00;
  box-shadow: 0 3px 0 #936e00;
}

.toggle-btn {
  grid-column: 1 / -1;
}

.controls {
  display: grid;
  gap: 0.55rem;
}

.primary-btn {
  width: 100%;
  margin-top: 0.35rem;
  background: linear-gradient(180deg, #ff6e51, #e3350d);
  color: #fff;
  box-shadow: 0 4px 0 #8d2511;
  font-size: 1.3rem;
}

.start-card .primary-btn {
  margin-top: auto;
}

.hud {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.34rem;
}

.stat-card {
  border: 3px solid #1d3a66;
  border-radius: 4px;
  min-height: 64px;
  padding: 0.28rem 0.24rem;
  text-align: center;
  background: linear-gradient(180deg, #f8fbff, #dcecff);
  box-shadow:
    0 3px 0 #90abce,
    0 0 0 2px rgba(255, 255, 255, 0.1) inset;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.stat-card .label {
  display: block;
  font-size: 0.8rem;
  letter-spacing: 0.14em;
  color: #eef6ff;
  font-weight: 900;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.4);
}

.stat-card strong {
  display: block;
  font-size: 1.7rem;
  font-weight: 900;
  margin-top: 0.04rem;
  color: #ffffff;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
}

.stat-card.points {
  border-color: #0f7a37;
  background: linear-gradient(180deg, #2dbb5e, #179347);
}

.stat-card.fail {
  border-color: #9f1f1a;
  background: linear-gradient(180deg, #e14d43, #bf2b22);
}

.stat-card.round {
  border-color: #0f2f5d;
  background: linear-gradient(180deg, #244f8f, #163a70);
}

.stat-card.finish {
  border-color: #12396f;
  background: linear-gradient(180deg, #1f4d8e, #163a70);
  color: #ffffff;
  font-size: 1.15rem;
  font-family: inherit;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.08s ease;
}

.stat-card.finish span {
  color: #ffffff;
}

.stat-card.finish:active {
  transform: translateY(2px);
}

.timer-wrap {
  margin: 0.42rem 0 0.28rem;
}

.timer-track {
  width: 100%;
  height: 20px;
  border-radius: 999px;
  border: 2px solid #233f6a;
  background: #d8e8ff;
  overflow: hidden;
}

.timer-fill {
  height: 100%;
  width: 100%;
  background: #44c267;
  transition: width 0.06s linear, background-color 0.06s linear;
}

.streak-banner {
  text-align: center;
  font-size: 0.92rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  color: #0f7b34;
  margin-bottom: 0.24rem;
}

.ghost-btn {
  flex: 1;
  background: linear-gradient(180deg, #eaf2ff, #d5e4fb);
  color: #1d385f;
  box-shadow: 0 3px 0 #91abd1;
}

.ghost-btn.danger {
  background: linear-gradient(180deg, #ffd0cc, #ffaba3);
  color: #6b1812;
  border-color: #84221d;
  box-shadow: 0 3px 0 #84221d;
}

.pokemon-wrap {
  position: relative;
  width: min(52vw, 238px);
  height: min(52vw, 238px);
  margin: 0.02rem auto 0.26rem;
  border-radius: 50%;
  border: 3px solid #90b0d8;
  background: radial-gradient(circle at 50% 35%, #fff 0%, #f1f7ff 58%, #d3deef 100%);
  display: grid;
  place-items: center;
  box-shadow: inset 0 7px 14px rgba(20, 45, 82, 0.18);
}

.pokemon {
  width: 86%;
  height: 86%;
  object-fit: contain;
  image-rendering: pixelated;
  transition: transform 0.3s ease, filter 0.3s ease;
}

.silhouette {
  filter: brightness(0);
  transform: scale(0.92);
}

.revealed {
  filter: brightness(1);
  transform: scale(1.05);
}

.options {
  display: flex;
  flex-direction: column;
  gap: 0.26rem;
  flex: 1;
  min-height: 0;
  padding-bottom: 0.15rem;
}

.option-btn {
  min-height: 0;
  height: 100%;
  flex: 1;
  background: linear-gradient(180deg, #ffe486, #ffcb05);
  color: #1f1f1f;
  border-color: #8d6b00;
  box-shadow: 0 4px 0 #8d6b00;
  font-size: clamp(1.62rem, 5.4vw, 2.05rem);
  letter-spacing: 0.03em;
  line-height: 1.1;
  padding: 0.34rem 0.55rem;
}

.option-btn.correct {
  background: linear-gradient(180deg, #5dd07f, #37aa56);
  border-color: #1d6b35;
  box-shadow: 0 4px 0 #1d6b35;
  color: #fff;
}

.option-btn.wrong {
  background: linear-gradient(180deg, #f27066, #d74337);
  border-color: #82231e;
  box-shadow: 0 4px 0 #82231e;
  color: #fff;
}

.spinner {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 5px solid #d8e7fd;
  border-top-color: var(--blue);
  animation: spin 1s linear infinite;
}

.shake {
  animation: shake 0.34s linear;
}

.bad-hit {
  animation: badflash 0.6s linear;
}

.good-hit {
  animation: goodflash 0.7s linear;
}

.pokemon-pop {
  animation: popwin 0.55s ease;
}

.pokemon-drop {
  animation: poplose 0.45s ease;
}

body.flash-good {
  animation: screenGood 0.35s ease;
}

body.flash-bad {
  animation: screenBad 0.35s ease;
}

#hit-overlay.fail {
  animation: failOverlay 0.62s ease;
}

@keyframes popwin {
  0% { transform: scale(0.94); }
  45% { transform: scale(1.18); }
  100% { transform: scale(1.05); }
}

@keyframes poplose {
  0% { transform: scale(1); }
  40% { transform: scale(0.86) rotate(-8deg); }
  100% { transform: scale(0.92); }
}

@keyframes screenGood {
  0% { box-shadow: inset 0 0 0 0 rgba(67, 210, 102, 0.2); }
  35% { box-shadow: inset 0 0 0 100vmax rgba(67, 210, 102, 0.18); }
  100% { box-shadow: inset 0 0 0 0 rgba(67, 210, 102, 0); }
}

@keyframes screenBad {
  0% { box-shadow: inset 0 0 0 0 rgba(235, 77, 64, 0.2); }
  35% { box-shadow: inset 0 0 0 100vmax rgba(235, 77, 64, 0.2); }
  100% { box-shadow: inset 0 0 0 0 rgba(235, 77, 64, 0); }
}

@keyframes failOverlay {
  0% { opacity: 0; background: rgba(255, 0, 0, 0); }
  20% { opacity: 1; background: rgba(240, 42, 32, 0.35); }
  45% { opacity: 0.65; background: rgba(240, 42, 32, 0.2); }
  100% { opacity: 0; background: rgba(255, 0, 0, 0); }
}

@keyframes badflash {
  0% { box-shadow: 0 0 0 0 rgba(220, 60, 48, 0.55); }
  100% { box-shadow: 0 0 0 14px rgba(220, 60, 48, 0); }
}

@keyframes goodflash {
  0% { box-shadow: 0 0 0 0 rgba(56, 192, 96, 0.55); }
  100% { box-shadow: 0 0 0 18px rgba(56, 192, 96, 0); }
}

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

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  30% { transform: translateX(-7px); }
  70% { transform: translateX(7px); }
}

.pill {
  display: inline-block;
  border-radius: 999px;
  border: 2px solid #a3bce0;
  padding: 0.3rem 0.7rem;
  background: #edf5ff;
  font-size: 0.95rem;
}

.big-score {
  font-size: 2.8rem;
  margin: 0.3rem 0;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(16px);
  opacity: 0;
  background: #111c31;
  color: #fff;
  border-radius: 8px;
  padding: 0.45rem 0.7rem;
  border: 2px solid #3d5b89;
  transition: 0.18s ease;
  font-size: 1.1rem;
  letter-spacing: 0.06em;
  pointer-events: none;
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.hidden {
  display: none !important;
}

@media (min-width: 768px) {
  .layout { padding: 0.8rem 1rem; }
  .card { max-width: 760px; }
  .options { grid-template-columns: 1fr 1fr; }
  .option-btn { min-height: 68px; }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}
