:root {
  --ink: #1a3a52;
  --ink-soft: #3d6078;
  --paper: #0f3d54;
  --grid-line: rgba(255, 255, 255, 0.12);
  --card: #ffe08a;
  --card-hi: #fff6ce;
  --card-lo: #f0c14a;
  --card-border: #c47a18;
  --card-shadow: rgba(20, 60, 80, 0.28);
  --accent: #ff6b3d;
  --accent-deep: #d9431f;
  --accent-edge: #9a2a10;
  --ok: #1f9a58;
  --bad: #e03535;
  --panel: #1f6f92;
  --panel-edge: #ffd24a;
  --panel-inner: #2784ab;
  --radius: 16px;
  --font-display: "Luckiest Guy", system-ui, sans-serif;
  --font-ui: "Nunito", system-ui, sans-serif;
  --p1: #ff6b3d;
  --p2: #2a9df4;
  --p3: #2ecf7a;
  --p4: #ffb347;
  --hud: #145a78;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  font-family: var(--font-ui);
  color: #f4fbff;
  background: var(--paper);
}

html {
  height: 100dvh;
}

body {
  position: relative;
  overflow-x: hidden;
  min-height: 100dvh;
}

body.playing {
  overflow: hidden;
  height: 100dvh;
}

/* —— Escenario arcade —— */
.stage-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background:
    radial-gradient(ellipse 90% 55% at 50% -8%, #245f78 0%, transparent 55%),
    radial-gradient(ellipse 70% 45% at 100% 100%, #165248 0%, transparent 48%),
    radial-gradient(ellipse 55% 40% at 0% 85%, #1e5574 0%, transparent 42%),
    linear-gradient(180deg, #134860 0%, #0f3a4e 42%, #0b2f40 100%);
}

.stage-glow {
  position: absolute;
  inset: -20%;
  background:
    radial-gradient(circle at 28% 38%, rgba(120, 200, 230, 0.18), transparent 34%),
    radial-gradient(circle at 78% 58%, rgba(255, 140, 70, 0.14), transparent 32%);
  animation: glow-drift 14s ease-in-out infinite alternate;
}

.stage-tiles {
  position: absolute;
  inset: 0;
  opacity: 0.45;
  background-image:
    linear-gradient(var(--grid-line) 2px, transparent 2px),
    linear-gradient(90deg, var(--grid-line) 2px, transparent 2px);
  background-size: 42px 42px;
  mask-image: radial-gradient(ellipse 80% 70% at 50% 45%, #000 20%, transparent 75%);
  animation: tiles-scroll 28s linear infinite;
}

.stage-orbs span {
  position: absolute;
  border-radius: 40% 60% 55% 45%;
  border: 3px solid rgba(255, 255, 255, 0.18);
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.02));
  animation: orb-float 9s ease-in-out infinite;
}

.stage-orbs span:nth-child(1) {
  width: 110px; height: 110px; top: 12%; left: 8%;
  background: linear-gradient(145deg, rgba(61, 184, 255, 0.35), rgba(61, 184, 255, 0.05));
  animation-duration: 11s;
}
.stage-orbs span:nth-child(2) {
  width: 70px; height: 70px; top: 22%; right: 12%;
  background: linear-gradient(145deg, rgba(255, 179, 71, 0.4), rgba(255, 179, 71, 0.05));
  animation-delay: -2s; animation-duration: 8s;
}
.stage-orbs span:nth-child(3) {
  width: 140px; height: 140px; bottom: 18%; left: 14%;
  background: linear-gradient(145deg, rgba(61, 214, 140, 0.28), rgba(61, 214, 140, 0.04));
  animation-delay: -4s; animation-duration: 13s;
}
.stage-orbs span:nth-child(4) {
  width: 54px; height: 54px; bottom: 28%; right: 18%;
  background: linear-gradient(145deg, rgba(255, 107, 61, 0.4), rgba(255, 107, 61, 0.06));
  animation-delay: -1s; animation-duration: 7s;
}
.stage-orbs span:nth-child(5) {
  width: 90px; height: 90px; top: 48%; left: 48%;
  background: linear-gradient(145deg, rgba(240, 193, 74, 0.25), rgba(240, 193, 74, 0.04));
  animation-delay: -6s; animation-duration: 10s;
}

@keyframes glow-drift {
  from { transform: translate(-2%, -1%) scale(1); }
  to { transform: translate(2%, 2%) scale(1.05); }
}

@keyframes tiles-scroll {
  from { background-position: 0 0, 0 0; }
  to { background-position: 42px 42px, 42px 42px; }
}

@keyframes orb-float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-18px) rotate(8deg); }
}

.screen {
  display: none;
  max-width: 960px;
  margin: 0 auto;
  padding: 1.25rem 1rem 2.5rem;
}

#screen-menu.screen.active {
  height: 100dvh;
  max-height: 100dvh;
  min-height: 0;
  overflow: hidden;
  padding: 0.45rem 0.75rem 0.5rem;
  gap: 0.45rem;
  justify-content: flex-start;
}

.screen.active {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  animation: fade-in 0.35s ease;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* —— Menú —— */
.menu-hero {
  text-align: center;
  padding: 0.15rem 0 0;
  flex-shrink: 0;
}

.brand-plate {
  display: inline-block;
  padding: 0.28rem 1rem 0.18rem;
  background:
    linear-gradient(180deg, #2b6f92 0%, #1a4a63 100%);
  border: 3px solid var(--panel-edge);
  border-radius: 14px;
  box-shadow:
    0 0 0 3px #0a2030,
    0 6px 0 #0a2030,
    0 10px 18px rgba(0, 0, 0, 0.28);
  animation: brand-pop 0.65s cubic-bezier(0.34, 1.45, 0.64, 1);
}

.brand {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.9rem, 6vw, 2.6rem);
  font-weight: 400;
  letter-spacing: 0.04em;
  line-height: 1;
  color: #fff8e7;
  text-shadow:
    0 3px 0 #c47a18,
    0 5px 0 #8a4e10,
    0 8px 12px rgba(0, 0, 0, 0.3);
  -webkit-text-stroke: 1px rgba(20, 40, 60, 0.15);
}

@keyframes brand-pop {
  from { opacity: 0; transform: scale(0.7) rotate(-3deg); }
  to { opacity: 1; transform: none; }
}

.menu-title {
  margin: 0.35rem 0 0;
  font-family: var(--font-display);
  font-size: clamp(1.05rem, 2.8vw, 1.3rem);
  font-weight: 400;
  letter-spacing: 0.02em;
  color: #fffdf5;
  text-shadow:
    0 2px 0 #0a2a3c,
    0 3px 0 rgba(10, 42, 60, 0.55),
    0 0 14px rgba(255, 210, 74, 0.28);
}

.menu-sub {
  margin: 0.2rem 0 0;
  font-size: 0.82rem;
  font-weight: 800;
  color: rgba(255, 250, 240, 0.92);
  text-shadow: 0 1px 0 rgba(10, 42, 60, 0.45);
}

.setup-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  background:
    linear-gradient(165deg, #2a6f92 0%, var(--panel) 40%, #143a50 100%);
  border: 3px solid var(--panel-edge);
  border-radius: 16px;
  padding: 0.7rem 0.85rem 0.8rem;
  box-shadow:
    0 0 0 3px #0a2030,
    0 8px 0 #0a2030,
    0 14px 28px rgba(0, 0, 0, 0.3);
}

.panel-shine {
  pointer-events: none;
  position: absolute;
  inset: 0;
  background: linear-gradient(125deg, rgba(255, 255, 255, 0.16) 0%, transparent 28%, transparent 70%, rgba(255, 255, 255, 0.05) 100%);
}

.setup-block {
  position: relative;
  border: none;
  margin: 0;
  padding: 0;
}

.setup-block legend {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 400;
  letter-spacing: 0.03em;
  margin-bottom: 0.35rem;
  padding: 0;
  color: #fff8e7;
  text-shadow: 0 2px 0 rgba(8, 36, 54, 0.45);
}

.player-count,
.range-presets,
.grid-presets,
.mode-presets,
.play-presets,
.timer-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.count-btn,
.range-btn,
.grid-btn,
.mode-btn,
.play-btn,
.timer-btn {
  font-family: var(--font-ui);
  font-weight: 900;
  font-size: 0.88rem;
  min-width: 2.6rem;
  padding: 0.38rem 0.7rem;
  border-radius: 10px;
  border: 2px solid #0a2030;
  background: linear-gradient(180deg, #f7fcff 0%, #d7eaf5 100%);
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 3px 0 #0a2030;
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sheet-btn {
  background: linear-gradient(180deg, #ffe08a 0%, #f0c14a 100%);
  color: var(--ink);
  border-color: #8a4e10;
  box-shadow: 0 3px 0 #8a4e10;
}

.mode-btn,
.play-btn {
  flex: 1 1 0;
  min-width: 5rem;
}

.timer-btn {
  flex: 1 1 0;
  min-width: 3.8rem;
}

#players-block.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}

.range-btn {
  flex: 1 1 auto;
  min-width: 5.5rem;
}

.grid-btn {
  flex: 1 1 0;
  min-width: 5.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.05rem;
  padding: 0.4rem 0.55rem;
}

.grid-label {
  font-size: 0.65rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.7;
}

.grid-size {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 400;
  letter-spacing: 0.02em;
}

.count-btn:hover,
.range-btn:hover,
.grid-btn:hover,
.mode-btn:hover,
.play-btn:hover,
.timer-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 #0a2030;
  filter: brightness(1.04);
}

.count-btn:active,
.range-btn:active,
.grid-btn:active,
.mode-btn:active,
.play-btn:active,
.timer-btn:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #0a2030;
}

.count-btn.active,
.range-btn.active,
.grid-btn.active,
.mode-btn.active,
.play-btn.active,
.timer-btn.active {
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-deep) 100%);
  color: #fff;
  border-color: var(--accent-edge);
  box-shadow: 0 4px 0 var(--accent-edge);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.2);
}

.count-btn:disabled {
  cursor: not-allowed;
  transform: none;
  filter: none;
}

.mode-example {
  position: relative;
  background: rgba(8, 36, 54, 0.45);
  border: 2px dashed rgba(240, 193, 74, 0.7);
  border-radius: 10px;
  padding: 0.45rem 0.65rem;
  flex-shrink: 1;
  min-height: 0;
  overflow: hidden;
}

.example-title {
  margin: 0 0 0.2rem;
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  color: #ffe08a;
}

.example-text {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.3;
  color: rgba(244, 251, 255, 0.9);
}

.example-text strong {
  color: #fff;
  font-weight: 900;
}

.grid-btn.active .grid-label {
  opacity: 0.95;
}

.hint {
  margin: 0.3rem 0 0;
  font-size: 0.75rem;
  font-weight: 800;
  color: rgba(244, 251, 255, 0.75);
}

.setup-panel .btn-primary {
  margin-top: 0.15rem;
  flex-shrink: 0;
  font-size: 1.15rem;
  padding: 0.55rem 1.1rem 0.45rem;
  border-radius: 12px;
  box-shadow:
    0 4px 0 var(--accent-edge),
    0 8px 16px rgba(0, 0, 0, 0.25);
}

.btn-primary {
  position: relative;
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  padding: 0.85rem 1.5rem 0.7rem;
  border: 3px solid var(--accent-edge);
  border-radius: 16px;
  background: linear-gradient(180deg, #ff8a55 0%, var(--accent) 45%, var(--accent-deep) 100%);
  color: #fff;
  cursor: pointer;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.25);
  box-shadow:
    0 6px 0 var(--accent-edge),
    0 12px 24px rgba(0, 0, 0, 0.28);
  transition: transform 0.12s ease, box-shadow 0.12s, filter 0.12s;
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.06);
  transform: translateY(-2px);
  box-shadow:
    0 8px 0 var(--accent-edge),
    0 16px 28px rgba(0, 0, 0, 0.3);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(4px);
  box-shadow:
    0 2px 0 var(--accent-edge),
    0 6px 14px rgba(0, 0, 0, 0.25);
}

.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-ghost {
  font-family: var(--font-ui);
  font-weight: 900;
  font-size: 0.9rem;
  padding: 0.5rem 0.9rem;
  border-radius: 12px;
  border: 3px solid #0a2030;
  background: linear-gradient(180deg, #f7fcff 0%, #d7eaf5 100%);
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 3px 0 #0a2030;
  transition: transform 0.12s, box-shadow 0.12s;
}

.btn-ghost:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 0 #0a2030;
}

.btn-ghost:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #0a2030;
}

/* —— Partida —— */
.screen-game.active {
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  padding: 0.45rem 0.7rem 0.55rem;
  gap: 0.35rem;
  max-width: 1100px;
}

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: nowrap;
  flex-shrink: 0;
}

.scoreboard {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.35rem;
  justify-content: flex-end;
  flex: 1;
  overflow: hidden;
}

.class-timer {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0 auto;
  padding: 0.3rem 0.85rem 0.25rem;
  border-radius: 12px;
  border: 3px solid var(--panel-edge);
  background: linear-gradient(180deg, #12384d 0%, var(--hud) 100%);
  box-shadow: 0 3px 0 #0a2030;
  color: #fffdf5;
}

.class-timer[hidden] {
  display: none;
}

.timer-label {
  font-family: var(--font-ui);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #ffe58a;
}

.timer-value {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 400;
  line-height: 1;
  min-width: 1.6em;
  text-align: center;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
}

.class-timer.is-urgent {
  border-color: var(--accent);
  background: linear-gradient(180deg, #8a2a18 0%, #5a180e 100%);
  animation: timer-pulse 0.55s ease-in-out infinite;
}

.class-timer.is-done {
  border-color: var(--panel-edge);
  background: linear-gradient(180deg, #12384d 0%, var(--hud) 100%);
  animation: none;
  opacity: 0.75;
}

@keyframes timer-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

body.class-play .player-zones {
  display: none;
}

body.class-play .turn-hint {
  font-size: 0.9rem;
}

body.class-play .screen-game.active {
  gap: 0.45rem;
}

.score-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 900;
  font-size: 0.78rem;
  padding: 0.3rem 0.6rem;
  border-radius: 10px;
  background: linear-gradient(180deg, #12384d 0%, var(--hud) 100%);
  border: 2px solid currentColor;
  color: #f4fbff;
  white-space: nowrap;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.35);
}

.score-chip .dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 4px;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.25);
}

.score-chip.selected {
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.35), 0 3px 0 rgba(0, 0, 0, 0.35);
}

.question {
  margin: 0;
  text-align: center;
  font-family: var(--font-display);
  font-weight: 400;
  color: #fffdf5;
  line-height: 1.15;
  flex-shrink: 0;
  text-shadow:
    0 2px 0 #0a2a3c,
    0 4px 0 rgba(10, 42, 60, 0.65),
    0 8px 16px rgba(0, 0, 0, 0.28);
}

.q-line {
  display: block;
  font-size: clamp(1.15rem, 3.2vw, 1.55rem);
  letter-spacing: 0.05em;
  color: #fffdf5;
  -webkit-text-stroke: 0.4px rgba(10, 42, 60, 0.25);
}

.q-range {
  display: block;
  margin-top: 0.2rem;
  font-size: clamp(1.05rem, 2.9vw, 1.4rem);
  color: #ffe58a;
  text-shadow:
    0 2px 0 #0a2a3c,
    0 4px 0 rgba(10, 42, 60, 0.55);
}

.q-range strong {
  font-size: 1.15em;
  color: #ffffff;
  -webkit-text-stroke: 0.5px rgba(10, 42, 60, 0.35);
  text-shadow:
    0 2px 0 #0a2a3c,
    0 0 12px rgba(255, 229, 138, 0.35);
}

.grid-stage {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.board-frame {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.55rem;
  background: linear-gradient(165deg, #2a6f92 0%, #1a4a63 100%);
  border: 4px solid var(--panel-edge);
  border-radius: 20px;
  box-shadow:
    0 0 0 4px #0a2030,
    0 10px 0 #0a2030,
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  max-width: 100%;
  max-height: 100%;
}

.number-grid {
  display: grid;
  grid-template-columns: repeat(var(--grid-cols, 3), 1fr);
  grid-template-rows: repeat(var(--grid-cols, 3), 1fr);
  gap: var(--grid-gap, 0.35rem);
  width: var(--grid-side, min(100%, 420px));
  height: var(--grid-side, min(100%, 420px));
  max-width: 100%;
  max-height: 100%;
  margin: 0 auto;
}

.num-card {
  aspect-ratio: auto;
  min-height: 0;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: var(--card-font, clamp(0.85rem, 2.8cqi, 1.45rem));
  color: var(--ink);
  background: linear-gradient(165deg, var(--card-hi) 0%, var(--card) 48%, var(--card-lo) 100%);
  border: 3px solid var(--card-border);
  border-radius: calc(var(--radius) - 2px);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.65),
    inset 0 -3px 0 rgba(180, 110, 20, 0.25),
    0 4px 0 #8a4e10;
  animation: card-in 0.4s cubic-bezier(0.34, 1.35, 0.64, 1) both;
  padding: 0.15rem;
  line-height: 1.05;
  text-align: center;
  overflow: hidden;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
}

.num-card.word-card {
  font-size: var(--card-font-word, 1rem);
  word-break: normal;
  overflow-wrap: anywhere;
  hyphens: manual;
  padding: 0.2rem 0.15rem;
  line-height: 1.05;
  letter-spacing: -0.01em;
}

.option-btn.word-option {
  font-size: clamp(0.85rem, 2.4vw, 1.15rem);
  padding: 0.45rem 0.2rem;
  line-height: 1.1;
  word-break: break-word;
  font-weight: 900;
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: scale(0.55) rotate(-8deg) translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.turn-hint {
  margin: 0;
  text-align: center;
  font-weight: 900;
  font-size: 0.78rem;
  color: rgba(255, 250, 240, 0.88);
  text-shadow: 0 1px 0 rgba(10, 42, 60, 0.5);
  flex-shrink: 0;
}

.player-zones {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem 1.35rem;
  width: 100%;
  max-width: 980px;
  margin: 0.35rem auto 0;
  flex: 0 1 auto;
  min-height: 0;
  padding: 0 0.25rem;
}

.player-zone {
  background: linear-gradient(165deg, #2a6f92 0%, var(--panel) 100%);
  border: 4px solid var(--zone-color, var(--panel-edge));
  border-radius: 16px;
  padding: 0.55rem 0.55rem 0.6rem;
  box-shadow:
    0 0 0 3px #0a2030,
    0 8px 0 #0a2030;
  transition: transform 0.15s ease;
  min-width: 0;
}

.player-zone.locked {
  opacity: 0.72;
  filter: grayscale(0.2);
}

.player-zone.shake {
  animation: shake 0.4s ease;
}

.zone-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  margin-bottom: 0.3rem;
}

.zone-name {
  margin: 0;
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 400;
  letter-spacing: 0.02em;
  color: #fff8e7;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.25);
}

.zone-score {
  font-weight: 900;
  font-size: 0.72rem;
  color: #ffe08a;
}

.zone-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.3rem;
}

.option-btn {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(0.9rem, 2.2vw, 1.15rem);
  padding: 0.45rem 0.2rem 0.35rem;
  border-radius: 10px;
  border: 3px solid #0a2030;
  background: linear-gradient(180deg, #fff8e7 0%, #ffe08a 100%);
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 3px 0 #0a2030;
  transition: transform 0.12s ease, box-shadow 0.12s, filter 0.12s;
  min-width: 0;
}

.option-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 5px 0 #0a2030;
  filter: brightness(1.04);
}

.option-btn:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #0a2030;
}

.option-btn.wrong {
  background: linear-gradient(180deg, #ffd0d0 0%, #f5a0a0 100%);
  border-color: var(--bad);
  color: var(--bad);
  opacity: 0.65;
  cursor: not-allowed;
  text-decoration: line-through;
  box-shadow: 0 2px 0 #8a1a1a;
}

.option-btn:disabled:not(.wrong) {
  opacity: 0.45;
  cursor: not-allowed;
}

.zone-feedback {
  margin: 0.25rem 0 0;
  min-height: 0;
  height: 1em;
  text-align: center;
  font-weight: 900;
  font-size: 0.72rem;
  color: #ffb4b4;
}

@media (max-height: 700px) {
  .turn-hint {
    display: none;
  }

  .zone-feedback {
    display: none;
  }

  .screen-game.active {
    padding: 0.3rem 0.5rem 0.35rem;
    gap: 0.25rem;
  }

  .board-frame {
    padding: 0.35rem;
  }
}

@keyframes shake {
  0%, 100% { transform: none; }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

/* —— Overlay victoria —— */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(20, 70, 95, 0.55);
  backdrop-filter: blur(7px);
  animation: overlay-in 0.35s ease;
}

@keyframes overlay-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.overlay[hidden] {
  display: none;
}

.overlay-card {
  position: relative;
  background: linear-gradient(165deg, #2f789c 0%, #1a4a63 55%, #12384d 100%);
  border-radius: 24px;
  padding: 1.55rem 1.35rem 1.35rem;
  text-align: center;
  max-width: 400px;
  width: 100%;
  border: 4px solid var(--panel-edge);
  box-shadow:
    0 0 0 6px #0a2030,
    0 18px 0 #0a2030,
    0 28px 50px rgba(0, 0, 0, 0.45);
  animation: overlay-card-pop 0.55s cubic-bezier(0.34, 1.45, 0.64, 1);
  overflow: hidden;
}

@keyframes overlay-card-pop {
  0% { opacity: 0; transform: scale(0.7) translateY(24px) rotate(-2deg); }
  70% { transform: scale(1.05) translateY(-4px) rotate(1deg); }
  100% { opacity: 1; transform: none; }
}

.overlay-burst {
  pointer-events: none;
  position: absolute;
  inset: 0;
}

.overlay-burst span {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: var(--panel-edge);
  opacity: 0;
  animation: burst-fly 0.9s ease-out forwards;
}

.overlay-burst span:nth-child(1) { --dx: -110px; --dy: -70px; background: #e8b84a; animation-delay: 0.05s; }
.overlay-burst span:nth-child(2) { --dx: 120px; --dy: -60px; background: var(--accent); animation-delay: 0.08s; }
.overlay-burst span:nth-child(3) { --dx: -90px; --dy: 80px; background: var(--p2); animation-delay: 0.12s; }
.overlay-burst span:nth-child(4) { --dx: 100px; --dy: 75px; background: var(--p3); animation-delay: 0.1s; }
.overlay-burst span:nth-child(5) { --dx: 0px; --dy: -105px; background: #f0c96a; width: 8px; height: 8px; animation-delay: 0.15s; }
.overlay-burst span:nth-child(6) { --dx: -130px; --dy: 10px; background: var(--p4); animation-delay: 0.18s; }
.overlay-burst span:nth-child(7) { --dx: 135px; --dy: 15px; background: #7ec8e8; animation-delay: 0.2s; }
.overlay-burst span:nth-child(8) { --dx: 20px; --dy: 100px; background: #e07a4a; animation-delay: 0.14s; }

@keyframes burst-fly {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.4); }
  25% { opacity: 1; }
  100% { opacity: 0; transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.2) rotate(40deg); }
}

.overlay-badge {
  display: inline-block;
  margin: 0;
  padding: 0.3rem 0.85rem;
  font-family: var(--font-ui);
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #fff;
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-deep) 100%);
  border: 2px solid var(--accent-edge);
  border-radius: 10px;
  box-shadow: 0 3px 0 var(--accent-edge);
  animation: badge-bob 1.4s ease-in-out infinite;
}

@keyframes badge-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.overlay-card h3 {
  margin: 0.65rem 0 0;
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 6vw, 2.3rem);
  font-weight: 400;
  letter-spacing: 0.03em;
  color: #fff8e7;
  text-shadow: 0 3px 0 rgba(8, 36, 54, 0.55);
  animation: title-shine 0.6s ease 0.15s both;
}

@keyframes title-shine {
  from { opacity: 0; letter-spacing: 0.14em; transform: scale(0.9); }
  to { opacity: 1; letter-spacing: 0.03em; transform: none; }
}

.overlay-msg {
  margin: 0.35rem 0 0;
  font-weight: 800;
  font-size: 0.95rem;
  color: rgba(244, 251, 255, 0.88);
  min-height: 1.2em;
}

.overlay-solution {
  margin: 1rem auto 0;
  padding: 0.9rem 1rem 1rem;
  max-width: 100%;
  background: linear-gradient(165deg, var(--card-hi) 0%, var(--card) 55%, var(--card-lo) 100%);
  border: 4px solid var(--card-border);
  border-radius: 18px;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.55),
    0 6px 0 #8a4e10;
  animation: solution-reveal 0.7s cubic-bezier(0.34, 1.5, 0.64, 1) 0.2s both;
}

@keyframes solution-reveal {
  0% { opacity: 0; transform: scale(0.5) rotate(-8deg); }
  60% { transform: scale(1.08) rotate(2deg); }
  100% { opacity: 1; transform: none; }
}

.solution-label {
  display: block;
  font-family: var(--font-ui);
  font-size: 0.8rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 0.15rem;
}

.solution-answer {
  display: block;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(2.5rem, 10vw, 3.8rem);
  line-height: 1.05;
  color: var(--ink);
  word-break: break-word;
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.4);
  animation: answer-pulse 1.2s ease-in-out 0.7s infinite;
}

.solution-answer.is-word {
  font-size: clamp(1.75rem, 7vw, 2.75rem);
}

.overlay-card.is-showing .overlay-burst span {
  animation-name: burst-fly;
}

@keyframes answer-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.overlay-actions {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-top: 1.15rem;
  animation: fade-in 0.4s ease 0.35s both;
}

.overlay-actions .btn-primary {
  width: 100%;
}

.overlay-actions .btn-ghost {
  background: linear-gradient(180deg, rgba(247, 252, 255, 0.95) 0%, rgba(215, 234, 245, 0.95) 100%);
}

/* —— Créditos / redes (menú) —— */
.credits {
  width: min(640px, 100%);
  margin: 0 auto;
  padding: 0.1rem 0 0.15rem;
  text-align: center;
  flex-shrink: 0;
}

.credits-by {
  margin: 0 0 0.3rem;
  font-weight: 900;
  font-size: 0.78rem;
  color: rgba(255, 250, 240, 0.92);
  text-shadow: 0 1px 0 rgba(10, 42, 60, 0.5);
}

.social-links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.social-link {
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--ink);
  background: linear-gradient(180deg, #fffdf5 0%, #e8f4fb 100%);
  border: 2px solid #0a2030;
  box-shadow: 0 2px 0 #0a2030;
  text-decoration: none;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.social-link svg {
  width: 0.85rem;
  height: 0.85rem;
}

.social-link:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 0 #0a2030;
}

.social-link:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #0a2030;
}

.credits-web {
  display: inline-block;
  margin-top: 0.3rem;
  color: #ffe58a;
  font-weight: 900;
  font-size: 0.75rem;
  text-decoration: none;
  text-shadow: 0 1px 0 rgba(10, 42, 60, 0.55);
}

@media (max-height: 780px) {
  .menu-sub,
  #timer-block .hint,
  .mode-example {
    display: none;
  }

  .setup-panel {
    gap: 0.4rem;
    padding: 0.55rem 0.7rem 0.65rem;
  }

  .credits-by {
    display: none;
  }
}

.credits-web:hover {
  color: #fffdf5;
  text-decoration: underline;
}
