:root {
  --ink: #1f1a2e;
  --pink: #ff4f87;
  --yellow: #ffd23f;
  --sky: #38bdf8;
  --green: #4ade80;
  --lilac: #a78bfa;
  --cream: #fff6df;
  --orange: #ff8c38;
  --red: #ef4444;
  --teal: #14b8a6;
  --white: #ffffff;
  --font-display: 'Lilita One', 'Trebuchet MS', cursive, sans-serif;
  --font-body: 'DM Sans', system-ui, -apple-system, sans-serif;
}

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

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #bfe8ff;
  font-family: var(--font-body);
  color: var(--ink);
}

#canvas-wrap {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#canvas-wrap:active {
  cursor: grabbing;
}

#count-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 8;
  overflow: hidden;
}

#confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 60;
}

.hidden {
  display: none !important;
}

/* ==================== STICKER BOOK PRIMITIVES ==================== */

.sticker-card {
  background: var(--cream);
  border: 3.5px solid var(--ink);
  border-radius: 22px;
  box-shadow: 5px 5px 0 var(--ink);
}

.sticker-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-display);
  font-size: 1.05rem;
  letter-spacing: 0.02em;
  color: var(--ink);
  background: var(--cream);
  border: 3px solid var(--ink);
  border-radius: 16px;
  padding: 10px 18px;
  box-shadow: 0 5px 0 var(--ink);
  cursor: pointer;
  transition: transform 0.12s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.12s ease, filter 0.12s ease;
}

.sticker-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 7px 0 var(--ink);
  filter: brightness(1.03);
}

.sticker-btn:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 var(--ink);
}

.sticker-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn-pink {
  background: var(--pink);
  color: var(--white);
  text-shadow: 0 2px 0 rgba(31, 26, 46, 0.35);
}

.btn-yellow {
  background: var(--yellow);
  color: var(--ink);
}

.btn-sky {
  background: var(--sky);
  color: var(--ink);
}

.btn-green {
  background: var(--green);
  color: var(--ink);
}

.btn-lilac {
  background: var(--lilac);
  color: var(--white);
}

.btn-cream {
  background: var(--cream);
  color: var(--ink);
}

.btn-lg {
  font-size: 1.25rem;
  padding: 14px 26px;
  border-radius: 20px;
  border-width: 3.5px;
  box-shadow: 0 6px 0 var(--ink);
}

.icon-btn {
  width: 48px;
  height: 48px;
  padding: 0;
  font-size: 1.3rem;
  border-radius: 15px;
}

.icon-btn.muted {
  opacity: 0.55;
  filter: grayscale(0.7);
}

/* ==================== TOP HUD ==================== */

.hud {
  position: fixed;
  top: 14px;
  left: 16px;
  right: 16px;
  z-index: 25;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}

.hud-left,
.hud-center,
.hud-right {
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
}

.title-pill {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 16px 8px 12px;
  border-radius: 18px;
}

.bag-badge {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  font-size: 1.4rem;
  background: var(--pink);
  border: 3px solid var(--ink);
  border-radius: 13px;
  box-shadow: 2px 2px 0 var(--ink);
}

.brand-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.18rem;
  line-height: 1.1;
  color: var(--ink);
}

.room-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.84rem;
  font-weight: 800;
  color: #463d5e;
  margin-top: 2px;
}

.room-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--sky);
  border: 2px solid var(--ink);
  display: inline-block;
}

.star-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 15px;
  border-radius: 18px;
  background: var(--yellow);
  font-family: var(--font-display);
  font-size: 1.25rem;
}

.star-icon {
  font-size: 1.35rem;
  display: inline-block;
}

.star-pill.pop .star-icon {
  animation: starBounce 0.55s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.star-total {
  font-size: 0.92rem;
  opacity: 0.72;
}

@keyframes starBounce {
  0% { transform: scale(1) rotate(0deg); }
  40% { transform: scale(1.6) rotate(18deg); }
  100% { transform: scale(1) rotate(0deg); }
}

/* ==================== SCHOOL MINI-MAP ==================== */

.minimap {
  position: fixed;
  top: 84px;
  left: 16px;
  right: auto;
  z-index: 22;
  width: 188px;
  padding: 8px;
  background: rgba(255, 246, 223, 0.96);
}

.minimap-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.minimap-title {
  font-family: var(--font-display);
  font-size: 0.9rem;
}

.minimap-progress {
  font-family: var(--font-display);
  font-size: 0.78rem;
  padding: 1px 7px;
  background: var(--green);
  border: 2px solid var(--ink);
  border-radius: 99px;
}

.minimap-grid {
  display: grid;
  grid-template-columns: 1fr 0.85fr 1fr;
  grid-template-rows: 30px 27px 27px 27px;
  gap: 4px;
}

.map-room {
  position: relative;
  border: 2px solid var(--ink);
  border-radius: 8px;
  box-shadow: 0 2px 0 var(--ink);
  font-family: var(--font-body);
  font-weight: 800;
  font-size: 0.66rem;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px 4px;
  text-align: center;
  line-height: 1.05;
  transition: transform 0.14s ease, box-shadow 0.14s ease;
}

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

.map-field {
  grid-column: 1 / 4;
  grid-row: 1;
  background: #86efac;
}

.map-library {
  grid-column: 1;
  grid-row: 2;
  background: #7dd3fc;
}

.map-corridor {
  grid-column: 2;
  grid-row: 2 / 5;
  background: #e0f2fe;
}

.map-spacer {
  grid-column: 3;
  grid-row: 2;
}

.map-music {
  grid-column: 1;
  grid-row: 3;
  background: #fde047;
}

.map-gym {
  grid-column: 3;
  grid-row: 3;
  background: #4ade80;
}

.map-office {
  grid-column: 1;
  grid-row: 4;
  background: #c4b5fd;
}

.map-art {
  grid-column: 3;
  grid-row: 4;
  background: #fca5a5;
}

.map-room.current {
  outline: 2.5px solid var(--pink);
  outline-offset: 1px;
  transform: scale(1.03);
  z-index: 2;
}

.map-room.current::before {
  content: '';
  position: absolute;
  top: -5px;
  left: -5px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--orange);
  border: 2px solid var(--ink);
  animation: pulseDot 1.1s infinite;
}

@keyframes pulseDot {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.25); }
}

.map-tick {
  position: absolute;
  top: -5px;
  right: -5px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--green);
  color: var(--ink);
  border: 2px solid var(--ink);
  font-size: 0.6rem;
  font-weight: 900;
  display: none;
  place-items: center;
}

.map-room.visited .map-tick {
  display: grid;
}

/* ==================== CHARACTER STORY BUBBLE ==================== */

.story-bubble {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 26;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 18px;
  width: min(620px, calc(100vw - 32px));
  background: rgba(255, 246, 223, 0.97);
  animation: slideUpPop 0.32s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes slideUpPop {
  from { opacity: 0; transform: translate(-50%, 24px) scale(0.95); }
  to { opacity: 1; transform: translate(-50%, 0) scale(1); }
}

.story-avatar {
  width: 58px;
  height: 58px;
  border-radius: 16px;
  border: 3px solid var(--ink);
  background: var(--sky);
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 0;
  flex-shrink: 0;
  box-shadow: 2px 3px 0 var(--ink);
}

.story-avatar svg {
  width: 100%;
  height: 100%;
  display: block;
}

.story-text-wrap {
  flex: 1;
}

.story-speaker {
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: var(--pink);
  line-height: 1.1;
}

.story-line {
  font-size: 1.02rem;
  font-weight: 700;
  line-height: 1.32;
  margin-top: 3px;
}

/* ==================== FROSTED-GLASS QUESTION PANEL ==================== */

.question-panel {
  position: fixed;
  bottom: 20px;
  z-index: 28;
  width: min(440px, calc(100vw - 32px));
  max-height: calc(100vh - 96px);
  overflow-y: auto;
  padding: 16px 18px 18px;
  background: rgba(255, 246, 223, 0.96);
  border: 3.5px solid var(--ink);
  border-radius: 24px;
  box-shadow: 6px 6px 0 var(--ink);
  animation: panelEnter 0.34s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.question-panel.side-right {
  right: 20px;
  left: auto;
}

.question-panel.side-left {
  left: 20px;
  right: auto;
}

@keyframes panelEnter {
  from { opacity: 0; transform: translateY(22px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

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

.q-type-badge {
  font-family: var(--font-display);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  padding: 4px 10px;
  border-radius: 99px;
  border: 2px solid var(--ink);
  background: var(--lilac);
  color: var(--white);
}

.q-step-badge {
  font-size: 0.84rem;
  font-weight: 800;
  color: #4b4263;
}

.mini-speak-btn {
  padding: 6px 12px;
  font-size: 0.88rem;
  border-radius: 12px;
  box-shadow: 0 3px 0 var(--ink);
}

.q-prompt {
  margin: 0 0 12px;
  font-family: var(--font-display);
  font-size: 1.28rem;
  line-height: 1.24;
  color: var(--ink);
}

.q-count-helper {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.count-btn {
  padding: 7px 14px;
  font-size: 0.94rem;
  border-radius: 13px;
  box-shadow: 0 3px 0 var(--ink);
}

.count-live-readout {
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--pink);
}

/* Fill in the blanks sentence */
.q-blanks-box {
  background: rgba(255, 255, 255, 0.9);
  border: 3px solid var(--ink);
  border-radius: 16px;
  padding: 11px 14px;
  margin-bottom: 12px;
  font-size: 1.04rem;
  font-weight: 800;
  line-height: 1.8;
}

.blank-slot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 84px;
  padding: 2px 10px;
  margin: 0 3px;
  border-radius: 11px;
  border: 2.5px dashed var(--ink);
  background: #fffbeb;
  font-family: var(--font-display);
  font-size: 1.04rem;
  color: var(--pink);
  cursor: pointer;
  vertical-align: middle;
  transition: transform 0.12s ease, background 0.15s ease;
}

.blank-slot.filled {
  border-style: solid;
  background: var(--yellow);
  color: var(--ink);
  box-shadow: 0 2px 0 var(--ink);
}

.blank-slot.active-slot {
  border-color: var(--pink);
  background: #ffe4ee;
}

.blank-slot.correct-slot {
  background: var(--green);
  color: var(--ink);
}

.blank-slot.wrong-slot {
  background: #fca5a5;
  color: var(--ink);
}

/* Options grid */
.q-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.q-options.single-col {
  grid-template-columns: 1fr;
}

.q-options.word-bank {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.option-btn {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  text-align: left;
  padding: 10px 13px;
  font-family: var(--font-display);
  font-size: 1.02rem;
  color: var(--ink);
  background: var(--white);
  border: 3px solid var(--ink);
  border-radius: 15px;
  box-shadow: 0 4px 0 var(--ink);
  cursor: pointer;
  transition: transform 0.12s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.12s ease, background 0.15s ease;
}

.option-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 var(--ink);
  background: #fffdf5;
}

.option-btn:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--ink);
}

.option-btn.word-tile {
  width: auto;
  min-height: 40px;
  padding: 8px 14px;
  background: var(--white);
}

.option-btn.word-tile.used {
  opacity: 0.38;
  transform: scale(0.95);
}

.option-btn.correct {
  background: var(--green) !important;
  color: var(--ink) !important;
  animation: correctPop 0.36s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.option-btn.wrong {
  background: #fca5a5 !important;
  animation: gentleShake 0.35s ease;
}

@keyframes correctPop {
  0% { transform: scale(1); }
  50% { transform: scale(1.06); }
  100% { transform: scale(1); }
}

@keyframes gentleShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.option-swatch {
  width: 24px;
  height: 24px;
  border-radius: 8px;
  border: 2.5px solid var(--ink);
  flex-shrink: 0;
  box-shadow: 1.5px 1.5px 0 var(--ink);
}

.q-blank-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 14px;
}

.q-blank-actions .sticker-btn {
  padding: 11px 20px;
  font-size: 1.1rem;
}

.q-feedback {
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: 18px;
  border: 3.5px solid var(--ink);
  background: var(--white);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.q-feedback.ok {
  background: #dcfce7;
}

.q-feedback.try-again {
  background: #fef3c7;
}

.q-feedback-text {
  font-weight: 800;
  font-size: clamp(1.05rem, 1.25vw, 1.22rem);
  line-height: 1.32;
}

.next-btn {
  flex-shrink: 0;
  padding: 12px 20px;
  font-size: 1.15rem;
}

/* ==================== 3D FLOATING COUNT BADGES ==================== */

.count-tag {
  position: absolute;
  transform: translate(-50%, -50%) scale(0);
  min-width: 42px;
  height: 42px;
  padding: 0 10px;
  border-radius: 99px;
  background: var(--yellow);
  color: var(--ink);
  border: 3.5px solid var(--ink);
  box-shadow: 0 4px 0 var(--ink);
  font-family: var(--font-display);
  font-size: 1.35rem;
  display: grid;
  place-items: center;
  animation: countPop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes countPop {
  from { transform: translate(-50%, -30%) scale(0.2); opacity: 0; }
  to { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

/* ==================== START & COLOUR MODAL OVERLAYS ==================== */

.overlay-screen {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(31, 26, 46, 0.38);
}

.start-card {
  width: min(590px, 100%);
  padding: 28px 30px;
  text-align: center;
  background: rgba(255, 246, 223, 0.95);
  box-shadow: 8px 8px 0 var(--ink);
}

.start-eyebrow {
  display: inline-block;
  padding: 5px 14px;
  border-radius: 99px;
  background: var(--sky);
  border: 2.5px solid var(--ink);
  font-family: var(--font-display);
  font-size: 0.9rem;
  margin-bottom: 10px;
}

.start-title {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 2.85rem);
  color: var(--pink);
  -webkit-text-stroke: 2px var(--ink);
  text-shadow: 0 4px 0 var(--ink);
  line-height: 1.05;
}

.start-desc {
  margin: 0 auto 16px;
  max-width: 480px;
  font-size: 1.02rem;
  font-weight: 700;
  line-height: 1.45;
  color: #352e4a;
}

.start-colour-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-bottom: 22px;
}

.dot-chip {
  background: var(--c);
  color: var(--white);
  font-family: var(--font-display);
  font-size: 0.88rem;
  padding: 5px 12px;
  border-radius: 99px;
  border: 2.5px solid var(--ink);
  box-shadow: 0 3px 0 var(--ink);
}

.start-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.start-tip {
  margin: 14px 0 0;
  font-size: 0.84rem;
  font-weight: 700;
  color: #5b5175;
}

/* Colour Warmup Modal */
.colour-modal-card {
  width: min(760px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px 26px;
  background: rgba(255, 246, 223, 0.97);
  box-shadow: 8px 8px 0 var(--ink);
}

.modal-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.85rem;
}

.modal-subtitle {
  margin: 8px 0 16px;
  font-weight: 700;
  color: #463d5e;
}

.colour-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}

.colour-learn-card {
  border: 3px solid var(--ink);
  border-radius: 18px;
  background: var(--white);
  box-shadow: 0 5px 0 var(--ink);
  padding: 12px;
  text-align: center;
  cursor: pointer;
  transition: transform 0.14s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.14s ease;
}

.colour-learn-card:hover {
  transform: translateY(-3px) rotate(-1deg);
  box-shadow: 0 8px 0 var(--ink);
}

.colour-learn-card:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 var(--ink);
}

.colour-learn-blob {
  width: 58px;
  height: 58px;
  margin: 0 auto 8px;
  border-radius: 18px;
  border: 3px solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  display: grid;
  place-items: center;
  font-size: 1.65rem;
}

.colour-learn-name {
  font-family: var(--font-display);
  font-size: 1.2rem;
}

.colour-learn-example {
  margin-top: 4px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #53496d;
}

.modal-footer {
  margin-top: 18px;
  text-align: center;
}

/* ==================== VICTORY & FREE EXPLORE ==================== */

.victory-panel {
  position: fixed;
  bottom: 22px;
  right: 22px;
  z-index: 35;
  width: min(410px, calc(100vw - 32px));
  padding: 22px 24px;
  text-align: center;
  background: rgba(255, 246, 223, 0.96);
  box-shadow: 7px 7px 0 var(--ink);
  animation: panelEnter 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.victory-stars {
  font-size: 1.8rem;
  letter-spacing: 6px;
  margin-bottom: 6px;
}

.victory-title {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 1.7rem;
  color: var(--pink);
}

.victory-desc {
  margin: 0 0 12px;
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.4;
}

.victory-score {
  display: inline-block;
  padding: 6px 16px;
  border-radius: 99px;
  background: var(--yellow);
  border: 2.5px solid var(--ink);
  font-family: var(--font-display);
  font-size: 1.05rem;
  margin-bottom: 16px;
}

.victory-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.explore-bar {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 26;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  background: rgba(255, 246, 223, 0.96);
  font-size: 0.92rem;
}

/* ==================== RESPONSIVE ==================== */

@media (max-width: 820px) {
  .minimap {
    width: 170px;
    top: 78px;
    left: 10px;
    right: auto;
    padding: 6px;
  }

  .question-panel.side-right,
  .question-panel.side-left {
    left: 10px;
    right: 10px;
    width: auto;
    bottom: 10px;
    max-height: 46vh;
    padding: 12px 14px 14px;
  }

  .q-prompt {
    font-size: 1.1rem;
    margin-bottom: 8px;
  }

  .q-blanks-box {
    padding: 8px 10px;
    margin-bottom: 8px;
    font-size: 0.94rem;
    line-height: 1.6;
  }

  .option-btn {
    min-height: 38px;
    padding: 7px 10px;
    font-size: 0.92rem;
  }

  .brand-title {
    font-size: 1rem;
  }
}
