:root {
    --primary-color: #176149;
    --primary-hover: #104633;
    --sb-button-ink: #ffffff;
    --sb-soft: #eaf3ed;
    --sb-ink: #174536;
    --sb-border: #b6cabc;
    --sb-a: #116054;
    --sb-b: #673b89;
}

.game-container { max-width: 1030px; padding: 18px; }
.header { padding: 16px 22px; gap: 12px; margin-bottom: 16px; flex-direction: row; text-align: left; }
.header h1 { font-size: clamp(1.7rem, 5vw, 2.3rem); color: var(--text-color); line-height: 1.15; }
.eyebrow { color: var(--text-muted); font-size: .73rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; }
.header .eyebrow { margin-bottom: 4px; }
.breadcrumb { flex-wrap: wrap; }
button { background: var(--primary-color); color: var(--sb-button-ink); touch-action: manipulation; }
button:hover { background: var(--primary-hover); color: var(--sb-button-ink); transform: none; }
button:focus-visible, input:focus-visible, summary:focus-visible { outline: 3px solid var(--focus-ring-color); outline-offset: 3px; }
.btn-secondary, .mode-btn, .lobby-tab { background: var(--card-background); color: var(--text-color); border: 1px solid var(--sb-border); box-shadow: none; }
.btn-secondary:hover, .mode-btn:hover, .lobby-tab:hover, .lobby-tab.active { background: var(--sb-soft); color: var(--sb-ink); border-color: var(--primary-color); transform: none; }
.mode-btn:hover .desc { color: var(--sb-ink); }
.lobby-tab.active { border-bottom: 3px solid var(--primary-color); }

.mode-selection { max-width: 520px; padding: 28px; gap: 14px; }
.mode-selection h2 { margin: 0; color: var(--text-color); font-size: 1.8rem; }
.tagline { text-align: center; color: var(--text-muted); margin-bottom: 6px; }
.mode-btn { min-height: 78px; padding: 14px; gap: 3px; }
.mode-footnote { color: var(--text-muted); font-size: .8rem; text-align: center; }
.intro-pucks { display: flex; padding: 4px 10px 12px; }
.intro-pucks span { display: grid; place-items: center; width: 52px; height: 52px; border: 4px double #f5fff9; border-radius: 50%; background: var(--sb-a); color: #fff; font-weight: 800; box-shadow: 0 4px 0 #173a30, 0 9px 14px #0002; transform: rotate(-12deg); }
.intro-pucks span + span { background: var(--sb-b); margin: 10px 0 -10px -8px; box-shadow: 0 4px 0 #372248, 0 9px 14px #0002; transform: rotate(12deg); }
.how-to-play, .table-details { width: 100%; text-align: left; }
summary { min-height: 44px; padding: 10px 2px; color: var(--primary-color); font-weight: 700; cursor: pointer; }
.how-to-play-content { line-height: 1.65; }
.how-to-play h3 { margin-top: 16px; font-size: 1rem; }
.how-to-play p, .table-details p { margin-block: 8px; }
.how-to-play ul, #puck-list { padding-left: 23px; }
.room-lobby, .waiting-room { overflow-wrap: anywhere; max-width: 500px; }
.lobby-form > p { margin-bottom: 14px; }
.waiting-text, #players-list, #copy-status { margin-block: 16px; }
#copy-status:empty { margin: 0; }
.room-code-display { max-width: 100%; color: var(--primary-color); }
.error-message { background: #fff0e8; color: #76290e; border: 1px solid #bd775c; padding: 12px; border-radius: 8px; font-size: .9rem; }

.game-area { background: var(--card-background); border-radius: 18px; padding: 20px; box-shadow: var(--shadow); }
#player-icon-legend { margin-bottom: 10px; padding: 6px 8px; }
.online-info { color: var(--text-muted); margin-bottom: 10px; font-size: .88rem; }
.online-badge { background: var(--sb-soft); color: var(--sb-ink); }
.scoreboard { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: stretch; gap: 12px; }
.player-card { display: flex; align-items: center; gap: 9px; border: 1px solid var(--sb-border); border-radius: 12px; padding: 10px; min-width: 0; }
.player-card.current { outline: 2px solid var(--primary-color); outline-offset: 2px; background: var(--sb-soft); }
.player-card > div { min-width: 0; }
.player-card strong { display: block; overflow-wrap: anywhere; line-height: 1.25; }
.puck-badge { display: inline-grid; place-items: center; flex-shrink: 0; height: 30px; width: 30px; border: 3px double #fff; border-radius: 50%; color: #fff; background: var(--sb-a); font-weight: 800; }
.player-b .puck-badge { background: var(--sb-b); }
.shots-label { font-size: .78rem; color: var(--text-muted); }
.player-card .score { margin-left: auto; font-size: 1.85rem; font-variant-numeric: tabular-nums; }
.round-meta { display: flex; flex-direction: column; justify-content: center; align-items: center; font-size: .9rem; }
.round-meta span { color: var(--text-muted); font-size: .75rem; white-space: nowrap; }
.status { min-height: 48px; display: flex; align-items: center; justify-content: center; margin: 16px 0; padding: 10px 14px; border-radius: 10px; background: var(--sb-soft); color: var(--sb-ink); font-weight: 650; text-align: center; overflow-wrap: anywhere; line-height: 1.4; }
.play-surface { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; gap: 30px; }
.table-scene { display: flex; justify-content: center; align-items: center; gap: 22px; min-width: 0; margin: 0; }
.table-column { flex-shrink: 0; }
.table-end { color: var(--text-muted); font-size: .7rem; font-weight: 600; text-align: center; margin-block: 3px; }
.table-frame { width: 170px; padding: 4px; border: 7px solid #68452d; border-radius: 15px; background: #563a27; box-shadow: 2px 6px 0 #38281d, 6px 12px 20px #0002, inset 0 0 0 1px #bc8e54; }
#shuffleboard-board { display: block; width: 100%; height: auto; overflow: visible; border-radius: 4px; }
.scoring-line { stroke: #77502c; stroke-width: .8; }
.foul-line { stroke: #684021; stroke-width: 1.2; stroke-dasharray: 4 2; }
.band-number { font: 800 10px "Segoe UI", sans-serif; text-anchor: middle; fill: #543c26; }
.table-label { font: 700 4.3px "Segoe UI", sans-serif; text-anchor: middle; fill: #543c26; letter-spacing: .6px; }
.launch-letter { font: 800 4.7px "Segoe UI", sans-serif; text-anchor: middle; dominant-baseline: central; fill: #173f35; }
.shuffleboard-puck circle { fill: var(--sb-a); stroke: #f5fff8; stroke-width: .7; }
.shuffleboard-puck[data-player="1"] circle { fill: var(--sb-b); stroke-dasharray: 1.4 .45; }
.shuffleboard-puck text { font: 800 5px "Segoe UI", sans-serif; fill: #fff; text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.shuffleboard-puck.counting circle { stroke: #fff6a6; stroke-width: 1; }
.score-key { max-width: 150px; font-size: .8rem; line-height: 1.5; }
.score-key h2 { font-size: 1.15rem; line-height: 1.3; margin: 5px 0 16px; }
.score-key dl { display: grid; gap: 12px; margin-bottom: 16px; }
.score-key dl > div { display: flex; gap: 9px; align-items: center; }
.score-key dt { font-weight: 800; font-size: 1.15rem; color: var(--sb-ink); background: var(--sb-soft); border-radius: 6px; text-align: center; width: 30px; flex-shrink: 0; }
.score-key dd { color: var(--text-color); }
.score-key > p:not(.eyebrow) { color: var(--text-muted); }
.score-key .edge-warning { border-top: 1px solid var(--sb-border); margin-top: 15px; padding-top: 12px; }
.shot-panel { padding: 18px; border: 1px solid var(--sb-border); border-radius: 14px; min-width: 0; }
.shot-heading { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; margin-bottom: 14px; }
.shot-heading h2 { font-size: 1.15rem; }
#shot-number { font-size: .78rem; color: var(--text-muted); white-space: nowrap; }
.slider-control { margin-bottom: 12px; }
.slider-control > div { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; }
.slider-control label { font-size: .9rem; font-weight: 650; }
.slider-control output { color: var(--sb-ink); font-size: .82rem; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
input[type="range"] { display: block; width: 100%; min-width: 44px; height: 44px; margin: 0; padding: 0; accent-color: var(--primary-color); background: transparent; cursor: pointer; }
input[type="range"]:disabled { cursor: not-allowed; opacity: .6; }
.range-hint { display: flex; justify-content: space-between; font-size: .68rem; color: var(--text-muted); margin-top: -6px; }
#shoot-btn, #next-round-btn, #retry-sync-btn { width: 100%; }
#power-tip { color: var(--text-muted); font-size: .78rem; line-height: 1.5; margin-top: 12px; }
.round-result { margin-top: 16px; border-top: 1px solid var(--sb-border); padding-top: 14px; }
.round-result h2 { font-size: 1rem; }
.round-result p { font-size: .9rem; margin-block: 6px 12px; }
#game-error, #retry-sync-btn { margin-top: 12px; }
.game-buttons { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; margin: 20px 0 12px; }
.game-buttons button { flex: 1 1 130px; max-width: 240px; padding-inline: 12px; }
.restart-hint { color: var(--text-muted); text-align: center; font-size: .8rem; }
.table-details { border-top: 1px solid var(--sb-border); margin-top: 14px; padding-top: 4px; font-size: .85rem; }
#puck-list { margin-block: 10px; }
.move-count { color: var(--text-muted); }

@media (prefers-color-scheme: dark) {
    :root { --primary-color: #a4e7ca; --primary-hover: #c3f4df; --sb-button-ink: #12392c; --sb-soft: #203d32; --sb-ink: #d3f0e2; --sb-border: #496458; }
    .error-message { background: #472b25; color: #ffe1d5; border-color: #b8816b; }
}

@media (max-width: 700px) {
    .game-container { padding: 10px; }
    .header { padding: 14px; flex-wrap: wrap; }
    .header .eyebrow { font-size: .62rem; }
    .game-area { padding: 14px; }
    .play-surface { gap: 16px; }
    .table-scene { gap: 12px; }
    .table-frame { width: 144px; }
    .score-key { font-size: .72rem; }
    .score-key .eyebrow { display: none; }
    .shot-panel { padding: 12px; }
    .shot-heading { flex-wrap: wrap; gap: 2px; }
    .scoreboard { gap: 8px; }
    .player-card { padding: 8px 6px; gap: 5px; }
    .player-card strong { font-size: .84rem; }
    .player-card .score { font-size: 1.5rem; }
    .puck-badge { width: 25px; height: 25px; font-size: .8rem; }
}

@media (max-width: 560px) {
    .game-container { padding: 8px; }
    .header { margin-bottom: 12px; }
    .header .back-btn { padding: 8px 10px; font-size: .8rem; }
    .header .eyebrow { display: none; }
    .mode-selection, .room-lobby, .waiting-room { padding: 18px; }
    .mode-selection { margin: 12px auto; }
    .game-area { padding: 12px; }
    #player-icon-legend { font-size: 12px; gap: 4px; }
    #player-icon-legend .player-icon-entry { padding: 3px 4px; gap: 4px; }
    .scoreboard { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
    .round-meta { grid-row: 1; grid-column: 1 / -1; flex-direction: row; justify-content: space-between; }
    .status { font-size: .9rem; margin-block: 12px; min-height: 44px; padding: 9px; }
    .play-surface { grid-template-columns: minmax(0, 1fr); }
    .table-scene { gap: 22px; }
    .table-frame { width: 136px; }
    .score-key { max-width: 128px; font-size: .75rem; }
    .score-key h2 { font-size: 1rem; }
    .score-key dl { gap: 12px; }
    .score-key dt { width: 26px; font-size: 1rem; }
    .shot-heading { margin-bottom: 10px; justify-content: space-between; }
    .shot-panel { padding: 12px; }
    .slider-control { margin-bottom: 7px; }
    #power-tip { margin-top: 8px; font-size: .75rem; }
    .range-hint { display: none; }
    .room-code-display { padding: 12px; letter-spacing: 3px; }
    .breadcrumb { font-size: .8rem; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
