/* Backgammon — mobile-first layout. The SVG board scales to its container. */
:root {
  --bg: #0f1726; --panel: #18233b; --panel-line: rgba(255,255,255,0.08);
  --text: #e8eef9; --muted: #93a3c0; --accent: #10b981; --gold: #f4c150; --field: #0f1726;
}
* { box-sizing: border-box; }
html, body { max-width: 100%; }
body {
  margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text); min-height: 100vh;
  background: radial-gradient(1200px 600px at 50% -10%, #16213a 0%, var(--bg) 60%);
}
.app-header { text-align: center; padding: 14px 16px 6px; }
.logo { font-size: 30px; margin: 0; color: var(--gold); letter-spacing: .5px; }
.tagline { color: var(--muted); margin: 4px 0 0; letter-spacing: 2px; text-transform: uppercase; font-size: 11px; }
.hdr-links { margin: 8px 0 0; display: flex; gap: 12px; justify-content: center; align-items: center; flex-wrap: wrap; }
.back-link { color: #f5d98a; font-size: 14px; text-decoration: none; padding: 8px 4px; }
.back-link:hover { text-decoration: underline; }

.app-main { display: flex; gap: 18px; justify-content: center; align-items: flex-start; padding: 8px 8px 40px; flex-wrap: wrap; }
.board-panel { width: 100%; max-width: 760px; min-width: 0; background: linear-gradient(160deg, #3a2a17, #241a0f); padding: 8px; border-radius: 14px; box-shadow: 0 18px 40px rgba(0,0,0,.5), inset 0 0 0 2px #7a5a2e; }
.board { width: 100%; touch-action: manipulation; -webkit-tap-highlight-color: transparent; user-select: none; }
.board svg { display: block; width: 100%; height: auto; }

.score-strip { display: flex; justify-content: space-between; align-items: center; gap: 6px; padding: 2px 4px 8px; font-size: 13px; }
.sc { font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.sc-w { background: #f1ead8; color: #2a2418; }
.sc-b { background: #20242c; color: #fff; border: 1px solid #555; }
.sc-mid { color: #f5d98a; text-align: center; font-size: 12px; }

.dice-strip { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.dice { display: flex; gap: 8px; align-items: center; min-height: 46px; cursor: pointer; flex: 1 1 130px; }
.tumble { display: inline-flex; gap: 8px; animation: shake .14s linear infinite; }
@keyframes shake { 0% { transform: rotate(-9deg) translateY(0); } 50% { transform: rotate(8deg) translateY(-3px); } 100% { transform: rotate(-9deg) translateY(0); } }
.die { width: 42px; height: 42px; border-radius: 9px; background: #fbf8ef; box-shadow: 0 2px 0 #b9ad8f, 0 4px 8px rgba(0,0,0,.45); display: grid; grid-template: repeat(3, 1fr) / repeat(3, 1fr); padding: 6px; }
.die i { display: block; }
.die i.pip { width: 8px; height: 8px; border-radius: 50%; background: #1b1b1b; margin: auto; }
.die.used { opacity: .35; filter: grayscale(.6); }
.die-hint { color: var(--muted); font-size: 14px; }
.act-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.status { margin-top: 8px; min-height: 22px; font-size: 14px; color: #f5d98a; font-weight: 600; }
.info-line { font-size: 12px; color: var(--muted); min-height: 16px; margin-top: 2px; }
.next-row { margin-top: 6px; }

.side-panel { width: 100%; max-width: 760px; background: var(--panel); border: 1px solid var(--panel-line); border-radius: 14px; padding: 16px; box-shadow: 0 18px 40px rgba(0,0,0,.4); }
.panel-title { font-size: 16px; color: #f5d98a; margin: 16px 0 10px; border-bottom: 1px solid var(--panel-line); padding-bottom: 6px; }
.panel-title:first-child { margin-top: 0; }
.turn-indicator { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 15px; }
.turn-dot { width: 14px; height: 14px; border-radius: 50%; border: 1px solid #0b1220; }
.turn-dot.w { background: #fdfaf3; box-shadow: 0 0 10px rgba(255,255,255,.5); }
.turn-dot.b { background: #22252c; box-shadow: 0 0 10px rgba(0,0,0,.6); border-color: #777; }
.controls { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.btn-row { display: flex; gap: 6px; }
.btn-row .btn { flex: 1; }
.btn { font: inherit; font-weight: 600; font-size: 14px; color: #06281e; background: var(--accent); border: none; border-radius: 11px; padding: 11px 16px; min-height: 44px; cursor: pointer; }
.btn:hover { filter: brightness(1.07); }
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .45; cursor: default; filter: none; }
.btn-sm { padding: 9px 12px; font-size: 13px; }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--panel-line); }
.btn-ghost:hover:not(:disabled) { color: #f5d98a; border-color: #f5d98a; }
.btn-gold { background: var(--gold); color: #3a2a05; }
.help-btn { margin: 0; background: transparent; color: #f5d98a; border: 1px solid rgba(245,217,138,.4); }
.ctl { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.ctl select { margin-left: auto; background: var(--field); color: var(--text); border: 1px solid var(--panel-line); border-radius: 6px; padding: 6px 8px; font: inherit; }
.ai-status { font-size: 12px; color: #f5d98a; min-height: 16px; font-style: italic; }

.tn-entry { display: flex; gap: 6px; margin-bottom: 8px; }
.tn-entry input, #ol-name { flex: 1; min-width: 0; width: 100%; background: var(--field); color: var(--text); border: 1px solid var(--panel-line); border-radius: 6px; padding: 9px 8px; font: inherit; font-size: 14px; margin-bottom: 8px; }
.tn-entry input { margin-bottom: 0; }
.tn-actions { display: flex; gap: 6px; margin-bottom: 10px; }
.tn-actions .btn { flex: 1; }
.tn-body { font-size: 13px; }
.tn-result { font-size: 15px; color: #f5d98a; margin-bottom: 6px; font-weight: 600; }
.tn-king { color: #ffcf6b; font-weight: 500; margin-bottom: 8px; }
.tn-sub { color: var(--muted); margin: 6px 0 4px; font-size: 12px; }
.tn-hint { color: var(--muted); font-style: italic; font-size: 12px; line-height: 1.45; }
.tn-queue { margin: 0 0 8px; padding-left: 22px; max-height: 140px; overflow-y: auto; }

.move-log { margin: 0; padding: 0; list-style: none; max-height: 240px; overflow-y: auto; font-size: 13px; }
.move-log li { margin: 1px 0; padding: 3px 6px; border-radius: 4px; display: flex; gap: 8px; }
.move-log li:nth-child(odd) { background: rgba(255,255,255,.03); }
.log-head { color: #f5d98a; font-weight: 700; }
.mv-who { width: 20px; text-align: center; border-radius: 4px; font-weight: 700; font-size: 11px; line-height: 18px; }
.mv-who.w { background: #f1ead8; color: #222; }
.mv-who.b { background: #20242c; color: #fff; border: 1px solid #555; }
.mv-t { overflow-wrap: anywhere; }

.help-overlay { position: fixed; inset: 0; background: rgba(10,6,3,.72); display: none; align-items: center; justify-content: center; z-index: 50; padding: 14px; }
.help-overlay.open { display: flex; }
.help-card { position: relative; background: var(--panel); border: 1px solid var(--panel-line); border-radius: 14px; max-width: 660px; width: 100%; max-height: 88vh; overflow-y: auto; padding: 22px 20px 20px; box-shadow: 0 24px 70px rgba(0,0,0,.6); }
.help-card h2 { color: #f5d98a; margin: 0 36px 8px 0; font-size: 21px; }
.help-card h3 { color: #f5d98a; font-size: 15px; margin: 16px 0 4px; }
.help-card p, .help-card li { font-size: 14px; line-height: 1.55; }
.help-card p { margin: 6px 0; }
.help-card ul { margin: 6px 0; padding-left: 20px; }
.help-card b { color: #f3e6d3; }
.help-close { position: absolute; top: 8px; right: 10px; background: transparent; border: none; color: var(--muted); font-size: 30px; line-height: 1; cursor: pointer; padding: 6px 10px; }
.help-actions { text-align: right; margin-top: 18px; }
.cube-card { max-width: 420px; }
.cube-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

@media (min-width: 900px) {
  .logo { font-size: 44px; }
  .app-main { gap: 24px; padding: 14px 16px 48px; }
  .board-panel { width: min(760px, calc(100vw - 400px)); min-width: 560px; }
  .side-panel { width: 320px; }
  .help-card { padding: 26px 30px; }
}
