/* ===== Diamond Game — Meditative Crystal Experience ===== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&family=Cinzel:wght@700;900&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Deep gem background */
  --bg:           #03050d;
  --bg-surface:   #080d1a;
  --bg-elevated:  #0f1629;

  /* Aurora accent triad */
  --aurora-violet: #6d28d9;
  --aurora-purple: #9333ea;
  --aurora-rose:   #db2777;
  --aurora-cyan:   #06b6d4;
  --aurora-teal:   #0d9488;
  --aurora-gold:   #d97706;

  /* Accent aliases (for existing references) */
  --accent:      #7c3aed;
  --accent-lt:   #a78bfa;
  --accent-glow: rgba(124,58,237,0.45);
  --cyan:        #06b6d4;
  --gold:        #fbbf24;
  --success:     #10b981;
  --danger:      #ef4444;

  /* Crystal glow tokens */
  --glow-violet: rgba(109,40,217,0.55);
  --glow-cyan:   rgba(6,182,212,0.45);
  --glow-rose:   rgba(219,39,119,0.4);
  --glow-gold:   rgba(217,119,6,0.5);

  /* Borders */
  --border:    rgba(255,255,255,0.05);
  --border-md: rgba(255,255,255,0.10);
  --border-lg: rgba(255,255,255,0.18);

  /* Text */
  --text:       #eef2ff;
  --text-dim:   #5d6f8a;
  --text-muted: #2e3a50;

  /* Layout */
  --radius:     16px;
  --radius-sm:  10px;
  --radius-pill:999px;
  --header-h:   58px;
  --palette-h:  92px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  overflow: hidden;
  touch-action: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===== Aurora Background ===== */

#aurora-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  width: 100%;
  height: 100%;
}

/* ===== App Container ===== */

#app {
  width: 100%;
  height: 100%;
  position: relative;
  z-index: 1;
}

/* ===== Screens ===== */

.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.screen.active {
  display: flex;
}

/* Directional entry animations */
.screen.entering-from-right {
  animation: slideFromRight 0.48s cubic-bezier(0.16,1,0.3,1) both;
}
.screen.entering-from-left {
  animation: slideFromLeft  0.48s cubic-bezier(0.16,1,0.3,1) both;
}
.screen.entering-scale {
  animation: scaleIn        0.52s cubic-bezier(0.34,1.56,0.64,1) both;
}

@keyframes slideFromRight {
  from { opacity: 0; transform: translateX(36px) scale(0.97); }
  to   { opacity: 1; transform: translateX(0)    scale(1); }
}
@keyframes slideFromLeft {
  from { opacity: 0; transform: translateX(-36px) scale(0.97); }
  to   { opacity: 1; transform: translateX(0)     scale(1); }
}
@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.86); filter: brightness(1.7); }
  to   { opacity: 1; transform: scale(1);    filter: brightness(1); }
}

/* ===== Start Screen ===== */

#screen-start {
  background: transparent; /* aurora shows through */
}

.start-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  padding: 44px 36px;
  position: relative;
  z-index: 1;
}

.game-logo {
  width: 82px;
  height: 82px;
  filter:
    drop-shadow(0 0 18px rgba(124,58,237,0.85))
    drop-shadow(0 0 40px rgba(6,182,212,0.3))
    drop-shadow(0 0 70px rgba(109,40,217,0.25));
  animation: logoGlow 4.2s ease-in-out infinite;
}

@keyframes logoGlow {
  0%, 100% {
    transform: translateY(0px) rotate(-1.5deg);
    filter: drop-shadow(0 0 18px rgba(124,58,237,0.85))
            drop-shadow(0 0 40px rgba(6,182,212,0.30))
            drop-shadow(0 0 70px rgba(109,40,217,0.25));
  }
  50% {
    transform: translateY(-11px) rotate(2deg);
    filter: drop-shadow(0 0 28px rgba(124,58,237,1.0))
            drop-shadow(0 0 55px rgba(6,182,212,0.50))
            drop-shadow(0 0 90px rgba(219,39,119,0.30));
  }
}

.game-title {
  font-family: 'Cinzel', 'Inter', serif;
  font-size: clamp(2rem, 8vw, 3.5rem);
  font-weight: 900;
  background: linear-gradient(
    135deg,
    #c4b5fd 0%,
    #a78bfa 25%,
    #67e8f9 55%,
    #fde68a 80%,
    #c4b5fd 100%
  );
  background-size: 200% 200%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-align: center;
  letter-spacing: 0.04em;
  line-height: 1.15;
  animation: titleShimmer 6s ease-in-out infinite;
}

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

.game-subtitle {
  color: var(--text-dim);
  font-size: 0.92rem;
  font-weight: 500;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  margin-top: -8px;
  text-align: center;
}

/* Decorative floating gems */
.start-gems {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.gem {
  position: absolute;
  animation: gemDrift var(--d, 6s) ease-in-out infinite;
  animation-delay: var(--delay, 0s);
  filter: drop-shadow(0 0 8px currentColor);
}

@keyframes gemDrift {
  0%, 100% { transform: translateY(0) rotate(0deg)   scale(1); }
  33%       { transform: translateY(-14px) rotate(8deg)  scale(1.05); }
  66%       { transform: translateY(-6px)  rotate(-5deg) scale(0.96); }
}

/* ===== Buttons ===== */

.btn {
  padding: 15px 38px;
  border: none;
  border-radius: var(--radius-pill);
  font-size: 1rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.22s ease, opacity 0.12s;
  min-width: 214px;
  text-align: center;
  letter-spacing: 0.04em;
}

.btn:hover  { transform: translateY(-3px); }
.btn:active { transform: scale(0.94) translateY(0); opacity: 0.88; }

.btn-primary {
  background: linear-gradient(135deg, #5b21b6 0%, #7c3aed 45%, #9333ea 75%, #06b6d4 100%);
  background-size: 200% 200%;
  color: #fff;
  box-shadow:
    0 4px 24px rgba(124,58,237,0.55),
    0 0 0 1px rgba(167,139,250,0.20),
    inset 0 1px 0 rgba(255,255,255,0.22);
  animation: btnPulse 4s ease-in-out infinite;
}
@keyframes btnPulse {
  0%, 100% { background-position: 0% 50%; }
  50%       { background-position: 100% 50%; }
}
.btn-primary:hover {
  box-shadow:
    0 8px 36px rgba(124,58,237,0.70),
    0 0 0 1px rgba(167,139,250,0.35),
    inset 0 1px 0 rgba(255,255,255,0.22);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border-md);
  box-shadow: 0 2px 12px rgba(0,0,0,0.40);
}
.btn-secondary:hover {
  border-color: rgba(167,139,250,0.35);
  box-shadow: 0 4px 20px rgba(0,0,0,0.50), 0 0 0 1px rgba(167,139,250,0.15);
}

.btn-back {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s;
}
.btn-back:hover { background: var(--border); color: var(--text); }

.btn-icon {
  background: transparent;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
  line-height: 1;
}
.btn-icon:hover { background: var(--border); }

/* ===== Category Select Screen ===== */

#screen-categories { justify-content: flex-start; }

.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
  padding: 20px 18px;
  overflow-y: auto;
  width: 100%;
  max-width: 600px;
  align-self: center;
}

.cat-card {
  background: linear-gradient(145deg, #0c1224, #101829);
  border: 1px solid rgba(109,40,217,0.22);
  border-radius: 16px;
  padding: 20px 14px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
  text-align: center;
}
.cat-card:hover {
  transform: translateY(-4px);
  border-color: rgba(109,40,217,0.55);
  box-shadow: 0 8px 24px rgba(109,40,217,0.2);
}
.cat-icon { font-size: 2.2rem; line-height: 1; }
.cat-name { font-size: 0.92rem; font-weight: 700; color: #e2e8f0; }
.cat-progress { font-size: 0.72rem; color: #8b949e; }
.cat-bar { width: 100%; height: 3px; background: rgba(255,255,255,0.08); border-radius: 2px; margin-top: 2px; }
.cat-bar-fill { height: 100%; background: #7c3aed; border-radius: 2px; transition: width 0.4s; }

/* ===== Gallery Screen ===== */

#screen-gallery { justify-content: flex-start; }

.gallery-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 20px 18px;
  overflow-y: auto;
  width: 100%;
  justify-content: center;
  align-self: center;
}
.gallery-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: transform 0.22s cubic-bezier(.34,1.56,.64,1);
}
.gallery-item:hover { transform: scale(1.06); }
.gallery-name {
  font-size: 0.78rem;
  color: #94a3b8;
  text-align: center;
  max-width: 140px;
}
.gallery-empty {
  text-align: center;
  color: #8b949e;
  font-size: 0.95rem;
  padding: 60px 20px;
}

/* ===== Level Select Screen ===== */

#screen-select { justify-content: flex-start; }

.screen-header {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: rgba(8,13,26,0.85);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border-bottom: 1px solid var(--border);
  height: var(--header-h);
  flex-shrink: 0;
}

.screen-header h2 {
  font-family: 'Cinzel', serif;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  background: linear-gradient(135deg, #c4b5fd 0%, #a78bfa 35%, #67e8f9 75%, #fde68a 100%);
  background-size: 200% 200%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: titleShimmer 6s ease-in-out infinite;
}

.level-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  padding: 20px 18px;
  overflow-y: auto;
  width: 100%;
  justify-content: center;
  align-self: center;
  scrollbar-width: thin;
  scrollbar-color: var(--border-md) transparent;
}
.level-grid::-webkit-scrollbar { width: 4px; }
.level-grid::-webkit-scrollbar-thumb { background: var(--border-md); border-radius: 2px; }

.level-card {
  background: linear-gradient(145deg, #0c1224, #101829);
  border-radius: var(--radius);
  padding: 14px 12px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: border-color 0.25s, transform 0.25s cubic-bezier(.34,1.56,.64,1), box-shadow 0.25s;
  user-select: none;
  position: relative;
  overflow: hidden;
}

.level-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(109,40,217,0.10), rgba(6,182,212,0.06));
  opacity: 0;
  transition: opacity 0.25s;
}

.level-card:hover {
  border-color: rgba(109,40,217,0.55);
  transform: translateY(-5px);
  box-shadow:
    0 14px 35px rgba(0,0,0,0.55),
    0 0 0 1px rgba(109,40,217,0.25),
    0 0 30px rgba(109,40,217,0.12);
}
.level-card:hover::before { opacity: 1; }
.level-card:not(.locked):active {
  transform: scale(0.93) translateY(0);
  transition: transform 0.08s ease;
}

.level-card.locked {
  opacity: 0.50;
  cursor: not-allowed;
  filter: grayscale(0.3);
}
.level-card.locked:hover { transform: none; box-shadow: none; border-color: var(--border); }

.level-card.completed { border-color: rgba(16,185,129,0.32); }
.level-card.completed::after {
  content: '';
  position: absolute;
  top: 10px;
  right: 10px;
  width: 18px;
  height: 18px;
  background: var(--success) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2 6l3 3 5-5' stroke='white' stroke-width='1.8' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/10px no-repeat;
  border-radius: 50%;
  box-shadow: 0 0 10px rgba(16,185,129,0.6);
}

.level-preview {
  width: 110px;
  height: 110px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow:
    0 2px 12px rgba(0,0,0,0.6),
    0 0 0 1px rgba(255,255,255,0.04);
  flex-shrink: 0;
}
.level-preview canvas { width: 100%; height: 100%; }

.level-name {
  font-size: 0.88rem;
  font-weight: 700;
  text-align: center;
  color: var(--text);
  letter-spacing: 0.03em;
}

.level-meta {
  font-size: 0.70rem;
  color: var(--text-dim);
  font-weight: 500;
}

.level-stars { font-size: 0.9rem; letter-spacing: 3px; }

/* ===== Game Screen ===== */

#screen-game {
  justify-content: flex-start;
  align-items: stretch;
}

#game-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  background: rgba(8,13,26,0.90);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border-bottom: 1px solid var(--border);
  height: var(--header-h);
  flex-shrink: 0;
}

#progress-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
}

#progress-bar {
  flex: 1;
  height: 7px;
  background: rgba(255,255,255,0.06);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

#progress-fill {
  height: 100%;
  background: linear-gradient(90deg,
    #6d28d9, #9333ea 20%,
    #06b6d4 45%, #0d9488 60%,
    #9333ea 80%, #6d28d9
  );
  background-size: 400% 100%;
  border-radius: var(--radius-pill);
  width: 0%;
  transition: width 0.45s cubic-bezier(.4,0,.2,1);
  animation: auroraShimmer 5s linear infinite;
}

@keyframes auroraShimmer {
  0%   { background-position: 100% center; }
  100% { background-position: -300% center; }
}

@keyframes progressPulse {
  0%   { filter: brightness(1); }
  30%  { filter: brightness(2.5) drop-shadow(0 0 10px rgba(139,92,246,1)); }
  100% { filter: brightness(1); }
}

#progress-fill.progress-pulse {
  animation: auroraShimmer 5s linear infinite, progressPulse 0.55s ease-out;
}

#progress-text {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--text-dim);
  min-width: 34px;
  text-align: right;
  letter-spacing: 0.03em;
}

#canvas-wrap {
  flex: 1;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: crosshair;
  background: transparent;
}

#game-canvas { display: block; touch-action: none; }

/* ===== Palette Tray ===== */

#palette-tray {
  height: auto;
  min-height: var(--palette-h);
  max-height: 160px;
  background: rgba(8,13,26,0.95);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  flex-shrink: 0;
}

#palette-colors {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px 2px;
  max-width: 100%;
  justify-content: center;
  align-items: center;
}

.palette-swatch {
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  border-radius: 10px;
  border: 2px solid rgba(255,255,255,0.08);
  cursor: pointer;
  transition: transform 0.18s cubic-bezier(.34,1.56,.64,1), border-color 0.15s, box-shadow 0.18s;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 800;
  color: #000;
  text-shadow: 0 1px 2px rgba(0,0,0,0.6), 0 0 4px rgba(255,255,255,0.4);
  user-select: none;
  position: relative;
  /* Subtle 3D gem tilt */
  perspective: 120px;
  transform-style: preserve-3d;
}

.palette-swatch:hover {
  transform: scale(1.09) translateY(-3px) rotateX(5deg);
}
.palette-swatch:active { transform: scale(0.88); }

.palette-swatch.selected {
  border-color: rgba(255,255,255,0.95);
  transform: scale(1.32) translateY(-7px) rotateX(6deg);
  box-shadow:
    0 12px 32px rgba(0,0,0,0.65),
    0 0 0 2px rgba(255,255,255,0.65),
    0 0 30px rgba(255,255,255,0.45),
    0 0 60px rgba(255,255,255,0.15);
  z-index: 2;
}

/* ===== Complete Screen ===== */

#screen-complete {
  background: transparent; /* aurora shows through */
}

.complete-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  padding: 36px 32px;
  text-align: center;
  max-width: 420px;
  width: 100%;
}


#complete-image-wrap canvas {
  border-radius: var(--radius);
  box-shadow:
    0 12px 50px rgba(124,58,237,0.50),
    0 0 0 1px rgba(255,255,255,0.07),
    0 0 80px rgba(109,40,217,0.20);
  max-width: min(240px, 75vw);
  max-height: min(240px, 35vh);
}

.star-rating {
  font-size: 2.6rem;
  letter-spacing: 10px;
  filter:
    drop-shadow(0 0 12px rgba(251,191,36,0.80))
    drop-shadow(0 0 30px rgba(251,191,36,0.35));
}

.star-rating span {
  display: inline-block;
  animation: starPop 0.55s cubic-bezier(.34,1.56,.64,1) both;
}
.star-rating span:nth-child(2) { animation-delay: 0.12s; }
.star-rating span:nth-child(3) { animation-delay: 0.24s; }

@keyframes starPop {
  from { transform: scale(0.2) rotate(-18deg); opacity: 0; }
  to   { transform: scale(1)   rotate(0deg);  opacity: 1; }
}

#complete-score {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 0.04em;
}

/* ===== Burger Button ===== */

.btn-burger {
  position: fixed;
  top: 10px;
  right: 12px;
  z-index: 300;
  width: 42px;
  height: 42px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  background: rgba(8,13,26,0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-md);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.18s, border-color 0.2s, transform 0.15s;
  /* Hidden on start screen via JS class on body */
}
.burger-line {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--text-dim);
  border-radius: 2px;
  transition: background 0.18s, transform 0.28s cubic-bezier(.34,1.56,.64,1), opacity 0.18s;
}
.btn-burger:hover {
  background: rgba(109,40,217,0.18);
  border-color: rgba(109,40,217,0.45);
  transform: scale(1.05);
}
.btn-burger:hover .burger-line { background: var(--text); }

/* X state when drawer open */
.btn-burger.open .burger-line:nth-child(1) { transform: translateY(7px) rotate(45deg); background: var(--accent-lt); }
.btn-burger.open .burger-line:nth-child(2) { opacity: 0; transform: scaleX(0); }
.btn-burger.open .burger-line:nth-child(3) { transform: translateY(-7px) rotate(-45deg); background: var(--accent-lt); }

/* Hide burger on start screen */
body.screen-start .btn-burger { opacity: 0; pointer-events: none; }

/* ===== Nav Backdrop ===== */

.nav-backdrop {
  position: fixed;
  inset: 0;
  z-index: 290;
  background: rgba(0,0,0,0.58);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
.nav-backdrop.visible {
  opacity: 1;
  pointer-events: auto;
}

/* ===== Nav Drawer ===== */

.nav-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 240px;
  height: 100%;
  z-index: 295;
  background: linear-gradient(180deg, #0c1428 0%, #080f1e 100%);
  border-left: 1px solid var(--border-md);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.34s cubic-bezier(0.16,1,0.3,1);
  box-shadow: -12px 0 50px rgba(0,0,0,0.6);
}
.nav-drawer.open {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 22px 18px 16px;
}

.drawer-gem {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  filter: drop-shadow(0 0 8px rgba(124,58,237,0.8));
}

.drawer-title {
  font-family: 'Cinzel', serif;
  font-size: 0.88rem;
  font-weight: 700;
  background: linear-gradient(135deg, #c4b5fd, #67e8f9);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.drawer-divider {
  height: 1px;
  background: var(--border);
  margin: 0 14px 8px;
}

.drawer-sub-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 14px;
}

.drawer-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 4px 10px;
  gap: 2px;
  overflow-y: auto;
}

.drawer-nav-item {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 13px 14px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius-sm);
  letter-spacing: 0.02em;
  transition: background 0.15s, color 0.15s, transform 0.15s;
  text-align: left;
  width: 100%;
}
.drawer-nav-item:hover {
  background: rgba(109,40,217,0.14);
  color: var(--text);
  transform: translateX(3px);
}
.drawer-nav-item:active { transform: scale(0.96); }

.dnav-icon {
  font-size: 1rem;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
  opacity: 0.8;
}

.drawer-footer {
  padding: 14px 18px 20px;
  border-top: 1px solid var(--border);
}
.drawer-version {
  font-size: 0.70rem;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ===== Complete Screen — floating title ===== */

.screen-floating-title {
  font-family: 'Cinzel', serif;
  font-size: 1.6rem;
  font-weight: 900;
  background: linear-gradient(135deg, #fff 10%, #c4b5fd 40%, #67e8f9 70%, #fde68a 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 0.05em;
  text-align: center;
}

/* ===== Start Screen — Secondary Menu Row ===== */

.start-menu-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: -6px;
  width: 100%;
  align-items: center;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border-md);
  color: var(--text-dim);
  font-size: 1rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  padding: 15px 38px;
  min-width: 214px;
  border-radius: var(--radius-pill);
  transition: background 0.15s, border-color 0.2s, color 0.15s, transform 0.18s;
  letter-spacing: 0.04em;
  text-align: center;
}
.btn-ghost:hover {
  background: rgba(255,255,255,0.05);
  border-color: rgba(167,139,250,0.40);
  color: var(--text);
  transform: translateY(-3px);
  box-shadow: 0 4px 20px rgba(0,0,0,0.40), 0 0 0 1px rgba(167,139,250,0.10);
}
.btn-ghost:active { transform: scale(0.94) translateY(0); opacity: 0.88; }

/* ===== Settings Screen ===== */

#screen-settings { justify-content: flex-start; }

.settings-content {
  width: 100%;
  max-width: 480px;
  align-self: center;
  overflow-y: auto;
  padding: 18px 18px 40px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-md) transparent;
}
.settings-content::-webkit-scrollbar { width: 4px; }
.settings-content::-webkit-scrollbar-thumb { background: var(--border-md); border-radius: 2px; }

.settings-card {
  background: linear-gradient(145deg, #0c1224, #101829);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 0;
  overflow: hidden;
}

.settings-card--danger {
  background: transparent;
  border: none;
  padding: 0;
  display: flex;
  justify-content: center;
}

.settings-section-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 12px 18px 8px;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  gap: 12px;
  cursor: default;
}

.setting-row-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.setting-icon {
  font-size: 1.15rem;
  line-height: 1;
  opacity: 0.85;
}

.setting-label {
  font-size: 0.96rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.02em;
}

.setting-divider {
  height: 1px;
  background: var(--border);
  margin: 0 18px;
}

/* Toggle Switch — iOS style */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 30px;
  cursor: pointer;
  flex-shrink: 0;
}
.toggle-switch input { display: none; }

.toggle-track {
  position: absolute;
  inset: 0;
  border-radius: 15px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-md);
  transition: background 0.28s, border-color 0.28s;
}
.toggle-track::after {
  content: '';
  position: absolute;
  width: 24px;
  height: 24px;
  top: 2px;
  left: 2px;
  border-radius: 50%;
  background: var(--text-dim);
  box-shadow: 0 2px 6px rgba(0,0,0,0.5);
  transition: transform 0.28s cubic-bezier(.34,1.56,.64,1), background 0.28s;
}
.toggle-switch input:checked + .toggle-track {
  background: linear-gradient(135deg, #6d28d9, #06b6d4);
  border-color: rgba(109,40,217,0.45);
}
.toggle-switch input:checked + .toggle-track::after {
  transform: translateX(22px);
  background: #fff;
}

/* Volume Slider */
.setting-row--slider {
  padding: 6px 18px 12px;
  gap: 14px;
}

.setting-label--dim {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  flex-shrink: 0;
}

.volume-slider {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-md);
  outline: none;
  cursor: pointer;
}

.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6d28d9, #06b6d4);
  box-shadow: 0 2px 6px rgba(0,0,0,0.5);
  cursor: pointer;
  transition: transform 0.15s;
}

.volume-slider::-webkit-slider-thumb:active {
  transform: scale(1.2);
}

.volume-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #6d28d9, #06b6d4);
  box-shadow: 0 2px 6px rgba(0,0,0,0.5);
  cursor: pointer;
}

/* Language Grid */
.language-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 4px 14px 14px;
}

.lang-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 6px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s, transform 0.18s cubic-bezier(.34,1.56,.64,1);
  font-family: inherit;
}
.lang-btn:hover {
  background: rgba(109,40,217,0.12);
  border-color: rgba(109,40,217,0.40);
  transform: translateY(-2px);
}
.lang-btn:active { transform: scale(0.92); }
.lang-btn.active {
  background: linear-gradient(135deg, rgba(109,40,217,0.22), rgba(6,182,212,0.12));
  border-color: rgba(109,40,217,0.65);
  box-shadow: 0 0 0 1px rgba(167,139,250,0.25), 0 4px 14px rgba(109,40,217,0.20);
}

.lang-flag {
  font-size: 1.5rem;
  line-height: 1;
}
.lang-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.lang-btn.active .lang-label { color: var(--accent-lt); }

/* Danger button */
.btn-danger {
  background: rgba(239,68,68,0.12);
  color: #fca5a5;
  border: 1px solid rgba(239,68,68,0.25);
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  padding: 13px 32px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s, transform 0.15s;
  letter-spacing: 0.03em;
}
.btn-danger:hover {
  background: rgba(239,68,68,0.22);
  border-color: rgba(239,68,68,0.50);
  transform: translateY(-2px);
}
.btn-danger:active { transform: scale(0.94); }

/* ===== About Screen ===== */

#screen-about { justify-content: flex-start; }

.about-content {
  width: 100%;
  max-width: 480px;
  align-self: center;
  overflow-y: auto;
  padding: 20px 18px 48px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-md) transparent;
}
.about-content::-webkit-scrollbar { width: 4px; }
.about-content::-webkit-scrollbar-thumb { background: var(--border-md); border-radius: 2px; }

.about-logo-wrap {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 16px 4px 6px;
}

.about-logo {
  width: 52px;
  height: 52px;
  flex-shrink: 0;
  filter:
    drop-shadow(0 0 10px rgba(124,58,237,0.80))
    drop-shadow(0 0 24px rgba(6,182,212,0.30));
  animation: logoGlow 4.2s ease-in-out infinite;
}

.about-logo-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.about-game-name {
  font-family: 'Cinzel', serif;
  font-size: 1.25rem;
  font-weight: 900;
  background: linear-gradient(135deg, #c4b5fd, #67e8f9);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 0.04em;
}

.about-tagline {
  font-size: 0.78rem;
  color: var(--text-dim);
  font-weight: 500;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.about-card {
  background: linear-gradient(145deg, #0c1224, #101829);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}

.about-desc {
  font-size: 0.92rem;
  line-height: 1.65;
  color: var(--text-dim);
  font-weight: 500;
}

.about-section-title {
  font-size: 0.80rem;
  font-weight: 700;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--accent-lt);
  margin-bottom: 14px;
}

.about-controls-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 11px;
}
.about-controls-list li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 0.88rem;
  color: var(--text-dim);
  font-weight: 500;
  line-height: 1.45;
}

.about-ctrl-icon {
  font-size: 1.05rem;
  flex-shrink: 0;
  margin-top: 1px;
}

.about-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 0 2px;
}

.about-version {
  font-size: 0.75rem;
  font-weight: 700;
  color: rgba(167,139,250,0.65);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ===== Gallery Lightbox ===== */

.lightbox-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 400;
  background: rgba(3,5,13,0.93);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 20px;
}
.lightbox-overlay.active {
  display: flex;
  animation: fadeIn 0.28s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.94); }
  to   { opacity: 1; transform: scale(1); }
}
.lightbox-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}
#lightbox-canvas {
  border-radius: 14px;
  box-shadow:
    0 0 60px rgba(124,58,237,0.55),
    0 0 120px rgba(109,40,217,0.22),
    0 0 0 1px rgba(255,255,255,0.08);
}
.lightbox-name {
  font-family: 'Cinzel', serif;
  font-size: 1.15rem;
  font-weight: 700;
  background: linear-gradient(135deg, #c4b5fd, #67e8f9);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-align: center;
  letter-spacing: 0.07em;
}
.lightbox-close {
  position: absolute;
  top: 18px;
  right: 18px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.16);
  color: var(--text-dim);
  font-size: 1.1rem;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  transition: background 0.15s, color 0.15s, transform 0.15s;
}
.lightbox-close:hover {
  background: rgba(255,255,255,0.14);
  color: var(--text);
  transform: scale(1.12);
}

/* ===== Utility ===== */
.hidden { display: none !important; }

/* ===== Responsive ===== */
@media (max-width: 400px) {
  .palette-swatch { width: 46px; height: 46px; }
  .btn { min-width: 172px; padding: 12px 24px; font-size: 0.95rem; }
  .level-grid { gap: 12px; padding: 14px; }
  .level-preview { width: 96px; height: 96px; }
  .language-grid { grid-template-columns: repeat(2, 1fr); }
  .btn-ghost { min-width: 172px; padding: 12px 24px; font-size: 0.95rem; }
}
