:root {
  --bg: #0b1a13;
  --panel: rgba(10, 20, 16, 0.72);
  --panel-solid: #0f2219;
  --line: rgba(255, 255, 255, 0.12);
  --text: #f2f5f1;
  --muted: #9fb3a8;
  --accent: #ff6b4a;
  --good: #7be36a;
  --gold: #ffd23f;
  --radius: 12px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
canvas#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 1px solid var(--line); background: rgba(255,255,255,0.06); border-radius: 8px; padding: 8px 12px; }
button:hover { background: rgba(255,255,255,0.12); }
button.primary { background: var(--accent); border-color: transparent; color: #1a0d08; font-weight: 600; }
button.primary:hover { filter: brightness(1.08); }
button.ghost { background: transparent; }
button.sm { padding: 5px 10px; font-size: 13px; }
input, select { background: rgba(255,255,255,0.06); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; width: 100%; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 0; }
label { display: block; color: var(--muted); font-size: 12px; margin: 0 0 10px; }
label input, label select { margin-top: 4px; color: var(--text); font-size: 14px; }
label.check { display: flex; gap: 8px; align-items: center; color: var(--text); font-size: 14px; }
label.check input { width: auto; margin: 0; }
a { color: var(--accent); }
.err { color: #ff8f7a; min-height: 1.2em; margin: 4px 0 8px; }
.row { display: flex; gap: 8px; align-items: center; }
.between { justify-content: space-between; }
.muted { color: var(--muted); }

.screen.card-screen { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; background: radial-gradient(ellipse at 30% 20%, rgba(30, 90, 60, 0.55), rgba(5, 14, 10, 0.92)); z-index: 10; }
.card { width: min(420px, 100%); background: var(--panel-solid); border: 1px solid var(--line); border-radius: 16px; padding: 24px; box-shadow: 0 20px 60px rgba(0,0,0,0.5); }
.card.wide { width: min(860px, 100%); max-height: calc(100vh - 32px); overflow: auto; }
.brand { display: flex; gap: 14px; align-items: center; margin-bottom: 18px; }
.brand h1 { margin: 0; font-size: 22px; letter-spacing: -0.01em; }
.brand p { margin: 2px 0 0; color: var(--muted); }
.flag { width: 40px; height: 40px; border-radius: 50%; background: #1b5e3f; position: relative; flex: none; }
.flag::before { content: ""; position: absolute; left: 15px; top: 8px; width: 2px; height: 24px; background: #fff; }
.flag::after { content: ""; position: absolute; left: 17px; top: 8px; border-left: 13px solid var(--accent); border-top: 5px solid transparent; border-bottom: 5px solid transparent; }
.tabs { display: flex; gap: 6px; margin-bottom: 16px; }
.tabs button { flex: 1; }
.tabs button.on { background: rgba(255,255,255,0.14); border-color: rgba(255,255,255,0.3); }
.reg-only { display: none; }
form.register .reg-only { display: block; }
form button[type=submit] { width: 100%; }
.grid2 { display: grid; grid-template-columns: 1.2fr 1fr; gap: 24px; }
@media (max-width: 720px) { .grid2 { grid-template-columns: 1fr; } }
h3 { margin: 6px 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.lobby-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.lobby-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,0.03); }
.lobby-list li.empty { color: var(--muted); justify-content: center; }
.lobby-list .meta { color: var(--muted); font-size: 12px; }
.code-in { text-transform: uppercase; letter-spacing: 0.3em; font-weight: 700; }
#codeForm button { width: auto; }

/* HUD */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
#hud > * { pointer-events: auto; }
.panel { background: var(--panel); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.topbar { position: absolute; top: 12px; left: 12px; right: 12px; display: flex; gap: 10px; align-items: center; pointer-events: none; }
.topbar > * { pointer-events: auto; }
.pill { background: var(--panel); backdrop-filter: blur(10px); border: 1px solid var(--line); border-radius: 999px; padding: 7px 14px; white-space: nowrap; }
.pill .code { font-weight: 700; letter-spacing: 0.15em; color: var(--gold); }
.areas { display: flex; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 4px; margin: 0 auto; }
.areas button { border: 0; border-radius: 999px; background: transparent; padding: 6px 14px; }
.areas button.on { background: var(--accent); color: #1a0d08; font-weight: 600; }
.wind #windArrow { display: inline-block; font-weight: 700; color: var(--gold); transition: transform 0.4s; }
.left-stack { position: absolute; top: 64px; left: 12px; width: 170px; }
.lie { display: grid; grid-template-columns: 1fr; gap: 0; }
.lie .k { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; margin-top: 6px; }
.lie .k:first-child { margin-top: 0; }
.lie .v { font-size: 18px; font-weight: 650; }
.bottom-left { position: absolute; left: 12px; bottom: 40px; width: 290px; }
.club-row { display: flex; align-items: center; gap: 8px; }
.club { flex: 1; text-align: center; }
.club #clubName { font-size: 20px; font-weight: 700; }
.club .sub { color: var(--muted); font-size: 12px; }
.ib { width: 36px; height: 36px; padding: 0; border-radius: 50%; }
.shot-types { display: flex; gap: 4px; margin: 10px 0; flex-wrap: wrap; }
.shot-types button { flex: 1; padding: 5px 4px; font-size: 12px; }
.shot-types button.on { background: rgba(255,255,255,0.2); border-color: rgba(255,255,255,0.45); font-weight: 600; }
.shot-types button:disabled { opacity: 0.3; cursor: default; }
.spin-wrap { display: flex; gap: 12px; align-items: center; }
.spin-ball { width: 66px; height: 66px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff, #d9dedb 60%, #9aa39e); position: relative; cursor: crosshair; flex: none; box-shadow: inset 0 -4px 8px rgba(0,0,0,0.25); }
.spin-ball::before, .spin-ball::after { content: ""; position: absolute; background: rgba(0,0,0,0.12); }
.spin-ball::before { left: 50%; top: 6px; bottom: 6px; width: 1px; }
.spin-ball::after { top: 50%; left: 6px; right: 6px; height: 1px; }
.spin-dot { position: absolute; width: 12px; height: 12px; border-radius: 50%; background: var(--accent); border: 2px solid #fff; transform: translate(-50%, -50%); left: 50%; top: 50%; pointer-events: none; }
.spin-help { color: var(--muted); font-size: 12px; }
.spin-help b { color: var(--text); }

.swing-meter { position: absolute; left: 50%; bottom: 40px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.swing-meter .track { width: 22px; height: 180px; border-radius: 12px; background: rgba(0,0,0,0.45); border: 1px solid var(--line); position: relative; overflow: hidden; }
.swing-meter .fill { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: linear-gradient(to top, #7be36a, #ffd23f 80%, #ff6b4a); }
.swing-meter .mark100 { position: absolute; left: -4px; right: -4px; bottom: calc(100% / 1.1); height: 2px; background: #fff; }
.swing-label { background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; font-size: 13px; white-space: nowrap; }

.right-stack { position: absolute; top: 64px; right: 12px; bottom: 12px; width: 300px; display: flex; flex-direction: column; gap: 10px; }
.players ul { list-style: none; margin: 8px 0; padding: 0; display: grid; gap: 4px; max-height: 230px; overflow: auto; }
.players li { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 6px; }
.players li .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; box-shadow: 0 0 0 2px transparent; transition: box-shadow 0.15s; }
.players li.speaking .dot { box-shadow: 0 0 0 3px var(--good); }
.players li .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.players li .tag { font-size: 11px; color: var(--muted); }
.players li .mic { font-size: 12px; }
.players li button { padding: 1px 6px; font-size: 11px; }
.voice-row { display: flex; gap: 6px; }
.board { font-size: 13px; }
.board h4 { margin: 0 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); display: flex; justify-content: space-between; align-items: center; }
.board .r { display: flex; justify-content: space-between; gap: 8px; padding: 2px 0; }
.board .r span:first-child { color: var(--muted); }
.chat { flex: 1; min-height: 140px; display: flex; flex-direction: column; padding: 8px; }
.chat-log { flex: 1; overflow-y: auto; font-size: 13px; padding: 2px 4px 6px; }
.chat-log .m { margin: 2px 0; word-wrap: break-word; }
.chat-log .m.sys { color: var(--muted); font-style: italic; }
.chat-log .m b { font-weight: 650; }
.chat input { padding: 7px 10px; }

.shot-card { position: absolute; left: 50%; top: 70px; transform: translateX(-50%); min-width: 420px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px 14px; text-align: center; }
.shot-card .head { grid-column: 1 / -1; font-weight: 700; font-size: 15px; }
.shot-card .s .k { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; }
.shot-card .s .v { font-size: 18px; font-weight: 700; }
.toast { position: absolute; top: 150px; left: 50%; transform: translateX(-50%); font-size: 30px; font-weight: 800; text-shadow: 0 2px 12px rgba(0,0,0,0.7); opacity: 0; transition: opacity 0.3s; pointer-events: none; white-space: nowrap; }
.toast.show { opacity: 1; }
.keys { position: absolute; left: 0; right: 0; bottom: 8px; text-align: center; color: rgba(255,255,255,0.7); font-size: 12px; text-shadow: 0 1px 3px #000; pointer-events: none; }
.label3d { position: absolute; transform: translate(-50%, -100%); padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: rgba(0,0,0,0.55); white-space: nowrap; pointer-events: none; border-left: 3px solid; }
#labels { position: fixed; inset: 0; pointer-events: none; z-index: 4; overflow: hidden; }

@media (max-width: 1100px) {
  .right-stack { width: 250px; }
  .shot-card { min-width: 320px; grid-template-columns: repeat(2, 1fr); }
}

.chars { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 18px; }
.chars button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px; border-radius: 12px; border: 2px solid var(--line); background: rgba(255,255,255,0.03); }
.chars button canvas { width: 100%; max-width: 220px; height: auto; aspect-ratio: 11 / 10; border-radius: 8px; background: linear-gradient(#9cc8ec, #cfe6ff 60%, #5aa33f 60%); }
.chars button b { font-size: 16px; margin-top: 6px; }
.chars button span { color: var(--muted); font-size: 12px; }
.chars button.on { border-color: var(--accent); background: rgba(255,107,74,0.1); }
