/* ============ PERFORATOR ============ */
:root { color-scheme: dark; }

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  display: flex; align-items: center; justify-content: center;
  background-color: #0c0e11;
  background-image: repeating-linear-gradient(135deg, rgba(255,179,0,.03) 0 24px, transparent 24px 48px);
  font-family: 'Segoe UI', system-ui, sans-serif;
  overflow: hidden;
}

.sr-only {
  position: absolute; width: 1px; height: 1px;
  clip: rect(0 0 0 0); overflow: hidden; white-space: nowrap;
}

/* ---- stage ---- */
#stage {
  position: relative;
  height: min(97vh, 126vw, 980px);
  aspect-ratio: 3 / 4;
  background: #000;
  border: 2px solid #2c313a;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0,0,0,.65);
}
#game {
  position: absolute; inset: 0; width: 100%; height: 100%;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
}
#stage::after { /* vignette */
  content: ''; position: absolute; inset: 0; z-index: 4; pointer-events: none;
  background: radial-gradient(ellipse at 50% 45%, transparent 55%, rgba(0,0,0,.5) 100%);
}

/* ---- HUD ---- */
#hud {
  position: absolute; inset: 0; z-index: 5; pointer-events: none;
  font-family: Consolas, 'Courier New', monospace; color: #e8ecf2;
}
body:not(.playing) #hud { display: none; }

#depth-box { position: absolute; top: 10px; left: 12px; text-shadow: 0 2px 0 #000; }
#depth { font-size: 30px; font-weight: 700; color: #ffd34d; line-height: 1; }
.unit { font-size: 14px; color: #b0a35c; margin-left: 4px; }
#layer { font-size: 10px; letter-spacing: .08em; color: #9aa3af; margin-top: 4px; text-transform: uppercase; }
#hud-best { font-size: 10px; color: #6d7681; margin-top: 2px; }

#top-right { position: absolute; top: 10px; right: 12px; text-align: right; }
#ping-box {
  display: flex; gap: 6px; justify-content: flex-end; align-items: center;
  font-size: 12px; color: #c6ccd4; text-shadow: 0 2px 0 #000;
}
#ping-dot { width: 8px; height: 8px; border-radius: 50%; background: #555c66; }
#ping-dot.good { background: #43d17a; box-shadow: 0 0 8px #43d17a; }
#ping-dot.mid  { background: #ffb300; box-shadow: 0 0 8px #ffb300; }
#ping-dot.bad  { background: #e5484d; box-shadow: 0 0 8px #e5484d; }

#hud-btns { margin-top: 8px; display: flex; gap: 6px; justify-content: flex-end; pointer-events: auto; }
#hud-btns button {
  font: 700 13px Consolas, monospace;
  width: 34px; height: 30px; cursor: pointer;
  background: rgba(20,24,30,.8); border: 1px solid #3a4250; color: #e8ecf2; border-radius: 6px;
}
#hud-btns button:hover { background: #ffb300; color: #14181d; }

#heat-box {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 12px;
  width: 44%; text-align: center;
}
#heat-label { font-size: 9px; letter-spacing: .2em; color: #8b929c; margin-bottom: 3px; }
#heat-bar { height: 10px; border: 2px solid #3a4250; background: #14181d; border-radius: 4px; overflow: hidden; }
#heat-fill { height: 100%; width: 0%; background: linear-gradient(90deg, #ffb300, #ff7a1a); }
#heat-box.over #heat-fill { background: #e5484d; animation: blink .4s steps(2) infinite; }
#heat-box.over #heat-label { color: #e5484d; }
@keyframes blink { 50% { opacity: .4; } }

/* ---- layer banner ---- */
#banner {
  position: absolute; top: 16%; left: 0; right: 0; z-index: 6; pointer-events: none;
  text-align: center;
  font: 700 15px Consolas, 'Courier New', monospace; letter-spacing: .25em;
  color: #ffd34d; text-shadow: 0 0 12px rgba(255,180,0,.5), 0 2px 0 #000;
  opacity: 0; transform: translateY(-8px); transition: opacity .35s, transform .35s;
}
#banner.show { opacity: 1; transform: none; }

/* ---- touch controls ---- */
#tc {
  position: absolute; left: 10px; right: 10px; bottom: 34px; z-index: 8;
  display: none; justify-content: space-between; align-items: center; pointer-events: none;
}
.tc-group { display: flex; gap: 10px; pointer-events: auto; }
#tc-boost { pointer-events: auto; }
#tc button {
  font: 700 20px Consolas, monospace;
  padding: 16px 20px; border-radius: 12px;
  background: rgba(20,24,30,.65); border: 2px solid #3a4250; color: #e8ecf2;
  touch-action: none; user-select: none; -webkit-user-select: none;
}
#tc button:active { background: #ffb300; color: #14181d; }
@media (pointer: coarse) {
  body.playing #tc { display: flex; }
}

/* ---- overlays ---- */
.overlay {
  position: absolute; inset: 0; z-index: 10;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: 24px; text-align: center;
  background: rgba(7,9,12,.86); color: #dfe5ec;
}
.hidden { display: none !important; }

.title {
  font-size: clamp(26px, 8vh, 50px); font-weight: 900; letter-spacing: .14em;
  color: #ffb300;
  text-shadow: 0 3px 0 #7a5500, 0 6px 0 rgba(0,0,0,.6), 0 0 30px rgba(255,179,0,.35);
}
.title.small {
  font-size: clamp(17px, 4.5vh, 27px); letter-spacing: .22em;
  color: #e8ecf2; text-shadow: 0 2px 0 #000;
}
.hazard {
  width: 58%; max-width: 300px; height: 8px; border-radius: 2px;
  background: repeating-linear-gradient(45deg, #ffb300 0 12px, #15181d 12px 24px);
  box-shadow: 0 0 0 2px #15181d;
}
.tagline { color: #aeb6c0; font-size: 14px; line-height: 1.55; }
.menu-stats { display: flex; flex-direction: column; gap: 3px; font: 12px Consolas, monospace; color: #8b929c; }

.btn {
  font: 700 14px 'Segoe UI', sans-serif; letter-spacing: .08em; text-transform: uppercase;
  padding: 10px 20px; cursor: pointer;
  background: #1c2128; border: 2px solid #3a4250; color: #e8ecf2; border-radius: 8px;
  transition: background .12s, color .12s, border-color .12s;
}
.btn:hover, .btn:focus-visible { background: #ffb300; border-color: #ffb300; color: #14181d; outline: none; }
.btn-primary { background: #ffb300; border-color: #ffb300; color: #14181d; font-size: 16px; padding: 12px 26px; }
.btn-primary:hover, .btn-primary:focus-visible { background: #ffc63d; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

.help { font: 11px Consolas, monospace; color: #6d7681; line-height: 1.7; }
.foot { font: 10px Consolas, monospace; color: #494f58; letter-spacing: .1em; }

.big-score {
  font: 700 clamp(40px, 10vh, 62px) Consolas, monospace;
  color: #ffd34d; text-shadow: 0 3px 0 #000; line-height: 1;
}
#go-cause { font: 12px Consolas, monospace; color: #ff9d5c; max-width: 85%; }
.newrec { color: #43d17a; font-weight: 800; letter-spacing: .2em; animation: blink 1s steps(2) infinite; }

.record-row { display: flex; gap: 8px; align-items: center; font: 700 13px Consolas, monospace; letter-spacing: .1em; }
#name-input {
  width: 12ch; font: 700 18px Consolas, monospace; letter-spacing: .12em;
  text-transform: uppercase; text-align: center;
  background: #101317; border: 2px solid #ffb300; color: #ffd34d;
  padding: 8px 10px; border-radius: 6px; outline: none;
}
#name-input:focus { box-shadow: 0 0 0 3px rgba(255,179,0,.3); }

#board-list { list-style: none; width: min(86%, 360px); display: flex; flex-direction: column; gap: 4px; font: 13px Consolas, monospace; }
#board-list li { display: flex; gap: 10px; padding: 7px 10px; background: #141920; border: 1px solid #262c36; border-radius: 6px; }
#board-list .rk { color: #8b929c; width: 2ch; text-align: right; }
#board-list .nm { flex: 1; text-align: left; color: #e8ecf2; font-weight: 700; letter-spacing: .08em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#board-list .sc { color: #ffd34d; font-weight: 700; }
#board-list li.me { border-color: #ffb300; background: #1d1a10; }
#board-note { font: 10px Consolas, monospace; color: #6d7681; letter-spacing: .08em; min-height: 12px; }
#board-empty { color: #8b929c; font-size: 13px; }
