:root {
  --bg-deep: #0D1F17;
  --bg-panel: rgba(13, 31, 23, 0.90);
  --bg-card: #132C21;
  --border-sage: #274D3B;
  --gold: #F59E0B;
  --gold-bright: #FBBF24;
  --crimson: #E11D48;
  --emerald: #10B981;
  --text-main: #F3F8F5;
  --text-muted: #9AB5A7;
  --font-head: 'Teko', sans-serif;
  --font-ui: 'Barlow', sans-serif;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-deep);
  color: var(--text-main);
  font-family: var(--font-ui);
  font-feature-settings: "tnum" 1;
  font-variant-numeric: tabular-nums;
}

#app-shell {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at 50% 25%, #17382A 0%, #0D1F17 100%);
}

/* Top Tactical Range HUD */
.range-hud {
  z-index: 20;
  background: linear-gradient(180deg, rgba(9, 23, 17, 0.96) 0%, rgba(13, 31, 23, 0.88) 100%);
  border-bottom: 2px solid var(--border-sage);
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
}

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

.brand-plate {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.brand-emblem {
  width: 34px;
  height: 34px;
  border-radius: 6px 0 0 6px;
  border: 1.5px solid var(--gold);
  object-fit: cover;
  flex-shrink: 0;
}

.brand-titles {
  min-width: 0;
}

.brand-name {
  font-family: var(--font-head);
  font-size: 22px;
  line-height: 0.95;
  font-weight: 700;
  letter-spacing: 0.8px;
  color: var(--gold-bright);
  white-space: nowrap;
  overflow: hidden;
  overflow-wrap: break-word;
}

.stage-sub {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  overflow-wrap: break-word;
}

.score-cluster {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.stat-notch {
  background: var(--bg-card);
  border: 1px solid var(--border-sage);
  border-left: 3px solid var(--gold);
  border-radius: 6px 0 0 6px;
  padding: 3px 9px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  min-width: 62px;
}

.stat-lbl {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.stat-val {
  font-family: var(--font-head);
  font-size: 20px;
  line-height: 1;
  font-weight: 700;
  color: var(--text-main);
}

/* Arrow-notched Button Geometry (border-radius: 6px 0 0 6px with right-side fletching notch) */
.fletch-btn,
.notch-icon-btn,
.dist-plate {
  position: relative;
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.4px;
  color: var(--text-main);
  background: var(--bg-card);
  border: 1.5px solid var(--border-sage);
  border-radius: 6px 0 0 6px;
  clip-path: polygon(0 0, 100% 0, calc(100% - 6px) 50%, 100% 100%, 0 100%);
  padding: 6px 14px 6px 10px;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
}

.fletch-btn:active,
.notch-icon-btn:active,
.dist-plate:active {
  transform: scale(0.95);
}

.fletch-btn.sm {
  padding: 4px 11px 4px 8px;
  min-height: 28px;
}

.fletch-btn.primary {
  background: linear-gradient(135deg, #D97706 0%, #F59E0B 100%);
  color: #08140E;
  border-color: #FBBF24;
  font-weight: 800;
}

.fletch-btn.secondary {
  background: #1A3A2B;
  border-color: #366951;
}

.fletch-btn.active-amber {
  background: rgba(245, 158, 11, 0.22);
  border-color: var(--gold);
  color: var(--gold-bright);
}

.notch-icon-btn {
  width: 36px;
  height: 36px;
  padding: 0 4px 0 0;
  font-size: 17px;
  color: var(--gold-bright);
  border-color: var(--gold);
}

/* Distance Selector & Wind Vane Row */
.hud-control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.distance-rack {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
}

.dist-plate {
  flex: 1;
  font-family: var(--font-head);
  font-size: 18px;
  font-weight: 600;
  padding: 3px 10px 3px 6px;
  min-height: 30px;
  color: var(--text-muted);
}

.dist-plate.active {
  background: var(--crimson);
  border-color: #FB7185;
  color: #FFFFFF;
}

.wind-vane-box {
  display: flex;
  align-items: center;
  gap: 7px;
  background: #091610;
  border: 1.5px solid var(--border-sage);
  border-radius: 6px 0 0 6px;
  padding: 3px 10px;
  min-width: 122px;
}

.wind-arrow {
  font-size: 18px;
  color: var(--gold-bright);
  display: inline-block;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.wind-readout {
  display: flex;
  flex-direction: column;
}

.wind-lbl {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.wind-val {
  font-size: 13px;
  font-weight: 800;
  color: var(--gold-bright);
  white-space: nowrap;
}

/* Tools Row */
.hud-tools-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.stage-stepper {
  display: flex;
  align-items: center;
  gap: 6px;
}

.stage-pill-txt {
  font-size: 12px;
  font-weight: 700;
  color: var(--emerald);
  white-space: nowrap;
}

.tactical-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Main Range Canvas Area */
.canvas-stage {
  position: relative;
  flex: 1;
  width: 100%;
  overflow: hidden;
  background: #0D1F17;
}

#rangeCanvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.telemetry-strip {
  position: absolute;
  top: 8px;
  left: 10px;
  right: 10px;
  display: flex;
  justify-content: space-between;
  background: rgba(9, 22, 16, 0.78);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 6px 0 0 6px;
  padding: 5px 10px;
  font-size: 12px;
  color: var(--text-muted);
  pointer-events: none;
}

.telemetry-strip strong {
  color: var(--gold-bright);
  font-weight: 700;
}

.aim-hint-banner {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(13, 31, 23, 0.86);
  border: 1px solid var(--border-sage);
  border-left: 3px solid var(--gold);
  border-radius: 6px 0 0 6px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

/* Stage Overlay */
.stage-overlay {
  position: absolute;
  inset: 0;
  background: rgba(7, 17, 12, 0.82);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 30;
}

.stage-card {
  width: 100%;
  max-width: 350px;
  background: linear-gradient(165deg, #153124 0%, #0B1B14 100%);
  border: 2px solid var(--gold);
  border-radius: 8px 0 0 8px;
  padding: 18px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.65);
  text-align: center;
}

.stage-card-badge {
  display: inline-block;
  background: var(--crimson);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: 4px 0 0 4px;
  letter-spacing: 0.8px;
  margin-bottom: 6px;
}

.stage-card-title {
  font-family: var(--font-head);
  font-size: 32px;
  line-height: 1;
  color: var(--gold-bright);
  margin-bottom: 6px;
}

.stage-card-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.stage-metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.metric-box {
  background: #091710;
  border: 1px solid var(--border-sage);
  border-radius: 6px 0 0 6px;
  padding: 8px 6px;
}

.m-lbl {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 700;
}

.m-val {
  font-family: var(--font-head);
  font-size: 24px;
  color: var(--text-main);
  font-weight: 700;
}

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

.overlay-btn-row .fletch-btn {
  flex: 1;
  min-height: 38px;
  font-size: 13px;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 13, 9, 0.85);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  z-index: 50;
}

.modal-frame {
  width: 100%;
  max-width: 430px;
  max-height: 88vh;
  background: #0F241B;
  border: 2px solid var(--gold);
  border-radius: 8px 0 0 8px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.75);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: #091711;
  border-bottom: 1.5px solid var(--border-sage);
}

.modal-head h2 {
  font-family: var(--font-head);
  font-size: 24px;
  line-height: 1;
  color: var(--gold-bright);
  letter-spacing: 0.6px;
}

.modal-close-btn {
  background: #1C3D2E;
  color: var(--text-main);
  border: 1px solid var(--border-sage);
  border-radius: 4px 0 0 4px;
  width: 30px;
  height: 30px;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}

.modal-body {
  padding: 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-lead {
  font-size: 13px;
  line-height: 1.4;
  color: var(--text-muted);
}

/* Ballistic Calculator & Table */
.calc-panel {
  background: #091610;
  border: 1.5px solid var(--border-sage);
  border-left: 3px solid var(--gold);
  border-radius: 6px 0 0 6px;
  padding: 10px;
}

.calc-title {
  font-size: 12px;
  font-weight: 800;
  color: var(--gold-bright);
  margin-bottom: 8px;
  letter-spacing: 0.5px;
}

.calc-controls {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-bottom: 10px;
}

.calc-field {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.calc-field span {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
}

.calc-field input,
.form-field select,
.form-field textarea {
  background: #132C21;
  border: 1px solid var(--border-sage);
  border-radius: 4px 0 0 4px;
  color: var(--text-main);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 700;
  padding: 6px 8px;
  outline: none;
}

.calc-results {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.calc-res-item {
  background: #132C21;
  padding: 6px;
  border-radius: 4px 0 0 4px;
  text-align: center;
}

.calc-res-item span {
  display: block;
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 700;
}

.calc-res-item strong {
  font-size: 13px;
  color: var(--emerald);
}

.table-scroll {
  overflow-x: auto;
}

.ballistic-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.ballistic-table th,
.ballistic-table td {
  padding: 7px 6px;
  text-align: center;
  border-bottom: 1px solid var(--border-sage);
}

.ballistic-table th {
  background: #091610;
  color: var(--gold-bright);
  font-weight: 800;
}

.target-legend {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #091610;
  border: 1px solid var(--border-sage);
  border-radius: 6px 0 0 6px;
  padding: 6px;
}

.legend-item img {
  width: 34px;
  height: 34px;
  object-fit: contain;
  flex-shrink: 0;
}

.legend-item strong {
  display: block;
  font-size: 12px;
  color: var(--text-main);
}

.legend-item span {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
}

/* Settings Sections */
.settings-section {
  background: #091711;
  border: 1px solid var(--border-sage);
  border-radius: 6px 0 0 6px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sec-heading {
  font-family: var(--font-head);
  font-size: 19px;
  color: var(--gold-bright);
  letter-spacing: 0.6px;
  border-bottom: 1px solid var(--border-sage);
  padding-bottom: 4px;
}

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

.toggle-row strong {
  display: block;
  font-size: 13px;
}

.toggle-row span {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
}

.version-strip {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  background: #132C21;
  padding: 7px 10px;
  border-radius: 4px 0 0 4px;
}

.rate-box {
  background: #132C21;
  padding: 10px;
  border-radius: 6px 0 0 6px;
  text-align: center;
}

.rate-lbl {
  display: block;
  font-size: 12px;
  font-weight: 800;
  color: var(--gold-bright);
  margin-bottom: 6px;
}

.star-row {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 4px;
}

.star-btn {
  background: #091711;
  border: 1px solid var(--border-sage);
  border-radius: 4px 0 0 4px;
  color: #476B59;
  font-size: 20px;
  width: 36px;
  height: 34px;
  cursor: pointer;
}

.star-btn.active {
  color: var(--gold-bright);
  border-color: var(--gold);
}

.rate-status {
  font-size: 12px;
  color: var(--text-muted);
}

.settings-btn-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.support-form {
  background: #132C21;
  padding: 10px;
  border-radius: 6px 0 0 6px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-field span {
  font-size: 11px;
  font-weight: 700;
  color: var(--gold-bright);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

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

.legal-scroll-box {
  background: #091610;
  border: 1px solid var(--border-sage);
  border-radius: 6px 0 0 6px;
  padding: 12px;
  max-height: 55vh;
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-muted);
}

.legal-scroll-box h4 {
  color: var(--gold-bright);
  margin: 10px 0 4px;
  font-size: 14px;
}

.toast-banner {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--gold);
  color: #07140E;
  font-size: 13px;
  font-weight: 800;
  padding: 9px 18px;
  border-radius: 6px 0 0 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  z-index: 90;
  white-space: nowrap;
}

.hidden {
  display: none !important;
}


/* === 2026 STUDIO POLISH & ZERO-ELLIPSIS AUTO-FIT === */
button, .tab-btn, [role="tab"], .skew-btn, .hex-btn, .plaque-btn, .jewel-btn, .jewel-tab,
.chevron-btn, .chevron-tab, .bead-key, .pebble-btn, .ticket-btn, .stamp-btn, .program-btn,
.fletch-btn, .dist-plate, .concave-btn, .brut-btn, .oct-btn, .nav-slip, .filter-slip,
.awning-btn, .kermis-tab {
  font-size: clamp(11px, 3.1vw, 14px);
  line-height: 1.2;
  overflow-wrap: break-word;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), 0 8px 20px rgba(0, 0, 0, 0.35);
  transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

button:active, .tab-btn:active, [role="tab"]:active, .hex-btn:active, .plaque-btn:active,
.jewel-btn:active, .jewel-tab:active, .chevron-btn:active, .chevron-tab:active,
.bead-key:active, .pebble-btn:active, .ticket-btn:active, .stamp-btn:active,
.program-btn:active, .fletch-btn:active, .dist-plate:active, .concave-btn:active,
.medallion-btn:active, .brut-btn:active, .oct-btn:active, .nav-slip:active,
.filter-slip:active, .awning-btn:active, .kermis-tab:active {
  transform: scale(0.95);
}

header, .top-bar, .hud-bar, .card, .glass-panel, .modal-card, .settings-group,
.stat-pill, .hud-pill, .badge, .toast, #toast {
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), 0 8px 20px rgba(0, 0, 0, 0.35);
}

p, .subtitle, .banner-text, .desc, .toast, #toast, .hint-box, .clue-text, .status-banner {
  white-space: normal;
  overflow-wrap: break-word;
}


/* === 2026 STUDIO PREMIUM UI POLISH === */
button, .btn, [role="button"], .mode-btn, .nav-plaque, .vessel-tile {
  transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.22s ease, filter 0.18s ease !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), inset 0 -1px 0 rgba(0, 0, 0, 0.38), 0 6px 18px -4px rgba(0, 0, 0, 0.45);
}
button:hover, .btn:hover, .mode-btn:hover, .nav-plaque:hover {
  filter: brightness(1.07);
}
button:active, .btn:active, [role="button"]:active, .mode-btn:active, .nav-plaque:active, .vessel-tile:active {
  transform: scale(0.95) translateY(1px) !important;
  filter: brightness(1.12);
}
@keyframes studioScorePop2026 {
  0% { transform: scale(1); }
  40% { transform: scale(1.22); filter: drop-shadow(0 0 8px rgba(251, 191, 36, 0.75)); }
  100% { transform: scale(1); }
}
.studio-score-pop {
  display: inline-block;
  animation: studioScorePop2026 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}
