:root {
  --bg-night: #102235;
  --bg-deep: #091521;
  --panel: rgba(15, 32, 49, 0.76);
  --panel-strong: rgba(14, 28, 43, 0.9);
  --panel-edge: rgba(104, 194, 255, 0.18);
  --text-main: #e9f6ff;
  --text-soft: rgba(213, 235, 255, 0.8);
  --text-muted: rgba(157, 197, 225, 0.72);
  --accent: #6ad3ff;
  --accent-warm: #ffd37c;
  --accent-punch: #86f7d0;
  --danger: #ff8d88;
  --shadow: 0 18px 48px rgba(2, 8, 18, 0.3);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--text-main);
  font-family: "Plus Jakarta Sans", "Trebuchet MS", sans-serif;
  background:
    radial-gradient(circle at 14% 12%, rgba(88, 176, 255, 0.24), transparent 24%),
    radial-gradient(circle at 84% 10%, rgba(106, 211, 255, 0.14), transparent 20%),
    radial-gradient(circle at 50% 120%, rgba(134, 247, 208, 0.12), transparent 24%),
    linear-gradient(180deg, #10263c 0%, var(--bg-night) 34%, var(--bg-deep) 100%);
}

body {
  overflow-x: hidden;
}

.odd-page-shell {
  gap: clamp(18px, 2.2vw, 28px);
}

.stage-card,
.overlay-card {
  border: 1px solid var(--panel-edge);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.015) 24%, transparent 30%),
    linear-gradient(180deg, rgba(18, 38, 58, 0.96), rgba(10, 22, 35, 0.92));
  box-shadow: var(--shadow);
}

.odd-stage-shell {
  padding: clamp(12px, 1.4vw, 18px);
  background:
    radial-gradient(circle at 10% 8%, rgba(93, 193, 255, 0.16), transparent 20%),
    radial-gradient(circle at 92% 12%, rgba(255, 211, 124, 0.12), transparent 22%),
    linear-gradient(180deg, rgba(16, 33, 50, 0.92), rgba(10, 20, 31, 0.88));
}

.game-play-shell {
  gap: 0;
}

.overlay-tag {
  margin: 0 0 0.9rem;
  font: 700 0.76rem/1 "Orbitron", sans-serif;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
}

.overlay-card h1,
.overlay-card h2 {
  margin: 0;
  font-family: "Orbitron", sans-serif;
  font-size: clamp(2.2rem, 4vw, 4rem);
  line-height: 0.96;
  letter-spacing: 0.03em;
}

.game-detail-head h2,
.info-card h2 {
  color: var(--text-main);
}

.overlay-copy,
.overlay-footnote,
.overlay-list {
  color: var(--text-soft);
}

.stage-card {
  position: relative;
  overflow: hidden;
  border-radius: 34px;
  padding: clamp(16px, 2vw, 22px);
}

.hud-bar,
.progress-shell {
  position: relative;
  z-index: 2;
}

.hud-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  margin-bottom: 0.8rem;
  padding: 0.3rem;
  border-radius: 28px;
  background: linear-gradient(180deg, rgba(10, 24, 38, 0.78), rgba(7, 18, 30, 0.9));
  border: 1px solid rgba(104, 194, 255, 0.12);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.hud-cluster {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.hud-cluster-right {
  align-items: center;
  justify-content: flex-end;
}

.hud-stat {
  min-width: 112px;
  padding: 0.72rem 0.88rem 0.78rem;
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.03));
  border: 1px solid rgba(104, 194, 255, 0.14);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.hud-stat-wide {
  min-width: 168px;
}

.hud-stat span,
.progress-copy,
.results-grid span {
  display: block;
  color: var(--text-muted);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hud-stat span {
  display: flex;
  align-items: center;
  gap: 0.42rem;
}

.hud-stat span i {
  display: grid;
  place-items: center;
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 999px;
  color: #9be8ff;
  background: rgba(115, 227, 255, 0.12);
  font-style: normal;
  font-size: 0.66rem;
  line-height: 1;
}

.hud-stat span em {
  font-style: normal;
}

.hud-stat strong,
.results-grid strong {
  display: block;
  margin-top: 0.34rem;
  color: #f3fbff;
  font-family: "Orbitron", sans-serif;
  font-size: clamp(1.2rem, 1.65vw, 1.5rem);
  line-height: 1.05;
}

.hud-split-value {
  display: flex !important;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.8rem;
}

.hud-split-value b,
.hud-split-value em {
  font: inherit;
  color: inherit;
}

.hud-split-value em {
  color: #8df7cf;
  font-style: normal;
  font-size: 0.8em;
}

.hud-time-bar {
  margin-top: 0.5rem !important;
}

.hud-time-track {
  display: block;
  flex: 1 1 auto;
  width: 100%;
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.24);
}

.hud-time-fill {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #74e3ff, #8ef7cf 56%, #ffd27a);
  box-shadow: 0 0 14px rgba(115, 227, 255, 0.28);
  transition: width 120ms linear, background 120ms ease, box-shadow 120ms ease;
}

.hud-time-fill.is-critical {
  background: linear-gradient(90deg, #ff9387, #ffc970);
  box-shadow: 0 0 16px rgba(255, 141, 136, 0.34);
}

.icon-btn,
.btn {
  border: 1px solid rgba(115, 227, 255, 0.2);
  border-radius: 18px;
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.08);
  font: 700 0.88rem/1 "Plus Jakarta Sans", sans-serif;
  cursor: pointer;
  transition:
    transform 120ms ease,
    border-color 120ms ease,
    background 120ms ease,
    box-shadow 120ms ease;
}

.icon-btn:hover,
.btn:hover {
  transform: translateY(-1px);
  border-color: rgba(115, 227, 255, 0.42);
  background: rgba(255, 255, 255, 0.12);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  min-width: 54px;
  width: 54px;
  min-height: 54px;
  padding: 0;
  border-radius: 18px;
}

.icon-btn.is-muted {
  border-color: rgba(255, 141, 136, 0.28);
  background: rgba(255, 141, 136, 0.08);
}

.icon-btn.is-muted .icon-btn-glyph {
  background: rgba(255, 141, 136, 0.14);
  color: #ffd4cf;
}

.icon-btn-glyph {
  display: inline-grid;
  place-items: center;
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 999px;
  background: rgba(115, 227, 255, 0.12);
  color: #baf2ff;
  font-size: 0.98rem;
  line-height: 1;
}

.btn {
  min-height: 50px;
  padding: 0.95rem 1.4rem;
}

.btn.primary {
  color: #071521;
  background: linear-gradient(135deg, #ffe49d, #8cf0ff 46%, #89ffd0);
  border-color: rgba(255, 243, 200, 0.28);
  box-shadow: 0 12px 30px rgba(106, 211, 255, 0.22);
}

.progress-shell {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.78rem 0.95rem;
  margin-bottom: 0.9rem;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(104, 194, 255, 0.12);
}

.progress-copy {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.progress-copy-meta {
  flex: 0 0 auto;
  margin-top: 0;
}

.stage-viewport {
  position: relative;
  min-height: min(72vh, 860px);
  height: clamp(520px, 70vh, 860px);
  border-radius: 28px;
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 0%, rgba(115, 227, 255, 0.18), transparent 28%),
    radial-gradient(circle at 88% 14%, rgba(255, 211, 124, 0.1), transparent 24%),
    linear-gradient(180deg, rgba(15, 31, 47, 0.94), rgba(9, 18, 30, 0.94));
  border: 1px solid rgba(104, 194, 255, 0.16);
  box-shadow: inset 0 0 18px rgba(255, 255, 255, 0.04);
}

.stage-viewport.is-shaking {
  animation: viewport-shake 240ms ease;
}

.stage-viewport.is-clutch-zoom {
  transform: scale(1.015);
  transition: transform 180ms ease;
}

.game-stage,
.game-stage canvas {
  position: absolute;
  inset: 0;
}

.game-stage canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.flash-layer {
  position: relative;
  pointer-events: none;
  z-index: 3;
  height: 0;
  margin-bottom: 0;
  overflow: visible;
}

.banner,
.toast,
.combo-callout,
.score-pop {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.8rem 1rem;
  border-radius: 16px;
  font-family: "Orbitron", sans-serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #fffdf4;
  background: rgba(7, 24, 39, 0.9);
  border: 1px solid rgba(115, 227, 255, 0.28);
  opacity: 0;
  will-change: transform, opacity;
}

.banner {
  top: 0;
  font-size: clamp(1rem, 2.4vw, 1.36rem);
}

.toast {
  top: 46px;
  font-size: 0.86rem;
}

.combo-callout {
  top: 92px;
  font-size: clamp(1rem, 2vw, 1.3rem);
  background: rgba(10, 110, 98, 0.84);
}

#comboValue.is-danger-glow {
  color: #ff8c7b;
  text-shadow: 0 0 16px rgba(255, 140, 123, 0.32);
}

.score-pop {
  top: 136px;
  font-size: 1rem;
  background: rgba(12, 88, 132, 0.84);
}

.banner.show,
.toast.show,
.combo-callout.show,
.score-pop.show {
  animation: pop-banner 1200ms ease forwards;
}

.score-pop.show {
  animation: candy-score-pop 860ms cubic-bezier(0.2, 0.9, 0.22, 1) forwards;
}

.hidden {
  display: none !important;
}

.overlay-card {
  position: absolute;
  inset: 50% auto auto 50%;
  z-index: 4;
  width: min(560px, calc(100% - 24px));
  padding: clamp(22px, 4vw, 34px);
  border-radius: 28px;
  transform: translate(-50%, -50%);
}

.overlay-card h2 {
  font-size: clamp(1.8rem, 4vw, 2.8rem);
}

.overlay-copy {
  margin: 1rem 0 0;
  line-height: 1.7;
}

.overlay-list {
  margin: 1rem 0 0;
  padding-left: 1.25rem;
  line-height: 1.7;
}

.overlay-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  margin-top: 1.4rem;
}

.mode-picker {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.8rem;
  margin-top: 1.2rem;
}

.mode-btn {
  padding: 0.95rem 0.9rem;
  border-radius: 18px;
  border: 1px solid rgba(104, 194, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: #edf9ff;
  text-align: left;
  cursor: pointer;
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.mode-btn strong,
.mode-btn span {
  display: block;
}

.mode-btn strong {
  font-size: 0.98rem;
}

.mode-btn span {
  margin-top: 0.26rem;
  color: var(--text-soft);
  font-size: 0.82rem;
}

.mode-btn.is-active {
  transform: translateY(-2px);
  border-color: rgba(47, 181, 239, 0.42);
  box-shadow: 0 12px 26px rgba(89, 194, 237, 0.18);
}

.overlay-footnote {
  margin: 1rem 0 0;
  font-size: 0.9rem;
}

.milestone-overlay {
  background:
    radial-gradient(circle at 18% 18%, rgba(255, 228, 157, 0.18), transparent 22%),
    radial-gradient(circle at 82% 14%, rgba(115, 227, 255, 0.18), transparent 20%),
    linear-gradient(180deg, rgba(19, 40, 60, 0.97), rgba(10, 23, 36, 0.96));
}

.milestone-grid {
  margin-top: 1.1rem;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
  margin-top: 1.2rem;
}

.near-miss-list {
  display: grid;
  gap: 0.55rem;
  margin-top: 1rem;
}

.moment-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}

.moment-card {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.85rem 0.95rem;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(104, 194, 255, 0.12);
  opacity: 0;
  animation: moment-in 360ms ease forwards;
}

.moment-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(255, 228, 157, 0.3), rgba(140, 240, 255, 0.2));
  font-size: 1.1rem;
}

.moment-copy strong,
.moment-copy em {
  display: block;
}

.moment-copy strong {
  color: #eef8ff;
  font-size: 0.84rem;
}

.moment-copy em {
  margin-top: 0.14rem;
  color: var(--text-soft);
  font-style: normal;
  font-size: 0.92rem;
}

.near-miss-list p {
  margin: 0;
  padding: 0.78rem 0.9rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(104, 194, 255, 0.1);
  color: #d3edff;
  font-size: 0.9rem;
}

.results-grid > div {
  padding: 1rem 1.05rem;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(104, 194, 255, 0.12);
}

.game-detail-shell {
  background:
    linear-gradient(180deg, rgba(14, 29, 44, 0.84), rgba(10, 20, 31, 0.82));
  border-color: rgba(104, 194, 255, 0.14);
}

.game-detail-head p,
.info-card p,
.info-card li {
  color: var(--text-soft);
}

.game-quick-facts span {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(104, 194, 255, 0.12);
  color: #dff5ff;
}

.info-card {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02)),
    linear-gradient(180deg, rgba(18, 37, 56, 0.95), rgba(11, 24, 38, 0.92));
  border-color: rgba(104, 194, 255, 0.14);
  box-shadow: 0 14px 34px rgba(2, 8, 18, 0.16);
}

@keyframes pop-banner {
  0% {
    opacity: 0;
    transform: translateX(-50%) translateY(18px) scale(0.92);
  }

  14%,
  72% {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
  }

  100% {
    opacity: 0;
    transform: translateX(-50%) translateY(-12px) scale(0.98);
  }
}

@keyframes viewport-shake {
  0%,
  100% {
    transform: translate3d(0, 0, 0);
  }

  20% {
    transform: translate3d(-8px, 0, 0);
  }

  40% {
    transform: translate3d(8px, 0, 0);
  }

  60% {
    transform: translate3d(-5px, 0, 0);
  }

  80% {
    transform: translate3d(5px, 0, 0);
  }
}

@keyframes timer-pulse {
  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.03);
  }
}

@keyframes moment-in {
  0% {
    opacity: 0;
    transform: translateY(10px) scale(0.96);
  }

  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes candy-score-pop {
  0% {
    opacity: 0;
    transform: translateX(-50%) translateY(12px) scale(0.72) rotate(-4deg);
  }

  22% {
    opacity: 1;
    transform: translateX(-50%) translateY(-2px) scale(1.14) rotate(2deg);
  }

  60% {
    opacity: 1;
    transform: translateX(-50%) translateY(-8px) scale(1.02) rotate(-1deg);
  }

  100% {
    opacity: 0;
    transform: translateX(-50%) translateY(-22px) scale(0.94) rotate(0deg);
  }
}

.share-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  place-items: center;
  padding: 16px;
  background: rgba(8, 34, 48, 0.26);
  backdrop-filter: blur(4px);
}

.share-overlay.is-visible {
  display: grid;
}

.share-card {
  position: relative;
  width: min(520px, 100%);
  padding: 24px;
  border-radius: 26px;
  border: 1px solid rgba(47, 181, 239, 0.18);
  background: linear-gradient(180deg, rgba(248, 254, 255, 0.96), rgba(226, 248, 255, 0.92));
  box-shadow: var(--shadow);
}

.share-card h2 {
  margin: 0;
  font-family: "Orbitron", sans-serif;
  color: #0b3752;
}

.share-copy,
.share-note,
.share-label {
  color: var(--text-soft);
}

.share-label {
  display: block;
  margin-top: 1rem;
  margin-bottom: 0.4rem;
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.share-card textarea,
.share-card input {
  width: 100%;
  border: 1px solid rgba(47, 181, 239, 0.18);
  border-radius: 16px;
  padding: 12px 14px;
  font: inherit;
  color: #0b3752;
  background: rgba(255, 255, 255, 0.84);
}

.share-card textarea {
  min-height: 120px;
  resize: vertical;
}

.share-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1rem;
}

.share-action {
  min-height: 46px;
  padding: 0.85rem 1rem;
  border: 1px solid rgba(47, 181, 239, 0.18);
  border-radius: 14px;
  background: rgba(244, 252, 255, 0.9);
  color: #0b3752;
  font: 700 0.92rem/1 "Plus Jakarta Sans", sans-serif;
  cursor: pointer;
}

.share-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: rgba(47, 181, 239, 0.12);
  color: #0b3752;
  font-size: 1.4rem;
  cursor: pointer;
}

@media (max-width: 720px) {
  .stage-card {
    padding: 12px;
    border-radius: 24px;
  }

  .hud-bar,
  .progress-copy {
    flex-direction: column;
    align-items: stretch;
  }

  .progress-shell {
    flex-direction: column;
    align-items: stretch;
  }

  .hud-bar {
    padding: 0.38rem;
    gap: 0.65rem;
  }

  .hud-cluster-right {
    justify-content: stretch;
  }

  .hud-stat {
    min-width: 0;
    flex: 1 1 calc(50% - 0.5rem);
    padding: 0.68rem 0.78rem 0.74rem;
  }

  .hud-stat-wide {
    flex-basis: 100%;
  }

  .hud-stat strong {
    font-size: 1.1rem;
  }

  .icon-btn {
    flex: 0 0 50px;
    width: 50px;
    min-height: 50px;
  }

  .toast {
    top: 44px;
  }

  .combo-callout {
    top: 86px;
  }

  .score-pop {
    top: 126px;
  }

  .stage-viewport {
    height: min(66vh, 620px);
    min-height: 420px;
  }

  .results-grid,
  .moment-list,
  .mode-picker {
    grid-template-columns: 1fr;
  }

  .overlay-card {
    width: calc(100% - 16px);
    padding: 20px;
  }

  .overlay-actions .btn {
    flex: 1 1 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .stage-viewport.is-shaking,
  .banner.show,
  .toast.show,
  .combo-callout.show,
  .score-pop.show,
  .moment-card {
    animation: none !important;
  }

  .icon-btn,
  .btn,
  .hud-time-fill,
  .stage-viewport.is-clutch-zoom {
    transition: none !important;
  }
}
