/* =========================================================================
   OCTAGON KOI — SACRED JADE SANCTUARY DESIGN SYSTEM
   Primary Palette:
   - Imperial Dark Sapphire & Emerald: #081C24, #0D3B2E
   - Auspicious Infinity Gold: #FFD700, #FF9900
   - Lucky Lantern Crimson: #E11D48, #F43F5E
   - Jade Relic Green & Crisp White: #10B981, #FFFDF5
   - 100% Crisp Unblurred Background Law: zero blur(), zero full-screen scrims
   ========================================================================= */

:root {
  --sapphire-deep: #081C24;
  --emerald-rich: #0D3B2E;
  --gold-bright: #FFD700;
  --gold-amber: #FF9900;
  --crimson-lantern: #E11D48;
  --crimson-glow: #F43F5E;
  --jade-green: #10B981;
  --jade-light: #34D399;
  --ivory-white: #FFFDF5;
  --text-muted: #B6D7CC;
  --panel-bg: rgba(8, 28, 36, 0.92);
  --panel-emerald: rgba(13, 59, 46, 0.94);
  --font-main: 'Nunito', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-main);
  color: var(--ivory-white);
  /* 100% CRISP UNBLURRED BACKGROUND LAW */
  background: url('bg.jpg') center/cover no-repeat fixed;
}

button, input, select, textarea {
  font-family: var(--font-main);
}

button {
  cursor: pointer;
  border: none;
  outline: none;
}

.hidden {
  display: none !important;
}

/* =========================================================================
   SCREEN ROUTING SYSTEM
   ========================================================================= */

.screen {
  display: none;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px;
}

.screen.active {
  display: flex;
  flex-direction: column;
  align-items: center;
}

#screen-arena.active {
  padding: 8px;
  overflow: hidden;
}

/* =========================================================================
   TOAST NOTIFICATION LAYER
   ========================================================================= */

.toast-container {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: min(92vw, 420px);
}

.imperial-toast {
  background: rgba(8, 28, 36, 0.96);
  border: 2px solid var(--gold-bright);
  border-radius: 12px;
  padding: 10px 14px;
  color: var(--ivory-white);
  font-weight: 800;
  font-size: 0.9rem;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toastSlideIn 0.25s ease-out;
}

@keyframes toastSlideIn {
  from {
    opacity: 0;
    transform: translateY(-14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* =========================================================================
   SCREEN 1: WELCOME / SANCTUARY GATE
   ========================================================================= */

.welcome-shell {
  width: min(100%, 480px);
  margin: auto;
  background: var(--panel-bg);
  border: 2.5px solid var(--gold-bright);
  border-radius: 22px;
  padding: 22px 18px;
  text-align: center;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.72), inset 0 0 18px rgba(255, 215, 0, 0.14);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.imperial-crest-badge {
  background: linear-gradient(90deg, var(--crimson-lantern), #9F1239);
  border: 1.5px solid var(--gold-bright);
  color: var(--ivory-white);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  padding: 5px 14px;
  border-radius: 999px;
  text-transform: uppercase;
}

.welcome-emblem-frame {
  position: relative;
  width: 146px;
  height: 146px;
  margin: 6px 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.octagon-halo-ring {
  position: absolute;
  inset: 0;
  border: 3px dashed var(--gold-bright);
  border-radius: 26%;
  animation: spinSlow 18s linear infinite;
  box-shadow: 0 0 18px rgba(255, 215, 0, 0.45);
}

@keyframes spinSlow {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.welcome-logo {
  width: 124px;
  height: 124px;
  object-fit: cover;
  border-radius: 22px;
  border: 3px solid var(--gold-bright);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.7);
  position: relative;
  z-index: 2;
}

.koi-orbit-tag {
  position: absolute;
  bottom: -8px;
  z-index: 3;
  background: var(--emerald-rich);
  border: 1.5px solid var(--gold-bright);
  color: var(--gold-bright);
  font-size: 0.7rem;
  font-weight: 900;
  padding: 3px 10px;
  border-radius: 999px;
}

.welcome-title {
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  color: var(--gold-bright);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.85);
  margin-top: 4px;
}

.welcome-subtitle {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--jade-light);
}

.welcome-lore-card {
  background: var(--panel-emerald);
  border: 1.5px solid rgba(255, 215, 0, 0.55);
  border-radius: 16px;
  padding: 14px;
  width: 100%;
  text-align: center;
}

.lore-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.78rem;
  font-weight: 900;
  color: var(--gold-bright);
  margin-bottom: 8px;
  letter-spacing: 0.05em;
}

.lore-text {
  font-size: 0.86rem;
  line-height: 1.45;
  color: var(--ivory-white);
  margin-bottom: 12px;
}

.lore-pillars {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.lore-pillar {
  background: rgba(8, 28, 36, 0.9);
  border: 1px solid var(--gold-bright);
  border-radius: 10px;
  padding: 7px 4px;
  display: flex;
  flex-direction: column;
}

.pillar-num {
  font-size: 1.2rem;
  font-weight: 900;
  color: var(--gold-bright);
}

.pillar-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
}

/* Primary Imperial Gold Button */
.btn-imperial-gold {
  background: linear-gradient(180deg, #FFE033 0%, #FF9900 100%);
  color: #081C24;
  border: 2px solid #FFFDF5;
  border-radius: 14px;
  padding: 13px 22px;
  font-size: 1rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 6px 18px rgba(255, 153, 0, 0.48);
  transition: transform 0.14s ease, box-shadow 0.14s ease;
  width: 100%;
}

.btn-imperial-gold:active {
  transform: scale(0.97);
}

.btn-pulse {
  animation: goldPulse 2.4s infinite ease-in-out;
}

@keyframes goldPulse {
  0%, 100% { box-shadow: 0 6px 18px rgba(255, 215, 0, 0.45); }
  50% { box-shadow: 0 8px 26px rgba(255, 215, 0, 0.85); }
}

.welcome-footer-meta {
  display: flex;
  gap: 8px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
}

/* =========================================================================
   SCREEN 2: INTERACTIVE TROPHY & MODE SHOWCASE HUB
   ========================================================================= */

.hub-container {
  width: min(100%, 720px);
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 24px;
}

.hub-top-bar {
  background: var(--panel-bg);
  border: 2px solid var(--gold-bright);
  border-radius: 16px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.6);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.hub-mini-logo {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  border: 2px solid var(--gold-bright);
  object-fit: cover;
}

.brand-titles {
  display: flex;
  flex-direction: column;
}

.brand-name {
  font-size: 1.05rem;
  font-weight: 900;
  color: var(--gold-bright);
  letter-spacing: 0.03em;
}

.brand-rank {
  font-size: 0.76rem;
  font-weight: 800;
  color: var(--jade-light);
}

.currency-strip {
  display: flex;
  align-items: center;
  gap: 8px;
}

.currency-pill {
  background: var(--panel-emerald);
  border: 1.5px solid var(--gold-bright);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 0.85rem;
  font-weight: 900;
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--ivory-white);
}

.icon-btn-gold {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--panel-emerald);
  border: 1.5px solid var(--gold-bright);
  color: var(--gold-bright);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

/* Hub Centerpiece: Rotating Auspicious Octagon Emblem */
.hub-octagon-showcase {
  background: var(--panel-bg);
  border: 2px solid var(--gold-bright);
  border-radius: 18px;
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.65);
}

.showcase-octagon-column {
  flex-shrink: 0;
}

.css-octagon-spinner {
  width: 106px;
  height: 106px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.octagon-ring-outer {
  position: absolute;
  inset: 0;
  background: conic-gradient(
    from 0deg,
    #FFD700 0deg 45deg,
    #10B981 45deg 90deg,
    #E11D48 90deg 135deg,
    #38BDF8 135deg 180deg,
    #FFD700 180deg 225deg,
    #10B981 225deg 270deg,
    #E11D48 270deg 315deg,
    #38BDF8 315deg 360deg
  );
  clip-path: polygon(30% 0%, 70% 0%, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0% 70%, 0% 30%);
  animation: spinSlow 14s linear infinite;
  border: 2px solid var(--gold-bright);
}

.octagon-ring-inner {
  width: 78px;
  height: 78px;
  background: var(--sapphire-deep);
  clip-path: polygon(30% 0%, 70% 0%, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0% 70%, 0% 30%);
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.octagon-center-figure {
  font-size: 1.75rem;
  font-weight: 900;
  color: var(--gold-bright);
  line-height: 1;
}

.octagon-center-sub {
  font-size: 0.65rem;
  font-weight: 800;
  color: var(--jade-light);
}

.showcase-status-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.showcase-chapter-tag {
  font-size: 0.72rem;
  font-weight: 900;
  color: var(--gold-bright);
  letter-spacing: 0.06em;
}

.showcase-stage-title {
  font-size: 1.15rem;
  font-weight: 900;
  color: var(--ivory-white);
}

.showcase-stage-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.35;
}

.showcase-stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 6px;
}

.mini-stat-box {
  background: var(--panel-emerald);
  border: 1px solid rgba(255, 215, 0, 0.5);
  border-radius: 10px;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
}

.mini-stat-val {
  font-size: 0.92rem;
  font-weight: 900;
  color: var(--gold-bright);
}

.mini-stat-lbl {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted);
}

/* Primary Start Sanctuary Stage Card */
.hub-primary-cta-card {
  background: linear-gradient(135deg, rgba(13, 59, 46, 0.96) 0%, rgba(8, 28, 36, 0.96) 100%);
  border: 2.5px solid var(--gold-bright);
  border-radius: 18px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.68);
}

.cta-card-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cta-badge-crimson {
  align-self: flex-start;
  background: var(--crimson-lantern);
  border: 1px solid var(--gold-bright);
  color: var(--ivory-white);
  font-size: 0.68rem;
  font-weight: 900;
  padding: 3px 10px;
  border-radius: 999px;
  letter-spacing: 0.06em;
}

.cta-card-info h3 {
  font-size: 1.2rem;
  font-weight: 900;
  color: var(--gold-bright);
}

.cta-card-info p {
  font-size: 0.84rem;
  color: var(--ivory-white);
  font-weight: 700;
}

.btn-start-arena {
  font-size: 1.05rem;
  padding: 14px 20px;
}

/* 4 Hub Mode Cards Grid */
.hub-cards-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.hub-mode-card {
  background: var(--panel-bg);
  border: 2px solid var(--gold-bright);
  border-radius: 16px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  transition: transform 0.14s ease, border-color 0.14s ease;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.6);
}

.hub-mode-card:hover,
.hub-mode-card:focus {
  transform: translateY(-2px);
  border-color: var(--jade-light);
}

.mode-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mode-card-icon {
  font-size: 1.65rem;
}

.mode-card-pill {
  background: var(--panel-emerald);
  border: 1px solid var(--gold-bright);
  color: var(--gold-bright);
  font-size: 0.7rem;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 999px;
}

.mode-card-title {
  font-size: 0.96rem;
  font-weight: 900;
  color: var(--gold-bright);
}

.mode-card-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.35;
}

.mode-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.76rem;
  font-weight: 900;
  color: var(--jade-light);
  border-top: 1px solid rgba(255, 215, 0, 0.25);
  padding-top: 7px;
}

.arrow-gold {
  color: var(--gold-bright);
  font-size: 0.95rem;
}

/* Daily Blessing Bar */
.hub-blessing-bar {
  background: var(--panel-emerald);
  border: 2px solid var(--gold-bright);
  border-radius: 14px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.blessing-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.blessing-lantern {
  font-size: 1.5rem;
}

.blessing-left strong {
  display: block;
  font-size: 0.86rem;
  color: var(--gold-bright);
}

.blessing-left span {
  font-size: 0.76rem;
  color: var(--ivory-white);
}

.btn-crimson-small {
  background: linear-gradient(180deg, var(--crimson-glow) 0%, var(--crimson-lantern) 100%);
  color: var(--ivory-white);
  border: 1.5px solid var(--gold-bright);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 0.76rem;
  font-weight: 900;
  white-space: nowrap;
}

.btn-crimson-small:disabled {
  opacity: 0.55;
  cursor: default;
}

/* =========================================================================
   SCREEN 3: SEPARATE FULLSCREEN SANCTUARY GAMEPLAY ARENA
   ========================================================================= */

.arena-wrapper {
  width: min(100%, 640px);
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.arena-hud-top {
  background: var(--panel-bg);
  border: 2px solid var(--gold-bright);
  border-radius: 14px;
  padding: 7px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.hud-btn-back {
  background: var(--panel-emerald);
  border: 1.5px solid var(--gold-bright);
  color: var(--gold-bright);
  border-radius: 10px;
  padding: 7px 11px;
  font-size: 0.8rem;
  font-weight: 900;
  white-space: nowrap;
}

.hud-center-cluster {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hud-stage-pill {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 900;
  color: var(--gold-bright);
}

.hud-progress-track {
  position: relative;
  height: 18px;
  background: rgba(0, 0, 0, 0.65);
  border: 1.5px solid var(--gold-bright);
  border-radius: 999px;
  overflow: hidden;
}

.hud-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--jade-green), var(--gold-bright));
  transition: width 0.2s ease;
}

.hud-progress-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 900;
  color: var(--ivory-white);
  text-shadow: 0 1px 3px #000;
}

.hud-right-metrics {
  display: flex;
  gap: 6px;
}

.hud-metric-badge {
  background: var(--panel-emerald);
  border: 1.5px solid var(--gold-bright);
  border-radius: 10px;
  padding: 4px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 58px;
}

.metric-lbl {
  font-size: 0.6rem;
  font-weight: 800;
  color: var(--text-muted);
}

.metric-val {
  font-size: 0.86rem;
  font-weight: 900;
  color: var(--gold-bright);
}

/* Boss Guardian Health & Beam Banner */
.arena-boss-banner {
  background: rgba(159, 18, 57, 0.94);
  border: 2px solid var(--gold-bright);
  border-radius: 12px;
  padding: 6px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.boss-banner-top {
  display: flex;
  justify-content: space-between;
  font-size: 0.76rem;
  font-weight: 900;
  color: var(--gold-bright);
}

.boss-hp-track {
  height: 10px;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid var(--gold-bright);
  border-radius: 999px;
  overflow: hidden;
}

.boss-hp-fill {
  height: 100%;
  background: linear-gradient(90deg, #F43F5E, #FFD700);
  transition: width 0.2s ease;
}

/* Elemental Facet Legend Strip */
.arena-facet-legend {
  background: var(--panel-bg);
  border: 1.5px solid rgba(255, 215, 0, 0.65);
  border-radius: 10px;
  padding: 5px 10px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.72rem;
  font-weight: 800;
}

.legend-chip {
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
}

.legend-hint {
  color: var(--gold-bright);
}

/* Interactive Canvas Stage */
.arena-canvas-stage {
  flex: 1;
  width: 100%;
  min-height: 280px;
  position: relative;
  background: rgba(8, 28, 36, 0.82);
  border: 2.5px solid var(--gold-bright);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: inset 0 0 28px rgba(0, 0, 0, 0.8);
  touch-action: none;
}

#sanctuary-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Bottom Tactile Control Deck */
.arena-controls-bar {
  display: grid;
  grid-template-columns: 1fr 1.6fr 1fr;
  gap: 8px;
  padding-top: 2px;
}

.btn-compass-turn {
  background: var(--panel-bg);
  border: 2px solid var(--gold-bright);
  color: var(--ivory-white);
  border-radius: 14px;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
}

.btn-compass-turn:active {
  transform: scale(0.95);
  background: var(--panel-emerald);
}

.turn-arrow {
  font-size: 1.35rem;
  font-weight: 900;
  color: var(--gold-bright);
  line-height: 1;
}

.turn-text {
  font-size: 0.7rem;
  font-weight: 900;
}

.btn-koi-infinity-surge {
  position: relative;
  background: var(--panel-emerald);
  border: 2.5px solid var(--gold-bright);
  border-radius: 14px;
  overflow: hidden;
  padding: 8px 12px;
  color: var(--ivory-white);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.65);
}

.btn-koi-infinity-surge:not(:disabled) {
  background: linear-gradient(135deg, #E11D48 0%, #FF9900 100%);
  animation: goldPulse 1.5s infinite;
}

.btn-koi-infinity-surge:disabled {
  opacity: 0.85;
  cursor: default;
}

.surge-fill-bg {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  background: linear-gradient(90deg, rgba(16, 185, 129, 0.55), rgba(255, 215, 0, 0.65));
  transition: width 0.2s ease;
  z-index: 1;
}

.surge-content {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.surge-symbol {
  font-size: 1.65rem;
  font-weight: 900;
  color: var(--gold-bright);
}

.surge-labels {
  display: flex;
  flex-direction: column;
  text-align: left;
}

.surge-main-title {
  font-size: 0.8rem;
  font-weight: 900;
  color: var(--ivory-white);
}

.surge-sub-status {
  font-size: 0.66rem;
  font-weight: 800;
  color: var(--gold-bright);
}

/* =========================================================================
   SUBSCREENS (30 STAGES / WORKSHOP / MILESTONES / SETTINGS)
   ========================================================================= */

.subscreen-shell {
  width: min(100%, 720px);
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.subscreen-header {
  background: var(--panel-bg);
  border: 2px solid var(--gold-bright);
  border-radius: 16px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.btn-back-hub {
  background: var(--panel-emerald);
  border: 1.5px solid var(--gold-bright);
  color: var(--gold-bright);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 0.78rem;
  font-weight: 900;
  white-space: nowrap;
}

.subscreen-title-block {
  flex: 1;
  text-align: center;
}

.subscreen-title-block h2 {
  font-size: 1.1rem;
  font-weight: 900;
  color: var(--gold-bright);
}

.subscreen-title-block p {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.subscreen-pill {
  background: var(--panel-emerald);
  border: 1.5px solid var(--gold-bright);
  color: var(--gold-bright);
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 900;
  white-space: nowrap;
}

/* Realm Filter Tabs */
.realm-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.realm-tab {
  background: var(--panel-bg);
  border: 2px solid rgba(255, 215, 0, 0.45);
  border-radius: 12px;
  padding: 8px 6px;
  color: var(--ivory-white);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.realm-tab.active {
  background: var(--panel-emerald);
  border-color: var(--gold-bright);
  box-shadow: 0 0 14px rgba(255, 215, 0, 0.35);
}

.realm-num {
  font-size: 0.68rem;
  font-weight: 900;
  color: var(--gold-bright);
}

.realm-name {
  font-size: 0.8rem;
  font-weight: 800;
}

/* 30 Stages Grid */
.stages-grid-scroll,
.workshop-grid-scroll,
.milestones-grid-scroll,
.settings-scroll-body {
  flex: 1;
  overflow-y: auto;
  padding-right: 4px;
  padding-bottom: 20px;
}

.stages-grid-scroll {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  align-content: start;
}

.stage-node-card {
  background: var(--panel-bg);
  border: 2px solid var(--gold-bright);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  position: relative;
}

.stage-node-card.locked {
  opacity: 0.62;
  border-color: rgba(255, 215, 0, 0.35);
}

.stage-node-card.boss-stage {
  background: linear-gradient(160deg, rgba(13, 59, 46, 0.95), rgba(159, 18, 57, 0.88));
}

.stage-node-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.stage-num-badge {
  font-size: 0.75rem;
  font-weight: 900;
  color: var(--gold-bright);
  background: rgba(0, 0, 0, 0.45);
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--gold-bright);
}

.stage-stars-display {
  font-size: 0.9rem;
  color: var(--gold-bright);
  letter-spacing: 2px;
}

.stage-node-title {
  font-size: 0.9rem;
  font-weight: 900;
  color: var(--ivory-white);
}

.stage-node-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.btn-stage-launch {
  background: linear-gradient(180deg, #FFE033, #FF9900);
  color: #081C24;
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 0.76rem;
  font-weight: 900;
  width: 100%;
}

.btn-stage-launch:disabled {
  background: rgba(255, 255, 255, 0.14);
  color: var(--text-muted);
}

/* Workshop List */
.workshop-grid-scroll {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 12px;
  align-content: start;
}

.artifact-card {
  background: var(--panel-bg);
  border: 2px solid var(--gold-bright);
  border-radius: 16px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
}

.artifact-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.artifact-icon-box {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--panel-emerald);
  border: 2px solid var(--gold-bright);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}

.artifact-title-col h4 {
  font-size: 0.96rem;
  font-weight: 900;
  color: var(--gold-bright);
}

.artifact-level-tag {
  font-size: 0.74rem;
  font-weight: 800;
  color: var(--jade-light);
}

.artifact-desc {
  font-size: 0.8rem;
  color: var(--ivory-white);
  line-height: 1.35;
}

.artifact-pips {
  display: flex;
  gap: 4px;
}

.artifact-pip {
  flex: 1;
  height: 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 215, 0, 0.4);
}

.artifact-pip.filled {
  background: linear-gradient(90deg, var(--jade-green), var(--gold-bright));
}

/* Milestones Hall */
.milestones-grid-scroll {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 12px;
  align-content: start;
}

.milestone-card {
  background: var(--panel-bg);
  border: 2px solid var(--gold-bright);
  border-radius: 16px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
}

.milestone-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.milestone-title {
  font-size: 0.94rem;
  font-weight: 900;
  color: var(--gold-bright);
}

.milestone-reward-tag {
  background: var(--panel-emerald);
  border: 1px solid var(--gold-bright);
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 900;
  color: var(--ivory-white);
}

.milestone-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Settings & Legal Hub */
.settings-scroll-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.settings-panel {
  background: var(--panel-bg);
  border: 2px solid var(--gold-bright);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel-heading {
  font-size: 0.96rem;
  font-weight: 900;
  color: var(--gold-bright);
  border-bottom: 1px solid rgba(255, 215, 0, 0.3);
  padding-bottom: 6px;
}

.panel-subtext {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.settings-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.settings-toggle-row strong {
  font-size: 0.88rem;
  color: var(--ivory-white);
}

.settings-toggle-row p {
  font-size: 0.76rem;
  color: var(--text-muted);
}

.btn-toggle-switch {
  background: rgba(255, 255, 255, 0.14);
  border: 1.5px solid var(--gold-bright);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.75rem;
  font-weight: 900;
}

.btn-toggle-switch.active {
  background: var(--jade-green);
  color: #081C24;
}

.about-app-card {
  background: var(--panel-emerald);
  border: 1.5px solid var(--gold-bright);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.about-logo-img {
  width: 64px;
  height: 64px;
  border-radius: 14px;
  border: 2px solid var(--gold-bright);
  object-fit: cover;
  flex-shrink: 0;
}

.about-meta-list h4 {
  font-size: 0.96rem;
  font-weight: 900;
  color: var(--gold-bright);
}

.version-badge-line {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 4px 0;
}

.badge-gold {
  background: rgba(255, 215, 0, 0.2);
  border: 1px solid var(--gold-bright);
  color: var(--gold-bright);
  font-size: 0.7rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
}

.badge-emerald {
  background: rgba(16, 185, 129, 0.2);
  border: 1px solid var(--jade-light);
  color: var(--jade-light);
  font-size: 0.7rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
}

.about-desc-copy {
  font-size: 0.78rem;
  color: var(--ivory-white);
  line-height: 1.35;
}

.about-actions-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.btn-imperial-card-action {
  background: var(--panel-emerald);
  border: 1.5px solid var(--gold-bright);
  border-radius: 12px;
  padding: 12px 8px;
  color: var(--ivory-white);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
}

.action-icon {
  font-size: 1.4rem;
}

.action-title {
  font-size: 0.82rem;
  font-weight: 900;
  color: var(--gold-bright);
}

.action-sub {
  font-size: 0.68rem;
  color: var(--text-muted);
}

.legal-actions-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.btn-legal-doc {
  background: var(--panel-emerald);
  border: 1.5px solid var(--gold-bright);
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--gold-bright);
  font-size: 0.84rem;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* =========================================================================
   MODALS (PAUSE / STAGE COMPLETE / SUPPORT / RATE / SHARE / LEGAL)
   ========================================================================= */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 28, 36, 0.82);
  z-index: 5000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
}

.imperial-modal {
  width: min(100%, 460px);
  max-height: 90vh;
  overflow-y: auto;
  background: var(--sapphire-deep);
  border: 2.5px solid var(--gold-bright);
  border-radius: 20px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.85);
}

.imperial-modal.modal-wide {
  width: min(100%, 560px);
}

.modal-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1.5px solid rgba(255, 215, 0, 0.35);
  padding-bottom: 8px;
}

.modal-header-bar h3 {
  font-size: 1.05rem;
  font-weight: 900;
  color: var(--gold-bright);
}

.btn-close-modal {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--panel-emerald);
  border: 1px solid var(--gold-bright);
  color: var(--gold-bright);
  font-size: 1.2rem;
  font-weight: 900;
}

.modal-octagon-crest {
  font-size: 2.5rem;
  text-align: center;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 900;
  color: var(--gold-bright);
  text-align: center;
}

.modal-subtitle {
  font-size: 0.84rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.4;
}

.result-stars-row {
  display: flex;
  justify-content: center;
  gap: 12px;
  font-size: 2.1rem;
}

.star-slot {
  color: rgba(255, 255, 255, 0.22);
}

.star-slot.earned {
  color: var(--gold-bright);
  text-shadow: 0 0 14px rgba(255, 215, 0, 0.75);
}

.result-metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.result-metric-item {
  background: var(--panel-emerald);
  border: 1px solid var(--gold-bright);
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.rm-label {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.rm-val {
  font-size: 1rem;
  font-weight: 900;
  color: var(--gold-bright);
}

.modal-btn-row {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.btn-secondary-emerald {
  flex: 1;
  background: var(--panel-emerald);
  border: 1.5px solid var(--gold-bright);
  color: var(--ivory-white);
  border-radius: 12px;
  padding: 11px 12px;
  font-size: 0.82rem;
  font-weight: 900;
}

/* Support & Rating Form Elements */
.imperial-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.form-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--gold-bright);
}

.imperial-input,
.imperial-textarea {
  background: rgba(13, 59, 46, 0.85);
  border: 1.5px solid var(--gold-bright);
  border-radius: 10px;
  padding: 9px 11px;
  color: var(--ivory-white);
  font-size: 0.85rem;
  user-select: text;
}

.support-confirm-banner {
  background: rgba(16, 185, 129, 0.22);
  border: 1.5px solid var(--jade-light);
  border-radius: 10px;
  padding: 10px;
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--ivory-white);
  text-align: center;
}

.ticket-history-section h4 {
  font-size: 0.82rem;
  color: var(--gold-bright);
  margin-bottom: 6px;
}

.ticket-log-scroll {
  max-height: 130px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ticket-item {
  background: var(--panel-emerald);
  border: 1px solid rgba(255, 215, 0, 0.45);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 0.74rem;
}

.ticket-item strong {
  color: var(--gold-bright);
}

/* 5-Star Rating Picker */
.star-rating-picker {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.rate-star-btn {
  background: transparent;
  font-size: 2.2rem;
  color: rgba(255, 255, 255, 0.25);
  transition: transform 0.12s ease;
}

.rate-star-btn.active {
  color: var(--gold-bright);
  text-shadow: 0 0 12px rgba(255, 215, 0, 0.65);
}

.rate-caption-text {
  text-align: center;
  font-size: 0.84rem;
  font-weight: 900;
  color: var(--jade-light);
}

/* Share Card */
.share-card-preview {
  background: var(--panel-emerald);
  border: 2px dashed var(--gold-bright);
  border-radius: 14px;
  padding: 14px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.share-code-badge {
  font-size: 1.35rem;
  font-weight: 900;
  color: var(--gold-bright);
  letter-spacing: 0.08em;
}

.share-summary-text {
  font-size: 0.8rem;
  color: var(--ivory-white);
  line-height: 1.4;
  user-select: text;
}

/* Legal Document Scroll */
.legal-doc-scroll {
  max-height: 52vh;
  overflow-y: auto;
  background: rgba(13, 59, 46, 0.65);
  border: 1px solid rgba(255, 215, 0, 0.4);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.legal-doc-scroll h4 {
  font-size: 0.88rem;
  font-weight: 900;
  color: var(--gold-bright);
  margin-top: 4px;
}

.legal-doc-scroll p {
  font-size: 0.78rem;
  color: var(--ivory-white);
  line-height: 1.45;
}

/* Responsive Mobile Tweaks */
@media (max-width: 520px) {
  .hub-octagon-showcase {
    flex-direction: column;
    text-align: center;
  }
  .hub-cards-grid {
    grid-template-columns: 1fr;
  }
  .about-actions-grid {
    grid-template-columns: 1fr;
  }
  .legal-actions-row {
    grid-template-columns: 1fr;
  }
}


/* ==========================================================================
   STRICT MOBILE PORTRAIT FRAME & TOUCH OPTIMIZATION (PHONE-ONLY VIEWPORT)
   ========================================================================== */
html {
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
}

body {
  width: 100%;
  max-width: 480px;
  height: 100dvh;
  margin: 0 auto !important;
  position: relative;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
}

#app-shell,
#app-root,
.screen {
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
}

canvas {
  touch-action: none;
  display: block;
}
