@import url("https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=Space+Grotesk:wght@400;500;600;700&display=swap");

:root {
  color-scheme: light;
  --page: #ffffff;
  --panel: #ffffff;
  --panel-raised: #f5f5f5;
  --stroke: #d7d7d7;
  --muted: #666666;
  --text: #111111;
  --lime: #111111;
  --orange: #111111;
  --mono: "DM Mono", Consolas, monospace;
  --sans: "Space Grotesk", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: var(--page);
  color: var(--text);
  font-family: var(--sans);
}

button, input, textarea { font: inherit; }
button { color: inherit; }

.app { width: min(1320px, calc(100% - 64px)); margin: 0 auto; }
.topbar { height: 76px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--stroke); }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); font-size: 15px; font-weight: 700; letter-spacing: 0.09em; text-decoration: none; }
.brand-mark { display: grid; width: 30px; height: 30px; place-items: center; color: #ffffff; background: #111111; border-radius: 9px; font-size: 17px; }
.brand-light { color: var(--lime); font-weight: 400; }
.eyebrow, .hud-label, .key-hint, .record-kicker { font-family: var(--mono); letter-spacing: 0.08em; }
.eyebrow { margin: 0 0 9px; color: var(--lime); font-size: 10px; }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; align-items: start; gap: 18px; }
.game-card, .leaderboard-card { overflow: hidden; background: var(--panel); border: 1px solid var(--stroke); border-radius: 14px; box-shadow: 0 12px 36px rgba(0, 0, 0, 0.07); }
.hud { display: flex; align-items: center; gap: 32px; padding: 12px 19px; background: #ffffff; border-bottom: 1px solid var(--stroke); }
.hud-stat { display: flex; flex-direction: column; gap: 4px; min-width: 68px; }
.hud-label { color: var(--muted); font-size: 9px; text-transform: uppercase; }
.hud-stat strong { font-family: var(--mono); font-size: 17px; font-weight: 500; letter-spacing: 0.04em; font-variant-numeric: tabular-nums; }
.canvas-wrap { position: relative; overflow: hidden; background: #ffffff; }
#gameCanvas { display: block; width: 100%; height: auto; aspect-ratio: 45 / 28; }
.overlay { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; background: rgba(255, 255, 255, 0.82); backdrop-filter: blur(4px); transition: opacity 180ms ease; }
.overlay:not(.visible) { visibility: hidden; opacity: 0; pointer-events: none; }
.overlay-content { width: min(430px, 100%); text-align: center; }
.overlay .eyebrow { margin-bottom: 12px; }
.overlay h2 { margin: 0 0 10px; font-size: clamp(28px, 4vw, 42px); letter-spacing: -0.04em; }
.overlay-content > p:not(.eyebrow):not(.key-hint) { max-width: 370px; margin: 0 auto 20px; color: #444444; font-size: 14px; line-height: 1.6; }
.primary-button { display: inline-flex; align-items: center; justify-content: center; gap: 22px; min-height: 44px; padding: 0 19px; border: 1px solid #111111; border-radius: 8px; background: #ffffff; color: #111111; font-size: 13px; font-weight: 700; cursor: pointer; transition: transform 120ms ease, filter 120ms ease; }
.primary-button:hover { filter: brightness(1.08); transform: translateY(-1px); }
.primary-button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--lime); outline-offset: 3px; }
.primary-button span { font-size: 17px; }
.key-hint { margin: 20px 0 0; color: #555555; font-size: 9px; }
.key-hint span { padding: 0 6px; color: var(--lime); }

.leaderboard-card { padding: 19px 17px 0; }
.leaderboard-heading { display: flex; align-items: center; justify-content: space-between; padding-bottom: 13px; border-bottom: 1px solid var(--stroke); }
.leaderboard-heading h2 { margin: 0; font-size: 17px; letter-spacing: -0.025em; }
.leaderboard-instructions { margin: 12px 0 0; color: #444444; font-size: 11px; line-height: 1.5; }
.leaderboard-status { min-height: 34px; margin: 12px 0 4px; color: #555555; font-size: 11px; line-height: 1.5; }
.leaderboard-list { display: flex; flex-direction: column; gap: 7px; min-height: 160px; margin: 8px 0 18px; padding: 0; list-style: none; }
.leaderboard-entry { padding: 10px 11px; background: #f5f5f5; border: 1px solid #dddddd; border-radius: 8px; }
.entry-topline { display: flex; align-items: center; gap: 8px; }
.entry-rank { width: 20px; color: #666666; font-family: var(--mono); font-size: 10px; }
.entry-rank.top-rank { color: var(--lime); }
.entry-name { overflow: hidden; flex: 1; color: #111111; font-size: 12px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.entry-score { color: var(--lime); font-family: var(--mono); font-size: 12px; }
.entry-message { overflow-wrap: anywhere; margin: 7px 0 0 28px; color: #555555; font-size: 11px; line-height: 1.45; }
.leaderboard-empty { display: grid; min-height: 150px; place-items: center; color: #555555; font-size: 12px; text-align: center; }
.record-form-wrap { margin: 0 -17px; padding: 16px 17px; background: #f5f5f5; border-top: 1px solid #dddddd; }
.record-form-wrap[hidden] { display: none; }
.record-kicker { margin: 0 0 5px; color: var(--lime); font-size: 9px; }
.record-copy { margin: 0 0 13px; color: #444444; font-size: 12px; line-height: 1.45; }
#recordForm { display: flex; flex-direction: column; gap: 7px; }
#recordForm label { margin-top: 3px; color: #222222; font-size: 10px; }
#recordForm label span { color: #666666; }
#recordForm input, #recordForm textarea { width: 100%; resize: vertical; padding: 9px 10px; border: 1px solid #cccccc; border-radius: 7px; background: #ffffff; color: var(--text); font-size: 12px; }
#recordForm input::placeholder, #recordForm textarea::placeholder { color: #777777; }
.submit-button { width: 100%; min-height: 38px; margin-top: 5px; font-size: 11px; }
.submit-status { min-height: 14px; margin: 0; color: #555555; font-size: 10px; line-height: 1.4; }

@media (max-width: 900px) {
  .app { width: min(100% - 36px, 720px); }
  .layout { grid-template-columns: 1fr; }
  .leaderboard-card { display: grid; grid-template-columns: 1fr; }
  .leaderboard-list { min-height: 80px; }
}

@media (max-width: 540px) {
  .app { width: calc(100% - 24px); }
  .topbar { height: 62px; }
  .hud { gap: 12px; padding: 10px 12px; }
  .hud-stat { min-width: 55px; }
  .hud-stat strong { font-size: 15px; }
  .overlay { padding: 16px; }
  .overlay-content > p:not(.eyebrow):not(.key-hint) { font-size: 12px; }
  .key-hint { font-size: 8px; }
}
