* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --dice-gold: #f1b43a;
  --dice-gold-deep: #c98210;
  --dice-gold-soft: #ffdf8a;
  --dice-gold-bright: #fff0bf;
  --dice-gold-bg: rgba(241, 180, 58, 0.12);
  --dice-gold-bg-strong: rgba(241, 180, 58, 0.2);
}
html, body { width: 100%; height: 100%; overflow: hidden; }
body {
  background: #1a1a2e;
  font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  color: #eee;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}
button, input, canvas {
  touch-action: manipulation;
}
#app { width: 100%; height: 100%; }
.hidden { display: none !important; }
#build-stamp {
  position: fixed;
  top: 14px;
  right: 18px;
  z-index: 120;
  padding: 8px 14px;
  border: 1px solid rgba(255, 212, 74, 0.55);
  border-radius: 999px;
  background: rgba(18, 20, 32, 0.9);
  color: #ffd54a;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
  pointer-events: none;
}

/* Title Screen */
#title-screen {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 100%; background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  position: relative;
}
#title-logo {
  width: min(520px, 72vw);
  max-width: 100%;
  margin: 96px 0 26px;
  object-fit: contain;
  filter: drop-shadow(0 18px 34px rgba(0, 0, 0, 0.36));
}
.subtitle { font-size: 18px; color: #888; margin: 8px 0 40px; }
.menu { display: flex; flex-direction: column; gap: 12px; width: 240px; }
.menu button, .hud-buttons button, .hud-panel-toggle, #btn-mobile-hub-close, .mobile-hub-footer button, .mobile-hub-nav-button {
  padding: 12px 24px; font-size: 16px; border: 2px solid var(--dice-gold-deep); border-radius: 8px;
  background: rgba(18, 20, 32, 0.32); color: var(--dice-gold-soft); cursor: pointer; transition: all 0.2s;
}
.menu button:hover, .hud-buttons button:hover, .hud-panel-toggle:hover, #btn-mobile-hub-close:hover, .mobile-hub-footer button:hover, .mobile-hub-nav-button:hover {
  background: linear-gradient(180deg, rgba(241, 180, 58, 0.9) 0%, rgba(201, 130, 16, 0.95) 100%);
  color: #241606;
  border-color: var(--dice-gold-soft);
  box-shadow: 0 10px 22px rgba(201, 130, 16, 0.25);
}
.title-note {
  max-width: 340px;
  margin: 18px 0 0;
  color: #c6d5f0;
  font-size: 14px;
  line-height: 1.45;
  text-align: center;
}
.version { position: absolute; bottom: 16px; color: #555; font-size: 13px; }

#tutorial-screen {
  height: 100%;
  overflow-y: auto;
  background: linear-gradient(160deg, #151827 0%, #17233b 48%, #10233c 100%);
}
.tutorial-shell {
  width: min(1120px, calc(100vw - 40px));
  margin: 0 auto;
  padding: 28px 0 40px;
}
.tutorial-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 24px;
}
.tutorial-topbar button {
  padding: 12px 20px;
  font-size: 15px;
  border: 2px solid var(--dice-gold-deep);
  border-radius: 10px;
  background: rgba(18, 20, 32, 0.42);
  color: var(--dice-gold-soft);
  cursor: pointer;
  transition: all 0.2s ease;
}
.tutorial-topbar button:hover {
  background: linear-gradient(180deg, rgba(241, 180, 58, 0.9) 0%, rgba(201, 130, 16, 0.95) 100%);
  color: #241606;
  border-color: var(--dice-gold-soft);
  box-shadow: 0 10px 22px rgba(201, 130, 16, 0.25);
}
.tutorial-hero {
  margin-bottom: 22px;
  padding: 22px 24px;
  border: 1px solid rgba(241, 180, 58, 0.22);
  border-radius: 18px;
  background:
    radial-gradient(circle at top right, rgba(241, 180, 58, 0.12) 0%, transparent 36%),
    linear-gradient(180deg, rgba(255,255,255,0.05) 0%, rgba(255,255,255,0.03) 100%);
  box-shadow: 0 18px 32px rgba(0,0,0,0.2);
}
.tutorial-kicker {
  color: #f2dc8c;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.tutorial-hero h1 {
  margin: 0 0 12px;
  color: #ffffff;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.05;
}
.tutorial-hero p {
  max-width: 760px;
  margin: 0;
  color: #d5dcee;
  font-size: 16px;
  line-height: 1.55;
}
.tutorial-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}
.tutorial-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.08);
  background: linear-gradient(180deg, rgba(255,255,255,0.06) 0%, rgba(255,255,255,0.03) 100%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
}
.tutorial-card--wide {
  grid-column: 1 / -1;
}
.tutorial-card-title {
  color: #ffffff;
  font-size: 20px;
  font-weight: 800;
  line-height: 1.15;
}
.tutorial-order-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.tutorial-order-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 999px;
  background: rgba(18, 20, 32, 0.56);
  border: 1px solid rgba(241, 180, 58, 0.22);
  color: #f8edc2;
  font-size: 13px;
  font-weight: 700;
}
.tutorial-order-chip img {
  width: 28px;
  height: 28px;
  object-fit: cover;
  border-radius: 8px;
}
.tutorial-order-rank {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #f6cf73 0%, #d1961b 100%);
  color: #16110a;
  font-weight: 900;
}
.tutorial-steps {
  margin: 0;
  padding-left: 20px;
  color: #d8dfee;
  line-height: 1.6;
}
.tutorial-steps li + li {
  margin-top: 8px;
}
.tutorial-board-example {
  display: grid;
  grid-template-columns: repeat(3, 72px);
  grid-template-rows: repeat(3, 72px);
  gap: 6px;
  justify-content: center;
}
.tutorial-board-tile {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: linear-gradient(180deg, #7fb15a 0%, #679147 100%);
  border: 1px solid rgba(18, 20, 32, 0.22);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
}
.tutorial-board-tile img {
  width: 54px;
  height: 54px;
  object-fit: cover;
  border-radius: 12px;
}
.tutorial-board-tile--move {
  box-shadow: inset 0 0 0 3px rgba(116, 241, 144, 0.95), 0 0 18px rgba(116, 241, 144, 0.24);
}
.tutorial-board-tile--attack {
  box-shadow: inset 0 0 0 3px rgba(255, 110, 110, 0.98), 0 0 18px rgba(255, 110, 110, 0.24);
}
.tutorial-board-tile--heal {
  box-shadow: inset 0 0 0 3px rgba(109, 238, 255, 0.98), 0 0 18px rgba(109, 238, 255, 0.24);
}
.tutorial-board-tile--danger {
  background: linear-gradient(180deg, rgba(220, 74, 74, 0.9) 0%, rgba(120, 28, 28, 0.96) 100%);
  box-shadow: inset 0 0 0 3px rgba(255, 207, 207, 0.86), 0 0 18px rgba(255, 100, 100, 0.2);
}
.tutorial-board-tile--unit {
  box-shadow: inset 0 0 0 3px rgba(255, 214, 74, 0.95), 0 0 18px rgba(255, 214, 74, 0.24);
}
.tutorial-board-tile--selected::after {
  content: '';
  position: absolute;
  inset: 8px;
  border: 3px solid rgba(255, 255, 255, 0.95);
  border-radius: 14px;
  pointer-events: none;
}
.tutorial-board-tile--danger::before,
.tutorial-board-tile--danger::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 42px;
  height: 3px;
  background: rgba(255, 245, 220, 0.9);
  border-radius: 999px;
  box-shadow: 0 0 10px rgba(255, 226, 168, 0.22);
}
.tutorial-board-tile--danger::before {
  transform: translate(-50%, -50%) rotate(45deg);
}
.tutorial-board-tile--danger::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}
.tutorial-legend {
  display: grid;
  gap: 8px;
  color: #d8dfee;
  font-size: 14px;
  line-height: 1.45;
}
.tutorial-legend > div {
  display: flex;
  align-items: center;
  gap: 10px;
}
.tutorial-swatch {
  width: 16px;
  height: 16px;
  border-radius: 5px;
  flex: 0 0 auto;
}
.tutorial-swatch--active { background: #ffd54a; }
.tutorial-swatch--selected {
  background: #ffffff;
  box-shadow: inset 0 0 0 2px #182133;
}
.tutorial-swatch--move { background: #67de83; }
.tutorial-swatch--attack { background: #ff6b6b; }
.tutorial-swatch--heal { background: #61eaff; }
.tutorial-swatch--danger { background: #d44848; }
.tutorial-roll-guide {
  display: grid;
  gap: 10px;
}
.tutorial-roll-band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(18, 20, 32, 0.48);
  color: #d7dff1;
}
.tutorial-roll-band strong {
  color: #ffffff;
  font-size: 17px;
}
.tutorial-roll-band--fail { border-color: rgba(255, 179, 71, 0.42); }
.tutorial-roll-band--miss { border-color: rgba(255, 121, 121, 0.3); }
.tutorial-roll-band--hit { border-color: rgba(83, 215, 105, 0.35); }
.tutorial-roll-band--crit { border-color: rgba(255, 214, 74, 0.5); }
.tutorial-copy {
  margin: 0;
  color: #d7dff1;
  line-height: 1.55;
}
.tutorial-unit-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.tutorial-unit-card {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 12px;
  border-radius: 14px;
  background: rgba(18, 20, 32, 0.44);
  border: 1px solid rgba(255,255,255,0.07);
}
.tutorial-unit-card img {
  width: 88px;
  height: 88px;
  object-fit: cover;
  border-radius: 16px;
  justify-self: center;
}
.tutorial-unit-card h3 {
  margin: 0 0 6px;
  color: #fff1bf;
  font-size: 17px;
}
.tutorial-unit-card p {
  margin: 0;
  color: #d8dfee;
  font-size: 14px;
  line-height: 1.45;
}
.tutorial-terrain-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.tutorial-terrain-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-radius: 14px;
  background: rgba(18, 20, 32, 0.44);
  border: 1px solid rgba(255,255,255,0.07);
  text-align: center;
}
.tutorial-terrain-item img {
  max-width: 100%;
  max-height: 120px;
  object-fit: contain;
}
.tutorial-terrain-item span {
  color: #d8dfee;
  font-size: 14px;
  line-height: 1.45;
}
.tutorial-bullets {
  margin: 0;
  padding-left: 20px;
  color: #d8dfee;
  line-height: 1.6;
}
.tutorial-bullets li + li {
  margin-top: 8px;
}

@media (max-width: 700px) {
  #title-logo {
    width: min(420px, 82vw);
    margin: 108px 0 20px;
  }
  .subtitle {
    margin: 8px 0 28px;
  }
  .tutorial-shell {
    width: min(100vw - 22px, 1120px);
    padding: 18px 0 28px;
  }
  .tutorial-topbar {
    flex-direction: column;
    align-items: stretch;
  }
  .tutorial-grid,
  .tutorial-unit-grid,
  .tutorial-terrain-row {
    grid-template-columns: 1fr;
  }
  .tutorial-board-example {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-rows: repeat(3, minmax(0, 72px));
  }
}

/* Game Screen */
#game-screen {
  display: flex; flex-direction: column; height: 100%; position: relative;
}
#hud-top {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 16px;
  padding: 10px 24px; background: rgba(0,0,0,0.4); border-bottom: 1px solid #333;
  position: relative;
}
#turn-indicator { font-size: 20px; font-weight: bold; }
#round-counter { font-size: 14px; color: #888; text-align: right; }
#turn-indicator,
#round-counter {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#hud-settings { position: relative; justify-self: start; }
.hud-top-button {
  padding: 10px 14px;
  border: 1px solid var(--dice-gold-deep);
  border-radius: 8px;
  background: rgba(18, 20, 32, 0.5);
  color: var(--dice-gold-soft);
  font-size: 12px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.hud-top-button:hover {
  background: var(--dice-gold-bg);
  color: var(--dice-gold-bright);
  border-color: var(--dice-gold-soft);
}
#settings-panel {
  position: fixed;
  top: 64px;
  left: 24px;
  width: 390px;
  max-height: 78vh;
  padding: 16px;
  border: 1px solid #5d4a2b;
  border-radius: 12px;
  background: rgba(18, 20, 32, 0.97);
  box-shadow: 0 18px 40px rgba(0,0,0,0.35);
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 40;
}
#settings-panel h3 {
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: #d7c28c;
}
.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.settings-header button {
  padding: 8px 12px;
  border: 1px solid rgba(201, 130, 16, 0.72);
  border-radius: 8px;
  background: rgba(18, 20, 32, 0.36);
  color: #ead29a;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
}
.settings-header button:hover {
  background: var(--dice-gold-bg);
  color: var(--dice-gold-bright);
  border-color: var(--dice-gold-soft);
}
.settings-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.settings-tab-button {
  padding: 10px 12px;
  border: 1px solid rgba(201, 130, 16, 0.7);
  border-radius: 8px;
  background: rgba(18, 20, 32, 0.35);
  color: #e8d3a0;
  font-size: 11px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.settings-tab-button:hover {
  background: var(--dice-gold-bg);
  color: var(--dice-gold-bright);
  border-color: var(--dice-gold-soft);
}
.settings-tab-button.active {
  background: var(--dice-gold-bg-strong);
  color: var(--dice-gold-bright);
  border-color: var(--dice-gold-deep);
}
.settings-lock-panel {
  margin: 12px 0 14px;
  padding: 12px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  background: rgba(255,255,255,0.04);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.settings-lock-panel.unlocked {
  border-color: rgba(120, 205, 122, 0.4);
  background: rgba(120, 205, 122, 0.08);
}
.settings-lock-title {
  font-size: 13px;
  font-weight: 700;
  color: #f3f6ff;
}
.settings-lock-subtitle {
  font-size: 11px;
  line-height: 1.4;
  color: #9da9c5;
}
.settings-lock-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}
.settings-lock-controls input {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid #46506a;
  border-radius: 8px;
  background: rgba(0,0,0,0.26);
  color: #f3f6ff;
}
.settings-lock-controls button {
  padding: 9px 12px;
  border: 1px solid var(--dice-gold-deep);
  border-radius: 8px;
  background: var(--dice-gold-bg);
  color: var(--dice-gold-soft);
  cursor: pointer;
}
.settings-lock-controls button:disabled {
  opacity: 0.6;
  cursor: default;
}
.settings-lock-status {
  font-size: 11px;
  color: #f2dc8c;
}
.settings-view {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.settings-note {
  font-size: 12px;
  line-height: 1.45;
  color: #9aa3bb;
}
#settings-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 48vh;
  overflow-y: auto;
  padding-right: 4px;
}
.settings-section {
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  background: rgba(255,255,255,0.03);
  overflow: hidden;
}
.settings-section summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  cursor: pointer;
  list-style: none;
  color: #f2dc8c;
  font-size: 12px;
  letter-spacing: 1.6px;
  text-transform: uppercase;
}
.settings-section summary::-webkit-details-marker {
  display: none;
}
.settings-section summary::after {
  content: '+';
  font-size: 18px;
  line-height: 1;
  color: #fff4c6;
}
.settings-section[open] summary::after {
  content: '-';
}
.settings-section-meta {
  font-size: 10px;
  color: #9aa3bb;
  letter-spacing: 1.2px;
}
.settings-section-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 32vh;
  overflow-y: auto;
  padding: 0 10px 10px;
}
.settings-section-body::-webkit-scrollbar { width: 10px; }
.settings-section-body::-webkit-scrollbar-track {
  background: rgba(255,255,255,0.05);
  border-radius: 999px;
}
.settings-section-body::-webkit-scrollbar-thumb {
  background: rgba(192,163,95,0.55);
  border-radius: 999px;
}
.settings-section-body::-webkit-scrollbar-thumb:hover {
  background: rgba(224,192,117,0.8);
}
.settings-row {
  padding: 10px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  background: rgba(255,255,255,0.04);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.settings-row-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.settings-row-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: #f3f6ff;
}
.settings-row-subtitle {
  font-size: 11px;
  line-height: 1.35;
  color: #8f97af;
}
.settings-inputs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.settings-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.settings-field label {
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #aeb7cd;
}
.settings-field input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #46506a;
  border-radius: 8px;
  background: rgba(0,0,0,0.26);
  color: #f3f6ff;
}
.settings-field input:disabled,
.settings-lock-controls input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.settings-actions {
  display: flex;
  gap: 8px;
}
.settings-actions button {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--dice-gold-deep);
  border-radius: 8px;
  background: var(--dice-gold-bg);
  color: var(--dice-gold-soft);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.settings-actions button:hover {
  background: var(--dice-gold-bg-strong);
  color: var(--dice-gold-bright);
  border-color: var(--dice-gold-soft);
}
.settings-actions button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  background: rgba(255,255,255,0.04);
  color: #8f97af;
  border-color: #46506a;
}
.settings-actions button.secondary {
  border-color: rgba(201, 130, 16, 0.7);
  background: rgba(241, 180, 58, 0.08);
  color: #edd7a2;
}
.settings-actions button.secondary:hover {
  background: var(--dice-gold-bg-strong);
  border-color: var(--dice-gold-soft);
  color: var(--dice-gold-bright);
}
.sound-settings {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sound-row {
  padding: 12px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  background: rgba(255,255,255,0.04);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sound-row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.sound-row-title {
  font-size: 14px;
  font-weight: 600;
  color: #f3f6ff;
}
.sound-row-subtitle {
  font-size: 11px;
  color: #8f97af;
}
.sound-row-value {
  font-size: 12px;
  font-weight: 700;
  color: #f2dc8c;
}
.sound-slider {
  width: 100%;
  accent-color: #c0a35f;
}
#settings-form::-webkit-scrollbar { width: 10px; }
#settings-form::-webkit-scrollbar-track {
  background: rgba(255,255,255,0.05);
  border-radius: 999px;
}
#settings-form::-webkit-scrollbar-thumb {
  background: rgba(192,163,95,0.55);
  border-radius: 999px;
}
#settings-form::-webkit-scrollbar-thumb:hover {
  background: rgba(224,192,117,0.8);
}
#game-area {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 16px;
  padding: 12px;
}
#board-stage-area {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
canvas#grid {
  border: 2px solid #5d4a2b;
  border-radius: 6px;
  cursor: pointer;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28), 0 0 0 1px rgba(187, 152, 96, 0.18);
  background: linear-gradient(180deg, #7aa652 0%, #6b8f49 100%);
  touch-action: manipulation;
}
.side-panel {
  width: 180px; background: rgba(0,0,0,0.3); border-radius: 8px; padding: 12px;
  display: flex; flex-direction: column; gap: 8px; max-height: 100%; overflow-y: auto;
}
.collapsible-side-panel {
  width: 200px;
  height: 430px;
  max-height: 70vh;
  align-self: center;
  overflow: hidden;
  transition: width 0.2s ease, padding 0.2s ease;
}
.collapsible-side-panel.collapsed {
  width: 52px;
  padding: 10px 8px;
}
#panel-treasure.collapsed {
  display: none;
}
#panel-guide.collapsed {
  display: none;
}
#panel-rules.collapsed {
  display: none;
}
#panel-initiative:not(.collapsed) {
  width: 200px;
}
.history-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  flex: 1;
}
.collapsible-side-panel.collapsed .history-content {
  display: none;
}
.history-toggle {
  border: 1px solid rgba(201, 130, 16, 0.72);
  background: rgba(18, 20, 32, 0.42);
  color: #ead29a;
  border-radius: 8px;
  padding: 10px 8px;
  font-size: 12px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  cursor: pointer;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  align-self: stretch;
  min-height: 120px;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.history-toggle:hover {
  background: var(--dice-gold-bg);
  color: var(--dice-gold-bright);
  border-color: var(--dice-gold-soft);
}
.collapsible-side-panel:not(.collapsed) .history-toggle {
  writing-mode: horizontal-tb;
  text-orientation: initial;
  min-height: auto;
  width: 100%;
  padding: 10px 12px;
}
.side-panel h3 { font-size: 14px; text-transform: uppercase; letter-spacing: 2px; color: #888; border-bottom: 1px solid #333; padding-bottom: 6px; }
.roster-unit {
  padding: 8px; border-radius: 6px; background: rgba(255,255,255,0.05); font-size: 13px;
  display: flex; flex-direction: column; gap: 2px;
}
.roster-unit.hovered-target {
  transform: translateX(-2px);
}
.roster-unit.hovered-target.hovered-red {
  background: linear-gradient(180deg, rgba(255, 119, 150, 0.22) 0%, rgba(255,255,255,0.08) 100%);
  border: 1px solid rgba(255, 191, 208, 0.76);
  box-shadow: 0 0 16px rgba(233, 69, 96, 0.24);
}
.roster-unit.hovered-target.hovered-blue {
  background: linear-gradient(180deg, rgba(115, 195, 255, 0.2) 0%, rgba(255,255,255,0.08) 100%);
  border: 1px solid rgba(190, 229, 255, 0.76);
  box-shadow: 0 0 16px rgba(78, 168, 222, 0.22);
}
.roster-unit.hovered-target .unit-label {
  font-weight: 700;
}
.roster-unit.hovered-target .hp-bar {
  box-shadow: 0 0 12px rgba(255,255,255,0.12);
}
.roster-unit.hovered-target .hp-fill {
  filter: brightness(1.15);
}
.unit-label {
  display: flex;
  align-items: center;
  gap: 6px;
}
.unit-badge {
  width: 18px;
  height: 18px;
  object-fit: cover;
  border-radius: 4px;
  flex: 0 0 auto;
}
.unit-badge-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
}
.roster-unit.dead { opacity: 0.3; text-decoration: line-through; }
.roster-unit .hp-bar { height: 4px; border-radius: 2px; background: #333; overflow: hidden; }
.roster-unit .hp-fill { height: 100%; border-radius: 2px; transition: width 0.3s; }
.roster-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.roster-hp-text {
  font-size: 11px;
  color: #777;
}
.roster-status-list {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.status-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: 0.2px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.08);
  color: #dce3f5;
}
.status-chip.debuff {
  background: rgba(233, 69, 96, 0.16);
  border-color: rgba(255, 152, 170, 0.45);
  color: #ffd7df;
}
.status-chip.buff {
  background: rgba(83, 215, 105, 0.14);
  border-color: rgba(150, 244, 166, 0.4);
  color: #d7ffe0;
}
.status-chip.neutral {
  background: rgba(113, 148, 224, 0.14);
  border-color: rgba(173, 199, 255, 0.38);
  color: #deebff;
}
#unit-guide,
#rules-guide,
#treasure-guide {
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  min-height: 0;
  flex: 1;
  padding-right: 6px;
  scrollbar-width: thin;
  scrollbar-color: #5f6d9c rgba(255,255,255,0.05);
  overscroll-behavior: contain;
}
#panel-guide {
  width: 290px;
}
#panel-treasure {
  width: 290px;
}
#panel-rules {
  width: 290px;
}
.collapsible-side-panel #unit-guide::-webkit-scrollbar,
.collapsible-side-panel #rules-guide::-webkit-scrollbar,
.collapsible-side-panel #treasure-guide::-webkit-scrollbar {
  width: 10px;
}
.collapsible-side-panel #unit-guide::-webkit-scrollbar-track,
.collapsible-side-panel #rules-guide::-webkit-scrollbar-track,
.collapsible-side-panel #treasure-guide::-webkit-scrollbar-track {
  background: rgba(255,255,255,0.05);
  border-radius: 999px;
}
.collapsible-side-panel #unit-guide::-webkit-scrollbar-thumb,
.collapsible-side-panel #rules-guide::-webkit-scrollbar-thumb,
.collapsible-side-panel #treasure-guide::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #6d7fb8 0%, #495b8f 100%);
  border-radius: 999px;
  border: 2px solid rgba(12, 16, 29, 0.95);
}
.collapsible-side-panel #unit-guide::-webkit-scrollbar-thumb:hover,
.collapsible-side-panel #rules-guide::-webkit-scrollbar-thumb:hover,
.collapsible-side-panel #treasure-guide::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #8194cf 0%, #5a6ea6 100%);
}
.guide-entry {
  border-radius: 6px;
  background: rgba(255,255,255,0.05);
  color: #cfd6e6;
  font-size: 12px;
  line-height: 1.35;
  overflow: hidden;
}
.guide-entry summary {
  list-style: none;
  cursor: pointer;
  padding: 8px 10px;
  color: #ffffff;
  font-weight: 700;
  letter-spacing: 0.3px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.guide-entry summary::-webkit-details-marker {
  display: none;
}
.guide-entry summary::after {
  content: '+';
  color: #8ea3d8;
  font-size: 15px;
  line-height: 1;
}
.guide-entry[open] summary {
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.guide-entry[open] summary::after {
  content: '-';
}
.guide-entry-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 10px 10px;
  min-height: 110px;
  max-height: 220px;
  overflow-y: scroll;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: #5f6d9c rgba(255,255,255,0.05);
}
.guide-entry-body::-webkit-scrollbar {
  width: 8px;
}
.guide-entry-body::-webkit-scrollbar-track {
  background: rgba(255,255,255,0.05);
  border-radius: 999px;
}
.guide-entry-body::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #6d7fb8 0%, #495b8f 100%);
  border-radius: 999px;
  border: 1px solid rgba(12, 16, 29, 0.95);
}
.guide-entry-body::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #8194cf 0%, #5a6ea6 100%);
}
.guide-row {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 8px;
  align-items: start;
}
.guide-key {
  color: #ffffff;
  font-weight: 700;
}
.guide-value {
  color: #cfd6e6;
}
.guide-entry strong {
  color: #ffffff;
}
.guide-team-selector {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.guide-team-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 10px 10px;
  border: 1px solid rgba(234, 210, 154, 0.28);
  border-radius: 10px;
  background: rgba(255,255,255,0.04);
  color: #d6dceb;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: transform 0.16s ease, background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}
.guide-team-button:hover {
  transform: translateY(-1px);
  background: rgba(201, 130, 16, 0.14);
  border-color: rgba(234, 210, 154, 0.82);
  color: #fff1bf;
}
.guide-team-button.active {
  background: linear-gradient(180deg, rgba(241, 180, 58, 0.22) 0%, rgba(201, 130, 16, 0.18) 100%);
  border-color: var(--dice-gold-soft);
  color: #fff1bf;
  box-shadow: 0 8px 18px rgba(201, 130, 16, 0.18);
}
.guide-team-prompt-card {
  align-items: center;
  justify-content: center;
  min-height: 160px;
  text-align: center;
}
.unit-guide-selector {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.unit-guide-button {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  width: 100%;
  padding: 10px 10px;
  border: 1px solid rgba(201, 130, 16, 0.64);
  border-radius: 10px;
  background: rgba(255,255,255,0.04);
  color: #ead29a;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
  text-align: left;
  cursor: pointer;
  transition: transform 0.18s ease, background 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}
.unit-guide-button .unit-badge,
.unit-guide-button .unit-badge-fallback {
  width: 22px;
  height: 22px;
  border-radius: 6px;
}
.unit-guide-button:hover {
  transform: translateY(-1px);
  background: rgba(201, 130, 16, 0.14);
  border-color: rgba(234, 210, 154, 0.82);
  color: #fff1bf;
}
.unit-guide-button.active {
  background: linear-gradient(180deg, rgba(241, 180, 58, 0.22) 0%, rgba(201, 130, 16, 0.18) 100%);
  border-color: var(--dice-gold-soft);
  color: #fff1bf;
  box-shadow: 0 8px 18px rgba(201, 130, 16, 0.18);
}
.unit-info-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(255,255,255,0.06) 0%, rgba(255,255,255,0.03) 100%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
}
.unit-card-portrait-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 180px;
  padding: 12px;
  border-radius: 12px;
  background:
    radial-gradient(circle at top, rgba(241, 180, 58, 0.18) 0%, rgba(18, 20, 32, 0) 58%),
    linear-gradient(180deg, rgba(18, 20, 32, 0.7) 0%, rgba(18, 20, 32, 0.42) 100%);
}
.unit-card-portrait-image {
  max-width: 100%;
  max-height: 190px;
  object-fit: contain;
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.34));
}
.unit-card-portrait-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 140px;
  height: 140px;
  font-size: 76px;
}
.unit-card-title {
  color: #ffffff;
  font-size: 18px;
  font-weight: 800;
  line-height: 1.15;
}
.unit-card-role {
  color: #f0cd7f;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.4px;
}
.unit-card-section {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.unit-card-section-title {
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.4px;
}
.unit-card-copy {
  color: #cfd6e6;
  font-size: 12px;
  line-height: 1.45;
}
.unit-card-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.unit-card-stat {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 8px 9px;
  border-radius: 8px;
  background: rgba(255,255,255,0.05);
}
.unit-card-stat-label {
  color: #f1ddb2;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.unit-card-stat-value {
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
}
.treasure-info-card {
  min-height: 100%;
}
.treasure-placeholder-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 180px;
  padding: 12px;
  border-radius: 12px;
  background:
    radial-gradient(circle at top, rgba(241, 180, 58, 0.18) 0%, rgba(18, 20, 32, 0) 60%),
    linear-gradient(180deg, rgba(18, 20, 32, 0.72) 0%, rgba(18, 20, 32, 0.42) 100%);
}
.treasure-art-image {
  max-width: 100%;
  max-height: 194px;
  object-fit: contain;
  filter: drop-shadow(0 12px 20px rgba(0, 0, 0, 0.34));
}
.treasure-placeholder {
  --treasure-accent: #d1b56a;
  width: 166px;
  height: 166px;
  border-radius: 24px;
  border: 2px solid color-mix(in srgb, var(--treasure-accent) 58%, white 16%);
  background:
    radial-gradient(circle at 30% 24%, rgba(255,255,255,0.18) 0%, transparent 30%),
    linear-gradient(160deg, color-mix(in srgb, var(--treasure-accent) 34%, rgba(18, 20, 32, 0.96)) 0%, rgba(18, 20, 32, 0.96) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.1),
    0 16px 26px rgba(0, 0, 0, 0.25),
    0 0 26px color-mix(in srgb, var(--treasure-accent) 18%, transparent);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.treasure-placeholder-mark {
  color: #ffffff;
  font-size: 52px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: 3px;
  text-shadow: 0 4px 10px rgba(0, 0, 0, 0.28);
}
.treasure-placeholder-label {
  color: #eadfbe;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.8px;
}
.rules-info-card {
  min-height: 100%;
}
#history-log,
#initiative-log {
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  min-height: 0;
  flex: 1;
  padding-right: 6px;
  scrollbar-width: thin;
  scrollbar-color: #5f6d9c rgba(255,255,255,0.05);
  overscroll-behavior: contain;
}
.collapsible-side-panel #history-log::-webkit-scrollbar,
.collapsible-side-panel #initiative-log::-webkit-scrollbar {
  width: 10px;
}
.collapsible-side-panel #history-log::-webkit-scrollbar-track,
.collapsible-side-panel #initiative-log::-webkit-scrollbar-track {
  background: rgba(255,255,255,0.05);
  border-radius: 999px;
}
.collapsible-side-panel #history-log::-webkit-scrollbar-thumb,
.collapsible-side-panel #initiative-log::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #6d7fb8 0%, #495b8f 100%);
  border-radius: 999px;
  border: 2px solid rgba(12, 16, 29, 0.95);
}
.collapsible-side-panel #history-log::-webkit-scrollbar-thumb:hover,
.collapsible-side-panel #initiative-log::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #8194cf 0%, #5a6ea6 100%);
}
.history-entry {
  padding: 7px 8px;
  border-radius: 6px;
  background: rgba(255,255,255,0.05);
  color: #cfd6e6;
  font-size: 12px;
  line-height: 1.35;
}
.initiative-entry {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 8px 9px;
  border-radius: 8px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.05);
  color: #dbe4f6;
  font-size: 12px;
}
.initiative-entry.active {
  background: rgba(241, 180, 58, 0.14);
  border-color: rgba(241, 180, 58, 0.45);
  box-shadow: 0 10px 20px rgba(201, 130, 16, 0.16);
}
.initiative-entry.defeated {
  opacity: 0.52;
}
.initiative-entry.boss-slot {
  border-color: rgba(78, 168, 222, 0.3);
  background: rgba(78, 168, 222, 0.08);
}
.initiative-rank {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: #0d1220;
  background: linear-gradient(180deg, #f6cf73 0%, #d1961b 100%);
}
.initiative-entry.boss-slot .initiative-rank {
  background: linear-gradient(180deg, #82c6ff 0%, #4b91d8 100%);
}
.initiative-main {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.initiative-name {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-weight: 700;
  min-width: 0;
}
.initiative-name .unit-badge,
.initiative-name .unit-badge-fallback {
  width: 30px;
  height: 30px;
  border-radius: 8px;
}
.initiative-roll {
  justify-self: end;
  min-width: 44px;
  padding: 4px 7px;
  border-radius: 999px;
  text-align: center;
  color: #fff1bf;
  background: rgba(201, 130, 16, 0.18);
  border: 1px solid rgba(241, 180, 58, 0.26);
  font-weight: 800;
}
.initiative-entry.defeated .initiative-name-text,
.initiative-entry.defeated .initiative-roll {
  text-decoration: line-through;
}
.initiative-empty {
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(255,255,255,0.05);
  color: #aeb9d2;
  font-size: 12px;
  line-height: 1.45;
}
#hud-bottom {
  display: flex; align-items: center; justify-content: center;
  padding: 7px 18px; background: rgba(0,0,0,0.4); border-top: 1px solid #333;
}
#hud-bottom-center {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  width: 100%;
}
.hud-panel-toggle {
  min-width: 96px;
  white-space: nowrap;
}
#unit-info {
  flex: 0 1 auto;
  min-width: 280px;
  max-width: 560px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 12.5px;
  padding: 7px 10px;
  border: 1px solid rgba(255, 215, 0, 0.3);
  border-radius: 8px;
  background: rgba(255, 215, 0, 0.08);
  color: #fff4b3;
  box-shadow: 0 0 12px rgba(255, 215, 0, 0.08);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#unit-info .unit-badge,
#unit-info .unit-badge-fallback {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  vertical-align: text-bottom;
}
#unit-info .turn-flow-prefix {
  color: #ffd96c;
  font-weight: 700;
}
#unit-info .turn-flow-unit {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #fff7d6;
  font-weight: 700;
}
#unit-info .turn-flow-sep {
  color: rgba(255, 233, 156, 0.72);
}
#unit-info .turn-flow-action {
  color: #fff2b2;
  font-weight: 600;
  transition: opacity 0.18s ease, color 0.18s ease;
}
#unit-info .turn-flow-action.done {
  color: rgba(217, 195, 126, 0.72);
  text-decoration: line-through;
  text-decoration-thickness: 1.5px;
  opacity: 0.8;
}
#unit-info .turn-flow-status {
  color: #ffd87f;
  font-weight: 700;
}
#action-log { display: none; }
.hud-buttons { display: flex; gap: 6px; flex: 0 0 auto; }
.hud-buttons button {
  padding: 9px 16px;
  font-size: 14px;
}
.hud-buttons button:disabled { opacity: 0.3; cursor: default; pointer-events: none; }
#choice-actions {
  position: absolute;
  left: 0;
  top: 66%;
  transform: translateY(-50%);
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  z-index: 45;
  box-sizing: border-box;
  width: 100%;
}
.choice-button {
  min-width: 210px;
  padding: 14px 18px;
  border: 2px solid var(--dice-gold-deep);
  border-radius: 12px;
  background: rgba(20, 24, 38, 0.92);
  color: var(--dice-gold-soft);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.4px;
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(0,0,0,0.28);
  transition: transform 0.15s ease, background 0.2s ease, color 0.2s ease;
}
.choice-button:hover {
  background: linear-gradient(180deg, rgba(241, 180, 58, 0.92) 0%, rgba(201, 130, 16, 0.96) 100%);
  color: #241606;
  transform: translateY(-1px);
}
#stage-summary-ultimates {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 14px);
  transform: translateX(-50%);
  width: min(700px, calc(100vw - 96px));
  max-height: 220px;
  overflow-y: auto;
  padding: 16px 18px;
  border: 2px solid rgba(241, 180, 58, 0.7);
  border-radius: 16px;
  background: rgba(12, 16, 26, 0.94);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(6px);
}
#stage-summary-ultimates::-webkit-scrollbar {
  width: 10px;
}
#stage-summary-ultimates::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.06);
  border-radius: 999px;
}
#stage-summary-ultimates::-webkit-scrollbar-thumb {
  background: rgba(241, 180, 58, 0.7);
  border-radius: 999px;
}
.stage-summary-ultimates-title {
  margin: 0 0 10px;
  color: var(--dice-gold-soft);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-align: center;
}
.stage-summary-ultimates-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.stage-summary-ultimates-section {
  padding: 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.stage-summary-ultimates-section h4 {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.stage-summary-ultimates-section--active h4 {
  color: #8af5ff;
}
.stage-summary-ultimates-section--lost h4 {
  color: #ffb3a7;
}
.stage-summary-ultimates-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.stage-summary-ultimates-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stage-summary-ultimates-name {
  color: #f5f7ff;
  font-size: 14px;
  font-weight: 700;
}
.stage-summary-ultimates-effect {
  color: #d6dceb;
  font-size: 13px;
  line-height: 1.35;
}
.stage-summary-ultimates-empty {
  color: #c7cfdf;
  font-size: 13px;
  line-height: 1.35;
}
.result-stats-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.result-stats-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.result-stats-name {
  color: #f5f7ff;
  font-size: 14px;
  font-weight: 700;
}
.result-stats-values {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  color: #d6dceb;
  font-size: 13px;
  line-height: 1.35;
}
.result-stats-values strong {
  color: #fff1bf;
}
#mobile-hub-overlay {
  position: fixed;
  inset: 0;
  z-index: 85;
  padding: 14px;
  background: rgba(8, 12, 20, 0.72);
  backdrop-filter: blur(8px);
}
#mobile-hub-card {
  width: min(760px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  margin: 0 auto;
  border-radius: 18px;
  border: 1px solid rgba(241, 180, 58, 0.32);
  background:
    radial-gradient(circle at top right, rgba(241, 180, 58, 0.12) 0%, transparent 34%),
    linear-gradient(180deg, rgba(18, 20, 32, 0.97) 0%, rgba(15, 19, 31, 0.98) 100%);
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.38);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.mobile-hub-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.mobile-hub-kicker {
  color: #f2dc8c;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.mobile-hub-title {
  color: #ffffff;
  font-size: 24px;
  font-weight: 800;
  line-height: 1.05;
}
#mobile-hub-nav {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 12px 16px 10px;
  scrollbar-width: thin;
  scrollbar-color: rgba(241, 180, 58, 0.6) rgba(255,255,255,0.05);
}
#mobile-hub-nav::-webkit-scrollbar {
  height: 10px;
}
#mobile-hub-nav::-webkit-scrollbar-track {
  background: rgba(255,255,255,0.05);
  border-radius: 999px;
}
#mobile-hub-nav::-webkit-scrollbar-thumb {
  background: rgba(241, 180, 58, 0.62);
  border-radius: 999px;
}
.mobile-hub-nav-button {
  flex: 0 0 auto;
  min-width: max-content;
  padding: 9px 12px;
  border: 1px solid rgba(201, 130, 16, 0.72);
  border-radius: 999px;
  background: rgba(18, 20, 32, 0.36);
  color: #ead29a;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1;
  white-space: nowrap;
  text-transform: uppercase;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.mobile-hub-nav-button.active {
  background: linear-gradient(180deg, rgba(241, 180, 58, 0.92) 0%, rgba(201, 130, 16, 0.96) 100%);
  color: #241606;
  border-color: var(--dice-gold-soft);
}
#mobile-hub-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 16px 16px;
  scrollbar-width: thin;
  scrollbar-color: rgba(241, 180, 58, 0.6) rgba(255,255,255,0.05);
}
#mobile-hub-content::-webkit-scrollbar {
  width: 12px;
}
#mobile-hub-content::-webkit-scrollbar-track {
  background: rgba(255,255,255,0.05);
  border-radius: 999px;
}
#mobile-hub-content::-webkit-scrollbar-thumb {
  background: rgba(241, 180, 58, 0.62);
  border-radius: 999px;
  border: 2px solid rgba(12, 16, 29, 0.95);
}
.mobile-hub-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.mobile-hub-panel-title {
  color: #fff4c6;
  font-size: 20px;
  font-weight: 800;
  line-height: 1.15;
}
.mobile-hub-panel-subtitle {
  color: #c7d0e6;
  font-size: 14px;
  line-height: 1.5;
}
.mobile-hub-panel-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.mobile-hub-footer {
  display: flex;
  gap: 10px;
  padding: 12px 16px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.mobile-hub-footer button,
#btn-mobile-hub-close {
  min-height: 46px;
}
.mobile-overview-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.mobile-overview-card,
.mobile-overview-roster-card,
.mobile-overview-turn-flow {
  padding: 12px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.04);
}
.mobile-overview-card-label,
.mobile-overview-section-title {
  color: #f1ddb2;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.mobile-overview-card-value {
  color: #ffffff;
  font-size: 22px;
  font-weight: 800;
  margin-top: 4px;
}
.mobile-overview-turn-copy,
.mobile-overview-turn-note,
.mobile-overview-empty {
  color: #dbe4f5;
  font-size: 13px;
  line-height: 1.5;
}
.mobile-overview-turn-note {
  margin-top: 8px;
}
.mobile-overview-rosters {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
.mobile-overview-roster-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.mobile-overview-roster-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 10px;
  border-radius: 10px;
  background: rgba(255,255,255,0.04);
}
.mobile-overview-roster-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.mobile-overview-roster-name {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #f7faff;
  font-size: 13px;
  font-weight: 700;
}
.mobile-overview-roster-hp {
  color: #c6d0e7;
  font-size: 12px;
  font-weight: 600;
}
.mobile-overview-roster-statuses {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
@media (max-width: 900px) {
  #stage-summary-ultimates {
    width: min(560px, calc(100vw - 48px));
    max-height: 180px;
  }
  .stage-summary-ultimates-grid {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 980px) {
  #hud-top {
    grid-template-columns: 1fr auto;
    gap: 10px;
    padding: 8px 12px;
  }
  #hud-settings,
  #panel-left,
  #panel-right,
  #panel-history,
  #panel-initiative,
  #panel-guide,
  #panel-treasure,
  #panel-rules,
  #btn-treasure-panel-toggle,
  #btn-guide-toggle,
  #btn-rules-toggle {
    display: none !important;
  }
  #turn-indicator {
    font-size: 16px;
  }
  #round-counter {
    font-size: 12px;
  }
  #game-area {
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    padding: 8px 10px 6px;
  }
  #board-stage-area {
    width: 100%;
  }
  canvas#grid {
    max-width: min(96vw, 96vh);
    max-height: calc(100vh - 230px);
  }
  #hud-bottom {
    padding: 8px 10px calc(env(safe-area-inset-bottom, 0px) + 8px);
  }
  #hud-bottom-center {
    gap: 8px;
  }
  #unit-info {
    order: 1;
    width: 100%;
    min-width: 0;
    max-width: none;
    white-space: normal;
    text-align: center;
    font-size: 13px;
    line-height: 1.4;
    padding: 9px 12px;
  }
  .hud-buttons {
    width: 100%;
    justify-content: stretch;
    gap: 8px;
  }
  .hud-buttons button {
    flex: 1 1 0;
    min-height: 46px;
    padding: 11px 12px;
    font-size: 15px;
  }
  #choice-actions {
    top: 72%;
    gap: 10px;
    padding: 0 10px;
  }
  .choice-button {
    min-width: 0;
    width: min(92vw, 320px);
  }
  #stage-summary-ultimates {
    width: min(92vw, 620px);
    max-height: 42vh;
    bottom: calc(100% + 10px);
  }
  #settings-panel {
    top: 10px;
    left: 10px;
    right: 10px;
    width: auto;
    max-height: calc(100vh - 20px);
    z-index: 90;
  }
  #mobile-hub-card {
    width: calc(100vw - 28px);
    max-height: calc(100vh - 28px);
  }
}
@media (max-width: 980px) and (orientation: landscape) {
  #hud-top {
    grid-template-columns: auto 1fr auto;
    gap: 8px;
    padding: 6px 10px;
  }
  #turn-indicator {
    font-size: 13px;
  }
  #round-counter {
    font-size: 11px;
  }
  .hud-top-button {
    padding: 8px 10px;
    font-size: 10px;
  }
  #game-area {
    padding: 6px 10px 4px;
  }
  canvas#grid {
    max-width: min(92vw, 92vh);
    max-height: calc(100vh - 132px);
  }
  #hud-bottom {
    padding: 6px 8px calc(env(safe-area-inset-bottom, 0px) + 6px);
  }
  #hud-bottom-center {
    gap: 6px;
    flex-wrap: nowrap;
  }
  #unit-info {
    order: 0;
    width: auto;
    min-width: 0;
    max-width: none;
    flex: 1 1 auto;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 11px;
    line-height: 1.25;
    padding: 6px 10px;
  }
  .hud-buttons {
    width: auto;
    flex: 0 0 auto;
    justify-content: flex-end;
  }
  .hud-buttons button {
    min-height: 38px;
    padding: 8px 10px;
    font-size: 13px;
  }
  #choice-actions {
    top: 68%;
  }
  .mobile-hub-header {
    padding: 12px 14px 10px;
  }
  .mobile-hub-title {
    font-size: 20px;
  }
  #mobile-hub-nav {
    gap: 6px;
    padding: 10px 12px 8px;
  }
  .mobile-hub-nav-button {
    padding: 8px 10px;
    font-size: 10px;
  }
  #mobile-hub-content {
    padding: 0 12px 12px;
  }
}
#btn-play-again {
  border-color: var(--dice-gold-deep);
  color: var(--dice-gold-soft);
}
#btn-play-again:hover {
  background: linear-gradient(180deg, rgba(241, 180, 58, 0.92) 0%, rgba(201, 130, 16, 0.96) 100%);
  color: #241606;
}
