html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body { display: flex; flex-direction: column; overflow: hidden; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 12px; background: var(--bg-2); border-bottom: 1px solid var(--line); flex: 0 0 auto; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand .home { color: var(--muted); text-decoration: none; font-size: 20px; padding: 4px 8px; border-radius: 6px; }
.brand .title { font-weight: 800; letter-spacing: .04em; text-transform: uppercase; font-size: 15px; color: var(--accent); }
.brand .sub { font-size: 12px; color: var(--muted); white-space: nowrap; }
.tools { display: flex; align-items: center; gap: 6px; }
.tools .sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }
.panel-toggle { display: none; }
.layout { flex: 1 1 auto; display: flex; min-height: 0; }
.board-wrap { flex: 1 1 auto; overflow: auto; padding: 12px; background: #06080c radial-gradient(circle at 30% 10%, #141b27 0, #06080c 60%); position: relative; }
.board-size { position: relative; margin: 0 auto; }
.board { position: absolute; left: 0; top: 0; transform-origin: 0 0; user-select: none; }
.board > * { position: absolute; }
.board .card { border-radius: 8px; box-shadow: 0 6px 24px rgba(0,0,0,.6); pointer-events: none; }
.board .card.mothership { z-index: 5; transition: top .5s ease; box-shadow: 0 20px 50px rgba(0,0,0,.8); }
.arrow-label { z-index: 6; font-size: 26px; font-weight: 800; color: #7df24a; text-shadow: 0 2px 6px #000; background: rgba(5,8,12,.7); padding: 4px 12px; border-radius: 8px; transition: top .5s ease; }
.skull-row { z-index: 1; background: repeating-linear-gradient(135deg, rgba(255,92,92,.12) 0 12px, transparent 12px 24px); border-top: 2px dashed rgba(255,92,92,.6); pointer-events: none; }
.ship { z-index: 7; border-radius: 50% 50% 8px 8px; display: flex; align-items: center; justify-content: center; font-weight: 900; font-size: 30px; color: #fff; box-shadow: 0 4px 12px rgba(0,0,0,.7); transition: left .4s ease, top .4s ease; border: 3px solid rgba(255,255,255,.5); }
.ship.green { background: #27c93f; }
.ship.red { background: #e5323e; }
.ship.target { box-shadow: 0 0 0 6px rgba(255,200,60,.55), 0 4px 12px rgba(0,0,0,.7); }
.ship.pending { opacity: .85; border-style: dashed; }
.reserve { z-index: 7; font-size: 24px; color: #ff8fa3; font-weight: 700; background: rgba(0,0,0,.5); padding: 4px 10px; border-radius: 8px; }
.spot-btn { z-index: 8; border: 5px dashed #7df24a; border-radius: 16px; cursor: pointer; background: rgba(125,242,74,.2); animation: rw-pulse 1.2s infinite; }
.cell { z-index: 3; border-radius: 14px; cursor: pointer; }
.cell.rock { background: rgba(0,0,0,.35); }
.cell.rock.tunnel { background: rgba(0,0,0,.45); }
.cell.dug.tunnel { background: rgba(255,255,255,.04); }
.cell.legal { background: rgba(125,242,74,.35); box-shadow: inset 0 0 0 6px #7df24a; animation: rw-pulse 1.2s infinite; }
.cell.legal.excavate { background: rgba(255,179,71,.35); box-shadow: inset 0 0 0 6px #ffb347; }
.cell.legal.robot { background: rgba(66,198,255,.35); box-shadow: inset 0 0 0 6px #42c6ff; }
.excavator { z-index: 6; background: #fff; border-radius: 10px; box-shadow: 0 3px 8px rgba(0,0,0,.7); border: 4px solid #333; }
.excavator::after { content: ""; position: absolute; inset: 12px; background: #ffb347; border-radius: 4px; }
.die { z-index: 9; border-radius: 18px; display: flex; align-items: center; justify-content: center; font-weight: 900; font-size: 56px; box-shadow: 0 6px 14px rgba(0,0,0,.7); cursor: pointer; transition: transform .3s; }
.die.black { background: #1a1d22; color: #fff; border: 4px solid #000; }
.die.white { background: #f4f6f8; color: #111; border: 4px solid #999; }
.die.robot { background: #2f7be0; color: #fff; border: 4px solid #164a93; }
.die.robot.used { transform: rotate(45deg); opacity: .8; }
.die.can { box-shadow: 0 0 0 8px rgba(125,242,74,.6), 0 6px 14px rgba(0,0,0,.7); }
.die.exc { border-color: #ffb347; }
.die .cost { position: absolute; bottom: -22px; font-size: 20px; color: #ffd400; text-shadow: 0 0 4px #000; }
.marker { z-index: 8; border-radius: 10px; border: 4px solid #fff; box-shadow: 0 3px 8px rgba(0,0,0,.7); transition: left .4s, top .4s; }
.marker.damage { background: #e5323e; }
.marker.research { background: #27c93f; }
.marker.energy { background: #ffd400; }
.zero-energy { z-index: 8; font-size: 36px; font-weight: 900; color: #ff5c5c; }
/* panel */
.side { flex: 0 0 380px; display: flex; flex-direction: column; border-left: 1px solid var(--line); background: var(--bg-2); min-height: 0; }
.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tabs button { flex: 1; background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted); font: inherit; font-weight: 600; padding: 10px 4px; cursor: pointer; }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }
.panel { flex: 1 1 auto; overflow: auto; padding: 10px 12px 40px; font-size: 14px; }
.sec { margin-bottom: 14px; padding: 10px 12px; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); }
.sec h3 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.sec p { margin: 6px 0; line-height: 1.4; }
.chips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.chip { background: var(--bg-3); border-radius: 8px; padding: 6px 8px; display: flex; flex-direction: column; }
.chip-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.chip-value { font-weight: 700; font-size: 15px; }
.chip.bad .chip-value { color: var(--danger); }
.chip.good .chip-value { color: var(--accent); }
.hand { display: flex; gap: 10px; margin: 8px 0; }
.hand .die { position: relative; width: 56px; height: 56px; font-size: 28px; border-radius: 12px; }
.hand .die.sel { outline: 4px solid var(--accent); outline-offset: 2px; }
.btn-row { display: flex; gap: 6px; align-items: center; margin: 6px 0; flex-wrap: wrap; }
.good-text { color: var(--accent); font-weight: 700; }
.result { font-size: 22px; font-weight: 900; letter-spacing: .1em; text-align: center; padding: 8px; border-radius: 8px; }
.result.victory { background: rgba(125,242,74,.15); color: var(--accent); }
.result.defeat { background: rgba(255,92,92,.15); color: var(--danger); }
.log { list-style: none; margin: 0; padding: 0; font-size: 12.5px; max-height: 240px; overflow: auto; }
.log li { padding: 3px 0; border-bottom: 1px dashed var(--line); }
.checks { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.accordion details { border-bottom: 1px solid var(--line); padding: 4px 0; }
.accordion summary { cursor: pointer; font-weight: 600; }
.rules-pages img { width: 100%; height: auto; border-radius: 6px; margin-bottom: 8px; background: #fff; }
.muted { color: var(--muted); } .small { font-size: 12px; }
@media (max-width: 900px) {
  .panel-toggle { display: inline-block; }
  .layout { flex-direction: column; }
  .side { flex: 0 0 auto; border-left: 0; border-top: 1px solid var(--line); max-height: 50vh; }
  body:not(.panel-open) .side { max-height: 44px; }
  body:not(.panel-open) .side .panel { display: none; }
  .brand .sub { display: none; }
}
