@import url('https://fonts.googleapis.com/css2?family=Share+Tech+Mono&display=swap');

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: #04040e;
  overflow: hidden;
  font-family: 'Share Tech Mono', 'Courier New', monospace;
  color: #c0e0ff;
  width: 100vw;
  height: 100vh;
}

/* Scanline overlay */
body::after {
  content: '';
  position: fixed; inset: 0;
  background: repeating-linear-gradient(
    0deg, transparent, transparent 2px,
    rgba(0,20,60,0.1) 2px, rgba(0,20,60,0.1) 4px
  );
  pointer-events: none;
  z-index: 200;
}

#c { position: absolute; top:0; left:0; width:100%; height:100%; display:block; }

/* ── HUD ─────────────────────────────────────────────────── */
#hud { position:absolute; top:0; left:0; width:100%; height:100%; pointer-events:none; z-index:10; }

#hud-top {
  position: absolute; top:0; left:50%; transform: translateX(-50%);
  display: flex; gap: 1px;
}

.hud-block {
  background: rgba(0,4,20,0.85);
  border: 1px solid rgba(0,200,255,0.2);
  border-top: 2px solid rgba(0,200,255,0.55);
  padding: 5px 22px 7px;
  text-align: center; min-width: 85px;
}

.hud-label { font-size: 9px; letter-spacing: 4px; color: rgba(0,200,255,0.5); }
.hud-value {
  font-size: 22px; font-weight: bold; color: #00ffff; letter-spacing: 2px; margin-top:2px;
  text-shadow: 0 0 6px rgba(0,255,255,0.9), 0 0 18px rgba(0,200,255,0.45);
}

.mode-btn {
  pointer-events: all; cursor: pointer; min-width: 65px;
  border-top-color: rgba(255,0,255,0.5); transition: background .15s;
}
.mode-btn:hover { background: rgba(255,0,255,0.07); }
.mode-btn .hud-label { color: rgba(255,0,255,0.5); }

.icon-btn {
  pointer-events: all; cursor: pointer; min-width: 60px; transition: background .15s;
}
.icon-btn:hover { background: rgba(0,255,255,0.06); }
.icon-btn .hud-value { font-size:18px; }
.icon-btn.muted .hud-value { color: rgba(255,255,255,0.25); text-shadow: none; }

#hud-side {
  position: absolute; right: 18px; top: 50%; transform: translateY(-50%);
}

.hud-panel {
  background: rgba(0,4,20,0.85);
  border: 1px solid rgba(0,200,255,0.18);
  border-left: 2px solid rgba(0,200,255,0.5);
  padding: 10px 12px;
}
.hud-panel .hud-label { margin-bottom: 8px; font-size: 9px; letter-spacing: 4px; color: rgba(0,200,255,0.5); }

#next-canvas {
  display:block; background: rgba(0,8,30,0.5);
  border: 1px solid rgba(0,200,255,0.12); margin: 0 auto;
}

/* ── Gesture Panel (left side, always-on) ────────────────── */
#gesture-panel {
  position: absolute; left: 20px; top: 50%; transform: translateY(-50%);
  z-index: 15; display: flex; flex-direction: column; gap: 10px; align-items: flex-start;
}

/* Status indicator replaces the old toggle button */
#gesture-status {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 14px 6px 10px;
  background: rgba(0,4,20,0.82);
  border: 1px solid rgba(0,255,180,0.25);
  border-left: 3px solid rgba(0,255,180,0.7);
  font-size: 10px; letter-spacing: 3px; color: rgba(0,255,180,0.7);
}
#gesture-state-dot {
  font-size: 8px; color: rgba(0,255,180,0.4);
  animation: dot-pulse 2s ease-in-out infinite;
}
#gesture-state-dot.active    { color: #00ffcc; animation-duration: 1s; }
#gesture-state-dot.connecting{ color: #ffcc00; animation-duration: 0.4s; }
#gesture-state-dot.error     { color: #ff2244; animation: none; }
#gesture-state-text { font-size: 10px; letter-spacing: 2px; }

@keyframes dot-pulse {
  0%, 100% { opacity: 0.35; }
  50%       { opacity: 1; }
}

/* Gesture feed */
#gesture-feed {
  background: rgba(0,4,20,0.9);
  border: 1px solid rgba(0,255,180,0.18);
  border-left: 2px solid rgba(0,255,180,0.5);
  padding: 8px 10px; display: flex; flex-direction: column; gap: 6px;
}
#gesture-feed.hidden { display: none; }

#hand-badges { display: flex; gap: 8px; }
.badge {
  font-size: 10px; letter-spacing: 2px; color: rgba(0,255,180,0.75);
  padding: 2px 8px; border: 1px solid rgba(0,255,180,0.25); background: rgba(0,20,15,0.5);
  min-width: 72px; text-align: center;
}

#cam-container { position: relative; width:160px; height:120px; }

#webcam {
  display: block; width:160px; height:120px; object-fit: cover;
  opacity: 0.5; transform: scaleX(-1);
  filter: brightness(.8) contrast(1.2);
}

#gesture-canvas {
  position:absolute; top:0; left:0;
  transform: scaleX(-1); pointer-events: none;
}

/* Zone guide overlay */
#zone-guide {
  position:absolute; inset:0; pointer-events:none;
  display: grid;
  grid-template-areas:
    ".     top    ."
    "left  center right"
    ".     bottom .";
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 1fr 1fr 1fr;
  font-size: 8px; letter-spacing: 1px; color: rgba(0,255,180,0.35);
}
.zone { display:flex; align-items:center; justify-content:center; text-align:center; }
.zone-top    { grid-area: top;    border-top: 1px dashed rgba(0,255,180,0.2); }
.zone-left   { grid-area: left;   border-left: 1px dashed rgba(0,255,180,0.2); }
.zone-right  { grid-area: right;  border-right: 1px dashed rgba(0,255,180,0.2); }
.zone-bottom { grid-area: bottom; border-bottom: 1px dashed rgba(0,255,180,0.2); }
.zone-center { grid-area: center; color: rgba(0,255,180,0.2); font-size:7px; }

/* ── Help Modal ─────────────────────────────────────────── */
#help-overlay {
  position:absolute; inset:0;
  background: rgba(0,0,10,0.85);
  display:flex; align-items:center; justify-content:center;
  z-index: 60; backdrop-filter: blur(4px);
}
#help-overlay.hidden { display:none; }

#help-box {
  position: relative;
  background: rgba(0,4,22,0.98);
  border: 1px solid rgba(0,200,255,0.25);
  border-top: 2px solid rgba(0,200,255,0.7);
  border-bottom: 2px solid rgba(255,0,255,0.5);
  padding: 28px 32px 28px;
  max-width: 900px; width: 90vw;
  box-shadow: 0 0 60px rgba(0,200,255,0.08), inset 0 0 60px rgba(0,0,30,0.4);
}

#help-title {
  font-size: 18px; letter-spacing: 6px; color: #00ffff; margin-bottom: 22px;
  text-shadow: 0 0 12px rgba(0,255,255,0.7);
}

#help-close {
  position: absolute; top: 16px; right: 20px;
  background: transparent; border: 1px solid rgba(255,255,255,0.2);
  color: rgba(255,255,255,0.5); font-size:14px; cursor:pointer;
  width: 28px; height:28px; display:flex; align-items:center; justify-content:center;
  transition: all .15s; font-family: monospace;
}
#help-close:hover { border-color: #ff2244; color: #ff2244; }

#help-cols {
  display: flex; gap: 0; align-items: flex-start;
}

.help-col { flex: 1; padding: 0 24px 0 0; }
.help-col:last-child { padding-right: 0; }

.help-col-title {
  font-size: 11px; letter-spacing: 4px;
  color: rgba(0,200,255,0.65); margin-bottom: 14px;
  border-bottom: 1px solid rgba(0,200,255,0.15); padding-bottom: 6px;
}

.help-divider {
  width: 1px; align-self: stretch;
  background: rgba(0,200,255,0.1); margin: 0 24px;
  flex-shrink: 0;
}

.help-table {
  display: grid; grid-template-columns: auto 1fr;
  gap: 6px 14px; font-size: 11px; color: rgba(180,220,255,0.75);
  margin-bottom: 14px;
}

.k {
  background: rgba(0,200,255,0.07);
  border: 1px solid rgba(0,200,255,0.2);
  color: #00ffff; padding: 1px 6px; font-size: 10px; letter-spacing: 1px;
  white-space: nowrap; display: inline-block;
}
.inline-k { display: inline; }
.mode-h { color: #00ffff; border-color: rgba(0,255,255,0.3); }
.mode-v { color: #ff00ff; border-color: rgba(255,0,255,0.3); }

.help-note {
  font-size: 10px; color: rgba(150,200,255,0.45);
  line-height: 1.7; letter-spacing: 0.5px;
}

/* Gesture guide */
.gesture-guide { display: flex; flex-direction: column; gap: 12px; margin-bottom: 12px; }
.g-row { display: flex; gap: 12px; align-items: center; }
.g-icon {
  font-size: 24px; width: 40px; text-align: center; flex-shrink: 0;
  filter: drop-shadow(0 0 8px rgba(0,255,180,0.4));
}
.right-icon { transform: scaleX(-1); display: inline-block; }
.left-icon { display: inline-block; }
.g-desc { font-size: 11px; line-height: 1.6; color: rgba(180,220,255,0.75); }
.g-desc strong { color: rgba(0,255,180,0.9); font-weight: normal; letter-spacing: 1px; }
.g-desc em { color: rgba(150,200,255,0.5); font-style: normal; font-size: 10px; }

/* ── Main Menu ──────────────────────────────────────────── */
#main-menu {
  position: absolute; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: rgba(4, 4, 14, 0.55);
}
#main-menu.hidden { display: none; }

#menu-stars {
  position: absolute; inset: 0; width: 100%; height: 100%;
  pointer-events: none;
}

#menu-content {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; align-items: center;
  pointer-events: all;
}

#menu-title-deco {
  font-size: 13px; letter-spacing: 12px; color: rgba(0,255,255,0.35);
  margin-bottom: 10px;
  text-shadow: 0 0 20px rgba(0,255,255,0.25);
}

#menu-title-main {
  font-size: clamp(52px, 9vw, 92px);
  letter-spacing: clamp(10px, 2.5vw, 26px);
  color: #00ffff; line-height: 1;
  text-shadow: 0 0 18px #00ffff, 0 0 50px rgba(0,255,255,0.5), 0 0 100px rgba(0,200,255,0.25);
  animation: title-glow 3s ease-in-out infinite;
}

#menu-title-sub {
  font-size: clamp(26px, 4.5vw, 46px);
  letter-spacing: clamp(18px, 3.5vw, 36px);
  color: #ff00ff; line-height: 1; margin-bottom: 6px;
  text-shadow: 0 0 14px #ff00ff, 0 0 40px rgba(255,0,255,0.45);
}

#menu-title-tag {
  font-size: 10px; letter-spacing: 5px;
  color: rgba(0,255,180,0.45); margin-bottom: 52px;
}

@keyframes title-glow {
  0%, 100% { text-shadow: 0 0 18px #00ffff, 0 0 50px rgba(0,255,255,0.4); }
  50%       { text-shadow: 0 0 28px #00ffff, 0 0 70px rgba(0,255,255,0.7), 0 0 120px rgba(0,200,255,0.3); }
}

#menu-nav {
  display: flex; flex-direction: column; gap: 14px;
  align-items: flex-start; margin-bottom: 44px;
}

.menu-item {
  background: rgba(0,4,20,0.72);
  border: 1px solid rgba(0,200,255,0.3);
  border-left: 3px solid #00ffff;
  color: #00ffff;
  font-family: 'Share Tech Mono','Courier New',monospace;
  font-size: 15px; letter-spacing: 6px;
  padding: 14px 52px 14px 24px;
  cursor: pointer; width: 270px; text-align: left;
  text-shadow: 0 0 8px rgba(0,255,255,0.7);
  box-shadow: 0 0 18px rgba(0,255,255,0.05);
  transition: letter-spacing .2s ease, background .15s, box-shadow .15s;
}
.menu-item:hover {
  background: rgba(0,255,255,0.06);
  border-color: rgba(0,255,255,0.7);
  box-shadow: 0 0 36px rgba(0,255,255,0.18);
  letter-spacing: 8px;
  color: #fff;
  text-shadow: 0 0 12px rgba(0,255,255,0.9);
}
/* second button: green tint */
#menu-help-btn {
  border-left-color: #00ffcc;
  color: #00ffcc;
  text-shadow: 0 0 8px rgba(0,255,180,0.7);
  border-color: rgba(0,255,180,0.3);
}
#menu-help-btn:hover {
  border-color: rgba(0,255,180,0.7);
  color: #fff;
  text-shadow: 0 0 12px rgba(0,255,180,0.9);
  box-shadow: 0 0 36px rgba(0,255,180,0.18);
}

#menu-hint {
  font-size: 9px; letter-spacing: 2.5px; color: rgba(0,200,255,0.28);
  text-align: center; line-height: 2;
}

/* ── Game Over ───────────────────────────────────────────── */
#overlay {
  position:absolute; inset:0; background: rgba(0,0,10,0.88);
  display:flex; align-items:center; justify-content:center; z-index:20;
}
#overlay.hidden { display:none; }

#overlay-box {
  background: rgba(0,4,20,0.97);
  border: 1px solid rgba(0,200,255,0.25);
  border-top: 2px solid #00ffff; border-bottom: 2px solid #ff00ff;
  padding: 44px 64px; text-align:center;
  box-shadow: 0 0 50px rgba(0,200,255,0.1), inset 0 0 40px rgba(0,0,30,0.5);
}
#overlay-title {
  font-size: 40px; letter-spacing: 8px; color: #ff2244; margin-bottom: 16px;
  text-shadow: 0 0 12px rgba(255,30,60,0.9), 0 0 36px rgba(255,0,80,0.45);
}
#overlay-score { font-size:12px; color: rgba(180,220,255,0.65); letter-spacing:2px; margin-bottom: 28px; }

#restart-btn {
  background: transparent; border: 1px solid rgba(0,255,255,0.45);
  color: #00ffff; font-family: 'Share Tech Mono','Courier New',monospace;
  font-size: 13px; letter-spacing: 4px; padding: 12px 36px; cursor: pointer;
  text-shadow: 0 0 8px rgba(0,255,255,0.7);
  box-shadow: 0 0 14px rgba(0,255,255,0.08); transition: all .15s ease;
}
#restart-btn:hover { background: rgba(0,255,255,0.07); border-color: #00ffff; box-shadow: 0 0 28px rgba(0,255,255,0.2); }
