@font-face {
  font-family: BeluzitoPixel;
  src: url('/assets/pixel.ttf') format('truetype');
  font-display: swap;
}

:root {
  color-scheme: dark;
  --navy: #07172f;
  --navy-deep: #04142d;
  --panel: #0b2f60;
  --inset: #123d72;
  --blue: #1466b5;
  --border: #4a83b6;
  --gold: #ffd447;
  --gold-deep: #d9aa24;
  --celeste: #82c9f0;
  --paper: #fff2d2;
  --pixel: BeluzitoPixel, monospace;
  font-family: var(--pixel);
  color: var(--paper);
  background: var(--navy);
  font-size: 17px;
}

* { box-sizing: border-box; }
html { min-width: 320px; min-height: 100%; }
body {
  position: relative;
  isolation: isolate;
  min-width: 320px;
  min-height: 100svh;
  margin: 0;
  overflow-x: hidden;
  background: var(--navy) url('/assets/beluzito-loading-background.png') center / cover fixed;
  font: 17px/1.55 var(--pixel);
}
body::before { position: fixed; z-index: -1; inset: 0; content: ''; background: #07172fba; pointer-events: none; }
a { color: inherit; text-decoration: none; }
button { color: inherit; font: inherit; }
a:focus-visible, button:focus-visible { outline: 4px solid var(--celeste); outline-offset: 4px; }

.arena, .site-footer { position: relative; z-index: 1; width: min(1080px, calc(100% - 48px)); margin-inline: auto; }

.arena { display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(320px, .92fr); align-items: start; gap: 24px; padding-block: clamp(18px, 5vh, 56px); }
.play-panel, .ranking-panel {
  border: 3px solid var(--border);
  border-bottom: 8px solid var(--navy-deep);
  border-radius: 7px;
  background: var(--panel);
  box-shadow: inset 0 0 0 5px var(--navy);
}
.play-panel { min-height: min(660px, calc(100svh - 48px)); display: flex; flex-direction: column; align-items: center; justify-content: flex-start; padding: clamp(26px, 4vw, 44px); text-align: center; }
h1 { max-width: 11ch; margin: 0; color: var(--gold); font-size: clamp(32px, 4.6vw, 55px); line-height: 1.17; text-wrap: balance; text-shadow: 3px 4px var(--navy-deep); }
.subtitle { margin: 2px 0 0; color: var(--celeste); font-size: clamp(16px, 2vw, 21px); }
.showcase-stage { position: relative; isolation: isolate; width: min(100%, 480px); height: clamp(208px, 28vw, 300px); margin: 3px auto 10px; }
.showcase-fallback, #card-showcase { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
.showcase-fallback { object-fit: contain; image-rendering: pixelated; transition: opacity 140ms ease; }
#card-showcase { opacity: 0; touch-action: pan-y; cursor: grab; }
#card-showcase:active { cursor: grabbing; }
body.showcase-ready #card-showcase { opacity: 1; }
body.showcase-ready .showcase-fallback { opacity: 0; }
.timba-panel { grid-column: 1 / -1; width: min(100%, 680px); min-height: 0; justify-self: center; }
.timba-head { width: clamp(88px, 12vw, 132px); height: clamp(88px, 12vw, 132px); object-fit: contain; image-rendering: pixelated; margin-bottom: 12px; }
.timba-note { margin: 15px 0 22px; color: var(--paper); }
.timba-back { margin: 18px 0 0; color: var(--celeste); }
.play-button { width: min(100%, 420px); min-height: 88px; display: grid; place-items: center; padding: 16px 22px; border: 3px solid #ffe477; border-bottom: 10px solid var(--gold-deep); border-radius: 6px; background: var(--gold); color: var(--navy-deep); font-size: clamp(26px, 3.6vw, 38px); line-height: 1; text-align: center; transition: filter 150ms ease, transform 100ms ease; }
.play-button:hover { filter: brightness(1.06); }
.play-button:active { transform: translateY(4px); border-bottom-width: 6px; }
.how-to { width: min(100%, 420px); margin-top: 18px; text-align: left; }
.how-to h2 { margin: 0 0 9px; color: var(--gold); font-size: 20px; line-height: 1.3; text-shadow: 2px 3px var(--navy-deep); }
.how-to ol { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; counter-reset: step; }
.how-to li { min-height: 42px; display: grid; grid-template-columns: 30px minmax(0, 1fr); align-items: center; gap: 8px; padding: 7px 10px; border-bottom: 3px solid var(--navy-deep); background: var(--inset); font-size: 14px; line-height: 1.35; counter-increment: step; }
.how-to li::before { content: counter(step); color: var(--gold); font-size: 18px; text-align: center; text-shadow: 1px 2px var(--navy-deep); }

.ranking-panel { align-self: start; padding: clamp(22px, 3vw, 36px); }
h2 { margin: 0; color: var(--gold); font-size: clamp(22px, 2.5vw, 30px); line-height: 1.25; text-wrap: balance; text-shadow: 2px 3px var(--navy-deep); }
#leaderboard { display: grid; align-content: start; margin: 0; padding: 0; list-style: none; }
.ranking-row { min-height: 54px; display: grid; grid-template-columns: 40px minmax(0, 1fr) max-content; align-items: center; gap: 11px; padding: 8px 10px; border-bottom: 3px solid var(--navy-deep); background: var(--inset); }
.ranking-row + .ranking-row { margin-top: 5px; }
.rank-position { color: var(--gold); text-align: center; }
.rank-name { overflow: hidden; color: var(--paper); text-overflow: ellipsis; white-space: nowrap; }
.rank-score { color: var(--celeste); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ranking-state { margin: 0; padding: 13px 12px; color: var(--paper); background: var(--inset); line-height: 1.5; }
.ranking-state.error { color: var(--gold); }
#ranking-retry { min-height: 48px; margin-top: 12px; padding: 8px 16px; border: 2px solid var(--border); border-bottom: 6px solid var(--navy-deep); border-radius: 5px; background: var(--blue); color: var(--paper); cursor: pointer; }
#ranking-retry:hover { background: #1c75c4; }

.site-footer { padding: 8px 0 28px; color: var(--paper); font-size: 14px; text-align: center; }
.site-footer p { margin: 0; }

@media (max-width: 760px) {
  .arena, .site-footer { width: min(100% - 32px, 520px); }
  .arena { grid-template-columns: 1fr; gap: 16px; padding-block: 12px 20px; }
  .play-panel { min-height: 0; padding: 24px 22px; }
  .showcase-stage { height: 224px; margin: 0 auto 8px; }
  h1 { font-size: clamp(31px, 9vw, 42px); }
  .play-button { min-height: 76px; }
  .ranking-panel { padding: 21px 18px; }
  .site-footer { padding-block: 5px 22px; }
}

@media (max-width: 380px) {
  .arena, .site-footer { width: calc(100% - 24px); }
  .play-panel { padding-inline: 16px; }
  .showcase-stage { height: 202px; }
  .ranking-row { grid-template-columns: 30px minmax(0, 1fr) max-content; gap: 7px; padding-inline: 7px; font-size: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

[hidden] { display: none !important; }
