:root{
  --bg:#0b1020; --bg2:#121a30; --panel:#151e38; --line:#27355c; --text:#e9eefb; --muted:#9aa7c7;
  --accent:#ffb84d; --accent2:#7de3f0; --radius:14px;
  --bg-image: radial-gradient(1200px 500px at 50% -120px, #1c2c5a 0%, transparent 70%);
  --felt:#0f4c5c; --felt2:#136a7d;
}
/* Shared arcade UI base (mobile-first). Game-specific theme + board styles follow. */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  background-image: var(--bg-image, none);
  line-height: 1.4;
}
button, select, input { font: inherit; }
.app-header { text-align: center; padding: 14px 16px 6px; }
.logo { margin: 0; font-size: 26px; letter-spacing: .5px; color: var(--accent); }
.tagline { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.back-link { color: var(--accent2); text-decoration: none; font-size: 14px; }
.back-link:hover { text-decoration: underline; }
.help-btn { margin-top: 10px; }
.app-main { display: flex; flex-direction: column; gap: 14px; padding: 8px 16px 40px; max-width: 1040px; margin: 0 auto; }
.board-panel { width: 100%; min-width: 0; }
.side-panel { width: 100%; min-width: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
@media (min-width: 900px) {
  .app-main { flex-direction: row; align-items: flex-start; gap: 22px; }
  .board-panel { flex: 1 1 auto; }
  .side-panel { flex: 0 0 340px; width: 340px; }
}
.panel-title { margin: 16px 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: 1.4px; color: var(--muted); }
.panel-title:first-child { margin-top: 0; }
.turn-indicator { display: flex; align-items: center; gap: 8px; font-weight: 600; min-height: 28px; }
.turn-dot { width: 16px; height: 16px; border-radius: 50%; flex: 0 0 16px; }
.result { display: none; padding: 10px 12px; border-radius: 10px; font-weight: 700; background: rgba(255,184,77,.12); border: 1px solid var(--accent); color: var(--accent); margin: 8px 0; }
.result.show { display: block; }
.stat-row { display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; margin: 6px 0; }
.stat-row b { color: var(--text); }
.controls { display: flex; flex-direction: column; gap: 10px; }
.btn-row { display: flex; gap: 6px; flex-wrap: wrap; }
.btn-row .btn { flex: 1 1 auto; }
.btn {
  appearance: none; border: 0; cursor: pointer; border-radius: 10px;
  background: var(--accent); color: #1a1205; font-weight: 700;
  padding: 11px 16px; min-height: 44px; font-size: 15px;
  touch-action: manipulation;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .4; cursor: default; filter: none; }
.btn-sm { padding: 7px 12px; font-size: 14px; min-height: 40px; }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--line); font-weight: 600; }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.ctl { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
select, input[type=text] {
  width: 100%; min-height: 42px; padding: 8px 10px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--bg2); color: var(--text); font-size: 15px;
}
.chk { display: flex; align-items: center; gap: 10px; min-height: 36px; font-size: 14px; color: var(--text); cursor: pointer; }
.chk input { width: 20px; height: 20px; accent-color: var(--accent); flex: 0 0 20px; }
.note { margin: 0; color: var(--muted); font-size: 12.5px; }
.ai-status { font-size: 13px; color: var(--accent); min-height: 18px; font-style: italic; }
.tn-entry { display: flex; gap: 6px; margin-bottom: 8px; }
.tn-actions { display: flex; gap: 6px; margin: 8px 0; }
.tn-actions .btn { flex: 1; }
#ol-name { margin-bottom: 4px; }
.tn-body { font-size: 13px; }
.tn-result { font-weight: 700; color: var(--accent); margin-bottom: 6px; }
.tn-king { color: var(--accent2); font-weight: 600; 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; }
.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: 150px; overflow-y: auto; font-size: 13px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 12px; }
.move-log li { display: flex; align-items: center; gap: 4px; }
.mv-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.flash {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%) translateY(20px);
  background: #1d2338; border: 1px solid var(--accent); color: var(--text);
  padding: 10px 16px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none;
  transition: opacity .2s ease, transform .2s ease; z-index: 70; max-width: 92vw; text-align: center;
}
.flash.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.help-overlay { display: none; position: fixed; inset: 0; background: rgba(5,8,16,.78); z-index: 80; align-items: center; justify-content: center; padding: 12px; }
.help-overlay.open { display: flex; }
.help-card { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; width: 100%; max-width: 640px; max-height: 92vh; overflow-y: auto; padding: 20px 18px; }
.help-card h2 { color: var(--accent); margin: 0 36px 8px 0; font-size: 22px; }
.help-card h3 { color: var(--accent); font-size: 15px; margin: 18px 0 6px; }
.help-card p, .help-card li { font-size: 14px; line-height: 1.55; }
.help-card ul, .help-card ol { padding-left: 20px; margin: 6px 0; }
.help-card b { color: #fff; }
.help-close { position: absolute; top: 8px; right: 8px; width: 40px; height: 40px; border: 0; background: transparent; color: var(--muted); font-size: 28px; cursor: pointer; }
.help-close:hover { color: var(--accent); }
.help-actions { text-align: right; margin-top: 18px; }
.help-figs { display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0; }
.help-figs figure { margin: 0; flex: 1 1 140px; min-width: 0; }
.help-figs svg { width: 100%; height: auto; display: block; border-radius: 8px; }
.help-figs figcaption { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; transition-duration: .01ms !important; transition-delay: 0s !important; } }

/* ---------- Reversi board ---------- */
.scorebar { display: flex; justify-content: space-between; gap: 10px; margin: 0 auto 8px; max-width: 560px; }
.sc { display: flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; background: var(--panel); border: 2px solid var(--line); font-size: 15px; min-width: 0; }
.sc b { font-size: 22px; min-width: 1.4em; text-align: center; }
.sc-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 90px; color: var(--muted); }
.sc.active { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255,184,77,.18); }
.sc.active .sc-name { color: var(--text); }
.sc-disc, .turn-dot, .mv-dot { display: inline-block; border-radius: 50%; flex: 0 0 auto; }
.sc-disc { width: 20px; height: 20px; }
.night { background: radial-gradient(circle at 35% 30%, #5560d6 0%, #2a3190 45%, #151a52 100%); }
.sun { background: radial-gradient(circle at 35% 30%, #fff0c2 0%, #ffb84d 50%, #d98a14 100%); }
.turn-dot.night, .turn-dot.sun, .mv-dot.night, .mv-dot.sun { box-shadow: 0 0 0 1px rgba(255,255,255,.25); }

.board {
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px;
  width: 100%; max-width: 560px; aspect-ratio: 1 / 1; margin: 0 auto; padding: 6px;
  background: #07313b; border-radius: 16px; border: 3px solid #1c7b90;
  box-shadow: 0 14px 40px rgba(0,0,0,.45), inset 0 0 0 2px rgba(0,0,0,.35);
}
.cell {
  position: relative; display: block; padding: 0; border: 0; border-radius: 6px; cursor: pointer; min-width: 0; min-height: 0;
  background: linear-gradient(145deg, var(--felt2), var(--felt));
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.cell:focus-visible { outline: 3px solid var(--accent2); outline-offset: -3px; }
.cell.hint { background: linear-gradient(145deg, #1b8196, #15697c); }
.hintdot { position: absolute; left: 50%; top: 50%; width: 26%; height: 26%; transform: translate(-50%, -50%) scale(0); border-radius: 50%; border: 2px solid var(--accent2); background: rgba(125,227,240,.25); transition: transform .15s; pointer-events: none; }
.cell.hint .hintdot { transform: translate(-50%, -50%) scale(1); }
.cell.last::after { content: ""; position: absolute; right: 6%; top: 6%; width: 18%; height: 18%; border-radius: 50%; background: #ff6f61; box-shadow: 0 0 0 2px rgba(0,0,0,.3); pointer-events: none; }

.disc { position: absolute; inset: 9%; transform-style: preserve-3d; transition: transform .5s cubic-bezier(.4,.1,.3,1); transform: scale(0); pointer-events: none; }
.disc[data-c="1"] { transform: scale(1) rotateY(0deg); }
.disc[data-c="2"] { transform: scale(1) rotateY(180deg); }
.face { position: absolute; inset: 0; border-radius: 50%; backface-visibility: hidden; -webkit-backface-visibility: hidden; box-shadow: 0 3px 6px rgba(0,0,0,.45), inset 0 -3px 5px rgba(0,0,0,.25); }
.face.sun { transform: rotateY(180deg); }

@media (prefers-reduced-motion: reduce) { .disc { transition: none; } }
