:root {
  --ink: #16201d;
  --ink-soft: #53605b;
  --paper: #f5f0e4;
  --paper-deep: #e9dfca;
  --cream: #fffaf0;
  --teal: #0e6a62;
  --teal-deep: #084a45;
  --red: #a94333;
  --gold: #bd8c35;
  --line: rgba(22, 32, 29, .15);
  --shadow: 0 18px 55px rgba(21, 28, 26, .13);
  font-family: Inter, Pretendard, "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 10% -10%, #fffdf6 0, transparent 36%), var(--paper); }
button, input, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid rgba(14, 106, 98, .3); outline-offset: 2px; }
[hidden] { display: none !important; }

.ambient-grid {
  position: fixed; inset: 0; pointer-events: none; opacity: .24; z-index: -1;
  background-image: linear-gradient(rgba(22,32,29,.055) 1px, transparent 1px), linear-gradient(90deg, rgba(22,32,29,.055) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: linear-gradient(to bottom, #000, transparent 75%);
}

.topbar {
  min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 20px;
  padding: 12px clamp(16px, 4vw, 52px); color: #f8f2e6; background: rgba(22, 32, 29, .97);
  border-bottom: 3px solid var(--gold); position: relative; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; min-width: max-content; }
.brand-seal { width: 43px; height: 43px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.45); transform: rotate(45deg); font: 700 22px/1 Georgia, serif; }
.brand-seal::first-letter { transform: rotate(-45deg); }
.brand > span:last-child { display: grid; gap: 2px; }
.brand strong { font: 700 clamp(20px, 2.5vw, 29px)/1.1 Georgia, "Noto Serif KR", serif; letter-spacing: -.04em; }
.brand-kicker, .chapter-label { font-size: 10px; font-weight: 800; letter-spacing: .18em; color: #d4b876; }
.top-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 7px; }
.connection-status { font-size: 12px; font-weight: 700; color: #9ad8bc; padding-right: 4px; }
.connection-status::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: currentColor; margin-right: 6px; }
.connection-status.is-offline { color: #e29a88; }

.button { border: 0; border-radius: 8px; min-height: 42px; padding: 10px 16px; font-weight: 800; cursor: pointer; transition: transform .15s ease, background .15s ease, opacity .15s ease; }
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:active:not(:disabled) { transform: translateY(0); }
.button:disabled { cursor: not-allowed; opacity: .42; }
.button-primary { color: white; background: var(--teal); box-shadow: 0 7px 18px rgba(14,106,98,.19); }
.button-primary:hover:not(:disabled) { background: var(--teal-deep); }
.button-secondary { color: var(--ink); background: var(--paper-deep); }
.button-dark { color: white; background: var(--ink); }
.button-danger { color: white; background: var(--red); }
.button-ghost { color: #f8f2e6; background: rgba(255,255,255,.08); min-height: 36px; padding: 7px 11px; font-size: 12px; }
.danger-text { color: #efb0a1; }
.button-wide { width: 100%; }
.help-button, .close-button {
  border: 1px solid rgba(255,255,255,.34); background: transparent; color: white; border-radius: 50%; width: 39px; height: 39px;
  display: grid; place-items: center; cursor: pointer; font: 800 20px/1 Georgia, serif; flex: 0 0 auto;
}
.log-button { font: 900 21px/1 sans-serif; letter-spacing: -2px; padding-right: 2px; }
.close-button { color: var(--ink); border-color: var(--line); font: 300 28px/1 sans-serif; }

.turn-order {
  display: flex; align-items: center; justify-content: center; gap: 6px; overflow-x: auto; min-height: 54px; padding: 8px 16px;
  border-bottom: 1px solid var(--line); background: rgba(255,250,240,.82); backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 15;
  scrollbar-width: thin;
}
.order-item { display: flex; align-items: center; gap: 7px; flex: 0 0 auto; border: 1px solid var(--line); border-radius: 999px; padding: 6px 10px 6px 7px; font-size: 12px; font-weight: 800; background: rgba(255,255,255,.58); }
.order-item.is-current { color: white; background: var(--teal); border-color: var(--teal); box-shadow: 0 4px 13px rgba(14,106,98,.2); }
.order-item.is-eliminated { opacity: .45; text-decoration: line-through; }
.order-number { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--paper-deep); color: var(--ink); font-size: 11px; }
.order-item.is-current .order-number { background: white; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #54a177; }
.status-dot.offline { background: var(--red); }
.status-dot.viewing-log { background: #8b5cf6; box-shadow: 0 0 0 2px #fff, 0 0 0 4px rgba(139,92,246,.28); }

.main-shell { width: min(1400px, 100%); margin: 0 auto; padding: clamp(18px, 3vw, 42px); }
.lobby-layout, .game-layout { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: clamp(16px, 2.5vw, 28px); align-items: start; }
.panel { border: 1px solid var(--line); border-radius: 14px; background: rgba(255,250,240,.86); box-shadow: var(--shadow); overflow: hidden; }
.panel-inner { padding: clamp(18px, 3vw, 30px); }
.hero-panel { min-height: 470px; position: relative; background: linear-gradient(145deg, rgba(255,250,240,.95), rgba(235,225,202,.8)); }
.hero-panel::after { content: "0 1 2 3 4 5 6 7 8 9 10 11"; position: absolute; right: -18px; bottom: 8px; color: rgba(22,32,29,.045); font: 700 clamp(38px, 6vw, 80px)/1 Georgia, serif; writing-mode: vertical-rl; letter-spacing: .02em; pointer-events: none; }
.hero-copy { max-width: 680px; padding: clamp(28px, 5vw, 64px); position: relative; z-index: 1; }
.hero-copy h1 { margin: 10px 0 17px; max-width: 650px; font: 700 clamp(38px, 6vw, 76px)/.98 Georgia, "Noto Serif KR", serif; letter-spacing: -.055em; }
.hero-copy p { max-width: 590px; color: var(--ink-soft); font-size: clamp(15px, 2vw, 18px); line-height: 1.75; }
.hero-rule { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 34px; }
.hero-rule div { border-top: 2px solid var(--ink); padding-top: 10px; }
.hero-rule strong { display: block; font: 700 25px Georgia, serif; }
.hero-rule span { color: var(--ink-soft); font-size: 12px; }

.side-stack { display: grid; gap: 16px; }
.section-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 18px; }
.section-heading h2, .dialog-card h2 { margin: 4px 0 0; font: 700 25px/1.15 Georgia, "Noto Serif KR", serif; letter-spacing: -.035em; }
.count-badge { border: 1px solid var(--line); border-radius: 99px; padding: 5px 9px; color: var(--ink-soft); font-size: 12px; font-weight: 800; }
.player-list { display: grid; gap: 8px; }
.player-row { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 9px; border: 1px solid var(--line); border-radius: 9px; background: rgba(255,255,255,.45); }
.player-row.is-me { border-color: rgba(14,106,98,.45); }
.player-row-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 800; }
.player-row small { display: block; color: var(--ink-soft); font-weight: 600; }
.spectator-list-block { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.section-heading.compact { margin-bottom: 10px; }
.section-heading.compact h3 { margin: 3px 0 0; font: 700 18px/1.15 Georgia, "Noto Serif KR", serif; }
.order-controls { display: flex; gap: 3px; }
.mini-button { border: 1px solid var(--line); background: var(--cream); border-radius: 6px; min-width: 30px; height: 30px; cursor: pointer; font-weight: 900; }
.mini-button.danger { color: var(--red); }
.host-settings { display: grid; gap: 13px; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.checkbox-row { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; color: var(--ink-soft); font-size: 13px; line-height: 1.45; }
.checkbox-row input { width: 18px; height: 18px; accent-color: var(--teal); flex: 0 0 auto; }
.host-note { margin: 0; color: var(--ink-soft); font-size: 12px; line-height: 1.5; }
.color-balance-setting { display: grid; gap: 9px; padding: 13px; border: 1px solid var(--line); border-radius: 9px; background: rgba(255,255,255,.5); }
.color-balance-heading, .color-counts, .range-ends { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.color-balance-heading span, .range-ends { color: var(--ink-soft); font-size: 10px; font-weight: 800; }
.color-counts { justify-content: center; }
.color-count { min-width: 100px; padding: 7px 10px; border: 1px solid; border-radius: 7px; text-align: center; font-size: 12px; font-weight: 800; }
.color-count.black { color: white; border-color: #111; background: #1c211f; }
.color-count.white { color: var(--ink); border-color: #aaa69c; background: #fff; }
.color-balance-range { width: 100%; margin: 2px 0 0; accent-color: var(--gold); direction: rtl; }
.personal-color-setting { width: min(520px, 100%); margin: 18px auto; }

.game-board { display: grid; gap: 17px; }
.turn-card { position: relative; padding: clamp(18px,3vw,28px); color: white; background: var(--ink); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow); }
.turn-card::after { content: "⌁"; position: absolute; right: 22px; top: -26px; font: 130px Georgia, serif; color: rgba(255,255,255,.05); transform: rotate(-18deg); }
.turn-card h1 { margin: 6px 0 4px; font: 700 clamp(25px,4vw,40px)/1.1 Georgia, "Noto Serif KR", serif; }
.turn-card p { margin: 0; color: rgba(255,255,255,.68); }
.turn-card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.turn-timer { position: relative; z-index: 1; flex: 0 0 auto; min-width: 88px; padding: 9px 12px; border: 1px solid rgba(255,255,255,.22); border-radius: 9px; text-align: right; background: rgba(255,255,255,.07); }
.turn-timer span, .turn-timer strong { display: block; }
.turn-timer span { color: rgba(255,255,255,.55); font-size: 9px; font-weight: 900; letter-spacing: .1em; }
.turn-timer strong { margin-top: 2px; color: #f3cf78; font: 700 22px Georgia,serif; }
.pause-banner { margin-top: 14px; padding: 10px 12px; border: 1px solid rgba(255,205,135,.4); border-radius: 8px; color: #ffe0a6; background: rgba(169,67,51,.2); font-size: 13px; font-weight: 700; }
.code-area { padding: clamp(16px,3vw,26px); }
.code-section + .code-section { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--line); }
.my-code-section { margin: -5px -7px 24px; padding: 18px 16px 7px; border: 2px solid rgba(14,106,98,.52); border-radius: 12px; background: linear-gradient(135deg, rgba(14,106,98,.12), rgba(255,255,255,.62)); box-shadow: inset 5px 0 0 var(--teal); }
.my-code-section + .opponent-divider { margin-top: 0; }
.my-code-badge { display: inline-flex; align-items: center; margin-right: 9px; padding: 4px 7px; border-radius: 5px; color: white; background: var(--teal); font: 800 9px/1 sans-serif; letter-spacing: .13em; vertical-align: 2px; }
.opponent-divider { display: flex; align-items: center; gap: 10px; margin: 2px 0 4px; color: var(--ink-soft); font-size: 10px; font-weight: 900; letter-spacing: .15em; }
.opponent-divider::before, .opponent-divider::after { content: ""; height: 1px; background: var(--line); flex: 1; }
.code-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 11px; }
.code-title h3 { margin: 0; font-size: 15px; }
.code-title span { color: var(--ink-soft); font-size: 12px; }
.code-row { display: flex; align-items: flex-end; gap: clamp(5px, 1vw, 10px); overflow-x: auto; padding: 18px 13px 16px; min-height: 128px; scrollbar-width: thin; }
.code-tile {
  position: relative; flex: 0 0 clamp(54px, 7vw, 72px); height: clamp(86px, 11vw, 108px); border-radius: 8px 8px 5px 5px;
  display: grid; place-items: center; border: 2px solid #111; box-shadow: 0 7px 14px rgba(22,32,29,.16); font: 700 clamp(23px,4vw,35px)/1 Georgia, serif;
  transition: transform .18s ease, box-shadow .18s ease;
}
button.code-tile { cursor: pointer; }
button.code-tile:hover { transform: translateY(-5px); box-shadow: 0 12px 20px rgba(22,32,29,.22); }
.code-tile.black { color: #f8f2e7; background: linear-gradient(145deg, #303633, #0e1211); }
.code-tile.white { color: #18201d; background: linear-gradient(145deg, #fff, #dedbd2); border-color: #b8b4aa; }
.code-tile.is-revealed { transform: rotate(3deg) translateY(6px); box-shadow: 0 3px 7px rgba(22,32,29,.13); }
.code-tile.is-selected { outline: 4px solid var(--gold); outline-offset: 3px; transform: translateY(-6px); }
.code-tile.is-last-inserted { box-shadow: 0 0 0 3px var(--gold), 0 9px 20px rgba(126,85,18,.28); }
.code-tile.is-last-inserted.is-revealed { box-shadow: 0 0 0 3px var(--gold), 0 5px 12px rgba(126,85,18,.24); }
.new-tile-label { position: absolute; top: -10px; right: -8px; z-index: 2; padding: 4px 5px; border-radius: 4px; color: #fff; background: var(--gold); box-shadow: 0 3px 8px rgba(80,52,8,.22); font: 900 8px/1 sans-serif; letter-spacing: .1em; }
.tile-color-label { position: absolute; left: 0; right: 0; bottom: 8px; text-align: center; font: 800 8px/1 sans-serif; letter-spacing: .16em; opacity: .55; }
.joker-mark { font-size: .72em; letter-spacing: -.08em; }
.pending-note { color: var(--gold); font-size: 12px; font-weight: 800; }
.pending-draw-separator { flex: 0 0 auto; align-self: stretch; display: grid; place-items: center; align-content: center; gap: 2px; min-width: 68px; color: var(--gold); }
.pending-draw-separator span { font: 700 28px Georgia,serif; }
.pending-draw-separator small { font-size: 8px; font-weight: 900; white-space: nowrap; }

.action-panel { padding: clamp(18px,3vw,28px); }
.action-panel h2 { margin: 5px 0 7px; font: 700 24px Georgia, "Noto Serif KR", serif; }
.action-panel > p { margin: 0 0 18px; color: var(--ink-soft); line-height: 1.55; }
.draw-display { display: flex; align-items: center; gap: 15px; margin-bottom: 18px; padding: 13px; border: 1px dashed var(--line); border-radius: 10px; }
.draw-display .code-tile { flex-basis: 58px; height: 84px; }
.pile-button { display: flex; align-items: center; justify-content: center; gap: 14px; width: 100%; min-height: 78px; background: var(--teal); color: white; border: 0; border-radius: 10px; cursor: pointer; font-weight: 900; }
.pile-button:disabled { cursor: not-allowed; opacity: .34; }
.pile-stack { position: relative; width: 42px; height: 54px; border: 2px solid white; border-radius: 5px; background: #243c36; box-shadow: 4px -4px 0 #668179, 8px -8px 0 #a6b4ae; }
.color-pile-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pile-button span:last-child strong, .pile-button span:last-child small { display: block; }
.pile-button span:last-child small { margin-top: 4px; opacity: .72; }
.pile-button.black-pile { background: #18201d; }
.pile-button.white-pile { color: #18201d; border: 1px solid #aaa69c; background: #fff; }
.pile-stack.white { border-color: #777; background: #fff; box-shadow: 4px -4px 0 #dedbd2, 8px -8px 0 #aaa69c; }
.empty-pile { background: var(--teal); }
.guess-picker { display: grid; gap: 14px; }
.guess-target { min-height: 48px; display: flex; align-items: center; padding: 10px 12px; border-radius: 8px; background: var(--paper-deep); color: var(--ink-soft); font-size: 13px; }
.number-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.number-choice { border: 1px solid var(--line); border-radius: 7px; min-height: 42px; background: var(--cream); cursor: pointer; font-weight: 900; }
.number-choice.is-selected { color: white; background: var(--teal); border-color: var(--teal); }
.number-choice.joker { grid-column: span 2; color: var(--red); }
.decision-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.guess-actions { display: grid; grid-template-columns: minmax(0,3fr) minmax(112px,1fr); gap: 9px; }
.guess-actions .button-primary { min-height: 52px; font-size: 15px; }
.stop-turn-button { min-height: 40px; align-self: center; font-size: 12px; }

.joker-placement { padding: 18px; border: 1px solid rgba(189,140,53,.35); border-radius: 10px; background: #fff8e7; }
.joker-placement h3 { margin: 0 0 6px; font: 700 20px Georgia, serif; }
.placement-joker-preview { display: flex; align-items: center; gap: 16px; margin-top: 16px; padding: 14px; border: 1px solid rgba(189,140,53,.32); border-radius: 10px; background: rgba(255,255,255,.68); }
.placement-joker-image { flex: 0 0 auto; }
.placement-joker-image .code-tile { width: 62px; height: 92px; font-size: 25px; }
.placement-joker-details { min-width: 0; flex: 1; }
.placement-joker-preview strong, .placement-joker-preview small { display: block; }
.placement-joker-preview strong { margin: 4px 0 5px; font: 700 18px Georgia,"Noto Serif KR",serif; }
.placement-joker-preview small { color: var(--ink-soft); line-height: 1.45; }
.placement-received { margin: 0 0 9px; color: var(--ink-soft); font-size: 13px; }
.placement-received strong { display: inline; margin: 0; color: var(--ink); font-size: 13px; font-weight: 900; }
.placement-progress { display: inline-block; padding: 3px 7px; border-radius: 999px; color: #fff; background: var(--gold); font-size: 10px; font-weight: 900; }
.placement-joker-queue { display: flex; flex-wrap: wrap; gap: 7px; margin: 10px 0; }
.joker-queue-item { display: flex; align-items: center; gap: 7px; min-width: 116px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; background: rgba(255,255,255,.72); opacity: .58; }
.joker-queue-item.is-current { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(189,140,53,.18); opacity: 1; }
.joker-queue-item.is-complete { opacity: .42; }
.joker-queue-item strong { margin: 0; font-size: 12px; font-weight: 800; line-height: 1.2; }
.joker-queue-item small { margin-top: 2px; font-size: 9px; font-weight: 900; }
.joker-queue-swatch { display: grid; place-items: center; width: 25px; height: 34px; border: 1px solid #111; border-radius: 4px; font: 700 13px Georgia,serif; }
.joker-queue-swatch.black { color: white; background: #151918; }
.joker-queue-swatch.white { color: #18201d; border-color: #aaa69c; background: #fff; }
.placement-row { display: flex; align-items: center; gap: 5px; overflow-x: auto; padding: 12px 2px 5px; }
.placement-slot { flex: 0 0 30px; align-self: stretch; min-height: 92px; border: 1px dashed var(--gold); background: rgba(189,140,53,.08); border-radius: 7px; color: var(--gold); cursor: pointer; font-size: 20px; }
.placement-row .code-tile { flex-basis: 48px; height: 78px; font-size: 22px; pointer-events: none; }
.setup-private-code { display: flex; align-items: flex-end; justify-content: center; gap: 7px; overflow-x: auto; margin: 17px 0; padding: 13px 5px 17px; border: 1px dashed rgba(14,106,98,.35); border-radius: 10px; background: rgba(255,255,255,.52); }
.setup-private-code .code-tile { flex-basis: 52px; height: 82px; font-size: 23px; }
.sealed-code-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
.sealed-code-card { display: flex; align-items: center; gap: 12px; min-height: 78px; padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: linear-gradient(135deg,rgba(22,32,29,.06),rgba(255,255,255,.5)); }
.sealed-code-mark { display: grid; place-items: center; width: 42px; height: 52px; border: 1px solid rgba(22,32,29,.3); border-radius: 6px; color: var(--gold); background: var(--ink); font: 700 23px Georgia,serif; }
.sealed-code-card strong, .sealed-code-card small { display: block; }
.sealed-code-card small { margin-top: 4px; color: var(--ink-soft); font-size: 11px; }

.game-log { max-height: 330px; overflow: auto; display: grid; gap: 9px; padding-right: 4px; }
.log-entry { padding-left: 11px; border-left: 2px solid var(--line); color: var(--ink-soft); font-size: 12px; line-height: 1.5; }
.log-entry.correct { border-color: var(--teal); color: var(--teal-deep); }
.log-entry.wrong, .log-entry.elimination { border-color: var(--red); }
.log-entry.winner { border-color: var(--gold); color: #785314; font-weight: 800; }
.log-entry.undo { border-color: #6f5aa8; color: #493675; font-weight: 800; }
.log-entry.is-reverted { opacity: .44; text-decoration: line-through; text-decoration-thickness: 1px; }
.spectator-note, .empty-state { padding: 14px; border-radius: 9px; color: var(--ink-soft); background: var(--paper-deep); font-size: 13px; line-height: 1.55; }
.winner-card { text-align: center; padding: clamp(30px,7vw,70px); background: linear-gradient(145deg, #fff9e8, #ead7a8); }
.winner-glyph { font: 700 70px Georgia, serif; color: var(--gold); }
.winner-card h1 { margin: 5px 0 10px; font: 700 clamp(36px,6vw,62px) Georgia, serif; }
.final-layout { display: grid; grid-template-columns: minmax(0,1fr) 330px; gap: clamp(16px,2.5vw,28px); align-items: start; }
.final-layout.single-column { grid-template-columns: minmax(0,1fr); }
.final-results-heading { margin: 36px 0 14px; padding-top: 26px; border-top: 1px solid rgba(22,32,29,.15); text-align: left; }
.final-results-heading h2 { margin: 5px 0 0; font: 700 clamp(23px,3vw,32px) Georgia,"Noto Serif KR",serif; }
.final-standings { display: grid; gap: 10px; text-align: left; }
.final-standing-row { display: grid; gap: 12px; padding: 16px; border: 1px solid rgba(22,32,29,.14); border-radius: 11px; background: rgba(255,250,240,.58); }
.final-standing-row.is-winner { border-color: rgba(189,140,53,.72); background: rgba(255,249,226,.86); box-shadow: inset 4px 0 0 var(--gold); }
.final-player-heading { display: flex; align-items: center; gap: 11px; }
.final-player-heading strong, .final-player-heading small { display: block; }
.final-player-heading strong { font: 700 19px Georgia,"Noto Serif KR",serif; }
.final-player-heading small { margin-top: 3px; color: var(--ink-soft); font-size: 11px; }
.final-rank { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; color: white; background: var(--ink); font: 700 17px Georgia,serif; }
.is-winner .final-rank { color: var(--ink); background: var(--gold); }
.final-code-row { display: flex; align-items: flex-end; gap: 7px; overflow-x: auto; padding: 10px 5px 13px; }
.final-code-row .code-tile { flex-basis: 48px; height: 76px; font-size: 21px; }
.final-code-row .code-tile.is-revealed { transform: none; }
.final-draw-separator { flex: 0 0 auto; align-self: stretch; display: grid; place-items: center; align-content: center; gap: 2px; min-width: 68px; color: #805b1d; }
.final-draw-separator span { font: 700 27px Georgia,serif; }
.final-draw-separator small { font-size: 9px; font-weight: 900; white-space: nowrap; }
.final-actions { margin-top: 22px; }
.final-actions p { margin: 0; color: var(--ink-soft); }
.final-host-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 9px; }

.dialog { border: 0; padding: 0; background: transparent; width: min(700px, calc(100% - 24px)); max-height: calc(100vh - 24px); overflow: visible; }
.dialog::backdrop { background: rgba(10, 15, 13, .72); backdrop-filter: blur(4px); }
.dialog-card { border: 1px solid rgba(255,255,255,.4); border-radius: 14px; background: var(--cream); box-shadow: 0 30px 90px rgba(0,0,0,.3); padding: clamp(22px,4vw,38px); max-height: calc(100vh - 24px); overflow: auto; }
.join-card { max-width: 460px; margin: auto; }
.compact-card { max-width: 480px; margin: auto; }
.dialog-card > p { color: var(--ink-soft); line-height: 1.65; }
.dialog-card label { display: block; margin: 20px 0 7px; font-size: 13px; font-weight: 900; }
.dialog-card input { width: 100%; border: 1px solid var(--line); background: white; border-radius: 8px; min-height: 48px; padding: 10px 13px; margin-bottom: 12px; }
.dialog-title-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.form-error { min-height: 20px; margin: 0 0 8px !important; color: var(--red) !important; font-size: 13px; font-weight: 700; }
.help-dialog { width: min(980px, calc(100% - 24px)); }
.log-dialog { width: min(760px, calc(100% - 24px)); }
.log-dialog-card { padding: clamp(22px,4vw,34px); }
.dialog-game-log { max-height: min(62vh, 620px); margin-top: 18px; padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,.48); }
.presence-legend { display: flex; flex-wrap: wrap; gap: 10px 18px; margin-top: 16px; padding: 11px 13px; border-radius: 9px; color: var(--ink-soft); background: var(--paper-deep); font-size: 11px; font-weight: 800; }
.presence-legend span { display: inline-flex; align-items: center; gap: 8px; }
.presence-legend .status-dot { display: inline-block; flex: 0 0 auto; }
.help-card { padding: 0; }
.sticky-title { position: sticky; top: 0; z-index: 2; padding: 24px clamp(20px,4vw,38px) 18px; background: rgba(255,250,240,.95); border-bottom: 1px solid var(--line); backdrop-filter: blur(8px); }
.manual-lead { padding: 30px clamp(20px,4vw,38px); background: var(--ink); color: white; }
.manual-lead strong { font: 700 clamp(24px,4vw,38px)/1.25 Georgia, "Noto Serif KR", serif; }
.manual-lead p { margin-bottom: 0; color: rgba(255,255,255,.67); }
.current-game-settings { padding: 18px clamp(20px,4vw,38px); border-bottom: 1px solid rgba(189,140,53,.35); background: #fff5dc; }
.current-game-settings strong { display: block; margin: 4px 0 5px; font: 700 20px Georgia, "Noto Serif KR", serif; }
.current-game-settings p { margin: 0; color: var(--ink-soft); font-size: 13px; line-height: 1.6; }
.setting-state { display: inline-block; padding: 3px 7px; border-radius: 999px; font-weight: 900; }
.setting-state.on { color: #07564f; background: #d8eee8; }
.setting-state.off { color: #76531a; background: #f1dfb8; }
.manual-grid { display: grid; grid-template-columns: 1fr 1fr; }
.manual-grid section { position: relative; padding: 28px clamp(20px,4vw,38px); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.manual-grid h3 { margin: 0 0 10px; font: 700 20px Georgia, "Noto Serif KR", serif; }
.manual-grid p, .manual-grid li { color: var(--ink-soft); font-size: 14px; line-height: 1.65; }
.manual-grid ul, .manual-grid ol { padding-left: 20px; }
.manual-number { position: absolute; right: 18px; top: 15px; color: rgba(22,32,29,.08); font: 700 40px Georgia, serif; }
.mini-code { display: flex; gap: 5px; margin: 14px 0; }
.mini-tile { width: 36px; height: 53px; border-radius: 4px; display: grid; place-items: center; font: 700 19px Georgia, serif; border: 1px solid #111; }
.mini-tile.black { color: white; background: #151918; }
.mini-tile.white { background: white; border-color: #bbb; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 18px); z-index: 100; max-width: calc(100% - 32px); padding: 11px 17px; border-radius: 8px; color: white; background: var(--red); box-shadow: 0 12px 30px rgba(0,0,0,.22); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; font-weight: 800; font-size: 13px; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.result-flash { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 18px; pointer-events: none; opacity: 0; background: rgba(12,18,16,.82); backdrop-filter: blur(7px); transition: opacity .2s ease; }
.result-flash.is-visible { opacity: 1; pointer-events: auto; }
.result-announcement-card { width: min(720px,100%); height: min(560px,calc(100vh - 36px)); display: grid; align-content: safe center; justify-items: center; gap: 15px; padding: clamp(24px,6vw,52px); border: 1px solid rgba(255,255,255,.22); border-radius: 18px; color: #fffaf0; background: radial-gradient(circle at 50% 0, rgba(189,140,53,.24), transparent 50%), #16201d; box-shadow: 0 30px 100px rgba(0,0,0,.45); overflow-y: auto; overflow-x: hidden; }
.announcement-owner { display: grid; justify-items: center; gap: 5px; text-align: center; }
.announcement-owner-kicker { color: var(--gold); font-size: 10px; font-weight: 900; letter-spacing: .18em; }
.announcement-owner-line { display: flex; align-items: baseline; justify-content: center; flex-wrap: wrap; column-gap: clamp(10px,2.2vw,20px); row-gap: 2px; max-width: 100%; }
.announcement-owner-line strong { max-width: 100%; overflow-wrap: anywhere; color: #f3cf78; font: 900 clamp(36px,8vw,62px)/1 Georgia,"Noto Serif KR",serif; letter-spacing: -.055em; text-shadow: 0 7px 22px rgba(189,140,53,.25); }
.announcement-owner-line span { color: rgba(255,255,255,.62); font-size: clamp(13px,2.5vw,18px); font-weight: 800; letter-spacing: -.02em; }
.announcement-code { display: flex; align-items: flex-end; justify-content: center; gap: clamp(4px,1.2vw,9px); max-width: 100%; padding: 18px 7px 9px; overflow-x: auto; }
.announcement-tile { position: relative; flex: 0 0 clamp(40px,8vw,62px); height: clamp(65px,12vw,92px); display: grid; place-items: center; border: 2px solid #111; border-radius: 7px 7px 4px 4px; box-shadow: 0 7px 15px rgba(0,0,0,.25); font: 700 clamp(18px,4vw,30px)/1 Georgia,serif; }
.announcement-tile.black { color: #f8f2e7; background: linear-gradient(145deg,#343a37,#090d0c); }
.announcement-tile.white { color: #18201d; background: linear-gradient(145deg,#fff,#d9d5ca); border-color: #aaa69c; }
.announcement-tile.is-target { z-index: 2; outline: 4px solid var(--gold); outline-offset: 4px; }
.result-flash.is-reading .announcement-tile.is-target { animation: target-rumble .13s linear infinite alternate; }
.announcement-target { margin: 0; color: rgba(255,255,255,.66); font-size: 13px; font-weight: 800; letter-spacing: .04em; }
.guess-call { font: 900 clamp(48px,12vw,96px)/1 Georgia,"Noto Serif KR",serif; letter-spacing: -.08em; color: #fff; text-shadow: 0 8px 25px rgba(0,0,0,.35); }
.result-verdict { min-height: clamp(62px,13vw,112px); display: grid; place-items: center; opacity: 0; transform: scale(.7); font: 900 clamp(56px,13vw,112px)/1 Georgia,"Noto Serif KR",serif; letter-spacing: -.08em; }
.result-flash.is-result .guess-call, .result-flash.is-result .announcement-target { opacity: .22; }
.result-flash.is-result .result-verdict { opacity: 1; transform: scale(1); animation: verdict-pop .42s cubic-bezier(.18,.9,.25,1.25); }
.result-flash.is-correct .result-verdict { color: #58c9b8; }
.result-flash.is-wrong .result-verdict { color: #ef7965; }
@keyframes target-rumble { from { transform: translateX(-2px) rotate(-1deg); } to { transform: translateX(2px) rotate(1deg); } }
@keyframes verdict-pop { from { opacity: 0; transform: scale(.55); } to { opacity: 1; transform: scale(1); } }

@media (max-width: 900px) {
  .lobby-layout, .game-layout, .final-layout { grid-template-columns: 1fr; }
  .side-stack { grid-template-columns: 1fr 1fr; }
  .hero-panel { min-height: 390px; }
}

@media (min-width: 651px) {
  .result-announcement-card { height: min(660px,calc(100vh - 36px)); }
  .announcement-code { width: 100%; min-height: 140px; padding: 30px 10px 14px; overflow-y: hidden; }
}

@media (max-width: 650px) {
  .topbar { align-items: flex-start; padding: 11px 13px; }
  .brand-seal { width: 35px; height: 35px; font-size: 18px; }
  .brand strong { font-size: 19px; }
  .brand-kicker { display: none; }
  .connection-status { display: none; }
  .top-actions { gap: 5px; }
  .button-ghost { padding: 6px 8px; font-size: 11px; }
  .help-button { width: 35px; height: 35px; }
  .turn-order { justify-content: flex-start; }
  .main-shell { padding: 14px 11px 28px; }
  .hero-copy { padding: 30px 22px; }
  .hero-copy h1 { font-size: 41px; }
  .hero-rule { grid-template-columns: 1fr; max-width: 260px; }
  .side-stack { grid-template-columns: 1fr; }
  .number-grid { grid-template-columns: repeat(4, 1fr); }
  .number-choice.joker { grid-column: span 4; }
  .decision-buttons { grid-template-columns: 1fr; }
  .guess-actions { grid-template-columns: minmax(0,1fr) auto; }
  .stop-turn-button { min-width: 104px; padding-inline: 10px; }
  .turn-card-heading { gap: 10px; }
  .turn-timer { min-width: 74px; padding: 8px 9px; }
  .turn-timer strong { font-size: 19px; }
  .pending-draw-separator { min-width: 56px; }
  .manual-grid { grid-template-columns: 1fr; }
  .manual-grid section { border-right: 0; }
  .sealed-code-grid { grid-template-columns: 1fr; }
  .winner-card { padding: 28px 14px; }
  .final-standing-row { padding: 13px 10px; }
  .final-code-row { gap: 5px; }
  .final-draw-separator { min-width: 58px; }
  .dialog { width: calc(100% - 16px); max-height: calc(100vh - 16px); }
  .dialog-card { max-height: calc(100vh - 16px); }
  .result-announcement-card { height: min(540px,calc(100vh - 24px)); padding: 24px 13px; gap: 12px; }
  .announcement-code { width: 100%; }
  .announcement-code::before, .announcement-code::after { content: ""; flex: 1 0 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .001ms !important; transition-duration: .001ms !important; }
  .result-flash.is-reading .announcement-tile.is-target { animation: target-rumble .13s linear infinite alternate !important; }
}
