:root {
  color-scheme: dark;
  --gold: #dfc47f;
  --cream: #f4ead1;
  --ink: #070706;
  --blue: #258bdd;
  --red: #d84f58;
  --yellow: #d8a72f;
  --green: #279164;
  background: #030403;
}
* { box-sizing: border-box }
[hidden] { display: none !important }
html { min-height: 100%; background: #030403 }
body {
  min-height: 100svh;
  margin: 0;
  background-color: #030403;
  background-image: radial-gradient(circle at 50% 34%, #253423 0, #0a0e0c 45%, #030403 85%);
  color: var(--cream);
  font-family: system-ui, sans-serif;
  overscroll-behavior: none;
}
.home-bar {
  display: flex;
  min-height: calc(52px + env(safe-area-inset-top));
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding-top: env(safe-area-inset-top);
  border-bottom: 1px solid #f2dc9c;
  background: linear-gradient(110deg, #af8532, #efd88b 48%, #af8532);
  color: #090806;
  font-size: .88rem;
  font-weight: 850;
  letter-spacing: .16em;
  text-decoration: none;
  text-transform: uppercase;
}
.home-bar::before { content: '←'; font-size: 1.15rem }
.preview-capture .home-bar, .preview-capture .ad-reservation { display: none }
.game-shell {
  display: flex;
  width: min(100%, 670px);
  height: calc(100svh - 52px - env(safe-area-inset-top));
  min-height: 610px;
  flex-direction: column;
  margin: auto;
  padding: 8px 10px calc(7px + env(safe-area-inset-bottom));
}
.scorebar {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  margin-bottom: 5px;
  overflow: hidden;
  border: 1px solid #554625;
  border-radius: 11px;
  background: #0d0c09;
  box-shadow: inset 0 1px #fff2;
}
.scorebar > div { padding: 5px; text-align: center }
.scorebar > div + div { border-left: 1px solid #3d321d }
.scorebar span { display: block; color: #a99f88; font-size: 8px; font-weight: 800; letter-spacing: .13em }
.scorebar strong { display: block; margin-top: 1px; color: #ead08f; font: 18px Georgia, serif }
.status { display: grid; min-height: 27px; place-items: center; margin: 0 0 4px; font-size: 12px; text-align: center }
.board {
  --cell: calc(100% / 15);
  position: relative;
  display: grid;
  width: min(100%, calc(100svh - 337px), 620px);
  aspect-ratio: 1;
  flex: 0 0 auto;
  grid-template-columns: repeat(15, 1fr);
  grid-template-rows: repeat(15, 1fr);
  align-self: center;
  overflow: hidden;
  border: 3px solid #d7b96b;
  border-radius: 16px;
  background: #e8dcc1;
  box-shadow: inset 0 0 0 2px #55431e, 0 13px 30px #000a;
  touch-action: manipulation;
}
.board-cell { position: relative; z-index: 1; border: .5px solid #806f4a60; background: #f3ead8 }
.board-cell.path { background: linear-gradient(145deg, #fffdf3, #d7ccb4) }
.board-cell.safe::after { content: '★'; position: absolute; inset: 0; display: grid; place-items: center; color: #9f8958; font-size: clamp(7px, 2vw, 14px) }
.board-cell.lane-blue { background: #70baf0 }
.board-cell.lane-red { background: #e98188 }
.board-cell.lane-gold { background: #edc45e }
.board-cell.lane-green { background: #6fc49a }
.yard { position: absolute; z-index: 0; width: 40%; height: 40%; padding: 5%; border: 1px solid #fff3; background: #111 }
.yard::before { content: ''; position: absolute; inset: 12%; border: 2px solid #fff7; border-radius: 18%; background: #f4eadb }
.yard-blue { left: 0; top: 0; background: #287ec0 }
.yard-red { right: 0; top: 0; background: #c94751 }
.yard-gold { right: 0; bottom: 0; background: #c99a27 }
.yard-green { left: 0; bottom: 0; background: #247b55 }
.center-mark { position: absolute; z-index: 1; left: 40%; top: 40%; width: 20%; height: 20%; overflow: hidden; background: conic-gradient(from 45deg, var(--red) 0 25%, var(--yellow) 0 50%, var(--green) 0 75%, var(--blue) 0); clip-path: polygon(50% 50%, 100% 0, 100% 100%, 0 100%, 0 0) }
.pieces { position: absolute; inset: 0; z-index: 5; pointer-events: none }
.piece { position: absolute; left: var(--x); top: var(--y); width: 9%; aspect-ratio: 1; border: 0; padding: 0; background: transparent; transform: translate(-50%, -67%); transition: left .22s ease, top .22s ease, transform .2s; filter: drop-shadow(0 2px 2px #000a); pointer-events: none }
.piece img { display: block; width: 100%; height: 100%; object-fit: contain; pointer-events: none }
.piece.selectable { pointer-events: auto; cursor: pointer; animation: piece-glow .8s ease-in-out infinite }
@keyframes piece-glow { 50% { filter: drop-shadow(0 0 7px #fff7a8) drop-shadow(0 2px 2px #000a); transform: translate(-50%, -72%) scale(1.13) } }
.ad-reservation { display: grid; min-height: 36px; place-items: center; margin-top: 6px; border: 1px dashed #66552e; border-radius: 9px; color: #8b8064; font-size: 8px; letter-spacing: .2em }
.coin-reveal { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; pointer-events: none; background: #0003 }
.coin-reveal span { display: grid; width: 112px; aspect-ratio: 1; place-items: center; border: 7px double #fff0a1; border-radius: 50%; background: #dfaa27; color: #8b580c; box-shadow: 0 0 55px #ffd85e; font-size: 58px; animation: coin-pop 2s ease-in-out }
@keyframes coin-pop { 0%, 100% { opacity: 0; transform: scale(.25) rotate(-20deg) } 20%, 72% { opacity: 1; transform: scale(1.18) rotate(8deg) } 45% { transform: scale(.94) } }
dialog { width: min(430px, calc(100% - 24px)); max-height: calc(100dvh - 28px); overflow: auto; border: 1px solid #79653a; border-radius: 19px; padding: 21px; background: #11100d; color: #ece0c8; color-scheme: dark; box-shadow: 0 25px 100px #000d }
dialog::backdrop { background: #000c }
.dialog-top { display: flex; align-items: center; justify-content: space-between; gap: 10px }
.dialog-top h2, dialog h2 { margin: 0; color: #efd699; font: 27px Georgia, serif }
.dialog-top .icon-button { width: 38px; height: 38px }
.select-field, .switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid #3b3120 }
.select-field span { display: grid; gap: 3px }
.select-field small { color: #a99e87 }
.select-field select { max-width: 145px; padding: 8px; border: 1px solid #6c5830; border-radius: 8px; background: #090807; color: #eee }
.switch-row input { width: 22px; height: 22px; accent-color: #d5b765 }
fieldset { margin: 15px 0 0; border: 1px solid #4a3c23; border-radius: 12px; padding: 8px 12px }
legend { color: #dfc47f; font-weight: 800 }
.player-setting { display: grid; grid-template-columns: 36px 1fr auto; align-items: center; gap: 8px; padding: 6px 0 }
.player-setting img { width: 36px; height: 36px; object-fit: contain }
.player-setting select { padding: 7px; border-radius: 8px; background: #090807; color: #eee }
.primary-button, .secondary-button { width: 100%; min-height: 50px; margin-top: 14px; border: 1px solid #e0c574; border-radius: 13px; background: linear-gradient(145deg, #b38834, #e1c36d 55%, #8b6420); color: #151006; font-weight: 900 }
.secondary-button { border-color: #64542f; background: #19160f; color: #ecd9aa }
.dialog-buttons { display: grid; gap: 7px }
.record-panel { margin: 14px 0; padding: 13px; border: 1px solid #4b3d24; border-radius: 13px; background: #18150f }
.eyebrow { margin: 0 0 9px; color: #ad9c78; font-size: 8px; font-weight: 800; letter-spacing: .15em }
.record-grid { display: grid; grid-template-columns: 1fr auto; gap: 7px; font-size: 13px }
.record-grid strong { color: #efd28e }
.control-rule { display: flex; align-items: center; gap: 10px }
.control-symbol { display: grid; flex: 0 0 34px; height: 34px; place-items: center; border: 1px solid #554625; border-radius: 50%; color: #ead28f }
.result-dialog { text-align: center }
.result-mark { margin: 0; font-size: 52px }
.result-dialog .secondary-button { margin-top: 8px }
button:focus-visible, select:focus-visible { outline: 3px solid #fff1a6; outline-offset: 2px }
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; transition-duration: .01ms !important } }
@media (min-width: 700px) and (min-height: 850px) { .game-shell { width: min(92vw, 820px) } .board { width: min(76vw, 690px) } }
@media (max-height: 720px) and (orientation: landscape) {
  .game-shell { display: grid; max-width: 1050px; grid-template-columns: minmax(430px, 65vh) 1fr; grid-template-rows: auto auto auto 1fr auto; gap: 5px }
  .topbar { grid-column: 1 / -1 }
  .scorebar, .demo-bar, .status, .ad-reservation { grid-column: 2 }
  .board { grid-column: 1; grid-row: 2 / 7; width: min(65vh, 600px) }
  .scorebar { grid-row: 2 }
  .demo-bar { grid-row: 3; margin: 0 }
  .status { grid-row: 4 }
  .ad-reservation { grid-row: 6 }
}
