:root {
  color-scheme: dark;
  --bg: #080d17;
  --ink: #e8f4f5;
  --cyan: #77e5e0;
  --orange: #ffcb76;
  --pink: #ff748c;
}
* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: #04060b; }
body { display: flex; justify-content: center; align-items: center; font-family: 'Trebuchet MS', 'Segoe UI', Arial, sans-serif; }
button { font: inherit; cursor: pointer; }
#stage { position: relative; overflow: hidden; width: 100vw; height: 56.25vw; max-height: 100vh; max-width: 177.7778vh; background: var(--bg); user-select: none; touch-action: none; }
#game { display: block; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
#top-controls { position: absolute; top: 2.4%; right: 2%; display: flex; gap: 7px; z-index: 6; }
.small-btn { color: #bcd5dc; border: 1px solid #3a5969; background: #101d2be5; padding: 10px 14px; min-width: 100px; font-weight: 800; font-size: clamp(8px, .78vw, 15px); letter-spacing: .1em; transition: background .15s, border-color .15s; }
.small-btn:hover, .small-btn:focus-visible { color: white; border-color: var(--cyan); background: #1d3948; }
.overlay { position: absolute; inset: 0; z-index: 5; display: flex; align-items: center; justify-content: center; background: #050b13c4; backdrop-filter: blur(6px); }
.overlay.hidden { display: none; }
.panel { position: relative; width: min(790px, 80%); max-height: 94%; padding: clamp(20px, 3.1vw, 52px) clamp(25px, 3.2vw, 60px) clamp(18px, 2vw, 36px); background: linear-gradient(150deg, #182936f5, #0b121df9 66%, #12212cf5); border: 1px solid #5d8492; box-shadow: 0 0 0 8px #09131a99, 0 25px 100px #000c; overflow-y: auto; text-align: left; }
.panel::before, .panel::after { content: ''; position: absolute; width: 34px; height: 34px; pointer-events: none; }
.panel::before { left: 0; top: 0; border-top: 4px solid var(--cyan); border-left: 4px solid var(--cyan); }
.panel::after { right: 0; bottom: 0; border-bottom: 4px solid var(--orange); border-right: 4px solid var(--orange); }
.overline { font-family: Consolas, 'Liberation Mono', monospace; font-size: clamp(10px, .85vw, 15px); letter-spacing: .24em; color: var(--cyan); font-weight: 700; }
h1 { margin: 16px 0 6px; line-height: .9; font-weight: 1000; font-size: clamp(45px, 5vw, 93px); letter-spacing: -.065em; color: #f1f5f2; text-shadow: 0 5px 0 #294651; }
h1 span { color: var(--orange); }
.tagline { margin: 20px 0 22px; font-weight: 900; letter-spacing: .18em; font-size: clamp(11px, 1vw, 18px); color: var(--cyan); }
#panel-body { color: #c4d4d8; line-height: 1.5; font-size: clamp(12px, .95vw, 17px); }
#panel-body p { margin: 0 0 13px; }
#panel-body strong { color: #fff6d3; }
#panel-body .warning { color: #ffadb6; }
.main-btn { width: 100%; display: flex; justify-content: space-between; align-items: center; padding: 17px 24px; margin-top: 24px; background: #f8c77b; color: #12222b; font-weight: 1000; font-size: clamp(14px, 1.3vw, 24px); letter-spacing: .12em; border: 0; box-shadow: 6px 6px 0 #6a432e; text-align: left; }
.main-btn:hover, .main-btn:focus-visible { background: #ffe0a5; transform: translateY(-1px); }
#secondary-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; margin-top: 26px; color: #829eac; font-family: Consolas, 'Liberation Mono', monospace; font-size: clamp(9px, .7vw, 13px); letter-spacing: .05em; }
.leaderboard { margin-top: 20px; font: clamp(10px, .78vw, 14px) Consolas, 'Liberation Mono', monospace; color: #a5c5cf; }
.leaderboard .leader-title { border-bottom: 1px solid #32505c; padding-bottom: 5px; margin-bottom: 8px; color: #d4e0e3; font-weight: 700; letter-spacing: .15em; }
.leaderboard .scores { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 25px; }
.leaderboard .rank { color: var(--orange); }
#gameover-entry { margin-top: 20px; display: flex; align-items: center; gap: 15px; flex-wrap: wrap; }
#gameover-entry label { color: var(--cyan); font-weight: 800; letter-spacing: .1em; font-size: 13px; }
#initials { max-width: 115px; background: #07121b; border: 1px solid var(--cyan); color: white; font: 700 24px Consolas, monospace; letter-spacing: .25em; padding: 8px; text-align: center; text-transform: uppercase; }
.hidden { display: none !important; }
.toast { position: absolute; z-index: 9; left: 50%; top: 14%; transform: translateX(-50%); color: white; background: #122331ee; border: 1px solid #577683; padding: 12px 20px; font: bold 16px Consolas, monospace; opacity: 0; transition: opacity .25s; pointer-events: none; }
.toast.show { opacity: 1; }
@media(max-width: 900px) {
  .small-btn { min-width: initial; padding: 6px 8px; font-size: 8px; }
  .panel { width: 87%; padding: 15px 23px; }
  .tagline { margin: 10px 0 12px; }
  #panel-body { line-height: 1.33; }
  #panel-body p { margin-bottom: 7px; }
  .main-btn { padding: 9px 13px; margin-top: 13px; }
  #secondary-row { margin-top: 12px; }
  .leaderboard { margin-top: 10px; }
}

/* Two independent scoreboards, worldwide and local, on the menu/game-over panel. */
.leaderboard .leader-title:not(:first-child) { margin-top: 16px; }
.leaderboard .online-status { padding: 7px 0 11px; color: var(--orange); font-size: .94em; letter-spacing: .05em; }
.leaderboard .leader-empty { color: #839caa; margin: 4px 0 10px; }
