:root {
  color-scheme: light;
  --paper: #f3f0e9;
  --paper-deep: #ebe6dc;
  --ink: #20231f;
  --muted: #74776f;
  --line: #dedbd2;
  --white: #fbfaf6;
  --coral: #e47765;
  --amber: #e7ae4b;
  --lime: #a8c665;
  --teal: #5daea0;
  --blue: #6d8ecb;
  --violet: #9c7bc3;
  --font-display: system-ui, sans-serif;
  --font-body: system-ui, sans-serif;
  --font-mono: ui-monospace, monospace;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(ellipse at 82% 8%, rgba(231, 174, 75, 0.1), transparent 34rem),
    var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }
button { color: inherit; }
[hidden] { display: none !important; }

.page-shell {
  width: min(1200px, calc(100% - 72px));
  min-height: 100vh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 88px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.wordmark {
  display: inline-flex;
  gap: 12px;
  align-items: center;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.8px;
  text-decoration: none;
}

.wordmark-period { color: var(--coral); }
.brand-mark { width: 25px; height: 25px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 3px; transform: rotate(-8deg); }
.brand-mark i { border-radius: 50%; background: var(--coral); }
.brand-mark i:nth-child(2) { background: var(--amber); }
.brand-mark i:nth-child(3) { background: var(--teal); }
.brand-mark i:nth-child(4) { background: var(--blue); }

.topbar-note, .card-kicker, .board-size, .player-sublabel, .room-code, .step-number {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.topbar-note { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 11px; }
.live-dot, .turn-dot { width: 7px; height: 7px; background: #83aa5e; border-radius: 50%; }

main { flex: 1; }
.lobby-view { min-height: 680px; padding: 94px 8.5% 76px; display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 9%; align-items: center; }
.eyebrow { margin: 0 0 18px; color: #a16f45; font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.13em; }
h1, h2, p { margin-top: 0; }
.intro h1, .game-heading h1 { margin: 0; font-family: var(--font-display); font-size: clamp(42px, 5vw, 66px); font-weight: 600; line-height: 1.07; letter-spacing: -3.2px; }
.intro h1 span { color: #92958b; }
.intro-copy { max-width: 390px; margin: 24px 0 38px; color: #676b63; font-size: 15px; line-height: 1.75; }
.how-to-play { border-top: 1px solid var(--line); max-width: 405px; }
.how-to-play > div { min-height: 56px; display: flex; gap: 17px; align-items: center; border-bottom: 1px solid var(--line); }
.step-number { color: #a16f45; }
.how-to-play p { margin: 0; color: #575b54; font-size: 12px; }

.lobby-card, .board-card, .status-card, .score-card {
  border: 1px solid rgba(47, 48, 42, 0.08);
  border-radius: 8px;
  background: var(--white);
  box-shadow: 0 18px 48px rgba(58, 52, 39, 0.045);
}
.lobby-card { padding: 35px 36px 29px; }
.card-kicker { margin: 0; color: #8d8e85; }
.sparkle { margin-right: 7px; color: var(--coral); font-size: 15px; vertical-align: -1px; }
.lobby-card h2 { margin: 20px 0 8px; font-family: var(--font-display); font-size: 25px; font-weight: 650; letter-spacing: -0.8px; }
.card-copy { margin-bottom: 25px; color: var(--muted); font-size: 12px; line-height: 1.65; }
.room-form { display: flex; flex-direction: column; gap: 9px; }
.room-form label { margin-top: 2px; color: #66695f; font-size: 11px; font-weight: 600; }
.room-form input { width: 100%; height: 42px; padding: 0 13px; border: 1px solid #e3e0d8; border-radius: 5px; background: #fffefa; color: var(--ink); font-size: 13px; outline: none; transition: border-color 0.15s, box-shadow 0.15s; }
.room-form input:focus { border-color: #b6a48b; box-shadow: 0 0 0 3px rgba(182, 164, 139, 0.15); }
.room-form input::placeholder { color: #aba99f; }
.button { min-height: 44px; padding: 0 16px; border: 1px solid transparent; border-radius: 5px; display: inline-flex; align-items: center; justify-content: space-between; gap: 14px; cursor: pointer; font-size: 12px; font-weight: 600; transition: background 0.15s, transform 0.15s, opacity 0.15s; }
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { opacity: 0.45; cursor: not-allowed; }
.button-dark { margin-top: 7px; background: var(--ink); color: #fff; }
.button-dark:hover:not(:disabled) { background: #373a33; }
.button-outline { margin-top: 7px; border-color: #d7d4cb; background: transparent; }
.button-outline:hover:not(:disabled) { background: #f4f1e9; }
.form-divider { position: relative; margin: 22px 0 17px; border-top: 1px solid var(--line); text-align: center; }
.form-divider span { position: relative; top: -8px; padding: 0 11px; background: var(--white); color: #92938c; font-size: 10px; }
.solo-button { width: 100%; margin-top: 12px; }
.join-form { display: flex; flex-direction: column; }
.join-form input.code-input { text-align: center; font-family: var(--font-mono); font-size: 14px; letter-spacing: 0.12em; }
.notice { min-height: 17px; margin: 10px 0 0; color: #ae4c40; font-size: 11px; line-height: 1.5; }
.notice.success { color: #50763d; }

.game-view { padding: 51px 4.5% 56px; }
.game-heading { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin-bottom: 28px; }
.game-heading .eyebrow { margin-bottom: 10px; }
.game-heading h1 { font-size: clamp(30px, 4vw, 44px); letter-spacing: -1.7px; }
.text-button { padding: 9px 0; border: 0; background: none; color: #777a71; cursor: pointer; font-size: 11px; }
.text-button:hover { color: var(--ink); }
.game-layout { display: grid; grid-template-columns: minmax(0, 1fr) 335px; gap: 20px; align-items: start; }
.board-card { padding: 19px; }
.board-topline { min-height: 28px; margin: 0 2px 15px; display: flex; justify-content: space-between; align-items: center; }
.turn-indicator { display: inline-flex; gap: 8px; align-items: center; color: #92938b; font-size: 11px; }
.turn-indicator .turn-dot { background: #b4b1a6; }
.turn-indicator.your-turn .turn-dot { background: #80a45b; box-shadow: 0 0 0 3px rgba(128, 164, 91, 0.13); }
.board-size { color: #a4a398; font-size: 9px; }
.board { width: 100%; aspect-ratio: 1; padding: 12px; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: clamp(5px, 1.3vw, 12px); border: 1px solid #e4e0d7; border-radius: 5px; background: #f4f1e9; }
.board-cell { position: relative; min-width: 0; padding: 0; border: 0; border-radius: 50%; background: transparent; cursor: default; }
.board-cell.has-stone::before { position: absolute; inset: 9%; border-radius: 50%; background: var(--stone-color); content: ""; box-shadow: inset 0 2px 2px rgba(255,255,255,.28), inset 0 -3px 4px rgba(0,0,0,.12), 0 3px 5px rgba(33,31,26,.1); transition: transform 0.18s, box-shadow 0.18s, opacity 0.18s; }
.board-cell.empty-cell { opacity: 0.2; }
.board-cell.stone-coral { --stone-color: var(--coral); }
.board-cell.stone-amber { --stone-color: var(--amber); }
.board-cell.stone-lime { --stone-color: var(--lime); }
.board-cell.stone-teal { --stone-color: var(--teal); }
.board-cell.stone-blue { --stone-color: var(--blue); }
.board-cell.stone-violet { --stone-color: var(--violet); }
.board-cell.is-pickable { cursor: pointer; }
.board-cell.is-pickable::after { position: absolute; inset: 4%; border: 1.5px solid rgba(38, 42, 35, 0.38); border-radius: 50%; content: ""; animation: pickable-pulse 2.2s ease-in-out infinite; }
.board-cell.is-pickable:hover::before { transform: scale(0.82); }
.board-cell.is-selected::before { transform: scale(0.72); box-shadow: 0 0 0 3px var(--white), 0 0 0 5px var(--ink), 0 4px 8px rgba(33,31,26,.16); }
.board-cell.is-selected::after { display: none; }
.board-cell:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
@keyframes pickable-pulse { 50% { opacity: .48; transform: scale(.94); } }
.board-footer { min-height: 38px; padding: 13px 3px 0; display: flex; flex-wrap: wrap; align-items: center; gap: 16px; color: #85867e; font-size: 9px; }
.board-footer > span:not(.connection-status) { display: inline-flex; align-items: center; gap: 6px; }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; }
.pickable-dot { border: 1px solid #77796f; }
.selected-dot { background: var(--ink); box-shadow: inset 0 0 0 2px #fff; }
.connection-status { margin-left: auto; font-family: var(--font-mono); font-size: 9px; }
.connection-status.is-connected { color: #6a9250; }
.game-sidebar { display: flex; flex-direction: column; gap: 14px; }
.status-card, .score-card { padding: 20px; }
.status-card h2 { margin: 12px 0 6px; font-family: var(--font-display); font-size: 19px; font-weight: 650; letter-spacing: -0.6px; }
.turn-description { min-height: 34px; margin-bottom: 11px; color: #77796f; font-size: 11px; line-height: 1.55; }
.selection-status { min-height: 31px; padding: 9px 10px; border-radius: 4px; background: #f3f0e8; color: #77796f; font-size: 10px; }
.take-button { width: 100%; margin-top: 11px; }
.take-button span { min-width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,.15); font-family: var(--font-mono); font-size: 10px; }
.game-notice { margin-bottom: -5px; }
.section-title-row { display: flex; justify-content: space-between; align-items: center; }
.room-code-group { display: flex; align-items: center; gap: 7px; }
.room-code { color: #45483f; font-size: 11px; letter-spacing: 0.12em; }
.copy-button { padding: 4px 7px; border: 1px solid #e1ded5; border-radius: 3px; background: transparent; color: #71736c; cursor: pointer; font-size: 9px; }
.copy-button:hover { background: #f3f0e8; }
.players { margin: 13px 0 16px; border-top: 1px solid #eeece5; }
.player-row { min-height: 56px; padding: 9px 0; border-bottom: 1px solid #eeece5; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.player-identity { display: grid; grid-template-columns: 19px auto; column-gap: 8px; align-items: center; min-width: 0; }
.player-marker { width: 12px; height: 12px; border: 1px solid #b1aea3; border-radius: 50%; grid-row: span 2; }
.player-marker-1 { border-color: var(--coral); background: var(--coral); }
.player-marker-2 { border-color: var(--blue); background: var(--blue); }
.player-label { overflow: hidden; color: #34372f; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.player-sublabel { color: #a1a198; font-size: 8px; }
.player-row.is-active .player-label { font-weight: 700; }
.player-row.is-winner .player-label { color: #628447; }
.capture-counts { display: flex; gap: 3px; }
.capture-chip { width: 15px; height: 15px; border-radius: 50%; display: grid; place-items: center; color: white; font-family: var(--font-mono); font-size: 8px; text-shadow: 0 1px 2px rgba(0,0,0,.24); }
.capture-chip.stone-coral, .guide-swatch.stone-coral { background: var(--coral); }
.capture-chip.stone-amber, .guide-swatch.stone-amber { background: var(--amber); }
.capture-chip.stone-lime, .guide-swatch.stone-lime { background: var(--lime); }
.capture-chip.stone-teal, .guide-swatch.stone-teal { background: var(--teal); }
.capture-chip.stone-blue, .guide-swatch.stone-blue { background: var(--blue); }
.capture-chip.stone-violet, .guide-swatch.stone-violet { background: var(--violet); }
.color-guide { padding-top: 14px; border-top: 1px solid #eeece5; }
.color-guide-list { margin-top: 8px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; }
.color-guide-row { display: grid; grid-template-columns: 10px 1fr auto; gap: 6px; align-items: center; color: #65675f; font-size: 9px; }
.guide-swatch { width: 8px; height: 8px; border-radius: 50%; }
.color-guide-row > span:last-child { color: #a1a198; font-size: 8px; }

.footer { min-height: 68px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; color: #92938b; font-size: 9px; }
.footer a { margin-left: 12px; color: inherit; text-decoration: underline; text-underline-offset: 3px; }
.footer a:hover { color: var(--ink); }
.footer-button { margin-left: 12px; padding: 0; border: 0; background: none; color: inherit; cursor: pointer; font-size: inherit; text-decoration: underline; text-underline-offset: 3px; }
.footer-button:hover { color: var(--ink); }

.storage-consent { position: fixed; z-index: 10; right: 24px; bottom: 20px; left: 24px; width: min(880px, calc(100% - 48px)); margin: 0 auto; padding: 19px 21px; border: 1px solid #dcd7ca; border-radius: 7px; background: var(--white); box-shadow: 0 12px 40px rgba(37, 35, 29, .18); display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.consent-copy { max-width: 550px; }
.consent-title { margin: 0 0 6px; color: var(--ink); font-family: var(--font-display); font-size: 14px; font-weight: 700; }
.consent-copy > p:last-child { margin: 0; color: #6d7067; font-size: 11px; line-height: 1.6; }
.consent-actions { min-width: 190px; display: flex; flex-direction: column; gap: 7px; }
.consent-actions .button { min-height: 37px; justify-content: center; margin: 0; padding: 0 11px; font-size: 10px; white-space: nowrap; }

.imprint-shell { width: min(760px, calc(100% - 40px)); min-height: 100vh; margin: 0 auto; padding: 48px 0; }
.imprint-page { padding: clamp(24px, 5vw, 52px); border: 1px solid rgba(47, 48, 42, 0.08); border-radius: 8px; background: var(--white); box-shadow: 0 18px 48px rgba(58, 52, 39, 0.045); }
.imprint-page > a { color: #777a71; font-size: 11px; text-decoration: none; }
.imprint-page > a:hover { color: var(--ink); }
.imprint-page .imprint-kicker { margin-top: 32px; }
.imprint-page h1 { margin: 28px 0 10px; font-family: var(--font-display); font-size: clamp(38px, 6vw, 54px); font-weight: 600; letter-spacing: -2px; }
.imprint-page h2 { margin: 30px 0 10px; font-family: var(--font-display); font-size: 17px; }
.imprint-page p, .imprint-page address { color: #676b63; font-size: 13px; line-height: 1.8; }
.imprint-page address { font-style: normal; }
.imprint-draft-notice { padding: 12px 14px; border-left: 2px solid var(--coral); background: #f7f1e9; }

@media (max-width: 900px) {
  .page-shell { width: min(100% - 40px, 720px); }
  .lobby-view { min-height: 0; padding: 70px 3% 60px; grid-template-columns: 1fr; gap: 42px; }
  .intro-copy { margin-bottom: 26px; }
  .how-to-play { max-width: none; }
  .lobby-card { max-width: 480px; width: 100%; margin: 0 auto; }
  .game-view { padding: 42px 0 52px; }
  .game-layout { grid-template-columns: minmax(0, 1fr) 290px; gap: 14px; }
  .board-card { padding: 13px; }
  .board { padding: 9px; gap: 6px; }
}

@media (max-width: 650px) {
  .page-shell { width: calc(100% - 32px); }
  .topbar { height: 68px; }
  .lobby-view { padding: 58px 0 42px; gap: 32px; }
  .intro h1 { font-size: 49px; letter-spacing: -2.6px; }
  .lobby-card { padding: 27px 22px 21px; }
  .game-view { padding: 33px 0 42px; }
  .game-heading { margin-bottom: 21px; }
  .game-heading h1 { font-size: 31px; }
  .game-layout { grid-template-columns: 1fr; }
  .board-card { padding: 13px; }
  .board { padding: 9px; gap: clamp(5px, 2vw, 10px); }
  .board-footer { gap: 11px; }
  .game-sidebar { display: grid; grid-template-columns: 1fr; }
  .footer { min-height: 56px; font-size: 8px; }
  .storage-consent { right: 10px; bottom: 10px; left: 10px; width: calc(100% - 20px); padding: 15px; flex-direction: column; align-items: stretch; gap: 12px; }
  .consent-actions { min-width: 0; flex-direction: row; }
  .consent-actions .button { flex: 1; white-space: normal; }
  .imprint-shell { width: calc(100% - 32px); padding: 24px 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
