/* Gestura — the camera is the room, the scene floats in front of it. */
:root {
  --ink: #e9eef5;
  --dim: #8b97a6;
  --amber: #ffb454;
  --cyan: #57d9ff;
  --line: rgba(255, 255, 255, .14);
  --panel: rgba(10, 13, 17, .72);
  --strip: #05070a;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: #07090c; color: var(--ink);
  font: 13px/1.4 ui-sans-serif, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent;
}
#cam, #gl, #hud { position: fixed; inset: 0; width: 100%; height: 100%; }
#cam { object-fit: cover; transform: scaleX(-1); filter: saturate(.55) brightness(.5) contrast(1.05); z-index: 0; }
#veil {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background:
    radial-gradient(120% 90% at 50% 45%, rgba(4, 7, 11, 0) 0%, rgba(4, 7, 11, .35) 55%, rgba(4, 7, 11, .82) 100%),
    linear-gradient(180deg, rgba(4, 7, 11, .55), rgba(4, 7, 11, 0) 22%, rgba(4, 7, 11, 0) 72%, rgba(4, 7, 11, .8));
}
#gl { z-index: 2; }
#hud { z-index: 3; pointer-events: none; }

/* ---- top bar ---- */
#bar {
  position: fixed; z-index: 5; top: 0; left: 0; right: 0;
  display: flex; align-items: center; gap: 14px; padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top));
  background: linear-gradient(180deg, rgba(5, 7, 10, .85), rgba(5, 7, 10, 0));
}
#mark { font-weight: 700; letter-spacing: .34em; font-size: 12px; color: var(--ink); }
#modes { display: flex; gap: 6px; margin-left: 4px; }
#modes button, #rail button {
  font: inherit; color: var(--dim); background: rgba(255, 255, 255, .05);
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 11px; cursor: pointer;
  transition: color .15s, background .15s, border-color .15s;
}
#modes button:hover, #rail button:hover { color: var(--ink); border-color: rgba(255, 255, 255, .3); }
#modes button.on, #rail button.on {
  color: #06090d; background: var(--amber); border-color: var(--amber); font-weight: 600;
}
#state { margin-left: auto; display: flex; align-items: center; gap: 7px; color: var(--dim); font-size: 12px; }
#dot { width: 7px; height: 7px; border-radius: 50%; background: #6b7684; box-shadow: 0 0 0 0 rgba(87, 217, 255, .5); }
#dot.live { background: var(--cyan); animation: pulse 1.8s infinite; }
#dot.warn { background: var(--amber); }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(87, 217, 255, .55); }
  70% { box-shadow: 0 0 0 7px rgba(87, 217, 255, 0); }
  100% { box-shadow: 0 0 0 0 rgba(87, 217, 255, 0); }
}

/* ---- side rail ---- */
#rail {
  position: fixed; z-index: 5; right: 12px; top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 7px; width: 92px;
  padding: 10px; border-radius: 14px; background: var(--panel);
  border: 1px solid var(--line); backdrop-filter: blur(14px);
}
#rail button { padding: 8px 6px; font-size: 12px; text-align: center; }
#rail hr { width: 100%; border: 0; border-top: 1px solid var(--line); margin: 3px 0; }

/* ---- hint + readout ---- */
#hint {
  position: fixed; z-index: 5; left: 50%; top: 62px; transform: translateX(-50%);
  padding: 7px 14px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line);
  color: var(--ink); font-size: 12px; letter-spacing: .04em; backdrop-filter: blur(12px);
  opacity: 0; transition: opacity .25s;
}
#hint.show { opacity: 1; }
#readout {
  position: fixed; z-index: 5; left: 14px; bottom: 58px; color: var(--dim);
  font: 11px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre;
  text-shadow: 0 1px 2px #000; opacity: .85;
}

/* ---- bottom strip (the reference's keymap) ---- */
#strip {
  position: fixed; z-index: 5; left: 0; right: 0; bottom: 0;
  padding: 9px 16px calc(9px + env(safe-area-inset-bottom));
  background: var(--strip); border-top: 1px solid rgba(255, 255, 255, .07);
  color: #9aa6b4; font: 11px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#strip .k { color: var(--ink); }
#strip .hand { color: var(--amber); font-weight: 700; letter-spacing: .1em; }
#strip .hand.r { color: var(--cyan); }
#strip .sep { color: #48525e; margin: 0 8px; }

/* ---- arcade scoreboard ---- */
#score {
  position: fixed; z-index: 5; left: 50%; transform: translateX(-50%);
  top: 58px; display: none;
  padding: 8px 16px; border-radius: 10px; background: rgba(10, 13, 17, .74);
  border: 1px solid var(--line); backdrop-filter: blur(12px);
  color: var(--amber); font: 600 12px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .12em; white-space: nowrap;
}
body.arcade #score { display: block; }
body.arcade #rail { display: none; }
body.arcade #hint { top: 104px; }

/* ---- permission gate ---- */
#gate {
  position: fixed; inset: 0; z-index: 20; display: grid; place-items: center;
  background: radial-gradient(90% 70% at 50% 40%, #101823, #05070a 70%);
  padding: 24px;
}
#gate.hidden { display: none; }
#gate .card {
  width: min(440px, 100%); padding: 26px 24px; border-radius: 18px;
  background: rgba(14, 19, 26, .9); border: 1px solid var(--line); text-align: left;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .55);
}
#gate h1 { margin: 0 0 6px; font-size: 26px; letter-spacing: .22em; font-weight: 700; }
#gate p { margin: 0 0 18px; color: var(--dim); line-height: 1.55; }
#gate .fine { font-size: 12px; margin: 14px 0 0; color: #6f7b89; }
#start {
  width: 100%; padding: 13px; border-radius: 11px; border: 0; cursor: pointer;
  background: var(--amber); color: #080b0f; font: 600 15px/1 inherit;
}
#start:disabled { opacity: .6; cursor: progress; }

@media (max-width: 720px) {
  #rail { width: 76px; right: 8px; padding: 7px; gap: 5px; }
  #rail button { font-size: 11px; padding: 7px 4px; }
  #modes button { padding: 6px 9px; font-size: 12px; }
  #strip { font-size: 10px; white-space: normal; line-height: 1.55; padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
  #mark { letter-spacing: .2em; font-size: 11px; }
  #readout { display: none; }
}
#state { cursor: pointer; }
