:root {
  --ink: #f3e9d6;
  --ink-dim: #b8ab94;
  --panel: rgba(18, 14, 10, 0.86);
  --edge: rgba(243, 233, 214, 0.18);
  --amber: #f0a844;
  --azure: #59b8f0;
  --accent: #e2b867;
  --danger: #e06a5a;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0b0907; color: var(--ink); font-family: Inter, system-ui, sans-serif; }
canvas#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }

#vignette { position: fixed; inset: 0; pointer-events: none; background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,0.55) 100%); }
#overlay { position: fixed; inset: 0; pointer-events: none; }
#overlay > * { pointer-events: auto; }
#ripple { position: fixed; inset: 0; pointer-events: none; opacity: 0; background: radial-gradient(circle, rgba(140,200,255,0.0) 20%, rgba(140,200,255,0.25) 60%, rgba(10,20,40,0.6) 100%); transition: opacity 0.2s; }
#ripple.on { animation: ripple 1.6s ease-out; }
@keyframes ripple { 0% { opacity: 0.9; transform: scale(1.3); } 100% { opacity: 0; transform: scale(1); } }

#hud { position: fixed; inset: 0; pointer-events: none; }
#crosshair { position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px 0 0 -3px; border-radius: 50%; background: rgba(255,255,255,0.75); box-shadow: 0 0 4px #000; }
#crosshair.active { width: 14px; height: 14px; margin: -7px 0 0 -7px; background: transparent; border: 2px solid var(--accent); }
#prompt { position: absolute; left: 50%; top: calc(50% + 26px); transform: translateX(-50%); padding: 4px 12px; border-radius: 4px; background: rgba(0,0,0,0.55); font-size: 15px; white-space: nowrap; }
#prompt:empty { display: none; }
#objective { position: absolute; left: 20px; top: 18px; max-width: 360px; padding: 10px 14px; background: linear-gradient(90deg, rgba(0,0,0,0.6), rgba(0,0,0,0)); border-left: 3px solid var(--accent); }
#objective .role { font-family: 'Cormorant Garamond', serif; font-size: 22px; font-weight: 700; }
#objective .text { font-size: 14px; color: var(--ink-dim); margin-top: 2px; line-height: 1.4; }
#hint { position: absolute; left: 20px; top: 120px; max-width: 380px; padding: 10px 14px; background: rgba(30, 24, 12, 0.85); border: 1px solid var(--edge); border-radius: 6px; font-size: 14px; line-height: 1.45; }
#toast { position: absolute; left: 50%; top: 18%; transform: translateX(-50%); font-family: 'Cormorant Garamond', serif; font-size: 28px; text-shadow: 0 2px 8px #000; text-align: center; white-space: pre-line; opacity: 0; transition: opacity 0.4s; max-width: 80vw; }
#toast.on { opacity: 1; }
#radio { position: absolute; right: 22px; bottom: 22px; display: flex; align-items: center; gap: 8px; padding: 8px 14px; background: rgba(0,0,0,0.55); border-radius: 20px; font-size: 13px; color: var(--ink-dim); }
#radio .led { width: 10px; height: 10px; border-radius: 50%; background: #3a3a3a; box-shadow: inset 0 0 2px #000; }
#radio.tx .led { background: #e04a3a; box-shadow: 0 0 10px #e04a3a; }
#radio.rx .led { background: #58d26a; box-shadow: 0 0 10px #58d26a; }
#chatlog { position: absolute; right: 22px; bottom: 66px; width: min(380px, 60vw); display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }
#chatlog .msg { padding: 5px 10px; background: rgba(0,0,0,0.55); border-radius: 6px; font-size: 14px; animation: fade 12s forwards; }
#chatlog .msg b.A { color: var(--amber); }
#chatlog .msg b.B { color: var(--azure); }
@keyframes fade { 0%, 80% { opacity: 1; } 100% { opacity: 0; } }
#chatinput { position: absolute; right: 22px; bottom: 66px; width: min(380px, 60vw); pointer-events: auto; padding: 8px 10px; background: rgba(0,0,0,0.8); color: var(--ink); border: 1px solid var(--accent); border-radius: 6px; font: inherit; }
#keys { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); font-size: 12px; color: rgba(243,233,214,0.5); white-space: nowrap; }

#inspect { position: fixed; inset: 0; background: rgba(5,4,3,0.82); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; }
#inspect canvas { max-width: 92vw; max-height: 80vh; border-radius: 6px; box-shadow: 0 10px 50px #000; }
#inspect .close { color: var(--ink-dim); font-size: 13px; }

.panel-screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: radial-gradient(ellipse at 50% 30%, rgba(60,40,20,0.55), rgba(5,4,3,0.92)); padding: 16px; }
.panel { width: min(760px, 100%); max-height: 100%; overflow: auto; background: var(--panel); border: 1px solid var(--edge); border-radius: 10px; padding: 28px 32px; box-shadow: 0 20px 80px rgba(0,0,0,0.6); }
.panel.small { width: min(440px, 100%); display: flex; flex-direction: column; gap: 10px; }
h1, h2 { font-family: 'Cormorant Garamond', serif; margin: 0 0 6px; }
h1 { font-size: 44px; letter-spacing: 0.5px; }
h2 { font-size: 32px; }
.sub { color: var(--ink-dim); margin: 0 0 20px; }
.row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin: 12px 0; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--ink-dim); }
input { background: rgba(255,255,255,0.06); color: var(--ink); border: 1px solid var(--edge); border-radius: 6px; padding: 9px 10px; font: inherit; width: 160px; }
button { background: var(--accent); color: #1b130a; border: 0; border-radius: 6px; padding: 10px 16px; font: inherit; font-weight: 600; cursor: pointer; }
button:hover { filter: brightness(1.1); }
button.secondary { background: rgba(255,255,255,0.08); color: var(--ink); border: 1px solid var(--edge); }
button.link { background: none; color: var(--accent); padding: 0; text-decoration: underline; font-weight: 400; }
button:disabled { opacity: 0.5; cursor: default; }
.share { margin: 8px 0 12px; color: var(--ink-dim); }
.share b { color: var(--ink); font-size: 20px; letter-spacing: 2px; }
#players { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.player { padding: 10px 12px; border-radius: 8px; border: 1px solid var(--edge); background: rgba(255,255,255,0.03); }
.player .tag { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; }
.player.A .tag { color: var(--amber); }
.player.B .tag { color: var(--azure); }
.player.empty { color: var(--ink-dim); font-style: italic; }
#levels { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; margin-top: 16px; }
.level { text-align: left; background: rgba(255,255,255,0.05); color: var(--ink); border: 1px solid var(--edge); padding: 14px; display: flex; flex-direction: column; gap: 6px; }
.level .n { font-size: 11px; color: var(--accent); letter-spacing: 1px; text-transform: uppercase; }
.level .t { font-family: 'Cormorant Garamond', serif; font-size: 22px; font-weight: 700; }
.level .b { font-size: 12px; color: var(--ink-dim); font-weight: 400; line-height: 1.4; }
.level .r { font-size: 12px; font-weight: 400; }
.note { color: var(--ink-dim); font-size: 13px; line-height: 1.5; margin-top: 14px; }
@media (max-width: 640px) {
  #levels { grid-template-columns: 1fr; }
  #players { grid-template-columns: 1fr; }
  #keys { display: none; }
  h1 { font-size: 34px; }
}
