@import url('https://fonts.googleapis.com/css2?family=Andika:ital,wght@0,400;0,700;1,400;1,700&display=swap');

:root {
  --color-forest: #3E7843;
  --color-forest-hover: #4e9454;
  --color-forest-dark: #2a522e;
  --color-gold: #f8b800;
  --color-border: #000000;
  --bg-dark: #121e14;
  --panel-bg: #ffffff;
  
  /* 7 RIU European Common Values Theme Colors */
  --theme-1: #F89700;
  --theme-2: #F55803;
  --theme-3: #8161E1;
  --theme-4: #A57102;
  --theme-5: #2CB535;
  --theme-6: #0284c7;
  --theme-7: #CE72B7;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Andika', sans-serif;
  background-color: #f4f4f2;
  background-image: url('../img/fundo.png'), url('./img/fundo.png'), url('https://riu.advancis.pt/img/fundo.png');
  background-repeat: repeat;
  background-position: center;
  color: #1a1a1a;
  touch-action: manipulation;
}

/* App Root Container */
#game-app {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
  position: relative;
}

/* =========================================================
   TOP HEADER BAR (Single Floating Rounded Glassmorphic Card)
   ========================================================= */
#header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
  min-height: 52px;
  margin: 6px 10px 2px 10px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 20px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  padding: 0 12px;
  z-index: 20;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
  gap: 10px;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  flex-shrink: 0;
}

.header-logo {
  width: 34px;
  height: 34px;
  object-fit: contain;
  border-radius: 6px;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.brand-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--color-forest);
  text-transform: uppercase;
}

.brand-subtitle {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #1a1a1a;
  text-transform: uppercase;
}

/* Integrated HUD Stats Group */
.header-stats-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  justify-content: center;
  overflow-x: auto;
  scrollbar-width: none;
}
.header-stats-group::-webkit-scrollbar {
  display: none;
}

.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 999px;
  padding: 0 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  font-size: 12px;
  font-weight: 700;
  color: #1a1a1a;
  white-space: nowrap;
  flex-shrink: 0;
}

.stat-icon-img {
  width: 16px;
  height: 16px;
  object-fit: contain;
}

.stat-label {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #555555;
}

.stat-val {
  font-size: 13px;
  font-weight: 800;
  color: #000000;
}

.stat-val.highlight {
  color: #b45309;
}

/* Card deck inside stat pill */
.hud-cards-deck {
  display: flex;
  align-items: center;
  gap: 3px;
  margin-left: 2px;
}

.hud-card-slot {
  width: 9px;
  height: 13px;
  border-radius: 2px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  background: #e5e7eb;
  transition: all 0.2s ease;
}

.hud-card-slot.collected {
  background: #2CB535;
  border-color: #2CB535;
  box-shadow: 0 0 4px rgba(44, 181, 53, 0.7);
  transform: translateY(-1px);
}

/* Lives */
.hud-lives-wrap {
  display: flex;
  align-items: center;
  gap: 2px;
}

.hud-life-heart {
  font-size: 13px;
  line-height: 1;
}

.hud-life-heart.lost {
  filter: grayscale(1) opacity(0.3);
}

/* Surge pill */
.surge-pill {
  display: none;
  background: #0284c7;
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.2);
  animation: surge-pulse 0.7s infinite alternate;
}

.surge-pill.active {
  display: inline-flex;
}

.surge-bolt {
  font-size: 13px;
}

.surge-text {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  color: #ffffff;
}

.surge-timer {
  background: rgba(0, 0, 0, 0.25);
  padding: 1px 6px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 800;
  color: #ffffff;
}

@keyframes surge-pulse {
  from { transform: scale(1); box-shadow: 0 4px 14px rgba(2, 132, 199, 0.3); }
  to { transform: scale(1.05); box-shadow: 0 6px 20px rgba(2, 132, 199, 0.5), 0 0 8px #38bdf8; }
}

/* 2P Active Turn Pill */
.active-turn-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #edf7ee;
  border: 1px solid rgba(62, 120, 67, 0.25);
  border-radius: 999px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
  color: var(--color-forest-dark);
}

.active-turn-pill .pill-avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.1);
  background: #fff;
  object-fit: cover;
}

/* Right Group: Lang pills & Circular Monochrome SVG Buttons */
.header-right-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.lang-pills-bar {
  display: flex;
  align-items: center;
  gap: 3px;
  background: rgba(237, 240, 237, 0.85);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 999px;
  padding: 2px 4px;
}

.lang-pill {
  border: none;
  background: transparent;
  padding: 3px 8px;
  border-radius: 12px;
  font-family: 'Andika', sans-serif;
  font-size: 11px;
  font-weight: 800;
  color: #444444;
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1;
}

.lang-pill:hover:not(.active) {
  background: rgba(216, 226, 216, 0.8);
  color: #000000;
}

.lang-pill.active {
  background: var(--color-forest);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(62, 120, 67, 0.3);
  transform: scale(1.04);
}

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

.header-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  min-width: 38px;
  min-height: 38px;
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  color: #1a1a1a;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}

.header-btn:hover {
  background: var(--color-forest);
  color: #ffffff;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(62, 120, 67, 0.25);
}

.header-btn:active {
  transform: scale(0.95);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}

.header-btn.primary-btn {
  background: var(--color-forest);
  color: #ffffff;
}

.header-btn.primary-btn:hover {
  background: var(--color-forest-hover);
  color: #ffffff;
}

.header-icon-svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
}

/* =========================================================
   MAZE VIEWPORT (ZERO SCROLLING WIDESCREEN 27x15 CALC)
   ========================================================= */
#maze-viewport {
  flex: 1;
  width: 100%;
  height: calc(100vh - 84px);
  max-height: calc(100vh - 84px);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  padding: 4px 8px;
}

#game-canvas {
  display: block;
  background: #f7f3e8;
  border-radius: 18px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.08);
  max-width: 100%;
  max-height: 100%;
}

/* Turn Transition Overlay */
#turn-banner-overlay {
  display: none;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(18, 30, 20, 0.94);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 20px;
  padding: 24px 32px;
  text-align: center;
  color: #fff;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.3);
  z-index: 30;
}

#turn-banner-overlay.show {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

/* Pause Banner Overlay */
#pause-banner-overlay {
  display: none;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(18, 30, 20, 0.94);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-radius: 20px;
  padding: 24px 36px;
  text-align: center;
  color: #fff;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
  z-index: 35;
}

#pause-banner-overlay.show {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

/* Floating Arcade Messages */
#arcade-message-toast {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: rgba(255, 204, 0, 0.95);
  color: #1a1a1a;
  border: none;
  box-shadow: 0 4px 14px rgba(255, 204, 0, 0.2);
  border-radius: 20px;
  padding: 6px 18px;
  font-size: 14px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
  z-index: 25;
}

#arcade-message-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* =========================================================
   BOTTOM BAR & MOBILE ON-SCREEN D-PAD
   ========================================================= */
#controls-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 26px;
  min-height: 26px;
  background: #0e170f;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding: 0 14px;
  color: #9cb89f;
  font-size: 11px;
  z-index: 10;
}

.controls-tips {
  display: flex;
  align-items: center;
  gap: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dpad-toggle-btn {
  background: transparent;
  border: none;
  color: #c4dcc6;
  font-family: 'Andika', sans-serif;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
}

/* Touch D-Pad */
#touch-dpad-container {
  display: none;
  position: fixed;
  bottom: 34px;
  right: 18px;
  width: 130px;
  height: 130px;
  z-index: 40;
  touch-action: none;
}

@media (max-width: 900px), (pointer: coarse) {
  #touch-dpad-container.active {
    display: block;
  }
}

.dpad-btn {
  position: absolute;
  width: 42px;
  height: 42px;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: bold;
  color: #1a1a1a;
  cursor: pointer;
  user-select: none;
}

.dpad-btn:active {
  background: var(--color-forest);
  color: #fff;
  transform: scale(0.92);
}

.dpad-up { top: 0; left: 44px; }
.dpad-down { bottom: 0; left: 44px; }
.dpad-left { top: 44px; left: 0; }
.dpad-right { top: 44px; right: 0; }
.dpad-center {
  top: 44px;
  left: 44px;
  width: 42px;
  height: 42px;
  background: rgba(62, 120, 67, 0.85);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 10px;
  pointer-events: none;
}

/* =========================================================
   MODAL DIALOGS (WIZARD, DISCOVERY, VICTORY, LEADERBOARD)
   ========================================================= */
.modal-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(10, 18, 11, 0.82);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.modal-backdrop.open {
  display: flex;
  opacity: 1;
}

.modal-card {
  width: 100%;
  max-width: 580px;
  max-height: 92vh;
  background: var(--panel-bg);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 24px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modal-pop 0.22s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

@keyframes modal-pop {
  from { transform: scale(0.92); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-header {
  padding: 16px 20px;
  background: #f7faf7;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
}

/* Setup Wizard Modal Header (Heritage Memory Match Layout) */
.wizard-modal-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  background: #ffffff;
  padding: 18px 24px 14px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.wizard-brand-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.wizard-brand-text {
  display: flex;
  flex-direction: column;
  text-align: left;
}

.wizard-brand-kicker {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-forest);
}

.wizard-brand-headline {
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 0.03em;
  color: #000000;
  line-height: 1.1;
}

.wizard-tagline {
  font-size: 12px;
  color: #555555;
  margin-top: 6px;
  font-weight: 600;
}

.modal-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.modal-logo {
  width: 44px;
  height: 44px;
  object-fit: contain;
}

.modal-title-text h2 {
  font-size: 18px;
  font-weight: 700;
  color: #000;
  line-height: 1.2;
}

.modal-title-text p {
  font-size: 12px;
  color: #555;
}

.modal-close-btn {
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 14px;
  font-weight: bold;
  color: #444;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  transition: all 0.15s ease;
}

.modal-close-btn:hover {
  background: #f4f6f4;
  color: #000;
  transform: scale(1.05);
}

.modal-close-btn:active {
  transform: scale(0.95);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}

.modal-body {
  padding: 18px 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 14px 20px;
  background: #f7faf7;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

/* Primary Button Styling */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: 'Andika', sans-serif;
  font-size: 14px;
  font-weight: 700;
  padding: 10px 20px;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.05);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
}

.btn:active {
  transform: scale(0.98);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.btn-primary {
  background: var(--color-forest);
  color: #ffffff;
  border-color: rgba(0, 0, 0, 0.05);
  box-shadow: 0 4px 16px rgba(59, 122, 87, 0.22);
}

.btn-primary:hover {
  background: var(--color-forest-hover);
  box-shadow: 0 6px 20px rgba(59, 122, 87, 0.3);
}

.btn-secondary {
  background: #ffffff;
  color: #1a1a1a;
  border-color: rgba(0, 0, 0, 0.08);
}

.btn-secondary:hover {
  background: #f4f6f4;
}

.btn-large {
  font-size: 15px;
  padding: 12px 26px;
}

/* =========================================================
   SETUP WIZARD STEP STYLING (1 - 2 - 3 - 4 Stepper)
   ========================================================= */
.wizard-stepper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  padding: 0 4px;
}

.stepper-step {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: #888;
}

.step-num {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1.5px solid #ccc;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  background: #fff;
  transition: all 0.2s ease;
}

.stepper-step.active {
  color: var(--color-forest);
}

.stepper-step.active .step-num {
  border-color: var(--color-forest);
  background: var(--color-forest);
  color: #fff;
  box-shadow: 0 0 0 3px rgba(62, 120, 67, 0.2);
}

.stepper-step.completed .step-num {
  border-color: var(--color-forest);
  background: var(--color-forest);
  color: #fff;
}

.step-line {
  flex: 1;
  height: 2px;
  background: #ddd;
  margin: 0 8px;
}

.step-content-pane {
  display: none;
}

.step-content-pane.active {
  display: block;
}

.step-title {
  font-size: 15px;
  font-weight: 800;
  color: #000;
  margin-bottom: 2px;
}

.step-sub {
  font-size: 12px;
  color: #555;
  margin-bottom: 12px;
}

/* Selection Cards Grid */
.options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.mode-options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}

.option-card, .mode-card, .diff-option-card {
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 16px;
  padding: 12px;
  background: #ffffff;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.04);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.option-card:hover, .mode-card:hover, .diff-option-card:hover {
  background: #f8faf8;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.07);
}

.option-card.selected, .option-card.active,
.mode-card.selected, .mode-card.active,
.diff-option-card.selected, .diff-option-card.active {
  background: #f2f8f4;
  border: 2px solid #3b7a57;
  box-shadow: 0 4px 14px rgba(59, 122, 87, 0.18);
  outline: none;
}

.option-icon-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #f0f7f1;
  border: 1px solid rgba(0, 0, 0, 0.08);
  margin-bottom: 2px;
}

.option-icon-wrap.duel-icons {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 56px;
  height: 36px;
  border-radius: 18px;
  padding: 0 4px;
  background: #f0f7f1;
  border: 1px solid rgba(0, 0, 0, 0.08);
  margin-bottom: 2px;
}

.mode-svg-user {
  width: 22px;
  height: 22px;
  overflow: visible;
}

.option-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.option-card-title {
  font-size: 13px;
  font-weight: 700;
  color: #000;
}

.option-card-desc {
  font-size: 11px;
  color: #555;
  line-height: 1.25;
}

/* Avatar Selector (6 High-Res Circular Portraits) */
.avatar-pick-heading {
  font-size: 12px;
  font-weight: 800;
  color: #222;
  margin-top: 10px;
  margin-bottom: 4px;
}

.avatar-grid {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 10px 0 16px;
  flex-wrap: wrap;
}

.avatar-choice, .avatar-option {
  width: 64px;
  height: 64px;
  min-width: 64px;
  min-height: 64px;
  border: 2px solid transparent;
  border-radius: 50%;
  padding: 0;
  background-color: #d8ecf8;
  background-image: url('../img/sprites/avatar_portraits.png');
  background-repeat: no-repeat;
  background-size: 350% auto;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.05);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  align-items: center;
  justify-content: center;
}

.avatar-option[data-avatar="1"], .avatar-option:nth-child(1) { background-position: 8.5% 18%; }
.avatar-option[data-avatar="2"], .avatar-option:nth-child(2) { background-position: 49.8% 18%; }
.avatar-option[data-avatar="3"], .avatar-option:nth-child(3) { background-position: 91.5% 18%; }
.avatar-option[data-avatar="4"], .avatar-option:nth-child(4) { background-position: 8.2% 84%; }
.avatar-option[data-avatar="5"], .avatar-option:nth-child(5) { background-position: 49.8% 84%; }
.avatar-option[data-avatar="6"], .avatar-option:nth-child(6) { background-position: 91.5% 84%; }

.avatar-choice:hover, .avatar-option:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
}

.avatar-choice.selected, .avatar-choice.active,
.avatar-option.selected, .avatar-option.active {
  border: 2.5px solid #3b7a57;
  box-shadow: 0 4px 12px rgba(59, 122, 87, 0.22);
  transform: scale(1.06);
  background-color: #ffffff;
}

.avatar-choice canvas, .avatar-choice img,
.avatar-option canvas, .avatar-option img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  pointer-events: none;
}

.avatar-choice-svg {
  width: 100%;
  height: 100%;
  pointer-events: none;
  border-radius: 50%;
}

/* Compact Zero-Scroll Setup Wizard Layout */
#setup-wizard-modal .modal-card {
  max-width: 680px;
  width: 92vw;
  max-height: 92vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 16px 20px;
}
#setup-wizard-modal .wizard-modal-header {
  padding: 10px 16px 8px;
  margin-bottom: 6px;
}
#setup-wizard-modal .wizard-tagline {
  margin-top: 2px;
  font-size: 0.88rem;
}
#setup-wizard-modal .wizard-stepper {
  padding: 4px 0;
  margin-bottom: 6px;
}
#setup-wizard-modal .step-title {
  margin-bottom: 2px;
  font-size: 0.95rem;
}
#setup-wizard-modal .step-sub {
  margin-bottom: 6px;
  font-size: 0.8rem;
}
#setup-wizard-modal .mode-options-grid {
  gap: 8px;
  margin-bottom: 8px;
}
#setup-wizard-modal .mode-card {
  padding: 10px 12px;
}
#setup-wizard-modal .option-icon-wrap {
  width: 36px;
  height: 36px;
  margin-bottom: 4px;
}
#setup-wizard-modal .option-card-title {
  font-size: 0.95rem;
  margin-bottom: 2px;
}
#setup-wizard-modal .option-card-desc {
  font-size: 0.78rem;
  line-height: 1.25;
}
#setup-wizard-modal .modal-body {
  padding: 8px 16px;
  overflow: hidden;
}
#setup-wizard-modal .modal-footer {
  padding-top: 8px;
  margin-top: 6px;
}

#step1-players-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
#step1-players-grid.dual-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

/* Theme List */
.theme-selector-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.theme-choice-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.04);
  cursor: pointer;
  transition: all 0.15s ease;
}

.theme-choice-row:hover {
  background: #f8faf8;
}

.theme-choice-row.selected {
  background: #f2f8f4;
  border: 2px solid #3b7a57;
  box-shadow: 0 4px 14px rgba(59, 122, 87, 0.18);
}

.theme-color-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.1);
  flex-shrink: 0;
}

.theme-choice-info {
  flex: 1;
}

.theme-choice-name {
  font-size: 13px;
  font-weight: 700;
  color: #000;
}

.theme-choice-count {
  font-size: 11px;
  color: #666;
}

/* Text Inputs */
.form-input-text, #player-name-input, #p1-name-input, #p2-name-input {
  width: 100%;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 10px;
  padding: 10px 14px;
  font-family: 'Andika', sans-serif;
  font-size: 13px;
  font-weight: 700;
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
  margin-top: 4px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-input-text:focus, #player-name-input:focus, #p1-name-input:focus, #p2-name-input:focus {
  outline: none;
  border-color: #3b7a57;
  box-shadow: 0 0 0 3px rgba(59, 122, 87, 0.15);
}

/* Summary Box */
.summary-container {
  background: #f4f8f4;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px dashed #ccc;
  padding-bottom: 6px;
  font-size: 13px;
}

.summary-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.summary-label {
  font-weight: bold;
  color: #444;
}

.summary-value {
  font-weight: 700;
  color: #000;
}

.mission-goal-card {
  margin-top: 12px;
  background: #fff;
  border: 2px solid var(--color-forest);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 12px;
  color: #2e5333;
  line-height: 1.35;
}

/* =========================================================
   CULTURAL DISCOVERY CARD MODAL
   ========================================================= */
#discovery-modal .modal-card {
  max-width: 500px;
}

.card-discovery-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.card-authentic-frame {
  width: 216px;
  max-width: 100%;
  aspect-ratio: 68 / 89;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  background: #ffffff;
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
}

.card-top-num {
  position: absolute;
  top: 8px;
  left: 8px;
  background: #ffffff;
  color: #1a1a1a;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 800;
  z-index: 3;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.card-image-render {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card-bottom-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 6px 10px 8px 10px;
  background: var(--color-forest);
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  z-index: 2;
  box-sizing: border-box;
}

.card-bottom-title {
  font-size: 12px;
  font-weight: 800;
  color: #ffffff;
  line-height: 1.2;
}

.card-bottom-category {
  font-size: 9px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.85);
  text-transform: uppercase;
  margin-top: 2px;
  letter-spacing: 0.03em;
}

.card-details-pane {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.card-badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  text-transform: uppercase;
}

.card-country-tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  font-size: 11px;
  font-weight: 700;
  background: #ffffff;
  color: #333333;
}

.card-desc-paragraph {
  font-size: 13px;
  line-height: 1.45;
  color: #222222;
  text-align: center;
  padding: 0 8px;
  margin-top: 6px;
}

.card-fun-fact-box {
  background: #fffbe6;
  border: 1px solid rgba(248, 184, 0, 0.4);
  border-radius: 12px;
  padding: 10px 14px;
  box-shadow: 0 4px 14px rgba(248, 184, 0, 0.12);
  width: 100%;
  font-size: 12px;
  color: #725200;
  line-height: 1.35;
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.fun-fact-icon {
  font-size: 16px;
  flex-shrink: 0;
}

/* =========================================================
   VICTORY & LEADERBOARD MODALS
   ========================================================= */
.stars-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 10px 0;
}

.star-icon {
  font-size: 38px;
  color: #ddd;
  transition: transform 0.3s ease, color 0.3s ease;
}

.star-icon.filled {
  color: #ffe600;
  filter: drop-shadow(0 2px 8px rgba(255, 230, 0, 0.5));
  animation: star-bounce 0.5s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

@keyframes star-bounce {
  0% { transform: scale(0.2); }
  60% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

.stat-pills-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 14px 0;
}

.modal-stat-card {
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 16px;
  padding: 10px;
  text-align: center;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.04);
}

.cards-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  gap: 8px;
  margin-top: 10px;
  max-height: 160px;
  overflow-y: auto;
  padding: 4px;
}

.gallery-card-item {
  aspect-ratio: 0.72;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  cursor: pointer;
  background: #fff;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.gallery-card-item:hover {
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.1);
}

.gallery-card-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Leaderboard Table */
.leaderboard-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin-top: 10px;
  font-size: 13px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.leaderboard-table th {
  background: var(--color-forest);
  color: #ffffff;
  padding: 8px 12px;
  text-align: left;
  border: none;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.leaderboard-table td {
  padding: 8px 12px;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  background: #ffffff;
  font-weight: 700;
}

.leaderboard-table tr:nth-child(even) td {
  background: #f7faf7;
}

.leaderboard-rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.1);
  font-size: 11px;
}

.rank-1 .leaderboard-rank-badge { background: #ffe600; color: #000; }
.rank-2 .leaderboard-rank-badge { background: #e0e0e0; color: #000; }
.rank-3 .leaderboard-rank-badge { background: #d7995b; color: #fff; }

.empty-leaderboard-msg {
  text-align: center;
  padding: 30px 14px;
  color: #666;
  font-size: 13px;
}

/* Compact Glassmorphic Objective Banner */
.objective-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 50px;
  padding: 4px 18px;
  margin: 2px auto 4px;
  font-size: 11px;
  font-weight: 700;
  color: #2e5333;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
  max-width: 95%;
  overflow-x: auto;
  scrollbar-width: none;
}
.objective-banner::-webkit-scrollbar { display: none; }

.objective-step {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.obj-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--color-forest);
  color: #ffffff;
  font-size: 10px;
  font-weight: 800;
  flex-shrink: 0;
}

.obj-sep {
  color: #bbb;
  font-size: 12px;
}

/* 3-Step Visual Expedition Guide in Step 4 Briefing */
.expedition-guide-box {
  background: #f4f8f4;
  border: 1px solid rgba(62, 120, 67, 0.2);
  border-radius: 14px;
  padding: 12px 14px;
  margin-top: 10px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
}

.guide-title {
  font-size: 12px;
  font-weight: 800;
  color: var(--color-forest);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.guide-steps-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.guide-step-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  color: #1a1a1a;
}

.guide-step-icon {
  font-size: 14px;
  flex-shrink: 0;
}

/* Unlocked Gate Status Pill */
.cards-pill.unlocked {
  background: #fef3c7;
  border-color: #f59e0b;
  color: #92400e;
  animation: gate-pill-pulse 0.8s infinite alternate;
}

@keyframes gate-pill-pulse {
  from { box-shadow: 0 0 4px rgba(245, 158, 11, 0.4); }
  to { box-shadow: 0 0 12px rgba(245, 158, 11, 0.8); }
}

/* Responsive adjust */
@media (max-width: 600px) {
  #header-bar {
    padding: 0 8px;
  }
  .brand-title {
    display: none;
  }
  .brand-subtitle {
    font-size: 13px;
  }
  .hud-item {
    font-size: 11px;
  }
  .hud-item-value {
    font-size: 13px;
  }
  .stat-pills-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .avatar-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .objective-banner {
    font-size: 10px;
    gap: 6px;
    padding: 3px 10px;
  }
}
