:root {
  color-scheme: dark;
  --page: #211923;
  --panel: #30232e;
  --line: #604651;
  --ink: #f6e8d0;
  --muted: #c7ab9f;
  --gold: #f0c686;
  font-family: "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: radial-gradient(ellipse at 50% 0%, #3d2937 0%, var(--page) 69%);
}

button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #372833;
  color: var(--ink);
  font: inherit;
  font-size: .84rem;
  font-weight: 650;
  padding: 6px 12px;
  cursor: pointer;
  white-space: nowrap;
}

button:hover { background: #513643; }
button:focus-visible { outline: 2px solid #fff0bc; outline-offset: 3px; }
button[aria-pressed="true"], .flash-button {
  background: var(--gold);
  border-color: var(--gold);
  color: #302027;
}
button[aria-pressed="true"]:hover, .flash-button:hover { background: #ffdaa0; }

.shell { width: min(1080px, calc(100% - 48px)); margin: 0 auto; padding: 30px 0 24px; }
.masthead { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 5px;
  color: var(--gold);
  font-size: .73rem;
  font-weight: 750;
  letter-spacing: .18em;
}
.reel { font-size: .97rem; line-height: 1; }
.edition { border-left: 1px solid #85616a; padding-left: 8px; color: var(--muted); font-variant-numeric: tabular-nums; }
h1 {
  margin: 0;
  font-family: "Songti TC", "Noto Serif TC", PMingLiU, serif;
  font-size: clamp(2.2rem, 5vw, 3.7rem);
  font-weight: 800;
  line-height: 1.06;
  letter-spacing: .035em;
  text-shadow: 2px 3px #181219;
}

.segmented { display: flex; align-items: center; gap: 3px; padding: 3px; border: 1px solid var(--line); border-radius: 9px; background: #211923; }
.segmented button { border-color: transparent; background: transparent; color: var(--muted); min-height: 32px; }
.segmented button[aria-pressed="true"] { color: #302027; background: var(--gold); }
.segmented button:hover:not([aria-pressed="true"]) { background: #47303d; color: var(--ink); }
.segmented a { padding: 6px 10px; border-radius: 7px; color: var(--gold); font-size: .84rem; font-weight: 650; text-decoration: none; white-space: nowrap; }
.segmented a:hover { background: #47303d; }
.segmented a:focus-visible { outline: 2px solid #fff0bc; outline-offset: 3px; }

.panel { overflow: hidden; border: 1px solid #75535d; border-radius: 12px; background: var(--panel); box-shadow: 0 16px 36px #140d1466; }
.rail, .commandbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 13px; }
.rail { border-bottom: 1px solid #71545d; }
.rail h2 { display: flex; align-items: center; gap: 9px; margin: 0; font-size: .9rem; letter-spacing: .08em; white-space: nowrap; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 3px #e6ac6b25; }
.actions { display: flex; align-items: center; gap: 8px; }
.actions button span, .flash-button span { margin-right: 2px; }
.stage { background: #211923; }
#arena { display: block; width: 100%; height: auto; cursor: crosshair; touch-action: manipulation; user-select: none; }
.figure.hit { filter: brightness(1.25); }
.commandbar { border-top: 1px solid var(--line); }
.commandbar p { margin: 0; color: var(--muted); font-size: .8rem; line-height: 1.7; }
.separator { margin: 0 4px; color: #bd8c77; }
kbd { border: 1px solid #715661; border-bottom-width: 2px; border-radius: 4px; padding: 2px 5px; color: var(--ink); font: inherit; font-size: .75rem; }

.cast-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; padding: 14px; }
.cast-card { overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: #2a202b; }
.cast-frame {
  display: grid;
  height: 148px;
  place-items: end center;
  padding-bottom: 24px;
  background: linear-gradient(transparent 123px, #77544966 124px, transparent 125px), radial-gradient(ellipse at 50% 72%, #bb987e, #927060 83%);
}
.cast-frame img { display: block; width: auto; height: var(--sprite-height, 72px); }
.cast-grid.is-silhouette img { filter: brightness(0); }
.cast-caption { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 11px; }
.cast-caption h3 { margin: 0; font-size: .87rem; font-weight: 650; }
.badge { border: 1px solid #825f64; border-radius: 20px; padding: 2px 6px; color: #e0b9b8; font-size: .66rem; white-space: nowrap; }
.badge.player { color: #f6dca9; border-color: #9c784f; }
.badge.npc { color: #d2c5df; border-color: #806b89; }
.cast-note { margin: 0; padding: 0 14px 14px; color: var(--muted); font-size: .78rem; }

@media (pointer: coarse) {
  .keyboard-hint { display: none; }
}

@media (max-width: 640px) {
  .shell { width: calc(100% - 24px); padding-top: 16px; }
  .masthead { align-items: start; flex-wrap: wrap; gap: 12px; margin-bottom: 12px; }
  .rail, .commandbar { padding-inline: 9px; }
  .rail h2 { font-size: .82rem; }
  button { padding-inline: 8px; }
  .cast-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 8px; }
  .cast-caption { padding-inline: 7px; }
  .cast-caption h3 { font-size: .77rem; }
  .cast-rail { flex-wrap: wrap; }
}
