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

:root {
  --bg: #06080f;
  --panel: #0c1018;
  --cyan: #2ee8ff;
  --magenta: #ff4de8;
  --gold: #ffd76a;
  --text: #e8f4ff;
  --muted: #8fa2be;
  --danger: #ff5c52;
  --v: 20261122-g9;
}

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 100% 55% at 50% 0%, rgba(46, 232, 255, 0.07), transparent 58%),
    radial-gradient(ellipse 70% 40% at 100% 25%, rgba(255, 77, 232, 0.06), transparent 50%),
    var(--bg);
}

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

html[data-promo-shot="1"] body {
  min-height: 100svh;
  background:
    radial-gradient(ellipse 90% 45% at 50% 0%, rgba(46, 232, 255, 0.12), transparent 55%),
    linear-gradient(180deg, #0a1018 0%, #1a2838 52%, #243448 100%);
}

html[data-promo-shot="1"] .shell {
  min-height: 100svh;
  max-width: 390px;
  display: flex;
  flex-direction: column;
  padding: 0.3rem 0.45rem 0.55rem;
  gap: 0.2rem;
}

html[data-promo-shot="1"] #console {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  gap: 0.22rem;
}

.promo-shot-head {
  display: none;
  text-align: center;
  padding: 0.2rem 0.35rem 0.15rem;
  border-radius: 6px;
  background: rgba(8, 12, 20, 0.88);
  border: 1px solid rgba(46, 232, 255, 0.28);
  font-size: 0.62rem;
  letter-spacing: 0.05em;
}

.promo-shot-head strong {
  display: block;
  color: var(--cyan);
  font-size: 0.82rem;
  letter-spacing: 0.07em;
}

.promo-shot-head span {
  color: var(--muted);
  font-size: 0.58rem;
}

html[data-promo-shot="1"] .promo-shot-head {
  display: block;
}

html[data-promo-shot="1"] .hud {
  margin-bottom: 0.15rem;
}

html[data-promo-shot="1"] .objective-strip {
  margin-bottom: 0.22rem;
  font-size: 0.68rem;
  padding: 0.32rem 0.55rem;
}

html[data-promo-shot="1"] .canvas-wrap {
  flex: 1 1 auto;
  max-width: none;
  width: 100%;
  overflow: visible;
  border-color: rgba(46, 232, 255, 0.32);
  box-shadow:
    0 0 0 1px rgba(255, 77, 232, 0.12),
    0 12px 36px rgba(0, 0, 0, 0.55),
    0 0 48px rgba(46, 232, 255, 0.08);
}

html[data-promo-shot="1"] #game-canvas {
  width: 100%;
  height: auto;
  max-height: min(62svh, 500px);
}

.promo-shot-foot {
  display: none;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.35rem 0.55rem;
  padding: 0.38rem 0.5rem;
  border-radius: 8px;
  background: rgba(8, 12, 20, 0.9);
  border: 1px solid rgba(255, 215, 106, 0.28);
  font-size: 0.58rem;
  color: var(--muted);
}

.promo-shot-foot .psf-label {
  color: var(--gold);
  font-weight: 700;
  letter-spacing: 0.08em;
  width: 100%;
  text-align: center;
}

.psf-glyph {
  display: inline-block;
  width: 28px;
  height: 40px;
  position: relative;
}

.psf-fork::before,
.psf-crown::before,
.psf-ring::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 3px;
}

.psf-fork::before {
  border: 2px solid var(--cyan);
  background: rgba(46, 232, 255, 0.15);
  clip-path: polygon(50% 0%, 25% 35%, 10% 100%, 35% 65%, 50% 88%, 65% 65%, 90% 100%, 75% 35%);
}

.psf-crown::before {
  border: 2px solid var(--magenta);
  background: rgba(255, 77, 232, 0.15);
  clip-path: polygon(12% 100%, 12% 48%, 28% 25%, 44% 48%, 58% 18%, 72% 48%, 88% 25%, 88% 100%);
}

.psf-ring::before {
  border: 2px solid var(--gold);
  background: rgba(255, 215, 106, 0.18);
  border-radius: 50% 50% 4px 4px;
}

.psf-note {
  width: 100%;
  text-align: center;
  font-size: 0.56rem;
}

html[data-promo-shot="1"] .promo-shot-foot {
  display: flex;
  flex-shrink: 0;
}

html[data-promo-shot="1"] .slow-button {
  margin: 0.25rem auto 0.2rem;
  max-width: none;
  flex-shrink: 0;
}

html[data-promo-shot="1"] .operator {
  margin-top: 0.15rem;
  max-width: none;
  flex-shrink: 0;
  border-color: rgba(46, 232, 255, 0.2);
}

html[data-promo-shot="1"] .fail-banner {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.shell {
  max-width: 430px;
  margin: 0 auto;
  padding: 0.65rem 0.75rem 1.25rem;
}

.masthead {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.6rem;
  margin-bottom: 0.7rem;
  font-size: 0.72rem;
}

.back {
  color: var(--muted);
  text-decoration: none;
}
.back:hover {
  color: var(--cyan);
}

.brand {
  flex: 1;
  color: var(--muted);
  line-height: 1.35;
}
.brand strong {
  display: block;
  color: var(--cyan);
  font-size: 0.82rem;
  letter-spacing: 0.04em;
}

.ghost-button,
.btn-primary {
  font: inherit;
  cursor: pointer;
  border-radius: 6px;
  padding: 0.45rem 0.85rem;
}

.ghost-button {
  border: 1px solid rgba(143, 162, 190, 0.35);
  background: rgba(12, 16, 24, 0.8);
  color: var(--text);
}

.btn-primary {
  border: none;
  background: linear-gradient(135deg, #2ee8ff, #55c4ff);
  color: #041018;
  font-weight: 700;
  width: 100%;
  max-width: 320px;
  margin-top: 0.4rem;
}

.play-intro .kicker {
  font-size: 0.68rem;
  color: var(--muted);
  letter-spacing: 0.08em;
  margin: 0 0 0.25rem;
}

.play-intro h1 {
  font-size: 1.35rem;
  margin: 0 0 0.5rem;
  line-height: 1.25;
}
.play-intro h1 span {
  display: block;
  font-size: 0.9rem;
  color: var(--magenta);
  font-weight: 600;
}

.tower-glyphs {
  display: flex;
  justify-content: center;
  gap: 1.2rem;
  margin: 0.5rem 0 0.85rem;
}

.tg {
  display: block;
  width: 36px;
  height: 52px;
  position: relative;
}
.tg-fork::before,
.tg-crown::before,
.tg-ring::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 4px 4px 2px 2px;
  opacity: 0.92;
}
.tg-fork::before {
  background: linear-gradient(180deg, rgba(46, 232, 255, 0.35), rgba(46, 232, 255, 0.08));
  border: 2px solid var(--cyan);
  clip-path: polygon(50% 0%, 25% 35%, 10% 100%, 35% 65%, 50% 88%, 65% 65%, 90% 100%, 75% 35%);
}
.tg-crown::before {
  background: linear-gradient(180deg, rgba(255, 77, 232, 0.35), rgba(255, 77, 232, 0.08));
  border: 2px solid var(--magenta);
  clip-path: polygon(12% 100%, 12% 48%, 28% 25%, 44% 48%, 58% 18%, 72% 48%, 88% 25%, 88% 100%);
}
.tg-ring::before {
  background: linear-gradient(180deg, rgba(255, 215, 106, 0.35), rgba(255, 215, 106, 0.08));
  border: 2px solid var(--gold);
  border-radius: 50% 50% 6px 6px;
  box-shadow: inset 0 -14px 0 rgba(255, 215, 106, 0.25);
}

.rule-list {
  margin: 0 0 1rem;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.45rem;
  font-size: 0.88rem;
}
.rule-list strong {
  color: var(--text);
}

.hud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.65rem;
  font-size: 0.62rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}
.hud strong {
  display: block;
  color: var(--text);
  font-size: 0.78rem;
}

.objective-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.55rem;
  align-items: center;
  margin: 0 0 0.4rem;
  padding: 0.28rem 0.5rem;
  font-size: 0.64rem;
  background: rgba(12, 16, 24, 0.85);
  border: 1px solid rgba(46, 232, 255, 0.22);
  border-radius: 6px;
}

.obj-label {
  color: var(--cyan);
  font-weight: 700;
  margin-right: 0.2rem;
}

.obj-tower {
  color: var(--gold);
  font-weight: 600;
}

.obj-bonus {
  color: var(--muted);
  font-size: 0.58rem;
}

.control-hint {
  margin: 0.2rem auto 0;
  max-width: 366px;
  font-size: 0.58rem;
  line-height: 1.4;
  color: var(--muted);
  text-align: center;
  overflow-wrap: anywhere;
}
.control-hint .hint-pc,
.control-hint .hint-touch {
  display: none;
}
@media (pointer: fine) {
  .control-hint .hint-pc {
    display: inline;
  }
  #game-canvas {
    cursor: crosshair;
  }
}
@media (pointer: coarse) {
  .control-hint .hint-touch {
    display: inline;
  }
}

.canvas-wrap {
  width: 100%;
  max-width: 366px;
  margin: 0 auto;
  border-radius: 10px;
  border: 1px solid rgba(46, 232, 255, 0.18);
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
}

#game-canvas {
  display: block;
  width: 100%;
  height: auto;
  touch-action: none;
  cursor: grab;
  background: #0a1018;
}
#game-canvas.dragging {
  cursor: grabbing;
}

.fail-banner {
  margin: 0.35rem 0;
  padding: 0.4rem 0.55rem;
  font-size: 0.75rem;
  border-radius: 6px;
  background: rgba(255, 92, 82, 0.15);
  border: 1px solid var(--danger);
  color: #ffd2cf;
}

.slow-button {
  display: block;
  width: 100%;
  max-width: 366px;
  margin: 0.45rem auto;
  padding: 0.55rem;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  color: #dcecff;
  border-radius: 8px;
  border: 1px solid rgba(181, 109, 255, 0.45);
  background: linear-gradient(180deg, rgba(60, 35, 90, 0.7), rgba(20, 14, 32, 0.9));
  cursor: pointer;
}
.slow-button[aria-pressed="true"] {
  border-color: var(--magenta);
  box-shadow: 0 0 18px rgba(255, 77, 232, 0.35);
}
.slow-sub {
  display: block;
  font-size: 0.58rem;
  font-weight: 400;
  color: var(--muted);
  margin-top: 0.15rem;
}

.operator {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  margin-top: 0.4rem;
  padding: 0.45rem 0.55rem;
  background: rgba(10, 14, 22, 0.9);
  border: 1px solid rgba(143, 162, 190, 0.22);
  border-radius: 8px;
  font-size: 0.72rem;
  max-width: 366px;
  margin-left: auto;
  margin-right: auto;
}
.op-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.58rem;
  letter-spacing: 0.06em;
}
.op-msg {
  margin: 0.15rem 0 0;
  color: var(--text);
}

.summary {
  margin-top: 1rem;
}
.summary h2 {
  font-size: 1.1rem;
}
.sum-rank {
  font-size: 2rem;
  color: var(--gold);
  font-weight: 800;
  margin: 0.25rem 0;
}
#sum-stats {
  padding-left: 1.1rem;
  font-size: 0.85rem;
}
.records {
  font-size: 0.72rem;
  color: var(--muted);
}
.summary-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

@media (min-width: 800px) {
  .shell {
    max-width: 480px;
  }
}