@font-face {
  font-family: Festa;
  src: url(assets/display.ttf) format("truetype");
  font-display: swap;
  font-weight: 800;
}
@font-face {
  font-family: Texto;
  src: url(assets/body.ttf) format("truetype");
  font-display: swap;
}
* {
  box-sizing: border-box;
}
:root {
  color-scheme: dark;
  --navy: #101b36;
  --gold: #ffce76;
  --cream: #fff1d4;
  --purple: #67318e;
  --red: #c8424c;
  --green: #428f74;
}
body {
  margin: 0;
  background: #080f20;
  color: var(--cream);
  font:
    16px/1.5 Texto,
    system-ui,
    sans-serif;
}
button,
input {
  font: inherit;
}
button {
  cursor: pointer;
  color: inherit;
  border: 0;
}
button:focus-visible,
a:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 4px;
}
button:disabled {
  opacity: 0.5;
  cursor: wait;
}
button:active {
  transform: translateY(2px);
}
[hidden] {
  display: none !important;
}
#app {
  position: relative;
  max-width: 580px;
  min-height: 800px;
  height: 100svh;
  min-height: min(800px, 100svh);
  margin: auto;
  overflow: hidden;
  background: var(--navy);
}
#stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  touch-action: none;
}
.vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(
    #101b3655,
    transparent 30%,
    #101b3677 65%,
    #101b36f5
  );
}
header {
  position: absolute;
  z-index: 4;
  top: 0;
  left: 0;
  right: 0;
  padding: max(12px, env(safe-area-inset-top)) 20px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.icon {
  border: 1px solid #ffffff30;
  background: #101b36cc;
  border-radius: 50px;
  padding: 9px 12px;
  font-size: 12px;
  font-family: Festa;
}
.wordmark {
  font-size: 10px;
  letter-spacing: 2px;
}
.screen {
  position: absolute;
  inset: 70px 24px 12px;
  text-align: center;
  z-index: 2;
  overflow-y: auto;
  scrollbar-width: thin;
}
.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 10px;
  letter-spacing: 2px;
}
.brand img {
  width: 122px;
  background: #fff;
  border-radius: 6px;
  padding: 5px;
  max-height: 45px;
  object-fit: contain;
}
.eyebrow {
  font-size: 11px;
  letter-spacing: 3px;
  color: var(--gold);
  margin: 20px 0 12px;
}
h1,
h2,
h3,
p {
  margin-top: 0;
}
h1,
h2,
h3,
.primary,
.secondary {
  font-family: Festa, system-ui, sans-serif;
}
h1 {
  font-size: clamp(60px, 15vw, 85px);
  line-height: 0.85;
  letter-spacing: -5px;
  text-shadow:
    0 4px 0 #46265d,
    0 12px 40px #070c24;
  margin: 0 auto 14px;
  transform: rotate(-3deg);
}
h1 span {
  color: var(--gold);
}
h1 em {
  display: block;
  letter-spacing: 8px;
  font-size: 17px;
  font-style: normal;
  margin-top: 18px;
}
h2 {
  font-size: 38px;
  line-height: 1.1;
  letter-spacing: -1.5px;
}
h3 {
  font-size: 21px;
  line-height: 1.2;
}
.intro-copy {
  font-size: 14px;
  margin-top: 20px;
  text-shadow: 0 1px 8px #000;
}
.home-bottom {
  position: absolute;
  bottom: 0;
  width: 100%;
}
.prizes {
  padding: 13px 0;
  margin-bottom: 8px;
  background: #101b3699;
  border-top: 1px solid #ffce7655;
  border-bottom: 1px solid #ffce7625;
}
.prizes span {
  font-size: 10px;
  color: var(--gold);
  letter-spacing: 3px;
  display: block;
}
.prizes strong {
  display: block;
  font-size: 15px;
}
.prizes small {
  font-size: 12px;
  color: #c8cadd;
}
.primary,
.secondary {
  display: block;
  width: 100%;
  padding: 15px;
  border-radius: 14px;
  font-size: 17px;
  margin: 9px auto;
  background: var(--gold);
  color: #291b3c;
  box-shadow: 0 5px 0 #a37136;
  transition: transform 0.15s;
}
.secondary {
  background: #253653;
  color: #fff1d4;
  border: 1px solid #e7cfa944;
  box-shadow: none;
  padding: 12px;
}
.gold {
  background: #ffce76;
}
nav {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin: 18px 0 8px;
}
nav button,
.back {
  font-size: 12px;
  background: transparent;
  color: #d7d5e0;
  text-decoration: underline;
  text-underline-offset: 4px;
  padding: 6px;
}
.panel {
  background: linear-gradient(140deg, #15213bf2, #172840f7);
  border: 1px solid #f4d39d44;
  border-radius: 24px;
  padding: 28px 22px;
  box-shadow: 0 20px 80px #0008;
  backdrop-filter: blur(10px);
}
.compact {
  inset: 24% 24px auto;
  padding: 30px 24px;
}
.compact small {
  display: block;
  margin: 16px;
  color: #bec6d9;
}
.characters {
  display: flex;
  gap: 12px;
  margin: 10px 0;
}
.characters button {
  width: 50%;
  border: 2px solid transparent;
  border-radius: 18px;
  background: #ffffff08;
  overflow: hidden;
  padding: 0 0 10px;
}
.characters .selected {
  border-color: var(--gold);
  background: #ffce7618;
}
.portrait {
  height: 165px;
  width: 110px;
  margin: auto;
  background-size: 880px 660px;
  background-repeat: no-repeat;
}
.portrait.boy {
  background-image: url(assets/boy.webp);
}
.portrait.girl {
  background-image: url(assets/girl.webp);
}
label {
  display: block;
  text-align: left;
  font-size: 14px;
  margin: 12px 0 6px;
}
input {
  display: block;
  background: #0a1429;
  color: #fff;
  border: 1px solid #7b8293;
  border-radius: 10px;
  padding: 12px;
  width: 100%;
  font-size: 16px;
}
input[type="checkbox"] {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  accent-color: var(--gold);
}
.check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 12px;
}
.check input {
  margin-top: 3px;
}
form small {
  display: block;
  font-size: 11px;
  text-align: left;
  color: #c7cbd6;
  margin-top: 6px;
}
.note {
  font-size: 12px;
  color: var(--gold);
  margin: 15px 0;
}
#hud {
  position: absolute;
  top: 65px;
  left: 20px;
  right: 20px;
  z-index: 3;
  display: flex;
  justify-content: space-between;
  background: #101b36d9;
  border: 1px solid #ffffff20;
  padding: 12px 16px;
  border-radius: 15px;
  pointer-events: none;
}
#hud small {
  display: block;
  font-size: 9px;
  letter-spacing: 1px;
  color: #c4cddd;
}
#hud b {
  font-family: Festa;
  font-size: 22px;
}
.hud-center {
  text-align: center;
}
.hud-center b {
  font-size: 13px !important;
  color: var(--gold);
}
progress {
  position: absolute;
  bottom: -5px;
  left: 10px;
  width: calc(100% - 20px);
  height: 5px;
  appearance: none;
  border: 0;
  border-radius: 9px;
  overflow: hidden;
}
progress::-webkit-progress-bar {
  background: #3c4660;
}
progress::-webkit-progress-value {
  background: var(--gold);
}
#game-controls {
  position: absolute;
  bottom: max(14px, env(safe-area-inset-bottom));
  left: 20px;
  right: 20px;
  z-index: 3;
  pointer-events: none;
}
#instruction {
  text-align: center;
  background: #101b36d9;
  border-radius: 10px;
  padding: 9px;
  font-size: 13px;
  min-height: 38px;
  margin-bottom: 10px;
}
#pads {
  display: flex;
  gap: 8px;
  justify-content: center;
}
#pads button {
  pointer-events: auto;
  min-width: 60px;
  flex: 1;
  max-width: 140px;
  min-height: 65px;
  border-radius: 14px;
  border: 1px solid #ffffff44;
  background: #293d5a;
  box-shadow: 0 4px 0 #091025;
  position: relative;
  font-size: 12px;
}
#pads img {
  width: 42px;
  height: 42px;
  object-fit: contain;
  display: block;
  margin: auto;
}
#pads button.lit {
  background: var(--gold);
  color: #101b36;
  box-shadow: 0 0 28px #ffce76aa;
}
.pause {
  pointer-events: auto;
  display: block;
  margin: 10px auto 0;
  background: #101b36bb;
  border-radius: 20px;
  padding: 6px 20px;
  font-size: 11px;
}
.big-score {
  font-family: Festa;
  font-size: 70px;
  color: var(--gold);
  line-height: 1;
}
#final-ranking,
#save-status {
  font-size: 13px;
  margin: 12px 0;
}
.cta {
  border-top: 1px solid #ffce7655;
  margin-top: 25px;
  padding-top: 22px;
}
.cta p {
  font-size: 13px;
}
.cta button {
  font-size: 14px;
}
dialog {
  width: min(92vw, 510px);
  max-height: 88svh;
  border: 1px solid #ffce7666;
  border-radius: 24px;
  background: #15233d;
  color: var(--cream);
  padding: 32px 24px;
  box-shadow: 0 30px 80px #000a;
}
dialog::backdrop {
  background: #050b1bcc;
  backdrop-filter: blur(6px);
}
dialog h2 {
  font-size: 30px;
  padding-right: 15px;
}
dialog p {
  font-size: 14px;
}
dialog small {
  color: #b5bfd2;
}
dialog .close {
  position: absolute;
  right: 12px;
  top: 8px;
  background: none;
  font-size: 30px;
}
dialog a {
  color: var(--gold);
}
.tabs {
  display: flex;
  gap: 8px;
  margin: 15px 0;
}
.tabs button {
  background: #2c3c58;
  border-radius: 10px;
  padding: 10px;
}
.tabs .active {
  background: var(--gold);
  color: var(--navy);
}
.rank-row {
  display: grid;
  grid-template-columns: 30px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid #ffffff20;
}
.rank-row b {
  color: var(--gold);
}
.rank-row small {
  display: block;
  font-size: 11px;
}
.empty {
  padding: 30px 0;
  text-align: center;
}
.secret {
  font-family: monospace;
  font-size: 17px;
  overflow-wrap: anywhere;
  padding: 20px;
  background: #0a1429;
  border: 1px dashed var(--gold);
  border-radius: 12px;
  user-select: all;
}
.rules-copy h3 {
  font-size: 18px;
  margin-top: 22px;
}
.rules-copy p {
  font-size: 13px;
}
.admin-row {
  padding: 12px 0;
  border-bottom: 1px solid #ffffff30;
  font-size: 13px;
  overflow-wrap: anywhere;
}
.admin-row button {
  background: #673a4e;
  border-radius: 8px;
  padding: 6px;
  margin: 6px;
}
.admin-row select {
  max-width: 100%;
  padding: 8px;
  background: #15233d;
  color: white;
}
#toast {
  position: absolute;
  top: 150px;
  left: 10%;
  width: 80%;
  z-index: 9;
  text-align: center;
  padding: 12px 16px;
  border-radius: 12px;
  background: #fff1d4;
  color: #15233d;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  font-size: 14px;
}
#toast.show {
  opacity: 1;
}
.podium {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin: 20px 0;
}
.podium div {
  flex: 1;
  background: #ffce7614;
  padding: 18px 5px;
  text-align: center;
  border-top: 3px solid var(--gold);
  border-radius: 12px;
  font-size: 12px;
}
.podium b {
  display: block;
  font-size: 24px;
  color: var(--gold);
}
@media (max-height: 720px) {
  h1 {
    font-size: 58px;
  }
  .eyebrow {
    margin: 12px 0 8px;
  }
  .intro-copy {
    margin-top: 12px;
  }
  .screen {
    inset: 62px 18px 8px;
  }
  .panel {
    padding: 20px 18px;
  }
  .characters .portrait {
    height: 125px;
    width: 84px;
    background-size: 672px 504px;
  }
  .compact {
    inset: 20% 20px auto;
  }
  .prizes {
    padding: 8px;
  }
  .primary {
    padding: 12px;
  }
  nav {
    margin: 10px 0 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto;
    transition: none !important;
  }
}
.brand img {
  background: #67318e;
  max-height: 50px;
  width: 150px;
  padding: 5px;
}
.screen {
  overflow-x: hidden;
}
.home-bottom {
  padding: 0 2px 5px;
}
.portrait {
  background-image: none !important;
  height: 165px;
  width: 130px;
  background-size: contain !important;
  background-position: center;
}
.portrait.boy {
  background-image: url(assets/boy-portrait.webp) !important;
}
.portrait.girl {
  background-image: url(assets/girl-portrait.webp) !important;
}

#stage {
  object-fit: fill;
}
.vignette {
  background: linear-gradient(
    #101b3633,
    transparent 30%,
    #101b3633 65%,
    #101b36dc
  );
}
@keyframes enter-screen {
  from {
    opacity: 0;
    translate: 0 12px;
  }
  to {
    opacity: 1;
    translate: 0 0;
  }
}
.screen:not([hidden]) {
  animation: enter-screen 0.32s ease-out;
}
@media (prefers-reduced-motion: reduce) {
  .screen:not([hidden]) {
    animation: none;
  }
}

/* Preserve the castle lighting; shade only behind the title and bottom controls. */
#app:has(#home:not([hidden])) .vignette {
  background: linear-gradient(#08132999 0%, #08132925 24%, transparent 38%, #08132915 62%, #081329e8 85%, #081329 100%);
}
/* Keep the full campaign and individual practice reachable on small screens. */
#choose { overflow-y:auto; padding-bottom:24px; }
select { display:block; width:100%; min-height:44px; padding:10px 14px; margin:6px 0 12px; border:1px solid #65728a; border-radius:12px; color:#fff1d4; background:#16223c; font:inherit; }
select:disabled { opacity:.6; }
#choose .characters { margin:8px 0; }
#choose .characters .portrait { height:100px; }
@media (max-width:480px) {
  #choose { padding:20px 22px; }
  #choose h2 { font-size:32px; margin:8px 0 12px; }
  #choose .eyebrow { margin:8px 0; }
}
/* Keep pointer coordinates aligned with the complete canvas at every aspect ratio. */
#stage { object-fit:fill; }

/* HUD and live messages share normal flow, including narrow/short phones. */
#play-messages { position:absolute; top:calc(62px + env(safe-area-inset-top)); left:12px; right:12px; z-index:3; display:grid; gap:7px; pointer-events:none; }
#play-messages #hud { position:relative; inset:auto; padding:8px 12px; min-width:0; }
#round-status, #play-notice { margin:0; padding:6px 10px; border-radius:10px; background:#101b36ed; color:var(--gold); font-size:13px; line-height:1.3; text-align:center; overflow-wrap:anywhere; }
#play-notice { background:var(--cream); color:var(--navy); }
.hud-center { min-width:0; padding:0 8px; }
@media(max-width:380px), (max-height:650px) { #play-messages { gap:5px; } #hud b { font-size:19px; } #hud small { letter-spacing:.4px; } #round-status, #play-notice { font-size:12px; padding:5px 8px; } }

/* Keep instructions out of the arena, and reserve a real touch-control dock. */
#play-messages #instruction { margin:0; min-height:0; padding:5px 10px; font-size:12px; line-height:1.3; }
#instruction:empty, #round-status:empty { display:none; }
#app.is-playing #stage { top:var(--arena-top,205px); bottom:auto; height:calc(100% - var(--arena-top,205px) - var(--arena-bottom,110px)); }
#app.is-playing .vignette { display:none; }
#game-controls { bottom:max(8px,env(safe-area-inset-bottom)); left:12px; right:12px; }
#pads button { touch-action:manipulation; min-width:0; min-height:60px; }
#pads img { width:32px; height:32px; }
.pause { min-height:44px; margin:6px auto 0; padding:8px 22px; }
@media(max-height:650px) {
 #pads button { min-height:48px; }
 #pads img { width:24px; height:24px; }
 #play-messages { top:54px; gap:3px; }
 #play-messages #hud { padding:4px 9px; }
 #play-messages #instruction { font-size:11px; padding:3px 6px; }
 #round-status, #play-notice { padding:3px 6px; font-size:11px; }
}
/* Long explanations remain scrollable, including on compact phones. */
#level-intro { max-height:calc(76% - 16px); overflow-y:auto; }
@media(max-height:650px) {
 #level-intro { top:64px; max-height:calc(100% - 76px); padding:18px; }
 #level-intro h2 { font-size:30px; margin:10px 0 16px; }
 #level-intro p { font-size:14px; line-height:1.45; }
 #level-intro small { margin:12px 0; font-size:13px; }
}
/* Full original 480×800 scene: overlays never resize or crop the canvas. */
#app.is-playing { width:min(100%,60svh); max-width:none; height:min(100svh,166.666667vw); min-height:0; }
#app.is-playing #stage { inset:0; width:100%; height:100%; object-fit:contain; }
#app.is-playing #play-messages { top:52px; left:8px; right:8px; height:auto; display:grid; grid-template-rows:42px 20px; gap:3px; }
#app.is-playing #hud { height:42px; padding:4px 8px; }
#app.is-playing #hud b { font-size:18px; }
#app.is-playing #round-status { padding:2px 6px; font-size:11px; line-height:16px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
#app.is-playing #instruction { display:none; }
#app.is-playing #play-notice { position:absolute; top:68px; left:0; right:0; margin:0; padding:5px 8px; font-size:12px; line-height:1.25; border-radius:8px; background:#fff1d4ee; }
#app.is-playing #game-controls { bottom:max(4px,env(safe-area-inset-bottom)); left:8px; right:8px; }
#app.is-playing #pads button { min-height:44px; padding:5px; }
#app.is-playing #pads img { width:24px; height:24px; }
#app.is-playing .pause { min-height:32px; margin:3px auto 0; padding:4px 16px; }
@media(max-height:500px) {
 #app.is-playing header { padding:4px 8px; }
 #app.is-playing #play-messages { top:40px; }
 #app.is-playing .wordmark { display:none; }
}
