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

:root {
  --bg: #04050a;
  --panel: #0a0e16;
  --cyan: #2ee8ff;
  --violet: #b56dff;
  --gold: #ffd76a;
  --mint: #6dffcf;
  --text: #e8f2ff;
  --muted: #8fa2be;
  --danger: #ff5c52;
  --v: 20261120-g2;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif;
  overflow-x: hidden;
}

body {
  background:
    radial-gradient(ellipse 110% 70% at 50% -5%, rgba(46, 232, 255, 0.08), transparent 55%),
    radial-gradient(ellipse 70% 50% at 100% 30%, rgba(181, 109, 255, 0.07), transparent 45%),
    var(--bg);
}

.shell {
  width: min(100%, 430px);
  margin: 0 auto;
  padding: 0.55rem 0.75rem calc(0.65rem + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  min-height: 100svh;
}

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.back {
  color: var(--mint);
  text-decoration: none;
  font-size: 0.82rem;
}

.brand {
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.08em;
}

.brand strong {
  display: block;
  color: var(--text);
  font-size: 0.88rem;
}

.ghost-button,
.btn-primary {
  border-radius: 10px;
  border: 1px solid rgba(109, 255, 207, 0.35);
  background: rgba(12, 18, 28, 0.85);
  color: var(--text);
  font-size: 0.82rem;
  padding: 0.45rem 0.75rem;
  cursor: pointer;
}

.btn-primary {
  background: linear-gradient(135deg, rgba(46, 232, 255, 0.22), rgba(181, 109, 255, 0.2));
  border-color: rgba(46, 232, 255, 0.55);
  font-size: 0.95rem;
  padding: 0.65rem 1rem;
  width: 100%;
}

.play-intro h1 {
  font-size: 1.35rem;
  margin: 0.2rem 0 0.5rem;
  letter-spacing: 0.02em;
}

.play-intro h1 span {
  display: block;
  font-size: 1.05rem;
  color: var(--cyan);
}

.kicker,
.lead {
  font-size: 0.82rem;
  color: var(--muted);
}

.rule-list {
  margin: 0.5rem 0 1rem;
  padding: 0.75rem 0.85rem;
  border-radius: 12px;
  background: rgba(12, 16, 26, 0.9);
  border: 1px solid rgba(46, 232, 255, 0.15);
  list-style: none;
}

.rule-list--primary li {
  margin: 0.35rem 0;
  font-size: 0.92rem;
  line-height: 1.45;
}

.hud {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.35rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.hud strong {
  display: block;
  color: var(--cyan);
  font-size: 1rem;
}

.console {
  display: flex;
  flex-direction: column;
  gap: 0.42rem;
  padding: 0.5rem 0.55rem 0.62rem;
  border-radius: 16px;
  border: 1px solid rgba(46, 232, 255, 0.14);
  background:
    linear-gradient(165deg, rgba(14, 20, 32, 0.94), rgba(8, 12, 22, 0.98)),
    repeating-linear-gradient(
      0deg,
      rgba(46, 232, 255, 0.04) 0,
      rgba(46, 232, 255, 0.04) 1px,
      transparent 1px,
      transparent 18px
    ),
    repeating-linear-gradient(
      90deg,
      rgba(181, 109, 255, 0.035) 0,
      rgba(181, 109, 255, 0.035) 1px,
      transparent 1px,
      transparent 22px
    );
  box-shadow: inset 0 -24px 40px rgba(46, 232, 255, 0.04);
}

.console::after {
  content: "";
  pointer-events: none;
  position: absolute;
  inset: auto 0 0;
  height: 120px;
  border-radius: 0 0 16px 16px;
  background: linear-gradient(0deg, rgba(255, 215, 106, 0.06), transparent 85%);
  opacity: 0.9;
}

.console {
  position: relative;
}

.city-glow {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 38%;
  pointer-events: none;
  border-radius: 0 0 14px 14px;
  background:
    radial-gradient(ellipse 80% 55% at 18% 100%, rgba(46, 232, 255, 0.12), transparent 70%),
    radial-gradient(ellipse 70% 50% at 82% 100%, rgba(181, 109, 255, 0.1), transparent 72%);
  opacity: 0.85;
}

.live-route {
  padding: 0.55rem 0.65rem 0.5rem;
  border-radius: 12px;
  background: rgba(6, 10, 18, 0.88);
  border: 1px solid rgba(46, 232, 255, 0.22);
  box-shadow: 0 0 22px rgba(46, 232, 255, 0.06);
}

.live-route-kicker {
  margin: 0 0 0.35rem;
  font-size: 0.62rem;
  letter-spacing: 0.2em;
  color: var(--mint);
}

.live-route-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.35rem 0.65rem;
  margin: 0;
}

.live-cell {
  margin: 0;
}

.live-cell dt {
  margin: 0;
  font-size: 0.68rem;
  color: var(--muted);
  letter-spacing: 0.06em;
}

.live-cell dd {
  margin: 0.1rem 0 0;
  font-size: 1.12rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.live-cell--next dd {
  font-size: 1.55rem;
  color: var(--cyan);
  text-shadow: 0 0 12px rgba(46, 232, 255, 0.35);
}

.live-cell--wide {
  grid-column: 1 / -1;
}

.live-cell--wide dd {
  font-size: 1.05rem;
  color: var(--gold);
}

.live-hint {
  margin: 0.35rem 0 0;
  font-size: 0.82rem;
  color: var(--mint);
}

.live-route.is-active .live-hint {
  display: none;
}

.canvas-wrap {
  position: relative;
  width: 100%;
  max-width: 390px;
  margin: 0 auto;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(46, 232, 255, 0.18);
  box-shadow: 0 0 28px rgba(46, 232, 255, 0.08);
}

#game-canvas {
  display: block;
  width: 100%;
  height: auto;
  touch-action: none;
  background: #060810;
}

.board-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  list-style: none;
  margin: 0.25rem 0;
  padding: 0;
  font-size: 0.72rem;
  color: var(--muted);
}

.board-legend .swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 0.25rem;
  vertical-align: middle;
}

.leg-start .swatch {
  background: var(--cyan);
  box-shadow: 0 0 8px var(--cyan);
}

.leg-beacon .swatch {
  background: var(--violet);
}

.leg-end .swatch {
  background: var(--gold);
}

.leg-hazard .swatch {
  background: var(--danger);
  border-radius: 2px;
}

.actions-row {
  display: flex;
  gap: 0.5rem;
}

.operator {
  display: flex;
  gap: 0.55rem;
  align-items: flex-start;
  padding: 0.55rem 0.65rem;
  border-radius: 12px;
  background: rgba(8, 12, 20, 0.92);
  border: 1px solid rgba(109, 255, 207, 0.12);
  order: 10;
  margin-top: 0.05rem;
}

.op-icon {
  flex-shrink: 0;
  filter: drop-shadow(0 0 6px rgba(46, 232, 255, 0.35));
}

.op-label {
  margin: 0;
  font-size: 0.65rem;
  color: var(--mint);
  letter-spacing: 0.12em;
}

.op-msg {
  margin: 0.15rem 0 0;
  font-size: 0.85rem;
}

.fail-toast {
  position: fixed;
  left: 50%;
  bottom: calc(1.2rem + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: rgba(255, 92, 82, 0.92);
  color: #fff;
  padding: 0.55rem 0.85rem;
  border-radius: 10px;
  font-size: 0.88rem;
  max-width: min(92vw, 360px);
  text-align: center;
  z-index: 30;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.summary h2 {
  font-size: 1.1rem;
  margin: 0.25rem 0;
}

.sum-rank {
  font-size: 1.5rem;
  color: var(--gold);
  margin: 0.25rem 0 0.5rem;
}

#map-canvas {
  width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(181, 109, 255, 0.25);
  margin-bottom: 0.5rem;
}

#sum-stats {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0;
  font-size: 0.85rem;
  color: var(--muted);
}

#sum-stats li {
  margin: 0.25rem 0;
}

.summary-actions {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.records {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.5rem;
}

html[data-capture="1"] .capture-hide,
html[data-promo-shot="1"] .capture-hide,
html[data-promo-og="1"] .capture-hide {
  display: none !important;
}

#promo-canvas {
  display: none;
}

@media (max-height: 700px) and (max-width: 400px) {
  .shell {
    overflow-y: auto;
    overflow-x: hidden;
    max-height: 100svh;
  }

  .console {
    flex-shrink: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}