/* ==========================================================================
   Mahjong Solitaire - Premium Asian Jade & Velvet Arcade Theme
   Penny Arcade (pennyarcade.click)
   ========================================================================== */

:root {
  --felt-base: #061912;
  --felt-glow: #0e3426;
  --felt-rim: #030c08;
  --gold-primary: #d4af37;
  --gold-light: #f5d77f;
  --gold-dark: #997a15;
  --gold-glow: rgba(212, 175, 55, 0.45);
  --jade-deep: #0a2d20;
  --jade-accent: #15573e;
  --jade-bright: #10b981;
  --tile-ivory: #fffdf8;
  --tile-ivory-dark: #f3ece0;
  --tile-border: #dcd0b5;
  --tile-side-jade: #134432;
  --text-light: #f8fafc;
  --text-muted: #94a3b8;
  --surface-glass: rgba(10, 35, 25, 0.75);
  --surface-border: rgba(212, 175, 55, 0.25);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --font-heading: 'Cinzel', 'Noto Serif SC', serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--felt-base);
  color: var(--text-light);
  font-family: var(--font-body);
}

/* Ambient Radial Velvet Felt Background */
.game-viewport {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at 50% 45%, var(--felt-glow) 0%, var(--felt-base) 65%, var(--felt-rim) 100%);
  background-attachment: fixed;
  overflow: hidden;
}

/* Subtle table felt texture overlay */
.felt-texture {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 0);
  background-size: 24px 24px;
  opacity: 0.6;
}

/* -------------------------------------------------------------
   Top Navigation / Header
   ------------------------------------------------------------- */
.topbar {
  position: relative;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 18px;
  background: var(--surface-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--surface-border);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-light);
  transition: transform var(--transition-fast);
}

.brand:hover {
  transform: translateY(-1px);
}

.brand-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, var(--gold-light), var(--gold-dark));
  color: #1a1202;
  font-family: var(--font-heading);
  font-weight: 900;
  font-size: 15px;
  border-radius: var(--radius-sm);
  box-shadow: 0 2px 8px var(--gold-glow);
  letter-spacing: -0.5px;
}

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

.brand-text strong {
  font-family: var(--font-heading);
  font-size: 13px;
  letter-spacing: 1.5px;
  color: var(--gold-light);
  text-transform: uppercase;
  line-height: 1.1;
}

.brand-text small {
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn, .action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: rgba(20, 60, 45, 0.6);
  color: var(--text-light);
  border: 1px solid rgba(212, 175, 55, 0.3);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: var(--font-body);
  font-weight: 600;
  text-decoration: none;
}

.icon-btn {
  width: 36px;
  height: 36px;
  font-size: 15px;
}

.action-btn {
  padding: 6px 14px;
  font-size: 12px;
  letter-spacing: 0.5px;
}

.icon-btn:hover, .action-btn:hover {
  background: rgba(30, 80, 60, 0.85);
  border-color: var(--gold-primary);
  color: var(--gold-light);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.icon-btn:active, .action-btn:active {
  transform: translateY(1px);
}

.action-btn.gold {
  background: linear-gradient(135deg, var(--gold-light), var(--gold-dark));
  color: #1c1303;
  border-color: var(--gold-light);
  box-shadow: 0 2px 10px var(--gold-glow);
}

.action-btn.gold:hover {
  background: linear-gradient(135deg, #fff0aa, var(--gold-primary));
  box-shadow: 0 4px 16px rgba(212, 175, 55, 0.6);
}

/* -------------------------------------------------------------
   Game HUD Bar
   ------------------------------------------------------------- */
.hud-bar {
  position: relative;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  padding: 8px 18px;
  background: rgba(8, 28, 20, 0.82);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(212, 175, 55, 0.15);
  gap: 12px;
}

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

.hud-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.hud-label {
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--gold-primary);
  text-transform: uppercase;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 4px;
}

.hud-value {
  font-family: var(--font-heading);
  font-size: 17px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 0.5px;
  min-width: 45px;
}

.hud-value.highlight {
  color: var(--gold-light);
  text-shadow: 0 0 10px var(--gold-glow);
}

.hud-streak {
  font-size: 11px;
  color: #fbbf24;
  font-weight: 700;
  margin-left: 4px;
  display: none;
}

.hud-streak.active {
  display: inline-block;
  animation: pulseGold 1.5s infinite;
}

.hud-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hud-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  background: rgba(18, 52, 38, 0.7);
  border: 1px solid rgba(212, 175, 55, 0.3);
  border-radius: var(--radius-sm);
  color: var(--text-light);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.hud-btn:hover:not(:disabled) {
  background: rgba(28, 75, 55, 0.9);
  border-color: var(--gold-primary);
  color: var(--gold-light);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
  transform: translateY(-1px);
}

.hud-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  border-color: rgba(255, 255, 255, 0.1);
}

.badge {
  display: inline-block;
  padding: 1px 5px;
  background: var(--gold-primary);
  color: #1c1303;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 800;
  margin-left: 2px;
}

/* -------------------------------------------------------------
   Board Container & Scaling Stage
   ------------------------------------------------------------- */
.board-viewport {
  position: relative;
  flex: 1;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* The scaled stage container */
.board-stage {
  position: absolute;
  transform-origin: center center;
  transition: transform 0.2s cubic-bezier(0.2, 0, 0, 1);
  will-change: transform;
}

/* -------------------------------------------------------------
   3D Mahjong Tiles
   Standard proportions: 48px wide x 64px tall
   Each layer z adds upward elevation and deeper cast shadow
   ------------------------------------------------------------- */
.tile-element {
  position: absolute;
  width: 48px;
  height: 64px;
  box-sizing: border-box;
  cursor: default;
  transition: transform var(--transition-fast), filter var(--transition-fast), box-shadow var(--transition-fast);
  border-radius: 6px;
  background: linear-gradient(145deg, var(--tile-ivory) 0%, var(--tile-ivory-dark) 100%);
  border: 1px solid var(--tile-border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
}

/* Realistic 3D Side & Bottom Jade/Bone Edges */
.tile-element::after {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: 6px;
  pointer-events: none;
  border-bottom: 3px solid var(--tile-side-jade);
  border-right: 2px solid var(--tile-side-jade);
}

/* Layer-based drop shadows */
.tile-element[data-z="0"] {
  box-shadow: 2px 2px 0 var(--tile-side-jade), 3px 4px 6px rgba(0, 0, 0, 0.45);
}
.tile-element[data-z="1"] {
  box-shadow: 3px 3px 0 var(--tile-side-jade), 5px 6px 9px rgba(0, 0, 0, 0.52);
}
.tile-element[data-z="2"] {
  box-shadow: 4px 4px 0 var(--tile-side-jade), 7px 9px 12px rgba(0, 0, 0, 0.58);
}
.tile-element[data-z="3"] {
  box-shadow: 5px 5px 0 var(--tile-side-jade), 9px 12px 16px rgba(0, 0, 0, 0.64);
}
.tile-element[data-z="4"] {
  box-shadow: 6px 6px 0 var(--tile-side-jade), 11px 15px 20px rgba(0, 0, 0, 0.70);
}

/* Free / Playable Tile */
.tile-element.is-free {
  cursor: pointer;
  filter: brightness(1) saturate(1.05);
}

.tile-element.is-free:hover {
  transform: translate(-2px, -3px) scale(1.03);
  filter: brightness(1.06) contrast(1.02);
  z-index: 1000 !important;
  box-shadow: 0 0 12px rgba(212, 175, 55, 0.6), 4px 8px 12px rgba(0, 0, 0, 0.5) !important;
}

/* Blocked Tile */
.tile-element.is-blocked {
  cursor: not-allowed;
}

/* When dimming blocked tiles is active in settings */
.dim-blocked .tile-element.is-blocked {
  filter: brightness(0.68) saturate(0.7) contrast(0.95);
  opacity: 0.92;
}

/* Selected Tile */
.tile-element.is-selected {
  transform: translate(-3px, -5px) scale(1.06) !important;
  z-index: 1100 !important;
  outline: 3px solid var(--gold-primary);
  outline-offset: 1px;
  box-shadow: 0 0 20px rgba(245, 158, 11, 0.9), 6px 12px 18px rgba(0, 0, 0, 0.6) !important;
  animation: pulseSelected 1.2s infinite alternate;
}

/* Hinted Tiles */
.tile-element.is-hinted {
  z-index: 1050 !important;
  outline: 3px solid #10b981;
  outline-offset: 1px;
  box-shadow: 0 0 22px rgba(16, 185, 129, 0.9), 0 0 10px rgba(245, 158, 11, 0.7) !important;
  animation: pulseHint 0.8s infinite alternate;
}

/* Matched Removal Animation */
.tile-element.is-matched {
  pointer-events: none;
  z-index: 1200 !important;
  animation: tileMatchOut 0.38s cubic-bezier(0.2, 0.8, 0.3, 1) forwards;
}

@keyframes tileMatchOut {
  0% {
    transform: translate(0, 0) scale(1);
    opacity: 1;
  }
  40% {
    transform: translate(0, -14px) scale(1.15);
    filter: brightness(1.4) drop-shadow(0 0 16px gold);
    opacity: 0.95;
  }
  100% {
    transform: translate(0, -32px) scale(0.6);
    opacity: 0;
  }
}

@keyframes pulseSelected {
  from {
    outline-color: #f59e0b;
    box-shadow: 0 0 14px rgba(245, 158, 11, 0.7);
  }
  to {
    outline-color: #fde047;
    box-shadow: 0 0 24px rgba(253, 224, 71, 0.95);
  }
}

@keyframes pulseHint {
  from {
    outline-color: #10b981;
    box-shadow: 0 0 14px rgba(16, 185, 129, 0.7);
  }
  to {
    outline-color: #34d399;
    box-shadow: 0 0 26px rgba(52, 211, 153, 0.95);
  }
}

@keyframes pulseGold {
  0%, 100% { opacity: 0.9; }
  50% { opacity: 1; transform: scale(1.05); }
}

/* Tile SVG Sizing */
.tile-svg {
  width: 100%;
  height: 100%;
  border-radius: 5px;
  display: block;
}

/* -------------------------------------------------------------
   Zoom & Viewport Controls (Bottom Right Floating)
   ------------------------------------------------------------- */
.zoom-controls {
  position: absolute;
  bottom: 16px;
  right: 18px;
  z-index: 80;
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 4px 8px;
  border-radius: 20px;
  border: 1px solid var(--surface-border);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.zoom-btn {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(20, 60, 45, 0.6);
  color: var(--text-light);
  border: 1px solid rgba(212, 175, 55, 0.2);
  border-radius: 50%;
  cursor: pointer;
  font-weight: 700;
  font-size: 13px;
  transition: all var(--transition-fast);
}

.zoom-btn:hover {
  background: rgba(30, 80, 60, 0.9);
  color: var(--gold-light);
  border-color: var(--gold-primary);
}

/* -------------------------------------------------------------
   Particle Effects Canvas
   ------------------------------------------------------------- */
#particle-canvas {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 95;
}

/* -------------------------------------------------------------
   Modals & Overlays
   ------------------------------------------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(2, 10, 6, 0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
  padding: 16px;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  position: relative;
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  background: linear-gradient(145deg, #0c261c 0%, #061811 100%);
  border: 1px solid var(--gold-primary);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.8), 0 0 30px rgba(212, 175, 55, 0.2);
  transform: scale(0.94);
  transition: transform var(--transition-normal);
}

.modal-overlay.active .modal-card {
  transform: scale(1);
}

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

.modal-header h2 {
  font-family: var(--font-heading);
  font-size: 20px;
  color: var(--gold-light);
  letter-spacing: 1px;
}

.close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
  transition: color var(--transition-fast);
}

.close-btn:hover {
  color: var(--gold-light);
}

/* Layout Cards Grid in Modal */
.layouts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  margin: 16px 0;
}

.layout-choice-card {
  background: rgba(14, 45, 34, 0.7);
  border: 1px solid rgba(212, 175, 55, 0.3);
  border-radius: var(--radius-md);
  padding: 16px;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: left;
}

.layout-choice-card:hover {
  background: rgba(22, 65, 48, 0.9);
  border-color: var(--gold-light);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.layout-choice-card.selected {
  border-color: var(--gold-primary);
  background: rgba(212, 175, 55, 0.15);
  box-shadow: 0 0 14px var(--gold-glow);
}

.layout-choice-card h3 {
  font-family: var(--font-heading);
  font-size: 15px;
  color: var(--gold-light);
  margin-bottom: 6px;
}

.layout-choice-card p {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Victory Screen Overlay */
.victory-card {
  text-align: center;
  max-width: 460px;
}

.victory-icon {
  font-size: 46px;
  margin-bottom: 8px;
  animation: bounceCelebration 1s ease infinite alternate;
}

.victory-title {
  font-family: var(--font-heading);
  font-size: 26px;
  color: var(--gold-light);
  margin-bottom: 6px;
  letter-spacing: 1.5px;
}

.stars-rating {
  font-size: 32px;
  color: #fbbf24;
  margin: 12px 0 18px 0;
  letter-spacing: 6px;
}

.win-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  background: rgba(6, 22, 16, 0.7);
  border-radius: var(--radius-md);
  padding: 14px;
  margin: 16px 0;
  border: 1px solid rgba(212, 175, 55, 0.2);
}

.win-stat-cell {
  display: flex;
  flex-direction: column;
}

.win-stat-cell span {
  font-size: 10px;
  color: var(--gold-primary);
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.win-stat-cell strong {
  font-size: 18px;
  color: #fff;
  font-family: var(--font-heading);
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 20px;
}

@keyframes bounceCelebration {
  from { transform: translateY(0); }
  to { transform: translateY(-8px); }
}

/* Settings Form Rows */
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.setting-info strong {
  font-size: 13px;
  color: var(--text-light);
  display: block;
}

.setting-info small {
  font-size: 11px;
  color: var(--text-muted);
}

/* Toggle Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: rgba(255, 255, 255, 0.2);
  transition: 0.25s;
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.25s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--jade-bright);
}

input:checked + .slider:before {
  transform: translateX(20px);
}

/* Rules / How To Play Content */
.rules-body {
  font-size: 13px;
  line-height: 1.6;
  color: #cbd5e1;
}

.rules-body p {
  margin-bottom: 12px;
}

.rules-body ul {
  padding-left: 20px;
  margin-bottom: 14px;
}

.rules-body li {
  margin-bottom: 6px;
}

.rules-body h4 {
  font-family: var(--font-heading);
  color: var(--gold-light);
  font-size: 14px;
  margin: 14px 0 6px 0;
}

/* Floating Status / Alert Toast */
.toast-banner {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: rgba(14, 45, 34, 0.95);
  border: 1px solid var(--gold-primary);
  color: var(--text-light);
  padding: 10px 20px;
  border-radius: 30px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6), 0 0 14px var(--gold-glow);
  z-index: 900;
  pointer-events: none;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

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

/* -------------------------------------------------------------
   Responsive Adaptations
   ------------------------------------------------------------- */
@media (max-width: 768px) {
  .topbar {
    padding: 6px 12px;
  }
  .brand-text strong {
    font-size: 12px;
  }
  .hud-bar {
    padding: 6px 12px;
    gap: 8px;
  }
  .hud-value {
    font-size: 15px;
  }
  .action-btn {
    padding: 5px 10px;
    font-size: 11px;
  }
  .hud-btn {
    padding: 5px 9px;
    font-size: 11px;
  }
  .tile-element {
    /* Scale down slightly for smaller screens */
    width: 42px;
    height: 56px;
  }
  .zoom-controls {
    bottom: 12px;
    right: 12px;
  }
}

@media (max-width: 480px) {
  .brand-text small {
    display: none;
  }
  .hud-label {
    font-size: 9px;
  }
  .hud-value {
    font-size: 14px;
  }
  .hud-btn span.btn-text {
    display: none;
  }
}

/* High Scores Leaderboard & Initials Input */
.scores-modal-card {
  max-width: 480px;
}

.score-submission-box {
  margin: 14px 0 10px;
  width: 100%;
}

.initials-box {
  background: rgba(14, 45, 34, 0.9);
  border: 1px solid rgba(212, 175, 55, 0.45);
  border-radius: var(--radius-md);
  padding: 12px 10px;
  box-sizing: border-box;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

.initials-box label {
  display: block;
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--gold-light);
  margin-bottom: 8px;
  letter-spacing: 1px;
}

.initials-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
}

.initials-row input {
  width: 95px;
  height: 44px;
  flex: none;
  background: #091a13;
  border: 2px solid #b45309;
  border-radius: 8px;
  color: var(--gold-light);
  font-family: inherit;
  font-size: 1.35rem;
  font-weight: 900;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 4px;
  padding: 4px;
  box-sizing: border-box;
  outline: none;
  transition: all 0.2s;
}

.initials-row input:focus {
  border-color: var(--gold-primary);
  box-shadow: 0 0 12px var(--gold-glow);
  background: #0e2d22;
}

.initials-row .backspace-btn {
  flex: none;
  width: 44px;
  height: 44px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  background: rgba(239, 68, 68, 0.2);
  border: 1.5px solid rgba(239, 68, 68, 0.6);
  color: #fca5a5;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.initials-row .backspace-btn:hover,
.initials-row .backspace-btn:active {
  background: rgba(239, 68, 68, 0.45);
  border-color: #ef4444;
  color: #fff;
  transform: scale(0.96);
}

.initials-row .submit-score-btn {
  flex: 1;
  max-width: 120px;
  height: 44px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.88rem;
  font-weight: 900;
  letter-spacing: 1px;
  background: linear-gradient(135deg, #10b981, #059669);
  border: 1.5px solid #34d399;
  color: #fff;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.initials-row .submit-score-btn:hover:not(:disabled),
.initials-row .submit-score-btn:active:not(:disabled) {
  background: linear-gradient(135deg, #059669, #047857);
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.6);
  transform: scale(0.98);
}

.initials-row .submit-score-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.score-submitted-msg {
  font-size: 0.85rem;
  font-weight: 800;
  color: #34d399;
  margin: 6px 0;
  padding: 8px;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.35);
  border-radius: 8px;
}

/* Leaderboard Tables */
.top-scores-container {
  width: 100%;
  margin-top: 8px;
}

.top5-box {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(212, 175, 55, 0.3);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 12px;
}

.top5-header {
  background: rgba(212, 175, 55, 0.15);
  color: var(--gold-light);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 1px;
  padding: 6px 10px;
  border-bottom: 1px solid rgba(212, 175, 55, 0.25);
}

.top5-table, .leaderboard-table {
  width: 100%;
  border-collapse: collapse;
}

.lb-row, .top5-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 0.85rem;
}

.lb-row:last-child, .top5-row:last-child {
  border-bottom: none;
}

.lb-row:nth-child(even), .top5-row:nth-child(even) {
  background: rgba(255, 255, 255, 0.02);
}

.top-rank {
  color: var(--gold-light);
  font-weight: 900;
}

.new-entry {
  background: rgba(16, 185, 129, 0.22) !important;
  color: #a7f3d0 !important;
  font-weight: 900;
  animation: pulseScore 1.5s infinite alternate;
}

.lb-rank, .top5-rank {
  font-weight: 900;
  color: var(--gold-primary);
  width: 32px;
  text-align: left;
}

.lb-name, .top5-name {
  font-weight: 800;
  letter-spacing: 2px;
  flex: 1;
  text-align: left;
  padding-left: 10px;
}

.lb-score, .top5-score {
  font-weight: 900;
  color: var(--gold-light);
  text-align: right;
  font-feature-settings: "tnum";
}

.lb-empty-msg {
  padding: 16px;
  color: #9ca3af;
  font-size: 0.85rem;
  text-align: center;
}

/* -------------------------------------------------------------
   Match Speed Timer & Reflex Scoring HUD Widget
   ------------------------------------------------------------- */
.speed-btn {
  background: linear-gradient(135deg, rgba(234, 179, 8, 0.22), rgba(56, 189, 248, 0.22)) !important;
  border-color: rgba(234, 179, 8, 0.5) !important;
  color: #fef08a !important;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  box-shadow: 0 0 10px rgba(234, 179, 8, 0.15);
  transition: all var(--transition-fast);
}

.speed-btn:hover {
  background: linear-gradient(135deg, rgba(234, 179, 8, 0.35), rgba(56, 189, 248, 0.35)) !important;
  border-color: #facc15 !important;
  box-shadow: 0 0 16px rgba(234, 179, 8, 0.35);
  transform: translateY(-1px);
}

.speed-bolt-icon {
  font-size: 13px;
  filter: drop-shadow(0 0 4px #facc15);
  animation: pulseBolt 1.8s infinite;
}

@keyframes pulseBolt {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 0 3px #facc15); }
  50% { transform: scale(1.18); filter: drop-shadow(0 0 8px #38bdf8); }
}

.match-speed-hud {
  display: flex;
  flex-direction: column;
  padding: 4px 10px;
  background: rgba(10, 36, 26, 0.85);
  border: 1px solid rgba(234, 179, 8, 0.3);
  border-radius: var(--radius-sm);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3), inset 0 0 12px rgba(234, 179, 8, 0.05);
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
  position: relative;
  min-width: 130px;
}

.match-speed-hud.pulse-match {
  animation: pulseHudGeneral 0.55s cubic-bezier(0.16, 1, 0.3, 1);
}

.match-speed-hud.pulse-blazing {
  animation: pulseHudBlazing 0.65s cubic-bezier(0.16, 1, 0.3, 1);
}

.match-speed-hud.pulse-lightning {
  animation: pulseHudLightning 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.match-speed-hud.pulse-swift {
  animation: pulseHudSwift 0.55s cubic-bezier(0.16, 1, 0.3, 1);
}

.match-speed-hud.pulse-steady {
  animation: pulseHudSteady 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.match-speed-hud.pulse-casual {
  animation: pulseHudCasual 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes pulseHudBlazing {
  0% { transform: scale(1); }
  25% { transform: scale(1.15); box-shadow: 0 0 28px rgba(56, 189, 248, 0.9), inset 0 0 16px rgba(56, 189, 248, 0.4); border-color: #38bdf8; }
  55% { transform: scale(1.04); box-shadow: 0 0 16px rgba(56, 189, 248, 0.5); border-color: #38bdf8; }
  100% { transform: scale(1); box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3), inset 0 0 12px rgba(234, 179, 8, 0.05); border-color: rgba(234, 179, 8, 0.3); }
}

@keyframes pulseHudLightning {
  0% { transform: scale(1); }
  25% { transform: scale(1.12); box-shadow: 0 0 24px rgba(245, 158, 11, 0.85), inset 0 0 14px rgba(245, 158, 11, 0.35); border-color: #fbbf24; }
  55% { transform: scale(1.03); box-shadow: 0 0 14px rgba(245, 158, 11, 0.45); border-color: #fbbf24; }
  100% { transform: scale(1); box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3), inset 0 0 12px rgba(234, 179, 8, 0.05); border-color: rgba(234, 179, 8, 0.3); }
}

@keyframes pulseHudSwift {
  0% { transform: scale(1); }
  25% { transform: scale(1.09); box-shadow: 0 0 20px rgba(16, 185, 129, 0.75), inset 0 0 12px rgba(16, 185, 129, 0.25); border-color: #34d399; }
  100% { transform: scale(1); box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3), inset 0 0 12px rgba(234, 179, 8, 0.05); border-color: rgba(234, 179, 8, 0.3); }
}

@keyframes pulseHudSteady {
  0% { transform: scale(1); }
  25% { transform: scale(1.06); box-shadow: 0 0 16px rgba(212, 175, 55, 0.6), inset 0 0 10px rgba(212, 175, 55, 0.2); border-color: var(--gold-light); }
  100% { transform: scale(1); box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3), inset 0 0 12px rgba(234, 179, 8, 0.05); border-color: rgba(234, 179, 8, 0.3); }
}

@keyframes pulseHudCasual {
  0% { transform: scale(1); }
  25% { transform: scale(1.04); box-shadow: 0 0 12px rgba(148, 163, 184, 0.4); border-color: #94a3b8; }
  100% { transform: scale(1); box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3), inset 0 0 12px rgba(234, 179, 8, 0.05); border-color: rgba(234, 179, 8, 0.3); }
}

@keyframes pulseHudGeneral {
  0% { transform: scale(1); }
  25% { transform: scale(1.08); box-shadow: 0 0 20px rgba(250, 204, 21, 0.7); }
  100% { transform: scale(1); }
}

.match-speed-hud.pulse-match .match-speed-sec {
  animation: speedDigitsPop 0.45s ease-out;
}

.match-speed-hud.pulse-match .speed-pts-live {
  animation: speedPtsPop 0.45s ease-out;
}

@keyframes speedDigitsPop {
  0% { transform: scale(1); }
  35% { transform: scale(1.28); color: #ffffff; text-shadow: 0 0 10px #38bdf8; }
  100% { transform: scale(1); }
}

@keyframes speedPtsPop {
  0% { transform: scale(1); }
  35% { transform: scale(1.22); color: #ffffff; text-shadow: 0 0 10px #fde047; }
  100% { transform: scale(1); }
}

.match-speed-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 2px;
}

.speed-tier-pill {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.5px;
  padding: 1px 6px;
  border-radius: 999px;
  text-transform: uppercase;
  transition: all 0.25s ease;
}

.speed-tier-pill.blazing {
  background: rgba(56, 189, 248, 0.25);
  color: #38bdf8;
  border: 1px solid #38bdf8;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.4);
  animation: blazingPillPulse 1.2s infinite alternate;
}

@keyframes blazingPillPulse {
  0% { box-shadow: 0 0 4px rgba(56, 189, 248, 0.4); }
  100% { box-shadow: 0 0 12px rgba(56, 189, 248, 0.8), 0 0 2px #fff; }
}

.speed-tier-pill.lightning {
  background: rgba(245, 158, 11, 0.25);
  color: #fbbf24;
  border: 1px solid #f59e0b;
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.3);
}

.speed-tier-pill.swift {
  background: rgba(16, 185, 129, 0.25);
  color: #34d399;
  border: 1px solid #10b981;
}

.speed-tier-pill.steady {
  background: rgba(212, 175, 55, 0.2);
  color: #e2e8f0;
  border: 1px solid rgba(212, 175, 55, 0.4);
}

.speed-tier-pill.casual {
  background: rgba(148, 163, 184, 0.15);
  color: #94a3b8;
  border: 1px solid rgba(148, 163, 184, 0.3);
}

.match-speed-main {
  display: flex;
  align-items: center;
  gap: 8px;
}

.match-gauge-box {
  position: relative;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.match-gauge-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.gauge-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 3.5;
}

.gauge-meter {
  fill: none;
  stroke: #38bdf8;
  stroke-width: 3.5;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.1s linear, stroke 0.3s ease;
}

.gauge-meter.blazing { stroke: #38bdf8; filter: drop-shadow(0 0 3px #38bdf8); }
.gauge-meter.lightning { stroke: #fbbf24; filter: drop-shadow(0 0 3px #f59e0b); }
.gauge-meter.swift { stroke: #34d399; filter: drop-shadow(0 0 2px #10b981); }
.gauge-meter.steady { stroke: #d4af37; }
.gauge-meter.casual { stroke: #64748b; }

.match-speed-sec {
  position: absolute;
  font-family: var(--font-heading);
  font-size: 10px;
  font-weight: 800;
  color: #ffffff;
  font-feature-settings: "tnum";
  letter-spacing: -0.2px;
}

.match-speed-rate {
  display: flex;
  flex-direction: column;
}

.speed-pts-live {
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 800;
  color: #fde047;
  letter-spacing: 0.3px;
  text-shadow: 0 0 8px rgba(250, 204, 21, 0.4);
  font-feature-settings: "tnum";
}

.speed-mult-tag {
  font-size: 9px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

/* -------------------------------------------------------------
   Victory Modal Speed Progression Enhancements
   ------------------------------------------------------------- */
.win-stat-cell.speed-stat-cell strong {
  color: #38bdf8;
  text-shadow: 0 0 10px rgba(56, 189, 248, 0.4);
}

.win-speed-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(56, 189, 248, 0.15));
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  margin: 12px 0 16px 0;
  text-align: left;
}

.win-speed-icon {
  font-size: 22px;
  color: #38bdf8;
  filter: drop-shadow(0 0 6px #38bdf8);
}

.win-speed-info {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.win-speed-info strong {
  font-family: var(--font-heading);
  font-size: 13px;
  color: #fde047;
  letter-spacing: 0.5px;
}

.win-speed-info small {
  font-size: 11px;
  color: var(--text-muted);
}

.speed-btn-sm {
  font-size: 11px !important;
  padding: 5px 10px !important;
  background: rgba(56, 189, 248, 0.2) !important;
  border-color: #38bdf8 !important;
  color: #e0f2fe !important;
  white-space: nowrap;
}

/* -------------------------------------------------------------
   Speed Analytics & Progression History Modal
   ------------------------------------------------------------- */
.speed-modal-card {
  max-width: 680px !important;
  width: 95% !important;
  max-height: 90vh;
  overflow-y: auto;
  padding: 22px 24px !important;
  background: radial-gradient(circle at 50% 0%, #0d2e23 0%, #061912 100%) !important;
}

.speed-modal-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.speed-modal-icon {
  font-size: 26px;
  filter: drop-shadow(0 0 8px #facc15);
}

.speed-modal-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.speed-profile-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  background: rgba(18, 52, 38, 0.6);
  border: 1px solid rgba(212, 175, 55, 0.25);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  margin: 14px 0 16px 0;
}

.player-tag-control {
  display: flex;
  align-items: center;
  gap: 8px;
}

.player-tag-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--gold-light);
}

#stats-player-tag {
  width: 90px;
  padding: 5px 8px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid var(--gold-primary);
  border-radius: var(--radius-sm);
  color: #ffffff;
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 2px;
  text-align: center;
  text-transform: uppercase;
}

.tag-apply-btn {
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 700;
  background: rgba(212, 175, 55, 0.2);
  border: 1px solid var(--gold-primary);
  border-radius: var(--radius-sm);
  color: var(--gold-light);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.tag-apply-btn:hover {
  background: var(--gold-primary);
  color: #1a1202;
}

.speed-verdict-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(56, 189, 248, 0.4);
}

.speed-verdict-badge.faster {
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.12);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.2);
}

.speed-verdict-badge.slower {
  border-color: #f59e0b;
  background: rgba(245, 158, 11, 0.12);
}

.speed-verdict-badge.steady {
  border-color: #10b981;
  background: rgba(16, 185, 129, 0.12);
}

.verdict-icon {
  font-size: 20px;
}

.verdict-text-wrap {
  display: flex;
  flex-direction: column;
}

.verdict-text-wrap strong {
  font-family: var(--font-heading);
  font-size: 11px;
  letter-spacing: 0.5px;
  color: #fde047;
}

.verdict-text-wrap small {
  font-size: 10px;
  color: var(--text-muted);
}

/* 4 Metric Cards */
.speed-metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

@media (max-width: 600px) {
  .speed-metrics-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.speed-card {
  display: flex;
  flex-direction: column;
  padding: 10px 12px;
  background: rgba(18, 52, 38, 0.5);
  border: 1px solid rgba(212, 175, 55, 0.2);
  border-radius: var(--radius-sm);
  text-align: center;
}

.speed-card-label {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.8px;
  color: var(--gold-primary);
  margin-bottom: 4px;
}

.speed-card-val {
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: 800;
  color: #ffffff;
  font-feature-settings: "tnum";
}

.speed-card-val.gold {
  color: #fde047;
  text-shadow: 0 0 10px rgba(250, 204, 21, 0.4);
}

.speed-card-sub {
  font-size: 9px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Chart Section */
.chart-section {
  background: rgba(8, 25, 18, 0.7);
  border: 1px solid rgba(212, 175, 55, 0.2);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 16px;
}

.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.chart-title {
  font-family: var(--font-heading);
  font-size: 12px;
  font-weight: 700;
  color: var(--gold-light);
  letter-spacing: 0.5px;
}

.chart-legend {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 10px;
  color: var(--text-muted);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.legend-dot.blazing { background: #38bdf8; box-shadow: 0 0 4px #38bdf8; }
.legend-dot.lightning { background: #fbbf24; }
.legend-dot.swift { background: #34d399; }
.legend-dot.steady { background: #94a3b8; }

.chart-canvas-wrap {
  position: relative;
  width: 100%;
  height: 200px;
}

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

.chart-footnote {
  font-size: 10px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 6px;
}

/* Bottom Split: Tier Distribution & Recent Matches */
.speed-bottom-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 600px) {
  .speed-bottom-row {
    grid-template-columns: 1fr;
  }
}

.tier-distribution-card, .recent-matches-card {
  background: rgba(18, 52, 38, 0.45);
  border: 1px solid rgba(212, 175, 55, 0.2);
  border-radius: var(--radius-sm);
  padding: 12px;
}

.tier-distribution-card h4, .recent-matches-card h4 {
  font-family: var(--font-heading);
  font-size: 11px;
  color: var(--gold-light);
  letter-spacing: 0.5px;
  margin-bottom: 10px;
  text-transform: uppercase;
}

.tier-bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 7px;
  font-size: 11px;
}

.tier-name {
  width: 105px;
  font-size: 10px;
  color: #e2e8f0;
  white-space: nowrap;
}

.tier-bar-track {
  flex: 1;
  height: 8px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 999px;
  overflow: hidden;
}

.tier-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.6s cubic-bezier(0.2, 0.8, 0.3, 1);
}

.tier-bar-fill.blazing { background: linear-gradient(90deg, #0284c7, #38bdf8); }
.tier-bar-fill.lightning { background: linear-gradient(90deg, #d97706, #fbbf24); }
.tier-bar-fill.swift { background: linear-gradient(90deg, #059669, #34d399); }
.tier-bar-fill.steady { background: linear-gradient(90deg, #b45309, #d4af37); }
.tier-bar-fill.casual { background: #64748b; }

.tier-pct {
  width: 32px;
  text-align: right;
  font-size: 10px;
  font-weight: 700;
  color: var(--gold-light);
}

.recent-matches-list {
  max-height: 150px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.recent-match-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 4px;
  font-size: 11px;
  border-left: 3px solid #64748b;
}

.recent-match-item.blazing { border-left-color: #38bdf8; }
.recent-match-item.lightning { border-left-color: #fbbf24; }
.recent-match-item.swift { border-left-color: #34d399; }
.recent-match-item.steady { border-left-color: #d4af37; }

.recent-match-time {
  font-family: var(--font-heading);
  font-weight: 800;
  color: #ffffff;
}

.recent-match-pts {
  color: #fde047;
  font-weight: 700;
  font-size: 10px;
}

.empty-matches-msg {
  color: var(--text-muted);
  font-size: 11px;
  text-align: center;
  padding: 20px 0;
}


/* Phone-only table: leave larger screen layouts unchanged. */
@media (max-width: 600px), (max-width: 950px) and (max-height: 500px) and (pointer: coarse) {
  .game-viewport {
    height: 100dvh;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  }
  .topbar { flex-wrap: wrap; gap: 4px; padding: 4px 8px; flex-shrink: 0; }
  .brand-mark { width: 30px; height: 30px; }
  .brand-text small { display: none; }
  .top-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; flex: 1 1 100%; min-width: 0; }
  .top-actions .action-btn, .top-actions .icon-btn { min-height: 44px; }
  .top-actions .icon-btn { min-width: 44px; }
  #layout-picker-btn { margin-right: auto; }
  #speed-stats-btn { padding: 4px 8px; }
  #speed-stats-btn span:last-child { display: none; }
  .hud-bar { padding: 5px 8px; gap: 5px; flex-shrink: 0; }
  .hud-group { width: 100%; justify-content: space-between; gap: 8px; min-width: 0; }
  .hud-item { min-width: 0; }
  .hud-value { font-size: 14px; }
  .hud-streak { display: none; }
  .match-speed-hud { display: none; }
  .hud-controls { width: 100%; display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
  .hud-btn { min-height: 44px; justify-content: center; padding: 5px; }
  .hud-btn span.btn-text { display: inline; font-size: 10px; }
  .board-viewport { min-height: 0; height: auto; }
  .tile-element { width: 48px; height: 64px; touch-action: manipulation; }
  .zoom-controls { right: 4px; bottom: 4px; }
  .zoom-btn { min-width: 44px; min-height: 44px; }
  .modal-overlay { padding: 12px; }
  .modal-card { max-width: 100%; max-height: calc(100dvh - 24px); overflow-y: auto; padding: 16px; }
  .modal-actions { flex-wrap: wrap; }
  .modal-actions .action-btn, .close-btn { min-height: 44px; min-width: 44px; }
  .layouts-grid { grid-template-columns: 1fr; }
  .phone-layout[hidden] { display: none; }
}
@media (max-width: 950px) and (max-height: 500px) and (pointer: coarse) {
  .topbar { flex-wrap: nowrap; }
  .top-actions { flex-basis: auto; }
  .brand-text { display: none; }
  .hud-bar { flex-wrap: nowrap; }
  .hud-group { width: auto; flex: 1; }
  .hud-controls { width: auto; }
  .hud-btn { min-width: 50px; }
  .hud-btn span.btn-text { display: none; }
}
