html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body { display: flex; flex-direction: column; overflow: hidden; }
.noscript { padding: 20px; }

.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 .home:hover { background: var(--bg-3); color: var(--text); }
.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; overflow: hidden; text-overflow: ellipsis; }
.tools { display: flex; align-items: center; gap: 6px; flex-wrap: nowrap; }
.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-scroll { flex: 1 1 auto; overflow: auto; padding: 12px; background: #0a0e14 radial-gradient(circle at 30% 20%, #16202d 0, #0a0e14 60%); }
.board-main { width: 100%; margin: 0 auto; box-shadow: 0 10px 40px rgba(0,0,0,.6); border-radius: 6px; overflow: hidden; }
.board-main .rw-board { width: 100%; }
.card-row { display: flex; flex-wrap: wrap; gap: 12px; margin: 14px auto 0; }
.card-wrap { flex: 1 1 320px; max-width: 520px; box-shadow: 0 10px 30px rgba(0,0,0,.5); border-radius: 6px; overflow: hidden; }
.card-wrap .rw-board { width: 100%; }

.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; min-width: 0; }
.chip-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.chip-value { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip.good .chip-value { color: var(--accent); }
.chip.bad .chip-value { color: var(--danger); }

.btn-row { display: flex; gap: 6px; align-items: center; }
.btn-row.wrap { flex-wrap: wrap; }
.btn-col { display: flex; flex-direction: column; gap: 4px; }
.dice-row { display: flex; gap: 10px; margin: 10px 0; }
.die-card { display: flex; align-items: center; gap: 10px; background: var(--bg-3); border-radius: 10px; padding: 8px 10px; flex: 1; border: 1px solid var(--line); }
.die-card.chosen { border-color: var(--accent); }
.die-card.dim { opacity: .5; }
.die { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 8px; background: #f4f6f8; color: #111; font-weight: 800; font-size: 20px; box-shadow: inset 0 -3px 0 rgba(0,0,0,.15); }
.die.big { width: 48px; height: 48px; font-size: 26px; }
.dice-line { display: flex; gap: 8px; }
.ap-row { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.ap-big { flex: 1; text-align: center; font-size: 30px; font-weight: 800; color: var(--accent); }
.ap-big span { font-size: 12px; color: var(--muted); margin-left: 6px; font-weight: 600; }

.action-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; margin-bottom: 8px; }
.btn.action { display: flex; align-items: center; gap: 8px; text-align: left; padding: 8px 10px; }
.btn.action .cost { display: inline-flex; align-items: center; justify-content: center; min-width: 26px; height: 24px; padding: 0 5px; border-radius: 6px; background: var(--accent); color: #0b1a07; font-weight: 800; font-size: 12px; }
.small-text { font-size: 12px; }
.warn-text { color: #ffb347; }
.good-text { color: var(--accent); font-weight: 700; }

.hack-rows { display: flex; flex-direction: column; gap: 4px; }
.hack-row { display: flex; justify-content: space-between; gap: 8px; padding: 6px 8px; border-radius: 6px; background: var(--bg-3); border-left: 3px solid var(--line); font-size: 13px; }
.hack-row.ready { border-left-color: var(--accent-2); }
.hack-row.done { border-left-color: var(--accent); opacity: .8; }
.hack-row.here { outline: 1px solid var(--accent-2); }

.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); }
.score-table { width: 100%; border-collapse: collapse; margin: 8px 0; }
.score-table td { padding: 4px 6px; border-bottom: 1px solid var(--line); }
.score-table td:last-child { text-align: right; font-weight: 700; }
.score-table tr.total td { border-bottom: 0; font-weight: 800; color: var(--accent); }

.log { list-style: none; margin: 0; padding: 0; font-size: 12.5px; max-height: 260px; overflow: auto; }
.log li { padding: 3px 0; border-bottom: 1px dashed var(--line); }

.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; font-weight: 600; }
.field .muted { font-weight: 400; }
.board-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.board-opt { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px; border: 2px solid var(--line); border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 12px; }
.board-opt.on { border-color: var(--accent); }
.board-opt input { display: none; }
.board-opt img { width: 100%; border-radius: 4px; }
.checks { display: flex; flex-direction: column; gap: 6px; font-weight: 400; }
.accordion details { border-bottom: 1px solid var(--line); padding: 4px 0; }
.accordion summary { cursor: pointer; font-weight: 600; padding: 4px 0; }
.accordion p { margin: 4px 0 8px; }
.rules-page img { width: 100%; height: auto; display: block; }
.slots { display: flex; flex-direction: column; gap: 6px; }
.slot { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px; background: var(--bg-3); border-radius: 8px; border: 1px solid var(--line); }
.slot.current { border-color: var(--accent); }

@media (max-width: 900px) {
  .panel-toggle { display: inline-block; }
  .tools .sep:last-of-type { display: none; }
  .layout { flex-direction: column; }
  .board-scroll { padding: 8px; }
  .side { flex: 0 0 auto; border-left: 0; border-top: 1px solid var(--line); max-height: 48vh; transition: max-height .2s; }
  body:not(.panel-open) .side { max-height: 44px; }
  body:not(.panel-open) .side .panel { display: none; }
  .chips { grid-template-columns: repeat(3, 1fr); }
  .brand .sub { display: none; }
}
@media (max-width: 480px) {
  .tools #redo, .tools #zoom-fit { display: none; }
  .action-grid { grid-template-columns: 1fr 1fr; }
}
