:root { color-scheme: dark; font-family: Inter, "Segoe UI", Arial, sans-serif; --cream: #fff4d7; --gold: #eec574; --line: #b88440; }
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; color: var(--cream); background: #06100e; }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .48; }
.game-stage {
  min-height: 100vh; width: min(1770px, 100%); margin: auto;
  padding: 14px clamp(10px, 2vw, 34px) 22px;
  background: #071310 url("assets/lounge-bg.webp") center / cover fixed;
  box-shadow: 0 0 90px #000c;
}
.top-controls {
  display: flex; justify-content: center; align-items: center; flex-wrap: wrap;
  gap: 8px; max-width: 1500px; margin: 0 auto 12px;
}
.top-button, .assist-toggle {
  display: inline-flex; align-items: center; justify-content: center; min-height: 38px;
  padding: 0 13px; border: 1px solid #916b39; border-radius: 6px;
  color: #f9eccc; background: linear-gradient(#12322a, #051915);
  box-shadow: inset 0 1px #e7c67b66, 0 3px 7px #0008;
  font-size: .82rem; font-weight: 800;
}
.top-button:hover, .assist-toggle:hover, .tab:hover { filter: brightness(1.18); }
.assist-toggle { gap: 8px; cursor: pointer; }
.assist-toggle input { width: 16px; height: 16px; margin: 0; accent-color: #d9ad58; cursor: pointer; }
.game-header {
  display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center; gap: 24px; max-width: 1500px; margin: auto auto 8px;
}
.title-block { text-align: center; min-width: 260px; }
h1 {
  display: flex; justify-content: center; align-items: center; gap: .08em;
  margin: 0; font: 900 clamp(2.6rem, 3.9vw, 4.35rem)/1 Georgia, serif;
  filter: drop-shadow(0 3px 0 #3f2514) drop-shadow(0 7px 5px #000);
}
.title-word {
  color: transparent;
  background: linear-gradient(#fffdf3 7%, #fff8e8 32%, #ead0a8 48%, #a26935 77%, #f6dbac 96%);
  background-clip: text; -webkit-background-clip: text; -webkit-text-stroke: .8px #57391c;
}
.eight-mark {
  display: block; flex: none; width: .98em; height: .98em; object-fit: contain;
  filter: drop-shadow(0 4px 4px #000a);
}
.mode-caption {
  display: flex; justify-content: center; align-items: center; gap: 10px;
  margin: 4px 0 0; color: #f3ebd9; font-size: .86rem; font-weight: 700;
}
.mode-caption::before, .mode-caption::after {
  content: ""; width: 44px; height: 1px;
  background: linear-gradient(90deg, transparent, #d3a650);
}
.mode-caption::after { transform: rotate(180deg); }
.turn-indicator { margin: 6px 0 0; color: #f8d587; font-size: .82rem; font-weight: 800; }
.mode-tabs { display: flex; border: 1px solid #916b39; border-radius: 6px; overflow: hidden; }
.tab { min-height: 36px; border: 0; padding: 6px 12px; color: #d5d8cd; background: #092119; font-size: .8rem; font-weight: 750; }
.tab + .tab { border-left: 1px solid #916b39; }
.tab.is-active { color: #211506; background: linear-gradient(#ffe7a1, #d59e49); }
.score-card {
  display: flex; align-items: center; gap: 14px; min-height: 82px; padding: 9px 16px;
  border: 1px solid #bd9558; border-radius: 6px 20px 6px 20px;
  background: linear-gradient(135deg, #0b3027eb, #071415ed 68%);
  box-shadow: inset 0 1px #e5bd7280, 0 10px 22px #0009;
}
.score-card-right { justify-content: flex-end; border-radius: 20px 6px 20px 6px; text-align: right; }
.score-card.active { border-color: #f8dd88; box-shadow: 0 0 0 2px #c99a4c66, 0 0 22px #d3a34266; }
.avatar {
  display: block; flex: none; width: 64px; height: 64px; object-fit: contain;
}
.score-copy { min-width: 86px; }
.score-copy strong, .score-copy small { display: block; }
.score-copy strong { font-size: 1.03rem; }
.score-copy small { margin-top: 5px; color: #f0c574; font-weight: 750; }
.ball-progress { display: flex; align-self: center; margin-left: auto; }
.score-card-right .ball-progress { margin-left: 0; margin-right: auto; }
.mini-ball {
  display: grid; place-items: center; flex: none;
  width: clamp(20px, 1.8vw, 30px); height: clamp(20px, 1.8vw, 30px);
  border: 1px solid #5d5036; border-radius: 50%; background: #030b08;
  box-shadow: inset 0 3px 6px #000, 0 1px 3px #0009;
}
.mini-ball + .mini-ball { margin-left: -3px; }
.mini-ball-art { display: block; width: 100%; height: 100%; border-radius: 50%; }
.mini-ball.is-pocketed {
  border-color: #3a4133; background: #020806;
  box-shadow: inset 0 3px 7px #000, inset 0 0 0 1px #000, 0 1px 2px #8e744433;
}
.mini-ball.is-unassigned { border-color: #b6a78188; background: #04110f; box-shadow: inset 0 0 0 1px #000; }
.table-area { position: relative; max-width: 1580px; margin: auto; padding-left: 76px; }
canvas { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; touch-action: pan-y; }
.table-message {
  width: fit-content; max-width: 100%; margin: 8px auto 0; padding: 6px 12px; border: 1px solid #dab46490;
  border-radius: 5px; color: #f5dc9e; background: #071a16dc; font-size: .83rem;
  font-weight: 700; text-align: center;
}
.table-message:empty { display: none; }
.power-control {
  position: absolute; z-index: 2; top: 50%; left: 0; transform: translateY(-50%);
  display: grid; justify-items: center; width: 63px; padding: 11px 5px 9px;
  border: 1px solid #ae8244; border-radius: 7px;
  color: #f2d996; background: linear-gradient(#15221ef2, #080f10f5);
  box-shadow: inset 0 1px #f7d88766, 0 9px 25px #000a;
  font-size: .76rem; font-weight: 800;
}
.undo-aim {
  display: grid; place-items: center; width: 32px; height: 32px; margin-bottom: 8px;
  border: 1px solid #b59155; border-radius: 4px; color: #f2d996;
  background: #10241d; cursor: pointer;
}
.undo-aim svg { width: 19px; height: 19px; }
.undo-aim:disabled { opacity: .4; cursor: default; }
.undo-aim:not(:disabled):hover { background: #24503c; }
.power-meter { touch-action: none;
  position: relative; display: block; width: 30px; height: 185px; margin: 10px 0 6px;
  border: 2px solid #b59155; border-radius: 5px;
  background: #07120d;
  box-shadow: inset 0 0 0 4px #07120d, 0 1px 6px #000;
}
.power-meter::before {
  content: ""; position: absolute; left: 4px; right: 4px; bottom: 4px;
  height: var(--power, 0%); max-height: calc(100% - 8px);
  background: linear-gradient(to top, #16bc51, #8ed935 30%, #f7da32 59%, #f68a22 79%, #d9362e);
}
.power-thumb {
  position: absolute; left: 50%; bottom: 44%; width: 38px; height: 15px;
  transform: translate(-50%, 50%); border: 2px solid #ffe6a2; border-radius: 4px;
  background: linear-gradient(90deg, #825216, #f4c469 45%, #fff2b8 54%, #8c5d20);
  box-shadow: 0 2px 6px #000b;
}
.power-control output { font-size: .82rem; font-variant-numeric: tabular-nums; }
.eyebrow { margin: 0; color: var(--gold); font-weight: 800; text-transform: uppercase; }
dialog { width: min(640px, calc(100% - 24px)); padding: 0; border: 1px solid var(--line); border-radius: 10px; color: var(--cream); background: #0d211b; box-shadow: 0 24px 70px #000c; }
dialog::backdrop { background: #000b; }
.start-dialog { width: min(700px, calc(100% - 24px)); }
.start-content { padding: 28px; }
.start-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.start-mode-options { display: flex; gap: 8px; margin: 0 0 16px; }
.start-mode { flex: 1; padding: 10px 12px; border: 1px solid #80633a; border-radius: 6px; color: var(--cream); background: #0c251d; font-weight: 800; }
.start-mode.is-selected { color: #1a1208; background: #f0c571; }
.start-option { min-height: 140px; padding: 18px; border: 1px solid #ba9051; border-radius: 6px; color: var(--cream); background: #113329; text-align: left; }
.start-option:hover, .start-option:focus-visible { border-color: #f6d385; background: #1d4635; }
.start-option strong, .start-option span { display: block; }
.start-option strong { margin-bottom: 12px; font: 700 1.45rem Georgia, serif; }
.start-option span { color: #ceddce; line-height: 1.45; }
.pause-overlay { position: fixed; z-index: 10; inset: 0; display: grid; place-items: center; padding: 20px; background: #03100edb; }
.pause-overlay[hidden] { display: none; }
.pause-panel { width: min(360px, 100%); padding: 30px; border: 1px solid var(--line); border-radius: 8px; background: #0d211b; text-align: center; }
.pause-panel p { color: #ceddce; }
.result-panel { width: min(420px, 100%); }
.ball-in-hand-panel { width: min(430px, 100%); overflow: hidden; }
.placement-art { position: relative; width: 190px; height: 148px; margin: -12px auto 8px; border-radius: 50%; background: radial-gradient(circle, #1c4937 0 34%, #123427 60%, transparent 71%); }
.placement-ball { position: absolute; z-index: 2; left: 73px; top: 54px; width: 44px; height: 44px; border: 2px solid #201b14; border-radius: 50%; background: radial-gradient(circle at 31% 25%, #fff 0 11%, #f3efe2 35%, #b9b4a9 78%, #746f68 100%); box-shadow: 0 4px 7px #020403aa, inset -5px -6px 8px #57524c55; }
.placement-arrow { position: absolute; z-index: 1; width: 11px; height: 43px; border-radius: 5px; background: #ead7a3; box-shadow: 0 0 0 1px #6e5733, 0 2px 4px #02040399; }
.placement-arrow::after { content: ""; position: absolute; left: 50%; transform: translateX(-50%); border-left: 12px solid transparent; border-right: 12px solid transparent; }
.arrow-up { left: 89px; top: 7px; }
.arrow-up::after { top: -10px; border-bottom: 14px solid #ead7a3; }
.arrow-down { left: 89px; bottom: 7px; }
.arrow-down::after { bottom: -10px; border-top: 14px solid #ead7a3; }
.arrow-right, .arrow-left { width: 43px; height: 11px; top: 68px; }
.arrow-right { right: 7px; }
.arrow-right::after { right: -10px; top: -2px; transform: none; border-top: 12px solid transparent; border-bottom: 12px solid transparent; border-left: 14px solid #ead7a3; }
.arrow-left { left: 7px; }
.arrow-left::after { left: -10px; top: -2px; transform: none; border-top: 12px solid transparent; border-bottom: 12px solid transparent; border-right: 14px solid #ead7a3; }
.scratch-art { position: relative; width: 170px; height: 92px; margin: 0 auto 12px; border: 1px solid #80613a; border-radius: 8px; background: linear-gradient(145deg, #123b2c, #061812); overflow: hidden; }
.scratch-art::after { content: ""; position: absolute; left: 18px; right: 16px; bottom: 15px; height: 10px; border-radius: 50%; background: #020403; box-shadow: 0 0 0 5px #37271a; }
.scratch-ball { position: absolute; z-index: 1; left: 42px; top: 28px; width: 24px; height: 24px; border: 1px solid #d9d9d9; border-radius: 50%; background: radial-gradient(circle at 32% 27%, #fff 0 18%, #dedbd0 42%, #9c9a93 100%); }
.scratch-arrow { position: absolute; z-index: 2; left: 68px; top: 27px; color: #f0c571; font-size: 30px; line-height: 1; }
.scratch-pocket { position: absolute; z-index: 1; right: 34px; bottom: 18px; width: 28px; height: 20px; border-radius: 50%; background: #020202; }
.result-avatar { display: block; width: 104px; height: 104px; margin: 0 auto 16px; object-fit: contain; }
.result-panel h2 { margin-bottom: 4px; }
.result-panel .result-reason { margin: 0 0 24px; color: var(--gold); font-weight: 800; }
.result-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; }
.secondary-button { color: var(--cream); background: #17362c; }
.rules-modal { padding: 24px; }
.modal-top { display: flex; justify-content: space-between; align-items: center; }
.close { border: 0; color: white; background: transparent; font-size: 1.6rem; }
h2 { margin: 4px 0 14px; font: 700 2rem Georgia, serif; }
li { margin: 8px 0; line-height: 1.4; }
.rules-modal p:not(.eyebrow) { color: #c6d2c6; line-height: 1.5; }
.modal-button { padding: 10px 16px; border: 1px solid var(--line); border-radius: 6px; color: #1a1208; background: #f0c571; font-weight: 800; }
@media (max-width: 1100px) {
  .score-card { gap: 8px; padding: 8px; }
  .avatar { width: 48px; height: 48px; }
  .score-copy { min-width: 70px; }
}
@media (max-width: 900px) {
  .game-header { gap: 8px; }
  .score-card { gap: 7px; padding: 7px; min-height: 66px; }
  .avatar { width: 43px; height: 43px; }
  .ball-progress { display: none; }
  .title-block { min-width: 170px; }
  .score-copy { min-width: 0; }
  .score-copy strong { font-size: .83rem; }
  .score-copy small { font-size: .7rem; }
}
@media (max-width: 600px) {
  .game-stage { padding: 8px 5px 16px; }
  .game-header { grid-template-columns: 1fr 1fr; }
  .title-block { grid-column: 1 / -1; grid-row: 1; }
  h1 { font-size: 2.8rem; }
  .score-card { grid-row: 2; }
  .score-card-right { flex-direction: row-reverse; justify-content: flex-start; text-align: left; }
  .table-area { margin: 2px -5px 0; padding-left: 48px; }
  .table-message { font-size: .67rem; }
  .top-controls { gap: 5px; margin-bottom: 8px; }
  .top-button, .assist-toggle, .top-controls .tab { min-height: 34px; padding: 0 8px; font-size: .72rem; }
  .power-control { width: 43px; padding: 5px 2px; font-size: .62rem; }
  .undo-aim { width: 25px; height: 25px; margin-bottom: 5px; }
  .undo-aim svg { width: 15px; height: 15px; }
  .power-meter { touch-action: none; width: 22px; height: 112px; margin: 5px 0; }
  .power-thumb { width: 29px; height: 12px; }
  .start-content { padding: 20px; }
  .start-options { grid-template-columns: 1fr; }
  .start-option { min-height: 100px; }
}

@media (pointer: coarse) { .game-stage { background-attachment: scroll; box-shadow: none; } canvas { image-rendering: auto; } }
