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

html, body {
  width: 100%;
  height: 100dvh;
  background: #eaeae4;
  color: #111111;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hidden {
  display: none !important;
}

.app-shell {
  position: relative;
  width: 100%;
  max-width: 460px;
  height: 100dvh;
  max-height: 100dvh;
  margin: 0 auto;
  background: #ffffff;
  border-left: 2px solid #111111;
  border-right: 2px solid #111111;
  overflow: hidden;
}

@media (max-width: 600px) {
  .app-shell {
    max-width: 100vw;
    border-left: none;
    border-right: none;
  }
}

/* Smooth Screen Transitions */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  width: 100%;
  height: 100%;
  opacity: 0;
  transform: translateY(14px) scale(0.975);
  transition:
    opacity 0.55s cubic-bezier(0.25, 1, 0.5, 1),
    transform 0.55s cubic-bezier(0.25, 1, 0.5, 1);
}

.screen.active {
  display: flex;
  opacity: 1;
  transform: translateY(0) scale(1);
}

.screen.fading-out {
  display: flex;
  opacity: 0;
  transform: translateY(-10px) scale(1.015);
  pointer-events: none;
}

/* 1. Splash Logo Screen */
.splash-screen {
  background: #000000;
  align-items: center;
  justify-content: center;
  z-index: 50;
  transform: scale(1.02);
  transition: opacity 0.65s cubic-bezier(0.25, 1, 0.5, 1), transform 0.65s cubic-bezier(0.25, 1, 0.5, 1);
}

.splash-screen.active {
  transform: scale(1);
}

.splash-screen.fading-out {
  transform: scale(0.97);
}

.splash-logo {
  width: min(82%, 340px);
  max-height: 60vh;
  object-fit: contain;
  opacity: 0;
  transform: scale(0.9) translateY(8px);
  transition: opacity 0.85s cubic-bezier(0.25, 1, 0.5, 1), transform 0.85s cubic-bezier(0.25, 1, 0.5, 1);
}

.splash-logo.show {
  opacity: 1;
  transform: scale(1) translateY(0);
}

.splash-logo.hide {
  opacity: 0;
  transform: scale(0.95) translateY(-6px);
}

/* 1b. Story Video Screen */
.story-screen {
  background: #000000;
  align-items: center;
  justify-content: center;
  z-index: 45;
  transform: scale(1.03);
  transition: opacity 0.6s cubic-bezier(0.25, 1, 0.5, 1), transform 0.6s cubic-bezier(0.25, 1, 0.5, 1);
}

.story-screen.active {
  transform: scale(1);
}

.story-screen.fading-out {
  transform: scale(0.98);
}

.story-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000000;
  transform: translateZ(0);
  will-change: transform;
  backface-visibility: hidden;
}

.story-vignette {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.32) 0%,
    rgba(0, 0, 0, 0) 22%,
    rgba(0, 0, 0, 0) 80%,
    rgba(0, 0, 0, 0.35) 100%
  );
  pointer-events: none;
}

/* Center Circle Sound Button Only */
.story-center-trigger {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.story-center-trigger.dismissed {
  display: none !important;
}

.story-center-circle-btn {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: #ffffff;
  color: #111111;
  border: 2.5px solid #111111;
  box-shadow: 4px 4px 0 #dc2626;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease;
}

.story-center-circle-btn:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 #dc2626;
}

.center-watch-label {
  font-size: 0.92rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: #ffffff;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.9), 0 0 4px rgba(0, 0, 0, 0.95);
  white-space: nowrap;
}

.story-top-actions {
  position: absolute;
  top: 18px;
  left: 18px;
  right: 18px;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
}

.story-icon-btn {
  pointer-events: auto;
  width: 42px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #111111;
  background: rgba(255, 255, 255, 0.94);
  border: 2px solid #111111;
  border-radius: 12px;
  box-shadow: 3px 3px 0 #111111;
  cursor: pointer;
}

.story-icon-btn.muted-state {
  background: #111111;
  color: #ffffff;
}

.story-icon-btn:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 #111111;
}

.story-action-btn {
  pointer-events: auto;
  padding: 9px 15px;
  font-size: 0.8rem;
  font-weight: 900;
  letter-spacing: 1px;
  color: #111111;
  background: rgba(255, 255, 255, 0.94);
  border: 2px solid #111111;
  border-radius: 12px;
  box-shadow: 3px 3px 0 #111111;
  cursor: pointer;
}

.skip-btn {
  display: none;
}

.skip-btn.visible {
  display: inline-block;
}

.story-action-btn:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 #111111;
}

/* 1c. Post-Story Description Screen */
.story-note-screen {
  background: #000000;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 44;
  transition: opacity 0.65s cubic-bezier(0.25, 1, 0.5, 1), transform 0.65s cubic-bezier(0.25, 1, 0.5, 1);
}

.story-note-box {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.story-note-text {
  font-size: 1.02rem;
  line-height: 1.7;
  font-weight: 600;
  color: #ffffff;
  text-align: left;
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.85s ease, transform 0.85s ease;
}

.story-note-text.reveal {
  opacity: 1;
  transform: translateY(0);
}

.story-note-footer {
  display: flex;
  justify-content: flex-end;
}

.story-ok-btn {
  padding: 10px 24px;
  font-size: 0.92rem;
  font-weight: 900;
  letter-spacing: 1.2px;
  background: #ffffff;
  color: #000000;
  border: 2px solid #ffffff;
  border-radius: 999px;
  cursor: pointer;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.55s ease 0.3s, transform 0.55s ease 0.3s;
}

.story-ok-btn.reveal {
  opacity: 1;
  transform: translateY(0);
}

.story-ok-btn:active {
  transform: translateY(2px);
}

/* 2. Home Screen */
.home-screen {
  background-image: url('campus-bg.jpg');
  background-size: cover;
  background-position: center;
  justify-content: center;
  align-items: center;
  opacity: 0;
  transform: translateY(18px) scale(1.03);
  transition:
    opacity 0.75s cubic-bezier(0.25, 1, 0.5, 1),
    transform 0.75s cubic-bezier(0.25, 1, 0.5, 1);
}

.home-screen.active {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.home-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.35);
}

.home-content {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 320px;
  padding: 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.game-title {
  width: 100%;
  font-size: clamp(2rem, 7.5vw, 2.6rem);
  font-weight: 900;
  letter-spacing: 2px;
  color: #111111;
  background: rgba(255, 255, 255, 0.95);
  border: 2px solid #111111;
  border-radius: 14px;
  padding: 10px 14px;
  box-shadow: 4px 4px 0 #111111;
  margin-bottom: 18px;
}

.home-actions {
  width: 100%;
  max-width: 245px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

/* Rounder Buttons */
.btn {
  width: 100%;
  padding: 14px 18px;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 1.2px;
  border: 2px solid #111111;
  border-radius: 14px;
  cursor: pointer;
}

.home-actions .btn {
  padding: 10px 14px;
  font-size: 0.88rem;
  letter-spacing: 1px;
  border-radius: 12px;
}

.btn.primary {
  background: #111111;
  color: #ffffff;
  box-shadow: 3px 3px 0 #dc2626;
}

.btn.secondary {
  background: rgba(255, 255, 255, 0.96);
  color: #111111;
  box-shadow: 3px 3px 0 #111111;
}

.btn:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 #111111;
}

.btn.primary:active {
  box-shadow: 1px 1px 0 #dc2626;
}

/* 2b. Credits Screen */
.credits-screen {
  background: #f6f6f2;
}

.credits-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
}

.credits-serial-list {
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.credit-item {
  background: #ffffff;
  color: #111111;
  border: 2px solid #111111;
  border-radius: 999px;
  padding: 13px 20px;
  text-align: center;
  font-size: 1.08rem;
  font-weight: 900;
  letter-spacing: 0.6px;
  box-shadow: 3px 3px 0 #111111;
  opacity: 0;
  transform: translateY(16px) scale(0.96);
  transition: opacity 0.45s ease, transform 0.45s ease;
}

.credit-item.shown {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* Shared Top Bar */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: #ffffff;
  border-bottom: 2px solid #111111;
  z-index: 12;
}

.top-bar h2 {
  font-size: 0.95rem;
  font-weight: 900;
  letter-spacing: 1px;
}

.mini-btn {
  padding: 6px 11px;
  font-size: 0.74rem;
  font-weight: 800;
  background: #ffffff;
  color: #111111;
  border: 2px solid #111111;
  border-radius: 9px;
  cursor: pointer;
}

.badge {
  padding: 5px 9px;
  font-size: 0.68rem;
  font-weight: 800;
  background: #111111;
  color: #ffffff;
  border-radius: 9px;
}

/* 3. Level Select Screen (Interactive Campus Map) */
.level-screen {
  background: #0f172a;
}

.map-viewport {
  position: relative;
  flex: 1;
  width: 100%;
  height: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  background: #1e293b;
}

.map-canvas-wrap {
  position: relative;
  height: 100%;
  width: max(1350px, 315dvh);
}

.campus-map-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

.map-route-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
}

.map-pins-layer {
  position: absolute;
  inset: 0;
  z-index: 4;
}

.map-pin {
  position: absolute;
  transform: translate(-50%, -100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  opacity: 0;
  transition: opacity 0.35s ease, transform 0.25s ease;
}

.map-pin.serial-show {
  opacity: 1;
}

.map-pin:not(.locked):active {
  transform: translate(-50%, -100%) scale(0.92);
}

.map-pin.locked {
  cursor: not-allowed;
  opacity: 0.85;
}

.pin-bubble {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 999px;
  background: #ffffff;
  color: #111111;
  border: 2.2px solid #111111;
  box-shadow: 2px 3px 0 #111111;
  white-space: nowrap;
  font-size: 0.74rem;
  font-weight: 900;
  transition: box-shadow 0.3s ease, background 0.3s ease, transform 0.3s ease;
}

.map-pin.completed .pin-bubble {
  background: #dcfce7;
  border-color: #15803d;
  box-shadow: 2px 3px 0 #15803d;
}

.map-pin.locked .pin-bubble {
  background: rgba(226, 232, 240, 0.92);
  color: #475569;
  border-color: #64748b;
  box-shadow: 2px 2px 0 #475569;
}

.pin-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #dc2626;
  color: #ffffff;
  font-size: 0.68rem;
  font-weight: 900;
}

.map-pin.completed .pin-num {
  background: #16a34a;
}

.map-pin.locked .pin-num {
  background: #64748b;
}

.pin-pointer {
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 8px solid #111111;
  margin-top: -1px;
}

.map-pin.locked .pin-pointer {
  border-top-color: #64748b;
}

.pin-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #dc2626;
  border: 2px solid #ffffff;
  box-shadow: 0 0 0 2px #111111;
  margin-top: 2px;
}

.map-pin.completed .pin-dot {
  background: #16a34a;
}

.map-pin.locked .pin-dot {
  background: #64748b;
  box-shadow: 0 0 0 2px #475569;
}

/* Glowing Lighting Effect for Current Active Level */
@keyframes activePinLighting {
  0%, 100% {
    box-shadow:
      0 0 0 2px #111111,
      0 0 14px 4px rgba(250, 204, 21, 0.95),
      0 0 26px 8px rgba(239, 68, 68, 0.75);
    transform: scale(1.06);
  }
  50% {
    box-shadow:
      0 0 0 2px #111111,
      0 0 22px 8px rgba(253, 224, 71, 1),
      0 0 38px 14px rgba(239, 68, 68, 0.95);
    transform: scale(1.12);
  }
}

@keyframes activeDotRing {
  0%, 100% {
    box-shadow:
      0 0 0 2px #111111,
      0 0 10px 4px rgba(250, 204, 21, 0.95);
  }
  50% {
    box-shadow:
      0 0 0 2px #111111,
      0 0 18px 8px rgba(239, 68, 68, 1);
  }
}

.map-pin.current-level {
  z-index: 9;
}

.map-pin.current-level .pin-bubble {
  background: #fef08a;
  border-color: #111111;
  animation: activePinLighting 1.6s ease-in-out infinite;
}

.map-pin.current-level .pin-dot {
  background: #facc15;
  animation: activeDotRing 1.6s ease-in-out infinite;
}

.map-hint-pill {
  position: sticky;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  width: fit-content;
  z-index: 10;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(17, 17, 17, 0.86);
  color: #ffffff;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.4px;
  border: 1.5px solid rgba(255, 255, 255, 0.35);
  pointer-events: none;
}

/* 4. Gameplay Screen */
.hud {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  border-bottom: 2px solid #111111;
  background: #ffffff;
  z-index: 12;
}

.hud-cell {
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  border-right: 2px solid #111111;
}

.hud-label {
  font-size: 0.68rem;
  font-weight: 800;
  color: #555555;
  letter-spacing: 0.8px;
}

.hud-val {
  font-size: 1.2rem;
  font-weight: 900;
}

.hud-exit {
  padding: 0 14px;
  font-size: 0.78rem;
  font-weight: 800;
  background: #f5f5f0;
  color: #111111;
  border: none;
  cursor: pointer;
}

.stage-wrap {
  position: relative;
  flex: 1;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #f9f9f6;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* Left & Right Full-Side Touch Zones Inside Canvas */
.side-touch-zone {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50%;
  z-index: 4;
  touch-action: none;
}

.left-zone {
  left: 0;
}

.right-zone {
  right: 0;
}

/* Controls Placed Lower Inside Canvas Bottom */
.canvas-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 24px;
  padding: 0 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 8;
  pointer-events: none;
}

.ctrl-btn.circle-ctrl {
  pointer-events: auto;
  width: 94px;
  height: 94px;
  border-radius: 50%;
  border: 2.5px solid #111111;
  font-size: 0.96rem;
  font-weight: 900;
  letter-spacing: 0.8px;
  background: rgba(255, 255, 255, 0.92);
  color: #111111;
  box-shadow: 0 4px 0 #111111;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.ctrl-btn.circle-ctrl.primary {
  background: rgba(17, 17, 17, 0.92);
  color: #ffffff;
  box-shadow: 0 4px 0 #dc2626;
}

.ctrl-btn.circle-ctrl:active,
.ctrl-btn.circle-ctrl.active-press {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #111111;
}

.ctrl-btn.circle-ctrl.primary:active,
.ctrl-btn.circle-ctrl.primary.active-press {
  box-shadow: 0 1px 0 #dc2626;
}

/* Pre-Level 3-2-1 Countdown Overlay */
.countdown-overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.35);
  z-index: 15;
  pointer-events: none;
}

.countdown-overlay.active {
  display: flex;
}

.countdown-number {
  font-size: 4.2rem;
  font-weight: 900;
  color: #111111;
  background: #ffffff;
  border: 3px solid #111111;
  border-radius: 999px;
  width: 112px;
  height: 112px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 5px 5px 0 #dc2626;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.24s ease, transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

.countdown-number.pop {
  opacity: 1;
  transform: scale(1.06);
}

/* 5. Game Finale Screen */
.finale-screen {
  background: #09090b;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 48;
  transition: opacity 0.85s ease, transform 0.85s ease;
}

.finale-card {
  width: 100%;
  max-width: 320px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.finale-line-main {
  color: #ffffff;
  font-size: 1.65rem;
  font-weight: 900;
  letter-spacing: 0.6px;
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.95s ease, transform 0.95s ease;
}

.finale-line-main.show {
  opacity: 1;
  transform: translateY(0);
}

.finale-line-sub {
  color: #e4e4e7;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.4px;
  margin-bottom: 12px;
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.95s ease, transform 0.95s ease;
}

.finale-line-sub.show {
  opacity: 1;
  transform: translateY(0);
}

.finale-btn {
  max-width: 220px;
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}

.finale-btn.show {
  opacity: 1;
  transform: translateY(0);
}

/* Modals & Quit Screen */
.modal {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(255, 255, 255, 0.9);
  z-index: 20;
}

.modal.active {
  display: flex;
}

.quit-screen {
  background: #f4f4f0;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-card {
  width: 100%;
  max-width: 320px;
  background: #ffffff;
  border: 2px solid #111111;
  border-radius: 14px;
  padding: 22px 18px;
  text-align: center;
  box-shadow: 4px 4px 0 #111111;
}

.modal-tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 1px;
  padding: 4px 9px;
  border: 1.5px solid #111111;
  border-radius: 9px;
  background: #e5e7eb;
  margin-bottom: 10px;
}

.modal-tag.win {
  background: #dcfce7;
}

.modal-tag.fail {
  background: #fee2e2;
}

.modal-card h3 {
  font-size: 1.35rem;
  font-weight: 900;
  margin-bottom: 8px;
}

.modal-sub {
  font-size: 0.9rem;
  color: #333333;
  margin-bottom: 16px;
}

.modal-card .btn + .btn {
  margin-top: 10px;
}