:root {
  --clr-ocean-deep:  #0a1628;
  --clr-ocean-mid:   #0d2f5e;
  --clr-ocean-light: #1a5276;
  --clr-bubble:      #7fd8f5;
  --clr-bubble-glow: #a8efff;
  --clr-luma-pink:   #ff8fab;
  --clr-luma-accent: #ffcad4;
  --clr-gold:        #ffe066;
  --clr-success:     #6effc5;
  --clr-panel:       rgba(255,255,255,0.08);
  --clr-panel-border:rgba(127,216,245,0.25);
  --clr-text:        #e8f8ff;
  --clr-text-dim:    #a0c8d8;
  --radius-lg:       20px;
  --radius-xl:       32px;
  --shadow-glow:     0 0 24px rgba(127,216,245,0.4);
  --font-main:       'Nunito', sans-serif;
}

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

body {
  font-family: var(--font-main);
  background: var(--clr-ocean-deep);
  color: var(--clr-text);
  min-height: 100vh;
  overflow-x: hidden;
}

.screen { display: none; min-height: 100vh; width: 100%; }
.screen.active { display: flex; flex-direction: column; align-items: center; }

.panel {
  background: var(--clr-panel);
  border: 1.5px solid var(--clr-panel-border);
  border-radius: var(--radius-xl);
  padding: 2rem;
  backdrop-filter: blur(8px);
}

.btn {
  font-family: var(--font-main);
  font-weight: 900;
  font-size: 1.25rem;
  border: none;
  border-radius: var(--radius-lg);
  padding: 0.9rem 2.2rem;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
  letter-spacing: 0.02em;
}
.btn:active { transform: scale(0.96); }

.btn-primary {
  background: var(--clr-gold);
  color: var(--clr-ocean-deep);
  box-shadow: 0 4px 20px rgba(255,224,102,0.4);
}
.btn-primary:hover { box-shadow: 0 6px 28px rgba(255,224,102,0.6); transform: translateY(-2px); }

.btn-secondary {
  background: var(--clr-panel);
  color: var(--clr-bubble);
  border: 1.5px solid var(--clr-panel-border);
}

.bg-bubbles { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.bg-bubble {
  position: absolute;
  bottom: -180px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 32%, rgba(168,239,255,0.55), rgba(127,216,245,0.2) 50%, transparent 75%);
  border: 1.5px solid rgba(168,239,255,0.45);
  box-shadow: inset 0 0 12px rgba(255,255,255,0.15), 0 0 8px rgba(127,216,245,0.2);
  animation: bgBubbleRise linear infinite;
}

.luma-wrap { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; position: relative; }
.luma-figure { width: 140px; height: 140px; transition: width 0.4s ease, height 0.4s ease; }

/* Larger Luma on game screen */
#screen-game .luma-figure { width: 260px; height: 260px; }
.luma-idle      { animation: lumaIdle 3s ease-in-out infinite; }
.luma-letter    { animation: lumaBounce 0.4s ease-in-out 1; }
.luma-bubble {
  display: none;
}

#screen-game {
  padding: 1.5rem 1rem 2rem;
  gap: 1.2rem;
  background: radial-gradient(ellipse at 50% 0%, #1a5276 0%, #0a1628 70%);
  position: relative;
}

.game-header {
  width: 100%;
  max-width: 900px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(8, 20, 38, 0.78);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(127,216,245,0.28);
  border-radius: 999px;
  margin-top: 8px;
  position: relative; z-index: 2;
}

/* Two-column game body: Luma left, puzzle right */
.game-body {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 2rem;
  width: 100%;
  max-width: 900px;
  padding: 0 1rem;
  position: relative;
  z-index: 1;
}

.luma-col {
  flex: 0 0 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: sticky;
  top: 1rem;
}

.puzzle-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  min-width: 0;
}

.progress-bar-wrap {
  flex: 1;
  height: 12px;
  background: rgba(255,255,255,0.1);
  border-radius: 99px;
  overflow: hidden;
  margin: 0 0.75rem;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--clr-success), var(--clr-bubble));
  border-radius: 99px;
  transition: width 0.5s ease;
}
.progress-label { font-size: 0.78rem; font-weight: 700; color: #e2e8f0; white-space: nowrap; text-shadow: 0 1px 2px rgba(0,0,0,0.6); }

.machine-panel {
  width: 100%; max-width: 480px;
  margin: 0 auto;
  background: linear-gradient(160deg, rgba(26,82,118,0.85), rgba(8,20,38,0.92));
  backdrop-filter: blur(8px);
  border: 1.5px solid var(--clr-panel-border);
  border-radius: var(--radius-xl);
  padding: 1.4rem 1.6rem;
  display: flex; flex-direction: column; align-items: center; gap: 0.75rem;
  position: relative;
  box-shadow: 0 12px 30px rgba(0,0,0,0.45);
}
.machine-panel::before {
  content: '';
  position: absolute; inset: 0;
  border-radius: var(--radius-xl);
  background: linear-gradient(180deg, rgba(127,216,245,0.06) 0%, transparent 60%);
  pointer-events: none;
}

.machine-lights { display: flex; gap: 0.5rem; }
.machine-light { width: 12px; height: 12px; border-radius: 50%; background: rgba(255,255,255,0.15); transition: background 0.4s, box-shadow 0.4s; }
.machine-light.on { background: var(--clr-success); box-shadow: 0 0 8px var(--clr-success); }

.clue-text { width: 100%; min-height: 2.6em; font-size: 1.15rem; font-weight: 700; color: var(--clr-text); text-align: center; line-height: 1.4; display: flex; align-items: center; justify-content: center; }

.answer-slots { width: 100%; display: flex; gap: 0.5rem; justify-content: center; flex-wrap: wrap; }
.slot {
  width: 52px; height: 56px;
  border-radius: 12px;
  background: rgba(255,255,255,0.06);
  border: 2px solid rgba(127,216,245,0.25);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; font-weight: 900; color: var(--clr-bubble);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.1s;
  user-select: none;
}
.slot.filled { background: rgba(127,216,245,0.15); border-color: var(--clr-bubble); }
.slot.filled:hover { background: rgba(255,100,100,0.15); border-color: #ff6b6b; }
.slot.success-flash { animation: slotSuccess 0.4s ease-out; background: rgba(110,255,197,0.25); border-color: var(--clr-success); }

.tile-bank { display: flex; gap: 0.6rem; justify-content: center; flex-wrap: wrap; max-width: 520px; }
.tile-bank-label {
  font-size: 0.8rem; font-weight: 700; color: #e2e8f0;
  text-align: center; letter-spacing: 0.05em; text-transform: uppercase;
  background: rgba(8, 20, 38, 0.7);
  padding: 4px 14px;
  border-radius: 999px;
  display: inline-block;
  margin: 0 auto;
  border: 1px solid rgba(127,216,245,0.28);
}
.tile {
  width: 58px; height: 62px;
  border-radius: 14px;
  background: linear-gradient(160deg, #1a5276, #0d2f5e);
  border: 2px solid rgba(127,216,245,0.4);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; font-weight: 900; color: var(--clr-bubble-glow);
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s, opacity 0.2s;
  user-select: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.tile:hover:not(.used) { transform: translateY(-4px); box-shadow: 0 8px 20px rgba(127,216,245,0.25); }
.tile:active:not(.used) { transform: scale(0.93); }
.tile.used { opacity: 0.25; pointer-events: none; }
.tile.shake { animation: tileShake 0.4s ease-out; }

.feedback-msg { font-size: 1.1rem; font-weight: 900; color: var(--clr-bubble-glow); min-height: 1.5rem; text-align: center; transition: color 0.3s; }
.feedback-msg.wrong { color: #ff6b6b; font-size: 1.25rem; text-shadow: 0 0 12px rgba(255,80,80,0.6); }
.feedback-msg.hint { color: var(--clr-bubble-glow); font-size: 1.1rem; text-shadow: 0 0 10px rgba(127,216,245,0.5); }
.feedback-msg.skip { color: var(--clr-gold); font-size: 1rem; }

.machine-panel.wrong-flash {
  animation: wrongFlash 0.6s ease-out;
}

@keyframes wrongFlash {
  0%   { box-shadow: 0 0 0 rgba(255,80,80,0); border-color: var(--clr-panel-border); }
  30%  { box-shadow: 0 0 32px rgba(255,80,80,0.7); border-color: #ff6b6b; }
  100% { box-shadow: 0 0 0 rgba(255,80,80,0); border-color: var(--clr-panel-border); }
}

.milestone-badge {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  background: linear-gradient(135deg, #ffe066, #ffcad4);
  color: var(--clr-ocean-deep);
  border-radius: var(--radius-xl);
  padding: 2rem 2.5rem; text-align: center;
  z-index: 1000;
  box-shadow: 0 0 60px rgba(255,224,102,0.6);
  animation: badgeReveal 0.6s ease-out;
}
.milestone-badge .badge-emoji { font-size: 3rem; }
.milestone-badge .badge-title { font-size: 1.5rem; font-weight: 900; margin-top: 0.5rem; }
.milestone-badge .badge-label { font-size: 0.95rem; font-weight: 700; opacity: 0.8; margin-top: 0.25rem; }

#screen-start {
  justify-content: flex-start; align-items: center;
  padding: 2rem 1rem;
  position: relative;
}

.start-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.1rem;
  max-width: 400px;
  width: 100%;
  position: relative; z-index: 1;
}

#screen-start .luma-figure {
  width: min(380px, 32vh);
  height: min(380px, 32vh);
}


.start-logo { text-align: center; }
.start-logo .subtitle {
  font-size: 0.95rem; font-weight: 700;
  color: var(--clr-bubble-glow);
  margin-top: 0.3rem;
  text-shadow: 0 2px 10px rgba(0,0,0,0.9);
}

.start-panel {
  width: 100%;
  background: rgba(4, 12, 28, 0.82);
  border: 1.5px solid rgba(127,216,245,0.28);
  border-radius: var(--radius-xl);
  padding: 1.4rem 1.6rem;
  backdrop-filter: blur(16px);
  display: flex; flex-direction: column; align-items: center; gap: 0.85rem;
  text-align: center;
}

.start-tagline {
  font-size: 0.97rem;
  color: var(--clr-text);
  line-height: 1.5;
}

/* Mobile: stack Luma above puzzle */
@media (max-width: 640px) {
  #screen-start .luma-figure { width: 320px; height: 320px; }

  .game-body {
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 0 0.5rem;
  }
  .luma-col {
    flex: none;
    position: static;
    flex-direction: row;
    gap: 0.75rem;
    width: 100%;
    justify-content: center;
  }
  .luma-figure { width: 90px; height: 90px; }
  #screen-game .luma-figure { width: 100px; height: 100px; }
  .luma-bubble { max-width: 200px; }
  .tile { width: 46px; height: 50px; font-size: 1.2rem; }
  .slot { width: 44px; height: 48px; font-size: 1.3rem; }
  .machine-panel { padding: 0.75rem; gap: 0.5rem; }
  .machine-illustration { display: none; }
  .game-header { padding: 0 0.5rem; }
}

.bg-bubbles { z-index: 0; }
.game-header, .game-body, .machine-panel, .tile-bank, .feedback-msg { position: relative; z-index: 1; }

/* ── Generated Assets ───────────────────────────── */

.luma-figure img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.luma-figure img.luma-popin {
  animation: lumaPopIn 0.5s ease-out forwards;
}

@keyframes lumaPopIn {
  0%   { opacity: 0.5; transform: scale(0.96); }
  100% { opacity: 1;   transform: scale(1); }
}

.luma-figure.luma-tap {
  animation: lumaTap 0.4s ease-out forwards;
}

@keyframes lumaTap {
  0%   { transform: scale(1)    translateY(0); }
  35%  { transform: scale(1.06) translateY(-5px); }
  100% { transform: scale(1)    translateY(0); }
}

#screen-start {
  background-image: url('../assets/images/bg-start.jpg');
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
}

#screen-game {
  background-image: url('../assets/images/bg-lab.jpg');
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
}

/* Light overlay on game screen only — start screen stays vivid */
#screen-game::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(10, 22, 40, 0.20);
  pointer-events: none;
  z-index: 0;
}

.machine-illustration {
  width: 160px;
  height: 160px;
  object-fit: contain;
  filter: drop-shadow(0 0 16px rgba(127,216,245,0.4));
}

/* Wordmark replaces text title */
.wordmark {
  max-width: 520px;
  width: 95%;
  height: auto;
  filter: drop-shadow(0 0 20px rgba(127,216,245,0.5));
}

/* Slot hint text */
.slot-hint {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--clr-text-dim);
  text-align: center;
  opacity: 0.75;
  letter-spacing: 0.02em;
}

/* × indicator on filled slots */
.slot.filled::after {
  content: '×';
  position: absolute;
  top: -6px;
  right: -6px;
  width: 16px;
  height: 16px;
  background: rgba(255,107,107,0.85);
  color: white;
  border-radius: 50%;
  font-size: 0.6rem;
  line-height: 16px;
  text-align: center;
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
}
.slot.filled:hover::after { opacity: 1; }

/* Slots need position:relative for the × to anchor */
.slot { position: relative; }

/* ── Week Select Screen ─────────────────────────────────── */

#screen-weeks {
  flex-direction: column;
  align-items: center;
  padding: 1.5rem 1rem 3rem;
  gap: 1.2rem;
  overflow-y: auto;
  background-image: url('../assets/images/bg-menu.jpg');
  background-size: cover;
  background-position: center center;
  position: relative;
}

#screen-weeks::before {
  content: '';
  position: fixed;
  inset: 0;
  background: rgba(5, 12, 28, 0.28);
  pointer-events: none;
  z-index: 0;
}

.weeks-header {
  width: 100%; max-width: 900px;
  display: flex; align-items: center; gap: 1rem;
  position: relative; z-index: 1;
}

.weeks-title-block { display: flex; flex-direction: column; gap: 0.1rem; }
.weeks-title {
  font-size: 1.5rem; font-weight: 900;
  color: var(--clr-bubble-glow);
  text-shadow: 0 0 20px rgba(127,216,245,0.5);
  line-height: 1.1;
}
.weeks-subtitle { font-size: 0.8rem; color: var(--clr-text-dim); font-weight: 700; }

.btn-back { font-size: 0.9rem; padding: 0.5rem 1rem; flex-shrink: 0; }

/* Game back button in header */
.game-back-btn { font-size: 0.8rem; padding: 0.35rem 0.75rem; flex-shrink: 0; }

/* ── Conveyor Belt System ─────────────────────────────────── */

.conveyor-wrap {
  width: 100%; max-width: 900px;
  position: relative; z-index: 1;
  display: flex; flex-direction: column; gap: 0;
}

.belt-rail {
  width: 100%; height: 14px;
  background:
    linear-gradient(180deg, rgba(60,120,180,0.6) 0%, rgba(30,70,110,0.8) 50%, rgba(20,50,80,0.6) 100%);
  border-radius: 3px;
  position: relative; overflow: hidden;
}
.belt-rail::before {
  content: '';
  position: absolute; inset: 0;
  background: repeating-linear-gradient(
    90deg,
    transparent 0,
    transparent 18px,
    rgba(0,0,0,0.35) 18px,
    rgba(0,0,0,0.35) 22px
  );
  animation: beltScroll 1.2s linear infinite;
}
.belt-rail::after {
  content: '';
  position: absolute; inset: 0;
  background:
    linear-gradient(180deg, rgba(127,216,245,0.25) 0%, transparent 40%),
    linear-gradient(0deg, rgba(0,0,0,0.3) 0%, transparent 40%);
  pointer-events: none;
}
@keyframes beltScroll {
  from { background-position: 0 0; }
  to   { background-position: 22px 0; }
}

.weeks-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.9rem;
  padding: 0.6rem 0;
  position: relative; z-index: 1;
  background: rgba(10,22,40,0.15);
}

/* ── Week Cards ─────────────────────────────────────────────── */

.week-card {
  background: rgba(8,18,36,0.92);
  border: 1.5px solid rgba(127,216,245,0.3);
  border-top: 3px solid rgba(127,216,245,0.5);
  border-radius: var(--radius-lg);
  padding: 0.75rem 0.9rem 0.9rem;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  display: flex; flex-direction: column; gap: 0.4rem;
  position: relative;
}
.week-card:hover:not(.locked) {
  transform: translateY(-4px);
  box-shadow: 0 8px 28px rgba(127,216,245,0.25);
  border-color: var(--clr-bubble);
  border-top-color: var(--clr-bubble);
}
.week-card.locked { opacity: 0.4; cursor: default; }
.week-card.completed {
  border-color: rgba(110,255,197,0.5);
  border-top-color: var(--clr-success);
  box-shadow: 0 0 12px rgba(110,255,197,0.15);
}
.week-card.completed:hover:not(.locked) {
  box-shadow: 0 8px 28px rgba(110,255,197,0.3);
}

.week-card-header { display: flex; align-items: center; justify-content: space-between; }
.week-card-num { font-size: 0.95rem; font-weight: 900; color: var(--clr-bubble-glow); }

.week-card-status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  flex-shrink: 0;
}
.dot-charged {
  background: var(--clr-success);
  box-shadow: 0 0 6px var(--clr-success);
  animation: dotPulse 2s ease-in-out infinite;
}
.dot-ready { background: var(--clr-bubble); box-shadow: 0 0 4px var(--clr-bubble); }
.dot-locked { background: rgba(255,255,255,0.2); }

@keyframes dotPulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

.week-card-stars { font-size: 1.1rem; }
.week-card-stars .star { color: var(--clr-text-dim); }
.week-card-stars .star.earned { color: var(--clr-gold); }
.week-card-clue { font-size: 0.78rem; color: var(--clr-text); line-height: 1.35; opacity: 0.85; }

/* ── Mute Button ──────────────────────────────────────────── */

.btn-mute {
  position: fixed;
  bottom: 1rem; right: 1rem;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: rgba(10,22,40,0.85);
  border: 1.5px solid rgba(127,216,245,0.4);
  color: var(--clr-text);
  font-size: 1.3rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  z-index: 5000;
  transition: background 0.2s, border-color 0.2s;
  backdrop-filter: blur(6px);
  padding: 0;
  font-family: var(--font-main);
}
.btn-mute:hover { background: rgba(127,216,245,0.15); border-color: var(--clr-bubble); }

.btn-echo {
  margin-top: 0.3rem;
  font-size: 0.78rem; font-weight: 800;
  padding: 0.35rem 0.75rem;
  background: rgba(110,255,197,0.15);
  color: var(--clr-success);
  border: 1px solid rgba(110,255,197,0.4);
  border-radius: 8px; cursor: pointer;
  transition: background 0.2s;
  font-family: var(--font-main);
}
.btn-echo:hover { background: rgba(110,255,197,0.25); }

/* ── Code Modal ─────────────────────────────────────────── */

.code-modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 2000;
}
.code-modal-box {
  max-width: 340px; width: 90%;
  display: flex; flex-direction: column; gap: 0.9rem;
  text-align: center;
}
.code-modal-title { font-size: 1.1rem; font-weight: 900; color: var(--clr-bubble-glow); }
.code-modal-input {
  font-family: var(--font-main);
  font-size: 1.6rem; font-weight: 900; letter-spacing: 0.12em;
  text-align: center; text-transform: uppercase;
  background: rgba(255,255,255,0.08);
  border: 2px solid var(--clr-panel-border);
  border-radius: 12px; color: var(--clr-text);
  padding: 0.6rem; width: 100%;
}
.code-modal-hint { font-size: 0.82rem; color: #ff6b6b; min-height: 1.2em; }
.code-modal-btns { display: flex; gap: 0.6rem; justify-content: center; }

/* ── Chalkboard Badge ───────────────────────────────────── */

.chalkboard-badge {
  background: rgba(30,50,30,0.75);
  border: 2px solid rgba(180,200,150,0.4);
  border-radius: 8px;
  padding: 0.2rem 0.7rem;
  font-size: 0.8rem; font-weight: 900;
  color: rgba(220,240,200,0.9);
  letter-spacing: 0.05em;
  white-space: nowrap;
}

/* ── Week-Complete Overlay ──────────────────────────────── */

.week-overlay {
  position: fixed; inset: 0;
  background: rgba(5,12,25,0.85);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 1.2rem; z-index: 1500;
  animation: badgeReveal 0.5s ease-out;
}
.week-overlay-luma { width: 180px; height: 180px; }
.week-overlay-luma img { width: 100%; height: 100%; object-fit: contain; }
.week-overlay-title {
  font-size: clamp(1.6rem, 5vw, 2.4rem); font-weight: 900;
  color: var(--clr-gold);
  text-shadow: 0 0 30px rgba(255,224,102,0.6);
  text-align: center;
}
.week-overlay-stars { font-size: 2.5rem; letter-spacing: 0.15em; }
.week-overlay-code {
  background: rgba(255,255,255,0.08);
  border: 1.5px solid var(--clr-panel-border);
  border-radius: var(--radius-lg);
  padding: 0.8rem 1.5rem; text-align: center;
}
.week-overlay-code-label { font-size: 0.8rem; font-weight: 700; color: var(--clr-text-dim); }
.week-overlay-code-value {
  font-size: 1.8rem; font-weight: 900; letter-spacing: 0.15em;
  color: var(--clr-bubble-glow);
}
.week-overlay-code-hint { font-size: 0.72rem; color: var(--clr-text-dim); margin-top: 0.25rem; }

/* ── Machine Activated ──────────────────────────────────── */

.machine-illustration.activated {
  filter: brightness(1.35) saturate(1.3) drop-shadow(0 0 20px rgba(110,255,197,0.6));
  transition: filter 0.3s;
}

/* ── Word Echo Mode ─────────────────────────────────────── */

.echo-panel {
  width: 100%; max-width: 500px;
  display: flex; flex-direction: column; align-items: center; gap: 1.2rem;
  position: relative; z-index: 1;
  background: rgba(8, 20, 38, 0.78);
  backdrop-filter: blur(8px);
  border: 1.5px solid rgba(127,216,245,0.32);
  border-radius: 22px;
  padding: 22px 24px 26px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.45);
}
.echo-prompt { font-size: 1.15rem; font-weight: 700; color: var(--clr-bubble-glow); text-align: center; text-shadow: 0 1px 3px rgba(0,0,0,0.6); }
.echo-play-btn {
  width: 80px; height: 80px; border-radius: 50%;
  background: linear-gradient(135deg, var(--clr-bubble), var(--clr-ocean-light));
  border: none; cursor: pointer; font-size: 2rem;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 20px rgba(127,216,245,0.4);
  transition: transform 0.15s, box-shadow 0.15s;
}
.echo-play-btn:hover { transform: scale(1.08); box-shadow: 0 0 32px rgba(127,216,245,0.6); }
.echo-choices { display: flex; flex-direction: column; gap: 0.7rem; width: 100%; }
.echo-choice {
  padding: 1rem 1.5rem;
  background: linear-gradient(160deg, rgba(26,82,118,0.6), rgba(10,22,40,0.8));
  border: 2px solid rgba(127,216,245,0.3);
  border-radius: var(--radius-lg);
  font-size: 1.4rem; font-weight: 900; color: var(--clr-bubble-glow);
  cursor: pointer; text-align: center; font-family: var(--font-main);
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}
.echo-choice:hover { border-color: var(--clr-bubble); transform: scale(1.02); }
.echo-choice.correct { border-color: var(--clr-success); background: rgba(110,255,197,0.15); }
.echo-choice.wrong { border-color: #ff6b6b; background: rgba(255,80,80,0.1); animation: tileShake 0.4s ease-out; }

/* ── Sentence Builder ───────────────────────────────────── */

.sentence-display {
  font-size: clamp(1rem, 2.8vw, 1.35rem);
  font-weight: 700;
  color: var(--clr-text);
  line-height: 1.55;
  text-align: center;
  padding: 0.5rem 0.25rem;
  margin-bottom: 0.5rem;
}

.sentence-blank {
  color: var(--clr-gold);
  font-weight: 900;
  letter-spacing: 0.08em;
  border-bottom: 2px solid var(--clr-gold);
  padding-bottom: 1px;
  animation: blankPulse 2s ease-in-out infinite;
}

@keyframes blankPulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.55; }
}

.btn-sentence {
  margin-top: 0.3rem;
  font-size: 0.78rem; font-weight: 800;
  padding: 0.35rem 0.75rem;
  background: rgba(255,224,102,0.12);
  color: var(--clr-gold);
  border: 1px solid rgba(255,224,102,0.4);
  border-radius: 8px; cursor: pointer;
  transition: background 0.2s;
  font-family: var(--font-main);
  display: block;
  width: 100%;
}
.btn-sentence:hover { background: rgba(255,224,102,0.22); }

/* ── Charge Bar (week-complete overlay) ───────────────────────────────────── */

.charge-bar-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
  margin: 0.5rem 0;
}

.charge-bar-machine-name {
  font-size: 0.85rem;
  color: #c9a227;
  font-weight: 600;
  text-align: center;
}

.charge-bar-track {
  width: 100%;
  max-width: 260px;
  height: 14px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  overflow: hidden;
}

.charge-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #60a5fa);
  border-radius: 999px;
  transition: width 0.4s ease;
}

.charge-bar-label {
  font-size: 0.8rem;
  color: #a0b4cc;
}

.charge-bar-label.online {
  color: #4ade80;
  font-weight: 700;
}

/* ── Lab Hub Screen ───────────────────────────────────────────────────────── */

#screen-weeks {
  gap: 1rem;
  padding: 1rem 1rem 2rem;
}

.lab-header {
  width: 100%; max-width: 860px;
  display: flex; align-items: center; justify-content: space-between;
  position: relative; z-index: 1;
  flex-shrink: 0;
}

.lab-title {
  font-size: 1.15rem; font-weight: 900;
  color: var(--clr-bubble-glow);
  text-shadow: 0 0 16px rgba(127,216,245,0.5);
  flex: 1; text-align: center;
}

.btn-sm { font-size: 0.78rem; padding: 0.35rem 0.75rem; }

/* ── Machine Hero ─────────────────────────────────────────────────────────── */

.machine-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  position: relative;
  z-index: 1;
  flex-shrink: 0;
}

.machine-hero-img-wrap {
  position: relative;
  width: 170px;
  height: 170px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.machine-hero-glow {
  position: absolute;
  inset: -24px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--mc, #60a5fa) 0%, transparent 68%);
  opacity: 0.35;
  animation: heroGlow 2.5s ease-in-out infinite alternate;
  pointer-events: none;
}

@keyframes heroGlow {
  from { opacity: 0.2; transform: scale(0.9); }
  to   { opacity: 0.5; transform: scale(1.1); }
}

.machine-hero-img {
  width: 170px;
  height: 170px;
  object-fit: cover;
  border-radius: 50%;
  border: 3px solid rgba(127, 216, 245, 0.3);
  position: relative;
  z-index: 1;
}

.machine-hero-img.online {
  border-color: #4ade80;
  box-shadow: 0 0 24px rgba(74, 222, 128, 0.5);
}

.machine-hero-name {
  font-size: 1.3rem;
  font-weight: 900;
  color: var(--clr-text);
  text-align: center;
  text-shadow: 0 2px 10px rgba(0,0,0,0.9);
}

.machine-hero-charge { margin-top: 0.1rem; }

/* ── Lab Panorama ─────────────────────────────────────────────────────────── */

.lab-panorama {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding: 8px 14px;
  position: relative;
  z-index: 1;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  max-width: 860px;
  width: 100%;
  flex-shrink: 0;
  background: rgba(8, 20, 38, 0.72);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(127,216,245,0.3);
  border-radius: 999px;
  justify-content: center;
}
.lab-panorama::-webkit-scrollbar { display: none; }

.machine-node {
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 2px solid rgba(127,216,245,0.35);
  overflow: hidden;
  position: relative;
  cursor: default;
  background: rgba(8, 20, 38, 0.55);
}

.machine-node img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.machine-node.online {
  border-color: #4ade80;
  box-shadow: 0 0 10px rgba(74,222,128,0.55);
}

.machine-node.charging {
  border-color: var(--mc, #60a5fa);
  box-shadow: 0 0 14px var(--mc, #60a5fa);
  animation: nodeCharge 1.6s ease-in-out infinite;
}

.machine-node.dormant {
  opacity: 0.7;
  filter: grayscale(0.5) brightness(0.85);
}

@keyframes nodeCharge {
  0%, 100% { box-shadow: 0 0 6px var(--mc, #60a5fa); }
  50%       { box-shadow: 0 0 22px var(--mc, #60a5fa); }
}

/* ── Week Activities Panel ────────────────────────────────────────────────── */

.week-activities {
  background: rgba(4, 12, 28, 0.85);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(127,216,245,0.2);
  border-radius: 20px;
  padding: 1.1rem 1.4rem;
  max-width: 460px;
  width: 92%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  position: relative;
  z-index: 1;
  flex-shrink: 0;
}

.week-act-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.week-act-num {
  font-size: 1.4rem;
  font-weight: 900;
  color: var(--clr-bubble-glow);
}

.week-act-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
}

.week-act-badge.charged {
  background: rgba(74,222,128,0.2);
  color: #4ade80;
  border: 1px solid rgba(74,222,128,0.4);
}

.week-act-badge.ready {
  background: rgba(127,216,245,0.1);
  color: var(--clr-bubble-glow);
  border: 1px solid rgba(127,216,245,0.3);
}

.week-act-clue {
  font-size: 0.88rem;
  color: var(--clr-text);
  text-align: center;
  opacity: 0.85;
  line-height: 1.4;
}

.week-act-stars { font-size: 1.2rem; }

.week-act-btns {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 0.2rem;
}

/* ── Past Weeks Overlay (modal) ──────────────────────────────────────────── */

.past-weeks-overlay {
  position: fixed; inset: 0; z-index: 1100;
  background: rgba(5, 12, 24, 0.7);
  backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  font-family: 'Nunito', system-ui, -apple-system, sans-serif;
}
.past-weeks-card {
  position: relative;
  background: rgba(8, 20, 38, 0.96);
  border: 2px solid rgba(127,216,245,0.45);
  border-radius: 22px;
  padding: 22px 26px 24px;
  max-width: 540px;
  width: 100%;
  max-height: 84vh;
  overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow: 0 18px 50px rgba(0,0,0,0.65);
}
.past-weeks-card h2 {
  margin: 0;
  color: var(--clr-bubble-glow);
  font-weight: 900;
  font-size: 1.4rem;
  letter-spacing: 0.04em;
}
.past-weeks-hint {
  margin: 4px 0 12px;
  color: rgba(241,245,249,0.7);
  font-size: 0.9rem;
}
.past-weeks-empty {
  color: rgba(241,245,249,0.6);
  text-align: center;
  padding: 24px 0;
}
.past-weeks-close {
  position: absolute;
  top: 10px; right: 14px;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: rgba(127,216,245,0.12);
  border: 1px solid rgba(127,216,245,0.4);
  color: #e2e8f0;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.past-weeks-close:hover {
  background: rgba(127,216,245,0.25);
}
.past-weeks-list {
  flex: 1;
  overflow-y: auto;
  padding-right: 6px;
  margin-right: -6px;
}

.past-week-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.past-week-row:last-child { border-bottom: none; }

.past-week-num {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--clr-bubble-glow);
  min-width: 50px;
}

.past-week-stars {
  font-size: 0.85rem;
  color: var(--clr-gold);
  min-width: 44px;
}

.past-week-btns { display: flex; gap: 0.25rem; margin-left: auto; }

.btn-chip {
  background: rgba(127,216,245,0.12);
  border: 1px solid rgba(127,216,245,0.28);
  color: var(--clr-text);
  font-family: var(--font-main);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.18rem 0.45rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-chip:hover { background: rgba(127,216,245,0.28); }

/* ── Machine Splash Screen ────────────────────────────────────────────────── */

.machine-splash {
  position: fixed;
  inset: 0;
  background: rgba(2, 5, 18, 0.97);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 4000;
  animation: splashFadeIn 0.45s ease;
}

@keyframes splashFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.machine-splash-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.9rem;
  max-width: 400px;
  width: 90%;
  text-align: center;
  padding: 1rem;
}

.machine-splash-img-wrap {
  position: relative;
  width: 210px;
  height: 210px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.machine-splash-glow {
  position: absolute;
  inset: -32px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--mc, #60a5fa) 0%, transparent 65%);
  opacity: 0.55;
  animation: splashGlowPulse 1.4s ease-in-out infinite alternate;
  pointer-events: none;
}

@keyframes splashGlowPulse {
  from { opacity: 0.35; transform: scale(0.88); }
  to   { opacity: 0.75; transform: scale(1.12); }
}

.machine-splash-img {
  width: 210px;
  height: 210px;
  object-fit: cover;
  border-radius: 50%;
  border: 4px solid var(--mc, #60a5fa);
  position: relative;
  z-index: 1;
  animation: splashImgPop 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes splashImgPop {
  from { opacity: 0; transform: scale(0.3) rotate(-15deg); }
  to   { opacity: 1; transform: scale(1) rotate(0deg); }
}

.machine-splash-online {
  background: linear-gradient(135deg, #4ade80, #16a34a);
  color: #e8fff0;
  font-size: 0.82rem;
  font-weight: 900;
  padding: 0.28rem 1.2rem;
  border-radius: 999px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  box-shadow: 0 0 20px rgba(74,222,128,0.55);
  animation: splashOnlinePop 0.4s 0.3s ease backwards;
}

@keyframes splashOnlinePop {
  from { opacity: 0; transform: scale(0.6); }
  to   { opacity: 1; transform: scale(1); }
}

.machine-splash-name {
  font-size: 1.9rem;
  font-weight: 900;
  color: var(--clr-text);
  text-shadow: 0 0 28px rgba(127,216,245,0.6);
  line-height: 1.1;
}

.machine-splash-luma {
  width: 90px;
  height: 90px;
  object-fit: contain;
}

.machine-splash-line {
  font-size: 1.05rem;
  line-height: 1.65;
  color: #c4d8f0;
  margin: 0;
}

/* ── Lab Hub: no-scroll layout ───────────────────────────────────────────── */
/* All elements must fit within one viewport — no vertical scroll on lab screen */

#screen-weeks {
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  overflow: hidden;
  padding: 0.55rem 1rem 0.4rem;
  gap: 0.45rem;
}

.machine-hero { gap: 0.3rem; }

.machine-hero-img-wrap {
  width: 110px;
  height: 110px;
}

.machine-hero-img {
  width: 110px;
  height: 110px;
}

.machine-hero-name {
  font-size: 1rem;
}

.machine-hero-charge { margin-top: 0; }

.lab-panorama {
  padding: 0.25rem 0.75rem;
}

.machine-node {
  width: 46px;
  height: 46px;
}

.week-activities {
  flex: 1;
  min-height: 0;
  padding: 0.75rem 1.2rem;
  gap: 0.4rem;
  flex-shrink: 1;
}

.week-act-clue {
  font-size: 0.84rem;
}

.week-act-btns { margin-top: 0.1rem; }

/* ── Start Screen: fit-to-viewport layout ──────────────────────────────── */

#screen-start {
  min-height: 100vh;
  min-height: 100dvh;
  justify-content: flex-start;
  padding: 1.5rem 1rem;
}

.start-center { gap: 0.5rem; margin: auto 0; }

#screen-start .luma-figure {
  width: min(380px, 32vh);
  height: min(380px, 32vh);
}

@media (max-height: 820px) {
  #screen-start { padding: 0.5rem 1rem; }
  .start-center { gap: 0.35rem; }
  #screen-start .luma-figure { width: min(320px, 26vh); height: min(320px, 26vh); }
  .start-panel { padding: 0.85rem 1.2rem; gap: 0.55rem; }
  .start-tagline { font-size: 0.85rem; }
  .wordmark { max-width: 320px; }
}

/* ---------- Cutscene Engine ---------- */
.cutscene {
  position: fixed;
  inset: 24px;
  z-index: 1000;
  background: #0a1628;
  border: 6px solid #1a2a3e;
  border-radius: 28px;
  opacity: 0;
  transition: opacity 0.28s ease;
  pointer-events: none;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0,0,0,0.65);
}
@media (max-width: 640px) {
  .cutscene {
    inset: 12px;
    border-width: 4px;
    border-radius: 20px;
  }
}
.cutscene.is-visible { opacity: 1; pointer-events: auto; }
.cutscene-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform-origin: center;
  animation: cutsceneBgDrift 38s ease-in-out infinite alternate;
}
@keyframes cutsceneBgDrift {
  0%   { transform: scale(1.04) translate(-1%, 0.5%); }
  100% { transform: scale(1.10) translate(1.5%, -1%); }
}
.cutscene-stage {
  position: absolute;
  inset: 0;
}
.cutscene-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(5,12,24,0.55) 100%);
}
.cutscene-bubble {
  position: absolute;
  top: 5%;
  left: 5%;
  right: 5%;
  width: auto;
  background: #fffaf0;
  border: 4px solid #1a2a3e;
  border-radius: 24px;
  padding: 22px 32px 26px;
  box-shadow: 0 14px 36px rgba(0,0,0,0.45);
  color: #1a2a3e;
  font-family: 'Nunito', system-ui, -apple-system, sans-serif;
  font-weight: 700;
  z-index: 5;
}
.cutscene-bubble[data-tail="down"]::before,
.cutscene-bubble[data-tail="down"]::after {
  content: '';
  position: absolute;
  width: 0; height: 0;
  border-style: solid;
}
/* Tail points toward Luma's standing position (default x:72%). Bubble
   spans 5%-95%, so the tail at left: calc(72% - 5%) / 90% inside bubble
   resolves to roughly 74% of the bubble width. */
.cutscene-bubble[data-tail="down"]::before {
  bottom: -26px;
  left: 74%;
  transform: translateX(-50%);
  border-width: 24px 18px 0 18px;
  border-color: #1a2a3e transparent transparent transparent;
}
.cutscene-bubble[data-tail="down"]::after {
  bottom: -18px;
  left: 74%;
  transform: translateX(-50%);
  border-width: 18px 14px 0 14px;
  border-color: #fffaf0 transparent transparent transparent;
}
.cutscene-text {
  font-size: clamp(17px, 2vw, 24px);
  line-height: 1.45;
  text-align: center;
  min-height: 3em;
}
.cutscene-controls {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 14px 24px 20px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  pointer-events: none;
  z-index: 6;
}
.cutscene-controls > * { pointer-events: auto; }
.cutscene-skip {
  background: rgba(15, 30, 50, 0.78);
  color: #e2e8f0;
  border: 1px solid rgba(127, 216, 245, 0.4);
  padding: 8px 16px;
  border-radius: 99px;
  font-weight: 600;
  cursor: pointer;
  margin-left: auto;
}
.cutscene-skip[hidden] { display: none; }
.cutscene-advance {
  position: absolute;
  bottom: 4px;
  left: 0; right: 0;
  text-align: center;
  font-size: 12px;
  color: rgba(241, 245, 249, 0.7);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  animation: cutsceneAdvancePulse 1.4s ease-in-out infinite;
  opacity: 0;
  pointer-events: none;
}
.cutscene-advance.is-ready { opacity: 1; }
@keyframes cutsceneAdvancePulse {
  50% { opacity: 0.4; }
}
.cutscene-sprite {
  --sprite-scale: 1;
  --sprite-platform-scale: 1;
  position: absolute;
  bottom: 20%;
  left: 50%;
  height: 50vh;
  width: auto;
  max-width: 60vw;
  transform: translate(-50%, 0) scale(calc(var(--sprite-scale) * var(--sprite-platform-scale)));
  transform-origin: bottom center;
  transition: opacity 0.3s ease, transform 0.4s ease, left 0.6s ease, bottom 0.6s ease;
  pointer-events: none;
  filter: drop-shadow(0 6px 18px rgba(0,0,0,0.45));
}
.cutscene-sprite[data-kind="luma"] {
  height: 48vh;
  width: 48vh;
  object-fit: contain;
}
@media (max-width: 640px) {
  .cutscene-sprite {
    --sprite-platform-scale: 0.8;
    max-width: 75vw;
  }
}

/* ---------- Cutscene Picker (QA: ?cutscene=menu) ---------- */
#cutscene-menu {
  position: fixed; inset: 0; z-index: 900;
  background: radial-gradient(ellipse at center, #0f2238 0%, #06101f 80%);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Nunito', system-ui, -apple-system, sans-serif;
  padding: 24px;
  overflow: auto;
}
#cutscene-menu .cutscene-menu-card {
  background: rgba(15, 30, 50, 0.85);
  border: 1px solid rgba(127, 216, 245, 0.3);
  border-radius: 18px;
  padding: 28px 32px;
  max-width: 520px;
  width: 100%;
  color: #f1f5f9;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
}
#cutscene-menu h2 {
  color: #7fd8f5;
  margin: 0 0 8px;
  font-weight: 900;
  letter-spacing: 0.05em;
}
#cutscene-menu p {
  color: rgba(241,245,249,0.7);
  margin: 0 0 20px;
  font-size: 0.95rem;
}
#cutscene-menu ul {
  list-style: none;
  margin: 0; padding: 0;
  display: grid;
  gap: 8px;
}
#cutscene-menu li { margin: 0; }
#cutscene-menu button {
  width: 100%;
  text-align: left;
  background: rgba(127, 216, 245, 0.08);
  color: #f1f5f9;
  border: 1px solid rgba(127, 216, 245, 0.25);
  border-radius: 10px;
  padding: 12px 16px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.12s ease;
}
#cutscene-menu button:hover {
  background: rgba(127, 216, 245, 0.18);
  border-color: rgba(127, 216, 245, 0.55);
}
#cutscene-menu button:active { transform: translateY(1px); }
