* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #11151c; color: #f2f4f7; font-family: system-ui, -apple-system, 'Segoe UI', sans-serif; }
body { user-select: none; -webkit-user-select: none; touch-action: none; }
.hidden { display: none !important; }
#scene, #scene canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

button, input { font: inherit; color: inherit; }
button { background: #2a3340; border: 1px solid #3d4a5c; border-radius: 10px; padding: 10px 14px; cursor: pointer; }
button:hover { background: #344052; }
button:disabled { opacity: 0.45; cursor: default; }
button.primary { background: #ffb703; border-color: #ffb703; color: #1b1300; font-weight: 700; }
button.primary:hover { background: #ffc633; }
button.big { width: 100%; padding: 14px; font-size: 1.1rem; }
button.small { padding: 6px 10px; font-size: 0.85rem; }
input:not([type=checkbox]) { background: #0d1117; border: 1px solid #3d4a5c; border-radius: 10px; padding: 10px 12px; width: 100%; user-select: text; -webkit-user-select: text; }
.row { display: flex; gap: 8px; margin: 8px 0; }
.row > * { flex: 1; }
.tag { color: #aab4c2; font-size: 0.9rem; margin: 8px 0; min-height: 1em; }

/* title */
.screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(10, 13, 18, 0.72); padding: 16px; overflow: auto; z-index: 20; }
.panel { background: #171c25; border: 1px solid #2c3644; border-radius: 16px; padding: 22px; width: min(440px, 100%); max-height: 100%; overflow: auto; }
.panel > input, .panel > button { margin-top: 8px; }
.logo { margin: 0 0 6px; font-size: 2.4rem; letter-spacing: 0.06em; color: #ffb703; }
.logo span { display: block; font-size: 0.75rem; letter-spacing: 0.2em; color: #8fd0f0; margin-top: 2px; }
#code-in { text-transform: uppercase; letter-spacing: 0.3em; text-align: center; }
.help { margin-top: 10px; color: #c7cfdb; font-size: 0.9rem; }
.help summary { cursor: pointer; color: #8fd0f0; }
.help ol { padding-left: 20px; }
.help li { margin: 6px 0; }

/* HUD */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 7; } /* above the phone look pad, so the paint chips can be tapped */
#top { position: absolute; top: max(10px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); background: rgba(12, 16, 22, 0.78); border-radius: 12px; padding: 8px 16px; text-align: center; min-width: 190px; }
#hud-phase { font-size: 1.05rem; color: #ffd166; }
#hud-time { font-size: 1.05rem; font-variant-numeric: tabular-nums; margin-left: 8px; }
#hud-role { display: block; color: #c7cfdb; }
#hud-count { position: absolute; top: max(10px, env(safe-area-inset-top)); left: 12px; background: rgba(12, 16, 22, 0.78); border-radius: 10px; padding: 6px 10px; font-size: 0.9rem; }
#hud-count:empty { display: none; }
#cross { 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 0 1px rgba(0, 0, 0, 0.6); }
#prompt { position: absolute; left: 50%; bottom: 96px; transform: translateX(-50%); background: rgba(12, 16, 22, 0.78); border-radius: 10px; padding: 8px 14px; white-space: nowrap; }
#prompt:empty { display: none; }
#toast { position: absolute; left: 50%; top: 24%; transform: translateX(-50%); background: rgba(12, 16, 22, 0.85); border-radius: 12px; padding: 10px 18px; font-weight: 600; opacity: 0; transition: opacity 0.25s; text-align: center; max-width: 90vw; }
#toast.show { opacity: 1; }
#paint-bar { position: absolute; left: 50%; bottom: 20px; transform: translateX(-50%); display: flex; gap: 8px; align-items: center; background: rgba(12, 16, 22, 0.78); border-radius: 14px; padding: 8px 10px; pointer-events: auto; }
.chip { min-width: 58px; height: 44px; border-radius: 10px; border: 2px solid rgba(255, 255, 255, 0.85); padding: 0 8px; font-size: 0.8rem; font-weight: 700; color: #fff; text-shadow: 0 1px 2px #000, 0 0 3px #000; }
.chip.brush { min-width: 44px; border-radius: 50%; display: inline-block; background: repeating-linear-gradient(45deg, #2a3340 0 6px, #3d4a5c 6px 12px); }

#blind { position: fixed; inset: 0; background: #05070a; z-index: 8; display: flex; align-items: center; justify-content: center; text-align: center; }
#blind b { display: block; font-size: 2rem; color: #ffd166; }
#blind span { display: block; color: #c7cfdb; margin: 6px 0; }
#blind i { font-style: normal; font-size: 3rem; font-variant-numeric: tabular-nums; }

/* room card */
#room { position: fixed; top: 12px; left: 12px; width: min(330px, calc(100vw - 24px)); max-height: calc(100vh - 24px); overflow: auto; background: rgba(23, 28, 37, 0.96); border: 1px solid #2c3644; border-radius: 16px; padding: 14px; z-index: 10; }
.room-head { display: flex; justify-content: space-between; align-items: flex-start; }
.room-head small { display: block; color: #aab4c2; letter-spacing: 0.15em; font-size: 0.7rem; }
#room-code { font-size: 2rem; letter-spacing: 0.25em; color: #ffb703; user-select: text; -webkit-user-select: text; }
.result { background: #22303f; border-radius: 10px; padding: 8px 10px; font-weight: 700; margin: 8px 0; }
button.mode.on { background: #8fd0f0; border-color: #8fd0f0; color: #06202e; font-weight: 700; }
#room-players { width: 100%; border-collapse: collapse; margin: 6px 0; font-size: 0.92rem; }
#room-players td { padding: 4px 4px; border-bottom: 1px solid #2c3644; }
#room-players td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
#room-players i { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
#room-players small { color: #aab4c2; margin-left: 6px; }
.check { display: flex; align-items: center; gap: 8px; margin: 8px 0; font-size: 0.92rem; }
.check input { width: 18px; height: 18px; }

/* phone controls */
#touch-ui { position: fixed; inset: 0; z-index: 6; }
#look-pad { position: absolute; inset: 0; }
#stick { position: absolute; left: max(18px, env(safe-area-inset-left)); bottom: max(22px, env(safe-area-inset-bottom)); width: 130px; height: 130px; border-radius: 50%; background: rgba(255, 255, 255, 0.12); border: 2px solid rgba(255, 255, 255, 0.35); }
#stick-knob { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px 0 0 -28px; border-radius: 50%; background: rgba(255, 255, 255, 0.55); }
#touch-right { position: absolute; right: max(14px, env(safe-area-inset-right)); bottom: max(22px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
#touch-top { position: absolute; right: max(10px, env(safe-area-inset-right)); top: max(10px, env(safe-area-inset-top)); display: flex; gap: 8px; }
.tb { background: rgba(20, 26, 34, 0.8); border: 2px solid rgba(255, 255, 255, 0.5); border-radius: 16px; min-width: 96px; min-height: 52px; font-weight: 700; }
.tb.big { min-width: 120px; min-height: 68px; background: rgba(255, 183, 3, 0.9); color: #1b1300; border-color: #fff; }
.tb.small { min-width: 64px; min-height: 40px; font-size: 0.85rem; }
body.touch #prompt { display: none; }
body.touch #paint-bar { bottom: auto; top: max(64px, calc(env(safe-area-inset-top) + 64px)); }
