:root {
  color-scheme: dark;
  font-family: "DM Sans", "Segoe UI", sans-serif;
  background: #100b1e;
  color: #fcf8ff;
  line-height: 1.45;
  --surface: #1c1530;
  --input: #100c21;
  --white: #fcf8ff;
  --muted: #c9bfdc;
  --line: #46395e;
  --lime: #e2fa77;
  --pink: #ff94bc;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; background: radial-gradient(ellipse at 90% 8%, #32214d 0, transparent 55%), #100b1e; }
.wrap { max-width: 77rem; margin: 0 auto; padding: clamp(.8rem, 3vw, 2.4rem); }
.mast, .section-head, .stage-head { display: flex; justify-content: space-between; align-items: center; gap: .75rem; }
.mast { margin-bottom: clamp(1rem, 3vw, 2.5rem); }
.mobile-dock { display: none; }
.brand { display: flex; align-items: center; font-size: clamp(1.3rem, 4vw, 1.85rem); letter-spacing: -.082em; font-weight: 900; }
.brand > span:last-child { color: var(--lime); }
.bolt { display: inline-block; width: 1.4rem; height: 1.7rem; margin-right: .38rem; background: var(--lime); clip-path: polygon(59% 1%, 5% 56%, 41% 56%, 34% 99%, 97% 35%, 59% 35%); }
.label { flex-shrink: 0; font-size: .75rem; font-weight: 700; padding: .28rem .6rem; border-radius: 99px; background: #302343; color: #f0e7ff; }
h1, h2, p, figure { margin: 0; }
.launch { display: grid; grid-template-columns: minmax(16rem, .88fr) minmax(0, 1.12fr); align-items: center; gap: clamp(1rem, 5vw, 4.5rem); padding-top: clamp(.6rem, 3vh, 2rem); }
.entry-copy { min-width: 0; }
.eyebrow { font-size: .76rem; font-weight: 750; letter-spacing: .13em; text-transform: uppercase; color: var(--pink); line-height: 1.4; }
#hello { font-size: clamp(3.05rem, 7vw, 6.4rem); line-height: .93; letter-spacing: -.087em; margin-block: .55rem 1.2rem; }
#hello em { font-style: normal; color: var(--lime); }
.intro { color: var(--muted); font-size: clamp(1rem, 1.8vw, 1.12rem); max-width: 35ch; }
.entry-form, .card { background: var(--surface); border: 1px solid var(--line); border-radius: 1.25rem; box-shadow: 0 6px 18px #0c071a44; padding: clamp(.9rem, 2.5vw, 1.45rem); min-width: 0; }
.entry-form { margin-top: 1.55rem; }
.browse-rooms { margin-top: .65rem; color: var(--lime); }
.room-rules { margin-block: .65rem; border-block: 1px solid var(--line); }
summary { cursor: pointer; font-weight: 750; min-height: 44px; align-content: center; }
.room-rules ul { font-size: .82rem; color: var(--muted); margin: 0 0 .55rem; padding-inline-start: 1.15rem; }
.room-rules li + li { margin-top: .3rem; }
.avatar-picker { border: 0; padding: 0; min-width: 0; margin: .75rem 0 0; }
.avatar-picker legend { font-size: .86rem; font-weight: 750; margin-bottom: .35rem; }
.avatar-options { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .35rem; }
.avatar-options label { position: relative; display: grid; place-items: center; gap: .24rem; margin: 0; padding: .35rem .06rem; color: var(--white); border: 1px solid var(--line); border-radius: .65rem; cursor: pointer; font-size: .76rem; }
.avatar-options input { position: absolute; opacity: 0; width: 1px; height: 1px; min-height: 0; padding: 0; pointer-events: none; }
.avatar-options label:has(:checked) { border-color: var(--lime); background: #33274a; }
.avatar-options label:has(:focus-visible) { outline: 3px solid #f69cc7; outline-offset: 2px; }
.doodle { width: 31px; height: 28px; flex: none; position: relative; display: inline-grid; place-items: center; border-radius: 39% 59% 48% 53%; background: #dffa7c; color: #342352; rotate: -8deg; }
.doodle i { display: block; width: 8px; height: 4px; border-radius: 0 0 10px 10px; background: currentColor; transform: translateY(5px); }
.doodle::before { content: ""; position: absolute; width: 3.4px; height: 5px; border-radius: 50%; background: currentColor; top: 8px; left: 9px; box-shadow: 10px 0 currentColor; }
.doodle[data-doodle="bean"] { background: #ff9aba; border-radius: 57% 42% 52% 31%; rotate: 12deg; }
.doodle[data-doodle="cat"] { background: #ffbb77; border-radius: 28% 32% 45% 45%; }
.doodle[data-doodle="cat"]::after { content: ""; background: inherit; position: absolute; width: 29px; height: 10px; top: -5px; clip-path: polygon(0 0, 36% 70%, 67% 70%, 100% 0, 100% 100%, 0 100%); }
.doodle[data-doodle="ghost"] { background: #b7eaf9; border-radius: 55% 55% 25% 25%; rotate: 7deg; }
.doodle[data-doodle="ghost"] i { width: 5px; height: 6px; border-radius: 50%; }
.doodle[data-doodle="monster"] { background: #c2a7ff; border-radius: 42% 44% 30% 60%; rotate: -14deg; }
.doodle[data-doodle="monster"] i { background: #fff4d9; border-top: 2px solid currentColor; }
.public-area { margin-top: 1rem; }
.public-area h2 { font-size: 1.25rem; }
#public-rooms { list-style: none; padding: 0; margin: .4rem 0 0; display: grid; gap: .5rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); }
#public-rooms > li { display: flex; justify-content: space-between; align-items: center; gap: .45rem; padding: .55rem; border: 1px solid var(--line); border-radius: .75rem; background: var(--input); }
#public-state:empty { display: none; }
.hero-stage, .live-stage { position: relative; min-width: 0; overflow: hidden; isolation: isolate; background: radial-gradient(ellipse at 48% 35%, #634594, #34245c 65%, #251845); border: 1px solid #644d92; border-radius: 1.25rem; }
.hero-stage { height: clamp(230px, 43vw, 520px); }
.hero-stage::before, .live-stage::before { content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none; background: radial-gradient(circle, #e9ddfa58 1px, transparent 1.5px) 0 0 / 17px 17px; opacity: .4; }
.hero-stage canvas, .live-stage canvas { display: block; width: 100%; height: 100%; }
.hero-fallback { position: absolute; width: 61%; height: 51%; left: 20%; top: 22%; display: grid; place-items: center; border: .6rem solid #8261f0; border-radius: .8rem; rotate: -9deg; box-shadow: 24px 18px #e66499; background: #f8eed7; }
.hero-fallback .bolt { width: 30%; height: 70%; background: #7656ee; }
label { display: block; color: var(--white); font-weight: 700; font-size: .88rem; margin-bottom: .32rem; }
label > span { font-weight: 500; color: var(--muted); }
.fields { display: grid; grid-template-columns: 1.4fr 1fr; gap: .6rem; margin-block: .8rem .7rem; }
button, input, select { min-height: 44px; border: 1px solid #685981; border-radius: .68rem; font: inherit; color: var(--white); }
button { font-weight: 750; background: #382956; padding: .48rem .75rem; cursor: pointer; }
button.primary { color: #211530; background: var(--lime); border-color: var(--lime); }
button[aria-pressed="true"] { color: var(--lime); border-color: #b8c65a; background: #382e45; }
button:disabled { opacity: .55; cursor: default; }
input, select { min-width: 0; background: var(--input); padding: .55rem .7rem; }
input { width: 100%; }
input::placeholder { opacity: 1; color: #b5a9cc; }
:focus-visible { outline: 3px solid #f69cc7; outline-offset: 3px; }
.notice { color: var(--lime); font-weight: 700; margin-block: .6rem; }
.notice:empty { margin: 0; }
.game-grid { display: grid; grid-template-columns: minmax(0, 2.35fr) minmax(15.5rem, 1fr); gap: .85rem; }
.station { position: relative; }
.side { display: grid; align-content: start; gap: .85rem; min-width: 0; }
.stage-head { margin-bottom: 1rem; align-items: flex-start; }
.stage-head h1 { font-size: clamp(1.65rem, 4vw, 2.9rem); line-height: 1.06; letter-spacing: -.06em; margin-block: .26rem .45rem; overflow-wrap: anywhere; }
.entry-form h2, .side h2 { font-size: 1.2rem; letter-spacing: -.03em; }
.muted { color: var(--muted); font-size: .9rem; }
.clock { flex: none; font-weight: 850; font-variant-numeric: tabular-nums; border: 1px solid #76528e; padding: .28rem .53rem; border-radius: .53rem; color: var(--lime); }
.clock[data-low="true"] { color: #ffb4d3; border-color: #b77b98; }
.turn-meter { height: .28rem; border-radius: 2rem; background: #3c2b53; overflow: hidden; margin-bottom: .75rem; }
.turn-meter span { display: block; height: 100%; background: linear-gradient(90deg, #b99aff, var(--lime)); transform-origin: left; }
.turn-meter[data-low="true"] span { background: var(--pink); }
.word-hint { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .45rem; padding: .55rem .7rem; background: #110b20; border: 1px solid var(--line); border-radius: .75rem; margin-bottom: .55rem; }
#letter-blanks { display: flex; flex-wrap: wrap; gap: .46rem .7rem; min-width: 0; }
.word-group { display: flex; gap: .25rem; }
.letter { display: grid; place-items: center; width: clamp(.85rem, 2.8vw, 1.35rem); height: 1.45rem; border-bottom: 2px solid #bba1f3; font: bold .9rem ui-monospace, monospace; }
.letter-count { color: #dacaef; font-size: .84rem; }
.revealed-letter { color: var(--lime); border-color: var(--lime); }
.pick-word { padding: .55rem 0; }
.pick-word h2 { font-size: 1rem; margin-bottom: .4rem; }
#word-choices { display: flex; flex-wrap: wrap; gap: .45rem; }
#word-choices button { border-color: #9674d0; }
.row, .toolbar, .board-nav, .panel-tabs { display: flex; align-items: center; gap: .45rem; }
.row button { flex: none; }
.toolbar, .board-nav { flex-wrap: wrap; margin-block: .42rem; }
.board-nav { justify-content: space-between; }
#view-mode { margin-inline-start: auto; font-size: .82rem; }
.toolbar label { margin: 0; }
.toolbar .keyboard-help { flex-basis: 100%; font-size: .82rem; }
.swatches, .tool-buttons, .drawing-rating { display: flex; flex-wrap: wrap; align-items: center; gap: .34rem; }
.swatches { width: 100%; }
.swatches button { width: 44px; padding: 0; position: relative; }
.swatches button::before { content: ""; position: absolute; inset: .5rem; border-radius: 50%; background: var(--swatch); }
.swatches [data-ink="ink"] { --swatch: #251d38; }
.swatches [data-ink="rose"] { --swatch: #e03972; }
.swatches [data-ink="blue"] { --swatch: #2e69d5; }
.swatches [data-ink="leaf"] { --swatch: #28a360; }
.swatches [data-ink="violet"] { --swatch: #8355d8; }
.swatches [data-ink="sun"] { --swatch: #f4bd31; }
.swatches [data-ink="orange"] { --swatch: #f57534; }
.swatches [data-ink="aqua"] { --swatch: #20b8c3; }
.drawing-rating { margin-top: .6rem; }
.drawing-rating > span { margin-right: .25rem; color: var(--muted); font-size: .85rem; }
.live-stage { height: clamp(260px, 42vw, 425px); border-radius: .9rem; }
.live-stage[data-drawing="true"] canvas { cursor: crosshair; touch-action: none; }
.flat-panels { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); gap: .65rem; }
figcaption { font-size: .84rem; color: var(--muted); margin-bottom: .18rem; }
.paper { display: block; width: 100%; height: auto; aspect-ratio: 3 / 2; background: #fff7e7; border: 1px solid #a587cf; border-radius: .65rem; }
.paper[data-active="true"] { cursor: crosshair; touch-action: none; }
#guess-form, .actions { margin-top: .7rem; }
#players { list-style: none; margin: .5rem 0 .65rem; padding: 0; }
#players li { display: flex; gap: .4rem; justify-content: space-between; align-items: center; min-height: 2.05rem; padding: .26rem 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
#players button, .leave { font-size: .8rem; }
.player-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .3rem; }
.player-line { display: flex; align-items: center; gap: .55rem; }
.player-line .doodle { scale: .9; }
.chat-messages { height: 11rem; margin: .65rem 0; padding: .55rem; border: 1px solid var(--line); border-radius: .7rem; overflow-y: auto; overflow-wrap: anywhere; background: #110d20; }
#chat-log { list-style: none; padding: 0; margin: 0; }
#chat-log li { font-size: .9rem; margin-bottom: .4rem; }
#chat-log strong { color: #efb5f5; }
.system-post { color: var(--lime); font-weight: 750; }
#chat-note, #chat-error, #lobby-actions .muted { margin-top: .45rem; font-size: .8rem; }
#chat-error { color: var(--pink); }
.feedback { margin-top: 1rem; }
.feedback form { display: grid; gap: .42rem; max-width: 35rem; }
.feedback textarea { resize: vertical; width: 100%; min-height: 5rem; color: var(--white); background: var(--input); border: 1px solid #685981; border-radius: .65rem; padding: .65rem; font: inherit; }
.feedback button { justify-self: start; }
.guess-spark { display: none; pointer-events: none; position: absolute; z-index: 1; inset: 6rem 0 auto; margin-inline: auto; width: fit-content; padding: .45rem 1rem; border-radius: .8rem; color: #20172e; background: var(--lime); font-size: 1.25rem; font-weight: 900; box-shadow: 0 0 30px #dbf8707d; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (max-width: 700px) {
  .launch, .game-grid { grid-template-columns: 1fr; }
  .wrap { padding-inline: .7rem; }
  .wrap:has(#game:not([hidden])) { padding-bottom: calc(5.15rem + env(safe-area-inset-bottom, 0px)); }
  .mast { margin-bottom: .7rem; }
  .launch { padding-top: .25rem; gap: .75rem; }
  .hero-stage { height: clamp(176px, 50vw, 295px); }
  #hello { font-size: clamp(2.7rem, 11vw, 4.7rem); margin-block: .35rem .72rem; }
  #hello br { display: none; }
  #hello em { display: block; }
  .intro { font-size: 1rem; }
  .entry-form { margin-top: .78rem; }
  .entry-form .primary { width: 100%; }
  input, select { font-size: 1rem; }
  .card { padding: .72rem; }
  .stage-head { margin-bottom: .55rem; }
  .stage-head h1 { margin-block: .16rem .22rem; }
  .eyebrow { letter-spacing: .07em; }
  .live-stage { height: clamp(198px, 59vw, 304px); }
  .board-nav button { padding-inline: .48rem; font-size: .8rem; }
  .toolbar label { margin-inline-end: .15rem; }
  .toolbar button, .toolbar select { padding-inline: .5rem; }
  .toolbar .keyboard-help { display: none; }
  .mobile-dock {
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .35rem;
    position: fixed; z-index: 10; left: 0; right: 0; bottom: 0;
    padding: .45rem .7rem calc(.45rem + env(safe-area-inset-bottom, 0px));
    background: #1b142d; border-top: 1px solid var(--line);
  }
  .mobile-dock button { background: #302343; border-color: #564669; font-size: .82rem; padding-inline: .12rem; }
  #unread-chat { background: var(--lime); color: #211530; border-radius: 99px; font-size: .75rem; padding: .06rem .3rem; }
  #chat-heading, #roster-title, #phase-title, #guess, #chat-text { scroll-margin-block: 1rem 5.9rem; }
}
@media (prefers-reduced-motion: no-preference) {
  button { transition: background-color .16s ease, border-color .16s ease, translate .15s ease; }
  button:hover:not(:disabled) { border-color: #f5c7f4; }
  .primary:hover:not(:disabled) { background: #f0ff9d; }
  button:active:not(:disabled) { translate: 0 1px; }
  .turn-meter span { transition: transform .24s linear, background .2s ease; }
  .clock[data-low="true"] { animation: clock-beat 1s ease-in-out 4; }
  .guess-spark { display: block; animation: score-burst .85s cubic-bezier(.18,.8,.36,1) both; }
  .guess-spark::before, .guess-spark::after { content: ""; position: absolute; width: .55rem; height: .55rem; border-radius: 25%; background: var(--pink); box-shadow: 7rem 0 #93eff7, -1rem 1.1rem #bfa4ff, 8rem 1.2rem var(--lime); }
  .guess-spark::before { left: -.8rem; top: .2rem; rotate: 25deg; }
  .guess-spark::after { left: -1.8rem; top: 1.8rem; rotate: -14deg; }
  .avatar-options label:has(:checked) .doodle { animation: doodle-hop .5s cubic-bezier(.2,.8,.3,1) both; }
  .player-line .doodle:hover { animation: doodle-hop .5s ease both; }
}
@keyframes doodle-hop {
  45% { transform: translateY(-6px) rotate(13deg); }
  72% { transform: translateY(2px) scale(1.06, .9); }
}
@keyframes clock-beat {
  50% { box-shadow: 0 0 0 .22rem #ff94bc32; }
}
@keyframes score-burst {
  0% { opacity: 0; transform: translateY(.7rem) scale(.86); }
  28% { opacity: 1; transform: translateY(0) scale(1.07); }
  66% { opacity: 1; transform: translateY(-.15rem) scale(1); }
  100% { opacity: 0; transform: translateY(-.8rem) scale(.97); }
}
