:root {
  --emerald-deep: #062819;
  --emerald-mid: #0c442a;
  --emerald-bright: #16a34a;
  --lime-neon: #4ade80;
  --gold-bright: #facc15;
  --gold-deep: #ca8a04;
  --amber-warm: #f59e0b;
  --crimson: #ef4444;
  --glass-bg: rgba(7, 36, 23, 0.84);
  --glass-border: rgba(255, 255, 255, 0.24);
  --text-light: #f8fafc;
  --text-muted: #bbf7d0;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  touch-action: none;
  overscroll-behavior: none;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text-light);
  background: #041d12 url('background.png') center center / cover no-repeat fixed;
}

/* Ambient Stadium Vignette */
#app-shell {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 520px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: radial-gradient(circle at 50% 24%, rgba(6, 40, 25, 0.18) 0%, rgba(3, 18, 11, 0.62) 100%);
  overflow: hidden;
}

.view-panel {
  display: none;
  width: 100%;
  height: 100%;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.view-panel.active {
  display: flex;
}

/* Top Compact Header in Hub */
.top-pill-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 8px) + 8px) 12px 6px;
  gap: 8px;
  z-index: 10;
}

.brand-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  box-shadow: inset 0 1.5px 0 rgba(255,255,255,0.28), 0 6px 16px rgba(0,0,0,0.45);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 5px 11px 5px 6px;
  border-radius: 999px;
}

.brand-badge img {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  object-fit: cover;
  border: 1px solid rgba(250, 204, 21, 0.6);
}

.brand-title {
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
  white-space: nowrap;
}

.stat-cluster {
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-pill {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  box-shadow: inset 0 1.5px 0 rgba(255,255,255,0.25), 0 4px 10px rgba(0,0,0,0.4);
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  color: var(--gold-bright);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 4px;
}

.icon-btn-round {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(180deg, #15653c 0%, #093820 100%);
  border: 1px solid rgba(255,255,255,0.3);
  border-bottom: 3px solid #041d10;
  color: #fff;
  font-weight: 900;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: inset 0 1.5px 0 rgba(255,255,255,0.35), 0 4px 10px rgba(0,0,0,0.4);
}

.icon-btn-round:active {
  transform: translateY(2px) scale(0.95);
}

/* Topology #2: Instant Playable Corner-Kick Table Preview */
.hub-table-wrap {
  position: relative;
  flex: 1;
  min-height: 155px;
  margin: 2px 12px 6px;
  border-radius: 18px;
  border: 1.5px solid rgba(74, 222, 128, 0.42);
  box-shadow: inset 0 2px 0 rgba(255,255,255,0.28), 0 10px 24px rgba(0,0,0,0.55);
  overflow: hidden;
  background: rgba(5, 32, 19, 0.58);
}

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

.hub-live-tag {
  position: absolute;
  top: 8px;
  left: 10px;
  background: rgba(6, 40, 25, 0.88);
  border: 1px solid rgba(74, 222, 128, 0.5);
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.7px;
  color: var(--lime-neon);
  pointer-events: none;
}

.hub-tap-hint {
  position: absolute;
  bottom: 8px;
  right: 10px;
  background: rgba(0, 0, 0, 0.72);
  border: 1px solid rgba(250, 204, 21, 0.5);
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  color: var(--gold-bright);
  pointer-events: none;
}

/* Z-Depth Interlocked Dossier Card */
.dossier-card {
  position: relative;
  margin: 18px 12px 6px;
  padding: 12px 14px 12px;
  background: linear-gradient(165deg, rgba(10, 56, 35, 0.90) 0%, rgba(5, 29, 18, 0.94) 100%);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-bottom: 4px solid #03170d;
  border-radius: 18px;
  box-shadow: inset 0 1.5px 0 rgba(255,255,255,0.28), 0 12px 24px rgba(0,0,0,0.55);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 8;
}

.watermark-num {
  position: absolute;
  right: 12px;
  top: -6px;
  font-size: 74px;
  font-weight: 900;
  color: rgba(255, 255, 255, 0.07);
  line-height: 1;
  pointer-events: none;
  z-index: 0;
}

.dossier-top-row {
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  z-index: 2;
}

.interlock-sprite {
  width: 76px;
  height: 76px;
  margin-top: -26px;
  object-fit: contain;
  filter: drop-shadow(0 10px 14px rgba(0, 0, 0, 0.62));
  flex-shrink: 0;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.dossier-info {
  flex: 1;
  min-width: 0;
}

.sector-kicker {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.9px;
  color: var(--gold-bright);
  text-transform: uppercase;
}

.sector-title {
  font-size: 17px;
  font-weight: 900;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-shadow: 0 1.5px 2px rgba(0,0,0,0.6);
  margin: 1px 0 4px;
}

.sector-specs {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
}

.spec-chip {
  background: rgba(0, 0, 0, 0.42);
  border: 1px solid rgba(255, 255, 255, 0.16);
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 800;
  color: var(--text-muted);
  white-space: nowrap;
}

.dossier-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 9px;
  position: relative;
  z-index: 2;
}

/* 15-Sector Compact Horizontal Ribbon */
.sector-strip-wrap {
  margin: 0 12px 6px;
  background: rgba(6, 33, 21, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 13px;
  padding: 6px 8px;
  z-index: 8;
}

.sector-strip {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
}

.sector-strip::-webkit-scrollbar {
  display: none;
}

.stage-node {
  min-width: 36px;
  height: 34px;
  border-radius: 9px;
  background: linear-gradient(180deg, #134e32 0%, #0a2e1d 100%);
  border: 1px solid rgba(255,255,255,0.22);
  border-bottom: 3px solid #04180e;
  color: #d1fae5;
  font-size: 12px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.stage-node.active {
  background: linear-gradient(180deg, #facc15 0%, #ca8a04 100%);
  border-color: #fef08a;
  border-bottom-color: #854d0e;
  color: #1c1917;
  transform: scale(1.06);
}

/* Glossy 3D Game Buttons (Supercell / Apple Arcade Standard) */
.btn-3d {
  appearance: none;
  border: 1px solid rgba(255,255,255,0.32);
  border-bottom: 4px solid #052e16;
  border-radius: 12px;
  padding: 9px 12px;
  min-height: 42px;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: #fff;
  text-shadow: 0 1.5px 1px rgba(0, 0, 0, 0.55);
  background: linear-gradient(180deg, #22c55e 0%, #15803d 100%);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.45), 0 5px 12px rgba(0, 0, 0, 0.42);
  cursor: pointer;
  white-space: nowrap;
  max-width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform 0.08s ease;
}

.btn-3d:active {
  transform: translateY(2px) scale(0.95);
  border-bottom-width: 2px;
}

.btn-gold {
  background: linear-gradient(180deg, #fde047 0%, #eab308 55%, #ca8a04 100%);
  border-bottom-color: #713f12;
  color: #111827;
  text-shadow: 0 1px 0 rgba(255,255,255,0.45);
}

.btn-slate {
  background: linear-gradient(180deg, #1e4635 0%, #0f291e 100%);
  border-bottom-color: #06130d;
  color: #e2e8f0;
}

.btn-crimson {
  background: linear-gradient(180deg, #f87171 0%, #dc2626 100%);
  border-bottom-color: #7f1d1d;
}

.flex-1 {
  flex: 1;
}

/* Topology #2: Bottom Floating 4-Icon Frosted Dock */
.floating-dock-wrap {
  padding: 2px 12px calc(env(safe-area-inset-bottom, 8px) + 6px);
  z-index: 25;
}

.floating-dock {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  background: rgba(5, 28, 18, 0.90);
  border: 1.5px solid rgba(255, 255, 255, 0.24);
  border-bottom: 4px solid #02120a;
  border-radius: 18px;
  padding: 5px;
  box-shadow: inset 0 1.5px 0 rgba(255,255,255,0.25), 0 10px 24px rgba(0,0,0,0.65);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.dock-item {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: #a7f3d0;
  border-radius: 12px;
  padding: 6px 4px;
  min-height: 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.4px;
  white-space: nowrap;
}

.dock-item svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.2;
}

.dock-item.active {
  background: linear-gradient(180deg, rgba(34, 197, 94, 0.32) 0%, rgba(21, 128, 61, 0.48) 100%);
  border-color: rgba(74, 222, 128, 0.55);
  color: var(--gold-bright);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.3);
}

/* Flagship Game Arena (76%+ Interactive Canvas + 44px Top HUD) */
.arena-hud {
  height: 44px;
  margin: calc(env(safe-area-inset-top, 4px) + 4px) 10px 4px;
  padding: 0 10px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  box-shadow: inset 0 1.5px 0 rgba(255,255,255,0.22), 0 4px 12px rgba(0,0,0,0.45);
  z-index: 12;
}

.hud-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.hud-badge {
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
  color: #fff;
}

.hud-badge.combo {
  color: var(--gold-bright);
  border-color: rgba(250, 204, 21, 0.5);
}

.hud-badge.wind {
  color: #7dd3fc;
}

.arena-canvas-box {
  position: relative;
  flex: 1;
  min-height: 74%;
  margin: 0 10px 4px;
  border-radius: 18px;
  border: 1.5px solid rgba(74, 222, 128, 0.45);
  box-shadow: inset 0 2px 0 rgba(255,255,255,0.25), 0 8px 20px rgba(0,0,0,0.55);
  overflow: hidden;
  background: rgba(4, 29, 18, 0.65);
}

#arena-canvas, #blitz-canvas, #sandbox-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.arena-controls {
  display: grid;
  grid-template-columns: 1fr 1.25fr 1fr;
  gap: 8px;
  padding: 2px 10px calc(env(safe-area-inset-bottom, 6px) + 6px);
  z-index: 12;
}

/* Pre-Start Overlay & Stage Clear Overlay inside Canvas Box */
.canvas-overlay {
  position: absolute;
  inset: 0;
  background: rgba(3, 19, 12, 0.82);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 20;
}

.canvas-overlay.hidden {
  display: none;
}

.overlay-card {
  width: 100%;
  max-width: 340px;
  background: linear-gradient(170deg, rgba(12, 64, 40, 0.96) 0%, rgba(5, 28, 17, 0.98) 100%);
  border: 1.5px solid rgba(250, 204, 21, 0.45);
  border-bottom: 4px solid #02120a;
  border-radius: 20px;
  padding: 22px 16px 16px;
  text-align: center;
  box-shadow: 0 16px 36px rgba(0,0,0,0.7);
  position: relative;
}

.overlay-card img.hero-pop {
  width: 86px;
  height: 86px;
  margin-top: -48px;
  object-fit: contain;
  filter: drop-shadow(0 10px 14px rgba(0,0,0,0.65));
}

.overlay-card h2 {
  font-size: 19px;
  font-weight: 900;
  color: var(--gold-bright);
  margin: 4px 0 6px;
  text-transform: uppercase;
}

.overlay-card p {
  font-size: 12px;
  line-height: 1.45;
  color: #dcfce7;
  margin-bottom: 12px;
}

.overlay-btn-row {
  display: flex;
  gap: 8px;
}

/* Sub-Views: Locker Customizer & Tactics Sandbox */
.subview-content {
  flex: 1;
  overflow-y: auto;
  padding: 4px 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.locker-showcase {
  position: relative;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 18px;
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: inset 0 1.5px 0 rgba(255,255,255,0.22), 0 8px 20px rgba(0,0,0,0.5);
}

.locker-showcase img {
  width: 92px;
  height: 92px;
  object-fit: contain;
  filter: drop-shadow(0 10px 14px rgba(0,0,0,0.6));
}

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

.gear-card {
  position: relative;
  background: rgba(7, 38, 24, 0.88);
  border: 1.5px solid rgba(255, 255, 255, 0.2);
  border-bottom: 4px solid #03170d;
  border-radius: 15px;
  padding: 14px 10px 10px;
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
}

.gear-card.equipped {
  border-color: var(--gold-bright);
  background: linear-gradient(180deg, rgba(20, 83, 45, 0.92) 0%, rgba(7, 38, 24, 0.95) 100%);
}

.gear-card img {
  width: 62px;
  height: 62px;
  margin-top: -28px;
  object-fit: contain;
  filter: drop-shadow(0 8px 10px rgba(0,0,0,0.55));
}

.gear-name {
  font-size: 13px;
  font-weight: 900;
  color: #fff;
  white-space: nowrap;
}

.gear-bonus {
  font-size: 10px;
  font-weight: 800;
  color: var(--lime-neon);
  margin-bottom: 4px;
}

/* Modal Dialog (Trophies & Settings) */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 14, 9, 0.84);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 50;
}

.modal-backdrop.open {
  display: flex;
}

.modal-sheet {
  width: 100%;
  max-width: 400px;
  max-height: 86vh;
  overflow-y: auto;
  background: linear-gradient(170deg, rgba(11, 58, 36, 0.97) 0%, rgba(4, 24, 15, 0.99) 100%);
  border: 1.5px solid rgba(255,255,255,0.28);
  border-bottom: 4px solid #020f09;
  border-radius: 20px;
  padding: 16px;
  box-shadow: 0 20px 44px rgba(0,0,0,0.75);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 900;
  color: var(--gold-bright);
  text-transform: uppercase;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0,0,0,0.35);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 800;
}

.relic-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.relic-item {
  background: rgba(0,0,0,0.38);
  border: 1px solid rgba(250, 204, 21, 0.35);
  border-radius: 12px;
  padding: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.relic-item img {
  width: 38px;
  height: 38px;
  object-fit: contain;
}

.relic-item div {
  font-size: 11px;
  font-weight: 800;
  color: #fef08a;
}
