:root {
  --bg: #0b0d10;
  --panel: rgba(22, 25, 31, 0.94);
  --panel-solid: #16191f;
  --btn: #262b34;
  --btn-hi: #33404f;
  --fg: #eef1f5;
  --muted: #9aa4b2;
  --accent: #4c8dff;
  --ok: #34c759;
  --warn: #ffb020;
  --bad: #ff4d4f;
  --focus: #ffd34d;
  --r: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg);
  font: 18px/1.35 system-ui, -apple-system, "Noto Sans KR", "Apple SD Gothic Neo", sans-serif; }
button { font: inherit; color: var(--fg); background: var(--btn); border: 2px solid transparent;
  border-radius: var(--r); cursor: pointer; min-height: 56px; min-width: 64px; padding: 6px 14px; }
button:hover, button:focus-visible { background: var(--btn-hi); border-color: var(--focus); outline: none; }
button:active { transform: scale(0.97); }
button.primary { background: var(--accent); }
button.big { min-height: 64px; padding: 10px 26px; font-size: 1.1em; }
button.huge { font-size: 1.6em; padding: 22px 48px; }
[hidden] { display: none !important; }

/* ---------- login ---------- */
body.login { display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { width: min(460px, 100%); background: var(--panel-solid); padding: 32px; border-radius: 20px; }
.login-card h1 { margin: 0 0 20px; font-size: 1.6em; }
.login-card label { display: block; margin: 14px 0 6px; color: var(--muted); }
.login-card input { width: 100%; font-size: 1.3em; padding: 14px; border-radius: 12px; border: 2px solid #39414d;
  background: #0f1216; color: var(--fg); }
.login-card input:focus { border-color: var(--focus); outline: none; }
.login-card button { width: 100%; margin-top: 22px; }
#msg { min-height: 1.4em; color: var(--warn); }

/* ---------- app ---------- */
body.app { overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
#stage { position: fixed; inset: 0; background: #000; }
#video { width: 100%; height: 100%; object-fit: contain; display: block; pointer-events: none; }
#hit { position: absolute; inset: 0; outline: none; cursor: default; }

.handle { position: fixed; top: 8px; right: 8px; z-index: 30; min-width: 56px; min-height: 56px;
  background: rgba(30,34,41,.55); font-size: 26px; padding: 0; opacity: .55; }
.handle:hover, .handle:focus-visible { opacity: 1; }
body.bar-open .handle { display: none; }

.rail { position: fixed; right: 8px; top: 50%; transform: translateY(-50%); z-index: 25;
  display: flex; flex-direction: column; gap: 14px; }
.rail button { width: 64px; height: 96px; font-size: 28px; background: rgba(30,34,41,.45); opacity: .6; }
.rail button:hover, .rail button:focus-visible { opacity: 1; }

.bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: flex; flex-wrap: wrap;
  align-items: center; gap: 10px; padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  background: var(--panel); transition: transform .2s ease; }
body:not(.bar-open) .bar { transform: translateY(110%); }
.bar .group { display: flex; gap: 6px; padding-right: 10px; border-right: 1px solid #333a45; }
.bar .group:last-of-type { border-right: 0; }
.bar button { display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 74px; min-height: 70px; font-size: 24px; line-height: 1; padding: 6px 8px; }
.bar button span { font-size: 13px; color: var(--muted); margin-top: 5px; }
.bar button b { font-size: 18px; }
.bar button.wide { min-width: 104px; }
.status { margin-left: auto; display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
.status i { width: 12px; height: 12px; border-radius: 50%; background: var(--warn); display: inline-block; }
.status i.ok { background: var(--ok); } .status i.bad { background: var(--bad); }

.overlay { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center; padding: 16px; }
.overlay.start { flex-direction: column; gap: 16px; background: rgba(0,0,0,.35); }
.panel { background: var(--panel-solid); border-radius: 20px; padding: 24px; width: min(980px, 100%);
  max-height: 100%; overflow: auto; }
.panel h2 { margin: 0 0 16px; font-size: 1.3em; } .panel h2 small { color: var(--muted); font-weight: normal; font-size: .7em; }
.panel input, .panel textarea { width: 100%; font-size: 1.5em; padding: 14px 16px; border-radius: 12px;
  border: 2px solid #39414d; background: #0f1216; color: var(--fg); resize: none; user-select: text; -webkit-user-select: text; }
.panel input:focus, .panel textarea:focus { border-color: var(--focus); outline: none; }
.row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.chips button { min-height: 52px; font-size: .95em; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.grid.two { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid button { min-height: 64px; }
.grid.q button { min-height: 76px; }
.grid.q button.on { background: var(--accent); }
.grid button.on { box-shadow: inset 0 0 0 3px var(--ok); }
.hint { color: var(--muted); font-size: .9em; margin: 12px 0 0; }

.stats { position: fixed; top: 8px; left: 8px; z-index: 50; background: rgba(0,0,0,.72); padding: 10px 14px;
  border-radius: 10px; font: 14px/1.45 ui-monospace, Menlo, Consolas, monospace; white-space: pre; pointer-events: none; }
.toast { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 70; background: var(--panel-solid);
  padding: 14px 24px; border-radius: 14px; font-size: 1.05em; box-shadow: 0 4px 20px rgba(0,0,0,.5); pointer-events: none; }

@media (max-width: 760px) {
  .bar button { min-width: 60px; min-height: 60px; font-size: 20px; }
  .bar .group { border-right: 0; padding-right: 0; }
}
