:root {
  --bg: #050806;
  --panel: #0c1612;
  --panel2: #101b16;
  --line: #23362e;
  --text: #edf4eb;
  --muted: #91a296;
  --lime: #a3ff43;
  --aqua: #56ffd0;
  --yellow: #ffe34e;
  --wall: #82918a;
  --wall-soft: #40534b;
  --font: ui-monospace, "SFMono-Regular", "IBM Plex Mono", "Roboto Mono", "Cascadia Mono", monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: radial-gradient(circle at 18% 12%, #102016 0, transparent 34%), radial-gradient(circle at 92% 0%, #0c302a 0, transparent 28%), var(--bg); color: var(--text); font-family: var(--font); }
button, input, select { font: inherit; }
button { cursor: pointer; border: 1px solid #244238; color: var(--text); background: #101a16; border-radius: 14px; padding: 12px 16px; font-weight: 900; letter-spacing: .02em; }
button:hover { border-color: #65c79c; }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: linear-gradient(90deg, #96ff45, #56ffd0); color: #06110d; border-color: transparent; box-shadow: 0 10px 28px rgba(86,255,208,.12); }
input, select { width: 100%; padding: 13px 14px; border: 1px solid #22352f; border-radius: 12px; background: #050908; color: var(--text); outline: none; }
input:focus, select:focus { border-color: #68d9b9; }
label { display: grid; gap: 9px; color: #b6c2bb; font-size: 12px; font-weight: 800; text-transform: lowercase; letter-spacing: .08em; }
.card { border: 1px solid #1d3a31; background: linear-gradient(180deg, rgba(16,28,23,.95), rgba(5,11,9,.95)); border-radius: 20px; box-shadow: 0 24px 60px rgba(0,0,0,.35); }
.shell { width: min(1600px, calc(100vw - 28px)); margin: 18px auto; }
.brand { width: 150px; height: auto; display: block; background: rgba(255,255,255,.04); padding: 6px; border-radius: 4px; }
.brand.large { width: min(430px, 72vw); margin: 0 auto; background: transparent; padding: 0; }
.home { width: min(1120px, 100%); margin: min(10vh, 90px) auto; padding: clamp(20px, 4vw, 44px); }
.home-head { text-align: center; margin-bottom: 28px; }
.home-head p { color: var(--muted); max-width: 740px; margin: 16px auto 0; line-height: 1.6; }
.home-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(290px, .65fr); gap: 18px; }
.panel { border: 1px solid #1d332b; background: rgba(4,10,8,.55); border-radius: 18px; padding: clamp(18px, 3vw, 32px); display: grid; gap: 20px; }
h1 { font-size: clamp(34px, 6.2vw, 76px); line-height: .96; margin: 0 0 10px; letter-spacing: -.07em; max-width: 720px; }
h2, h3 { margin: 0; color: var(--lime); text-transform: uppercase; font-size: 13px; letter-spacing: .28em; }
.note, .muted { color: var(--muted); line-height: 1.55; font-size: 13px; }
.swatches { display: flex; flex-wrap: wrap; gap: 12px; }
.swatch { --c: #fff; width: 46px; height: 46px; padding: 0; border-radius: 50%; background: var(--c); border: 3px solid rgba(255,255,255,.1); box-shadow: 0 0 22px color-mix(in srgb, var(--c) 42%, transparent); }
.swatch.selected { outline: 3px solid #fff; outline-offset: 3px; }
.actions.two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: stretch; }
.join-line { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.topbar { display: grid; grid-template-columns: auto 170px minmax(220px,1fr) 150px auto; align-items: center; gap: 12px; padding: 12px; }
.status-box { min-height: 58px; border: 1px solid #1d332d; background: #050b09; border-radius: 14px; padding: 10px 12px; display: grid; grid-template-columns: 1fr auto; column-gap: 10px; align-items: center; }
.status-box small { color: var(--lime); text-transform: uppercase; letter-spacing: .2em; font-size: 10px; grid-column: 1 / -1; }
.status-box b { font-size: 24px; letter-spacing: .08em; }
.status-box button { padding: 8px 10px; font-size: 12px; }
.status-box.timer b { color: var(--yellow); }
.play-layout { display: grid; grid-template-columns: minmax(0, 1fr) 290px; gap: 16px; margin-top: 16px; align-items: stretch; }
.board { position: relative; min-height: calc(100vh - 140px); overflow: hidden; padding: 10px; }
#mazeCanvas { width: 100%; height: 100%; display: block; border-radius: 16px; background: #020604; }
.side { padding: 16px; display: grid; align-content: start; gap: 18px; min-height: calc(100vh - 140px); }
.side-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.list { display: grid; gap: 9px; }
.player, .place { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; padding: 10px 12px; background: rgba(255,255,255,.045); border-radius: 12px; color: #dbe6df; font-size: 13px; }
.dot { width: 13px; height: 13px; border-radius: 50%; background: var(--pc); box-shadow: 0 0 18px var(--pc); }
.player b, .place b { text-transform: uppercase; font-size: 10px; color: #d3ded7; }
.rank { color: var(--yellow); font-weight: 900; }
.hint { position: absolute; left: 24px; bottom: 15px; margin: 0; font-size: 11px; color: rgba(238,246,240,.62); }
.countdown { position: absolute; inset: 0; display: grid; place-items: center; font-size: min(24vw, 260px); font-weight: 1000; color: var(--lime); text-shadow: 0 0 44px rgba(163,255,67,.38); pointer-events: none; }
.dpad { position: fixed; right: 18px; bottom: 18px; display: none; grid-template-columns: 64px 64px 64px; grid-template-rows: 64px 64px; gap: 8px; z-index: 20; }
.dpad button { padding: 0; font-size: 28px; background: rgba(12,24,20,.88); backdrop-filter: blur(12px); }
.dpad [data-dir="up"] { grid-column: 2; }
.dpad [data-dir="left"] { grid-column: 1; grid-row: 2; }
.dpad [data-dir="down"] { grid-column: 2; grid-row: 2; }
.dpad [data-dir="right"] { grid-column: 3; grid-row: 2; }
@media (max-width: 1050px) {
  .shell { width: calc(100vw - 20px); margin: 10px auto; }
  .home-grid, .play-layout { grid-template-columns: 1fr; }
  .topbar { grid-template-columns: auto 1fr auto; }
  .topbar .grow { grid-column: 1 / -1; }
  .status-box.timer { grid-column: span 1; }
  .board { min-height: 70vh; }
  .side { min-height: auto; }
  .dpad { display: grid; }
}
@media (max-width: 620px) {
  .topbar { grid-template-columns: 1fr 1fr; }
  .brand { width: 132px; }
  .topbar .brand { grid-column: 1 / -1; justify-self: center; }
  .actions.two { grid-template-columns: 1fr; }
  .board { min-height: 62vh; }
  h1 { font-size: 42px; }
}
.countdown[hidden], [hidden] { display: none !important; }
.rooms-panel { grid-column: 1 / -1; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.panel-head button { padding: 8px 12px; font-size: 12px; border-radius: 10px; }
.active-rooms { display: grid; gap: 8px; }
.room-row { display: grid; grid-template-columns: 86px 1fr auto; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.06); }
.room-row b { color: var(--yellow); letter-spacing: .16em; }
.room-row span { color: var(--muted); font-size: 12px; }
.room-row button { padding: 8px 12px; font-size: 12px; border-radius: 10px; }
#gameNote { min-height: 44px; }
#newMazeBtn:disabled { opacity: .35; }
@media (max-width: 700px) {
  .room-row { grid-template-columns: 1fr auto; }
  .room-row span { grid-column: 1 / -1; order: 3; }
}
