:root {
  --ink: #1b2233;
  --paper: #fffaf0;
  --accent: #2f9e6e;
  --accent-ink: #ffffff;
  --muted: #6b7385;
  --danger: #c8443a;
  --glass: rgba(18, 24, 36, 0.62);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #bfe3e8; color: var(--ink); font-family: system-ui, -apple-system, 'Segoe UI', sans-serif; }
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }
button { font: inherit; cursor: pointer; border: 0; border-radius: 10px; padding: 10px 16px; background: #e8e1d0; color: var(--ink); }
button:hover { filter: brightness(1.05); }
button.primary { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
button.big { font-size: 1.15rem; padding: 14px 26px; }
button.link { background: none; padding: 0; color: inherit; text-decoration: underline; font-weight: 600; }
kbd { display: inline-block; min-width: 1.6em; padding: 1px 6px; border-radius: 5px; background: #fff; color: var(--ink); border: 1px solid #c9c1ae; border-bottom-width: 3px; font: 600 0.8rem system-ui, sans-serif; text-align: center; margin-right: 4px; }

.overlay { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(30, 50, 60, 0.35); padding: 16px; z-index: 20; }
.card { background: var(--paper); border-radius: 18px; padding: 28px 30px; width: min(460px, 100%); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25); }
.card.small { width: min(400px, 100%); text-align: center; }
.card h1 { margin: 0 0 4px; font-size: 2.2rem; letter-spacing: -0.02em; }
.card h2 { margin: 0 0 10px; }
.sub { color: var(--muted); margin: 0 0 18px; }
.tip { color: var(--muted); font-size: 0.85rem; margin: 2px 0 16px 26px; }
.field { display: block; font-weight: 600; margin: 0 0 14px; }
.field input { display: block; width: 100%; margin-top: 6px; padding: 10px 12px; font: inherit; border: 2px solid #ddd3bd; border-radius: 10px; background: #fff; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 600; }
#colors { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
#colors button { width: 34px; height: 34px; border-radius: 50%; padding: 0; border: 3px solid transparent; }
#colors button.on { border-color: var(--ink); }
.row { display: flex; gap: 10px; margin-top: 10px; }
.row > * { flex: 1; }
.row.join input { padding: 10px 12px; font: 600 1.1rem system-ui; text-transform: uppercase; letter-spacing: 0.25em; border: 2px solid #ddd3bd; border-radius: 10px; text-align: center; }
.err { color: var(--danger); min-height: 1.2em; margin: 10px 0 0; }
.code { font-family: ui-monospace, monospace; letter-spacing: 0.12em; }
.menu { display: flex; gap: 10px; justify-content: center; margin-top: 18px; }
.sens { display: block; margin-top: 18px; font-weight: 600; font-size: 0.95rem; }
.sens input { display: block; width: 100%; margin-top: 8px; accent-color: var(--accent); }
.keys { display: grid; gap: 8px; margin-bottom: 14px; line-height: 1.7; }

#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; color: #fff; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6); }
#hud button { pointer-events: auto; }
#topleft { position: absolute; left: 16px; top: 14px; max-width: min(440px, 60vw); }
#levelname { font-weight: 800; font-size: 1.1rem; }
#objective { margin-top: 4px; }
#hint { margin-top: 8px; background: var(--glass); padding: 8px 12px; border-radius: 10px; text-shadow: none; }
#roominfo { margin-top: 8px; font-size: 0.9rem; opacity: 0.9; }
#players { position: absolute; right: 16px; top: 14px; display: grid; gap: 6px; justify-items: end; }
.pl { display: flex; align-items: center; gap: 8px; background: var(--glass); padding: 4px 10px; border-radius: 99px; text-shadow: none; font-size: 0.9rem; }
.pl .dot { width: 12px; height: 12px; border-radius: 50%; box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.6); }
.pl .ear { font-size: 0.75rem; padding: 1px 7px; border-radius: 99px; background: rgba(255, 255, 255, 0.15); }
.pl .ear.off { background: rgba(200, 68, 58, 0.85); }
.pl.talk .dot { box-shadow: 0 0 0 3px #7cf29a; }
#cross { position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px 0 0 -3px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.35); }
#prompt { position: absolute; left: 50%; top: calc(50% + 26px); transform: translateX(-50%); background: var(--glass); padding: 6px 12px; border-radius: 10px; white-space: nowrap; text-shadow: none; }
#prompt:empty { display: none; }
#toast { position: absolute; left: 50%; top: 18%; transform: translateX(-50%); font-size: 1.4rem; font-weight: 800; text-align: center; transition: opacity 0.4s; opacity: 0; max-width: 80vw; }
#toast.on { opacity: 1; }
#chatlog { position: absolute; left: 16px; bottom: 64px; width: min(420px, 70vw); display: grid; gap: 4px; font-size: 0.92rem; }
#chatlog div { background: var(--glass); padding: 4px 10px; border-radius: 8px; text-shadow: none; justify-self: start; }
#chatin { position: absolute; left: 16px; bottom: 56px; width: min(420px, 80vw); pointer-events: auto; padding: 9px 12px; font: inherit; border-radius: 10px; border: 2px solid var(--accent); }
#mic { position: absolute; right: 16px; bottom: 60px; display: flex; align-items: center; gap: 8px; background: var(--glass); padding: 6px 12px; border-radius: 99px; text-shadow: none; font-size: 0.85rem; }
#micbar { width: 70px; height: 8px; background: rgba(255, 255, 255, 0.2); border-radius: 4px; overflow: hidden; }
#micbar i { display: block; height: 100%; width: 0; background: #7cf29a; }
#bar { position: absolute; left: 0; right: 0; bottom: 12px; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 14px; font-size: 0.85rem; padding: 0 16px; }
#bar span { background: var(--glass); padding: 4px 10px; border-radius: 99px; text-shadow: none; }

@media (max-width: 720px) {
  #bar { display: none; }
  #players { top: auto; bottom: 110px; }
}
