/* ==========================================================================
   DESKTOP STAGE WRAPPER WITH TIGHTENED SPACING
   ========================================================================== */
.game-stage-outer {
  width: 100%;
  max-width: 1040px;
  margin: 18px auto 8px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  box-sizing: border-box;
}

/* Desktop Floating Left Graphics */
.desktop-decor {
  position: absolute;
  top: 30px;
  z-index: 5;
  pointer-events: none;
  display: none;
}

.desktop-decor-left {
  left: 0;
  width: 220px;
  height: 490px;
}

@media (min-width: 1025px) {
  .desktop-decor { display: block; }
}

.floating-text {
  font-family: 'Comic Sans MS', 'Plus Jakarta Sans', cursive, sans-serif;
  font-size: 1.95rem;
  font-weight: 900;
  color: #3b82f6;
  transform: rotate(-8deg);
  text-shadow: 2px 2px 0 #fff;
  line-height: 1.1;
  position: absolute;
  top: 10px;
  left: 0;
}

/* Clean, Non-Animated Tagline Directly Below "Small Move Big Brain!" */
.desktop-subtagline {
  font-family: var(--font-main);
  font-size: 0.98rem;
  font-weight: 800;
  color: #475569;
  letter-spacing: 0.05em;
  position: absolute;
  top: 86px;
  left: 4px;
  transform: rotate(-8deg);
  text-shadow: 1px 1px 0 #fff;
  user-select: none;
}

[data-theme="dark"] .desktop-subtagline {
  color: #94a3b8;
  text-shadow: none;
}

.desktop-girl {
  width: 195px;
  height: auto;
  position: absolute;
  bottom: 0;
  left: 0;
  filter: drop-shadow(0 15px 25px rgba(0, 0, 0, 0.22));
}

.floating-brain {
  font-size: 2.8rem;
  position: absolute;
  top: 115px;
  left: 155px;
  animation: floatAnim 3s ease-in-out infinite;
}

/* ==========================================================================
   ANIMATED QUESTION MARK (POSITIONED DIRECTLY TO THE LEFT OF THE GIRL)
   ========================================================================== */
.floating-question {
  font-size: 4.6rem;
  color: #f59e0b;
  position: absolute;
  bottom: 150px;
  left: -22px; /* Placed directly in the red-marked area to the left of the girl */
  font-weight: 900;
  text-shadow: 2px 2px 0 #ffffff;
  animation: questionWobbleLeft 3s ease-in-out infinite;
  user-select: none;
}

@keyframes questionWobbleLeft {
  0%, 100% { transform: translateY(0) rotate(-10deg); }
  50% { transform: translateY(-10px) rotate(8deg); }
}

@keyframes floatAnim {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}

/* ==========================================================================
   MAIN GAME CARD (EXPANDED TO 800PX & POSITIONED WITH ZERO DEAD GAP)
   ========================================================================== */
.main-game-card {
  width: 100%;
  max-width: 800px;
  margin-left: 240px; /* Perfectly clears the 220px left column */
  margin-right: 0;
  background: var(--bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 28px;
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.07);
  padding: 18px 26px 22px;
  box-sizing: border-box;
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
}

[data-theme="dark"] .main-game-card {
  background: #1e293b;
  border-color: #334155;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5);
}

/* 3x2 HUD DASHBOARD */
.game-hud-wrapper {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
  width: 100%;
  box-sizing: border-box;
}

.hud-row {
  display: grid;
  grid-template-columns: 1.25fr 1fr 1fr;
  gap: 10px;
  width: 100%;
  box-sizing: border-box;
}

.hud-pill {
  background: var(--bg-surface);
  border-radius: 12px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.04);
  border: 1px solid var(--border-color);
  font-size: 0.88rem;
  font-weight: 800;
  white-space: nowrap;
  min-width: 0;
  overflow: hidden;
  box-sizing: border-box;
}

/* Interactive Level Pill (Tap to select level) */
#level-selector-trigger {
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  user-select: none;
}

#level-selector-trigger:hover {
  transform: translateY(-2px);
  border-color: #f59e0b;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.25);
}

.hud-edit-hint {
  font-size: 0.65rem;
  color: var(--accent-gold);
  margin-left: -2px;
  opacity: 0.8;
}

[data-theme="dark"] .hud-pill {
  background: #0f172a;
}

.hud-icon { font-size: 1.05rem; flex-shrink: 0; }
.hud-label { color: var(--text-muted); flex-shrink: 0; }
.hud-sub { color: var(--text-subtle); font-size: 0.78rem; flex-shrink: 0; }

.desktop-diff-label { display: inline; }
.mobile-diff-label { display: none; }

.hud-val-box {
  border-radius: 6px;
  padding: 2px 7px;
  font-family: var(--font-mono);
  font-weight: 900;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bg-dark { background: #0f172a; color: #fff; }
.bg-light { background: #f1f5f9; color: #0f172a; border: 1px solid #cbd5e1; }
[data-theme="dark"] .bg-light { background: #334155; color: #f8fafc; border-color: #475569; }

.hud-val-text { font-family: var(--font-mono); font-weight: 900; font-size: 1.02rem; }
.orange-glow { color: #ea580c; text-shadow: 0 0 8px rgba(234, 88, 12, 0.3); }
.red { color: #dc2626; }
.black { color: var(--text-main); }

/* ==========================================================================
   FIXED PUZZLE BOX
   ========================================================================== */
.fixed-puzzle-card {
  width: 100%;
  height: 250px;
  background-color: #0f172a;
  background-image: 
    radial-gradient(circle at center, #1e293b 0%, #0f172a 100%),
    linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 100% 100%, 25px 25px, 25px 25px;
  border-radius: 22px;
  border: 4px solid #1e293b;
  box-shadow: 
    0 0 0 3px #eab308, 
    0 8px 30px rgba(234, 179, 8, 0.35),
    inset 0 0 30px rgba(0, 0, 0, 0.9);
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 10px 14px;
  margin-bottom: 16px;
  box-sizing: border-box;
}

.puzzle-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 28px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fde047' stroke-width='4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='15 18 9 12 15 6'%3E%3C/polyline%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  filter: drop-shadow(0 0 8px #eab308);
}

.puzzle-arrow.left { left: -26px; }
.puzzle-arrow.right { right: -26px; transform: translateY(-50%) rotate(180deg); }

.puzzle-equation-viewport {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

svg#equation-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
  touch-action: none;
}

/* YELLOW BRUSH CALLOUT */
.callout-wrapper {
  text-align: center;
  margin-top: -30px;
  position: relative;
  z-index: 6;
}

.callout-brush-bg {
  display: inline-block;
  background: #fde047;
  padding: 7px 22px;
  border-radius: 4px 16px 4px 16px / 16px 4px 16px 4px;
  transform: rotate(-1.5deg);
  box-shadow: 0 6px 15px rgba(253, 224, 71, 0.4);
}

#callout-instruction {
  font-size: 1.1rem;
  font-weight: 800;
  color: #000;
  font-style: italic;
}

#callout-instruction strong {
  color: #dc2626;
  font-weight: 900;
}

/* PINK TIMER PILL */
.timer-section-row {
  display: flex;
  justify-content: center;
  margin: 14px 0 16px;
}

.timer-pill {
  background: var(--bg-surface);
  border: 3px solid #f43f5e;
  border-radius: 9999px;
  padding: 5px 24px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 0 0 5px rgba(244, 63, 94, 0.12);
}

.timer-pill svg { color: #f43f5e; }

#level-timer {
  font-family: var(--font-mono);
  font-size: 1.3rem;
  font-weight: 900;
  color: var(--text-main);
}

.timer-pill.tense { border-color: #ef4444; animation: timerTension 1s infinite alternate; }
.timer-pill.overtime { border-color: #d97706; box-shadow: 0 0 0 5px rgba(217, 119, 6, 0.1); }
@keyframes timerTension { to { transform: scale(1.05); } }

/* 3D ACTION BUTTONS (UNDO / RESET / HINT) */
.controls-panel {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  width: 100%;
}

.btn-3d {
  border-radius: 9999px;
  font-size: 1rem;
  font-weight: 800;
  color: #fff;
  border: none;
  padding: 11px 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  position: relative;
  top: 0;
  transition: all 0.1s ease;
  user-select: none;
}

.btn-3d:active:not(:disabled) {
  top: 4px;
  box-shadow: 0 0 0 rgba(0, 0, 0, 0) !important;
}

.btn-3d:disabled {
  filter: grayscale(1);
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-blue {
  background: linear-gradient(180deg, #60a5fa, #2563eb);
  box-shadow: 0 5px 0 #1e40af, 0 8px 18px rgba(37, 99, 235, 0.35);
}

.btn-slate {
  background: linear-gradient(180deg, #94a3b8, #475569);
  box-shadow: 0 5px 0 #334155, 0 8px 18px rgba(100, 116, 139, 0.35);
}

.btn-orange {
  background: linear-gradient(180deg, #fbbf24, #d97706);
  box-shadow: 0 5px 0 #b45309, 0 8px 18px rgba(245, 158, 11, 0.35);
}

/* MATCHSTICK SVG INTERACTION */
.segment-group { cursor: pointer; }
.match-shaft, .match-head-group { transition: transform 0.12s; }
.segment-group.is-held .match-shaft,
.segment-group.is-held .match-head-group { transform: scale(1.1) translate(-2px, -6px); }

.ghost-slot {
  opacity: 0;
  visibility: hidden;
  stroke: rgba(255, 255, 255, 0.2);
  stroke-width: 2;
  stroke-dasharray: 6, 4;
  fill: rgba(255, 255, 255, 0.05);
  rx: 4;
  pointer-events: none;
}

.is-holding-stick .ghost-slot {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  stroke: #fbbf24;
  fill: rgba(251, 191, 36, 0.2);
  animation: ghostPulse 1.5s infinite;
  cursor: pointer;
}

@keyframes ghostPulse {
  50% { fill: rgba(251, 191, 36, 0.4); stroke: #f59e0b; }
}

.hint-source { animation: hintGlow 1s infinite; }
@keyframes hintGlow { 50% { filter: drop-shadow(0 0 15px #f59e0b); } }

.hitbox { fill: transparent; cursor: pointer; }

.shake-board {
  animation: gentleShake 0.44s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes gentleShake {
  10%, 90% { transform: translate3d(-3px, 0, 0); }
  20%, 80% { transform: translate3d(4px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-5px, 0, 0); }
  40%, 60% { transform: translate3d(5px, 0, 0); }
}

/* DESKTOP MINI FOOTER */
.desktop-mini-footer {
  text-align: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-subtle);
  margin-top: 14px;
  display: none;
}

@media (min-width: 1025px) {
  .desktop-mini-footer { display: block; }
}

/* ==========================================================================
   LEVEL SELECTOR MODAL STYLING
   ========================================================================== */
.level-modal-window {
  max-width: 440px;
}

.modal-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 16px;
  line-height: 1.4;
}

.level-input-wrap {
  width: 100%;
  margin-bottom: 14px;
}

.level-input-wrap input {
  width: 100%;
  font-family: var(--font-mono);
  font-size: 1.4rem;
  font-weight: 900;
  text-align: center;
  padding: 10px 16px;
  border-radius: 14px;
  border: 2px solid var(--border-color);
  background: var(--bg-subtle);
  color: var(--text-main);
  box-sizing: border-box;
  outline: none;
  transition: all 0.2s ease;
}

.level-input-wrap input:focus {
  border-color: #3b82f6;
  background: var(--bg-surface);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
}

.level-chips-container {
  width: 100%;
  margin-bottom: 18px;
  text-align: left;
}

.chips-label {
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--text-subtle);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: block;
  margin-bottom: 8px;
}

.chips-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.level-chip-btn {
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 800;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.15s ease;
}

.level-chip-btn:hover {
  background: #3b82f6;
  color: #ffffff;
  border-color: #2563eb;
  transform: translateY(-1px);
}

.modal-actions-row {
  display: flex;
  gap: 10px;
  width: 100%;
}

.modal-actions-row .btn-action {
  flex: 1;
  justify-content: center;
  font-size: 0.95rem;
  padding: 10px 16px;
}

/* CELEBRATION MODAL */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 16, 0.74);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 120;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  padding: 16px 12px;
  box-sizing: border-box;
}

.modal-overlay.open { opacity: 1; pointer-events: auto; }

.modal-window {
  background: var(--bg-surface);
  border: 1.5px solid var(--border-color);
  border-radius: 28px;
  max-width: 400px;
  width: 100%;
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 20px 16px 16px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  transform: scale(0.92) translateY(14px);
  transition: transform 0.28s cubic-bezier(0.18, 0.89, 0.32, 1.28);
  box-sizing: border-box;
  margin: auto;
}

.modal-overlay.open .modal-window { transform: scale(1) translateY(0); }

.modal-header-icon { font-size: 2.3rem; margin-bottom: 2px; }
.modal-title { font-size: 1.55rem; font-weight: 900; color: var(--text-main); letter-spacing: -0.03em; margin-bottom: 2px; }
.modal-solved-eq { font-size: 1.05rem; font-weight: 800; color: var(--accent-red); margin-bottom: 8px; font-family: var(--font-mono); }
.modal-diff-line { font-size: 0.76rem; font-weight: 700; color: var(--text-muted); margin: -4px 0 10px; }

.modal-stats-card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  background: rgba(0, 0, 0, 0.03);
  border-radius: 14px;
  padding: 8px 6px;
  margin-bottom: 10px;
}

.modal-stat-box { display: flex; flex-direction: column; align-items: center; justify-content: center; }
.modal-stat-box span:first-child { font-size: 0.65rem; font-weight: 700; text-transform: uppercase; color: var(--text-muted); }
.modal-stat-box span:last-child { font-size: 1.02rem; font-weight: 900; color: var(--text-main); }

.modal-rank-banner {
  background: linear-gradient(135deg, rgba(234, 179, 8, 0.15), rgba(217, 119, 6, 0.15));
  border: 1.5px solid rgba(217, 119, 6, 0.4);
  border-radius: 12px;
  padding: 7px 12px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-rank-text { font-size: 0.84rem; font-weight: 800; color: var(--text-main); }
.modal-rank-val { font-size: 1.1rem; font-weight: 900; color: #b45309; font-family: var(--font-mono); }

.modal-quote-box {
  background: rgba(239, 68, 68, 0.06);
  border-left: 3px solid var(--accent-red);
  padding: 7px 10px;
  border-radius: 6px;
  margin-bottom: 12px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-main);
  text-align: left;
  font-style: italic;
}

.social-share-box {
  background: rgba(0, 0, 0, 0.02);
  border: 1px dashed var(--border-color);
  border-radius: 12px;
  padding: 8px;
  margin-bottom: 12px;
  text-align: center;
}

.social-share-title { font-size: 0.8rem; font-weight: 800; color: var(--text-main); margin-bottom: 2px; }
.social-share-sub { font-size: 0.7rem; color: var(--text-muted); margin-bottom: 6px; }

.share-buttons-row { display: flex; align-items: center; justify-content: center; gap: 5px; flex-wrap: wrap; }
.btn-share { font-size: 0.74rem; font-weight: 700; padding: 4px 10px; border-radius: 9999px; display: inline-flex; align-items: center; gap: 4px; color: #ffffff; }
.btn-share-wa { background: #25D366; }
.btn-share-x { background: #111111; }
.btn-share-fb { background: #1877F2; }
.btn-share-copy { background: #475569; }

#toast-banner {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #0f172a;
  color: #ffffff;
  padding: 9px 18px;
  border-radius: 9999px;
  font-size: 0.84rem;
  font-weight: 700;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
  z-index: 150;
  pointer-events: none;
  transition: transform 0.25s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

#toast-banner.show { transform: translateX(-50%) translateY(0); }
#confetti-canvas { position: fixed; inset: 0; pointer-events: none; z-index: 110; }