/* Track Hurdle — Studio Game Art & Topology #7: Top 65% Live Physics Track Diorama + Bottom 35% 2-Column Sprinter Cockpit */
:root {
  --tartan-red: #e03e2d;
  --tartan-deep: #5e140c;
  --laurel-gold: #ffd438;
  --takeoff-green: #22e67b;
  --volt-lime: #c8ff29;
  --cockpit-bg: rgba(24, 14, 16, 0.88);
  --cockpit-deep: rgba(14, 8, 10, 0.94);
  --lane-white: #fff9f5;
  --warm-sand: #f0d5c8;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background-color: #14090b;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--lane-white);
}

/* Full-Bleed Olympic Tartan Stadium Background */
#app-shell {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 520px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background-image:
    radial-gradient(circle at 50% 25%, rgba(224, 62, 45, 0.14), rgba(14, 8, 10, 0.56) 78%),
    url('background.png');
  background-size: cover;
  background-position: center;
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.9);
  overflow: hidden;
}

/* Compact Top Olympic Timing Header */
.stadium-top-bar {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: max(env(safe-area-inset-top, 8px), 8px) 10px 7px;
  background: linear-gradient(180deg, rgba(36, 14, 14, 0.92) 0%, rgba(18, 8, 10, 0.88) 100%);
  border-bottom: 2px solid rgba(255, 212, 56, 0.55);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.6);
}

.brand-pill {
  display: flex;
  align-items: center;
  gap: 7px;
}

.brand-pill img {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  border: 1.5px solid var(--laurel-gold);
}

.brand-name {
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.5px;
  color: var(--lane-white);
  white-space: nowrap;
}

.timing-pills {
  display: flex;
  align-items: center;
  gap: 6px;
}

.omega-pill {
  background: rgba(14, 7, 9, 0.88);
  border: 1.5px solid rgba(255, 212, 56, 0.6);
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}

.omega-pill span {
  color: var(--laurel-gold);
}

.medals-btn {
  height: 31px;
  padding: 0 9px;
  border-radius: 999px;
  border: 1.5px solid var(--laurel-gold);
  background: linear-gradient(180deg, #ffd438 0%, #c99300 100%);
  color: #1c1200;
  font-size: 11px;
  font-weight: 900;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 3px 0 #664900;
}

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

/* Main Viewport Container */
#view-stage {
  position: relative;
  flex: 1;
  width: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.screen-view {
  display: none;
  width: 100%;
  height: 100%;
  flex-direction: column;
  justify-content: space-between;
  padding: 6px 10px 8px;
  overflow: hidden;
}

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

/* TOPOLOGY #7 HUB: Top 65% Unoccluded Live Physics Track Diorama + Bottom 35% 2-Column Sprinter Cockpit */
.diorama-top-65 {
  position: relative;
  height: 58%;
  min-height: 220px;
  width: 100%;
  border-radius: 18px;
  border: 2.5px solid rgba(255, 212, 56, 0.72);
  background: rgba(18, 8, 10, 0.34);
  box-shadow:
    0 12px 26px rgba(0, 0, 0, 0.65),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
  overflow: hidden;
  cursor: pointer;
}

#hub-diorama-canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.diorama-live-pill {
  position: absolute;
  top: 8px;
  left: 8px;
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(16, 8, 10, 0.88);
  border: 1px solid rgba(200, 255, 41, 0.65);
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 10px;
  font-weight: 900;
  color: var(--volt-lime);
}

.diorama-speed-pill {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(16, 8, 10, 0.88);
  border: 1px solid rgba(255, 212, 56, 0.65);
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 10px;
  font-weight: 900;
  color: var(--laurel-gold);
}

/* Bottom 35% Staggered 2-Column Sprinter Cockpit Sheet */
.cockpit-bottom-35 {
  position: relative;
  margin-top: 14px;
  padding: 10px 12px 10px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(38, 16, 18, 0.92) 0%, rgba(18, 8, 10, 0.96) 100%);
  border: 2px solid rgba(224, 62, 45, 0.78);
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.72), inset 0 1px 0 rgba(255, 230, 210, 0.28);
  overflow: visible;
}

.cockpit-watermark {
  position: absolute;
  right: 12px;
  top: 2px;
  font-size: 68px;
  font-weight: 900;
  line-height: 1;
  color: rgba(255, 212, 56, 0.08);
  pointer-events: none;
  z-index: 0;
}

.cockpit-interlock-sprite {
  position: absolute;
  top: -32px;
  right: 12px;
  width: 76px;
  height: 76px;
  object-fit: contain;
  filter: drop-shadow(0 10px 14px rgba(0, 0, 0, 0.75));
  z-index: 4;
  pointer-events: none;
  animation: spikeFloat 2.4s ease-in-out infinite alternate;
}

@keyframes spikeFloat {
  from { transform: translateY(0px) rotate(-4deg); }
  to { transform: translateY(-6px) rotate(4deg); }
}

.cockpit-header {
  position: relative;
  z-index: 2;
  padding-right: 76px;
}

.cockpit-kicker {
  font-size: 10px;
  font-weight: 900;
  color: var(--laurel-gold);
  letter-spacing: 0.7px;
}

.cockpit-title {
  font-size: 16px;
  font-weight: 900;
  color: var(--lane-white);
  white-space: nowrap;
  overflow: hidden;
}

/* 15 Unlocked Heats Ribbon */
.heat-ribbon {
  position: relative;
  z-index: 2;
  display: flex;
  gap: 5px;
  overflow-x: auto;
  padding: 6px 2px;
  scrollbar-width: none;
}
.heat-ribbon::-webkit-scrollbar { display: none; }

.heat-chip {
  flex: 0 0 auto;
  min-width: 38px;
  height: 26px;
  padding: 0 7px;
  border-radius: 7px;
  border: 1px solid rgba(255, 212, 56, 0.45);
  background: rgba(14, 7, 9, 0.85);
  color: var(--warm-sand);
  font-size: 10px;
  font-weight: 900;
  cursor: pointer;
  white-space: nowrap;
}

.heat-chip.active {
  background: var(--laurel-gold);
  color: #1c1000;
  border-color: #ffffff;
}

/* Staggered 2-Column Control Deck (2x2 Glossy 3D Buttons) */
.cockpit-2col-grid {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin-top: 2px;
}

/* Glossy 3D Game Buttons (.btn-3d) */
.btn-3d {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 43px;
  padding: 7px 10px;
  border-radius: 12px;
  border: 1.5px solid rgba(255, 255, 255, 0.55);
  border-bottom: 4px solid #694900;
  background: linear-gradient(180deg, #ffe570 0%, #ffd438 55%, #cf9800 100%);
  color: #1f1300;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.5px;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.45);
  box-shadow: 0 5px 12px rgba(0, 0, 0, 0.55), inset 0 2px 0 rgba(255, 255, 255, 0.55);
  cursor: pointer;
  white-space: nowrap;
  max-width: 100%;
  transition: transform 0.08s ease;
}

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

.btn-3d.volt {
  background: linear-gradient(180deg, #ddff6e 0%, #b8f516 55%, #7fb000 100%);
  border-bottom-color: #3d5700;
  color: #121c00;
}

.btn-3d.tartan {
  background: linear-gradient(180deg, #ff7363 0%, #e03e2d 55%, #a31f12 100%);
  border-bottom-color: #520b04;
  color: #ffffff;
  text-shadow: 0 1.5px 2px rgba(0,0,0,0.65);
}

.btn-3d.carbon {
  background: linear-gradient(180deg, #42262a 0%, #261417 55%, #140a0c 100%);
  border-color: rgba(255, 212, 56, 0.5);
  border-bottom-color: #080405;
  color: var(--laurel-gold);
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}

/* Flagship 2D Physics Arena (Reflex Stride Cadence & Perfect Hurdle Clearance) */
.arena-hud-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  height: 40px;
  padding: 0 8px;
  border-radius: 11px;
  background: rgba(22, 10, 12, 0.90);
  border: 1.5px solid rgba(255, 212, 56, 0.55);
  margin-bottom: 6px;
}

.arena-stat-pill {
  font-size: 11px;
  font-weight: 900;
  color: var(--lane-white);
  white-space: nowrap;
}

.arena-stat-pill span {
  color: var(--laurel-gold);
}

.combo-chip {
  padding: 2px 8px;
  border-radius: 999px;
  background: linear-gradient(180deg, #c8ff29, #7fb000);
  color: #111c00;
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}

.arena-canvas-wrap {
  position: relative;
  flex: 1;
  width: 100%;
  border-radius: 16px;
  border: 2.5px solid rgba(224, 62, 45, 0.78);
  background: rgba(16, 8, 10, 0.45);
  box-shadow: 0 10px 24px rgba(0,0,0,0.65), inset 0 0 18px rgba(0,0,0,0.65);
  overflow: hidden;
}

#arena-canvas, #drill-canvas, #sandbox-canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.arena-bottom-controls {
  display: grid;
  grid-template-columns: 1.15fr 1.35fr 0.9fr;
  gap: 7px;
  margin-top: 6px;
}

/* Result Overlay */
.canvas-overlay-card {
  position: absolute;
  inset: 12px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(38, 16, 18, 0.95), rgba(16, 7, 9, 0.97));
  border: 2px solid var(--laurel-gold);
  box-shadow: 0 14px 32px rgba(0,0,0,0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 14px;
  z-index: 10;
}

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

.overlay-hero-img {
  width: 84px;
  height: 84px;
  object-fit: contain;
  filter: drop-shadow(0 8px 14px rgba(0,0,0,0.7));
  margin-bottom: 6px;
}

.overlay-title {
  font-size: 18px;
  font-weight: 900;
  color: var(--laurel-gold);
  margin-bottom: 4px;
}

.overlay-desc {
  font-size: 12px;
  line-height: 1.35;
  color: var(--lane-white);
  max-width: 280px;
  margin-bottom: 10px;
}

/* Spike Lab 3D Customizer Grid */
.spike-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
  flex: 1;
  align-content: start;
}

.spike-card {
  position: relative;
  margin-top: 16px;
  padding: 36px 10px 10px;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(40, 18, 20, 0.90), rgba(18, 8, 10, 0.94));
  border: 2px solid rgba(255, 212, 56, 0.45);
  text-align: center;
  box-shadow: 0 8px 18px rgba(0,0,0,0.6);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 6px;
}

.spike-card.equipped {
  border-color: var(--volt-lime);
  box-shadow: 0 0 16px rgba(200, 255, 41, 0.35);
}

.spike-card img {
  position: absolute;
  top: -26px;
  left: 50%;
  transform: translateX(-50%);
  width: 62px;
  height: 62px;
  object-fit: contain;
  filter: drop-shadow(0 8px 10px rgba(0,0,0,0.7));
}

.spike-card-title {
  font-size: 13px;
  font-weight: 900;
  color: var(--lane-white);
  white-space: nowrap;
}

.spike-card-perk {
  font-size: 10px;
  font-weight: 700;
  color: var(--laurel-gold);
}

/* Modal Backdrop */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 4, 5, 0.84);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  z-index: 100;
}

.modal-backdrop.hidden {
  display: none;
}

.modal-panel {
  width: 100%;
  max-width: 400px;
  max-height: 86vh;
  overflow-y: auto;
  border-radius: 18px;
  background: linear-gradient(180deg, #2b1215 0%, #140809 100%);
  border: 2.5px solid var(--laurel-gold);
  padding: 14px;
  box-shadow: 0 18px 40px rgba(0,0,0,0.88);
}

.relic-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 12px;
  background: rgba(12, 5, 6, 0.75);
  border: 1px solid rgba(255, 212, 56, 0.35);
  margin-bottom: 8px;
}

.relic-row img {
  width: 46px;
  height: 46px;
  object-fit: contain;
}
