/* ============================================
   TheWorldsBillboard - OPTIMIZED STYLESHEET
   ============================================ */

/* Font Face */
@font-face {
  font-family: 'MyFont';
  font-style: normal;
  font-weight: normal;
  src: url(fonts/interfont/Inter_18pt-Regular.ttf) format('truetype');
}

/* CSS Variables */
:root {
  --accent-color: #b8860b;
  --accent-dark: #8a6508;
  --accent-soft: #f7edd1;
  --bg: #f7f7f8;
  --font-main: 'MyFont', Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
  --glass: rgba(255, 255, 255, 0.7);
  --glass-border: rgba(200, 200, 205, 0.35);
  --gold-silver: linear-gradient(135deg, #ffefc3 0%, #f6f6f6 50%, #f8f8f8 100%);
  --muted: #9aa0a6;
  --panel: #ffffff;
  --radius-lg: 28px;
  --radius-md: 16px;
  --shadow-1: 0 6px 18px rgba(15, 18, 20, 0.06);
  --shadow-2: 0 4px 10px rgba(15, 18, 20, 0.04);
  --modal-z-index: 1300;
  --modal-bg: #ffffff;
  --modal-text-main: #1a1a1a;
  --modal-text-sub: #555555;
  --modal-accent: 184, 134, 11;
  /* RGB for GoldenRod */
  --modal-ease: cubic-bezier(0.16, 1, 0.3, 1);
  /* Smooth 'Premium' Ease */
}

/* Remove mobile tap highlight on all elements */
* {
  -webkit-tap-highlight-color: transparent;
}

/* Base Styles - MOBILE HARD LOCK */
html,
body {
  -moz-osx-font-smoothing: grayscale;
  -webkit-font-smoothing: antialiased;
  background: linear-gradient(180deg, #fbfcfd 0%, var(--bg) 100%);
  color: #111;
  font-family: var(--font-main);
  font-size: 15px;

  /* CRITICAL: Lock viewport completely on mobile */
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  position: fixed;
  /* Prevents "rubber band" scroll on the page itself */
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  /* Disables browser gestures like swipe to back */
}

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

/* Top Bar */
#topbar {
  bottom: 24px;
  display: flex;
  justify-content: flex-end;
  left: auto;
  pointer-events: none;
  position: fixed;
  right: 24px;
  top: auto;
  z-index: 1100;
}

#topbar-inner {
  align-items: center;
  backdrop-filter: blur(6px);
  background: linear-gradient(135deg, #32260b 0%, #231a05 100%);
  border: 1px solid rgba(var(--modal-accent), 0.20);
  border-radius: 14px;
  box-shadow: 0 4px 16px rgba(var(--modal-accent), 0.10), 0 1px 4px rgba(var(--modal-accent), 0.08);
  display: flex;
  gap: 8px;
  padding: 8px;
  pointer-events: auto;
  /* Added relative positioning to anchor the absolute search results correctly */
  position: relative;
  /* CRITICAL FIX: Removed 'width' and 'all' from parent transition. 
     Only animate background/shadow to prevent conflict with child width animation. */
  transition: background-color 0.3s ease, box-shadow 0.3s ease;
  width: auto;
  max-width: 90vw;
}

/* Top Buttons */
.top-btn {
  background: transparent;
  border: none;
  border-radius: 14px;
  box-shadow: none;
  cursor: pointer;
  font-family: var(--font-main);
  font-weight: 600;
  letter-spacing: 0.2px;
  padding: 10px 16px;
  transition: all 0.2s cubic-bezier(0.2, 0.9, 0.3, 1);
  position: relative;
  color: var(--accent-color);
  flex-shrink: 0;
}

.top-btn.subtle {
  color: var(--accent-soft);
  margin-left: 5px;
}

.top-btn.subtle:hover {
  background: linear-gradient(135deg, #fff6e4 0%, #feecc6 100%);
  border-color: rgba(var(--modal-accent), 0.35);
  box-shadow: 0 6px 24px rgba(var(--modal-accent), 0.16), 0 2px 8px rgba(var(--modal-accent), 0.12);
  color: var(--accent-dark);
  transform: scale(1.08);
}

.top-btn.subtle:active,
.top-btn.subtle.active {
  background: linear-gradient(135deg, #fff3d4 0%, #fedda9 96%);
  color: var(--accent-dark);
  transform: scale(0.96);
  box-shadow: 0 2px 8px rgba(var(--modal-accent), 0.12);
}

.top-btn.search-icon,
.top-btn.leaderboard-icon {
  align-items: center;
  display: flex;
  justify-content: center;
  padding: 10px;
}

.top-btn.search-icon svg,
.top-btn.leaderboard-icon svg {
  fill: none;
  height: 20px;
  stroke: currentColor;
  stroke-width: 2;
  width: 20px;
  transition: all 0.2s cubic-bezier(0.2, 0.9, 0.3, 1);
}

.top-btn.search-icon:hover svg,
.top-btn.leaderboard-icon:hover svg {
  stroke-width: 2.5;
}

.top-btn.search-icon.active,
.top-btn.leaderboard-icon.active {
  background: linear-gradient(135deg, #fff3d4 0%, #fedda9 96%);
  color: var(--accent-dark);
  transform: scale(0.96);
  box-shadow: 0 2px 8px rgba(var(--modal-accent), 0.12);
}

.top-btn.search-icon.active:hover,
.top-btn.leaderboard-icon.active:hover {
  background: linear-gradient(135deg, #ffe8b8 0%, #ffd68a 96%);
  transform: scale(1.05);
  box-shadow: 0 8px 20px rgba(var(--modal-accent), 0.25);
}

.top-btn.subtle.active:hover {
  background: linear-gradient(135deg, #ffe8b8 0%, #ffd68a 96%);
  transform: scale(1.05);
  box-shadow: 0 8px 20px rgba(var(--modal-accent), 0.25);
}

/* Search Bar */
#search-container {
  display: flex;
  align-items: center;
  /* Use max-width for smoother drawer animations */
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  position: relative;
  /* FIXED: Synchronized opacity and max-width timing for smooth closing */
  transition: max-width 0.5s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: max-width;
}

#search-container.active {
  max-width: 240px;
  opacity: 1;
}

#search-container.expanded {
  overflow: visible;
}

#search-input {
  background: transparent;
  border: none;
  color: var(--accent-soft);
  font-size: 15px;
  outline: none;
  padding: 10px 16px;
  /* UPDATED: Increased width to fit placeholder text fully */
  width: 240px;
  white-space: nowrap;
  box-sizing: border-box;
  /* Synchronized with container for smooth closing */
  opacity: 0;
  transform: translateX(-10px);
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

#search-input::placeholder {
  color: var(--muted);
  /* Synchronized with input for smooth closing */
  transition: opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Search Enter Arrow Hint */
.search-enter-hint {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: rgba(var(--modal-accent), 0.1);
  border: 1px solid rgba(var(--modal-accent), 0.2);
  border-radius: 6px;
  opacity: 0;
  /* Synchronized with container for smooth closing */
  transition: opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1), transform 0.2s ease;
  pointer-events: none;
}

.search-enter-hint svg {
  width: 14px;
  height: 14px;
  stroke: var(--accent-dark);
  stroke-width: 2;
  fill: none;
}

#search-container.active .search-enter-hint {
  opacity: 0.6;
}

#search-input:focus~.search-enter-hint,
#search-container.active:hover .search-enter-hint {
  opacity: 1;
}

/* Adjust input padding to account for arrow */
#search-container.active #search-input {
  padding-right: 40px;
  opacity: 1;
  transform: translateX(0);
}

/* Search Results - UI Fixes Applied */
#search-results {
  backdrop-filter: blur(12px);
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  bottom: calc(100% + 12px);
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.12);

  /* Layout & Sizing */
  display: flex;
  /* Changed from display:none to allow transitions */
  flex-direction: column-reverse;
  /* ALIGNMENT FIX: Adjusted to align with toolbar content */
  right: -9px;
  left: auto;
  max-height: 400px;
  width: 250px;
  /* UPDATED: Match expanded search container width */
  overflow-y: auto;
  position: absolute;
  top: auto;
  z-index: 2000;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;

  /* Animation Initial State */
  opacity: 0;
  visibility: hidden;
  /* Use visibility instead of display:none */
  pointer-events: none;
  transform: translateY(8px) scale(0.98);
  /* Start slightly down for float-up effect */

  /* Transitions */
  transition: opacity 0.3s cubic-bezier(0.2, 0.8, 0.2, 1),
    transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1),
    visibility 0.3s;
}

#search-results.visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.search-result-item {
  border-top: 1px solid rgba(0, 0, 0, 0.05);
  border-top: none;
  cursor: pointer;
  padding: 12px 16px;
  transition: background 0.15s;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 0;
}

.search-result-item:last-child {
  border-bottom: none;
  border-top: none;
}

.search-result-item:hover {
  background: rgba(184, 134, 11, 0.08);
}

.search-result-info {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.search-result-name {
  color: #333;
  font-weight: 600;
  margin-bottom: 4px;
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
}

.search-result-key {
  color: var(--muted);
  font-size: 13px;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.search-result-copy {
  background: transparent;
  border: 1px solid rgba(184, 134, 11, 0.2);
  border-radius: 6px;
  color: var(--accent-color);
  cursor: pointer;
  padding: 6px 8px;
  font-size: 11px;
  font-weight: 600;
  transition: all 0.2s ease;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 4px;
}

.search-result-copy:hover {
  background: rgba(184, 134, 11, 0.1);
  border-color: var(--accent-color);
  transform: scale(1.05);
}

.search-result-copy:active {
  transform: scale(0.95);
}

.search-result-copy.copied {
  background: rgba(184, 134, 11, 0.15);
  color: var(--accent-dark);
}

.search-result-copy svg {
  width: 12px;
  height: 12px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

.search-result-more {
  color: var(--muted);
  font-size: 13px;
  font-style: italic;
  padding: 12px 16px;
  text-align: center;
  border-top: 1px solid rgba(0, 0, 0, 0.05);
}

.search-no-results {
  color: var(--muted);
  padding: 20px;
  text-align: center;
}

/* =========================================
   COSMIC BACKGROUND
   ========================================= */

#cosmic-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: radial-gradient(ellipse 75% 75% at 50% 50%, #020100 0%, #1c1810 65%, #231d0f 100%);
  overflow: hidden;
  pointer-events: none;
}

/* Nebula layer - slow drifting warm gold clouds */
#cosmic-bg::before {
  content: '';
  position: absolute;
  inset: -50%;
  width: 200%;
  height: 200%;
  background:
    radial-gradient(ellipse 65% 45% at 25% 40%, rgba(184, 134, 11, 0.09) 0%, rgba(184, 134, 11, 0) 70%),
    radial-gradient(ellipse 50% 65% at 75% 60%, rgba(138, 101, 8, 0.07) 0%, rgba(138, 101, 8, 0) 70%),
    radial-gradient(ellipse 70% 40% at 50% 85%, rgba(247, 237, 209, 0.045) 0%, rgba(247, 237, 209, 0) 65%),
    radial-gradient(ellipse 45% 55% at 80% 20%, rgba(184, 134, 11, 0.055) 0%, rgba(184, 134, 11, 0) 65%);
  animation: nebulaFloat 90s ease-in-out infinite alternate;
  will-change: transform;
}

/* Second nebula layer offset for depth */
#cosmic-bg::after {
  content: '';
  position: absolute;
  inset: -50%;
  width: 200%;
  height: 200%;
  background:
    radial-gradient(ellipse 55% 70% at 60% 30%, rgba(138, 101, 8, 0.055) 0%, rgba(138, 101, 8, 0) 70%),
    radial-gradient(ellipse 60% 50% at 20% 70%, rgba(184, 134, 11, 0.065) 0%, rgba(184, 134, 11, 0) 70%);
  animation: nebulaFloat 120s ease-in-out infinite alternate-reverse;
  will-change: transform;
}

#star-field {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

@keyframes nebulaFloat {
  0%   { transform: translate(0%, 0%) rotate(0deg); }
  33%  { transform: translate(3%, -2%) rotate(1deg); }
  66%  { transform: translate(-2%, 3%) rotate(-1deg); }
  100% { transform: translate(2%, 1%) rotate(0.5deg); }
}

/* Canvas Wrapper */
#canvasWrap {
  box-sizing: border-box;
  display: block;
  padding: 0;
  margin: 0;
  overflow: hidden;
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

#canvas {
  background: transparent;
  border-radius: 14px;
  box-shadow: var(--shadow-2);
  display: block;
  height: 100%;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
  width: 100%;
  /* Canvas handles its own touch actions */
  touch-action: none;
  /* Disable text selection and callouts on mobile */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  box-sizing: border-box;
}

/* Canvas Image Rendering */
canvas {
  -moz-osx-font-smoothing: grayscale;
  -webkit-font-smoothing: antialiased;
}

/* Zoom Controls */
.zoom-controls {
  align-items: center;
  bottom: 32px;
  display: flex;
  gap: 5px;
  left: 24px;
  position: fixed;
  z-index: 1040;
}

.zoom-btn {
  align-items: center;
  background: linear-gradient(180deg, #32260b 0%, #231a05 100%);
  border: 1px solid rgba(var(--modal-accent), 0.20);
  border-radius: 14px;
  box-shadow: 0 4px 16px rgba(var(--modal-accent), 0.10), 0 1px 4px rgba(var(--modal-accent), 0.08);
  color: var(--accent-soft);
  cursor: pointer;
  display: flex;
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  height: 42px;
  justify-content: center;
  min-height: 42px;
  min-width: 42px;
  outline: none;
  padding: 0;
  transition: all 0.2s cubic-bezier(0.2, 0.9, 0.3, 1);
  width: 42px;
}

.zoom-btn:hover,
.zoom-btn:focus,
.zoom-btn.active {
  background: linear-gradient(135deg, #fff6e4 0%, #feecc6 100%);
  border-color: rgba(var(--modal-accent), 0.35);
  box-shadow: 0 6px 24px rgba(var(--modal-accent), 0.16), 0 2px 8px rgba(var(--modal-accent), 0.12);
  color: var(--accent-dark);
  transform: scale(1.08);
}

.zoom-btn:active {
  background: linear-gradient(135deg, #fff3d4 0%, #fedda9 96%);
  color: var(--accent-dark);
  transform: scale(0.96);
}

.zoom-btn svg {
  display: block;
  fill: none;
  height: 20px;
  stroke: currentColor;
  stroke-width: 2.2;
  width: 20px;
}

/* -----------------------------------------------
   Split Reset / Cinema Button
   ----------------------------------------------- */
.zoom-btn-split {
  background: linear-gradient(180deg, #32260b 0%, #231a05 100%);
  border: 1px solid rgba(var(--modal-accent), 0.20);
  border-radius: 14px;
  box-shadow: 0 4px 16px rgba(var(--modal-accent), 0.10), 0 1px 4px rgba(var(--modal-accent), 0.08);
  width: 42px;
  height: 58px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: background 0.2s cubic-bezier(0.2, 0.9, 0.3, 1),
              border-color 0.2s cubic-bezier(0.2, 0.9, 0.3, 1),
              box-shadow 0.2s cubic-bezier(0.2, 0.9, 0.3, 1),
              transform 0.2s cubic-bezier(0.2, 0.9, 0.3, 1);
}

.zoom-btn-split:hover {
  border-color: rgba(var(--modal-accent), 0.35);
  box-shadow: 0 6px 24px rgba(var(--modal-accent), 0.16), 0 2px 8px rgba(var(--modal-accent), 0.12);
  transform: scale(1.08);
}

.zoom-split-top,
.zoom-split-bottom {
  background: transparent;
  border: none;
  outline: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-soft);
  width: 100%;
  transition: background 0.15s ease, color 0.15s ease;
}

.zoom-split-top {
  flex: 3; /* 75% */
}

.zoom-split-bottom {
  flex: 1; /* 25% */
}

.zoom-split-top:hover {
  background: linear-gradient(180deg, #fff6e4 0%, #feecc6 100%);
  color: var(--accent-dark);
}

.zoom-split-bottom:hover {
  background: linear-gradient(180deg, #feecc6 0%, #fedda9 100%);
  color: var(--accent-dark);
}

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

.zoom-split-top svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  display: block;
}

.zoom-split-bottom svg {
  width: 11px;
  height: 11px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.5;
  display: block;
}

.zoom-split-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.09);
  margin: 0 7px;
  flex-shrink: 0;
}

/* Hover Tooltip */
#hover-tooltip {
  background: var(--accent-color);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  color: #ffffff;
  font-size: 9px;
  font-weight: 500;
  text-transform: uppercase;
  opacity: 0;
  padding: 4px 8px;
  pointer-events: none;
  position: fixed;
  transition: opacity 0.12s ease;
  z-index: 2000;
  max-width: 180px;
  line-height: 1.3;
  text-align: center;
}

/* =========================================
   1. Modal Overlay (Backdrop)
   ========================================= */
.modal {
  align-items: center;
  background: rgba(0, 0, 0, 0);
  backdrop-filter: blur(0px);
  -webkit-backdrop-filter: blur(0px);
  display: none;
  inset: 0;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  position: fixed;
  transition: opacity 0.5s var(--modal-ease),
    backdrop-filter 0.5s var(--modal-ease),
    background 0.5s var(--modal-ease);
  z-index: var(--modal-z-index);
}

.modal.open {
  display: flex;
  opacity: 1;
  background: rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  pointer-events: auto;
}

.modal.closing {
  opacity: 0;
  backdrop-filter: blur(0px);
  -webkit-backdrop-filter: blur(0px);
  pointer-events: none;
  transition-duration: 0.3s;
}

/* Keep backdrop visible during modal-to-modal transition */
.modal.transitioning {
  opacity: 1 !important;
  backdrop-filter: blur(8px) !important;
  -webkit-backdrop-filter: blur(8px) !important;
  background: rgba(0, 0, 0, 0.2) !important;
}

/* But hide the modal content during transition */
.modal.transitioning.closing .modal-content {
  animation: modalExit 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* =========================================
   2. Modal Card (Container)
   ========================================= */
.modal-content {
  background: var(--modal-bg);
  border-radius: 24px;
  /* Premium Border & Shadow Stack */
  border: 1px solid rgba(255, 255, 255, 0.8);
  box-shadow:
    0 20px 40px -10px rgba(0, 0, 0, 0.1),
    0 0 0 1px rgba(var(--modal-accent), 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 1);

  display: flex;
  flex-direction: column;

  /* Sizing - Flexible yet constrained */
  width: 90%;
  max-width: 520px;
  height: 70vh;
  max-height: 600px;

  padding: 32px;
  position: relative;
  overflow: hidden;

  /* Animation Start State */
  opacity: 0;
  transform: scale(0.96) translateY(20px);
  will-change: transform, opacity;
}

/* Subtle Ambient Glow Background */
.modal-content::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% -20%,
      rgba(var(--modal-accent), 0.08) 0%,
      transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* Top Accent Line */
.modal-content::after {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 3px;
  background: linear-gradient(90deg,
      transparent,
      rgba(var(--modal-accent), 0.6),
      transparent);
  border-radius: 0 0 4px 4px;
  z-index: 1;
}

/* Animation States */
.modal.open .modal-content {
  animation: modalEnter 0.6s var(--modal-ease) forwards;
}

.modal.closing .modal-content {
  animation: modalExit 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* Ensure content sits above the background glow */
.modal-content>* {
  position: relative;
  z-index: 2;
}

/* =========================================
   3. Typography & Elements
   ========================================= */
.modal .closeBtn {
  background: rgba(0, 0, 0, 0.03);
  border: none;
  border-radius: 50%;
  color: var(--modal-text-sub);
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  right: 20px;
  top: 20px;
  font-size: 18px;
  transition: all 0.2s ease;
  z-index: 10;
}

.modal .closeBtn:hover {
  background: rgba(var(--modal-accent), 0.1);
  color: #000;
  transform: rotate(90deg);
}



.modal-content h2 {
  color: var(--modal-text-main);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin: 0 0 24px 0;
  padding-bottom: 0;
}

#info-modal .modal-content h2 {
  font-family: 'MyFont', Inter, system-ui, sans-serif;
  font-size: 24px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 5.5px;
  color: var(--accent-dark);
  background: linear-gradient(110deg, #8a6508 30%, #d4a843 50%, #8a6508 70%);
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-align: left;
  margin: 0 0 24px 0;
  animation: shimmerGold 3s linear infinite;
  text-align: center;
  margin-bottom: 0;
  padding-bottom: 16px;
  /* Visual separation */
  position: relative;
}

@keyframes shimmerGold {
  0% {
    background-position: 0% center;
  }

  100% {
    background-position: 200% center;
  }
}

/* --- REMOVE CIRCLE BEHIND X-BUTTONS --- */
.modal .closeBtn,
.leaderboard-close-btn {
  background: transparent !important;
  border: none !important;
  border-radius: 0 !important;
  color: #999;
}

.modal .closeBtn:hover,
.leaderboard-close-btn:hover {
  background: transparent !important;
  color: var(--accent-color) !important;
  transform: scale(1.2) rotate(90deg);
}

.modal-content p {
  color: var(--modal-text-sub);
  font-size: 15px;
  line-height: 1.6;
  margin-bottom: 16px;
}

.modal-content ul {
  padding-left: 20px;
  margin-bottom: 20px;
}

.modal-content ul li {
  color: var(--modal-text-sub);
  font-size: 14px;
  margin-bottom: 8px;
  position: relative;
}

.modal-content ul li::marker {
  color: rgba(var(--modal-accent), 0.8);
}

/* =========================================
   4. Tabs (Minimalist)
   ========================================= */
.modal-tabs {
  display: flex;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(184, 134, 11, 0.15);
  /* Separation line */
  margin-bottom: 20px;
  gap: 8px;
  position: relative;
  justify-content: center;
  /* Center tabs */
}

.modal-tabs::after {
  display: none;
  /* Remove the old indicator line */
}

.modal-tab {
  background: linear-gradient(135deg, #fffbf2 0%, #fff9eb 100%);
  border: 1px solid rgba(184, 134, 11, 0.20);
  border-radius: 14px;
  /* Fully rounded */
  box-shadow: 0 4px 16px rgba(184, 134, 11, 0.10), 0 1px 4px rgba(184, 134, 11, 0.08);
  color: #b8860b;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  padding: 10px 20px;
  transition: all 0.2s cubic-bezier(0.2, 0.9, 0.3, 1);
  white-space: nowrap;
}

.modal-tab:hover,
.modal-tab.active {
  background: linear-gradient(135deg, #fff6e4 0%, #feecc6 100%);
  border-color: rgba(184, 134, 11, 0.35);
  box-shadow: 0 6px 24px rgba(184, 134, 11, 0.16), 0 2px 8px rgba(184, 134, 11, 0.12);
  color: #8a6508;
  transform: scale(1.05);
  font-weight: 700;
}

.modal-tab.active {
  background: linear-gradient(135deg, #fff3d4 0%, #fedda9 96%);
  transform: scale(0.98);
  /* Slightly pressed look for active */
}

/* Welcome tab stands out with subtle glow */
.modal-tab.welcome-tab {
  background: linear-gradient(135deg, #fffbf2 0%, #fff5e0 100%);
  border: 1.5px solid rgba(184, 134, 11, 0.3);
  box-shadow: 0 4px 16px rgba(184, 134, 11, 0.15), 0 0 0 0 rgba(184, 134, 11, 0.4);
  animation: gentlePulse 3s ease-in-out infinite;
}

.modal-tab.welcome-tab:hover {
  background: linear-gradient(135deg, #fff9eb 0%, #ffefc6 100%);
  border-color: rgba(184, 134, 11, 0.5);
  box-shadow: 0 6px 24px rgba(184, 134, 11, 0.25), 0 0 20px rgba(184, 134, 11, 0.3);
  animation: none;
}

.modal-tab.welcome-tab.active {
  background: linear-gradient(135deg, #fff6e4 0%, #ffe9b3 100%);
  border-color: rgba(184, 134, 11, 0.4);
  box-shadow: 0 6px 24px rgba(184, 134, 11, 0.2), inset 0 2px 4px rgba(184, 134, 11, 0.1);
  animation: none;
}

@keyframes gentlePulse {

  0%,
  100% {
    box-shadow: 0 4px 16px rgba(184, 134, 11, 0.15), 0 0 0 0 rgba(184, 134, 11, 0.4);
  }

  50% {
    box-shadow: 0 4px 16px rgba(184, 134, 11, 0.2), 0 0 12px rgba(184, 134, 11, 0.3);
  }
}

/* Tab Content Area */
.modal-tab-content {
  display: none;
  flex: 1;
  /* Fills remaining height */
  overflow-y: auto;
  padding-right: 8px;
  /* Space for scrollbar */

  /* Scrollbar Styling */
  scrollbar-width: thin;
  scrollbar-color: rgba(var(--modal-accent), 0.3) transparent;
}

.modal-tab-content.active {
  display: block;
  animation: fadeUp 0.4s var(--modal-ease) forwards;
}

/* Webkit Scrollbar */
.modal-tab-content::-webkit-scrollbar {
  width: 4px;
}

.modal-tab-content::-webkit-scrollbar-track {
  background: transparent;
}

.modal-tab-content::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 4px;
}

.modal-tab-content::-webkit-scrollbar-thumb:hover {
  background: rgba(var(--modal-accent), 0.6);
}

/* =========================================
   5. Animations
   ========================================= */
@keyframes modalEnter {
  0% {
    opacity: 0;
    transform: scale(0.96) translateY(20px);
  }

  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes modalExit {
  0% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }

  100% {
    opacity: 0;
    transform: scale(0.96) translateY(10px);
  }
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes tabLine {
  from {
    transform: scaleX(0);
  }

  to {
    transform: scaleX(1);
  }
}

/* ========================================= 
   WELCOME MODAL 
   ========================================= */

.welcome-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--modal-z-index);

  /* Smooth Opacity Transition */
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.6s ease, visibility 0.6s;
}

/* Backdrop Blur Effect */
.welcome-modal::before {
  content: '';
  position: absolute;
  inset: 0;

  /* Start with no blur and transparent background */
  background: rgba(0, 0, 0, 0);
  backdrop-filter: blur(0px);
  -webkit-backdrop-filter: blur(0px);

  z-index: -1;
  will-change: backdrop-filter, background;

  /* Smooth transition for the blur */
  transition: backdrop-filter 0.8s ease, background 0.8s ease;
}

.welcome-modal.open {
  opacity: 1;
  visibility: visible;
}

/* When coming from transition, show immediately */
.welcome-modal.from-transition {
  opacity: 1 !important;
  visibility: visible !important;
  transition: none !important;
}

/* Active State: Blur the background content */
.welcome-modal.open::before {
  background: rgba(0, 0, 0, 0.2);
  /* Match info modal backdrop */
  backdrop-filter: blur(8px);
  /* The requested blur effect */
  -webkit-backdrop-filter: blur(8px);
}

/* When transitioning from info modal, start with blur already active */
.welcome-modal.from-transition::before {
  background: rgba(0, 0, 0, 0.2) !important;
  backdrop-filter: blur(8px) !important;
  -webkit-backdrop-filter: blur(8px) !important;
  transition: none !important;
  /* No transition - instant */
}

.welcome-content {
  /* PRESERVED ORIGINAL SIZING */
  max-width: 680px;
  width: 92%;
  max-height: 85vh;
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;

  /* Solid background (kept as requested) */
  background: var(--modal-bg);
  border: 1px solid #e0e0e0;
  border-radius: 40px;
  box-shadow: 0 32px 64px -12px rgba(0, 0, 0, 0.14);

  /* Entrance Animation State */
  opacity: 0;
  transform: scale(0.95) translateY(10px);
  transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.6s ease;
}

.welcome-modal.open .welcome-content {
  opacity: 1;
  transform: scale(1) translateY(0);
}

.welcome-modal.closing .welcome-content {
  opacity: 0;
  transform: scale(0.95) translateY(10px);
  transition: transform 0.4s ease, opacity 0.4s ease;
}

.welcome-modal.closing::before {
  background: rgba(0, 0, 0, 0);
  backdrop-filter: blur(0px);
  -webkit-backdrop-filter: blur(0px);
}

.welcome-scroll-content {
  flex: 1;
  overflow-y: auto;
  padding: 48px 56px 80px 56px;
  position: relative;
  z-index: 1;
  scrollbar-width: none;
  -ms-overflow-style: none;
  scroll-behavior: smooth;
}

.welcome-scroll-content::-webkit-scrollbar {
  width: 0px;
  background: transparent;
}

/* ========================================= 
   TYPOGRAPHY 
   ========================================= */

.welcome-header {
  text-align: center;
  margin-bottom: 24px;
  opacity: 1;
  animation: none;
}

.welcome-title {
  font-size: 32px;
  font-weight: 800;
  line-height: 1.2;
  margin: 0;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  position: relative;
  display: inline-block;
  background: linear-gradient(110deg,
      #4c3704 10%,
      #8a6508 30%,
      #d4a843 50%,
      #8a6508 70%,
      #4c3704 90%);
  background-size: 200% auto;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  animation: titleShine 8s ease-in-out infinite;
}

@keyframes titleShine {
  0% {
    background-position: 0% 50%;
  }

  50% {
    background-position: 100% 50%;
  }

  100% {
    background-position: 0% 50%;
  }
}

.welcome-section {
  margin-bottom: 40px;
  opacity: 1;
  animation: none;
}

.welcome-section-title {
  font-size: 18px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 800;
  color: var(--accent-dark);
  margin: 0 0 16px 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.welcome-section-title::after {
  content: '';
  height: 1px;
  flex: 1;
  background: linear-gradient(90deg, rgba(184, 134, 11, 0.3), transparent);
}

.welcome-section p {
  font-size: 15px;
  line-height: 1.7;
  color: var(--modal-text-sub);
  margin: 0 0 16px 0;
  font-weight: 500;
}

/* ========================================= 
   TIMELINE 
   ========================================= */

.timeline-container {
  position: relative;
  margin: 16px 0 24px 0;
  padding-left: 0;
  overflow: visible;
}

#helpTimelineContainer {
  margin-left: 11px;
}

.timeline-track-bg {
  position: absolute;
  left: 16px;
  top: 16px;
  width: 2px;
  background: rgba(0, 0, 0, 0.06);
  z-index: 0;
  border-radius: 2px;
}

.timeline-track-fill {
  position: absolute;
  left: 16px;
  top: 16px;
  width: 2px;
  height: 0px;
  background: var(--accent-color);
  z-index: 1;
  border-radius: 2px;
  box-shadow: 0 0 8px rgba(184, 134, 11, 0.4);
  transition: none;
}

.timeline-item {
  position: relative;
  padding: 0 0 20px 56px;
  color: var(--modal-text-sub);
}

.timeline-item:last-child {
  padding-bottom: 0;
  min-height: 32px;
}

.timeline-marker {
  position: absolute;
  left: 0;
  top: 0;
  width: 32px;
  height: 32px;
  background: #ffffff;
  color: #999;
  border: 2px solid #e0e0e0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-main);
  font-size: 14px;
  font-weight: 700;
  z-index: 2;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.timeline-item.active .timeline-marker {
  background: var(--accent-color);
  color: #ffffff;
  border-color: var(--accent-color);
  box-shadow: 0 4px 12px rgba(184, 134, 11, 0.3);
  transform: scale(1.1);
}

/* Flash Effect */
.timeline-container.flash-success .timeline-marker,
.timeline-container.flash-success .timeline-track-fill {
  animation: successFlash 0.6s ease-out forwards;
}

@keyframes successFlash {
  0% {
    filter: brightness(1);
  }

  50% {
    filter: brightness(1.5) drop-shadow(0 0 8px var(--accent-color));
  }

  100% {
    filter: brightness(1);
  }
}

.timeline-item strong {
  display: block;
  color: var(--modal-text-main);
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 4px;
  padding-top: 4px;
  transition: color 0.3s ease;
}

.timeline-item.active strong {
  color: var(--accent-dark);
}

.step-text {
  display: block;
  font-size: 15px;
  line-height: 1.5;
  opacity: 0.9;
}

/* ========================================= 
   FLOATING CONTROLS & BUTTON 
   ========================================= */

.welcome-footer-area {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 80px;
  padding: 0;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  pointer-events: none;
  z-index: 10;
  background: linear-gradient(to top, rgba(255, 255, 255, 0.95) 50%, rgba(255, 255, 255, 0) 100%);
  border-bottom-left-radius: 40px;
  border-bottom-right-radius: 40px;
}

/* Skip Button */
.skip-btn {
  pointer-events: none;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.8);
  padding: 10px 22px;
  border-radius: 100px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--modal-text-sub);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
  transform: translateY(20px);
  opacity: 0;
  transition: all 0.3s var(--modal-ease);
  position: absolute;
  bottom: 20px;
}

.skip-btn.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.skip-btn:hover {
  transform: translateY(-3px) scale(1.02);
  color: var(--modal-text-main);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  background: #ffffff;
}

.skip-btn:active {
  transform: translateY(-1px) scale(0.96);
}

.skip-icon {
  width: 16px;
  height: 16px;
  fill: currentColor;
  animation: bounceSmall 2s infinite;
}

/* --- Continue Button Wrapper --- */
.continue-btn-wrapper {
  width: 100%;
  display: flex;
  justify-content: center;
  pointer-events: none;
  perspective: 1000px;
  margin: 32px 0 24px 0;
}

/* THE FLOWING BORDER CONTAINER */
.btn-border-container {
  position: relative;
  /* Wrapper Radius = Button Radius (14px) + Border Width (4px) = 18px */
  border-radius: 18px;
  padding: 4px;
  /* Creates the border width */
  opacity: 0;
  transform: translateY(15px);
  transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
  overflow: hidden;
  display: flex;
  background: transparent;
}

.btn-border-container.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* The Spinning Gradient Background */
.btn-border-container::before {
  content: '';
  position: absolute;
  /* Use inset -100% to ensure coverage */
  inset: -100%;
  background: conic-gradient(from 0deg,
      var(--metal_03) 0%,
      var(--metal_04) 10%,
      var(--metal_01) 20%,
      var(--metal_04) 30%,
      var(--metal_03) 40%,
      var(--metal_05) 50%,
      var(--metal_03) 60%,
      var(--metal_04) 70%,
      var(--metal_01) 80%,
      var(--metal_04) 90%,
      var(--metal_03) 100%);
  animation: rotateBorder 4s linear infinite;
  z-index: 0;
}

@keyframes rotateBorder {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

/* The Actual Button */
.continue-btn {
  position: relative;
  z-index: 1;
  padding: 14px 28px;
  border-radius: 14px;
  /* Inner radius */
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;

  /* Default: Solid background */
  background: var(--accent-color);
  color: #ffffff;
  border: none;
  width: 100%;

  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

/* Gradient overlay for hover effect */
.continue-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--accent-dark) 0%, var(--accent-color) 100%);
  opacity: 0;
  transition: opacity 0.3s ease;
  border-radius: 14px;
  z-index: -1;
}

.continue-btn svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
  opacity: 1;
  transition: transform 0.3s ease;
}

/* Ensure text and SVG stay above the gradient overlay */
.continue-btn>* {
  position: relative;
  z-index: 1;
}

/* Hover: Show gradient overlay */
.continue-btn:hover::before {
  opacity: 1;
}

.continue-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(184, 134, 11, 0.4);
}

.continue-btn:hover svg {
  transform: translateY(-2px);
}

.continue-btn:active {
  transform: translateY(0) scale(0.98);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.continue-btn:active::before {
  background: var(--accent-darker);
  opacity: 1;
}

/* Animation Utils */
@keyframes welcomeFadeInUp {
  0% {
    opacity: 0;
    transform: translateY(12px);
  }

  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes bounceSmall {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(3px);
  }
}

/* Mobile Responsive - Keep as modal, not fullscreen */
@media (max-width: 768px) {
  .welcome-content {
    max-width: 95%;
    width: 95%;
    max-height: 75vh;
    border-radius: 24px;
    border: 1px solid #e0e0e0;
  }

  .welcome-footer-area {
    border-radius: 0 0 24px 24px;
  }

  .welcome-scroll-content {
    padding: 32px 28px 120px 28px;
  }

  .welcome-title {
    font-size: 26px;
  }

  .continue-btn {
    padding: 14px 28px;
  }

  .timeline-item {
    padding: 0 0 16px 48px;
  }

  .welcome-section p {
    font-size: 14px;
  }
}

/* =========================================
   6. Mobile Optimization
   ========================================= */
@media (max-width: 600px) {
  .modal-content {
    width: 100%;
    border-radius: 20px 20px 0 0;
    margin-top: auto;
    /* Docks to bottom */
    margin-bottom: 0;
    max-height: 90vh;
    padding: 24px;
  }

  .modal.open .modal-content {
    animation-name: slideUpMobile;
  }

  .modal.closing .modal-content {
    animation-name: slideDownMobile;
  }
}

@keyframes slideUpMobile {
  from {
    transform: translateY(100%);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes slideDownMobile {
  from {
    transform: translateY(0);
    opacity: 1;
  }

  to {
    transform: translateY(100%);
    opacity: 0;
  }
}

/* ============================================
   DRAWER STYLES (Fixed & Smoothed)
   ============================================ */

/* Drawer hint arrow - child of drawer, moves with it via inherited transform */
#drawer-hint-arrow {
  position: absolute;
  top: calc(100% + 5px);
  left: 50%;
  transform: translateX(-50%);
  pointer-events: auto;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  color: var(--accent-dark);
}

body.app-ready #drawer-hint-arrow,
body.loader-finished #drawer-hint-arrow {
  opacity: 1;
  visibility: visible;
}

#drawer-hint-arrow svg {
  width: clamp(44px, 8vw, 80px);
  height: auto;
  display: block;
  animation: drawerHintBounce 6s ease-in-out infinite;
}

@keyframes drawerHintBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

/* Hide arrow when drawer is open; delay fade-in so it appears after drawer fully closes */
body:has(#drawer.open) #drawer-hint-arrow {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

body:not(:has(#drawer.open)) #drawer-hint-arrow {
  transition: opacity 0.4s ease 0.5s, visibility 0.4s ease 0.5s;
}


.drawer {
  background: white;
  border: 1px solid rgba(184, 134, 11, 0.15);
  border-radius: 32px;
  box-shadow: 0 24px 60px rgba(138, 101, 8, 0.12), 0 8px 20px rgba(184, 134, 11, 0.08);
  display: flex;
  flex-direction: column;
  font-size: 11px;
  font-weight: 800;
  height: 400px;
  /* Fixed height */
  left: 50%;
  letter-spacing: 2px;
  max-width: 800px;
  /* Reduced max-width for cleaner layout */
  min-width: 320px;
  opacity: 0;
  overflow: visible;
  pointer-events: auto;
  position: fixed;
  text-transform: uppercase;
  top: 24px;
  width: 90vw;
  z-index: 1200;
  touch-action: pan-y;

  /* CURTAIN EFFECT: Smooth ease-out, no elastic bounce */
  transform: translate3d(-50%, calc(-100% + 56px), 0);
  transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94),
    opacity 0.4s ease,
    box-shadow 0.4s ease;
  will-change: transform;
}

/* Open State */
.drawer.open {
  background: #ffffff;
  box-shadow: 0 32px 90px rgba(138, 101, 8, 0.16), 0 12px 30px rgba(184, 134, 11, 0.10);
  opacity: 1;
  transform: translate3d(-50%, 0, 0);
  transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94),
    opacity 0.4s ease,
    box-shadow 0.4s ease;
}

/* Hover State (Subtle peek) */
.drawer:not(.open):hover {
  transform: translate3d(-50%, calc(-100% + 64px), 0);
}

/* Suppress peek after user manually closes - cleared once cursor physically leaves */
.drawer.user-closed:not(.open):hover {
  transform: translate3d(-50%, calc(-100% + 56px), 0);
}

/* Drawer Banner Fade Out on Open */
.drawer.open #drawer-cover-banner {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease 0.2s;
  /* Delayed fade out for smooth effect */
}

/* Drawer Content & Grid */
.drawer-content {
  display: flex;
  flex-direction: column;
  padding: 24px 32px 32px;
  height: 100%;
  overflow: visible;
  /* No scroll on desktop, prevent cropping */
  -webkit-overflow-scrolling: touch;
  opacity: 0;
  transition: opacity 0.6s ease 0.3s;
  /* Fade in after drawer opens */
}

.drawer.open .drawer-content {
  opacity: 1;
}

.drawer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  /* Equal width columns */
  gap: 32px;
  width: 100%;
  margin-bottom: 24px;
  overflow: visible;
  /* Prevent cropping of input hover effects */
}

.drawer-left,
.drawer-right {
  display: flex;
  flex-direction: column;
  gap: 18px;
  /* Vertical spacing between sections */
  overflow: visible;
  /* Prevent cropping of hover effects */
}

/* Input & Label Alignments */
.drawer-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  z-index: 1;
  overflow: visible;
  /* Fix for hover cropping */
}

.drawer-field label {
  margin-bottom: 2px;
  /* Consistent spacing */
}

.drawer input {
  position: relative;
  z-index: 2;
}

.split-inputs {
  display: flex;
  gap: 16px;
}

.input-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Live Indicator Wrapper */
.input-with-indicator {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-indicator input {
  flex: 1;
  padding-right: 36px;
  /* Make room for the indicator */
}

/* Live Indicator Dot */
.live-indicator {
  position: absolute;
  right: 12px;
  width: 8px;
  height: 8px;
  background: #22c55e;
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.6);
  transition: opacity 0.3s ease;
  cursor: help;
  z-index: 3000;
}

.live-indicator.active {
  opacity: 1;
  pointer-events: auto;
  animation: liveIndicatorGlow 2s ease-in-out infinite;
}

@keyframes liveIndicatorGlow {

  0%,
  100% {
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.6);
  }

  50% {
    box-shadow: 0 0 12px rgba(34, 197, 94, 0.8), 0 0 16px rgba(34, 197, 94, 0.4);
  }
}

/* Character Counter */
.input-with-counter {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-counter input {
  flex: 1;
  padding-right: 50px;
  /* Make room for the counter */
}

.char-counter {
  position: absolute;
  right: 12px;
  font-size: 10px;
  color: rgba(107, 114, 128, 0.5);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease, color 0.2s ease;
  font-variant-numeric: tabular-nums;
  user-select: none;
  z-index: 5000;
}

.char-counter.at-limit {
  color: rgba(184, 134, 11, 0.7);
  animation: charLimitPulse 0.4s ease-out;
}

@keyframes charLimitPulse {
  0% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.15);
  }

  100% {
    transform: scale(1);
  }
}

/* Tooltip styling for live indicator */
.live-indicator[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  top: 50%;
  left: calc(100% + 12px);
  bottom: auto;
  right: auto;
  transform: translateY(-50%);
  background: rgba(26, 26, 26, 0.95);
  color: #fff;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 8px;
  font-weight: 500;
  white-space: nowrap;
  z-index: 1000;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.live-indicator[data-tooltip]:hover::before {
  display: none;
  z-index: 1000;
  pointer-events: none;
}

/* Bottom Section */
.drawer-promo-section {
  width: 100%;
  margin-top: -8px;
  margin-bottom: 6px;
}

.promo-toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 20px;
  overflow: visible;
}

.promo-toggle-label {
  color: #333;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.promo-input-group {
  flex: 1;
}

.promo-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.promo-code-input {
  width: 100%;
  padding: 1px 24px 1px 7px;
  line-height: 1;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 6px;
  color: #111;
  font-size: 12px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  box-sizing: border-box;
}

.promo-code-input::placeholder {
  color: rgba(0, 0, 0, 0.35);
  text-transform: none;
  letter-spacing: normal;
}

.promo-code-input:focus {
  border-color: rgba(0, 0, 0, 0.45);
}

.promo-code-input.valid {
  border-color: #4caf50;
}

.promo-code-input.invalid {
  border-color: #e57373;
}

.promo-check-btn {
  position: absolute;
  right: 5px;
  z-index: 3;
  background: none;
  border: none;
  padding: 2px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}

.check-circle {
  fill: none;
  stroke: rgba(0, 0, 0, 0.25);
  transition: fill 0.15s ease, stroke 0.15s ease;
}

.check-mark {
  stroke: rgba(0, 0, 0, 0.25);
  transition: stroke 0.15s ease;
}

.promo-check-btn:not(.state-valid):not(.state-invalid):hover .check-circle,
.promo-check-btn:not(.state-valid):not(.state-invalid):hover .check-mark {
  stroke: rgba(0, 0, 0, 0.55);
}

.promo-check-btn.state-valid .check-circle {
  fill: #2e7d32;
  stroke: #2e7d32;
}

.promo-check-btn.state-valid .check-mark {
  stroke: #fff;
}

.promo-check-btn.state-invalid .check-circle {
  fill: #c62828;
  stroke: #c62828;
}

.promo-check-btn.state-invalid .check-mark {
  stroke: #fff;
}


#drawer-bottom-section {
  margin-top: auto;
  width: 100%;
  max-height: 1000px;
  transition: opacity 0.3s ease, max-height 0.3s ease, margin 0.3s ease, padding 0.3s ease;
  opacity: 1;
}

#drawer-bottom-section.hidden {
  opacity: 0;
  max-height: 0 !important;
  overflow: hidden;
  margin: 0 !important;
  padding: 0 !important;
  pointer-events: none;
}

.drawer-buttons {
  display: flex;
  gap: 16px;
  width: 100%;
}

.drawer-confirm,
.drawer-crypto {
  flex: 1;
  /* Equal width buttons */
  margin-top: 0;
}

.payment-disclaimer {
  margin-top: 16px;
  text-align: center;
  font-size: 8px;
  line-height: 1.4;
  opacity: 0.6;
  word-wrap: break-word;
  overflow-wrap: break-word;
  max-width: 100%;
}

/* Drawer Cover Banner */
#drawer-cover-banner {
  align-items: flex-end;
  animation: drawerBorderMove 20s linear infinite;
  background:
    linear-gradient(180deg, #efd9a4 30%, #231a05 100%) padding-box,
    linear-gradient(115deg,
      rgba(var(--modal-accent), 0.20) 0%,
      rgba(var(--modal-accent), 0.20) 6%,
      rgba(var(--modal-accent), 0.35) 20%,
      var(--accent-color) 35%,
      var(--accent-dark) 50%,
      var(--accent-color) 65%,
      rgba(var(--modal-accent), 0.35) 80%,
      rgba(var(--modal-accent), 0.20) 94%,
      rgba(var(--modal-accent), 0.20) 100%) border-box;
  background-size: 100% 100%, 200% 100%;
  border: 1px solid transparent;
  border-radius: 34px;
  box-sizing: border-box;
  display: flex;
  inset: -4px;
  justify-content: center;
  opacity: 1;
  overflow: hidden;
  padding-bottom: 25px;
  pointer-events: none;
  position: absolute;
  transition: opacity 0.6s ease;
  /* Smooth fade in/out */
  z-index: 2000;
}


#drawer-cover-banner span {
  box-sizing: border-box;
  display: inline-block;
  width: 100%;
  position: relative;
  z-index: 1110;
  font-size: clamp(0.5rem, 2.2vw, 1.3rem);
  font-weight: 800;
  text-align: center;
  text-transform: uppercase;
  white-space: nowrap;
  line-height: 1.4;
  letter-spacing: 2.2em;
  padding-left: 2.2em;
  color: var(--accent-dark);
  background: linear-gradient(110deg, var(--accent-soft) 30%, #ffefc8 50%, var(--accent-soft) 70%);
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: shimmerGold 4s linear infinite;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.drawer.open #drawer-cover-banner {
  opacity: 0;
  pointer-events: none;
  transform: scale(1.02);
  transition: opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

#drawer-banner {
  display: none;
}

#drawer-banner span {
  -webkit-background-clip: text;
  background-clip: text;
  background-color: var(--accent-dark);
  color: transparent;
  text-shadow: 0px 2px 4px rgba(var(--modal-accent), 0.4);
  transform: rotate(180deg);
  white-space: nowrap;
  writing-mode: vertical-rl;
}

#drawer-banner::before {
  background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 60%);
  content: '';
  height: 200%;
  left: -50%;
  opacity: 0;
  position: absolute;
  top: -50%;
  transition: opacity 0.3s ease;
  width: 200%;
}

.drawer:hover #drawer-banner::before {
  opacity: 1;
}

.drawer.open #drawer-banner {
  opacity: 0;
  transform: translateX(-10px);
  transition-delay: 0s;
  z-index: -1;
}

/* Drawer Tab */
.drawer-tab {
  align-items: center;
  backdrop-filter: blur(16px);
  background: #ffffff;
  border: 1px solid rgba(184, 134, 11, 0.15);
  border-radius: 0 0 24px 24px;
  border-top: none;
  box-shadow:
    0 15px 24px -4px rgba(184, 134, 11, 0.16),
    0 8px 8px -4px rgba(184, 134, 11, 0.12);
  color: #8a6508;
  cursor: pointer;
  display: flex;
  height: 40px;
  justify-content: center;
  left: 50%;
  opacity: 0;
  pointer-events: none;
  position: absolute;
  top: 100%;
  transform: translateX(-50%) translateY(-2px);
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  width: 68px;
  z-index: 1250;
}

.drawer-tab svg {
  opacity: 0.7;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.drawer.open.locked .drawer-tab {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

.drawer-tab:hover {
  background: linear-gradient(135deg, #fff6e4 0%, #feecc6 100%);
  border-radius: 16px;
  /* Round on all corners on hover */
  border: 1px solid rgba(184, 134, 11, 0.35);
  box-shadow: 0 6px 24px rgba(184, 134, 11, 0.16), 0 2px 8px rgba(184, 134, 11, 0.12);
  transform: translateX(-50%) translateY(4px) scale(1.05);
}

.drawer-tab:hover svg {
  color: #b8860b;
  opacity: 1;
  transform: translateY(1px);
}

.drawer.open.locked .drawer-tab:hover {
  transform: translateX(-50%) translateY(3px);
}

/* Drawer Scroll Indicator */
.drawer-scroll-indicator {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 6px;
  background: linear-gradient(to top, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0.8) 20%, rgba(255, 255, 255, 0.5) 40%, rgba(255, 255, 255, 0.25) 60%, rgba(255, 255, 255, 0.1) 80%, rgba(255, 255, 255, 0) 100%);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  mask-image: linear-gradient(to top, black 0%, black 20%, rgba(0, 0, 0, 0.6) 40%, rgba(0, 0, 0, 0.3) 60%, rgba(0, 0, 0, 0.1) 80%, transparent 100%);
  -webkit-mask-image: linear-gradient(to top, black 0%, black 20%, rgba(0, 0, 0, 0.6) 40%, rgba(0, 0, 0, 0.3) 60%, rgba(0, 0, 0, 0.1) 80%, transparent 100%);
  border-bottom-left-radius: 32px;
  border-bottom-right-radius: 32px;
}

.drawer-scroll-indicator.visible {
  opacity: 1;
}

.drawer-scroll-indicator svg {
  color: #b8860b;
  opacity: 0.7;
  animation: bounce-arrow 1.5s ease-in-out infinite;
}

@keyframes bounce-arrow {
  0%, 100% {
    transform: translateY(0);
    opacity: 0.7;
  }
  50% {
    transform: translateY(4px);
    opacity: 1;
  }
}

.drawer:not(.open) .drawer-scroll-indicator {
  display: none;
}

/* Drawer Close Button */
.drawer .closeBtn {
  position: absolute;
  top: 16px;
  right: 16px;
  background: transparent !important;
  border: none !important;
  color: #999;
  cursor: pointer;
  font-size: 28px;
  line-height: 1;
  padding: 4px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s ease;
  z-index: 1300;
}

.drawer.open.locked .closeBtn {
  opacity: 1;
  pointer-events: auto;
}

.drawer .closeBtn:hover {
  background: transparent !important;
  color: var(--accent-color) !important;
  transform: scale(1.2) rotate(90deg);
}

/* Drawer Content */
.drawer-content {
  box-sizing: border-box;
  display: flex;
  flex: 1 1 0%;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  padding: 20px 24px 24px;
  width: 100%;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1) 0.1s,
    transform 0.5s cubic-bezier(0.4, 0, 0.2, 1) 0.1s;
  /* Enable momentum scrolling */
  -webkit-overflow-scrolling: touch;
}

.drawer.open .drawer-content {
  opacity: 1;
  transform: translateY(0);
}

.drawer h2 {
  font-size: 17px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--accent-dark);
  background: linear-gradient(110deg, #8a6508 30%, #d4a843 50%, #8a6508 70%);
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin: 0 0 8px 0;
  animation: shimmerGold 3s linear infinite;
}

.drawer-grid {
  box-sizing: border-box;
  display: grid;
  flex: 1;
  gap: 28px;
  grid-template-columns: 1.2fr 1fr;
  min-height: 0;
  width: 100%;
}


.drawer-left,
.drawer-right {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

.drawer-right {
  justify-content: flex-start;
  padding-top: 41px;
  /* Align with name input on left side */
}

/* --- DRAWER SECTIONS ANIMATION (Simple Fade In/Out) --- */
.drawer-section {
  transition: opacity 0.3s ease, max-height 0.3s ease, margin 0.3s ease, padding 0.3s ease;
  overflow: visible;
  /* Prevent cropping of input hover effects */
  opacity: 1;
  max-height: 2000px;
}

.drawer-section.compact {
  margin-bottom: 0;
  padding-bottom: 8px;
}

#name-section.drawer-section.compact {
  padding-bottom: 0px;
}

.drawer-section.hidden {
  opacity: 0;
  pointer-events: none;
  max-height: 0 !important;
  overflow: hidden;
  margin: 0 !important;
  padding: 0 !important;
}

#key-section {
  padding-bottom: 18px;
  margin-top: 0;
  margin-bottom: 0;
  transition: max-height 0.3s ease, opacity 0.3s ease, padding 0.3s ease;
  max-height: 200px;
  overflow: visible;
}

#key-section.hidden {
  max-height: 0;
  opacity: 0;
  padding-bottom: 0;
  pointer-events: none;
  overflow: hidden;
}


/* FIX: Ensure key error appears directly below input, not at bottom of drawer */
#key-section .muted.error {
  position: static;
  margin-top: 4px;
  width: auto;
}


.key-enter-icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #b8860b;
  opacity: 0.5;
  pointer-events: auto;
  cursor: pointer;
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 1300;
}

.key-enter-icon:hover {
  opacity: 1;
  transform: translateY(-50%) scale(1.1);
}

#drawer-key:focus+.key-enter-icon {
  opacity: 1;
  transform: translateY(-50%) translateX(2px);
}

#payment-section .muted.error,
#payment-section .muted.hint {
  bottom: auto;
  top: 64px;
}

#slippage-info {
  margin-top: 24px !important;
}

.drawer-section label {
  color: #8a6508;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2px;
  margin-bottom: 2px;
  padding-left: 4px;
}

.drawer-row {
  align-items: center;
  color: #333;
  display: flex;
  flex-shrink: 0;
  font-weight: 600;
  gap: 6px;
  line-height: 1.2;
  margin-bottom: 6px;
}

.drawer-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 0;
  padding-bottom: 18px;
  position: relative;
}

.drawer-field label {
  color: #333;
  font-weight: 600;
  margin-bottom: 2px;
}

.drawer-field label[for="buyer-name"] {
  color: #8a6508;
}

.drawer-field label[title],
.drawer-section label[title] {
  cursor: help;
  text-decoration: underline dotted;
  text-decoration-color: rgba(184, 134, 11, 0.4);
  text-underline-offset: 3px;
}

.drawer-section label .info-icon {
  display: inline-block;
  vertical-align: middle;
  margin-left: 4px;
  color: #b8860b;
  opacity: 0.6;
  cursor: help;
  transition: opacity 0.2s ease, transform 0.2s ease;
  position: relative;
}

.drawer-section label .info-icon:hover {
  opacity: 1;
  transform: scale(1.15);
}

/* Tooltip for info icon - removed, using #hover-tooltip instead */

#additional-fields {
  display: block;
  margin-bottom: 0;
  margin-top: 0;
  padding-top: 33px;
  max-height: 1000px;
  transition: opacity 0.3s ease, max-height 0.3s ease, margin 0.3s ease, padding 0.3s ease;
  opacity: 1;
}

#additional-fields.hidden {
  opacity: 0;
  max-height: 0 !important;
  overflow: hidden;
  margin: 0 !important;
  padding: 0 !important;
  pointer-events: none;
}

/* Remove arrows/spinners from number inputs */
/* Chrome, Safari, Edge, Opera */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}


/* Drawer Inputs */
.drawer input[type="text"],
.drawer input[type="number"],
.drawer input[type="url"],
.drawer input[type="file"],
.drawer input[type="email"] {
  background: #ffffff;
  border: 1px solid rgba(184, 134, 11, 0.20);
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(138, 101, 8, 0.06);
  box-sizing: border-box;
  color: #2c2c2e;
  font-family: var(--font-main);
  font-size: 12px;
  min-width: 0;
  outline: none;
  padding: 10px 12px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  width: 100%;
}

.drawer input:focus {
  background: #ffffff;
  border-color: rgba(184, 134, 11, 0.40);
  box-shadow: 0 0 0 3px rgba(184, 134, 11, 0.10), 0 4px 12px rgba(138, 101, 8, 0.12);
  transform: translateY(-1px);
}

.drawer input.live-derived {
  border-color: rgba(16, 185, 129, 0.25);
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.08), 0 1px 3px rgba(138, 101, 8, 0.06);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.drawer input.promo-locked {
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
  border-color: #2e7d32 !important;
  box-shadow: 0 0 0 2px rgba(46, 125, 50, 0.15) !important;
}

.promo-free-label {
  font-size: 11px;
  color: #2e7d32;
  margin-top: 5px;
  font-weight: 500;
}

.drawer input.live-derived:focus {
  border-color: rgba(16, 185, 129, 0.40);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.12), 0 4px 12px rgba(16, 185, 129, 0.15);
}

#drawer-key:disabled {
  background: linear-gradient(180deg, #f7f7f5, #f2f2f0);
  border-color: rgba(184, 134, 11, 0.10);
  color: #8e8e93;
  cursor: not-allowed;
  opacity: 0.75;
}

/* Split Inputs */
.split-inputs {
  display: flex;
  gap: 12px;
}

.input-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.input-col label {
  display: block;
  margin-bottom: 2px;
  position: relative;
}

.tooltip-icon {
  display: inline-block;
  margin-left: 2px;
  font-size: 10px;
  color: #b8860b;
  cursor: help;
  opacity: 0.7;
  transition: opacity 0.2s ease;
  font-weight: 500;
}

.tooltip-icon:hover {
  opacity: 1;
}

.tooltip-icon::before {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  /* Fix: Align to right to prevent screen overflow, use max-width */
  left: auto;
  right: -10px;
  transform: none;

  background: var(--accent-dark);
  color: #fff;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 400;
  white-space: normal;

  /* Fix: Constraint width */
  width: max-content;
  max-width: 200px;

  text-align: center;
  line-height: 1.4;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  pointer-events: none;
  z-index: 1000;
  margin-bottom: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.tooltip-icon:hover::before {
  opacity: 1;
  visibility: visible;
}

/* Messages */
#drawer-warning {
  font-size: 10px;
  font-weight: 600;
  margin-top: 6px;
  min-height: 14px;
}

.drawer-section .muted.error,
.drawer-section .muted.hint,
.drawer-section .muted.success,
.drawer-field .muted.error,
.drawer-field .muted.hint,
.drawer-field .muted.success {
  font-size: 9px;
  font-weight: 700;
  height: 14px;
  line-height: 14px;
  margin-top: 0;
  overflow: hidden;
  padding-left: 2px;
  pointer-events: none;
  text-overflow: ellipsis;
  white-space: nowrap;
  position: absolute;
  bottom: 2px;
  left: 0;
  width: 100%;
  display: none;
  /* Hidden by default, shown by JS */
}

/* Override for payment section - show errors below amount input */
#payment-section .muted.error,
#payment-section .muted.hint {
  position: static;
  margin-top: 4px;
  width: auto;
}

.muted.error {
  color: #ff3b30;
}

.muted.hint {
  color: #8e8e93;
}

.muted.success {
  color: #34c759;
  font-size: 10px;
  font-weight: 600;
  margin-top: 4px;
}

/* Key Confirmation */
#key-confirmation,
#current-info {
  background: linear-gradient(135deg, #f9fafb 0%, #f3f4f6 100%);
  border: 1px solid rgba(100, 100, 100, 0.1);
  border-radius: 10px;
  color: #4b5563;
  font-size: 12px;
  height: 0;
  line-height: 1.4;
  margin: 0;
  overflow: hidden;
  padding: 0;
  transition: none;
  max-height: none !important;
}

#key-confirmation:not([style*="display: none"]):not([style*="display:none"]),
#current-info:not([style*="display: none"]):not([style*="display:none"]) {
  height: auto;
  margin-top: 4px;
  padding: 8px 10px;
  overflow: visible;
}

#key-confirmation {
  background: linear-gradient(135deg, #fffdf5 0%, #fff7e6 100%);
  border-color: rgba(184, 134, 11, 0.2);
  color: var(--accent-dark);
}

#key-confirmation:not([style*="display: none"]):not([style*="display:none"]) {
  margin-top: 13px;
}

/* Position current-info to align with key input when visible */
.drawer-right #current-info:not([style*="display: none"]):not([style*="display:none"]) {
  margin-top: 4px;
  /* Keep standard spacing instead of negative margin to prevent layout issues */
}

/* On desktop (when grid is side-by-side), add extra spacing to align with payment section */
@media (min-width: 769px) {
  .drawer-right #current-info:not([style*="display: none"]):not([style*="display:none"]) {
    margin-top: 28px;
  }
}

/* Existing Space Preview */
.existing-space-header {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.existing-space-preview {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(184, 134, 11, 0.2);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.existing-space-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

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

/* Checkboxes */
#has-key-toggle,
#terms-check,
#promo-toggle {
  appearance: none;
  background: #ffffff;
  border: 2px solid rgba(184, 134, 11, 0.3);
  border-radius: 6px;
  cursor: pointer;
  height: 20px;
  position: relative;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  vertical-align: middle;
  width: 20px;
  flex-shrink: 0;
}

#has-key-toggle:hover,
#terms-check:hover,
#promo-toggle:hover {
  border-color: rgba(184, 134, 11, 0.5);
}

#has-key-toggle:checked,
#terms-check:checked,
#promo-toggle:checked {
  animation: checkbox-flash 0.3s ease;
  background-color: #b8860b;
  border-color: #b8860b;
}

#has-key-toggle::after,
#terms-check::after,
#promo-toggle::after {
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 20 20' fill='none' stroke='%23ffffff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round' xmlns='http://www.w3.org/2000/svg'%3E%3Cpolyline points='4 11 8 15 16 6'/%3E%3C/svg%3E");
  background-position: center;
  background-repeat: no-repeat;
  background-size: 12px;
  content: "";
  inset: 0;
  opacity: 0;
  position: absolute;
  transform: scale(0.8);
  transition: all 0.2s ease;
}

#has-key-toggle:checked::after,
#terms-check:checked::after,
#promo-toggle:checked::after {
  opacity: 1;
  transform: scale(1);
}

/* File Upload */
.file-upload {
  align-items: center;
  display: flex;
  flex-wrap: nowrap;
  gap: 10px;
  position: relative;
  width: 100%;
}

.file-upload input[type="file"] {
  opacity: 0;
  pointer-events: none;
  position: absolute;
}

.file-button {
  background: linear-gradient(180deg, #fffbf2, #fff9eb);
  border: 1px solid rgba(184, 134, 11, 0.20);
  border-radius: 10px;
  box-shadow: 0 2px 6px rgba(138, 101, 8, 0.08);
  color: #8a6508;
  cursor: pointer;
  font-family: var(--font-main);
  font-size: 12px;
  font-weight: 600;
  padding: 9px 14px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
}

.file-button:hover {
  background: linear-gradient(180deg, #fff6e4, #feecc6);
  border-color: rgba(184, 134, 11, 0.35);
  box-shadow: 0 3px 10px rgba(138, 101, 8, 0.12);
  transform: translateY(-1px);
}

.file-button:active {
  transform: translateY(0) scale(0.98);
}

.file-name {
  color: #636366;
  flex: 1;
  font-size: 11px;
  line-height: 1.4;
  max-width: 100px;
  overflow: hidden;
  overflow-wrap: break-word;
  text-overflow: ellipsis;
  white-space: nowrap;
  word-break: break-word;
}

#file-preview {
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 6px;
  display: none;
  flex-shrink: 0;
  height: 32px;
  margin-right: 0;
  object-fit: cover;
  width: 32px;
}

.remove-file-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  display: none;
  flex-shrink: 0;
  font-size: 20px;
  font-weight: 600;
  line-height: 1;
  padding: 0 4px;
  transition: color 0.2s;
}

/* Drag & Drop Overlay */
.drop-overlay {
  position: absolute;
  inset: 0;
  /* Covers entire parent (drawer) */
  background: rgba(255, 251, 242, 0.95);
  border: 2px dashed rgba(184, 134, 11, 0.6);
  border-radius: 32px;
  /* Match drawer radius */
  backdrop-filter: blur(4px);
  z-index: 2200;
  /* Above everything in drawer */
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
  z-index: 10;
  pointer-events: none;
}

.drop-overlay.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  background: rgba(184, 134, 11, 0.12);
  border-color: rgba(184, 134, 11, 0.6);
}

.drop-overlay-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 600;
}

.drop-overlay-content svg {
  width: 24px;
  height: 24px;
  stroke: var(--accent-dark);

}

.remove-file-btn:hover {
  color: #dc2626;
}

/* --- ENTER KEY HINT (Moved to Drawer) --- */
.key-enter-hint {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: rgba(184, 134, 11, 0.1);
  border: 1px solid rgba(184, 134, 11, 0.2);
  border-radius: 6px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.key-enter-hint svg {
  width: 14px;
  height: 14px;
  stroke: #8a6508;
  stroke-width: 2;
  fill: none;
}

#drawer-key:not(:placeholder-shown)+.key-enter-hint,
#drawer-key:focus+.key-enter-hint {
  opacity: 0.8;
}

/* Terms */
.terms-container {
  align-items: center;
  display: flex;
  gap: 10px;
  margin-bottom: 0;
  margin-top: 0;
  padding-top: 4px;
  max-height: 500px;
  /* Add fade animation like other drawer sections */
  transition: opacity 0.3s ease, max-height 0.3s ease, margin 0.3s ease, padding 0.3s ease;
  opacity: 1;
}

.terms-container.hidden {
  opacity: 0;
  max-height: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
  pointer-events: none;
}

.terms-label {
  color: #333;
  font-size: 11px;
  font-weight: 500;
}

.terms-label a {
  color: #b8860b;
  font-weight: 600;
  text-decoration: none;
}

.terms-label a:hover {
  text-decoration: underline;
}

#support-tab a,
#policy-tab a {
  color: #b8860b;
  text-decoration: none;
}

#support-tab a:hover,
#policy-tab a:hover {
  text-decoration: underline;
}

/* Turnstile */
.turnstile-container {
  align-items: center;
  display: flex;
  justify-content: center;
  margin-top: 16px;
  min-height: 65px;
}

#turnstile-container {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* Drawer Confirm Button */
.drawer-confirm {
  background: #8a6508;
  border: 0;
  border-radius: 14px;
  color: #fffef8;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.3px;
  margin-top: 20px;
  overflow: visible;
  padding: 12px 16px;
  position: relative;
  transition: all 0.4s cubic-bezier(0.2, 0.9, 0.3, 1);
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  outline: none;
  z-index: 10;
}

.drawer-confirm:focus,
.drawer-confirm:focus-visible {
  outline: none;
}

/* Liquid Border Effect - Glowing Rim Light */
.drawer-confirm::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 14px;
  padding: 0;
  background: linear-gradient(90deg, #b8860b, #ffd700, #fff, #ffd700, #b8860b);
  background-size: 400% 100%;
  filter: blur(3px);
  opacity: 0.3;
  animation: liquidBorderGold 6s ease-in-out infinite;
  pointer-events: none;
  z-index: 0;
  transition: filter 0.4s ease, opacity 0.4s ease;
}

@keyframes liquidBorderGold {
  0% {
    background-position: 0% 0%;
  }

  50% {
    background-position: 200% 0%;
  }

  100% {
    background-position: 400% 0%;
  }
}

.drawer-confirm:disabled {
  background: #d1d1d6;
  box-shadow: none !important;
  color: #8e8e93;
  cursor: not-allowed;
  opacity: 0.6;
  transform: none !important;
  position: relative;
}

.drawer-confirm:disabled::before {
  display: none;
}

/* Tooltip on hover for disabled buttons - use data-tooltip instead of title */
.drawer-confirm:disabled[data-tooltip]::after,
.drawer-crypto:disabled[data-tooltip]::after {
  content: attr(data-tooltip);
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  /* CHANGED: Relative to button */
  bottom: auto;
  max-height: 40px;
  left: var(--tooltip-x, 50%);
  top: var(--tooltip-y, 50%);
  /* Position: 12px right of cursor, and shifted up by full height + 10px padding */
  transform: translate(12px, calc(-100% - 10px));
  background: #111827;
  /* Solid background color (gray-900) */
  color: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 9px;
  font-weight: 500;
  text-transform: uppercase;
  white-space: normal;
  max-width: 180px;
  text-align: center;
  line-height: 1.3;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  z-index: 4000;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.12s ease, visibility 0.12s ease;
}

.drawer-confirm:disabled[data-tooltip]:hover::after,
.drawer-crypto:disabled[data-tooltip]:hover::after {
  opacity: 1;
  visibility: visible;
}

@keyframes tooltipFadeIn {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(4px);
  }

  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

/* Inner Glow Layer */
.drawer-confirm::after {
  background: radial-gradient(circle at 50% 0%, rgba(255, 255, 255, 0.25), transparent 70%);
  content: "";
  height: 100%;
  left: 0;
  opacity: 0;
  pointer-events: none;
  position: absolute;
  top: 0;
  transition: opacity 0.3s ease;
  width: 100%;
  border-radius: 14px;
}

.drawer-confirm:hover:not(:disabled) {
  background: linear-gradient(135deg, #9a7209 0%, #c89a0f 100%);
  box-shadow: 0 8px 32px rgba(255, 215, 0, 0.5),
    inset 0 -4px 12px rgba(0, 0, 0, 0.3);
  transform: translateY(-3px);
}

.drawer-confirm:hover:not(:disabled)::before {
  filter: blur(5px);
  opacity: 0.9;
}

.drawer-confirm:hover:not(:disabled)::after {
  opacity: 1;
}

.drawer-confirm:hover:not(:disabled) .button-icon {
  transform: scale(1.15);
  filter: drop-shadow(0 0 8px rgba(255, 215, 0, 0.8));
}

.drawer-confirm:active:not(:disabled) {
  box-shadow: 0 2px 8px rgba(138, 101, 8, 0.20), inset 0 2px 8px rgba(0, 0, 0, 0.1);
  transform: translateY(0) scale(0.98);
  transition: all 0.1s ease;
}

/* Drawer Buttons Container */
.drawer-buttons {
  display: flex;
  flex-direction: row;
  gap: 12px;
  margin-top: 20px;
}

.drawer-buttons .drawer-confirm {
  flex: 2;
  /* Takes 2/3rds */
  margin-top: 0;
  width: auto;
}

.drawer-buttons .drawer-crypto {
  flex: 1;
  /* Takes 1/3rd */
  margin-top: 0;
  width: auto;
}

/* Crypto Button */
.drawer-crypto {
  background: #1e3a8a;
  border: 0;
  border-radius: 14px;
  color: #fff;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.3px;
  overflow: visible;
  padding: 12px 16px;
  position: relative;
  transition: all 0.4s cubic-bezier(0.2, 0.9, 0.3, 1);
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  outline: none;
}

.drawer-crypto:focus,
.drawer-crypto:focus-visible {
  outline: none;
}

/* Liquid Border Effect - Glowing Blue Rim Light */
.drawer-crypto::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 14px;
  padding: 0;
  background: linear-gradient(90deg, #1d4ed8, #3b82f6, #60a5fa, #93c5fd, #60a5fa, #3b82f6, #1d4ed8);
  background-size: 400% 100%;
  filter: blur(3px);
  opacity: 0.3;
  animation: liquidBorderBlue 6s ease-in-out infinite;
  pointer-events: none;
  z-index: 0;
  transition: filter 0.4s ease, opacity 0.4s ease;
}

@keyframes liquidBorderBlue {
  0% {
    background-position: 0% 0%;
  }

  50% {
    background-position: 200% 0%;
  }

  100% {
    background-position: 400% 0%;
  }
}

.drawer-crypto:disabled {
  background: #d1d1d6;
  box-shadow: none !important;
  color: #8e8e93;
  cursor: not-allowed;
  opacity: 0.6;
  position: relative;
}

.drawer-crypto:disabled::before {
  display: none;
}

/* Inner Glow Layer */
.drawer-crypto::after {
  background: radial-gradient(circle at 50% 0%, rgba(147, 197, 253, 0.25), transparent 70%);
  content: "";
  height: 100%;
  left: 0;
  opacity: 0;
  pointer-events: none;
  position: absolute;
  top: 0;
  transition: opacity 0.3s ease;
  width: 100%;
  border-radius: 14px;
}

.drawer-crypto:hover:not(:disabled) {
  background: linear-gradient(135deg, #1e40af 0%, #2563eb 100%);
  box-shadow: 0 8px 32px rgba(59, 130, 246, 0.6),
    inset 0 -4px 12px rgba(0, 0, 0, 0.3);
  transform: translateY(-3px);
}

.drawer-crypto:hover:not(:disabled)::before {
  filter: blur(5px);
  opacity: 0.9;
}

.drawer-crypto:hover:not(:disabled)::after {
  opacity: 1;
}

.drawer-crypto:hover:not(:disabled) .button-icon {
  transform: scale(1.15);
  filter: drop-shadow(0 0 8px rgba(96, 165, 250, 0.8));
}

.drawer-crypto:active:not(:disabled) {
  box-shadow: 0 2px 8px rgba(29, 78, 216, 0.20), inset 0 2px 8px rgba(0, 0, 0, 0.1);
  transform: translateY(0) scale(0.98);
  transition: all 0.1s ease;
}

/* Button Icon & Text Styles */
.button-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s cubic-bezier(0.2, 0.9, 0.3, 1);
  position: relative;
  z-index: 1;
}

.button-text {
  display: inline-block;
  /* Prepare for smooth width collapse */
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  position: relative;
  z-index: 1;
  /* Single transition for all changing properties */
  transition:
    color 0.15s ease-out,
    max-width 0.5s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.5s cubic-bezier(0.4, 0, 0.2, 1),
    margin 0.5s cubic-bezier(0.4, 0, 0.2, 1),
    padding 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Processing State Animations */
.drawer-confirm.processing,
.drawer-crypto.processing {
  pointer-events: none;
  gap: 0;
  transition: gap 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Text collapses width to 0 and fades out */
.drawer-confirm.processing .button-text,
.drawer-crypto.processing .button-text {
  opacity: 0;
  max-width: 0;
  margin: 0;
  padding: 0;
  transform: translateX(20px);
}

/* Icon simply scales up - Flexbox handles the centering movement automatically */
.drawer-confirm.processing .button-icon,
.drawer-crypto.processing .button-icon {
  transform: scale(1.4);
  animation: none;
  /* Disable the old jerky keyframe animation */
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}


@keyframes iconScaleUp {
  0% {
    transform: scale(1);
  }

  100% {
    transform: scale(1.4);
  }
}



/* Card Button Light Scan Animation */
@keyframes lightScan {
  0% {
    left: -100%;
  }

  100% {
    left: 200%;
  }
}

@keyframes goldPulse {

  0%,
  100% {
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.4),
      inset 0 0 20px rgba(255, 215, 0, 0.2);
  }

  50% {
    box-shadow: 0 0 40px rgba(255, 215, 0, 0.8),
      inset 0 0 30px rgba(255, 215, 0, 0.4);
  }
}

.drawer-confirm.processing::after {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 50%;
  height: 100%;
  background: linear-gradient(90deg,
      transparent,
      rgba(255, 255, 255, 0.6),
      transparent);
  animation: lightScan 1.5s ease-in-out infinite;
  opacity: 1;
  pointer-events: none;
}

.drawer-confirm.processing {
  animation: goldPulse 1.5s ease-in-out infinite;
}

/* Crypto Button Matrix Rain Animation */
@keyframes matrixFall1 {
  0% {
    transform: translateY(-100%);
    opacity: 0;
  }

  10% {
    opacity: 1;
  }

  90% {
    opacity: 1;
  }

  100% {
    transform: translateY(200%);
    opacity: 0;
  }
}

@keyframes matrixFall2 {
  0% {
    transform: translateY(-100%);
    opacity: 0;
  }

  15% {
    opacity: 1;
  }

  85% {
    opacity: 1;
  }

  100% {
    transform: translateY(200%);
    opacity: 0;
  }
}

@keyframes matrixFall3 {
  0% {
    transform: translateY(-100%);
    opacity: 0;
  }

  20% {
    opacity: 1;
  }

  80% {
    opacity: 1;
  }

  100% {
    transform: translateY(200%);
    opacity: 0;
  }
}

@keyframes bluePulse {

  0%,
  100% {
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.4),
      inset 0 0 20px rgba(59, 130, 246, 0.2);
  }

  50% {
    box-shadow: 0 0 40px rgba(59, 130, 246, 0.8),
      inset 0 0 30px rgba(59, 130, 246, 0.4);
  }
}

/* Matrix falling columns */
.drawer-crypto.processing {
  animation: bluePulse 1.5s ease-in-out infinite;
  overflow: hidden;
}

/* Matrix rain overlay container */
.matrix-rain {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  border-radius: 14px;
  z-index: 2;
}

/* Individual matrix column */
.matrix-column {
  position: absolute;
  top: -100%;
  font-family: 'Courier New', monospace;
  font-size: 10px;
  line-height: 1.4;
  color: rgba(96, 165, 250, 0.8);
  text-shadow: 0 0 8px rgba(96, 165, 250, 0.9);
  white-space: pre;
  animation: matrixFall1 2s linear infinite;
}

.matrix-column:nth-child(2) {
  animation: matrixFall2 2.3s linear infinite;
  animation-delay: 0.3s;
}

.matrix-column:nth-child(3) {
  animation: matrixFall3 1.8s linear infinite;
  animation-delay: 0.6s;
}

.matrix-column:nth-child(4) {
  animation: matrixFall1 2.1s linear infinite;
  animation-delay: 0.9s;
}

.matrix-column:nth-child(5) {
  animation: matrixFall2 1.9s linear infinite;
  animation-delay: 1.2s;
}

.matrix-column:nth-child(6) {
  animation: matrixFall3 2.2s linear infinite;
  animation-delay: 0.2s;
}

.matrix-column:nth-child(7) {
  animation: matrixFall1 2.4s linear infinite;
  animation-delay: 0.7s;
}

.matrix-column:nth-child(8) {
  animation: matrixFall2 2s linear infinite;
  animation-delay: 1s;
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
  .drawer-buttons {
    flex-direction: column;
  }

  .drawer-buttons .drawer-confirm,
  .drawer-buttons .drawer-crypto {
    width: 100%;
    flex: none;
  }
}

.payment-disclaimer {
  font-size: 8px;
  line-height: 1.4;
  color: var(--muted-color, #888);
  opacity: 0.65;
  text-align: center;
  margin-top: 12px;
  word-wrap: break-word;
  overflow-wrap: break-word;
  max-width: 100%;
  line-height: 1.5;
  padding: 0 8px;
}

/* Processing Overlays */
.processing-overlay {
  align-items: center;
  background: rgba(255, 255, 255, 0.98);
  border-radius: 28px;
  display: none;
  flex-direction: column;
  inset: 0;
  justify-content: center;
  position: absolute;
  z-index: 100;
}

.processing-overlay.active {
  display: flex;
}

.processing-spinner {
  display: none;
}

.processing-infinity {
  margin-bottom: 16px;
  width: 90px;
  height: 40px;
}

.processing-infinity .infinity-svg {
  filter: drop-shadow(0 0 10px rgba(184, 134, 11, 0.6));
}

.processing-infinity .infinity-path {
  fill: none;
  stroke-width: 3.5;
  stroke-linecap: round;
  stroke-dasharray: 180;
  stroke-dashoffset: 180;
  animation: dashFlow 2s linear infinite;
}

@keyframes dashFlow {
  0% {
    stroke-dashoffset: 180;
  }

  100% {
    stroke-dashoffset: -180;
  }
}

.processing-text {
  color: #333;
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
}

.processing-subtext {
  color: var(--muted);
  font-size: 13px;
}

/* Success Overlay */
.success-content {
  padding: 20px;
  text-align: center;
}

.success-icon {
  align-items: center;
  animation: scaleIn 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
  background: linear-gradient(135deg, #fffcf4 0%, #fefce8 100%);
  border: 1px solid rgba(184, 134, 11, 0.15);
  border-radius: 50%;
  display: flex;
  height: 64px;
  justify-content: center;
  margin: 0 auto 20px;
  width: 64px;
}

.success-icon svg {
  height: 32px;
  stroke: var(--accent-color);
  stroke-width: 3;
  width: 32px;
}

.success-title {
  color: var(--accent-dark);
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 12px;
}

.success-details {
  background: rgba(255, 250, 235, 0.6);
  border: 1px solid rgba(184, 134, 11, 0.1);
  border-radius: 12px;
  margin-bottom: 20px;
  padding: 16px;
}

.success-detail-row {
  border-bottom: 1px solid rgba(184, 134, 11, 0.15);
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
}

.success-detail-row:last-child {
  border-bottom: none;
}

.success-detail-label {
  color: #666;
  font-weight: 600;
}

.success-detail-value {
  color: var(--accent-dark);
  font-weight: 700;
}

/* Removed - now using .info-icon with #hover-tooltip system */

.success-note {
  color: #666;
  font-size: 0.75rem;
  font-style: italic;
  margin-top: 8px;
  opacity: 0.8;
  text-align: center;
}

.success-button {
  background: linear-gradient(90deg, var(--accent-soft) 0%, var(--panel) 50%, var(--accent-soft) 100%);
  background-size: 200% 100%;
  animation: successButtonGradient 8s ease infinite;
  border: none;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(184, 134, 11, 0.2);
  color: var(--accent-color);
  cursor: pointer;
  font-weight: 700;
  padding: 12px 24px;
  transition: transform 0.2s, box-shadow 0.2s;
}

@keyframes successButtonGradient {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

.success-button:hover {
  box-shadow: 0 6px 16px rgba(184, 134, 11, 0.3);
  transform: scale(1.05);
}

/* Animations */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes scaleIn {
  from {
    transform: scale(0);
  }

  to {
    transform: scale(1);
  }
}

@keyframes checkbox-flash {
  0% {
    box-shadow: 0 0 0px 4px rgba(184, 134, 11, 0.28);
  }

  100% {
    box-shadow: 0 0 0px 0px rgba(184, 134, 11, 0);
  }
}

@keyframes borderMove {
  0% {
    background-position: 0 0, 0% 0;
  }

  100% {
    background-position: 0 0, 100% 0;
  }
}

@keyframes drawerBorderMove {
  0% {
    background-position: 0 0, 0% 0;
  }

  100% {
    /* FIX: Shift to 200% (equivalent to -2x container width) to match the 200% background-size for a seamless loop */
    background-position: 0 0, 200% 0;
  }
}

@keyframes drawerCoverPulse {

  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(184, 134, 11, 0);
  }

  50% {
    box-shadow: 0 0 30px 3px rgba(184, 134, 11, 0.15);
  }
}


/* --- DECRYPTION ANIMATION FOR TEXT --- */
@keyframes decryptText {
  0% {
    opacity: 0;
    filter: blur(4px);
    letter-spacing: -2px;
  }

  50% {
    opacity: 1;
    filter: blur(0px);
    letter-spacing: 2px;
  }

  100% {
    opacity: 1;
    filter: blur(0);
    letter-spacing: normal;
  }
}

.decrypt-animate {
  animation: decryptText 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

/* Media Queries */
@media (max-width: 768px) {
  #canvasWrap {
    padding: 0;
    margin: 0;
    border-radius: 0;
  }

  #canvas {
    height: 100%;
    width: 100%;
    border-radius: 0;
    box-shadow: none;
  }

  .drawer {
    border-radius: 22px;
    height: auto;
    left: 50%;
    /* FIX: Ensure drawer has room to grow but stays within viewport */
    max-height: 85vh;
    max-height: 85dvh;
    max-width: 96vw;
    min-width: 0;
    padding: 0;
    right: auto;
    top: 16px;
    width: 96vw;
    /* FIX: Explicit flex direction for scrolling context */
    display: flex;
    flex-direction: column;
    /* FIX: Ensure drawer is properly centered */
  }

  .drawer-grid {
    display: flex !important;
    /* Override grid layout */
    flex-direction: column !important;
    /* Stack columns vertically */
    gap: 0;
    /* No gap - using margins for uniform spacing */
    flex-shrink: 0;
    /* Don't shrink, let parent scroll instead */
  }

  .drawer-left {
    margin-bottom: 6px;
    /* Reduced spacing after left column */
  }

  .drawer-left,
  .drawer-right {
    display: flex;
    flex-direction: column;
    gap: 0;
    /* No gap - using margins for uniform spacing */
  }

  .drawer-right {
    padding-top: 0;
  }

  .drawer-row {
    margin-bottom: 0 !important;
    /* Override base style */
  }

  .drawer-row.compact {
    margin-bottom: 6px !important;
    /* Minimal spacing after key toggle */
  }

  .drawer-section {
    margin-bottom: 10px !important;
    /* Uniform spacing between all sections */
    padding-bottom: 0;
  }

  .drawer-section.compact {
    margin-bottom: 10px !important;
    /* Same spacing for compact sections */
  }

  #key-section {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    padding-bottom: 10px;
    overflow: visible;
    /* Normalize spacing for mobile - prevents gap when hidden */
  }

  #name-section {
    margin-top: 0 !important;
    /* No top margin - spacing controlled by element above */
    margin-bottom: 10px !important;
    /* Same spacing after name input */
  }

  #payment-section {
    margin-top: 0 !important;
    /* No top margin - spacing controlled by element above */
    margin-bottom: 10px !important;
    /* Same spacing after payment inputs */
  }

  .drawer-content {
    padding: 20px 24px;
    /* FIX: Remove fixed height calc, use flex to fill available space */
    height: auto;
    max-height: none;
    min-height: 0;
    /* Crucial for flex scrolling */
    flex: 1 1 auto;
    overflow-y: auto;
    /* Enable scroll on mobile */
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
  }

  #drawer-bottom-section {
    margin-top: 10px !important;
    /* Override auto margin with uniform spacing */
    padding-top: 0;
  }

  .terms-container {
    margin-bottom: 5px !important;
    padding-top: 0 !important;
    /* Reduced spacing around terms toggle */
  }

  .drawer-scroll-indicator {
    height: 25px;
    padding-bottom: 4px;
    border-bottom-left-radius: 22px;
    border-bottom-right-radius: 22px;
  }

  .drawer-scroll-indicator svg {
    width: 18px;
    height: 18px;
  }

  /* Mobile: Stack all inputs vertically except payment USD/% row */
  .split-inputs {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 10px !important;
    /* Uniform spacing within payment row */
  }

  /* Mobile: Payment buttons stacked vertically, card above crypto */
  .drawer-buttons {
    flex-direction: column !important;
    gap: 10px !important;
    margin-top: 0 !important;
    /* No extra margin, controlled by drawer-bottom-section */
  }

  .drawer-buttons .drawer-confirm {
    width: 100% !important;
    flex: none !important;
    order: 1 !important;
  }

  .drawer-buttons .drawer-crypto {
    width: 100% !important;
    flex: none !important;
    order: 2 !important;
  }

  .drawer-tab {
    display: none !important;
  }

  .drawer h2 {
    font-size: 17px;
  }

  .drawer input[type="text"],
  .drawer input[type="number"],
  .drawer input[type="url"],
  .drawer input[type="file"],
  .drawer input[type="email"] {
    font-size: 13px;
    padding: 8px 8px;
  }

  .drawer-confirm {
    border-radius: 10px;
    font-size: 13px;
    padding: 8px 7px;
  }
}

@media (max-width: 480px) {
  #canvasWrap {
    padding: 0;
    margin: 0;
    border-radius: 0;
  }

  #canvas {
    height: 100%;
    width: 100%;
    border-radius: 0;
    box-shadow: none;
  }

  .drawer {
    border-radius: 16px;
    height: auto;
    left: 50%;
    /* FIX: Give it space */
    max-height: 88vh;
    max-height: 87dvh;
    max-width: 95vw;
    min-width: 0;
    padding: 0;
    right: auto;
    top: 12px;
    width: 98vw;
    display: flex;
    flex-direction: column;
  }

  .drawer-grid {
    display: flex !important;
    /* Stack as flex column for consistent behavior */
    flex-direction: column !important;
    gap: 0;
    /* No gap - using margins for uniform spacing */
    flex-shrink: 0;
    /* Don't shrink, let parent scroll instead */
  }

  .drawer-left {
    margin-bottom: 6px;
    /* Reduced spacing after left column */
  }

  .drawer-left,
  .drawer-right {
    display: flex;
    flex-direction: column;
    gap: 0;
    /* No gap - using margins for uniform spacing */
  }

  .drawer-right {
    padding-top: 0;
  }

  .drawer-row {
    margin-bottom: 0 !important;
    /* Override base style */
  }

  .drawer-row.compact {
    margin-bottom: 6px !important;
    /* Minimal spacing after key toggle */
  }

  .drawer-section {
    margin-bottom: 10px !important;
    /* Uniform spacing between all sections */
    padding-bottom: 0;
  }

  .drawer-section.compact {
    margin-bottom: 10px !important;
    /* Same spacing for compact sections */
  }

  #key-section {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    padding-bottom: 10px;
    overflow: visible;
    /* Normalize spacing for mobile - prevents gap when hidden */
  }

  #name-section {
    margin-top: 0 !important;
    /* No top margin - spacing controlled by element above */
    margin-bottom: 10px !important;
    /* Same spacing after name input */
  }

  #payment-section {
    margin-top: 0 !important;
    /* No top margin - spacing controlled by element above */
    margin-bottom: 10px !important;
    /* Same spacing after payment inputs */
  }

  #drawer-bottom-section {
    margin-top: 10px !important;
    /* Override auto margin with uniform spacing */
    padding-top: 0;
  }

  .terms-container {
    margin-bottom: 5px !important;
    padding-top: 0 !important;
    /* Reduced spacing around terms toggle */
  }

  .drawer-scroll-indicator {
    height: 22px;
    padding-bottom: 3px;
    border-bottom-left-radius: 16px;
    border-bottom-right-radius: 16px;
  }

  .drawer-scroll-indicator svg {
    width: 16px;
    height: 16px;
  }

  .drawer-content {
    padding: 12px 4vw 20px;
    /* FIX: Enable proper scrolling for stacked elements */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
    max-height: none;
    /* Removed broken calc */
  }

  /* Mobile: Stack all inputs vertically except payment USD/% row */
  .split-inputs {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 10px !important;
    /* Uniform spacing within payment row */
  }

  /* Mobile: Payment buttons stacked vertically, card above crypto */
  .drawer-buttons {
    flex-direction: column !important;
    gap: 10px !important;
    margin-top: 0 !important;
    /* No extra margin, controlled by drawer-bottom-section */
  }

  .drawer-buttons .drawer-confirm {
    width: 100% !important;
    flex: none !important;
    order: 1 !important;
  }

  .drawer-buttons .drawer-crypto {
    width: 100% !important;
    flex: none !important;
    order: 2 !important;
  }

  .modal-content {
    max-height: 80vh;
    padding: 20px 16px;
  }


  #has-key-toggle {
    width: 16px !important;
    height: 16px !important;
  }

  .drawer-row {
    gap: 6px;
    font-size: 11px;
  }

  .drawer-row:not(.compact) {
    margin-bottom: 10px;
  }

  /* CRITICAL: Force 16px font size on inputs to prevent iOS zoom-in */
  .drawer input[type="text"],
  .drawer input[type="number"],
  .drawer input[type="url"],
  .drawer input[type="file"],
  .drawer input[type="email"] {
    font-size: 13px !important;
    padding: 10px 12px;
  }
}

/* Fix: Adjust banner text size for tablet/intermediate widths to prevent overflow */
@media (min-width: 693px) and (max-width: 900px) {
  #drawer-cover-banner span {
    font-size: clamp(0.5rem, 1.8vw, 1.2rem);
  }
}

@media (max-height: 700px) {
  .modal-content {
    max-height: 70vh;
  }
}

@media (max-height: 500px) {
  .modal-content {
    max-height: 85vh;
    padding: 20px 18px;
  }
}


/* ============================================
     NEW LUXURY LOADING SCREEN STYLES
     ============================================ */

#loader-overlay {
  background: #ffffff;
  display: flex;
  inset: 0;
  justify-content: center;
  align-items: center;
  position: fixed;
  z-index: 9999;
  pointer-events: auto;
}

#loader-overlay.finished {
  pointer-events: none;
  animation: consumeScreen 0.5s cubic-bezier(0.7, 0, 0.2, 1) forwards 0.4s;
}

@keyframes consumeScreen {
  0% {
    clip-path: circle(150% at 50% 50%);
    background: #ffffff;
  }

  100% {
    clip-path: circle(0% at 50% 50%);
    background: #ffffff;
  }
}

.loader-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: visible;
  padding: 40px;
  transition: all 0.5s ease;
}

.loader-text {
  font-family: var(--font-main);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.6em;
  color: var(--accent-dark);
  margin-bottom: 20px;

  background: linear-gradient(110deg, #8a6508 30%, #ffd700 45%, #8a6508 60%);
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  color: transparent;

  animation:
    textReveal 1.2s cubic-bezier(0.2, 0.8, 0.2, 1) forwards,
    textShine 3s linear infinite;

  opacity: 0;
  transform: translateY(20px);
}

.finished .loader-text,
.finished .loader-sub {
  animation:
    textReveal 1.2s cubic-bezier(0.2, 0.8, 0.2, 1) forwards,
    textShine 3s linear infinite,
    suckText 0.6s cubic-bezier(0.6, -0.28, 0.735, 0.045) forwards;
}

@keyframes suckText {
  0% {
    transform: scale(1);
    opacity: 1;
    filter: blur(0);
    max-height: 50px;
    margin-bottom: 20px;
  }

  100% {
    transform: scale(0.2) translateY(10px);
    opacity: 0;
    filter: blur(10px);
    max-height: 0;
    margin-bottom: 0;
    margin-top: 0;
  }
}

.loader-line {
  width: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent-color), transparent);
  animation:
    lineGrow 1.5s cubic-bezier(0.7, 0, 0.3, 1) forwards 0.5s,
    linePulse 2s ease-in-out infinite 2s;
  opacity: 0.8;
  transition: transform 0.5s ease;
}

.finished .loader-line {
  animation:
    lineGrow 1.5s cubic-bezier(0.7, 0, 0.3, 1) forwards 0.5s,
    linePulse 2s ease-in-out infinite 2s,
    formGoldSingularity 0.8s cubic-bezier(0.7, 0, 0.2, 1) forwards 0.5s;
}

@keyframes formGoldSingularity {
  0% {
    width: 60px;
    height: 2px;
    background: var(--accent-color);
    box-shadow: none;
    border-radius: 0;
  }

  40% {
    width: 2px;
    height: 2px;
    border-radius: 50%;
    background: var(--accent-color);
    box-shadow: 0 0 10px var(--accent-color);
  }

  100% {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-color);
    box-shadow: 0 0 20px var(--accent-color), 0 0 40px var(--accent-color), 0 0 60px #ffd700;
    transform: scale(2);
  }
}

.loader-sub {
  font-family: var(--font-main);
  font-size: 9px;
  letter-spacing: 0.3em;
  color: var(--muted);
  margin-top: 15px;
  opacity: 0;
  text-transform: uppercase;
  animation: fadeSub 1s ease forwards 1.2s;
}

@keyframes textReveal {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes textShine {
  to {
    background-position: 200% center;
  }
}

@keyframes lineGrow {
  0% {
    width: 0;
    opacity: 0;
  }

  50% {
    width: 120px;
    opacity: 1;
  }

  100% {
    width: 60px;
    opacity: 0.6;
  }
}

@keyframes linePulse {

  0%,
  100% {
    opacity: 0.6;
    transform: scaleX(1);
  }

  50% {
    opacity: 0.85;
    transform: scaleX(1.08);
  }
}

@keyframes fadeSub {
  to {
    opacity: 0.5;
  }
}

/* Desktop Hover Card */
#hover-card {
  position: fixed;
  pointer-events: none;
  z-index: 3000;
  opacity: 0;
  transform: scale(0.95);
  transition: opacity 0.2s cubic-bezier(0.2, 0.8, 0.2, 1),
    transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1),
    width 0.35s cubic-bezier(0.16, 1, 0.3, 1),
    /* Smooth width */
    height 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  /* Smooth height */
}

#hover-card.visible {
  opacity: 1;
  transform: scale(1);
}

.hover-card-inner {
  background: linear-gradient(135deg, #ffffff 0%, #fefefe 100%);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(184, 134, 11, 0.1);
  border-radius: 10px;
  padding: 10px 14px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06),
    0 1px 4px rgba(0, 0, 0, 0.03);
  min-width: 180px;
  position: relative;
  overflow: hidden;
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  /* Match parent transition */
}

#hover-card.expanded .hover-card-inner {
  min-width: 340px;
  max-width: 90vw;
  min-height: 180px;
  max-height: 400px;
  padding: 16px 20px;
  overflow-y: auto;
}

.hover-card-inner::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1.5px;
  background: linear-gradient(90deg, transparent, rgba(184, 134, 11, 0.25), transparent);
  opacity: 0.5;
}

.hover-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 6px;
}

.hover-card-header-left {
  flex: 1;
  min-width: 0;
}

.hover-card-name {
  font-size: 13px;
  font-weight: 700;
  color: #1a1a1a;
  margin-bottom: 4px;
  letter-spacing: 0.2px;
  /* MOBILE FIX: Handle long names gracefully with word wrapping */
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
}

.hover-card-percent {
  font-size: 11px;
  color: var(--accent-color);
  font-weight: 600;
  margin-bottom: 0;
}

.hover-card-key {
  font-size: 9px;
  color: rgba(0, 0, 0, 0.45);
  font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
  letter-spacing: 0.3px;
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  flex-shrink: 0;
  align-self: flex-start;
  display: none;
  transition: opacity 0.3s ease 0.1s, max-height 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

#hover-card.expanded .hover-card-key {
  opacity: 1;
  max-height: 50px;
  display: block;
}

#hover-card:not(.expanded) .hover-card-header {
  flex-direction: column;
  gap: 0;
}

.hover-card-hint {
  font-size: 8px;
  color: rgba(0, 0, 0, 0.4);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  transition: opacity 0.2s ease;
  margin-bottom: 6px;
}

#hover-card.expanded .hover-card-hint {
  margin-bottom: 2px;
}

#hover-card.expanded .hover-card-hint-desktop {
  font-size: 0;
}

#hover-card.expanded .hover-card-hint-mobile {
  font-size: 0;
  line-height: 0;
  visibility: hidden;
}

.hover-card-hint-mobile {
  display: none;
}

body.touch-device .hover-card-hint-desktop {
  display: none;
}

body.touch-device .hover-card-hint-mobile {
  display: block;
}

/* Mobile compact hover card */
#hover-card.mobile-compact .hover-card-inner {
  min-width: 160px;
  max-width: 220px;
  padding: 8px 12px;
  font-size: 11px;
  transition: height 0.35s cubic-bezier(0.16, 1, 0.3, 1),
    min-height 0.35s cubic-bezier(0.16, 1, 0.3, 1),
    max-height 0.35s cubic-bezier(0.16, 1, 0.3, 1),
    padding 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  /* Only animate height, not width */
}

#hover-card.mobile-compact .hover-card-name {
  font-size: 11px;
  margin-bottom: 2px;
}

#hover-card.mobile-compact .hover-card-percent {
  font-size: 9px;
  margin-bottom: 4px;
}

#hover-card.mobile-compact .hover-card-hint {
  font-size: 7px;
}

#hover-card.mobile-compact.expanded .hover-card-inner {
  min-width: 200px;
  max-width: 280px;
  padding: 10px 14px;
  max-height: 320px;
  font-size: 11px;
}

#hover-card.expanded .hover-card-hint-desktop::before {
  content: 'Press shift to close details';
  font-size: 8px;
}

#hover-card.expanded .hover-card-hint-mobile::before {
  content: 'Tap legacy once to close, twice to open link';
  font-size: 8px;
  visibility: visible;
  line-height: normal;
}

.hover-card-body {
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1) 0.1s,
    max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#hover-card.expanded .hover-card-body {
  opacity: 1;
  max-height: 2000px;
  margin-top: 20px;
}

/* Expanded Detail Panel */
#detail-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  width: 480px;
  max-width: 90vw;
  max-height: 85vh;
  background: linear-gradient(135deg, rgba(10, 10, 12, 0.97) 0%, rgba(0, 0, 0, 0.98) 100%);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(184, 134, 11, 0.25);
  border-radius: 20px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(184, 134, 11, 0.1) inset;
  opacity: 0;
  pointer-events: none;
  z-index: 4000;
  overflow: hidden;
  transition: opacity 0.3s cubic-bezier(0.2, 0.8, 0.2, 1),
    transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

#detail-panel.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}

#detail-panel::before {
  content: '';
  position: absolute;
  inset: -2px;
  background: linear-gradient(45deg,
      transparent 0%,
      var(--accent-color) 20%,
      transparent 40%,
      transparent 60%,
      var(--accent-color) 80%,
      transparent 100%);
  background-size: 200% 200%;
  border-radius: 20px;
  opacity: 0.2;
  animation: borderPulse 4s linear infinite;
  z-index: -1;
}

@keyframes borderPulse {
  0% {
    background-position: 0% 0%;
  }

  100% {
    background-position: 200% 200%;
  }
}

.detail-panel-header {
  padding: 24px 28px 20px;
  border-bottom: 1px solid rgba(184, 134, 11, 0.15);
  position: relative;
}

.detail-panel-title {
  font-size: 20px;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 8px;
  letter-spacing: 0.5px;
}

.detail-panel-subtitle {
  font-size: 12px;
  color: var(--accent-color);
  font-weight: 600;
}

.detail-panel-close {
  position: absolute;
  top: 20px;
  right: 20px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.6);
  font-size: 18px;
  transition: all 0.2s ease;
}

.detail-panel-close:hover {
  background: rgba(184, 134, 11, 0.2);
  border-color: var(--accent-color);
  color: var(--accent-color);
  transform: scale(1.1);
}

.detail-panel-body {
  padding: 24px 28px;
  overflow-y: auto;
  max-height: calc(85vh - 200px);
}

.detail-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.detail-stats-grid:only-of-type {
  grid-template-columns: repeat(2, 1fr);
  margin-bottom: 16px;
}

.detail-stat {
  background: linear-gradient(135deg, #fafafa 0%, #ffffff 100%);
  border: 1px solid rgba(184, 134, 11, 0.08);
  border-radius: 8px;
  padding: 8px 10px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.02);
}

.detail-stat::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1.5px;
  background: linear-gradient(90deg, transparent, rgba(184, 134, 11, 0.18), transparent);
  opacity: 0.5;
}

.detail-stat-label {
  font-size: 7px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: rgba(0, 0, 0, 0.45);
  margin-bottom: 4px;
  font-weight: 600;
}

.detail-stat-value {
  font-size: 15px;
  font-weight: 700;
  color: var(--accent-color);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.detail-stat-unit {
  font-size: 9px;
  color: rgba(0, 0, 0, 0.5);
  margin-left: 1px;
  font-weight: 500;
}

.detail-timeline-section {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(184, 134, 11, 0.08);
}

.detail-image-section {
  margin-top: 12px;
  margin-bottom: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(184, 134, 11, 0.08);
}

.detail-image-container {
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(0, 0, 0, 0.02);
  border-radius: 6px;
  padding: 8px;
}

.detail-original-image {
  max-width: 100%;
  max-height: 200px;
  width: auto;
  height: auto;
  display: block;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  object-fit: contain;
}

.detail-section-title {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: rgba(0, 0, 0, 0.5);
  margin-bottom: 14px;
  font-weight: 700;
}

.timeline-container {
  position: relative;
  padding: 12px 0;
}

.timeline-line {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1.5px;
  background: linear-gradient(90deg,
      transparent 0%,
      rgba(184, 134, 11, 0.12) 10%,
      rgba(184, 134, 11, 0.12) 90%,
      transparent 100%);
  transform: translateY(-50%);
}

.timeline-nodes {
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
  z-index: 1;
}

.timeline-node {
  width: 8px;
  height: 8px;
  background: var(--accent-color);
  border: 1.5px solid #ffffff;
  border-radius: 50%;
  box-shadow: 0 1px 6px rgba(184, 134, 11, 0.25),
    0 0 0 2px rgba(184, 134, 11, 0.08);
  animation: nodePulse 2s ease-in-out infinite;
  position: relative;
  cursor: pointer;
  transition: all 0.2s ease;
}

.timeline-node:hover {
  transform: scale(1.25);
  box-shadow: 0 2px 10px rgba(184, 134, 11, 0.35),
    0 0 0 3px rgba(184, 134, 11, 0.12);
}

.timeline-node:nth-child(2) {
  animation-delay: 0.3s;
}

.timeline-node:nth-child(3) {
  animation-delay: 0.6s;
}

.timeline-node:nth-child(4) {
  animation-delay: 0.9s;
}

.timeline-node:nth-child(5) {
  animation-delay: 1.2s;
}

@keyframes nodePulse {

  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.15);
  }
}

.timeline-node-tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: #ffffff;
  border: 1px solid rgba(184, 134, 11, 0.15);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 9px;
  color: #333;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 10;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.timeline-node:hover .timeline-node-tooltip {
  opacity: 1;
}

.timeline-node-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #ffffff;
}

.detail-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px 16px;
}

.detail-loading-spinner {
  width: 26px;
  height: 26px;
  border: 2.5px solid rgba(184, 134, 11, 0.12);
  border-top-color: var(--accent-color);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-bottom: 10px;
}

.detail-loading-text {
  font-size: 10px;
  color: rgba(0, 0, 0, 0.5);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 600;
}

/* Mobile Center Crosshair */
#mobile-crosshair {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 24px;
  height: 24px;
  pointer-events: none;
  z-index: 2500;
  opacity: 0;
  transition: opacity 0.3s ease;
}

#mobile-crosshair.visible {
  opacity: 0.6;
}

#mobile-crosshair.overlay-active {
  opacity: 0 !important;
}

.crosshair-inner {
  position: absolute;
  inset: 0;
}

.crosshair-inner::before,
.crosshair-inner::after {
  content: '';
  position: absolute;
  background: var(--accent-color);
  box-shadow: 0 0 4px var(--accent-color);
}

.crosshair-inner::before {
  left: 50%;
  top: 0;
  bottom: 0;
  width: 1px;
  transform: translateX(-50%);
}

.crosshair-inner::after {
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  transform: translateY(-50%);
}

.crosshair-dot {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 4px;
  height: 4px;
  background: var(--accent-color);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 8px var(--accent-color);
  animation: crosshairPulse 1.5s ease-in-out infinite;
}

@keyframes crosshairPulse {

  0%,
  100% {
    opacity: 0.8;
    transform: translate(-50%, -50%) scale(1);
  }

  50% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.5);
  }
}

@media (max-width: 768px) {
  #topbar {
    /* Sit above the 40px panel grip + 8px breathing room */
    bottom: calc(40px + 8px);
    right: 16px;
    left: 16px;
    justify-content: center;
  }

  #topbar-inner {
    width: 100%;
    max-width: 100%;
  }

  #topbar-inner.search-active {
    max-width: 100%;
    width: 100%;
  }

  #search-results {
    max-width: calc(100vw - 48px);
    min-width: calc(100vw - 80px);
    left: 50%;
  }

  #hover-card {
    max-width: calc(100vw - 40px) !important;
  }

  #hover-card.expanded .hover-card-inner {
    min-width: calc(100vw - 40px);
    max-width: calc(100vw - 40px);
    min-height: 160px;
    max-height: 70vh;
  }

  #detail-panel {
    width: 95vw;
    max-height: 90vh;
    /* Position detail panel to not block tapped space on mobile */
    max-width: 95vw;
  }

  .detail-stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .detail-stat {
    padding: 8px 8px;
  }

  .detail-panel-header {
    padding: 20px 20px 16px;
  }

  .detail-panel-body {
    padding: 20px;
    max-height: calc(90vh - 180px);
  }

  .zoom-controls {
    left: 16px;
    bottom: 24px;
  }

  .modal-content {
    width: 95vw;
    max-width: 95vw;
    padding: 24px 20px;
  }

  .age-gate-content {
    padding: 30px 24px;
  }
}

@media (max-width: 480px) {
  #topbar {
    bottom: calc(40px + 8px);
    right: 12px;
    left: 12px;
  }

  .top-btn {
    padding: 8px 12px;
    font-size: 13px;
  }

  .top-btn.search-icon,
  .top-btn.leaderboard-icon {
    padding: 8px;
  }

  #search-results {
    max-width: calc(100vw - 32px);
    min-width: calc(100vw - 48px);
  }

  #hover-card.expanded .hover-card-inner {
    min-width: calc(100vw - 32px);
    max-width: calc(100vw - 32px);
    min-height: 150px;
    max-height: 65vh;
    padding: 14px 16px;
  }

  .hover-card-name {
    font-size: 12px;
  }

  .hover-card-percent {
    font-size: 10px;
  }

  .detail-panel-title {
    font-size: 16px;
  }

  .detail-stat {
    padding: 7px 8px;
  }

  .detail-stat-value {
    font-size: 14px;
  }

  .detail-stat-label {
    font-size: 6.5px;
    letter-spacing: 0.5px;
  }

  .detail-stat-unit {
    font-size: 8px;
  }

  .zoom-controls {
    left: 12px;
    bottom: 20px;
    gap: 4px;
  }

  .zoom-btn {
    width: 34px;
    height: 34px;
    min-width: 34px;
    min-height: 34px;
  }

  .zoom-btn svg {
    width: 18px;
    height: 18px;
  }

  .modal-content {
    width: 96vw;
    max-width: 96vw;
    padding: 20px 16px;
    border-radius: 16px;
  }

  .modal-content h2 {
    font-size: 18px;
  }

  .age-gate-content {
    padding: 24px 16px;
  }

  .age-gate-btn {
    padding: 10px 20px;
    font-size: 13px;
  }
}



/* ============================================
   ADDITIONAL STYLES
   ============================================ */

/* Leaderboard button icon - enhanced fill animation */
.top-btn.leaderboard-icon svg {
  height: 18px;
  width: 18px;
}

.top-btn.leaderboard-icon:hover svg {
  fill: currentColor;
}

.top-btn.leaderboard-icon.active svg {
  fill: currentColor;
}

#leaderboard-panel {
  position: fixed;

  /* VERTICAL POSITIONING: Match search-results exactly
     Search-results uses: bottom: calc(100% + 12px) relative to #search-container (inside #topbar-inner)
     This places it 12px above the top of #search-container.

     #search-container sits inside #topbar-inner at the same level as the buttons.
     Button height with padding: 10px + 10px + ~20px SVG = ~40px
     #topbar-inner padding: 8px top + 8px bottom = 16px
     Total #topbar-inner height: 40px (buttons) + 16px (padding) = 56px

     From viewport: #topbar bottom (24px) + #topbar-inner height (56px) + gap (12px)
     BUT let's try a smaller height estimate to close the gap: ~48px for #topbar-inner */
  bottom: calc(24px + 48px + 12px);

  /* HORIZONTAL POSITIONING: Match #topbar-inner exactly
     #topbar is at right: 24px from viewport
     #topbar-inner sits directly inside with no offset
     Therefore: right: 24px aligns leaderboard's right edge with #topbar (and #topbar-inner) */
  right: 24px;
  left: auto;

  /* WIDTH: Must match #topbar-inner's actual width when collapsed
     Measurement from buttons:
     - padding-left: 8px
     - "Info" button: ~50px (text + padding)
     - margin-left on .subtle: 5px
     - gap: 8px
     - Leaderboard icon: 40px (10px padding × 2 + 20px SVG)
     - gap: 8px
     - Search icon: 40px
     - padding-right: 8px
     Total: 8 + 50 + 5 + 8 + 40 + 8 + 40 + 8 = 167px

     But adding some buffer for text rendering variations: ~172px */
  width: 192px;

  max-height: 0;
  overflow: hidden;

  /* MATCH TOOLBAR: Same background and border as toolbar */
  background: linear-gradient(135deg, #fffbf2 0%, #fff9eb 100%);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(var(--modal-accent), 0.20);
  border-radius: 14px;
  box-shadow: 0 4px 16px rgba(var(--modal-accent), 0.10), 0 1px 4px rgba(var(--modal-accent), 0.08);
  z-index: 1050;
  opacity: 0;

  /* SYNC WITH SEARCH: Match search container transition exactly */
  transition: max-height 0.5s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.3s ease,
    right 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: max-height, right;
  box-sizing: border-box;
  transform: translateZ(0);
  /* Force GPU acceleration */
  backface-visibility: hidden;
  /* Prevent flickering */
}

#leaderboard-panel.open {
  max-height: 500px;
  opacity: 1;
}

@media (min-width: 769px) {
  #leaderboard-panel.shifted {
    /* When search opens, #search-container becomes active with max-width: 240px
       This expands #topbar-inner leftward by: 240px (search width) + 8px (gap) = 248px

       Starting position: right: 24px
       Must shift right by the expansion amount: 24px + 248px = 272px */
    right: calc(24px + 260px);
  }
}

.leaderboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid rgba(184, 134, 11, 0.1);
}

.leaderboard-title {
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--accent-dark);
  background: linear-gradient(110deg, #8a6508 30%, #d4a843 50%, #8a6508 70%);
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: leaderboardShine 3s linear infinite;
}

@keyframes leaderboardShine {
  to {
    background-position: 200% center;
  }
}

.leaderboard-close-btn {
  background: rgba(0, 0, 0, 0.03);
  border: none;
  border-radius: 50%;
  color: var(--muted);
  cursor: pointer;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 500;
  line-height: 1;
  padding: 0;
  transition: all 0.2s ease;
}

.leaderboard-close-btn:hover {
  background: rgba(var(--modal-accent), 0.1);
  color: var(--accent-color);
  transform: rotate(90deg);
}

.leaderboard-content {
  padding: 12px 16px 16px;
  max-height: 380px;
  overflow-y: auto;
}

.leaderboard-loading {
  display: flex;
  justify-content: center;
  padding: 30px;
}

.leaderboard-empty {
  text-align: center;
  color: var(--muted);
  padding: 30px;
  font-size: 13px;
}

.leaderboard-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  margin-bottom: 6px;
  border-radius: 12px;
  /* MATCH LEADERBOARD PANEL: Same background as leaderboard panel */
  background: linear-gradient(135deg, #fffbf2 0%, #fff9eb 100%);
  border: 1px solid rgba(0, 0, 0, 0.04);
  cursor: pointer;
  transition: all 0.2s ease;
}

.leaderboard-item:hover {
  background: linear-gradient(135deg, #fffdf5 0%, #fff8e6 100%);
  border-color: rgba(184, 134, 11, 0.15);
  transform: translateX(4px);
  box-shadow: 0 4px 12px rgba(184, 134, 11, 0.1);
}

.leaderboard-item:last-child {
  margin-bottom: 0;
}

.leaderboard-rank {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  background: #f3f3f3;
  border-radius: 6px;
  flex-shrink: 0;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.leaderboard-item.rank-1 .leaderboard-rank {
  background: linear-gradient(135deg, #ffd700 0%, #ffec8b 50%, #ffd700 100%);
  background-size: 200% 200%;
  color: #8a6508;
  box-shadow: 0 0 12px rgba(255, 215, 0, 0.4);
  animation: goldPulse 2s ease-in-out infinite;
}

.leaderboard-item.rank-2 .leaderboard-rank {
  background: linear-gradient(135deg, #c0c0c0 0%, #e8e8e8 50%, #c0c0c0 100%);
  background-size: 200% 200%;
  color: #666;
  box-shadow: 0 0 8px rgba(192, 192, 192, 0.4);
  animation: silverPulse 2s ease-in-out infinite 0.3s;
}

.leaderboard-item.rank-3 .leaderboard-rank {
  background: linear-gradient(135deg, #cd7f32 0%, #e6a65c 50%, #cd7f32 100%);
  background-size: 200% 200%;
  color: #5c3d1e;
  box-shadow: 0 0 8px rgba(205, 127, 50, 0.4);
  animation: bronzePulse 2s ease-in-out infinite 0.6s;
}

@keyframes goldPulse {

  0%,
  100% {
    background-position: 0% 50%;
    transform: scale(1);
  }

  50% {
    background-position: 100% 50%;
    transform: scale(1.05);
  }
}

@keyframes silverPulse {

  0%,
  100% {
    background-position: 0% 50%;
    transform: scale(1);
  }

  50% {
    background-position: 100% 50%;
    transform: scale(1.05);
  }
}

@keyframes bronzePulse {

  0%,
  100% {
    background-position: 0% 50%;
    transform: scale(1);
  }

  50% {
    background-position: 100% 50%;
    transform: scale(1.05);
  }
}

.leaderboard-rank.animated {
  position: relative;
}

.leaderboard-item.rank-1 .leaderboard-rank::after {
  content: '★';
  position: absolute;
  top: -6px;
  right: -6px;
  font-size: 10px;
  color: #ffd700;
  animation: starTwinkle 1.5s ease-in-out infinite;
}

@keyframes starTwinkle {

  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }

  50% {
    opacity: 0.5;
    transform: scale(0.8);
  }
}

.leaderboard-image-container {
  width: 24px;
  height: 24px;
  position: relative;
  flex-shrink: 0;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: #f3f3f3;
}

.leaderboard-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.leaderboard-image-blur {
  filter: blur(20px);
}

.leaderboard-image-18 {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.8);
  color: white;
  font-size: 7px;
  font-weight: 700;
  padding: 2px 3px;
  border-radius: 2px;
  pointer-events: none;
  z-index: 2;
}


.leaderboard-image-container.rank-1 {
  border: 1px solid #ffd700;
  box-shadow: 0 0 8px rgba(255, 215, 0, 0.5), inset 0 0 10px rgba(255, 215, 0, 0.2);
  animation: goldGlow 2s ease-in-out infinite;
}

.leaderboard-image-container.rank-2 {
  border: 1px solid #c0c0c0;
  box-shadow: 0 0 6px rgba(192, 192, 192, 0.5), inset 0 0 8px rgba(192, 192, 192, 0.2);
  animation: silverGlow 2s ease-in-out infinite 0.3s;
}

.leaderboard-image-container.rank-3 {
  border: 1px solid #cd7f32;
  box-shadow: 0 0 6px rgba(205, 127, 50, 0.5), inset 0 0 8px rgba(205, 127, 50, 0.2);
  animation: bronzeGlow 2s ease-in-out infinite 0.6s;
}

@keyframes goldGlow {

  0%,
  100% {
    box-shadow: 0 0 16px rgba(255, 215, 0, 0.5), inset 0 0 20px rgba(255, 215, 0, 0.2);
    transform: scale(1);
  }

  50% {
    box-shadow: 0 0 24px rgba(255, 215, 0, 0.7), inset 0 0 30px rgba(255, 215, 0, 0.3);
    transform: scale(1.05);
  }
}

@keyframes silverGlow {

  0%,
  100% {
    box-shadow: 0 0 12px rgba(192, 192, 192, 0.5), inset 0 0 15px rgba(192, 192, 192, 0.2);
    transform: scale(1);
  }

  50% {
    box-shadow: 0 0 18px rgba(192, 192, 192, 0.7), inset 0 0 25px rgba(192, 192, 192, 0.3);
    transform: scale(1.05);
  }
}

@keyframes bronzeGlow {

  0%,
  100% {
    box-shadow: 0 0 12px rgba(205, 127, 50, 0.5), inset 0 0 15px rgba(205, 127, 50, 0.2);
    transform: scale(1);
  }

  50% {
    box-shadow: 0 0 18px rgba(205, 127, 50, 0.7), inset 0 0 25px rgba(205, 127, 50, 0.3);
    transform: scale(1.05);
  }
}

.leaderboard-rank-badge {
  position: absolute;
  bottom: -3px;
  right: -3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  font-weight: 800;
  border: 1px solid white;
  background: #666;
  color: white;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.leaderboard-image-container.rank-1 .leaderboard-rank-badge {
  background: linear-gradient(135deg, #ffd700 0%, #ffec8b 50%, #ffd700 100%);
  background-size: 200% 200%;
  color: #8a6508;
  box-shadow: 0 1px 4px rgba(255, 215, 0, 0.6);
  animation: goldPulse 2s ease-in-out infinite;
}

.leaderboard-image-container.rank-2 .leaderboard-rank-badge {
  background: linear-gradient(135deg, #c0c0c0 0%, #e8e8e8 50%, #c0c0c0 100%);
  background-size: 200% 200%;
  color: #666;
  box-shadow: 0 1px 3px rgba(192, 192, 192, 0.6);
  animation: silverPulse 2s ease-in-out infinite 0.3s;
}

.leaderboard-image-container.rank-3 .leaderboard-rank-badge {
  background: linear-gradient(135deg, #cd7f32 0%, #e6a65c 50%, #cd7f32 100%);
  background-size: 200% 200%;
  color: #5c3d1e;
  box-shadow: 0 1px 3px rgba(205, 127, 50, 0.6);
  animation: bronzePulse 2s ease-in-out infinite 0.6s;
}

.leaderboard-image-container.rank-1 .leaderboard-rank-badge::after {
  content: '★';
  position: absolute;
  top: -5px;
  right: -5px;
  font-size: 8px;
  color: #ffd700;
  animation: starTwinkle 1.5s ease-in-out infinite;
}

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

.leaderboard-name {
  font-size: 13px;
  font-weight: 600;
  color: #333;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.leaderboard-percent {
  font-size: 11px;
  color: var(--accent-color);
  font-weight: 600;
}

.age-gate-content {
  text-align: center;
  padding: 24px 28px 20px;
  max-width: 450px;
  margin: 0 auto;
}

.age-gate-content h2 {
  color: var(--accent-dark);
  margin-bottom: 10px;
  font-size: 1.25rem;
}

.age-gate-content p {
  color: #555;
  margin-bottom: 6px;
  font-size: 0.92rem;
  line-height: 1.35;
}

.age-gate-buttons {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-top: 16px;
}

.age-gate-btn {
  padding: 12px 28px;
  border: none;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.age-gate-btn.confirm {
  background: linear-gradient(135deg, #fffbf2 0%, #fff9eb 100%);
  border: 1px solid rgba(184, 134, 11, 0.20);
  border-radius: 14px;
  /* Fully rounded */
  box-shadow: 0 4px 16px rgba(184, 134, 11, 0.10), 0 1px 4px rgba(184, 134, 11, 0.08);
  color: #b8860b;
}

.age-gate-btn.confirm:hover {
  transform: translateY(-2px);
  color: var(--accent-dark);
  box-shadow: 0 6px 20px rgba(184, 134, 11, 0.35);
}

.age-gate-btn.confirm:active {
  transform: translate(-.5px, .5px);
  color: var(--accent-dark);
  box-shadow: 0 6px 20px rgba(184, 134, 11, 0.35);
}

.age-gate-btn.cancel {
  background: #f3f3f3;
  color: #666;
}

.age-gate-btn.cancel:hover {
  background: #e8e8e8;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(44, 44, 44, 0.15);
}

.age-gate-btn.cancel:active {
  transform: translate(-.5px, .5px);
  box-shadow: 0 6px 20px rgba(44, 44, 44, 0.15);
}

#age-gate-modal .modal-content {
  height: auto;
  max-height: none;
}

#hover-card {
  will-change: left, top, transform, opacity;
  backface-visibility: hidden;
  -webkit-font-smoothing: subpixel-antialiased;
}

#hover-card.visible {
  pointer-events: none;
}

.explicit-content-blur {
  filter: blur(20px);
  transition: filter 0.3s ease;
}

.explicit-content-revealed {
  filter: blur(0);
}

.explicit-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  color: white;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  pointer-events: none;
}

/* FOUC FIX: Hide critical UI elements by default immediately */
#canvasWrap,
#topbar,
.zoom-controls {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* Drawer uses opacity-only hide (no visibility:hidden) to preserve iOS Safari transform transitions */
#drawer {
  opacity: 0;
  pointer-events: none;
}

/* Only show elements when the app-ready class is explicitly added by JS */
/* This prevents showing unstyled content if the loader-finished class is present in HTML by mistake */
body.app-ready #canvasWrap,
body.app-ready #topbar,
body.app-ready .zoom-controls {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 0.4s ease 0.2s, transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

body.app-ready #drawer {
  opacity: 1;
  pointer-events: auto;
  transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              opacity 0.4s ease,
              box-shadow 0.4s ease;
}

#loader-overlay {
  visibility: visible;
  opacity: 1;
  z-index: 9999;
}

#loader-overlay.finished {
  pointer-events: none;
}

body.loader-finished #canvasWrap,
body.loader-finished #topbar,
body.loader-finished .zoom-controls {
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
  transition: opacity 0.4s ease 0.2s, transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

body.loader-finished #drawer {
  opacity: 1 !important;
  pointer-events: auto !important;
  transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              opacity 0.4s ease,
              box-shadow 0.4s ease;
}

body.app-ready #canvasWrap {
  opacity: 1;
  transition: opacity 0.3s ease;
}

@media (max-width: 768px) {
  #leaderboard-panel {
    right: 16px;
    /* MOBILE: Position above toolbar (topbar now at 48px + ~56px height + 12px gap) */
    bottom: calc(40px + 8px + 56px + 12px);
    width: auto;
    /* Let it size naturally on mobile */
    min-width: 160px;
    max-width: 90vw;
  }

  #leaderboard-panel.open {
    max-height: 60vh;
  }

  .leaderboard-content {
    max-height: calc(60vh - 80px);
  }

  .age-gate-buttons {
    flex-direction: column;
  }

  .age-gate-btn {
    width: 100%;
  }
}

@media (max-width: 480px) {
  #leaderboard-panel {
    right: 12px;
    /* MOBILE: Position above toolbar on smaller mobile screens */
    bottom: calc(12px + 56px + 12px);
    /* Mobile toolbar: 12px bottom + ~56px height + 12px gap */
    min-width: 140px;
    max-width: 95vw;
  }

  #leaderboard-panel.open {
    max-height: 55vh;
  }

  .leaderboard-item {
    padding: 8px 10px;
  }


  .leaderboard-name {
    font-size: 12px;
  }

  .leaderboard-header {
    padding: 12px 16px 10px;
  }

  .leaderboard-title {
    font-size: 11px;
    letter-spacing: 1.2px;
  }

  .leaderboard-content {
    padding: 10px 12px 12px;
    max-height: calc(55vh - 80px);
  }
}

/* Touch device behavior - does NOT affect layout geometry */
@media (pointer: coarse) {

  html,
  body {
    touch-action: none;
    -webkit-overflow-scrolling: auto;
    overscroll-behavior: none;
  }

  #canvasWrap,
  #canvas,
  #overlay-layer {
    touch-action: pan-x pan-y pinch-zoom;
  }

  #topbar,
  #drawer,
  #hover-card,
  #leaderboard-panel,
  #info-modal,
  #age-gate-modal,
  .zoom-controls,
  .modal {
    touch-action: auto;
  }
}


/* ============================================
   LAYOUT MODE CLASSES (JS-controlled)
   .mobile-layout = narrow viewport (portrait mobile)
   .desktop-layout = wide viewport (desktop OR mobile landscape)
   .touch-device = touch input device (for interaction behavior)
   ============================================ */

/* Mobile portrait LAYOUT - topbar positioning */
body.mobile-layout #topbar {
  bottom: 16px;
  top: auto;
  right: 16px;
  left: auto;
  justify-content: flex-end;
}

body.mobile-layout #topbar-inner {
  width: auto;
  max-width: none;
}

body.mobile-layout #topbar-inner.search-active {
  max-width: calc(100vw - 32px);
  width: calc(100vw - 32px);
  position: fixed;
  right: 16px;
  left: 16px;
  bottom: 16px;
}

body.mobile-layout #search-results {
  bottom: calc(100% + 8px);
  left: auto;
  right: 0;
  transform: none;
  max-width: calc(100vw - 32px);
}

body.mobile-layout #search-results.visible {
  transform: translateY(0);
}

/* Mobile compact hover card - fixed bottom-left position (layout-based) */
#hover-card.mobile-compact {
  position: fixed !important;
  left: 16px !important;
  bottom: 16px !important;
  top: auto !important;
  right: auto !important;
}

#hover-card.mobile-compact.visible {
  opacity: 1;
  transform: scale(1) !important;
}

/* Touch target sizes - applies to touch devices in mobile LAYOUT only */
body.mobile-layout.touch-device .top-btn {
  min-width: 44px;
  min-height: 44px;
  padding: 12px 14px;
}

body.mobile-layout.touch-device .zoom-btn {
  min-width: 44px;
  min-height: 44px;
  width: 44px;
  height: 44px;
}

body.mobile-layout.touch-device .leaderboard-close-btn,
body.mobile-layout.touch-device .modal .closeBtn,
body.mobile-layout.touch-device .drawer .closeBtn {
  min-width: 44px;
  min-height: 44px;
  padding: 10px;
}

body.mobile-layout.touch-device .age-gate-btn {
  min-height: 44px;
  padding: 12px 28px;
}

body.mobile-layout.touch-device .drawer-confirm {
  min-height: 48px;
  padding: 12px 14px;
}

body.mobile-layout.touch-device #has-key-toggle,
body.mobile-layout.touch-device #terms-check {
  width: 24px;
  height: 24px;
}

body.mobile-layout.touch-device .drawer-row,
body.mobile-layout.touch-device .terms-label {
  padding: 8px 0;
}

body.mobile-layout.touch-device .drawer-row.compact {
  padding: 4px 0;
  /* Reduced padding for compact rows on touch devices */
}

@media (max-height: 500px) and (orientation: landscape) {
  .drawer {
    max-height: 90vh;
    top: 8px;
  }

  .drawer-content {
    padding: 10px 2vw 16px;
  }

  #leaderboard-panel.open {
    max-height: 80vh;
  }

  .modal-content {
    max-height: 85vh;
    padding: 16px 20px;
  }

  .drawer-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    /* Fixed gap between columns */
    flex-shrink: 0;
    /* Don't shrink, let parent scroll instead */
  }

  .drawer-left,
  .drawer-right {
    display: flex;
    flex-direction: column;
    gap: 0;
    /* No gap - using margins for uniform spacing */
  }

  .drawer-row {
    margin-bottom: 0 !important;
    /* Override base style */
  }

  .drawer-row.compact {
    margin-bottom: 6px !important;
    /* Minimal spacing after key toggle */
  }

  .drawer-section {
    margin-bottom: 8px !important;
    /* Uniform spacing between all sections */
    padding-bottom: 0;
  }

  .drawer-section.compact {
    margin-bottom: 8px !important;
    /* Same spacing for compact sections */
  }

  #key-section {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    padding-bottom: 8px;
    overflow: visible;
    /* Normalize spacing for landscape - prevents gap when hidden */
  }

  #drawer-bottom-section {
    margin-top: 10px !important;
    /* Override auto margin with uniform spacing */
    padding-top: 0;
  }

  .terms-container {
    margin-bottom: 8px !important;
    /* Uniform spacing before buttons */
  }
}

@media (max-width: 768px) and (max-height: 500px) and (orientation: landscape) {
  .drawer-grid {
    display: flex !important;
    /* Stack as flex column for consistent behavior */
    flex-direction: column !important;
    gap: 0;
    /* No gap - using margins for uniform spacing */
    flex-shrink: 0;
    /* Don't shrink, let parent scroll instead */
  }

  .drawer-left {
    margin-bottom: 6px;
    /* Reduced spacing after left column - tighter for small landscape */
  }

  .drawer-left,
  .drawer-right {
    display: flex;
    flex-direction: column;
    gap: 0;
    /* No gap - using margins for uniform spacing */
  }

  .drawer-row {
    margin-bottom: 0 !important;
    /* Override base style */
  }

  .drawer-row.compact {
    margin-bottom: 5px !important;
    /* Minimal spacing after key toggle - tighter for small landscape */
  }

  .drawer-section {
    margin-bottom: 8px !important;
    /* Uniform spacing between all sections */
    padding-bottom: 0;
  }

  .drawer-section.compact {
    margin-bottom: 8px !important;
    /* Same spacing for compact sections */
  }

  #key-section {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    padding-bottom: 8px;
    /* Normalize spacing for small landscape - prevents gap when hidden */
  }

  #name-section {
    margin-top: 0 !important;
    /* No top margin - spacing controlled by element above */
    margin-bottom: 8px !important;
    /* Same spacing after name input */
  }

  #payment-section {
    margin-top: 0 !important;
    /* No top margin - spacing controlled by element above */
    margin-bottom: 8px !important;
    /* Same spacing after payment inputs */
  }

  #drawer-bottom-section {
    margin-top: 8px !important;
    /* Override auto margin with uniform spacing */
    padding-top: 0;
  }

  .terms-container {
    margin-bottom: 5px !important;
    padding-top: 0 !important;
    /* Reduced spacing around terms toggle */
  }

  #additional-fields {
    margin-top: 0;
    /* No extra margin */
  }
}

html,
body {
  overflow-x: hidden;
  max-width: 100vw;
}

* {
  word-wrap: break-word;
  overflow-wrap: break-word;
}

#canvasWrap {
  width: 100%;
  height: 100%;
  overflow: hidden;
  margin: 0;
  padding: 0;
}

img {
  max-width: 100%;
  height: auto;
}

@media (max-width: 360px) {
  .drawer {
    width: 98vw;
    max-width: 98vw;
    font-size: 12px;
  }

  .drawer h2 {
    font-size: 15px;
  }

  .drawer input[type="text"],
  .drawer input[type="number"],
  .drawer input[type="url"],
  .drawer input[type="email"] {
    font-size: 12px;
    padding: 7px 8px;
  }

  .top-btn {
    padding: 8px 10px;
    font-size: 12px;
  }

  #topbar-inner {
    gap: 6px;
    padding: 6px;
  }

  .zoom-btn {
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
  }

  .leaderboard-title {
    font-size: 10px;
    letter-spacing: 1px;
  }

  .leaderboard-name {
    font-size: 11px;
  }

  .modal-content h2 {
    font-size: 16px;
  }

  .modal-content p {
    font-size: 14px;
  }
}

@media (min-width: 481px) and (max-width: 768px) and (orientation: portrait) {
  .drawer {
    border-radius: 16px;
    height: auto;
    left: 50%;
    /* FIX: Give it space */
    max-height: 88vh;
    max-height: 87dvh;
    max-width: 95vw;
    min-width: 0;
    padding: 0;
    right: auto;
    top: 12px;
    width: 98vw;
    display: flex;
    flex-direction: column;
  }

  .drawer-grid {
    display: flex !important;
    /* Stack as flex column for consistent behavior */
    flex-direction: column !important;
    gap: 0;
    /* No gap - using margins for uniform spacing */
    flex-shrink: 0;
    /* Don't shrink, let parent scroll instead */
  }

  .drawer-left {
    margin-bottom: 6px;
    /* Reduced spacing after left column */
  }

  .drawer-left,
  .drawer-right {
    display: flex;
    flex-direction: column;
    gap: 0;
    /* No gap - using margins for uniform spacing */
  }

  .drawer-row {
    margin-bottom: 0 !important;
    /* Override base style */
  }

  .drawer-row.compact {
    margin-bottom: 6px !important;
    /* Minimal spacing after key toggle */
  }

  .drawer-section {
    margin-bottom: 10px !important;
    /* Uniform spacing between all sections */
    padding-bottom: 0;
  }

  .drawer-section.compact {
    margin-bottom: 10px !important;
    /* Same spacing for compact sections */
  }

  #key-section {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    padding-bottom: 10px;
    /* Normalize spacing for portrait mobile - prevents gap when hidden */
  }

  #name-section {
    margin-top: 0 !important;
    /* No top margin - spacing controlled by element above */
    margin-bottom: 10px !important;
    /* Same spacing after name input */
  }

  #payment-section {
    margin-top: 0 !important;
    /* No top margin - spacing controlled by element above */
    margin-bottom: 10px !important;
    /* Same spacing after payment inputs */
  }

  #drawer-bottom-section {
    margin-top: 10px !important;
    /* Override auto margin with uniform spacing */
    padding-top: 0;
  }

  .terms-container {
    margin-bottom: 5px !important;
    padding-top: 0 !important;
    /* Reduced spacing around terms toggle */
  }

  #has-key-toggle {
    width: 16px !important;
    height: 16px !important;
  }

  .drawer-row {
    gap: 6px;
    font-size: 11px;
  }

  .drawer-row:not(.compact) {
    margin-bottom: 10px;
    /* Uniform spacing */
  }
}

@media (min-width: 481px) and (max-width: 900px) and (orientation: landscape) {
  .drawer {
    width: 75vw;
    max-width: 700px;
    max-height: 85vh;
  }

  .drawer-grid {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    /* Fixed gap between columns */
    flex-shrink: 0;
    /* Don't shrink, let parent scroll instead */
  }

  .drawer-left,
  .drawer-right {
    display: flex;
    flex-direction: column;
    gap: 0;
    /* No gap - using margins for uniform spacing */
  }

  .drawer-row {
    margin-bottom: 0 !important;
    /* Override base style */
  }

  .drawer-row.compact {
    margin-bottom: 6px !important;
    /* Minimal spacing after key toggle */
  }

  .drawer-section {
    margin-bottom: 10px !important;
    /* Uniform spacing between all sections */
    padding-bottom: 0;
  }

  .drawer-section.compact {
    margin-bottom: 10px !important;
    /* Same spacing for compact sections */
  }

  #key-section {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    padding-bottom: 10px;
    /* Normalize spacing for landscape mobile - prevents gap when hidden */
  }

  #drawer-bottom-section {
    margin-top: 10px !important;
    /* Override auto margin with uniform spacing */
    padding-top: 0;
  }

  .terms-container {
    margin-bottom: 8px !important;
    /* Reduced spacing before buttons */
  }

  #topbar {
    bottom: 12px;
    right: 12px;
  }

  .zoom-controls {
    bottom: 12px;
    left: 12px;
  }
}

/* ============================================
   MOBILE-ONLY UI/UX FIXES
   Append this entire block to the END of style.css
   These styles ONLY affect mobile devices (pointer: coarse)
   Desktop behavior remains completely unchanged
   ============================================ */

/* ============================================
   1. DRAWER COVER BANNER FIX (Touch devices)
   - Seamless gradient with no visible line
   - Prevent drawer from protruding behind banner
   ============================================ */
body.touch-device #drawer-cover-banner {
  background:
    linear-gradient(180deg, #efd9a4 30%, #231a05 100%) padding-box,
    linear-gradient(115deg,
      rgba(var(--modal-accent), 0.20) 0%,
      rgba(var(--modal-accent), 0.20) 8%,
      rgba(var(--modal-accent), 0.35) 18%,
      var(--accent-color) 28%,
      var(--accent-dark) 50%,
      var(--accent-color) 72%,
      rgba(var(--modal-accent), 0.35) 82%,
      rgba(var(--modal-accent), 0.20) 92%,
      rgba(var(--modal-accent), 0.20) 100%) border-box;
  background-size: 100% 100%, 200% 100%;
  border-radius: 34px;
  overflow: hidden;
  z-index: 2000;
}

body.touch-device .drawer {
  border-radius: 32px;
}

/* Suppress the CSS hover peek on touch - tap opens directly via touchstart */
body.touch-device .drawer:not(.open):hover {
  transform: translate3d(-50%, calc(-100% + 56px), 0);
}

/* ============================================
   2. INFO MODAL FIX (Touch devices)
   - Constrained sizing for touch interaction
   ============================================ */

/* Mobile portrait layout - compact modal */
body.mobile-layout #info-modal .modal-content {
  width: 85vw !important;
  max-width: 380px !important;
  height: auto !important;
  max-height: 65vh !important;
  min-height: 200px;
  margin: auto !important;
  border-radius: 20px !important;
  padding: 24px 20px !important;
}

body.mobile-layout #info-modal.open {
  align-items: center !important;
  justify-content: center !important;
}

body.mobile-layout #info-modal.open .modal-content {
  animation-name: modalEnter !important;
  margin-top: 0 !important;
  margin-bottom: 0 !important;
}

body.mobile-layout #info-modal .modal-tabs {
  gap: 8px;
  margin-bottom: 16px;
  justify-content: center;
  padding-top: 5px;
}

body.mobile-layout #info-modal .modal-tab {
  font-size: 10px;
  padding: 8px 14px;

}

body.mobile-layout #info-modal .modal-content h2 {
  font-size: 18px !important;
  margin-bottom: 1px !important;
}

body.mobile-layout #info-modal .modal-content p {
  font-size: 14px;
  line-height: 1.5;
}

body.mobile-layout #info-modal .modal-tab-content {
  max-height: calc(65vh - 160px);
}

/* Touch device in desktop layout (landscape) - height constrained */
body.touch-device.desktop-layout #info-modal .modal-content {
  max-height: 80vh !important;
}

body.touch-device.desktop-layout #info-modal .modal-tab-content {
  max-height: calc(80vh - 140px);
}

/* ============================================
   3. TOOLBAR BUTTONS - TOUCH HOVER STATE FIX
   - Remove stuck hover/active states after tap
   - Proper touch-friendly active/pressed behavior
   Uses .touch-device class for interaction behavior
   ============================================ */

/* Remove hover states on touch devices - they cause "stuck" appearance */
body.touch-device .top-btn.subtle:hover,
body.touch-device .top-btn.search-icon:hover,
body.touch-device .top-btn.leaderboard-icon:hover {
  background: transparent !important;
  border-color: transparent !important;
  box-shadow: none !important;
  color: var(--accent-color) !important;
  transform: none !important;
}

body.touch-device .top-btn.search-icon:hover svg,
body.touch-device .top-btn.leaderboard-icon:hover svg {
  stroke-width: 2 !important;
}

/* Active state - brief visual feedback on tap */
body.touch-device .top-btn.subtle:active,
body.touch-device .top-btn.search-icon:active,
body.touch-device .top-btn.leaderboard-icon:active {
  background: linear-gradient(135deg, #fff3d4 0%, #fedda9 96%) !important;
  color: var(--accent-dark) !important;
  transform: scale(0.94) !important;
  box-shadow: 0 2px 8px rgba(var(--modal-accent), 0.12) !important;
  transition: all 0.1s ease !important;
}

/* Toggled active state (when panel is open) */
body.touch-device .top-btn.subtle.active,
body.touch-device .top-btn.search-icon.active,
body.touch-device .top-btn.leaderboard-icon.active {
  background: linear-gradient(135deg, #fff3d4 0%, #fedda9 96%) !important;
  color: var(--accent-dark) !important;
  transform: scale(0.96) !important;
  box-shadow: 0 2px 8px rgba(var(--modal-accent), 0.12) !important;
}

/* When active state button is tapped */
body.touch-device .top-btn.subtle.active:active,
body.touch-device .top-btn.search-icon.active:active,
body.touch-device .top-btn.leaderboard-icon.active:active {
  transform: scale(0.92) !important;
  transition: all 0.1s ease !important;
}

/* Remove hover effect on active buttons */
body.touch-device .top-btn.subtle.active:hover,
body.touch-device .top-btn.search-icon.active:hover,
body.touch-device .top-btn.leaderboard-icon.active:hover {
  background: linear-gradient(135deg, #fff3d4 0%, #fedda9 96%) !important;
  transform: scale(0.96) !important;
  box-shadow: 0 2px 8px rgba(var(--modal-accent), 0.12) !important;
}

/* ============================================
   4. PORTRAIT MOBILE LAYOUT ALIGNMENT
   - Toolbar in BOTTOM-RIGHT (not centered)
   - Hover card in bottom-left (no overlap)
   - Leaderboard centered above toolbar, shifts with it
   NOW USES .mobile-layout CLASS (viewport-based, not device-based)
   ============================================ */
body.mobile-layout #topbar {
  bottom: 16px !important;
  right: 16px !important;
  left: auto !important;
  justify-content: flex-end !important;
}

body.mobile-layout #topbar-inner {
  width: auto !important;
  max-width: calc(100vw - 32px) !important;
  position: relative !important;
}

body.mobile-layout #topbar-inner.search-active {
  width: auto !important;
  max-width: calc(100vw - 32px) !important;
  position: relative !important;
  right: auto !important;
  left: auto !important;
  bottom: auto !important;
}

body.mobile-layout #search-input {
  padding: 10px 14px !important;
  width: 220px !important;
  box-sizing: border-box !important;
}

body.mobile-layout #search-container.active {
  max-width: 220px !important;
}

body.mobile-layout #search-container.expanded {
  overflow: visible !important;
}

body.mobile-layout #leaderboard-panel {
  bottom: calc(40px + 8px + 56px + 12px) !important;
  right: 16px !important;
  left: auto !important;
  width: 192px !important;
  min-width: 160px !important;
  max-width: calc(100vw - 32px) !important;
  transition: max-height 0.5s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.3s ease,
    right 0.5s cubic-bezier(0.4, 0, 0.2, 1) !important;
  transform: translateZ(0) !important;
  backface-visibility: hidden !important;
}

body.mobile-layout #leaderboard-panel.shifted {
  right: calc(16px + 188px) !important;
  left: auto !important;
  width: 192px !important;
}

body.mobile-layout #leaderboard-panel.open {
  max-height: 55vh !important;
}

body.mobile-layout #search-results {
  bottom: calc(100% + 10px) !important;
  left: auto !important;
  right: -8px !important;
  width: 230px !important;
  min-width: 220px !important;
  max-width: calc(100vw - 48px) !important;
}

/* ============================================
   5. LANDSCAPE MOBILE - TOUCH BEHAVIOR ONLY
   Mobile landscape uses DESKTOP layout geometry but needs
   touch-specific adjustments for height constraints and safe areas.
   Layout positioning is handled by desktop defaults.
   ============================================ */

/* Touch device in landscape - only height constraints, NOT layout changes */
body.touch-device.desktop-layout #leaderboard-panel.open {
  max-height: 70vh !important;
}

/* Reduced spacing for touch landscape (height is limited) */
@media (max-height: 500px) {
  body.touch-device.desktop-layout #topbar {
    bottom: 12px !important;
    right: 16px !important;
  }

  body.touch-device.desktop-layout .zoom-controls {
    bottom: 12px !important;
    left: 12px !important;
  }
}

/* ============================================
   6. ZOOM BUTTONS & HOVER CARD BEHAVIOR
   - Zoom buttons hidden on touch devices (pinch-to-zoom instead)
   - Hover card compact styles for mobile-layout only
   ============================================ */

/* Hide zoom buttons on touch devices - they use pinch-to-zoom */
body.touch-device .zoom-controls {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

/* Hover card compact positioning - only in mobile LAYOUT */
#hover-card.mobile-compact {
  position: fixed !important;
  left: 16px !important;
  bottom: 16px !important;
  top: auto !important;
  right: auto !important;
  max-width: calc(50vw - 24px) !important;
  z-index: 2500 !important;
}

#hover-card.mobile-compact.visible {
  opacity: 1 !important;
  transform: scale(1) !important;
}

/* Compact hover card dimensions */
#hover-card.mobile-compact .hover-card-inner {
  width: 160px !important;
  min-width: 160px !important;
  max-width: 160px !important;
  padding: 10px 14px !important;
  transition: height 0.35s cubic-bezier(0.16, 1, 0.3, 1),
    min-height 0.35s cubic-bezier(0.16, 1, 0.3, 1),
    max-height 0.35s cubic-bezier(0.16, 1, 0.3, 1),
    padding 0.35s cubic-bezier(0.16, 1, 0.3, 1) !important;
  /* Only animate height, not width */
}

#hover-card.mobile-compact.expanded .hover-card-inner {
  width: 160px !important;
  min-width: 160px !important;
  max-width: 160px !important;
  min-height: 140px !important;
  max-height: 50vh !important;
  padding: 12px 14px !important;
  overflow-y: auto !important;
}

/* Elements inside compact hover card - visually smaller */
#hover-card.mobile-compact .hover-card-name {
  font-size: 11px !important;
  margin-bottom: 2px !important;
}

#hover-card.mobile-compact .hover-card-percent {
  font-size: 9px !important;
  margin-bottom: 3px !important;
}

#hover-card.mobile-compact .hover-card-hint {
  font-size: 7px !important;
}

#hover-card.mobile-compact .hover-card-header-left {
  flex: 1 !important;
  min-width: 0 !important;
}

#hover-card.mobile-compact .hover-card-name {
  word-wrap: break-word !important;
  overflow-wrap: break-word !important;
}

#hover-card.mobile-compact .hover-card-key {
  font-size: 8px !important;
  max-width: 50% !important;
  word-wrap: break-word !important;
  overflow-wrap: break-word !important;
  word-break: break-word !important;
  white-space: normal !important;
  text-align: right !important;
}

#hover-card.mobile-compact .detail-stat {
  padding: 6px 8px !important;
}

#hover-card.mobile-compact .detail-stat-label {
  font-size: 6px !important;
  letter-spacing: 0.5px !important;
}

#hover-card.mobile-compact .detail-stat-value {
  font-size: 12px !important;
}

#hover-card.mobile-compact .detail-stat-unit {
  font-size: 7px !important;
}

#hover-card.mobile-compact .detail-section-title {
  font-size: 8px !important;
}

#hover-card.mobile-compact .timeline-node {
  width: 6px !important;
  height: 6px !important;
}

#hover-card.mobile-compact .timeline-node-tooltip {
  font-size: 8px !important;
  padding: 4px 8px !important;
}

#hover-card.mobile-compact .detail-image-section {
  margin-bottom: 8px !important;
}

#hover-card.mobile-compact .detail-original-image {
  max-height: 120px !important;
}

#hover-card.mobile-compact .detail-image-container {
  padding: 6px !important;
}

#hover-card.mobile-compact .detail-loading-text {
  font-size: 9px !important;
}

/* Expanded state elements */
#hover-card.mobile-compact.expanded .hover-card-name {
  font-size: 12px !important;
}

#hover-card.mobile-compact.expanded .hover-card-percent {
  font-size: 10px !important;
}

#hover-card.mobile-compact.expanded .hover-card-body {
  margin-top: 14px !important;
}

#hover-card.mobile-compact.expanded .detail-stats-grid {
  gap: 6px !important;
  margin-bottom: 10px !important;
}

/* Portrait hover card sizing - using mobile-layout class */
body.mobile-layout #hover-card.mobile-compact .hover-card-inner {
  width: 160px !important;
}

body.mobile-layout #hover-card.mobile-compact.expanded .hover-card-inner {
  width: 160px !important;
  max-height: 45vh !important;
}

/* ============================================
   CRITICAL: Ensure toolbar interaction hides hover card
   (Handled via JS, but CSS ensures proper stacking)
   ============================================ */
body.touch-device #topbar {
  z-index: 1100;
}

body.touch-device #topbar-inner {
  z-index: 1100;
}

/* ============================================
   Small screen (< 360px) additional tweaks
   ============================================ */
@media (max-width: 360px) {
  body.mobile-layout #leaderboard-panel {
    width: 160px !important;
    min-width: 140px !important;
  }

  #hover-card.mobile-compact .hover-card-inner {
    width: 140px !important;
    min-width: 140px !important;
    max-width: 140px !important;
    padding: 8px 10px !important;
  }

  #hover-card.mobile-compact.expanded .hover-card-inner {
    width: 140px !important;
    min-width: 140px !important;
    max-width: 140px !important;
  }

  body.mobile-layout #info-modal .modal-content {
    width: 92vw !important;
    max-width: none !important;
    padding: 20px 16px !important;
  }
}

/* ============================================
   SOCIAL MEDIA ICONS
   ============================================ */
.social-icons-container {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
}

.social-icon-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, #fffbf2 0%, #fff9eb 100%);
  border: 1px solid rgba(184, 134, 11, 0.20);
  box-shadow: 0 4px 12px rgba(184, 134, 11, 0.10), 0 1px 3px rgba(184, 134, 11, 0.08);
  color: #b8860b;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  text-decoration: none;
}

.social-icon-link:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 8px 20px rgba(184, 134, 11, 0.20), 0 2px 6px rgba(184, 134, 11, 0.15);
  border-color: rgba(184, 134, 11, 0.35);
  background: linear-gradient(135deg, #fff 0%, #fffbf2 100%);
}

.social-icon-link:active {
  transform: translateY(0) scale(0.98);
  box-shadow: 0 2px 8px rgba(184, 134, 11, 0.15);
}

.social-icon-link svg {
  width: 20px;
  height: 20px;
  transition: transform 0.3s ease;
}

.social-icon-link:hover svg {
  transform: scale(1.1);
}

/* Support tab social icons spacing */
.support-social-icons {
  margin-top: 32px;
  padding-top: 18px;
  padding-bottom: 20px;
  border-top: 1px solid rgba(184, 134, 11, 0.15);
}

.support-social-icons p {
  text-align: center;
}

/* ============================================
   RESPONSIVE FIXES FOR INFO MODAL
   ============================================ */

/* Fix modal width expansion between 692px-768px */
@media (min-width: 692px) and (max-width: 768px) {
  #info-modal .modal-content {
    width: 70vw !important;
    max-width: 690px !important;
  }
}

/* ============================================
   CINEMA / IMMERSIVE MODE
   ============================================ */

#cinema-vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 900;
  background: radial-gradient(ellipse at center, transparent 32%, rgba(0, 0, 0, 0.7) 100%);
  opacity: 0;
  transition: opacity 0.8s ease;
}

#cinema-hint {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(10, 8, 5, 0.65);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: rgba(255, 255, 255, 0.92);
  padding: 11px 26px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
  border: 1px solid rgba(255, 255, 255, 0.12);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
  z-index: 950;
  white-space: nowrap;
}

#cinema-hint kbd {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  padding: 1px 6px;
  font-family: inherit;
  font-size: 12px;
}

.cinema-mode #cinema-vignette.visible { opacity: 1; }
.cinema-mode #cinema-hint.visible { opacity: 1; }

/* Bottom-center position for hint after first idle transition */
#cinema-hint.hint-bottom {
  top: auto;
  bottom: 48px;
  transform: translateX(-50%);
}

/* Slide UI elements off-screen in cinema mode */
.cinema-mode #topbar {
  transform: translateY(200%);
  transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.cinema-mode .zoom-controls {
  transform: translateY(200%);
  transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.cinema-mode #drawer-cover-banner,
.cinema-mode #drawer-hint-arrow {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
  transition: opacity 0.4s ease;
}

/* Hide the purchase drawer (all states) when in cinema mode */
.cinema-mode .drawer {
  transform: translate3d(-50%, calc(-100% - 200px), 0) !important;
  opacity: 0 !important;
  pointer-events: none !important;
  transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94), opacity 0.3s ease;
}

.cinema-mode #bottom-panel {
  transform: translateX(-50%) translateY(200%);
  transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Smooth transitions for normal state */
#topbar {
  transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.zoom-controls {
  transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* When panel is open, slide topbar and zoom off-screen downward */
body.panel-open #topbar {
  transform: translateY(200%);
}

body.panel-open .zoom-controls {
  transform: translateY(200%);
}

/* When a topbar UI element is active, slide panel off-screen and restore topbar/zoom */
body.topbar-active #bottom-panel {
  transform: translateX(-50%) translateY(200%);
}

body.topbar-active #topbar {
  transform: translateY(0);
}

body.topbar-active .zoom-controls {
  transform: translateY(0);
}
