* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0f1216; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: #fff; touch-action: none; user-select: none; -webkit-user-select: none; }
canvas { display: block; }
[hidden] { display: none !important; }

#overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: radial-gradient(ellipse at center, rgba(10,14,20,0.35), rgba(10,14,20,0.8)); z-index: 10; padding: 16px; overflow: auto; }
.card { width: min(680px, 100%); background: rgba(22,26,32,0.92); border: 3px solid #f5b82e; border-radius: 22px; padding: 28px; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,0.5); }
h1 { margin: 0; font-size: clamp(32px, 7vw, 54px); letter-spacing: 2px; color: #f5b82e; font-weight: 900; }
.sub { margin: 6px 0 22px; color: #b8c4d0; }
button { font: inherit; cursor: pointer; }
.big { display: block; width: 100%; padding: 18px; font-size: 24px; font-weight: 800; letter-spacing: 1px; border: 0; border-radius: 14px; background: #f5b82e; color: #1a1a1a; }
.big:disabled { background: #5a6270; color: #c9d0d8; cursor: not-allowed; }
.note { margin: 8px 0 16px; font-size: 14px; color: #9fb0c2; min-height: 18px; }
.ghost { width: 100%; padding: 12px; border-radius: 12px; border: 2px solid #4f5d6e; background: transparent; color: #fff; font-weight: 600; }
.ghost:hover { border-color: #f5b82e; }
.mic { margin-top: 10px; }
.mic.on { border-color: #4cc35a; color: #c8f5cf; }
.meter { height: 8px; margin: 8px 0 0; background: #2d3540; border-radius: 6px; overflow: hidden; }
.meter > div { height: 100%; width: 0; background: linear-gradient(90deg, #4cc35a 0 70%, #f5b82e 70% 85%, #e74c3c 85%); background-size: 100vw 100%; transition: width 60ms linear; }
#overlay .meter > div { background-size: min(680px, 100vw) 100%; }
.hud-meter { position: absolute; left: 12px; top: 34px; width: 120px; margin: 0; }
.status { margin-top: 10px; font-size: 14px; color: #f5b82e; min-height: 18px; }
.status.bad { color: #ff7b72; font-weight: 700; }
.controls { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; text-align: left; margin-top: 20px; font-size: 14px; color: #d6dee6; }
.controls h3 { margin: 0 0 6px; color: #f5b82e; font-size: 15px; }
.controls ul { margin: 0; padding-left: 18px; line-height: 1.6; }
.attrib { margin: 6px 0 0; font-size: 12px; color: #7d8a98; }
.attrib a { color: #b8c4d0; }
.credit { margin: 18px 0 0; font-size: 12px; color: #7d8a98; letter-spacing: 1px; text-transform: uppercase; }
@media (max-width: 560px) { .controls { grid-template-columns: 1fr; } }

#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
#crosshair { position: absolute; left: 50%; top: 50%; width: 10px; height: 10px; margin: -5px 0 0 -5px; border: 2px solid #fff; border-radius: 50%; box-shadow: 0 0 3px #000; }
#toolbar { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); background: rgba(22,26,32,0.8); border: 2px solid #f5b82e; padding: 8px 16px; border-radius: 12px; font-weight: 700; letter-spacing: 1px; font-size: 15px; white-space: nowrap; }
#hint { position: absolute; left: 12px; top: 10px; font-size: 13px; color: rgba(255,255,255,0.8); text-shadow: 0 1px 2px #000; }

#menu { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(520px, 94vw); max-height: 92vh; overflow: auto; z-index: 20; background: rgba(22,26,32,0.95); border: 3px solid #f5b82e; border-radius: 18px; padding: 14px 16px 18px; }
.menu-head { display: flex; justify-content: space-between; align-items: center; font-weight: 900; color: #f5b82e; font-size: 22px; }
.menu-close { background: #2d3540; border: 0; color: #fff; border-radius: 8px; width: 34px; height: 34px; font-size: 18px; }
.menu-title { margin: 12px 0 6px; font-size: 13px; font-weight: 700; color: #9fb0c2; letter-spacing: 1px; }
.menu-row { display: grid; gap: 7px; }
.menu-btn { padding: 11px 4px; border: 0; border-radius: 9px; background: #2d3540; color: #fff; font-weight: 700; font-size: 13px; }
.menu-btn:hover { background: #4f5d6e; }
.menu-btn.active { background: #f5b82e; color: #1a1a1a; }
.menu-btn.swatch { height: 34px; outline: 3px solid transparent; }
.menu-btn.swatch.active { outline-color: #fff; }

#touch { position: fixed; inset: 0; z-index: 6; }
#look { position: absolute; right: 0; top: 0; width: 60%; height: 100%; }
#stick { position: absolute; left: 28px; bottom: 28px; width: 130px; height: 130px; border-radius: 50%; background: rgba(255,255,255,0.12); border: 2px solid rgba(255,255,255,0.35); display: flex; align-items: center; justify-content: center; }
#knob { width: 56px; height: 56px; border-radius: 50%; background: rgba(245,184,46,0.85); }
.tbtns { position: absolute; right: 18px; bottom: 80px; display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.tbtns button { width: 78px; height: 62px; border-radius: 14px; border: 2px solid rgba(255,255,255,0.4); background: rgba(22,26,32,0.6); color: #fff; font-weight: 800; font-size: 13px; }
.tbtns button:active { background: #f5b82e; color: #111; }

#err { position: fixed; left: 50%; top: 12px; transform: translateX(-50%); z-index: 50; background: #b0302a; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; max-width: 92vw; }
