:root {
  --ink: #17223b;
  --muted: #687087;
  --paper: #fffaf0;
  --cream: #fff2d8;
  --orange: #f15a3a;
  --orange-dark: #d84125;
  --yellow: #ffc857;
  --green: #24a36d;
  --blue: #3478f6;
  --line: #dfd6c6;
  --white: #ffffff;
  --shadow: 0 22px 60px rgba(72, 48, 20, 0.12);
  font-family: Inter, ui-rounded, "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: radial-gradient(circle at 12% 22%, #ffe6ad 0, transparent 28rem), var(--paper); }
button, input, textarea, select { font: inherit; }
button { color: inherit; }
[hidden] { display: none !important; }

.page-shell { width: min(1500px, calc(100% - 40px)); margin: 0 auto; }
.site-header { min-height: 92px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid rgba(23, 34, 59, 0.12); }
.brand { display: flex; gap: 12px; align-items: center; color: inherit; text-decoration: none; }
.brand strong { display: block; font-size: 19px; line-height: 1; letter-spacing: -0.03em; }
.brand small { display: block; color: var(--muted); font-size: 11px; margin-top: 5px; letter-spacing: 0.04em; }
.brand-mark { width: 43px; height: 43px; border-radius: 14px; background: var(--ink); display: grid; place-content: center; gap: 3px; transform: rotate(-3deg); }
.brand-mark span { display: block; height: 4px; border-radius: 4px; }
.brand-mark span:nth-child(1) { width: 23px; background: var(--yellow); }
.brand-mark span:nth-child(2) { width: 17px; background: var(--orange); }
.brand-mark span:nth-child(3) { width: 11px; background: var(--green); }
.connection-pill { padding: 7px 11px; border-radius: 999px; font-size: 11px; font-weight: 800; letter-spacing: 0.05em; text-transform: uppercase; background: #e9edf3; color: var(--muted); }
.connection-pill[data-status="online"] { color: #11633f; background: #dff6e9; }
.connection-pill[data-status="offline"] { color: #9b2f1c; background: #ffe4dc; }

.lobby-layout { min-height: calc(100vh - 92px); padding: 80px 6vw; display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(360px, 480px); gap: 9vw; align-items: center; }
.eyebrow { display: block; font-size: 11px; letter-spacing: 0.18em; font-weight: 900; color: var(--orange); }
.hero-copy h1 { max-width: 760px; font-size: clamp(62px, 7.6vw, 128px); line-height: 0.84; letter-spacing: -0.07em; margin: 22px 0 34px; }
.hero-copy h1 em { color: var(--orange); font-style: normal; }
.hero-example { display: flex; align-items: center; flex-wrap: wrap; gap: 11px; font-size: clamp(18px, 2vw, 28px); font-weight: 850; margin: 0 0 26px; }
.hero-example span { background: var(--white); border: 1px solid var(--line); border-radius: 12px; padding: 8px 13px; box-shadow: 0 6px 0 rgba(23, 34, 59, 0.06); }
.hero-example b { color: var(--orange); }
.hero-description { color: var(--muted); max-width: 630px; font-size: 17px; line-height: 1.7; }
.join-card { background: rgba(255,255,255,0.92); border: 1px solid var(--line); border-radius: 28px; padding: 35px; box-shadow: var(--shadow); backdrop-filter: blur(15px); }
.join-card label { display: block; font-weight: 800; margin: 5px 0 11px; }
.step-number { color: var(--orange); font-size: 10px; font-weight: 900; letter-spacing: 0.16em; }
input, textarea, select { width: 100%; border: 1px solid var(--line); border-radius: 12px; background: #fffdf8; color: var(--ink); outline: none; transition: border .15s, box-shadow .15s; }
input:focus, textarea:focus, select:focus { border-color: var(--orange); box-shadow: 0 0 0 4px rgba(241,90,58,.12); }
input, select { min-height: 50px; padding: 0 14px; }
textarea { padding: 13px; resize: vertical; line-height: 1.5; }
.primary-button, .secondary-button, .quiet-button, .tool-button, .code-button { border: 0; cursor: pointer; font-weight: 850; }
.primary-button { width: 100%; min-height: 54px; margin-top: 18px; padding: 0 18px; border-radius: 13px; background: var(--orange); color: white; box-shadow: 0 7px 0 var(--orange-dark); display: flex; justify-content: space-between; align-items: center; }
.primary-button:active { transform: translateY(4px); box-shadow: 0 3px 0 var(--orange-dark); }
.primary-button:disabled { opacity: .45; cursor: not-allowed; }
.or-divider { display: flex; align-items: center; gap: 14px; margin: 31px 0 24px; color: #979dac; font-size: 11px; text-transform: uppercase; letter-spacing: .12em; }
.or-divider::before, .or-divider::after { content: ""; height: 1px; background: var(--line); flex: 1; }
.join-row { display: grid; grid-template-columns: 1fr 105px; gap: 9px; }
.room-code-input { text-transform: uppercase; letter-spacing: .22em; font-weight: 900; }
.secondary-button { border-radius: 12px; background: var(--ink); color: white; }
.notice { min-height: 20px; margin: 16px 0 0; color: var(--orange-dark); font-size: 13px; font-weight: 700; }
.privacy-note { text-align: center; color: #969cad; font-size: 11px; margin: 18px 0 0; }

.room-screen { padding: 24px 0 48px; }
.room-bar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; margin-bottom: 18px; }
.room-label { display: block; color: var(--muted); font-size: 9px; font-weight: 900; letter-spacing: .16em; }
.code-button { background: transparent; padding: 4px 0; font-size: 24px; letter-spacing: .13em; }
.code-button small { vertical-align: middle; letter-spacing: normal; color: var(--orange); background: #ffe5de; border-radius: 7px; padding: 4px 7px; font-size: 9px; text-transform: uppercase; }
.round-summary { justify-self: center; color: var(--muted); font-weight: 750; font-size: 13px; }
.quiet-button { justify-self: end; background: transparent; color: var(--muted); padding: 10px; }
.game-layout { display: grid; grid-template-columns: 225px minmax(420px, 1fr) 290px; gap: 16px; align-items: start; }
.panel { background: rgba(255,255,255,.92); border: 1px solid var(--line); border-radius: 18px; }
.panel-heading { display: flex; justify-content: space-between; align-items: center; padding: 17px 18px; border-bottom: 1px solid #ece6dc; }
.panel-heading h2 { font-size: 14px; margin: 0; letter-spacing: -.02em; }
.panel-heading span { color: var(--muted); font-size: 10px; font-weight: 800; text-transform: uppercase; }
.player-list { list-style: none; margin: 0; padding: 8px; }
.player-item { display: grid; grid-template-columns: 32px 1fr auto; gap: 9px; align-items: center; padding: 10px; border-radius: 11px; }
.player-item + .player-item { margin-top: 3px; }
.player-item.self { background: var(--cream); }
.player-avatar { width: 32px; height: 32px; border-radius: 10px; display: grid; place-content: center; color: white; font-weight: 900; font-size: 12px; background: var(--ink); }
.player-name { min-width: 0; font-weight: 750; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-name small { display: block; color: var(--muted); font-size: 8px; text-transform: uppercase; margin-top: 2px; }
.player-score { font-size: 12px; font-weight: 900; }
.player-item.disconnected { opacity: .45; }
.player-item.guessed .player-avatar { background: var(--green); }
.play-panel { min-width: 0; }
.word-strip { min-height: 82px; display: flex; justify-content: space-between; align-items: center; gap: 15px; background: var(--ink); color: white; border-radius: 18px 18px 0 0; padding: 14px 20px; }
.word-strip > div:first-child { min-width: 0; }
.word-kicker { display: block; font-size: 9px; color: #aeb8cf; letter-spacing: .16em; font-weight: 900; text-transform: uppercase; margin-bottom: 5px; }
#current-word { display: block; font-size: clamp(15px, 2vw, 24px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#alias-hint { display: block; color: #aeb8cf; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.timer { width: 56px; height: 56px; flex: 0 0 auto; border: 2px solid var(--yellow); border-radius: 50%; display: grid; place-content: center; text-align: center; }
.timer span { font-weight: 900; font-size: 19px; line-height: 1; }
.timer small { color: #aeb8cf; font-size: 8px; }
.canvas-frame { position: relative; width: 100%; aspect-ratio: 16 / 10; background: white; border: 1px solid var(--line); border-top: 0; overflow: hidden; }
#drawing-canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
#drawing-canvas[data-tool="fill"] { cursor: cell; }
#drawing-canvas[data-tool="eyedropper"] { cursor: copy; }
.canvas-placeholder, .game-over-card, .word-choice-card { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; text-align: center; padding: 30px; background: repeating-linear-gradient(-45deg, #fff, #fff 18px, #fffdf8 18px, #fffdf8 36px); color: var(--muted); }
.canvas-placeholder, .game-over-card { pointer-events: none; }
.canvas-placeholder strong { color: var(--ink); margin: 9px 0 5px; }
.canvas-placeholder span:last-child { font-size: 12px; }
.placeholder-pencil { color: var(--orange); font-size: 40px; }
.game-over-card { background: rgba(255,250,240,.96); }
.game-over-card span { color: var(--orange); font-size: 10px; letter-spacing: .18em; font-weight: 900; }
.game-over-card strong { color: var(--ink); font-size: clamp(30px, 5vw, 62px); letter-spacing: -.05em; margin: 9px 0; }
.game-over-card p { margin: 0; }
.word-choice-card { z-index: 2; align-content: center; }
.word-choice-card > span { color: var(--orange); font-size: 10px; letter-spacing: .18em; font-weight: 900; }
.word-choice-card > strong { color: var(--ink); font-size: clamp(22px, 4vw, 40px); letter-spacing: -.04em; margin: 8px 0 22px; }
.word-choice-options { width: min(680px, 100%); display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.word-choice-button { min-width: 0; min-height: 112px; border: 1px solid var(--line); border-radius: 16px; background: white; color: var(--ink); padding: 15px 12px; cursor: pointer; box-shadow: 0 6px 0 rgba(23, 34, 59, .08); transition: transform .15s, border-color .15s; }
.word-choice-button:hover { border-color: var(--orange); transform: translateY(-2px); }
.word-choice-button:active { transform: translateY(3px); box-shadow: 0 3px 0 rgba(23, 34, 59, .08); }
.word-choice-button strong { display: block; font-size: clamp(20px, 3vw, 31px); overflow-wrap: anywhere; }
.word-choice-button small { display: block; color: var(--muted); margin-top: 8px; line-height: 1.35; overflow-wrap: anywhere; }
.drawing-tools { min-height: 58px; border: 1px solid var(--line); border-top: 0; border-radius: 0 0 18px 18px; background: white; display: grid; gap: 8px; padding: 9px 12px; }
.tool-row, .tool-set, .history-tools, .colors { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tool-row { width: 100%; }
.history-tools { margin-left: auto; }
.color-swatch { width: 29px; height: 29px; border: 3px solid white; border-radius: 50%; background: var(--swatch); box-shadow: 0 0 0 1px var(--line); cursor: pointer; }
.color-swatch.selected { box-shadow: 0 0 0 2px var(--ink); }
.custom-color { width: 31px; height: 31px; border: 1px solid var(--line); border-radius: 50%; overflow: hidden; cursor: pointer; }
.custom-color input { width: 43px; height: 43px; min-height: 0; padding: 0; border: 0; border-radius: 0; transform: translate(-6px, -6px); cursor: pointer; }
.size-control { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 10px; font-weight: 800; }
.size-control output { min-width: 18px; color: var(--ink); text-align: center; }
.size-control input { width: 95px; min-height: 0; padding: 0; box-shadow: none; }
.tool-button { background: #f2efe9; border-radius: 9px; padding: 8px 10px; font-size: 10px; }
.tool-button:hover { background: #e9e4dc; }
.tool-button.active { background: var(--ink); color: white; }
.tool-button.danger { color: var(--orange-dark); }
.shortcut-help { margin-left: auto; }
.shortcut-panel { border-top: 1px solid #ece6dc; padding-top: 8px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px 12px; color: var(--muted); font-size: 10px; }
.shortcut-panel[hidden] { display: none; }
.shortcut-panel span { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
kbd { min-width: 20px; border: 1px solid #d9d2c7; border-bottom-width: 2px; border-radius: 5px; background: #faf8f4; color: var(--ink); padding: 2px 5px; font: 700 9px/1.2 ui-monospace, "Cascadia Code", monospace; text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.host-panel { margin-top: 16px; padding-bottom: 18px; }
.host-panel .panel-heading { border-bottom: 0; }
.host-panel .panel-heading h2 { font-size: 22px; margin-top: 5px; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 0 18px 14px; }
.settings-grid label, .word-pack-label { font-size: 11px; font-weight: 800; }
.settings-grid select { display: block; margin-top: 6px; min-height: 42px; }
.word-pack-label { display: flex; justify-content: space-between; gap: 15px; padding: 0 18px 7px; }
.word-pack-label small { color: var(--muted); font-weight: 500; }
#word-pack { width: calc(100% - 36px); margin: 0 18px; font-family: ui-monospace, "Cascadia Code", monospace; font-size: 12px; }
.host-actions { display: flex; align-items: end; gap: 15px; padding: 0 18px; }
.host-actions .notice { flex: 1; }
.host-actions .primary-button { width: 180px; }
.guest-waiting { margin-top: 16px; padding: 20px; color: var(--muted); text-align: center; font-size: 13px; }
.chat-panel { display: flex; flex-direction: column; height: min(680px, calc(100vh - 170px)); }
.chat-messages { flex: 1; overflow-y: auto; padding: 10px 13px; }
.chat-line { font-size: 12px; line-height: 1.45; padding: 7px 2px; overflow-wrap: anywhere; }
.chat-line strong { margin-right: 5px; }
.chat-line.system { color: var(--green); font-weight: 750; }
.guess-form { padding: 11px; border-top: 1px solid #ece6dc; display: grid; grid-template-columns: 1fr 42px; gap: 7px; }
.guess-form input { min-height: 43px; font-size: 12px; }
.guess-form button { border: 0; border-radius: 10px; background: var(--orange); color: white; font-size: 19px; font-weight: 900; cursor: pointer; }
.guess-form input:disabled, .guess-form button:disabled { opacity: .45; }
.toast-region { position: fixed; z-index: 10; top: 20px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; width: min(380px, calc(100% - 30px)); pointer-events: none; }
.toast { background: var(--ink); color: white; border-radius: 12px; padding: 12px 16px; box-shadow: 0 12px 34px rgba(23,34,59,.24); font-size: 13px; font-weight: 750; animation: toast-in .2s ease-out; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }

@media (max-width: 1150px) {
  .game-layout { grid-template-columns: 190px minmax(400px, 1fr); }
  .chat-panel { grid-column: 1 / -1; height: 260px; }
  .lobby-layout { gap: 5vw; padding-inline: 2vw; }
}
@media (max-width: 780px) {
  .page-shell { width: min(100% - 24px, 1500px); }
  .site-header { min-height: 75px; }
  .lobby-layout { min-height: auto; padding: 45px 0; display: block; }
  .hero-copy h1 { font-size: clamp(56px, 19vw, 96px); }
  .hero-description { margin-bottom: 34px; }
  .join-card { padding: 24px; }
  .room-bar { grid-template-columns: 1fr auto; }
  .round-summary { grid-row: 2; grid-column: 1 / -1; margin-top: 10px; }
  .game-layout { display: flex; flex-direction: column; }
  .play-panel, .players-panel, .chat-panel { width: 100%; }
  .play-panel { order: 1; }
  .players-panel { order: 2; }
  .chat-panel { order: 3; height: 280px; }
  .canvas-frame { aspect-ratio: 4 / 3; }
  .canvas-frame.choosing { min-height: 390px; aspect-ratio: auto; }
  .word-choice-options { grid-template-columns: 1fr; gap: 8px; }
  .word-choice-button { min-height: 72px; padding: 10px; }
  .word-choice-card { padding: 18px; }
  .word-choice-card > strong { margin-bottom: 12px; }
  .player-list { display: grid; grid-template-columns: repeat(2, 1fr); }
  .shortcut-panel { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .settings-grid { grid-template-columns: 1fr; }
  .host-actions { display: block; }
  .host-actions .primary-button { width: 100%; }
}
@media (max-width: 460px) {
  .brand small { display: none; }
  .hero-copy h1 { font-size: 55px; }
  .hero-example { gap: 7px; }
  .hero-example span { padding: 6px 9px; }
  .word-strip { padding: 12px; }
  .timer { width: 48px; height: 48px; }
  .player-list { grid-template-columns: 1fr; }
  .drawing-tools { gap: 9px; }
  .history-tools { width: 100%; margin-left: 0; }
  .tool-options { align-items: flex-start; }
  .size-control { order: 2; width: calc(100% - 90px); }
  .size-control input { flex: 1; }
  .shortcut-help { margin-left: 0; }
  .shortcut-panel { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
