/* HexaMage - Premium Web Gaming Stylesheet */

:root {
  --bg-primary: #0a1118;
  --bg-secondary: #0e1c27;
  --bg-board: #071317;
  --panel-bg: rgba(14, 28, 39, 0.85);
  --panel-border: rgba(64, 224, 208, 0.25);
  
  --hex-orange-1: #ff5e14;
  --hex-orange-2: #ff9800;
  --hex-blue-border: #1a56db;
  --hex-yellow-text: #ffe066;
  
  --opr-x2-color: #38bdf8;
  --opr-1forall-color: #4ade80;
  --opr-clone-color: #ec4899;
  
  --accent-cyan: #06b6d4;
  --accent-gold: #facc15;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  
  --font-family: 'Rubik', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --shadow-glow: 0 0 25px rgba(6, 182, 212, 0.35);
  --shadow-tile: 0 8px 20px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

body, html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-primary);
  font-family: var(--font-family);
  color: var(--text-main);
}

/* Background Ambient Lighting */
.ambient-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
  background: 
    radial-gradient(circle at 20% 20%, rgba(6, 182, 212, 0.12) 0%, transparent 40%),
    radial-gradient(circle at 80% 80%, rgba(255, 94, 20, 0.1) 0%, transparent 50%),
    radial-gradient(circle at 50% 50%, rgba(14, 28, 39, 0.95) 0%, #050b10 100%);
  pointer-events: none;
}

/* App Wrapper */
#app-container {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Screen Management */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  opacity: 0;
  transition: opacity 0.35s ease;
  pointer-events: none;
}

.screen.active {
  display: flex;
  opacity: 1;
  pointer-events: auto;
}

/* ==================== TITLE SCREEN ==================== */
#screen-menu {
  padding: 20px;
  text-align: center;
  position: relative;
}

.top-lang-bar {
  position: absolute;
  top: 18px;
  right: 22px;
  z-index: 10;
}

[dir="rtl"] .top-lang-bar {
  right: auto;
  left: 22px;
}

.lang-btn {
  width: auto;
  padding: 8px 16px;
  font-size: 0.95rem;
  font-weight: 700;
  border-radius: 20px;
}

.menu-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 650px;
  width: 100%;
  animation: fadeInDown 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ==================== 3D INTERLOCKING HONEYCOMB LOGO ==================== */
.game-logo-wrapper {
  position: relative;
  width: 364px;
  height: 184px;
  margin: 0 auto 20px auto;
  perspective: 900px;
  perspective-origin: 50% 50%;
  transform-origin: center center;
}

.hex-logo-tile {
  position: absolute;
  left: var(--tile-x);
  top: var(--tile-y);
  width: 78px;
  height: 96px;
  transform-style: preserve-3d;
  will-change: transform, opacity;
  animation: 
    hexLogoFadeIn 0.5s ease-out var(--fade-delay) both,
    hexLogoTiltWave 2.4s ease-in-out calc(var(--fade-delay) + 0.2s) 2 normal forwards;
  cursor: pointer;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.45));
  transition: transform 0.25s ease, filter 0.25s ease;
}

.hex-tile-svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}

.hex-logo-letter {
  font-family: 'Rubik', system-ui, sans-serif;
  font-weight: 900;
  font-size: 38px;
  fill: #000000;
  text-anchor: middle;
  dominant-baseline: central;
  filter: drop-shadow(0 0 3px rgba(255, 234, 0, 0.75));
  user-select: none;
  pointer-events: none;
}

.hex-logo-tile:hover {
  transform: translateY(-4px) scale(1.05) !important;
  filter: drop-shadow(0 12px 18px rgba(250, 204, 21, 0.55)) drop-shadow(0 4px 8px rgba(0, 0, 0, 0.5));
  z-index: 25;
}

.hex-logo-tile.tile-clicked {
  animation: hexLogoClickPunch 0.3s ease-out !important;
}

/* Pure smooth Fade In without jumping */
@keyframes hexLogoFadeIn {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

/* Subtle, gentle tilt wave that stabilizes peacefully after 2 passes */
@keyframes hexLogoTiltWave {
  0% {
    transform: translateY(0px) rotateX(0deg) rotateY(0deg);
  }
  25% {
    transform: translateY(-3px) rotateX(-4deg) rotateY(3deg);
  }
  50% {
    transform: translateY(0px) rotateX(0deg) rotateY(0deg);
  }
  75% {
    transform: translateY(2.5px) rotateX(3.5deg) rotateY(-2.5deg);
  }
  100% {
    transform: translateY(0px) rotateX(0deg) rotateY(0deg);
  }
}

@keyframes hexLogoClickPunch {
  0% { transform: scale(1) translateY(0); }
  50% { transform: scale(1.15) translateY(-5px); }
  100% { transform: scale(1) translateY(0); }
}

@media (max-width: 420px) {
  .game-logo-wrapper {
    transform: scale(0.88);
    margin-bottom: 2px;
  }
}

@media (max-width: 360px) {
  .game-logo-wrapper {
    transform: scale(0.78);
    margin-bottom: -12px;
  }
}

.game-tagline {
  font-size: 1.25rem;
  font-weight: 500;
  color: var(--accent-cyan);
  text-shadow: 0 0 12px rgba(6, 182, 212, 0.5);
  margin-top: -10px;
  margin-bottom: 25px;
}

.total-stars-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  background: rgba(250, 204, 21, 0.15);
  border: 1px solid rgba(250, 204, 21, 0.35);
  border-radius: 30px;
  color: var(--accent-gold);
  font-weight: 700;
  font-size: 1.15rem;
  margin-bottom: 30px;
  box-shadow: 0 0 15px rgba(250, 204, 21, 0.2);
}

.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: 340px;
}

.btn-primary {
  padding: 16px 28px;
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #ff5e14 0%, #ff8c00 100%);
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 16px;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(255, 94, 20, 0.4);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.btn-primary:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 10px 28px rgba(255, 94, 20, 0.6);
  border-color: #fff;
}

.btn-primary:active {
  transform: translateY(1px) scale(0.98);
}

.btn-secondary {
  padding: 14px 24px;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-main);
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(10px);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-secondary:hover {
  background: rgba(20, 42, 60, 0.95);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  transform: translateY(-2px);
}

/* ==================== WORLD SELECTION ==================== */
#screen-worlds {
  padding: 20px;
}

.page-header {
  width: 100%;
  max-width: 900px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding: 0 10px;
}

.header-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.header-title {
  font-size: 1.8rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
  margin: 0;
}

.header-stars-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 6px;
  background: rgba(250, 204, 21, 0.15);
  border: 1px solid rgba(250, 204, 21, 0.45);
  color: #fef08a;
  padding: 4px 16px;
  border-radius: 20px;
  font-size: 0.95rem;
  font-weight: 700;
  box-shadow: 0 2px 10px rgba(250, 204, 21, 0.2);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

.worlds-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
  width: 100%;
  max-width: 900px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  padding: 10px;
}

.world-card {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  backdrop-filter: blur(12px);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: all 0.25s ease;
  box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

.world-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, var(--accent-cyan), var(--hex-orange-1));
  opacity: 0.8;
}

.world-card:hover {
  transform: translateY(-5px);
  border-color: var(--accent-cyan);
  box-shadow: 0 12px 30px rgba(6, 182, 212, 0.25);
}

.world-card.locked {
  opacity: 0.55;
  filter: grayscale(0.5);
  cursor: not-allowed;
}

.world-card.locked:hover {
  transform: none;
  border-color: var(--panel-border);
  box-shadow: none;
}

.world-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.world-number-badge {
  font-size: 0.85rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.15);
  padding: 4px 10px;
  border-radius: 8px;
}

.world-powerup-icon {
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
}

.world-title {
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: #fff;
}

.world-desc {
  font-size: 0.95rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 18px;
}

.world-stars-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 12px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--accent-gold);
}

.stat-fraction {
  display: inline-block;
  direction: ltr;
  unicode-bidi: isolate;
  font-variant-numeric: tabular-nums;
}

/* ==================== LEVEL SELECTION ==================== */
#screen-levels {
  padding: 20px;
}

.levels-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  width: 100%;
  max-width: 650px;
  padding: 10px;
}

@media (max-width: 600px) {
  .levels-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
  }
}

.level-box {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.level-box:hover {
  transform: translateY(-3px) scale(1.04);
  border-color: var(--hex-orange-2);
  box-shadow: 0 6px 18px rgba(255, 152, 0, 0.3);
}

.level-box.locked {
  opacity: 0.4;
  cursor: not-allowed;
}

.level-box.locked:hover {
  transform: none;
  box-shadow: none;
  border-color: var(--panel-border);
}

.level-box-num {
  font-size: 1.4rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 4px;
}

.level-box-stars {
  display: flex;
  gap: 3px;
  font-size: 0.8rem;
  color: var(--accent-gold);
}

.level-box-stars .star-empty {
  opacity: 0.25;
  color: #fff;
}

/* ==================== GAMEPLAY SCREEN ==================== */
#screen-game {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

/* Game Top HUD */
.game-hud {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: linear-gradient(180deg, rgba(7, 19, 23, 0.95) 0%, rgba(7, 19, 23, 0.4) 80%, transparent 100%);
  position: absolute;
  top: 0;
  left: 0;
  z-index: 10;
  pointer-events: auto;
}

.hud-left, .hud-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hud-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(14, 28, 39, 0.8);
  border: 1px solid var(--panel-border);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  cursor: pointer;
  transition: all 0.2s ease;
  backdrop-filter: blur(8px);
}

.hud-btn:hover {
  background: rgba(20, 45, 65, 0.95);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  transform: translateY(-2px);
}

.hud-center {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.target-panel {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(10, 25, 32, 0.85);
  border: 1px solid rgba(250, 204, 21, 0.4);
  border-radius: 16px;
  padding: 6px 18px;
  box-shadow: 0 0 16px rgba(250, 204, 21, 0.2);
  backdrop-filter: blur(10px);
}

.target-label {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--accent-gold);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.targets-container {
  display: flex;
  align-items: center;
  gap: 10px;
}

.target-chip {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  font-size: 1.15rem;
  font-weight: 800;
  color: #fff;
  transition: all 0.3s ease;
}

.target-chip.completed {
  background: rgba(250, 204, 21, 0.25);
  border-color: var(--accent-gold);
  color: var(--accent-gold);
  box-shadow: 0 0 12px rgba(250, 204, 21, 0.5);
  transform: scale(1.06);
}

.use-all-badge {
  font-size: 0.75rem;
  font-weight: 700;
  color: #ec4899;
  background: rgba(236, 72, 153, 0.15);
  border: 1px solid rgba(236, 72, 153, 0.3);
  border-radius: 6px;
  padding: 2px 8px;
  margin-top: 4px;
}

/* Canvas Board */
#game-canvas-container {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
}

#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

/* Floating Status / Instructions Overlay */
.in-game-hint {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(7, 19, 23, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 0.9rem;
  color: var(--text-muted);
  backdrop-filter: blur(8px);
  pointer-events: none;
  transition: opacity 0.3s ease;
}

/* Live 3D Tilt Selector Bar */
.tilt-selector-bar {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(4, 30, 24, 0.94);
  border: 1px solid rgba(52, 211, 153, 0.35);
  padding: 8px 18px;
  border-radius: 28px;
  backdrop-filter: blur(14px);
  box-shadow: 0 4px 22px rgba(0, 0, 0, 0.6);
  z-index: 10;
}

.tilt-label {
  font-size: 0.9rem;
  font-weight: 700;
  color: #34d399;
  white-space: nowrap;
}

.tilt-min-max {
  font-size: 0.78rem;
  font-weight: 600;
  color: #94a3b8;
  white-space: nowrap;
}

.tilt-slider-input {
  -webkit-appearance: none;
  appearance: none;
  width: 170px;
  height: 6px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  outline: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tilt-slider-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #38bdf8;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.8);
  border: 2px solid #ffffff;
  cursor: pointer;
  transition: transform 0.1s ease;
}

.tilt-slider-input::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  background: #0284c7;
}

.tilt-slider-input::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #38bdf8;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.8);
  border: 2px solid #ffffff;
  cursor: pointer;
}

.tilt-val-badge {
  font-family: monospace;
  font-size: 0.95rem;
  font-weight: 800;
  color: #facc15;
  background: rgba(0, 0, 0, 0.45);
  padding: 3px 10px;
  border-radius: 12px;
  border: 1px solid rgba(250, 204, 21, 0.35);
  min-width: 44px;
  text-align: center;
}

/* ==================== MODALS ==================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(4, 9, 14, 0.85);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.modal-overlay.active {
  display: flex;
  opacity: 1;
}

.modal-box {
  background: var(--panel-bg);
  border: 2px solid var(--panel-border);
  border-radius: 24px;
  padding: 32px 28px;
  max-width: 500px;
  width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--accent-cyan) rgba(255, 255, 255, 0.05);
  text-align: center;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.6), var(--shadow-glow);
  position: relative;
  animation: modalPop 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-box::-webkit-scrollbar {
  width: 6px;
}
.modal-box::-webkit-scrollbar-thumb {
  background: var(--accent-cyan);
  border-radius: 4px;
}

.modal-title {
  font-size: 2rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 12px;
}

.modal-desc {
  font-size: 1.05rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 24px;
}

.win-stars-display {
  display: flex;
  justify-content: center;
  gap: 12px;
  font-size: 2.8rem;
  color: var(--accent-gold);
  margin-bottom: 24px;
  filter: drop-shadow(0 0 15px rgba(250, 204, 21, 0.6));
}

.win-target-tile-preview {
  margin: 15px auto;
  width: 100px;
  height: 100px;
  position: relative;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Tutorial Demo Modal Canvas */
.tutorial-canvas-wrapper {
  width: 100%;
  height: 220px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 16px;
  margin-bottom: 18px;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

#tutorial-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Settings Modal Specifics */
.settings-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin: 16px 0 24px 0;
}

[dir="rtl"] .settings-content {
  text-align: right;
  direction: rtl;
}

[dir="ltr"] .settings-content {
  text-align: left;
  direction: ltr;
}

.settings-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: rgba(255, 255, 255, 0.04);
  padding: 14px 18px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.settings-label {
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent-cyan);
}

.settings-slider-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  direction: ltr;
}

.settings-slider-row .tilt-slider-input {
  flex: 1;
}

.settings-hex-preview-box {
  width: 64px;
  height: 64px;
  border-radius: 14px;
  background: rgba(7, 19, 23, 0.75);
  border: 1px solid rgba(6, 182, 212, 0.35);
  box-shadow: 0 0 16px rgba(6, 182, 212, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

#settings-hex-preview-canvas {
  width: 64px;
  height: 64px;
  display: block;
}

.settings-toggle-row {
  display: flex;
  gap: 10px;
}

.settings-toggle-row .btn-secondary {
  flex: 1;
  padding: 10px 12px;
  font-size: 0.95rem;
}

/* Win Unsolved Alert Notice */
.win-unsolved-notice {
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.45);
  color: #fbbf24;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.45;
  margin-bottom: 18px;
  text-align: center;
  box-shadow: 0 0 15px rgba(245, 158, 11, 0.15);
}

/* Danger Button & Zone */
.btn-danger {
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
  color: #fff;
  border: 1px solid rgba(239, 68, 68, 0.4);
  box-shadow: 0 4px 14px rgba(220, 38, 38, 0.35);
  padding: 12px 20px;
  border-radius: 14px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 100%;
}

.btn-danger:hover {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  box-shadow: 0 6px 20px rgba(239, 68, 68, 0.5);
  transform: translateY(-2px);
}

.btn-danger:active {
  transform: translateY(0);
}

.settings-danger-group {
  border-color: rgba(239, 68, 68, 0.25) !important;
  background: rgba(239, 68, 68, 0.05) !important;
}

.settings-danger-label {
  color: #f87171 !important;
}

/* Keyframe Animations */
@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes floatLogo {
  0%, 100% { transform: translateY(0px) rotate(0deg); }
  50% { transform: translateY(-8px) rotate(-1deg); }
}

@keyframes modalPop {
  0% { transform: scale(0.85); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* ==================== SHARE SYSTEM & TOAST ==================== */
.btn-win-share {
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%) !important;
  border-color: rgba(56, 189, 248, 0.5) !important;
  box-shadow: 0 6px 20px rgba(2, 132, 199, 0.45) !important;
  color: #fff !important;
}

.btn-win-share:hover {
  background: linear-gradient(135deg, #0369a1 0%, #0284c7 100%) !important;
  box-shadow: 0 8px 26px rgba(56, 189, 248, 0.6) !important;
  transform: translateY(-2px);
}

.share-toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(30px);
  background: rgba(7, 25, 38, 0.95);
  border: 1.5px solid var(--accent-cyan);
  color: #fff;
  padding: 12px 26px;
  border-radius: 30px;
  font-size: 1rem;
  font-weight: 700;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), var(--shadow-glow);
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  backdrop-filter: blur(14px);
  text-align: center;
  max-width: 90vw;
  white-space: nowrap;
}

.share-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ==================== COMPREHENSIVE MOBILE & LANDSCAPE RESPONSIVENESS ==================== */

/* Short Height Screen / Mobile Landscape (e.g. Phone rotated horizontally) */
@media (max-height: 580px), (orientation: landscape) and (max-height: 750px) {
  /* Menu Screen */
  #screen-menu {
    padding: 6px 16px !important;
    overflow-y: auto !important;
  }

  .menu-content {
    max-width: 580px !important;
  }

  .game-logo-wrapper {
    margin: 0 auto 4px auto !important;
    transform: scale(0.68) !important;
    transform-origin: center top !important;
    height: 125px !important;
  }

  .game-logo-img {
    max-width: 170px !important;
    height: auto !important;
  }

  .game-tagline {
    font-size: 0.95rem !important;
    margin-top: -6px !important;
    margin-bottom: 6px !important;
  }

  .total-stars-badge {
    font-size: 0.9rem !important;
    padding: 3px 14px !important;
    margin-bottom: 8px !important;
  }

  .menu-buttons {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    max-width: 480px !important;
    gap: 8px !important;
  }

  .menu-buttons .btn-primary,
  .menu-buttons .btn-secondary {
    padding: 9px 14px !important;
    font-size: 0.92rem !important;
    border-radius: 12px !important;
  }

  /* Worlds & Levels Screen */
  .page-header {
    margin-bottom: 8px !important;
    padding: 0 8px !important;
  }

  .header-title {
    font-size: 1.35rem !important;
  }

  .worlds-grid {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)) !important;
    gap: 10px !important;
    max-height: calc(100vh - 65px) !important;
    padding: 6px !important;
  }

  .world-card {
    padding: 12px 14px !important;
    border-radius: 16px !important;
  }

  .world-title {
    font-size: 1.1rem !important;
    margin-bottom: 3px !important;
  }

  .world-desc {
    font-size: 0.82rem !important;
    margin-bottom: 8px !important;
  }

  .levels-grid {
    grid-template-columns: repeat(7, 1fr) !important;
    gap: 8px !important;
    max-height: calc(100vh - 65px) !important;
    padding: 6px !important;
    overflow-y: auto !important;
  }

  .level-box {
    border-radius: 12px !important;
  }

  .level-box-num {
    font-size: 1.05rem !important;
  }

  /* Gameplay HUD & In-game */
  .game-hud {
    padding: 4px 14px !important;
  }

  .hud-btn {
    width: 36px !important;
    height: 36px !important;
    border-radius: 10px !important;
    font-size: 1.05rem !important;
  }

  .target-panel {
    padding: 3px 12px !important;
    gap: 8px !important;
    border-radius: 12px !important;
  }

  .target-label {
    font-size: 0.8rem !important;
  }

  .target-chip {
    font-size: 0.95rem !important;
    padding: 2px 8px !important;
  }

  .use-all-badge {
    font-size: 0.65rem !important;
    padding: 1px 6px !important;
  }

  .in-game-hint {
    bottom: 6px !important;
    font-size: 0.78rem !important;
    padding: 3px 12px !important;
  }

  .tilt-selector-bar {
    bottom: 6px !important;
    padding: 4px 12px !important;
    gap: 6px !important;
  }

  .tilt-label, .tilt-min-max {
    font-size: 0.75rem !important;
  }

  .tilt-slider-input {
    width: 110px !important;
  }

  /* Modals in Landscape */
  .modal-overlay {
    padding: 10px !important;
  }

  .modal-box {
    padding: 16px 20px !important;
    max-width: 480px !important;
    max-height: 94vh !important;
    border-radius: 18px !important;
  }

  .modal-title {
    font-size: 1.35rem !important;
    margin-bottom: 6px !important;
  }

  .modal-desc {
    font-size: 0.88rem !important;
    line-height: 1.35 !important;
    margin-bottom: 12px !important;
  }

  .win-stars-display {
    font-size: 2rem !important;
    gap: 8px !important;
    margin-bottom: 12px !important;
  }

  .modal-actions {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
  }

  .modal-actions .btn-primary,
  .modal-actions .btn-secondary {
    padding: 9px 12px !important;
    font-size: 0.88rem !important;
    border-radius: 12px !important;
  }

  .tutorial-canvas-wrapper {
    height: 130px !important;
    margin-bottom: 8px !important;
  }

  .settings-content {
    gap: 10px !important;
    margin: 8px 0 14px 0 !important;
  }

  .settings-group {
    padding: 8px 12px !important;
    gap: 6px !important;
  }
}

/* Mobile Portrait Narrow Screen */
@media (max-width: 480px) and (min-height: 541px) {
  .menu-content {
    padding: 10px;
  }

  .game-logo-img {
    max-width: 250px;
  }

  .game-tagline {
    font-size: 1.05rem;
  }

  .hud-btn {
    width: 38px;
    height: 38px;
    font-size: 1.1rem;
  }

  .hud-left, .hud-right {
    gap: 6px;
  }

  .target-panel {
    padding: 4px 10px;
  }

  .target-chip {
    font-size: 1rem;
    padding: 2px 7px;
  }

  .tilt-selector-bar {
    padding: 6px 12px;
    gap: 6px;
  }

  .tilt-slider-input {
    width: 120px;
  }
}

/* ==================== BACKGROUND THEMES ==================== */
body[data-bg-theme="black"] .ambient-bg {
  background: #000000 !important;
}

body[data-bg-theme="space"] .ambient-bg {
  background: 
    radial-gradient(circle at 20% 20%, rgba(56, 189, 248, 0.16) 0%, transparent 45%),
    radial-gradient(circle at 80% 80%, rgba(99, 102, 241, 0.14) 0%, transparent 50%),
    radial-gradient(circle at 50% 50%, #06152d 0%, #020612 100%) !important;
}

body[data-bg-theme="mystic"] .ambient-bg {
  background: 
    radial-gradient(circle at 20% 20%, rgba(192, 132, 252, 0.18) 0%, transparent 45%),
    radial-gradient(circle at 80% 80%, rgba(244, 114, 182, 0.14) 0%, transparent 50%),
    radial-gradient(circle at 50% 50%, #20053a 0%, #090117 100%) !important;
}

body[data-bg-theme="charcoal"] .ambient-bg {
  background: 
    radial-gradient(circle at 20% 20%, rgba(148, 163, 184, 0.12) 0%, transparent 45%),
    radial-gradient(circle at 80% 80%, rgba(71, 85, 105, 0.12) 0%, transparent 50%),
    radial-gradient(circle at 50% 50%, #111a28 0%, #020617 100%) !important;
}

/* Theme Selector Compact Swatch Row in Settings */
.settings-themes-row,
.settings-themes-grid {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  width: 100%;
  margin-top: 6px;
  padding: 2px 0;
}

.theme-card {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid rgba(255, 255, 255, 0.15);
  cursor: pointer;
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}

.theme-card:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(64, 224, 208, 0.6);
  transform: translateY(-2px) scale(1.08);
}

.theme-card.active {
  background: rgba(6, 182, 212, 0.18);
  border-color: var(--accent-cyan);
  box-shadow: 0 0 16px rgba(6, 182, 212, 0.55);
  transform: scale(1.10);
}

.theme-card.active::after {
  content: '✓';
  position: absolute;
  font-size: 0.85rem;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.95);
  pointer-events: none;
}

.theme-swatch {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  flex-shrink: 0;
  box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.35), 0 3px 6px rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.25);
  transition: transform 0.2s ease;
}

.theme-card:hover .theme-swatch {
  transform: scale(1.04);
}

.theme-swatch.swatch-emerald {
  background: radial-gradient(circle, #10b981 0%, #064e3b 100%);
}

.theme-swatch.swatch-black {
  background: #000000;
  border-color: #444;
}

.theme-swatch.swatch-space {
  background: radial-gradient(circle, #38bdf8 0%, #0c2340 100%);
}

.theme-swatch.swatch-mystic {
  background: radial-gradient(circle, #c084fc 0%, #3b0764 100%);
}

.theme-swatch.swatch-charcoal {
  background: radial-gradient(circle, #94a3b8 0%, #0f172a 100%);
}

.settings-hint-text {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-top: -2px;
  margin-bottom: 4px;
}

.btn-active {
  border-color: var(--accent-cyan) !important;
  color: var(--accent-cyan) !important;
  background: rgba(6, 182, 212, 0.16) !important;
}

