/* ==============================================================================
   HimalTrex: Summit Trail — Desktop Launcher Style (Himalayan Theme)
   Palette: Dark Himalayan Slate, Tibetan Gold, Turquoise, Warm Sand
   ============================================================================== */

:root {
  --bg-dark: #0b1118;
  --bg-dark-secondary: #131b24;
  --bg-card: rgba(20, 28, 38, 0.92);
  --bg-card-border: rgba(212, 168, 83, 0.28);
  --gold-primary: #d4a853;
  --gold-glow: rgba(212, 168, 83, 0.4);
  --gold-bright: #fbbf24;
  --text-main: #f0f4f8;
  --text-muted: #9baec2;
  --board-bed: #c2410c;
  --trail-sand: #fef08a;
  --font-family: 'Outfit', system-ui, -apple-system, sans-serif;
  --radius-card: 14px;
}

* {
  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%;
  font-family: var(--font-family);
  background-color: var(--bg-dark);
  background-image: 
    radial-gradient(circle at 50% 8%, rgba(212, 168, 83, 0.12) 0%, transparent 45%),
    radial-gradient(circle at 10% 90%, rgba(245, 158, 11, 0.06) 0%, transparent 40%),
    radial-gradient(circle at 90% 90%, rgba(56, 189, 248, 0.06) 0%, transparent 40%);
  color: var(--text-main);
  overflow: hidden; /* no page scroll — board fills viewport */
  display: flex;
  flex-direction: column;
}

/* ==============================================================================
   TOP HEADER (Launcher Portal Style)
   ============================================================================== */
.game-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 24px;
  background: rgba(11, 17, 24, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--bg-card-border);
  z-index: 50;
  height: 54px;
  flex-shrink: 0;
}

.top-bar-left, .top-bar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.12rem;
  font-weight: 800;
  color: var(--gold-primary);
  text-decoration: none;
  letter-spacing: 0.6px;
}

.brand-badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 8px;
  background: rgba(212, 168, 83, 0.16);
  border: 1px solid rgba(212, 168, 83, 0.45);
  border-radius: 12px;
  color: #fce8b3;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.top-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 9px;
  color: var(--text-main);
  font-size: 0.82rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.18s ease;
}

.top-btn:hover {
  background: rgba(212, 168, 83, 0.18);
  border-color: rgba(212, 168, 83, 0.5);
  color: #ffffff;
  transform: translateY(-1px);
}

.top-btn:active {
  transform: scale(0.96);
}

.profile-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 0.82rem;
  font-weight: 700;
}

.pill-avatar {
  font-size: 1.1rem;
}

.coins-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(212, 168, 83, 0.12);
  border: 1px solid rgba(212, 168, 83, 0.4);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 0.82rem;
  font-weight: 800;
  color: #fde047;
}

/* ==============================================================================
   TIBETAN PRAYER FLAGS GARLAND (Inherited from himaltrex-profile.css)
   ============================================================================== */

/* ==============================================================================
   DESKTOP WORKSPACE (2-Column Layout: sidebar + board)
   ============================================================================== */
.trail-app-workspace {
  flex: 1;
  display: grid;
  grid-template-columns: 290px 1fr;
  gap: 20px;
  padding: 12px 24px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  min-height: 0; /* allow grid children to shrink */
  overflow: hidden;
  align-items: stretch; /* both columns fill full row height */
}

/* Desktop Sidebar Layout */
.trail-sidebar, .sidebar-left {
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(212,168,83,0.3) transparent;
  justify-content: flex-start;
}

/* ==============================================================================
   PANEL CARDS (Launcher Style)
   ============================================================================== */
.panel-card {
  background: var(--bg-card);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-card);
  padding: 14px 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  gap: 10px;
  backdrop-filter: blur(10px);
}

.card-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--gold-primary);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  border-bottom: 1px solid rgba(212, 168, 83, 0.18);
  padding-bottom: 6px;
}


.level-pill {
  background: #334155;
  color: #ffffff;
  font-size: 0.68rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 8px;
  letter-spacing: 0.6px;
}

.peak-details-box {
  display: flex;
  align-items: center;
  gap: 12px;
}

.peak-icon-emblem {
  font-size: 2.2rem;
  line-height: 1;
}

.peak-name {
  font-size: 1.35rem;
  font-weight: 900;
  color: #ffffff;
  letter-spacing: 0.5px;
  line-height: 1.15;
}

.peak-altitude {
  font-size: 0.8rem;
  font-weight: 700;
  color: #fbbf24;
}

.peak-brief {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.35;
}

/* Stats Counter Grid */
.stats-counters-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 100%;
}

.stat-box {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 7px 10px;
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;       /* critical: let flexbox shrink below content size */
  overflow: hidden;
}

.stat-icon {
  font-size: 1.3rem;
  line-height: 1;
  flex-shrink: 0;
}

.stat-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.stat-label {
  font-size: 0.6rem;
  font-weight: 800;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.stat-val {
  font-size: 1.15rem;
  font-weight: 900;
  color: #ffffff;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Hearts display fits tighter */
.hearts-val-text {
  font-size: 0.78rem;
  letter-spacing: 0px;
}

/* Actions Stack */
.actions-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hud-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  color: #ffffff;
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.16s ease;
}

.hud-action-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(212, 168, 83, 0.4);
  transform: translateY(-1px);
}

.hud-action-btn:active {
  transform: scale(0.97);
}

.hud-action-btn.primary {
  background: linear-gradient(135deg, #d97706, #b45309);
  border-color: #f59e0b;
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(217, 119, 6, 0.35);
}

.hud-action-btn.primary:hover {
  background: linear-gradient(135deg, #f59e0b, #d97706);
}

.hud-action-btn.danger {
  background: rgba(220, 38, 38, 0.14);
  border-color: rgba(220, 38, 38, 0.35);
  color: #fca5a5;
}

.hud-action-btn.danger:hover {
  background: rgba(220, 38, 38, 0.28);
}

.hud-action-btn.rules-btn {
  background: rgba(42, 157, 143, 0.16);
  border-color: rgba(42, 157, 143, 0.45);
  color: #5eead4;
}

.hud-action-btn.rules-btn:hover {
  background: rgba(42, 157, 143, 0.32);
  border-color: #2a9d8f;
  box-shadow: 0 4px 14px rgba(42, 157, 143, 0.28);
}

.hud-action-btn.actions-spaced {
  margin-top: 10px;
}

/* ==============================================================================
   CENTER COLUMN: GAME BOARD
   ============================================================================== */
.trail-center-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 24px 0 16px 0;
}

/* Board: always square, fills all available space in the center column */
.grid-board-frame {
  position: relative;
  z-index: 5;
  width: min(calc(100vh - 190px), calc(100vw - 360px), 640px);
  height: min(calc(100vh - 190px), calc(100vw - 360px), 640px);
  aspect-ratio: 1 / 1;
  background: #cbd5e1;
  padding: 3px;
  border-radius: 14px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  border: 2.5px solid rgba(212, 168, 83, 0.45);
  transition: width 0.25s ease, height 0.25s ease;
}

.trail-grid-6x6 {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-template-rows: repeat(6, 1fr);
  width: 100%;
  height: 100%;
  gap: 1.5px;
  background-color: #94a3b8;
  border-radius: 10px;
  overflow: hidden;
}

/* Summit Pinnacle */
.summit-pinnacle {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: absolute;
  z-index: 15;
  top: -48px;
  left: calc((var(--col, 2) + 0.5) * (100% / var(--grid-size, 6)));
  transform: translateX(-50%);
  transition: left 0.32s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}

.summit-rock-base {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

.flag-pole {
  width: 3px;
  height: 22px;
  background-color: #0f172a;
  position: relative;
  border-radius: 1px;
}

.summit-flag-banner {
  position: absolute;
  top: 0;
  left: 3px;
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 18px solid #ea580c;
  animation: flagFlutter 2s infinite alternate ease-in-out;
}

@keyframes flagFlutter {
  0% { transform: skewY(0deg) scaleX(1); }
  100% { transform: skewY(-6deg) scaleX(0.92); }
}

.summit-rock-svg {
  margin-top: -3px;
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.4));
}

.summit-badge-label {
  background: #1e293b;
  border: 1px solid rgba(212, 168, 83, 0.4);
  color: #ffffff;
  font-size: 0.68rem;
  font-weight: 800;
  padding: 2px 10px;
  border-radius: 6px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.35);
  margin-top: -3px;
  letter-spacing: 0.5px;
}

/* Base Camp Tent */
.basecamp-dock {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: absolute;
  z-index: 15;
  bottom: -34px;
  left: calc((var(--col, 2) + 0.5) * (100% / var(--grid-size, 6)));
  transform: translateX(-50%);
  transition: left 0.32s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}

.tent-illustration {
  line-height: 1;
  filter: drop-shadow(0 3px 8px rgba(0, 0, 0, 0.45));
}

.basecamp-badge-label {
  background: #1e293b;
  border: 1px solid rgba(212, 168, 83, 0.4);
  color: #ffffff;
  font-size: 0.68rem;
  font-weight: 800;
  padding: 2px 10px;
  border-radius: 6px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.35);
  margin-top: -5px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
}

/* Individual Cell Tile */
.trail-tile {
  position: relative;
  width: 100%;
  height: 100%;
  cursor: pointer;
  overflow: hidden;
  background-color: #e2e8f0;
  transition: filter 0.15s ease;
}

.trail-tile.static-tile {
  cursor: default;
}

.trail-tile:not(.static-tile):hover {
  filter: brightness(1.08);
}

.trail-tile:not(.static-tile):active {
  transform: scale(0.97);
}

/* Scenery Layer */
.tile-scenery-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

/* Trail Road Segment Layer */
.tile-path-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
  transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Active Trail Connection Highlighting - Vivid Golden Assembled Route */
.trail-tile.connected .road-bed,
.trail-tile.connected .tile-path-svg rect[fill="#f3e7bb"],
.trail-tile.connected .tile-path-svg path[fill="#f3e7bb"] {
  fill: #f59e0b !important; /* Radiant Himalayan Expedition Gold */
  stroke: #b45309 !important;
  transition: fill 0.22s ease, stroke 0.22s ease;
}

.trail-tile.connected .road-line,
.trail-tile.connected .tile-path-svg line[stroke="#ffffff"],
.trail-tile.connected .tile-path-svg path[stroke="#ffffff"] {
  stroke: #ffffff !important;
  stroke-width: 3.5px !important;
  filter: drop-shadow(0 0 3px #ffffff) drop-shadow(0 0 8px #f59e0b) !important;
}

/* Connected Wooden Bridge Highlighting */
.trail-tile.connected .tile-path-svg rect[fill="#8b5e2d"] {
  fill: #b45309 !important;
  stroke: #78350f !important;
}

.trail-tile.connected .tile-path-svg rect[fill="#a1743f"],
.trail-tile.connected .tile-path-svg rect[fill="#ba8b52"] {
  fill: #d97706 !important;
}

.trail-tile.connected .tile-path-svg {
  filter: drop-shadow(0 0 8px rgba(245, 158, 11, 0.95)) drop-shadow(0 0 16px rgba(251, 191, 36, 0.6)) !important;
  transition: filter 0.22s ease;
}

.trail-tile.connected::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 6;
  box-shadow: inset 0 0 12px rgba(245, 158, 11, 0.35);
  border-radius: 2px;
}

.trail-tile.hint-pulse {
  animation: hintPulseAnim 0.8s ease-out;
}

@keyframes hintPulseAnim {
  0% { transform: scale(1); filter: brightness(1); }
  50% { transform: scale(1.08); filter: brightness(1.35) drop-shadow(0 0 12px #fbbf24); }
  100% { transform: scale(1); filter: brightness(1); }
}

/* No hints left — shake + red flash */
.shake-no {
  animation: shakeNoAnim 0.45s ease-out;
}

@keyframes shakeNoAnim {
  0%   { transform: translateX(0);    background: inherit; }
  15%  { transform: translateX(-6px); background: rgba(239,68,68,0.35); }
  35%  { transform: translateX(6px);  background: rgba(239,68,68,0.25); }
  55%  { transform: translateX(-4px); background: rgba(239,68,68,0.15); }
  75%  { transform: translateX(4px);  background: rgba(239,68,68,0.08); }
  100% { transform: translateX(0);    background: inherit; }
}

/* ==============================================================================
   RIGHT SIDEBAR (Legend & Catalog)
   ============================================================================== */
.legend-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.76rem;
  background: rgba(255, 255, 255, 0.03);
  padding: 5px 8px;
  border-radius: 7px;
}

.legend-icon {
  font-size: 1.15rem;
  line-height: 1;
}

.legend-info {
  display: flex;
  flex-direction: column;
}

.legend-info strong {
  color: #ffffff;
  font-weight: 700;
}

.legend-info span {
  color: var(--text-muted);
  font-size: 0.7rem;
}

/* Peaks Catalog */
.peaks-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 180px;
  overflow-y: auto;
  padding-right: 4px;
}

.peaks-list::-webkit-scrollbar {
  width: 4px;
}
.peaks-list::-webkit-scrollbar-thumb {
  background: rgba(212, 168, 83, 0.3);
  border-radius: 4px;
}

.peak-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 6px;
  font-size: 0.74rem;
  color: var(--text-muted);
}

.peak-item-row.active {
  background: rgba(212, 168, 83, 0.15);
  border: 1px solid rgba(212, 168, 83, 0.4);
  color: #fbbf24;
  font-weight: 800;
}

/* ==============================================================================
   MODALS (Victory & Rules)
   ============================================================================== */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(5, 10, 16, 0.82);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100000;
  animation: fadeIn 0.2s ease;
}

.modal-backdrop.active,
.modal-backdrop.open {
  display: flex !important;
}

.modal-dialog {
  background: #151d28;
  border: 1.5px solid var(--bg-card-border);
  border-radius: 20px;
  padding: 24px;
  width: 90%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8), 0 0 35px rgba(245, 158, 11, 0.15);
  text-align: center;
  animation: popIn 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  z-index: 1;
}

/* ── Result stars (Three Stars: center is larger and elevated) ── */
.victory-stars-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

.result-stars {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 16px;
  height: 70px;
  margin-bottom: 6px;
}

.result-stars .star {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  user-select: none;
  transition: all 0.3s ease;
}

.result-stars .star-side {
  font-size: 2.3rem;
  transform: translateY(2px) scale(0.92);
  opacity: 0.95;
  filter: drop-shadow(0 4px 10px rgba(247, 201, 72, 0.5));
  animation: starPopSide 0.45s ease backwards;
}

.result-stars .star-left {
  animation-delay: 0.05s;
}

.result-stars .star-right {
  animation-delay: 0.25s;
}

.result-stars .star-center {
  font-size: 3.6rem;
  transform: translateY(-10px) scale(1.18);
  filter: drop-shadow(0 6px 20px rgba(247, 201, 72, 0.85));
  animation: starPopCenter 0.5s ease 0.15s backwards, starGlow 2.2s infinite ease-in-out 0.65s;
  z-index: 2;
}

.result-stars .star.star-empty {
  opacity: 0.22 !important;
  filter: grayscale(1) !important;
  transform: translateY(2px) scale(0.85) !important;
  animation: none !important;
}

.result-stars .star-center.star-empty {
  transform: translateY(-4px) scale(0.95) !important;
}

.victory-stars-subtext {
  font-size: 0.86rem;
  font-weight: 800;
  color: #fbbf24;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: 20px;
  padding: 4px 14px;
}

@keyframes starPopCenter {
  0% { transform: translateY(14px) scale(0); opacity: 0; }
  65% { transform: translateY(-16px) scale(1.3); opacity: 1; }
  100% { transform: translateY(-10px) scale(1.18); opacity: 1; }
}

@keyframes starPopSide {
  0% { transform: translateY(14px) scale(0); opacity: 0; }
  65% { transform: translateY(-2px) scale(1.05); opacity: 1; }
  100% { transform: translateY(2px) scale(0.92); opacity: 1; }
}

@keyframes starGlow {
  0%, 100% { filter: drop-shadow(0 6px 18px rgba(247, 201, 72, 0.75)); }
  50% { filter: drop-shadow(0 8px 26px rgba(247, 201, 72, 1)); }
}

.victory-trophy-icon {
  font-size: 3.2rem;
  line-height: 1;
  margin-bottom: 6px;
  animation: bounceTrophy 1.5s infinite alternate ease-in-out;
}

@keyframes bounceTrophy {
  0% { transform: scale(1) translateY(0); }
  100% { transform: scale(1.1) translateY(-6px); }
}

.victory-header-title {
  font-size: 1.7rem;
  font-weight: 900;
  color: #fbbf24;
  letter-spacing: 0.6px;
  margin-bottom: 4px;
}

.victory-route-desc {
  font-size: 1.05rem;
  font-weight: 800;
  color: #ffffff;
  margin-bottom: 4px;
}

.victory-altitude-pill {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.victory-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}

.v-stat-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.v-label {
  font-size: 0.68rem;
  font-weight: 800;
  color: var(--text-muted);
}

.v-val {
  font-size: 1.35rem;
  font-weight: 900;
  color: #ffffff;
}

.v-val.gold {
  color: #f59e0b;
}

.v-val.cyan {
  color: #38bdf8;
}

/* Confetti canvas overlay (inside modal-backdrop, behind dialog) */
.confetti-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

/* Ensure dialog sits above confetti */
.victory-dialog {
  position: relative;
  z-index: 1;
}

.victory-btn-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.v-btn {
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
  border: none;
  transition: all 0.16s ease;
}

.v-btn.primary {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #ffffff;
  box-shadow: 0 4px 18px rgba(245, 158, 11, 0.4);
}

.v-btn.primary:hover {
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  transform: translateY(-2px);
}

.v-btn.secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.v-btn.secondary:hover {
  background: rgba(255, 255, 255, 0.14);
}

/* Rules Modal */
.rules-dialog {
  text-align: left;
  max-width: 740px;
  max-height: 88vh;
  overflow-y: auto;
}

.trail-rules-intro {
  background: rgba(212, 168, 83, 0.08);
  border: 1px solid rgba(212, 168, 83, 0.28);
  border-radius: 10px;
  padding: 9px 14px;
  margin-bottom: 10px;
  font-size: 0.85rem;
  line-height: 1.4;
  text-align: center;
  color: #e2e8f0;
}

.trail-rules-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: stretch;
  gap: 10px;
}

.trail-rules-card {
  background: rgba(11, 16, 22, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 11px 14px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.trail-rules-card-wide {
  grid-column: 1 / -1;
}

.trail-rules-card-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--gold-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.trail-rules-card-text {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.45;
  color: #cbd5e1;
}

.tc-gold   { color: #facc15; font-weight: 700; }
.tc-cyan   { color: #38bdf8; font-weight: 700; }
.tc-green  { color: #4ade80; font-weight: 700; }
.tc-orange { color: #fb923c; font-weight: 700; }

@media (max-width: 640px) {
  .trail-rules-grid {
    grid-template-columns: 1fr;
  }
}

.modal-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(212, 168, 83, 0.2);
  padding-bottom: 10px;
  margin-bottom: 12px;
}

.modal-header-row h3 {
  color: var(--gold-primary);
  font-size: 1.15rem;
  font-weight: 800;
}

.close-modal-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.6rem;
  cursor: pointer;
}

.rules-body {
  font-size: 0.85rem;
  color: #cbd5e1;
  line-height: 1.5;
}

.rules-body h4 {
  color: #fbbf24;
  margin-bottom: 4px;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes popIn {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

/* ==============================================================================
   TIMER & ATTEMPTS STYLES
   ============================================================================== */
.timer-val-text {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.5px;
}

#timerBox.warning .timer-val-text {
  color: #f59e0b;
}

#timerBox.danger .timer-val-text {
  color: #ef4444;
  animation: timerBlink 0.65s infinite alternate ease-in-out;
}

#timerBox.bonus-pulse {
  animation: timerBonusFlash 0.9s ease-out;
}

@keyframes timerBlink {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.08); opacity: 0.55; }
}

@keyframes timerBonusFlash {
  0% { transform: scale(1); box-shadow: 0 0 0 rgba(34, 197, 94, 0); }
  50% { transform: scale(1.06); box-shadow: 0 0 16px rgba(34, 197, 94, 0.8); }
  100% { transform: scale(1); box-shadow: 0 0 0 rgba(34, 197, 94, 0); }
}



/* ==============================================================================
   TREASURE BONUS TOAST & FLOATING CELL BONUS
   ============================================================================== */
.treasure-toast {
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%) translateY(-30px);
  background: rgba(20, 28, 38, 0.95);
  border: 1.5px solid #f59e0b;
  box-shadow: 0 10px 30px rgba(245, 158, 11, 0.35);
  padding: 10px 22px;
  border-radius: 30px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 120;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.treasure-toast.active {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast-gem {
  font-size: 1.8rem;
  line-height: 1;
  animation: gemSpin 1s ease-in-out;
}

@keyframes gemSpin {
  0% { transform: scale(0.4) rotate(-30deg); }
  60% { transform: scale(1.3) rotate(15deg); }
  100% { transform: scale(1) rotate(0deg); }
}

.toast-text {
  display: flex;
  flex-direction: column;
}

.toast-text strong {
  color: #fbbf24;
  font-size: 0.95rem;
  font-weight: 800;
}

.toast-text span {
  color: #cbd5e1;
  font-size: 0.78rem;
}

/* Floating animation on the tile where treasure is found */
.floating-cell-bonus {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1rem;
  font-weight: 900;
  color: #fbbf24;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.8);
  pointer-events: none;
  z-index: 20;
  white-space: nowrap;
  animation: floatBonusUp 1.2s forwards cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes floatBonusUp {
  0% { transform: translate(-50%, -10%) scale(0.6); opacity: 0; }
  25% { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
  75% { transform: translate(-50%, -110%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -160%) scale(0.9); opacity: 0; }
}

/* ==============================================================================
   TIME UP & GAME OVER MODALS
   ============================================================================== */
.timeup-dialog, .gameover-dialog {
  max-width: 400px;
}

.timeup-icon, .gameover-icon {
  font-size: 3rem;
  margin-bottom: 6px;
  line-height: 1;
}

.timeup-title {
  color: #ef4444;
  font-size: 1.65rem;
  font-weight: 900;
  margin-bottom: 6px;
}

.gameover-title {
  color: #f87171;
  font-size: 1.65rem;
  font-weight: 900;
  margin-bottom: 6px;
}

.timeup-desc, .gameover-desc {
  color: #cbd5e1;
  font-size: 0.92rem;
  margin-bottom: 16px;
  line-height: 1.4;
}

.attempts-hearts-row {
  display: flex;
  justify-content: center;
  gap: 8px;
  font-size: 1.6rem;
  margin-bottom: 20px;
}

.timeup-btn-stack, .gameover-btn-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ==============================================================================
   BOTTOM PEAKS STRIP
   ============================================================================== */
.peaks-bottom-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(13, 21, 32, 0.92);
  border-top: 1px solid rgba(212, 168, 83, 0.25);
  padding: 0 20px;
  height: 46px;
  flex-shrink: 0;
  overflow: hidden;
}

.peaks-strip-label {
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--gold-primary);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  white-space: nowrap;
  flex-shrink: 0;
}

.peaks-strip-list {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  flex: 1;
  padding: 4px 0;
}

.peaks-strip-list::-webkit-scrollbar { display: none; }

.peak-strip-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 0.72rem;
  font-weight: 700;
  color: #94a3b8;
  white-space: nowrap;
  cursor: default;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.peak-strip-chip.done {
  background: rgba(34, 197, 94, 0.12);
  border-color: rgba(34, 197, 94, 0.35);
  color: #4ade80;
}

.peak-strip-chip.done::before {
  content: '✅';
  font-size: 0.75rem;
}

.peak-strip-chip.active {
  background: rgba(245, 164, 37, 0.18);
  border-color: rgba(245, 164, 37, 0.55);
  color: #fbbf24;
  box-shadow: 0 0 8px rgba(245, 164, 37, 0.3);
}

.peak-strip-chip.active::before {
  content: '🧗';
  font-size: 0.75rem;
}

.peak-strip-chip.locked {
  opacity: 0.45;
  cursor: not-allowed;
}

.peak-strip-chip.locked::before {
  content: '🔒';
  font-size: 0.65rem;
}

/* ==============================================================================
   RULES LEGEND (inside Rules modal)
   ============================================================================== */
.rules-legend {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}

.rules-legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  color: #cbd5e1;
}

.rules-legend-item span {
  font-size: 1.1rem;
  flex-shrink: 0;
  width: 22px;
  text-align: center;
}

/* Mountain backdrop art matches the height of the first sidebar card */
.mountain-backdrop-art {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 174px;
  margin-bottom: 0;
  pointer-events: none;
  z-index: 1;
}

.mountain-backdrop-art svg {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 14px;
}

/* ==============================================================================
   RESPONSIVE LAYOUT (Mobile, Tablet & Narrow Windows)
   ============================================================================== */

@media (max-width: 960px) {
  .trail-app-workspace {
    grid-template-columns: 240px 1fr;
    gap: 12px;
    padding: 8px 14px;
  }

  .grid-board-frame {
    width: min(calc(100vh - 150px), calc(100vw - 280px), 560px);
    height: min(calc(100vh - 150px), calc(100vw - 280px), 560px);
  }
}

/* ── Screen Width <= 768px: Mobile / Narrow Vertical Stack ── */
@media (max-width: 768px) {
  html, body {
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
  }

  /* Compact Top Header */
  .game-top-bar {
    height: 44px;
    padding: 4px 10px;
  }

  .brand-title {
    font-size: 0.92rem;
    gap: 6px;
  }

  .brand-badge {
    display: none;
  }

  .coins-pill {
    display: none;
  }

  .top-btn {
    padding: 4px 8px;
    font-size: 0.72rem;
  }

  .profile-pill {
    padding: 2px 8px;
    font-size: 0.75rem;
  }

  /* Prayer flags thin */
  .prayer-flags-decor {
    height: 8px;
  }

  /* Workspace becomes a vertical flex column */
  .trail-app-workspace {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 4px !important;
    padding: 4px 8px !important;
    width: 100% !important;
    max-width: 100% !important;
    flex: 1 !important;
    min-height: 0 !important;
    overflow: hidden !important;
  }

  /* Compact HUD bar replaces full desktop sidebar */
  .trail-sidebar,
  .sidebar-left {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    flex-shrink: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 4px !important;
    padding: 0 !important;
    overflow: visible !important;
  }

  /* Hide the large peak objective card on mobile — peak is already highlighted in bottom strip */
  .peak-card {
    display: none !important;
  }

  /* Hide card headers on mobile to maximize board vertical space */
  .card-heading {
    display: none !important;
  }

  /* Panel cards become thin, compact horizontal containers */
  .panel-card {
    padding: 4px 6px !important;
    border-radius: 8px !important;
    gap: 0 !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25) !important;
  }

  /* Stats grid: 4 columns in one thin row */
  .stats-counters-grid {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 4px !important;
    width: 100% !important;
  }

  .stat-box {
    padding: 2px 4px !important;
    border-radius: 6px !important;
    justify-content: center !important;
    gap: 4px !important;
  }

  .stat-icon {
    font-size: 0.82rem !important;
  }

  .stat-col {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.1 !important;
  }

  .stat-label {
    font-size: 0.52rem !important;
    letter-spacing: 0.3px;
  }

  .stat-val {
    font-size: 0.8rem !important;
    font-weight: 800 !important;
  }

  .timer-val-text,
  .hearts-val-text {
    font-size: 0.82rem !important;
  }

  /* Actions buttons: 3 horizontal buttons in a thin row */
  .actions-stack {
    display: flex !important;
    flex-direction: row !important;
    gap: 4px !important;
    width: 100% !important;
  }

  .hud-action-btn {
    flex: 1 !important;
    padding: 5px 6px !important;
    font-size: 0.72rem !important;
    border-radius: 6px !important;
    justify-content: center !important;
    gap: 4px !important;
  }

  .hud-action-btn.actions-spaced {
    margin-top: 0 !important;
    margin-left: 6px !important;
  }

  /* Center Stage: takes all remaining height, perfectly centered */
  .trail-center-stage {
    flex: 1 !important;
    min-height: 0 !important;
    width: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    position: relative !important;
    padding: 24px 0 20px 0 !important;
  }

  .mountain-backdrop-art {
    display: none !important;
  }

  /* ══ BOARD: FROM FRAME TO FRAME ("от рамки до рамки, как резиновое") ══ */
  .grid-board-frame {
    width: min(calc(100vw - 12px), calc(100vh - 180px)) !important;
    height: min(calc(100vw - 12px), calc(100vh - 180px)) !important;
    max-width: calc(100vw - 12px) !important;
    max-height: calc(100vh - 180px) !important;
    aspect-ratio: 1 / 1 !important;
    border-radius: 10px !important;
    padding: 2px !important;
  }

  /* Summit marker tight on mobile */
  .summit-pinnacle {
    top: -32px !important;
  }

  .summit-rock-svg {
    width: 44px !important;
    height: 18px !important;
  }

  .flag-pole {
    height: 16px !important;
  }

  .summit-badge-label,
  .basecamp-badge-label {
    font-size: 0.56rem !important;
    padding: 1px 6px !important;
    margin-top: -2px !important;
  }

  .basecamp-dock {
    bottom: -24px !important;
  }

  .tent-illustration svg {
    width: 42px !important;
    height: 30px !important;
  }

  /* ══ BOTTOM PEAKS STRIP: ALWAYS VISIBLE AND HORIZONTALLY SCROLLABLE ══ */
  .peaks-bottom-strip {
    height: 40px !important;
    padding: 0 8px !important;
    gap: 6px !important;
    background: rgba(13, 21, 32, 0.98) !important;
    border-top: 1px solid rgba(212, 168, 83, 0.3) !important;
    flex-shrink: 0 !important;
    z-index: 50 !important;
  }

  .peaks-strip-label {
    font-size: 0.65rem !important;
  }

  .peaks-strip-list {
    gap: 5px !important;
    padding: 2px 0 !important;
  }

  .peak-strip-chip {
    padding: 2px 8px !important;
    font-size: 0.68rem !important;
    border-radius: 14px !important;
  }
}

/* ── Screen Width <= 420px (Ultra-narrow mobile) ── */
@media (max-width: 420px) {
  .trail-app-workspace {
    padding: 2px 4px !important;
    gap: 3px !important;
  }

  .grid-board-frame {
    width: min(calc(100vw - 8px), calc(100vh - 170px)) !important;
    height: min(calc(100vw - 8px), calc(100vh - 170px)) !important;
    max-width: calc(100vw - 8px) !important;
    max-height: calc(100vh - 170px) !important;
    border-radius: 8px !important;
  }

  .hud-action-btn span {
    font-size: 0.68rem !important;
  }

  .brand-title span:first-child {
    font-size: 0.82rem;
  }

  #btnBackToPortal span {
    font-size: 0.7rem;
  }

  #heroProfileName {
    display: none;
  }
}
