:root {
  color-scheme: light;
  --paper: #f4f1e8;
  --paper-dark: #eae5d9;
  --ink: #242820;
  --muted: #77796f;
  --line: #ded9cc;
  --white: #fffefa;
  --coral: #e47765;
  --sage: #78945c;
  --font-mono: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(ellipse at 86% 9%, rgba(228, 119, 101, .09), transparent 34rem),
    var(--paper);
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
button { color: inherit; }
[hidden] { display: none !important; }
.shell { width: min(1180px, calc(100% - 64px)); min-height: 100vh; margin: auto; display: flex; flex-direction: column; }
.topbar { height: 78px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.wordmark { display: inline-flex; gap: 10px; align-items: center; color: var(--ink); text-decoration: none; font-size: 19px; font-weight: 800; letter-spacing: -.8px; }
.logo-die { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 8px; background: var(--ink); color: var(--paper); font-family: var(--font-mono); font-size: 15px; transform: rotate(-7deg); }
.period { color: var(--coral); }
.top-actions { display: flex; align-items: center; gap: 18px; }
.live-label { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 11px; }
.live-label i { width: 7px; height: 7px; border-radius: 50%; background: var(--sage); }
.quiet-button { padding: 8px 0; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 11px; }
.quiet-button:hover { color: var(--ink); }
.lobby { min-height: 640px; flex: 1; padding: 72px 7% 66px; display: grid; grid-template-columns: 1.1fr .8fr; gap: 9%; align-items: center; }
.eyebrow, .card-eyebrow { margin: 0 0 13px; color: #a16f45; font-family: var(--font-mono); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
.intro h1 { margin-bottom: 20px; font-size: clamp(42px, 5.3vw, 66px); font-weight: 650; line-height: 1.04; letter-spacing: -3.2px; }
.intro h1 span { color: #96978c; }
.intro-copy { max-width: 420px; margin-bottom: 31px; color: #66695f; font-size: 14px; line-height: 1.75; }
.how-to { max-width: 430px; border-top: 1px solid var(--line); }
.how-to p { min-height: 48px; margin: 0; display: flex; align-items: center; gap: 17px; border-bottom: 1px solid var(--line); color: #555950; font-size: 12px; }
.how-to b { color: #a16f45; font: 10px var(--font-mono); }
.lobby-card, .table-card, .score-card, .room-card, .rules-card { border: 1px solid rgba(47, 48, 42, .08); border-radius: 9px; background: var(--white); box-shadow: 0 16px 42px rgba(58, 52, 39, .045); }
.lobby-card { padding: 34px 35px 27px; }
.card-eyebrow { margin-bottom: 0; color: #8d8e85; font-size: 9px; }
.lobby-card h2 { margin: 17px 0 8px; font-size: 24px; letter-spacing: -.7px; }
.card-copy { margin-bottom: 22px; color: var(--muted); font-size: 12px; line-height: 1.65; }
.button { min-height: 44px; padding: 0 15px; border: 1px solid transparent; border-radius: 5px; display: inline-flex; align-items: center; justify-content: space-between; gap: 15px; cursor: pointer; font-size: 12px; font-weight: 650; transition: transform .15s, background .15s, opacity .15s; }
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { opacity: .46; cursor: not-allowed; }
.button-dark { width: 100%; background: var(--ink); color: white; }
.button-dark:hover:not(:disabled) { background: #373c32; }
.button-light { width: 100%; margin-top: 9px; border-color: var(--line); background: transparent; }
.button-light:hover:not(:disabled) { background: #f6f3eb; }
.divider { margin: 23px 0 16px; border-top: 1px solid var(--line); text-align: center; }
.divider span { position: relative; top: -8px; padding: 0 10px; background: var(--white); color: #92938c; font-size: 10px; }
#join-form { display: flex; flex-direction: column; gap: 8px; }
#join-form label { color: #66695f; font-size: 11px; font-weight: 650; }
#join-form input { width: 100%; height: 42px; padding: 0 12px; border: 1px solid #e3e0d8; border-radius: 5px; background: #fffefa; text-align: center; font: 14px var(--font-mono); letter-spacing: .15em; text-transform: uppercase; }
#join-form input:focus { outline: 2px solid rgba(120, 148, 92, .35); border-color: var(--sage); }
.message { min-height: 18px; margin: 10px 0 0; color: #aa5044; font-size: 11px; line-height: 1.5; }
.message.success { color: #50763d; }

.game { padding: 45px 2% 55px; flex: 1; }
.game-heading { margin-bottom: 24px; display: flex; justify-content: space-between; align-items: end; gap: 15px; }
.game-heading .eyebrow { margin-bottom: 9px; }
.game-heading h1 { margin: 0; font-size: clamp(28px, 4vw, 42px); letter-spacing: -1.7px; }
.game-heading-actions { display: flex; gap: 20px; align-items: center; }
.game-layout { display: grid; grid-template-columns: minmax(0, 1fr) 295px; gap: 17px; align-items: start; }
.play-column, .side-column { display: grid; gap: 16px; }
.table-card { padding: 20px 22px 14px; }
.table-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.table-heading h2, .score-heading h2 { margin: 5px 0 0; font-size: 17px; letter-spacing: -.4px; }
.connection-status { color: #a16f45; font: 9px var(--font-mono); text-transform: uppercase; }
.connection-status.connected { color: var(--sage); }
.dice-tray { min-height: 128px; display: flex; justify-content: center; align-items: center; gap: clamp(9px, 2.8vw, 27px); }
.die { width: clamp(48px, 8vw, 68px); aspect-ratio: 1; position: relative; border: 1px solid #e6e1d7; border-radius: 13px; background: #fffefa; color: var(--ink); box-shadow: 0 5px 12px rgba(47, 48, 42, .07); cursor: default; }
.die span { position: absolute; inset: 0; display: grid; place-items: center; font-size: clamp(25px, 4vw, 35px); font-weight: 750; }
.die.empty { color: #c6c2b9; background: #f8f6f0; box-shadow: none; }
.die:not(:disabled) { cursor: pointer; }
.die:not(:disabled):hover { transform: translateY(-2px); }
.die.held { border-color: #8ca676; background: #eef3e8; box-shadow: 0 0 0 3px rgba(120, 148, 92, .13); }
.dice-hint { min-height: 17px; margin: 0; color: var(--muted); text-align: center; font-size: 11px; }
.roll-controls { display: flex; justify-content: center; align-items: center; gap: 13px; margin-top: 12px; }
.roll-controls .button { width: 155px; }
.roll-count { color: var(--muted); font: 10px var(--font-mono); }
.table-card > .message { text-align: center; }
.score-card { padding: 19px 21px 17px; }
.score-heading { margin-bottom: 13px; display: flex; justify-content: space-between; align-items: end; gap: 16px; }
.score-heading > p { margin: 0; color: var(--muted); font-size: 10px; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 11px; }
thead th { padding: 8px 9px; color: #84867d; font-size: 9px; font-weight: 650; text-align: right; }
thead th:first-child { text-align: left; }
thead th:not(:first-child) { width: 27%; }
tbody th, tbody td, tfoot th, tfoot td { height: 33px; padding: 4px 9px; border-top: 1px solid #efede7; text-align: right; }
tbody th, tfoot th { color: #555950; font-weight: 550; text-align: left; }
tbody td { color: #41453d; }
.scored { color: #4c6d3b; font-weight: 700; }
.empty-score { color: #c5c2b9; }
.score-choice { padding: 4px 6px; border: 1px solid #dfe7d7; border-radius: 4px; background: #f4f7ef; color: #587447; cursor: pointer; font-size: 9px; white-space: nowrap; }
.score-choice:hover { border-color: #9cb48a; background: #eaf1e2; }
.summary-row th, .summary-row td { color: #77796f; font-size: 10px; }
.total-row th, .total-row td { border-top: 1px solid #dcd8ce; color: var(--ink); font-weight: 750; }
.room-card, .rules-card { padding: 18px; }
.room-code-row { margin: 10px 0 9px; display: flex; justify-content: space-between; align-items: center; }
.room-code-row strong { font: 22px var(--font-mono); letter-spacing: .16em; }
.copy-button { padding: 6px 9px; border: 1px solid var(--line); border-radius: 4px; background: transparent; color: #575b54; cursor: pointer; font-size: 10px; }
.copy-button:hover { background: #f5f2ea; }
.room-card > p:last-child { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.55; }
.rules-card ul { margin: 12px 0 0; padding-left: 17px; color: #696c63; font-size: 10px; line-height: 1.6; }
.rules-card li + li { margin-top: 5px; }
footer { min-height: 54px; display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--line); color: #92938b; font-size: 10px; }
footer span:first-child { color: #61645b; font-weight: 700; }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 3; padding: 11px 15px; border-radius: 6px; background: var(--ink); color: white; font-size: 11px; opacity: 0; pointer-events: none; transform: translateY(8px); transition: opacity .2s, transform .2s; }
.toast.visible { opacity: 1; transform: translateY(0); }

@media (max-width: 850px) {
  .shell { width: min(100% - 36px, 660px); }
  .lobby { min-height: 0; padding: 53px 0; grid-template-columns: 1fr; gap: 35px; }
  .intro-copy, .how-to { max-width: 520px; }
  .lobby-card { max-width: 520px; width: 100%; margin: auto; }
  .game { padding: 35px 0 45px; }
  .game-layout { grid-template-columns: 1fr; }
  .side-column { grid-template-columns: 1fr 1fr; align-items: start; }
}

@media (max-width: 520px) {
  .shell { width: calc(100% - 28px); }
  .topbar { height: 65px; }
  .top-actions { gap: 10px; }
  .live-label { font-size: 10px; }
  .intro h1 { font-size: 46px; }
  .lobby-card { padding: 25px 22px 19px; }
  .game { padding-top: 25px; }
  .game-heading { align-items: start; }
  .game-heading h1 { max-width: 220px; font-size: 28px; }
  .game-heading-actions { flex-direction: column; align-items: end; gap: 3px; }
  .table-card { padding: 17px 12px 11px; }
  .dice-tray { min-height: 108px; gap: 8px; }
  .die { width: min(16vw, 58px); border-radius: 10px; }
  .score-card { padding: 16px 9px 13px; }
  .score-heading { align-items: start; flex-direction: column; gap: 5px; }
  tbody th, tbody td, tfoot th, tfoot td { padding-right: 5px; padding-left: 5px; }
  thead th { padding-right: 5px; padding-left: 5px; }
  .score-choice { font-size: 8px; padding: 4px; }
  .side-column { grid-template-columns: 1fr; }
  footer { font-size: 9px; }
}
