:root {
  --bg-midnight: #0D0918;
  --bg-surface: rgba(20, 14, 38, 0.86);
  --bg-card: rgba(29, 21, 52, 0.92);
  --cinnabar: #EF4444;
  --cinnabar-glow: rgba(239, 68, 68, 0.45);
  --brass: #F59E0B;
  --brass-bright: #FDE047;
  --brass-deep: #B45309;
  --azure: #38BDF8;
  --frost: #67E8F9;
  --ink-white: #F8FAFC;
  --ink-muted: #CBD5E1;
  --ink-dim: #94A3B8;
  --border-brass: rgba(245, 158, 11, 0.36);
  --border-subtle: rgba(255, 255, 255, 0.14);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-midnight);
  color: var(--ink-white);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  touch-action: none;
  overscroll-behavior: none;
}

#app-shell {
  position: relative;
  width: 100vw;
  height: 100dvh;
  overflow: hidden;
  background: radial-gradient(circle at 50% 25%, #1E153B 0%, #0D0918 75%);
}

#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: crosshair;
}

.hidden {
  display: none !important;
}

/* Top HUD Bar — Score-Safe & Zero-Overflow even at 320px */
.top-bar {
  position: absolute;
  top: max(8px, env(safe-area-inset-top, 8px));
  left: 8px;
  right: 8px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 5px;
  pointer-events: none;
}

.brand-cluster,
.center-cluster,
.action-cluster {
  display: flex;
  align-items: center;
  gap: 5px;
  pointer-events: auto;
  flex-shrink: 0;
}

.score-block,
.best-block {
  background: rgba(13, 9, 24, 0.82);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border-brass);
  border-radius: 12px;
  padding: 4px 8px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 42px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
}

.score-block {
  min-width: 72px;
}

.best-block {
  min-width: 58px;
}

.hud-caption {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--brass);
  white-space: nowrap;
  line-height: 1.1;
}

.score-row {
  display: flex;
  align-items: center;
  gap: 4px;
}

.score-value {
  font-size: 18px;
  font-weight: 900;
  color: var(--ink-white);
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
  white-space: nowrap;
}

.best-value {
  font-size: 15px;
  font-weight: 800;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  white-space: nowrap;
}

.combo-pill {
  background: linear-gradient(135deg, var(--cinnabar), var(--brass));
  color: #0D0918;
  font-size: 11px;
  font-weight: 900;
  padding: 1px 5px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Lives & Timer */
.lives-row {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(13, 9, 24, 0.82);
  border: 1px solid var(--border-brass);
  padding: 6px 8px;
  border-radius: 999px;
  min-height: 36px;
}

.life-seal {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #FDE047, #EF4444 70%);
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.75);
  border: 1.5px solid #FEF08A;
  transition: transform 0.25s ease, opacity 0.25s ease, filter 0.25s ease;
}

.life-seal.lost {
  opacity: 0.22;
  transform: scale(0.75);
  filter: grayscale(1);
  box-shadow: none;
}

.timer-pill {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(13, 9, 24, 0.84);
  border: 1px solid var(--azure);
  border-radius: 999px;
  padding: 5px 9px;
  min-height: 36px;
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.25);
}

.timer-icon {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--azure);
  box-shadow: 0 0 8px var(--azure);
}

.timer-value {
  font-size: 13px;
  font-weight: 900;
  color: var(--ink-white);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Top Action Buttons */
.icon-pill {
  appearance: none;
  border: 1px solid var(--border-brass);
  background: rgba(13, 9, 24, 0.84);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--ink-white);
  border-radius: 999px;
  height: 36px;
  padding: 0 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.03em;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  transition: transform 0.14s ease, border-color 0.14s ease, background 0.14s ease;
}

.icon-pill:active {
  transform: scale(0.94);
}

.pill-glyph {
  color: var(--brass);
  font-size: 12px;
  line-height: 1;
}

.pill-text {
  font-size: 11px;
  white-space: nowrap;
}

/* Horn Fever & Frost Resonance Bar */
.fever-bar-wrap {
  position: absolute;
  top: calc(max(8px, env(safe-area-inset-top, 8px)) + 48px);
  left: 50%;
  transform: translateX(-50%);
  width: min(300px, calc(100vw - 24px));
  z-index: 18;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  pointer-events: none;
}

.fever-bar-track {
  width: 100%;
  height: 8px;
  background: rgba(13, 9, 24, 0.84);
  border: 1px solid rgba(245, 158, 11, 0.45);
  border-radius: 999px;
  overflow: hidden;
  box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.7);
}

.fever-bar-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #EF4444 0%, #F59E0B 55%, #FDE047 100%);
  border-radius: 999px;
  transition: width 0.12s ease-out;
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.8);
}

.fever-bar-wrap.fever-active .fever-bar-fill {
  background: linear-gradient(90deg, #FDE047 0%, #38BDF8 50%, #EF4444 100%);
  box-shadow: 0 0 18px #FDE047;
}

.fever-bar-wrap.frost-active .fever-bar-fill {
  background: linear-gradient(90deg, #38BDF8 0%, #67E8F9 60%, #E0F2FE 100%);
  box-shadow: 0 0 18px #67E8F9;
}

.fever-bar-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--brass-bright);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.9);
  white-space: nowrap;
}

/* Title Sky Bottom Prompt */
.title-hint-bar {
  position: absolute;
  bottom: max(14px, env(safe-area-inset-bottom, 14px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 15;
  pointer-events: none;
  max-width: calc(100vw - 16px);
}

.swipe-prompt-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: rgba(13, 9, 24, 0.88);
  border: 1px solid rgba(245, 158, 11, 0.55);
  padding: 8px 14px;
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.65), 0 0 18px rgba(239, 68, 68, 0.25);
}

.prompt-spark {
  width: 8px;
  height: 8px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--brass-bright);
  box-shadow: 0 0 10px var(--brass-bright);
  animation: pulseSpark 1.4s infinite ease-in-out;
}

.prompt-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: var(--ink-white);
  white-space: nowrap;
}

@keyframes pulseSpark {
  0%, 100% { transform: scale(0.9); opacity: 0.7; }
  50% { transform: scale(1.3); opacity: 1; }
}

/* Modals (Dojo & Finale) */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(7, 4, 15, 0.84);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}

.dojo-sheet {
  position: relative;
  width: min(500px, 100%);
  max-height: min(90dvh, 780px);
  overflow-y: auto;
  background: linear-gradient(180deg, #130E24 0%, #0D0918 100%);
  border: 1px solid rgba(245, 158, 11, 0.42);
  border-radius: 24px;
  padding: 18px 14px 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.85);
}

.sheet-close-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink-white);
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Nike Training Club Inspired Dramatic Dark Showcase */
.ntc-hero-showcase {
  text-align: center;
  padding: 4px 6px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 14px;
}

.ntc-floating-emblems {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 8px;
}

.ntc-float-token {
  width: 46px;
  height: 46px;
  object-fit: contain;
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.7));
}

.token-left {
  transform: rotate(-14deg) translateY(4px);
}

.token-right {
  transform: rotate(14deg) translateY(4px);
}

.ntc-center-seal {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, rgba(245, 158, 11, 0.35), rgba(239, 68, 68, 0.18) 70%);
  border: 2px solid var(--brass);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 26px rgba(245, 158, 11, 0.35);
}

.ntc-main-horn {
  width: 52px;
  height: 52px;
  object-fit: contain;
}

.ntc-eyebrow {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--brass);
  text-transform: uppercase;
  margin-bottom: 3px;
  white-space: nowrap;
}

.ntc-hero-heading {
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--ink-white);
  line-height: 1.08;
  margin-bottom: 5px;
  white-space: nowrap;
}

.ntc-hero-sub {
  font-size: 12px;
  color: var(--ink-muted);
  max-width: 340px;
  margin: 0 auto 10px;
  line-height: 1.35;
}

.ntc-stats-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.ntc-stat-chip {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 6px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
}

.ntc-stat-num {
  font-size: 15px;
  font-weight: 900;
  color: var(--brass-bright);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.ntc-stat-lbl {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-dim);
  white-space: nowrap;
}

/* Dojo Sections */
.dojo-section {
  margin-bottom: 14px;
}

.section-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 8px;
}

.section-title {
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.06em;
  color: var(--ink-white);
  white-space: nowrap;
}

.section-badge {
  font-size: 11px;
  font-weight: 800;
  color: var(--brass);
  background: rgba(245, 158, 11, 0.14);
  border: 1px solid rgba(245, 158, 11, 0.35);
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

/* Silk Blade Ribbon Cards */
.blade-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.blade-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1.5px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  padding: 9px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 6px;
  min-width: 0;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.blade-card.equipped {
  border-color: var(--brass-bright);
  background: rgba(245, 158, 11, 0.13);
  box-shadow: 0 0 16px rgba(245, 158, 11, 0.22);
}

.blade-swatch {
  height: 18px;
  border-radius: 999px;
  width: 100%;
  box-shadow: inset 0 1px 3px rgba(255, 255, 255, 0.45);
}

.blade-name {
  font-size: 12px;
  font-weight: 800;
  color: var(--ink-white);
  white-space: nowrap;
}

.blade-desc {
  font-size: 11px;
  color: var(--ink-muted);
  line-height: 1.25;
}

.blade-btn {
  appearance: none;
  border: none;
  border-radius: 999px;
  height: 30px;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  white-space: nowrap;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.12);
  color: var(--ink-white);
  width: 100%;
}

.blade-card.equipped .blade-btn {
  background: linear-gradient(135deg, var(--brass), var(--brass-bright));
  color: #0D0918;
}

/* Apple Games Temple Run Inspired Embossed Golden Medallion Cards */
.medallion-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.medallion-card {
  position: relative;
  border-radius: 16px;
  padding: 8px 8px 10px;
  background: linear-gradient(160deg, #422507 0%, #241304 55%, #160B02 100%);
  border: 1.5px solid rgba(245, 158, 11, 0.45);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  min-width: 0;
  box-shadow: inset 0 1px 0 rgba(254, 240, 138, 0.35), 0 8px 18px rgba(0, 0, 0, 0.55);
}

.medallion-card.unlocked {
  background: linear-gradient(160deg, #78350F 0%, #451A03 55%, #270E02 100%);
  border-color: var(--brass-bright);
  box-shadow: inset 0 1px 2px rgba(254, 240, 138, 0.65), 0 0 20px rgba(245, 158, 11, 0.28);
}

.medallion-arc-svg {
  width: 114px;
  height: 30px;
  margin-bottom: -5px;
  overflow: visible;
}

.medallion-arc-text {
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.1em;
  fill: #FDE047;
  text-transform: uppercase;
}

.medallion-seal {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #FDE047 0%, #F59E0B 55%, #92400E 100%);
  border: 2px solid #FEF08A;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
  margin-bottom: 5px;
}

.medallion-card:not(.unlocked) .medallion-seal {
  filter: grayscale(0.75) brightness(0.7);
}

.medallion-seal-icon {
  font-size: 20px;
  line-height: 1;
}

.medallion-req {
  font-size: 11px;
  font-weight: 700;
  color: #FDE68A;
  line-height: 1.2;
}

.medallion-status {
  margin-top: 4px;
  font-size: 11px;
  font-weight: 900;
  color: var(--brass-bright);
  white-space: nowrap;
}

.dojo-footer {
  display: flex;
  justify-content: center;
  margin-top: 6px;
}

.ntc-pill-cta {
  appearance: none;
  border: none;
  border-radius: 999px;
  height: 42px;
  padding: 0 20px;
  background: var(--ink-white);
  color: #0D0918;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.06em;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
  transition: transform 0.14s ease;
}

.ntc-pill-cta:active {
  transform: scale(0.95);
}

/* Finale Card */
.finale-card {
  width: min(390px, 100%);
  background: linear-gradient(180deg, #1A1130 0%, #0D0918 100%);
  border: 1.5px solid var(--brass);
  border-radius: 24px;
  padding: 20px 16px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.85);
}

.finale-seal-wrap {
  width: 72px;
  height: 72px;
  margin: 0 auto 8px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(245, 158, 11, 0.4), rgba(239, 68, 68, 0.2));
  border: 2px solid var(--brass-bright);
  display: flex;
  align-items: center;
  justify-content: center;
}

.finale-emblem {
  width: 52px;
  height: 52px;
  object-fit: contain;
}

.finale-score-box {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 16px;
  padding: 12px 10px;
  margin: 10px 0 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.finale-score-lbl {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  white-space: nowrap;
}

.finale-score-val {
  font-size: 36px;
  font-weight: 900;
  color: var(--brass-bright);
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
  white-space: nowrap;
}

.finale-new-best {
  font-size: 11px;
  font-weight: 900;
  color: #4ADE80;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.finale-metrics-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 14px;
}

.finale-metric {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 12px;
  padding: 7px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
}

.metric-val {
  font-size: 16px;
  font-weight: 900;
  color: var(--ink-white);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.metric-lbl {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-dim);
  white-space: nowrap;
}

.finale-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.primary-cta {
  background: linear-gradient(135deg, var(--cinnabar), var(--brass));
  color: #0D0918;
  padding: 0 10px;
}

.secondary-cta {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--border-subtle);
  color: var(--ink-white);
  padding: 0 10px;
}

@media (max-width: 350px) {
  .top-bar {
    left: 5px;
    right: 5px;
    gap: 3px;
  }
  .score-block,
  .best-block {
    padding: 3px 6px;
    min-width: 54px;
  }
  .icon-pill {
    padding: 0 7px;
    height: 34px;
  }
}
