/* ==========================================================================
   Little Notary Derrick World — Super Mario Bros. Wonder × Oak Valley Theme
   ========================================================================== */

@font-face {
  font-family: 'LND Display';
  src: url('../assets/brand/PermanentMarker-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --navy: #1E3A8A;
  --navy-deep: #0F2357;
  --gold: #FACC15;
  --gold-bright: #FEF08A;
  --gold-deep: #CA8A04;
  --crimson: #DC2626;
  --crimson-deep: #991B1B;
  --emerald: #16A34A;
  --emerald-deep: #15803D;
  --parchment: #FFFBEB;
  --parchment-warm: #FEF3C7;
  --ink: #0F172A;
  --muted-ink: #475569;
  --font-display: 'LND Display', 'Trebuchet MS', cursive, sans-serif;
  --font-ui: 'Nunito', 'Quicksand', 'Avenir Next', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --shadow-card: 0 14px 36px rgba(15, 23, 42, 0.34), 0 4px 0 rgba(15, 35, 87, 0.9);
  --shadow-pill: 0 6px 16px rgba(15, 23, 42, 0.28), 0 3px 0 rgba(15, 35, 87, 0.85);
}

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

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-ui);
  color: var(--ink);
  background: #0F2357;
  user-select: none;
  -webkit-user-select: none;
}

#app {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

#game-canvas-container {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

#game-canvas-container canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.hidden {
  display: none !important;
}

/* ==========================================================================
   Wonder Mode Edge Aura
   ========================================================================== */
.wonder-aura {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  box-shadow:
    inset 0 0 60px rgba(250, 204, 21, 0.55),
    inset 0 0 130px rgba(236, 72, 153, 0.32);
  animation: wonderPulse 1.1s ease-in-out infinite alternate;
}

@keyframes wonderPulse {
  from { opacity: 0.65; }
  to { opacity: 1; }
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 3px solid var(--navy-deep);
  border-radius: 999px;
  font-family: var(--font-display);
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
  box-shadow: 0 5px 0 var(--navy-deep), 0 10px 20px rgba(15, 23, 42, 0.25);
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover {
  transform: translateY(-2px) scale(1.02);
  filter: brightness(1.05);
}

.btn:active {
  transform: translateY(3px) scale(0.98);
  box-shadow: 0 2px 0 var(--navy-deep), 0 4px 10px rgba(15, 23, 42, 0.25);
}

.btn-xl {
  padding: 14px 30px;
  font-size: 1.3rem;
}

.btn-lg {
  padding: 11px 22px;
  font-size: 1.05rem;
}

.btn-md {
  padding: 9px 18px;
  font-size: 0.96rem;
}

.btn-sm {
  padding: 7px 14px;
  font-size: 0.85rem;
}

.btn-primary {
  background: linear-gradient(180deg, #22C55E 0%, var(--emerald) 100%);
  color: #FFFFFF;
  text-shadow: 0 2px 0 var(--emerald-deep);
}

.btn-gold {
  background: linear-gradient(180deg, #FDE047 0%, var(--gold) 100%);
  color: var(--navy-deep);
}

.btn-navy {
  background: linear-gradient(180deg, #2563EB 0%, var(--navy) 100%);
  color: #FFFFFF;
  text-shadow: 0 2px 0 var(--navy-deep);
}

.btn-crimson {
  background: linear-gradient(180deg, #EF4444 0%, var(--crimson) 100%);
  color: #FFFFFF;
  text-shadow: 0 2px 0 var(--crimson-deep);
}

.btn-parchment {
  background: linear-gradient(180deg, #FFFFFF 0%, var(--parchment-warm) 100%);
  color: var(--navy-deep);
}

/* ==========================================================================
   In-Game Mario HUD
   ========================================================================== */
.hud {
  position: absolute;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.hud-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
}

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

.hud-center {
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.hud-card {
  background: rgba(255, 251, 235, 0.94);
  border: 3px solid var(--navy);
  border-radius: 18px;
  box-shadow: var(--shadow-pill);
  backdrop-filter: blur(6px);
}

/* Hero Badge */
.hero-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 12px 5px 6px;
}

.hero-avatar-wrap {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #DBEAFE, #93C5FD);
  border: 2.5px solid var(--navy);
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  flex-shrink: 0;
}

.hero-avatar {
  height: 42px;
  width: auto;
  object-fit: contain;
}

.hero-vitals {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.hero-name-row {
  display: flex;
  align-items: center;
  gap: 7px;
}

.hero-tag {
  font-family: var(--font-display);
  font-size: 0.85rem;
  color: var(--navy);
  letter-spacing: 0.04em;
}

.lives-pill {
  background: var(--navy);
  color: var(--gold);
  font-weight: 900;
  font-size: 0.78rem;
  padding: 1px 7px;
  border-radius: 999px;
}

.hearts-row {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 1.05rem;
  line-height: 1;
}

.heart-full {
  color: var(--crimson);
  text-shadow: 0 1px 0 rgba(153, 27, 27, 0.4);
}

.heart-empty {
  color: #CBD5E1;
}

/* Active Stamp Buddy Pill */
.buddy-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 5px 6px;
  max-width: 225px;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.buddy-pill.is-empty {
  opacity: 0.88;
}

.buddy-pill-icon-wrap {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, #FEF9C3, #FDE047);
  border: 2px solid var(--navy);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.buddy-pill-img {
  width: 36px;
  height: 36px;
  object-fit: contain;
}

.buddy-pill-q {
  font-family: var(--font-display);
  font-size: 1.25rem;
  color: var(--navy);
}

.buddy-pill-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.buddy-pill-name {
  font-weight: 900;
  font-size: 0.78rem;
  color: var(--navy);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.buddy-pill-power {
  font-size: 0.71rem;
  font-weight: 700;
  color: var(--emerald-deep);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Center Docs Notarized Card */
.docs-card {
  padding: 6px 14px 8px;
  min-width: 270px;
  max-width: 360px;
}

.docs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 5px;
}

.level-code-badge {
  background: var(--crimson);
  color: #FFFFFF;
  font-family: var(--font-display);
  font-size: 0.82rem;
  padding: 1px 8px;
  border-radius: 8px;
  border: 2px solid var(--navy-deep);
}

.docs-label {
  font-family: var(--font-display);
  font-size: 0.84rem;
  color: var(--navy);
  letter-spacing: 0.04em;
}

.docs-count {
  font-weight: 900;
  font-size: 0.92rem;
  color: var(--emerald-deep);
}

.docs-bar-track {
  position: relative;
  height: 12px;
  border-radius: 999px;
  background: #E2E8F0;
  border: 2px solid var(--navy);
  overflow: hidden;
}

.docs-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #22C55E 0%, #FACC15 100%);
  border-radius: 999px;
  transition: width 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}

.docs-target-marker {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: rgba(30, 58, 138, 0.45);
}

/* Animated Combo Pill */
.combo-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 14px;
  border-radius: 999px;
  background: linear-gradient(135deg, #FACC15, #F97316);
  border: 2.5px solid var(--navy-deep);
  box-shadow: 0 4px 0 var(--navy-deep);
  color: var(--navy-deep);
  font-family: var(--font-display);
  animation: comboBounce 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.combo-value {
  font-size: 1rem;
  color: var(--crimson-deep);
}

.combo-label {
  font-size: 0.8rem;
}

@keyframes comboBounce {
  0% { transform: scale(0.7); }
  70% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

/* Top-Right Stats & Buttons */
.stats-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.1;
}

.stat-label {
  font-size: 0.62rem;
  font-weight: 900;
  color: var(--muted-ink);
  letter-spacing: 0.06em;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 1.02rem;
  color: var(--navy);
}

.seal-stat {
  flex-direction: row;
  gap: 5px;
}

.seal-coin {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #FEF08A, #EAB308);
  border: 2px solid var(--navy-deep);
  color: var(--crimson-deep);
  font-size: 0.85rem;
}

.stat-divider {
  width: 2px;
  height: 26px;
  background: rgba(30, 58, 138, 0.16);
  border-radius: 2px;
}

.time-stat.is-low .stat-value {
  color: var(--crimson);
  animation: pulseFast 0.6s ease-in-out infinite alternate;
}

@keyframes pulseFast {
  from { transform: scale(1); }
  to { transform: scale(1.12); }
}

.hud-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.hud-icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 3px solid var(--navy);
  background: var(--parchment);
  color: var(--navy);
  font-weight: 900;
  font-size: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--navy-deep);
  transition: transform 0.1s ease;
}

.hud-icon-btn:hover {
  transform: translateY(-2px);
}

.hud-icon-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--navy-deep);
}

/* Wonder Timer Bar */
.wonder-timer-wrap {
  align-self: center;
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 16px 6px 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(30, 58, 138, 0.95), rgba(109, 40, 217, 0.95));
  border: 3px solid var(--gold);
  box-shadow: 0 6px 20px rgba(250, 204, 21, 0.45);
  color: #FFFFFF;
  min-width: 340px;
}

.wonder-star-icon {
  width: 32px;
  height: 32px;
  object-fit: contain;
  animation: spinSlow 2.4s linear infinite;
}

@keyframes spinSlow {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.wonder-timer-content {
  flex: 1;
}

.wonder-timer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-family: var(--font-display);
  font-size: 0.78rem;
  color: var(--gold-bright);
  margin-bottom: 3px;
}

.wonder-track {
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
  overflow: hidden;
}

.wonder-fill {
  height: 100%;
  background: linear-gradient(90deg, #FACC15, #F472B6, #38BDF8);
  transition: width 0.08s linear;
}

/* Bottom Speech Bubble Toast */
.speech-toast {
  align-self: center;
  margin-top: auto;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 580px;
  padding: 10px 18px 10px 12px;
  background: rgba(255, 251, 235, 0.97);
  border: 3px solid var(--navy);
  border-radius: 20px;
  box-shadow: var(--shadow-pill);
  animation: toastSlideUp 0.22s ease-out;
}

@keyframes toastSlideUp {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

.speech-avatar-wrap {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: #FEF3C7;
  border: 2px solid var(--navy);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

.speech-avatar {
  width: 42px;
  height: 42px;
  object-fit: contain;
}

.speech-speaker {
  font-family: var(--font-display);
  font-size: 0.84rem;
  color: var(--crimson);
}

.speech-text {
  font-weight: 800;
  font-size: 0.94rem;
  color: var(--navy-deep);
  line-height: 1.25;
}

/* Touch Controls */
.touch-controls {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 8px 6px 2px;
  pointer-events: auto;
}

.touch-dpad,
.touch-actions {
  display: flex;
  gap: 10px;
}

.touch-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 3px solid var(--navy-deep);
  background: rgba(255, 251, 235, 0.88);
  color: var(--navy-deep);
  font-family: var(--font-display);
  font-size: 0.85rem;
  box-shadow: 0 4px 0 var(--navy-deep);
  cursor: pointer;
  touch-action: none;
}

.touch-btn.is-pressed {
  transform: translateY(3px);
  background: var(--gold);
}

.touch-jump {
  background: rgba(34, 197, 94, 0.92);
  color: #FFFFFF;
}

.touch-stamp {
  background: rgba(250, 204, 21, 0.94);
}

/* ==========================================================================
   Overlay Screens (Title, Map, Results)
   ========================================================================== */
.overlay-screen {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 18px 24px;
}

/* Title Screen lets the live 3D Oak Valley shine through! */
.screen-title {
  justify-content: space-between;
  background: linear-gradient(
    180deg,
    rgba(15, 35, 87, 0.42) 0%,
    rgba(15, 35, 87, 0.12) 48%,
    rgba(15, 35, 87, 0.56) 100%
  );
}

.title-topbar {
  width: 100%;
  max-width: 1220px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.title-topbar-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.clubhouse-back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255, 251, 235, 0.94);
  border: 3px solid var(--navy);
  color: var(--navy);
  font-weight: 800;
  font-size: 0.85rem;
  text-decoration: none;
  box-shadow: 0 4px 0 rgba(15, 35, 87, 0.25);
  transition: transform 0.12s ease, background 0.12s ease;
}

.clubhouse-back-link:hover {
  background: #FEF08A;
  transform: translateY(-1px);
}

.brand-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 16px;
  border-radius: 999px;
  background: rgba(255, 251, 235, 0.94);
  border: 3px solid var(--navy);
  box-shadow: var(--shadow-pill);
  font-weight: 900;
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  color: var(--navy);
}

.brand-pill-badge {
  width: 26px;
  height: 26px;
  object-fit: contain;
}

.title-center-stage {
  width: 100%;
  max-width: 1120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  margin-bottom: 8px;
}

.title-showcase {
  display: grid;
  grid-template-columns: 180px minmax(360px, 560px) 180px;
  align-items: end;
  justify-content: center;
  gap: 18px;
  width: 100%;
}

.showcase-buddy {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.showcase-buddy img {
  max-height: 155px;
  width: auto;
  filter: drop-shadow(0 12px 18px rgba(15, 23, 42, 0.45));
}

.buddy-float {
  animation: floatBob 2.6s ease-in-out infinite;
}

.buddy-float-alt {
  animation: floatBob 2.9s ease-in-out 0.6s infinite;
}

@keyframes floatBob {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-10px); }
}

.buddy-tag {
  background: var(--parchment);
  border: 2.5px solid var(--navy);
  border-radius: 999px;
  padding: 3px 12px;
  font-weight: 900;
  font-size: 0.78rem;
  color: var(--navy);
  box-shadow: 0 3px 0 var(--navy-deep);
}

.buddy-tag.gold-tag {
  background: var(--gold);
  color: var(--navy-deep);
}

.title-hero-core {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.title-logo-card {
  text-align: center;
  padding: 16px 28px 14px;
  background: linear-gradient(180deg, rgba(255, 251, 235, 0.96) 0%, rgba(254, 243, 199, 0.96) 100%);
  border: 4px solid var(--navy);
  border-radius: 26px;
  box-shadow: var(--shadow-card);
  width: 100%;
}

.title-eyebrow {
  display: inline-block;
  background: var(--crimson);
  color: #FFFFFF;
  font-weight: 900;
  font-size: 0.74rem;
  letter-spacing: 0.1em;
  padding: 3px 12px;
  border-radius: 999px;
  margin-bottom: 6px;
}

.game-title {
  margin: 0;
  font-family: var(--font-display);
  line-height: 0.96;
  letter-spacing: 0.02em;
}

.title-line-1 {
  display: block;
  font-size: clamp(1.85rem, 3.2vw, 2.55rem);
  color: var(--navy);
  text-shadow: 0 3px 0 #FFFFFF, 0 5px 0 rgba(30, 58, 138, 0.25);
}

.title-line-2 {
  display: block;
  font-size: clamp(2.2rem, 3.9vw, 3.1rem);
  color: var(--crimson);
  text-shadow: 0 3px 0 var(--gold), 0 6px 0 var(--navy-deep);
}

.title-tagline {
  margin: 8px 0 0;
  font-weight: 900;
  font-size: 0.94rem;
  color: var(--navy-deep);
}

.title-derrick-pedestal {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  height: 175px;
}

.title-derrick-art {
  max-height: 175px;
  width: auto;
  filter: drop-shadow(0 14px 20px rgba(15, 23, 42, 0.5));
}

.title-menu-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.title-footer-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  padding: 6px 16px;
  border-radius: 999px;
  background: rgba(15, 35, 87, 0.86);
  border: 2px solid rgba(250, 204, 21, 0.65);
  color: #FFFFFF;
  font-size: 0.78rem;
  font-weight: 800;
}

.title-footer-strip strong {
  color: var(--gold);
}

/* ==========================================================================
   Shared Panel Shell & Modals
   ========================================================================== */
.modal-backdrop {
  position: absolute;
  inset: 0;
  z-index: 50;
  background: rgba(15, 23, 42, 0.66);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.panel-shell {
  background: var(--parchment);
  border: 4px solid var(--navy);
  border-radius: 26px;
  box-shadow: var(--shadow-card);
  width: 100%;
  max-height: calc(100vh - 36px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 22px;
  background: linear-gradient(90deg, var(--navy) 0%, #2563EB 100%);
  color: #FFFFFF;
  border-bottom: 4px solid var(--gold);
}

.panel-header.center-header {
  justify-content: center;
  text-align: center;
}

.panel-kicker {
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  color: var(--gold-bright);
}

.panel-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.55rem;
  letter-spacing: 0.03em;
}

.panel-header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ==========================================================================
   Overworld Town Map Overlay
   ========================================================================== */
.screen-map {
  background: rgba(15, 35, 87, 0.58);
  backdrop-filter: blur(6px);
}

.map-shell {
  max-width: 1100px;
}

.map-board {
  position: relative;
  height: 350px;
  margin: 16px 20px 10px;
  border-radius: 20px;
  border: 3px solid var(--navy);
  background:
    radial-gradient(circle at 18% 20%, rgba(254, 240, 138, 0.5), transparent 40%),
    radial-gradient(circle at 82% 24%, rgba(187, 247, 208, 0.55), transparent 45%),
    linear-gradient(180deg, #DBEAFE 0%, #DCFCE7 48%, #BBF7D0 100%);
  overflow: hidden;
}

.map-road-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.map-nodes {
  position: relative;
  width: 100%;
  height: 100%;
}

.map-node {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 175px;
  padding: 10px 10px 8px;
  border-radius: 18px;
  border: 3px solid var(--navy);
  background: var(--parchment);
  box-shadow: 0 6px 0 var(--navy-deep), 0 10px 18px rgba(15, 23, 42, 0.24);
  cursor: pointer;
  text-align: center;
  transition: transform 0.14s ease, border-color 0.14s ease;
}

.map-node:hover:not(.is-locked) {
  transform: translate(-50%, -54%) scale(1.03);
}

.map-node.is-selected {
  border-color: var(--crimson);
  background: #FFFDF0;
  box-shadow: 0 6px 0 var(--crimson-deep), 0 0 0 4px rgba(250, 204, 21, 0.7);
}

.map-node.is-locked {
  opacity: 0.62;
  filter: grayscale(0.5);
  cursor: not-allowed;
}

.map-derrick-pin {
  position: absolute;
  top: -46px;
  left: 50%;
  transform: translateX(-50%);
  height: 50px;
  filter: drop-shadow(0 4px 6px rgba(15, 23, 42, 0.4));
  animation: floatBob 1.8s ease-in-out infinite;
  pointer-events: none;
}

.map-node-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.map-node-code {
  background: var(--navy);
  color: var(--gold);
  font-family: var(--font-display);
  font-size: 0.8rem;
  padding: 1px 8px;
  border-radius: 999px;
}

.map-node-rank {
  font-family: var(--font-display);
  font-size: 0.84rem;
  color: var(--emerald-deep);
}

.map-node-name {
  font-weight: 900;
  font-size: 0.84rem;
  color: var(--navy-deep);
  line-height: 1.2;
}

.map-node-meta {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted-ink);
  margin-top: 3px;
}

.map-selected-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 22px 16px;
  background: var(--parchment-warm);
  border-top: 3px solid rgba(30, 58, 138, 0.15);
}

.map-selected-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.map-sel-name {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.2rem;
  color: var(--navy);
}

.map-sel-meta {
  margin: 2px 0 0;
  font-size: 0.84rem;
  font-weight: 800;
  color: var(--muted-ink);
}

/* ==========================================================================
   Stamp Buddies & Cast Almanac Modal
   ========================================================================== */
.almanac-shell {
  max-width: 1080px;
}

.almanac-scroll {
  padding: 16px 20px 22px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.almanac-spotlight-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.cast-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 18px;
  border: 3px solid var(--navy);
  background: #FFFFFF;
  box-shadow: 0 4px 0 rgba(30, 58, 138, 0.2);
}

.cast-card.spotlight-card {
  background: linear-gradient(135deg, #FEF9C3 0%, #FFFFFF 100%);
}

.cast-portrait-box {
  width: 78px;
  height: 78px;
  border-radius: 14px;
  background: radial-gradient(circle at 30% 30%, #EFF6FF, #DBEAFE);
  border: 2px solid var(--navy);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 4px;
}

.cast-portrait-box img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.cast-name {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.02rem;
  color: var(--navy);
}

.cast-role {
  font-size: 0.74rem;
  font-weight: 900;
  color: var(--crimson);
  margin: 2px 0 4px;
}

.cast-power {
  display: inline-block;
  background: #DCFCE7;
  color: var(--emerald-deep);
  border: 1.5px solid var(--emerald);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 0.72rem;
  font-weight: 900;
  margin-bottom: 4px;
}

.cast-desc {
  margin: 0;
  font-size: 0.77rem;
  font-weight: 700;
  color: var(--muted-ink);
  line-height: 1.28;
}

.cast-quote {
  margin: 4px 0 0;
  font-size: 0.74rem;
  font-style: italic;
  font-weight: 700;
  color: var(--navy-deep);
}

.buddies-section-title {
  margin: 2px 0 0;
  font-family: var(--font-display);
  font-size: 1.15rem;
  color: var(--navy);
}

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

/* ==========================================================================
   How To Play & Pause Modals
   ========================================================================== */
.howto-shell {
  max-width: 860px;
}

.howto-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  padding: 18px 22px 22px;
  overflow-y: auto;
}

.howto-card {
  background: #FFFFFF;
  border: 3px solid var(--navy);
  border-radius: 18px;
  padding: 14px 16px;
}

.howto-card h3 {
  margin: 0 0 10px;
  font-family: var(--font-display);
  color: var(--crimson);
  font-size: 1.15rem;
}

.key-list,
.rule-list {
  margin: 0;
  padding-left: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.86rem;
  font-weight: 700;
}

.key-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px dashed #E2E8F0;
  padding-bottom: 6px;
}

kbd {
  background: var(--navy);
  color: var(--gold);
  padding: 2px 7px;
  border-radius: 6px;
  font-family: var(--font-ui);
  font-weight: 900;
  font-size: 0.76rem;
}

.rule-list {
  padding-left: 16px;
  list-style: disc;
}

.pause-shell {
  max-width: 420px;
}

.pause-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 20px 26px 24px;
}

/* ==========================================================================
   Level Clear, Victory Parade & Game Over Screens
   ========================================================================== */
.result-shell,
.gameover-shell {
  max-width: 760px;
}

.victory-shell {
  max-width: 880px;
}

.result-banner {
  padding: 14px 22px;
  text-align: center;
  color: #FFFFFF;
  border-bottom: 4px solid var(--gold);
}

.emerald-banner {
  background: linear-gradient(90deg, var(--emerald-deep), var(--emerald));
}

.gold-banner {
  background: linear-gradient(90deg, var(--navy), #7C3AED, var(--crimson));
}

.crimson-banner {
  background: linear-gradient(90deg, var(--crimson-deep), var(--crimson));
}

.result-body {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 18px;
  padding: 18px 24px 12px;
  align-items: center;
}

.result-hero-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.result-derrick-img {
  height: 165px;
  object-fit: contain;
  filter: drop-shadow(0 8px 14px rgba(15, 23, 42, 0.25));
}

.rank-badge {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  border: 4px solid var(--navy-deep);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 1.7rem;
  box-shadow: 0 5px 0 var(--navy-deep);
}

.rank-S\+,
.rank-S {
  background: linear-gradient(135deg, #FEF08A, #F59E0B);
  color: var(--crimson-deep);
}

.rank-A {
  background: linear-gradient(135deg, #86EFAC, #16A34A);
  color: #FFFFFF;
}

.rank-B {
  background: linear-gradient(135deg, #93C5FD, #2563EB);
  color: #FFFFFF;
}

.tally-table {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #FFFFFF;
  border: 3px solid var(--navy);
  border-radius: 18px;
  padding: 12px 16px;
}

.tally-row {
  display: flex;
  justify-content: space-between;
  font-weight: 800;
  font-size: 0.94rem;
  padding-bottom: 5px;
  border-bottom: 1px dashed #E2E8F0;
}

.tally-row strong {
  color: var(--navy);
}

.tally-total {
  border-bottom: none;
  padding-top: 4px;
  font-family: var(--font-display);
  font-size: 1.2rem;
  color: var(--crimson);
}

.tally-total strong {
  color: var(--crimson);
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  padding: 10px 22px 20px;
}

/* Victory Parade */
.victory-stage {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 24px;
  padding: 12px 20px 0;
}

.victory-center-art {
  height: 148px;
  object-fit: contain;
  filter: drop-shadow(0 10px 14px rgba(15, 23, 42, 0.3));
}

.victory-side-art {
  height: 108px;
  object-fit: contain;
  animation: floatBob 2.4s ease-in-out infinite;
}

.victory-quote {
  text-align: center;
  margin: 8px 24px 10px;
  font-weight: 900;
  font-size: 0.96rem;
  color: var(--navy);
}

.victory-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding: 0 22px;
}

.victory-stat-pill {
  background: #FFFFFF;
  border: 3px solid var(--navy);
  border-radius: 16px;
  padding: 8px 10px;
  text-align: center;
}

.victory-stat-pill span {
  display: block;
  font-size: 0.68rem;
  font-weight: 900;
  color: var(--muted-ink);
}

.victory-stat-pill strong {
  font-family: var(--font-display);
  font-size: 1.18rem;
  color: var(--crimson);
}

.victory-parade-strip {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 22px 4px;
}

.parade-mini-buddy {
  width: 42px;
  height: 42px;
  object-fit: contain;
  background: #FFFFFF;
  border: 2px solid var(--navy);
  border-radius: 10px;
  padding: 3px;
}

/* Game Over */
.gameover-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 24px 6px;
  text-align: center;
}

.gameover-derrick-img {
  height: 140px;
  object-fit: contain;
}

.gameover-quote {
  margin: 0;
  font-weight: 800;
  color: var(--navy);
}

.gameover-score-line {
  font-weight: 900;
  color: var(--muted-ink);
}

/* Error Banner */
.error-banner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 100;
  max-width: 520px;
  background: var(--parchment);
  border: 4px solid var(--crimson);
  border-radius: 20px;
  padding: 20px 24px;
  box-shadow: var(--shadow-card);
  text-align: center;
}

/* ==========================================================================
   Responsive Adjustments (1280x800, 1440x900, and smaller viewports)
   ========================================================================== */
@media (max-height: 820px) {
  .title-showcase {
    grid-template-columns: 160px minmax(340px, 520px) 160px;
  }
  .showcase-buddy img {
    max-height: 130px;
  }
  .title-derrick-pedestal {
    height: 145px;
  }
  .title-derrick-art {
    max-height: 145px;
  }
  .map-board {
    height: 310px;
  }
}

@media (max-width: 900px) {
  .title-showcase {
    grid-template-columns: 1fr;
  }
  .showcase-buddy {
    display: none;
  }
  .howto-grid,
  .almanac-spotlight-row,
  .result-body,
  .victory-stats {
    grid-template-columns: 1fr;
  }
  .hud-top {
    flex-wrap: wrap;
  }
}
