/* ==========================================================================
   Graduation Avatar — Francesco 2.0
   Design System & Global Styles
   ========================================================================== */

:root {
  /* Core Palette */
  --bg-color: #F8F9FB;
  --bg-gradient: radial-gradient(circle at 50% 20%, #FFFFFF 0%, #F0F2F6 100%);
  --bg-warm-plaza: linear-gradient(180deg, #FBFBFD 0%, #EEF1F7 100%);

  /* Graduation & Accent Colors */
  --crimson: #B71C1C;
  --grad-red: #B71C1C;
  --grad-crimson: #C62828;
  --grad-gold: #F5A623;
  --grad-gold-light: #FFE8A3;
  --laurel-green: #2E7D32;
  --laurel-light: #E8F5E9;

  /* Neutrals */
  --text-primary: #1E1E24;
  --text-secondary: #5C6274;
  --text-muted: #8E95A5;
  --surface: #FFFFFF;
  --surface-translucent: rgba(255, 255, 255, 0.92);
  --border-light: rgba(0, 0, 0, 0.08);
  --border-active: rgba(183, 28, 28, 0.25);

  /* Shadows */
  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 8px 24px rgba(30, 30, 36, 0.08);
  --shadow-lg: 0 16px 40px rgba(30, 30, 36, 0.12);
  --shadow-btn: 0 6px 18px rgba(183, 28, 28, 0.28);
  --shadow-dialogue: 0 12px 36px rgba(18, 22, 33, 0.12);

  /* Typography */
  --font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-body: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  /* Layout & Geometry */
  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 26px;
  --radius-full: 9999px;
  --app-max-width: 480px;
}

/* Reset & Base Setup */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

html,
body {
  width: 100%;
  height: 100%;
  min-height: 100dvh;
  background-color: #12141B;
  font-family: var(--font-body);
  color: var(--text-primary);
  overflow-x: hidden;
  position: relative;
  -webkit-font-smoothing: antialiased;
}

/* App Main Container (Centered mobile frame on desktop, 100% on mobile) */
#app {
  width: 100%;
  max-width: var(--app-max-width);
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--bg-warm-plaza);
  position: relative;
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

/* Plaza Ambient Dots Pattern */
.plaza-bg-pattern {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, rgba(0, 0, 0, 0.04) 1.5px, transparent 1.5px);
  background-size: 20px 20px;
  pointer-events: none;
  z-index: 1;
}

/* Floating Audio / Sound Control in Header */
.top-controls {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  right: 16px;
  z-index: 100;
  display: flex;
  gap: 10px;
}

.control-btn {
  background: var(--surface-translucent);
  border: 1px solid var(--border-light);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  width: 42px;
  height: 42px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, background 0.2s ease;
}

.control-btn:active {
  transform: scale(0.92);
  background: #EBEFF5;
}

/* Scene Framework */
.scene-container {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  z-index: 2;
  padding: max(20px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom)) 20px;
  box-sizing: border-box;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
  transform: translateY(12px) scale(0.98);
  overflow-y: auto;
  overflow-x: hidden;
}

.scene-container.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

/* ==========================================================================
   SCENE 0: GUEST SELECTION (CHI SEI?)
   ========================================================================== */
#scene-select {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding-top: max(44px, env(safe-area-inset-top));
  padding-bottom: max(20px, env(safe-area-inset-bottom));
  gap: 12px;
}

.select-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 4px;
}

.select-plaza-icon {
  font-size: 38px;
  margin-bottom: 6px;
  filter: drop-shadow(0 4px 12px rgba(245, 166, 35, 0.35));
  animation: floatIdle 3s ease-in-out infinite;
}

.select-title {
  font-family: var(--font-heading);
  font-size: clamp(26px, 7vw, 32px);
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.15;
  letter-spacing: -0.5px;
}

.select-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.45;
  max-width: 320px;
  margin-top: 4px;
}

/* Search Box */
.search-box-wrapper {
  width: 100%;
  position: relative;
  margin-top: 4px;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
  pointer-events: none;
  opacity: 0.6;
}

.search-input {
  width: 100%;
  height: 46px;
  padding: 0 16px 0 42px;
  border-radius: var(--radius-full);
  border: 1.5px solid var(--border-light);
  background: var(--surface);
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
  outline: none;
  transition: all 0.2s ease;
}

.search-input:focus {
  border-color: var(--grad-crimson);
  box-shadow: 0 0 0 3px rgba(183, 28, 28, 0.15);
}

/* Category Filter Chips */
.guest-filter-chips {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 2px 2px 2px;
  margin-top: 2px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.guest-filter-chips::-webkit-scrollbar {
  display: none;
}

.filter-chip {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-full);
  border: 1.5px solid var(--border-light);
  background: var(--surface);
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
  white-space: nowrap;
}

.filter-chip:hover {
  background: #FFF5F5;
  border-color: rgba(183, 28, 28, 0.3);
  color: var(--grad-crimson);
}

.filter-chip.active {
  background: var(--grad-crimson);
  color: #FFFFFF;
  border-color: var(--grad-crimson);
  box-shadow: 0 3px 10px rgba(183, 28, 28, 0.25);
}

/* Guests Grid / List */
.guests-list-grid {
  width: 100%;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 4px 2px 16px 2px;
  max-height: calc(100dvh - 300px);
  min-height: 220px;
  -webkit-overflow-scrolling: touch;
}

/* Custom Scrollbar for Guests List */
.guests-list-grid::-webkit-scrollbar {
  width: 5px;
}

.guests-list-grid::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.12);
  border-radius: 10px;
}

/* Guest Card Item */
.guest-card-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-md);
  text-align: left;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.guest-card-btn:hover {
  transform: translateY(-2px);
  border-color: rgba(183, 28, 28, 0.3);
  box-shadow: var(--shadow-md);
}

.guest-card-btn:active {
  transform: scale(0.98);
}

.guest-avatar-bubble {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, #FFF1F0 0%, #FFE4E1 100%);
  border: 2px solid #FFCDD2;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 22px;
  color: var(--grad-crimson);
  flex-shrink: 0;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(183, 28, 28, 0.12);
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.guest-avatar-bubble.guest-avatar-unlocked {
  border-color: #FFB300;
  background: linear-gradient(135deg, #FFF9C4 0%, #FFE082 100%);
  box-shadow: 0 2px 10px rgba(255, 179, 0, 0.3);
}

.guest-avatar-initial {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 23px;
  line-height: 1;
  color: var(--grad-crimson);
  letter-spacing: -0.5px;
  user-select: none;
}

.guest-avatar-bubble img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  transform: scale(1.1);
}

.guest-card-info {
  flex: 1;
  min-width: 0;
}

.guest-card-name {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 16px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.guest-card-rel {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.guest-card-arrow {
  font-size: 16px;
  color: var(--grad-crimson);
  font-weight: 700;
  opacity: 0.6;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.guest-card-btn:hover .guest-card-arrow {
  opacity: 1;
  transform: translateX(3px);
}

.no-guests-found {
  padding: 30px 16px;
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
}

.btn-text-link {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  padding: 10px 16px;
  margin-top: 8px;
  border-radius: var(--radius-full);
  transition: color 0.2s ease, background 0.2s ease;
}

.btn-text-link:hover {
  color: var(--grad-crimson);
  background: rgba(183, 28, 28, 0.05);
}

/* ==========================================================================
   SCENE 1: INTRO
   ========================================================================== */
#scene-intro {
  align-items: center;
  justify-content: space-between;
  text-align: center;
  padding-top: max(44px, env(safe-area-inset-top));
  padding-bottom: max(20px, env(safe-area-inset-bottom));
}

.intro-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  background: var(--laurel-light);
  color: var(--laurel-green);
  border: 1px solid rgba(46, 125, 50, 0.2);
  border-radius: var(--radius-full);
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  box-shadow: var(--shadow-sm);
}

.intro-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: auto 0;
}

.intro-laurel-emblem {
  width: 90px;
  height: 90px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.emblem-icon {
  font-size: 52px;
  filter: drop-shadow(0 8px 16px rgba(183, 28, 28, 0.2));
}

.intro-title {
  font-family: var(--font-heading);
  font-size: clamp(24px, 7vw, 32px);
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.15;
  margin-bottom: 6px;
  letter-spacing: -0.5px;
}

.intro-title span {
  color: var(--grad-crimson);
  display: block;
}

.intro-subtitle {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.45;
  max-width: 280px;
  margin-top: 6px;
}

.intro-recipient-chip {
  margin-top: 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  padding: 6px 16px;
  border-radius: var(--radius-full);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.intro-actions {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

/* ==========================================================================
   BUTTONS & TACTILE CONTROLS
   ========================================================================== */
.btn-primary {
  width: 100%;
  min-height: 56px;
  background: linear-gradient(135deg, var(--grad-crimson) 0%, var(--grad-red) 100%);
  color: #FFFFFF;
  border: none;
  border-radius: var(--radius-lg);
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  box-shadow: var(--shadow-btn);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn-primary:active {
  transform: scale(0.97);
  box-shadow: 0 3px 10px rgba(183, 28, 28, 0.2);
}

.btn-secondary {
  width: 100%;
  min-height: 50px;
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}

.btn-secondary:hover {
  background: #F1F4F9;
  border-color: #CBD5E1;
}

.btn-secondary:active {
  transform: scale(0.97);
  background: #E2E8F0;
}

.btn-gold {
  background: linear-gradient(135deg, #FFB300 0%, #F57F17 100%);
  color: #FFFFFF;
  box-shadow: 0 6px 18px rgba(245, 127, 23, 0.3);
}

/* ==========================================================================
   SCENE 2: INTERACTIVE STAGE & AVATAR CANVAS
   ========================================================================== */
#scene-stage {
  justify-content: space-between;
  padding-top: max(44px, env(safe-area-inset-top));
  padding-bottom: max(20px, env(safe-area-inset-bottom));
}

.stage-area {
  flex: 1;
  width: 100%;
  min-height: 200px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  position: relative;
  padding-bottom: 8px;
}

/* Characters Container */
.avatar-stage {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 16px;
  position: relative;
}

/* Mii Character Frame */
.mii-character {
  width: 160px;
  height: 240px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  position: relative;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
}

.mii-character img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.15));
  pointer-events: none;
}

/* Spot Shadow beneath Mii */
.mii-shadow {
  position: absolute;
  bottom: 0;
  width: 110px;
  height: 18px;
  background: radial-gradient(ellipse at center, rgba(30, 30, 36, 0.22) 0%, transparent 70%);
  border-radius: 50%;
  z-index: -1;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

/* Recipient Mii (hidden until revealed) - Quadro Portrait */
.mii-recipient {
  width: 175px;
  height: 245px;
  transform: scale(0);
  opacity: 0;
  display: none;
  border-radius: 18px;
  background: linear-gradient(145deg, #FFFDF8 0%, #F5EFEB 100%);
  border: 5px solid #D4AF37;
  /* Elegante cornice dorata stile quadro */
  box-shadow:
    0 10px 25px rgba(0, 0, 0, 0.18),
    0 0 0 2px #8C6D1F,
    inset 0 0 10px rgba(0, 0, 0, 0.08);
  overflow: hidden;
  position: relative;
  padding: 10px 4px 6px 4px;
  box-sizing: border-box;
}

/* Subtle canvas texture / matting inside the picture frame */
.mii-recipient::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 35%, rgba(255, 255, 255, 0.8) 0%, rgba(230, 222, 210, 0.4) 100%);
  pointer-events: none;
  z-index: 0;
}

.mii-recipient.revealed {
  display: flex;
  transform: scale(1);
  opacity: 1;
}

/* Picture frame in Final Duo Stage */
.final-recipient-frame {
  border-radius: 16px;
  background: linear-gradient(145deg, #FFFDF8 0%, #F5EFEB 100%);
  border: 4px solid #D4AF37;
  box-shadow:
    0 8px 20px rgba(0, 0, 0, 0.16),
    0 0 0 2px #8C6D1F,
    inset 0 0 8px rgba(0, 0, 0, 0.08);
  overflow: hidden;
  position: relative;
  padding: 8px 4px 4px 4px;
  box-sizing: border-box;
}

.final-recipient-frame::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 35%, rgba(255, 255, 255, 0.8) 0%, rgba(230, 222, 210, 0.4) 100%);
  pointer-events: none;
  z-index: 0;
}

/* Align recipient inside frame */
.mii-recipient img,
#recipient-avatar-img,
#final-recipient-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform-origin: center center;
  position: relative;
  z-index: 1;
}

/* Height modifier classes inside the picture frame:
   In 1440x1440 renders:
   - "low" (Monica): body has less height margin -> scale 1.15
   - "medium" (Giulio): scale 1.18
   - "high" (Nico, Vale): scale 1.25
   This ensures the head and feet are completely visible inside the frame!
*/
.mii-height-low,
#recipient-avatar-img.mii-height-low,
#final-recipient-img.mii-height-low {
  transform: scale(1.15) !important;
  margin-bottom: 0 !important;
}

.mii-height-medium,
#recipient-avatar-img.mii-height-medium,
#final-recipient-img.mii-height-medium {
  transform: scale(1.18) !important;
  margin-bottom: 0 !important;
}

.mii-height-high,
#recipient-avatar-img.mii-height-high,
#final-recipient-img.mii-height-high {
  transform: scale(1.24) !important;
  margin-bottom: 0 !important;
}

/* ==========================================================================
   DIALOGUE BOX COMPONENT
   ========================================================================== */
.dialogue-wrapper {
  width: 100%;
  position: relative;
  margin-top: auto;
  z-index: 10;
}

.dialogue-box {
  background: var(--surface-translucent);
  border: 1.5px solid rgba(0, 0, 0, 0.08);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: var(--radius-lg);
  padding: 18px 20px 16px 20px;
  box-shadow: var(--shadow-dialogue);
  min-height: 120px;
  position: relative;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: border-color 0.2s ease, transform 0.1s ease;
}

.dialogue-box:active {
  transform: scale(0.99);
}

/* Character Nameplate Tag */
.nameplate {
  position: absolute;
  top: -14px;
  left: 20px;
  background: linear-gradient(135deg, var(--grad-crimson) 0%, var(--grad-red) 100%);
  color: #FFFFFF;
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 4px 14px;
  border-radius: var(--radius-full);
  box-shadow: 0 4px 10px rgba(183, 28, 28, 0.25);
  display: flex;
  align-items: center;
  gap: 6px;
}

.nameplate-icon {
  font-size: 13px;
}

/* Dialogue Text */
.dialogue-text {
  font-size: 16px;
  line-height: 1.55;
  color: var(--text-primary);
  font-weight: 500;
  min-height: 48px;
  margin-top: 6px;
  margin-bottom: 8px;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Tap to Continue Indicator */
.dialogue-prompt {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.dialogue-indicator-arrow {
  display: inline-block;
  color: var(--grad-crimson);
  font-size: 14px;
}

/* ==========================================================================
   SCENE: AUTHENTICATION QUESTION
   ========================================================================== */
.auth-box {
  width: 100%;
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 10;
}

.question-card {
  background: var(--surface);
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  box-shadow: var(--shadow-md);
  text-align: center;
}

.question-label {
  font-family: var(--font-heading);
  font-size: 11px;
  font-weight: 700;
  color: var(--grad-crimson);
  letter-spacing: 1.2px;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.question-title {
  font-family: var(--font-heading);
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.35;
}

.answers-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.answer-btn {
  width: 100%;
  min-height: 52px;
  background: var(--surface);
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  text-align: left;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, border-color 0.2s ease, background 0.2s ease;
}

.answer-btn:active {
  transform: scale(0.98);
}

.answer-btn .btn-badge {
  width: 28px;
  height: 28px;
  background: #EDF2F7;
  color: var(--text-secondary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.answer-btn.correct-select {
  background: #E8F5E9;
  border-color: #4CAF50;
  color: #1B5E20;
}

.answer-btn.correct-select .btn-badge {
  background: #4CAF50;
  color: #FFFFFF;
}

.answer-btn.wrong-select {
  background: #FFEBEE;
  border-color: #E53935;
  color: #B71C1C;
}

.answer-btn.wrong-select .btn-badge {
  background: #E53935;
  color: #FFFFFF;
}

/* ==========================================================================
   SCENE 3: MEMORIES SLIDESHOW
   ========================================================================== */
#scene-memories {
  padding-top: max(44px, env(safe-area-inset-top));
  padding-bottom: max(20px, env(safe-area-inset-bottom));
  justify-content: space-between;
}

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

.memories-title {
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: 800;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.memories-counter {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  background: rgba(0, 0, 0, 0.05);
  padding: 4px 10px;
  border-radius: var(--radius-full);
}

/* Polaroid Card Container */
.memory-viewer {
  flex: 1;
  width: 100%;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 12px 12px 18px 12px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border-light);
}

.memory-image-box {
  width: 100%;
  flex: 1;
  min-height: 220px;
  border-radius: var(--radius-md);
  overflow: hidden;
  position: relative;
  background: #1A1C24;
}

.memory-image-box.mii-pose-viewer-box {
  background: radial-gradient(circle at 50% 30%, #FFFFFF 0%, #E8EDF5 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  border: 1px solid rgba(0, 0, 0, 0.04);
  min-height: 280px;
}

.mii-showcase-img {
  width: 95% !important;
  max-width: 95% !important;
  height: 95% !important;
  max-height: 380px !important;
  object-fit: contain !important;
  transform: scale(1.3);
  filter: drop-shadow(0 14px 24px rgba(0, 0, 0, 0.16));
  animation: floatIdle 3.5s ease-in-out infinite;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.memory-image-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.memory-tag {
  position: absolute;
  top: 12px;
  left: 12px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  color: #FFFFFF;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.memory-info {
  margin-top: 14px;
  padding: 0 6px;
}

.memory-title-text {
  font-family: var(--font-heading);
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.memory-caption-text {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.45;
}

/* Slideshow Navigation & Controls */
.memory-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
}

.memory-dots {
  display: flex;
  gap: 6px;
  align-items: center;
}

.memory-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: #CBD5E1;
  transition: width 0.25s ease, background 0.25s ease;
}

.memory-dot.active {
  width: 22px;
  background: var(--grad-crimson);
}

.nav-arrow-btn {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  background: var(--surface);
  border: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--text-primary);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, background 0.15s ease;
}

.nav-arrow-btn:active {
  transform: scale(0.92);
  background: #EDF2F7;
}

.memory-finish-btn {
  flex: 1;
  min-height: 44px;
}

/* ==========================================================================
   SCENE 4: GIFT REVEAL & DOWNLOADS
   ========================================================================== */
#scene-gift {
  padding-top: max(44px, env(safe-area-inset-top));
  padding-bottom: max(24px, env(safe-area-inset-bottom));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.gift-header {
  text-align: center;
  margin-bottom: 16px;
}

.gift-badge {
  display: inline-block;
  padding: 4px 14px;
  background: var(--grad-gold-light);
  color: #B26A00;
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 1px;
  border-radius: var(--radius-full);
  margin-bottom: 6px;
}

.gift-title {
  font-family: var(--font-heading);
  font-size: 24px;
  font-weight: 800;
  color: var(--text-primary);
}

.gifts-scroll {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-bottom: 16px;
}

.gift-card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.gift-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.gift-icon-box {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: #FFF3E0;
  color: #E65100;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.gift-icon-box.qr-icon {
  background: #E3F2FD;
  color: #0D47A1;
}

.gift-icon-box.photo-icon {
  background: #FCE4EC;
  color: #880E4F;
}

.gift-card-title {
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.gift-card-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.45;
}

.qr-preview-box {
  background: #FFFFFF;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 6px 0;
}

#qrcode-container canvas {
  width: 180px !important;
  height: 180px !important;
  border-radius: 8px;
}

/* ==========================================================================
   3D MODEL VIEWER COMPONENT (THREE.JS / MODEL-VIEWER)
   ========================================================================== */
.model-viewer-box {
  width: 100%;
  height: clamp(340px, 45vh, 385px);
  background: radial-gradient(circle at 50% 45%, #FFFFFF 0%, #F8FAFC 55%, #E2E8F0 100%);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  overflow: hidden;
  position: relative;
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.05), var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 4px 0 8px 0;
}

model-viewer {
  width: 100%;
  height: 100%;
  --poster-color: transparent;
  outline: none;
  display: block;
}

/* 3D Hint Badge */
.model-hint-badge {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  font-weight: 700;
  color: #475569;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 4px 12px;
  border-radius: var(--radius-full);
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.08);
  border: 1px solid rgba(0, 0, 0, 0.06);
  z-index: 2;
  transition: opacity 0.4s ease;
}

/* Interactive Floating Controls Toolbar */
.model-viewer-controls {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 4px 8px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  z-index: 3;
}

.model-tool-btn {
  background: none;
  border: none;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 700;
  color: #1E293B;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  padding: 5px 10px;
  border-radius: var(--radius-full);
  transition: background 0.15s ease, transform 0.15s ease;
}

.model-tool-btn:hover {
  background: #F1F5F9;
}

.model-tool-btn:active {
  transform: scale(0.94);
  background: #E2E8F0;
}

/* Custom AR Button for Mobile */
.custom-ar-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  color: var(--crimson);
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 11px;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  z-index: 3;
  transition: transform 0.15s ease, background 0.15s ease;
}

.custom-ar-btn:active {
  transform: scale(0.95);
  background: #FFF5F5;
}

/* Loading Poster / Spinner */
.model-loading-poster {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.model-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(183, 28, 28, 0.15);
  border-top-color: var(--crimson);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Model Fallback Card */
.model-fallback-view {
  display: none;
  position: absolute;
  inset: 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 16px;
  gap: 8px;
  background: radial-gradient(circle at 50% 40%, #FFFFFF 0%, #F1F5F9 100%);
  z-index: 1;
}

.model-fallback-view img {
  width: 95px;
  height: 95px;
  object-fit: contain;
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.15));
}

.model-fallback-title {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 15px;
  color: var(--text-primary);
}

.model-fallback-sub {
  font-size: 12px;
  color: var(--text-secondary);
  max-width: 250px;
  line-height: 1.4;
}

/* Post-Download GLB Instructions Box */
.glb-instructions-box {
  margin-top: 4px;
  padding: 12px 14px;
  background: #F8FAFC;
  border: 1px dashed #CBD5E1;
  border-radius: var(--radius-md);
  text-align: left;
}

.glb-instructions-title {
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.glb-instructions-text {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.45;
  margin-bottom: 8px;
}

.glb-instructions-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.glb-instructions-list li {
  font-size: 12px;
  color: #334155;
  line-height: 1.4;
  padding-left: 14px;
  position: relative;
}

.glb-instructions-list li::before {
  content: '•';
  position: absolute;
  left: 3px;
  color: var(--crimson);
  font-weight: bold;
}

.glb-link {
  color: var(--crimson);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: opacity 0.15s ease;
}

.glb-link:hover {
  opacity: 0.8;
}

/* ==========================================================================
   MII RENDERS GALLERY GRID & SINGLE DOWNLOADS
   ========================================================================== */
.renders-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 6px;
}

.render-item-card {
  background: #FFFFFF;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.render-item-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.render-item-preview {
  width: 100%;
  height: 125px;
  background: radial-gradient(circle at 50% 50%, #FFFFFF 0%, #F8FAFC 60%, #EEF2F6 100%);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.05);
  padding: 6px;
}

.render-item-preview img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.12));
  transition: transform 0.2s ease;
}

.render-item-card:hover .render-item-preview img {
  transform: scale(1.06);
}

.render-item-info {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.render-item-title {
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.25;
}

.render-item-sub {
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.3;
}

.btn-download-single-render {
  width: 100%;
  min-height: 38px;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  background: #F1F5F9;
  border: 1.5px solid #CBD5E1;
  color: #1E293B;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 12.5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
  margin-top: auto;
  text-decoration: none;
}

.btn-download-single-render span {
  color: inherit;
  font-weight: 700;
  line-height: 1;
}

.btn-download-single-render:hover {
  background: linear-gradient(135deg, var(--grad-crimson) 0%, var(--grad-red) 100%);
  color: #FFFFFF !important;
  border-color: var(--grad-crimson);
  box-shadow: 0 4px 14px rgba(183, 28, 28, 0.35);
  transform: translateY(-1px);
}

.btn-download-single-render:hover span {
  color: #FFFFFF !important;
}

.btn-download-single-render:active {
  transform: scale(0.95);
  box-shadow: 0 2px 6px rgba(183, 28, 28, 0.2);
}

/* ==========================================================================
   SCENE 5: FINAL SCREEN
   ========================================================================== */
#scene-final {
  align-items: center;
  justify-content: space-between;
  text-align: center;
  padding-top: max(44px, env(safe-area-inset-top));
  padding-bottom: max(24px, env(safe-area-inset-bottom));
}

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

.final-heading {
  font-family: var(--font-heading);
  font-size: clamp(32px, 9vw, 42px);
  font-weight: 900;
  color: var(--grad-crimson);
  letter-spacing: -0.5px;
}

.final-subheading {
  font-size: 16px;
  color: var(--text-secondary);
  max-width: 290px;
  line-height: 1.45;
}

.final-duo-stage {
  width: 100%;
  height: 200px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 20px;
  margin: 12px 0;
}

.final-quote-card {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  box-shadow: var(--shadow-sm);
  font-style: italic;
  font-size: 14px;
  color: var(--text-primary);
  max-width: 320px;
}

.final-signature {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 16px;
  color: var(--grad-crimson);
  letter-spacing: 0.5px;
  margin-top: 6px;
}

/* ==========================================================================
   FALLBACK / 404 SCREEN
   ========================================================================== */
#scene-lost {
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 18px;
}

.lost-icon {
  font-size: 64px;
}

.lost-title {
  font-family: var(--font-heading);
  font-size: 26px;
  font-weight: 800;
  color: var(--text-primary);
}

.lost-desc {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.5;
  max-width: 300px;
}

/* ==========================================================================
   COMPLETED MII & DIRECT GIFT SHORTCUT
   ========================================================================== */
.btn-gift-shortcut {
  background: linear-gradient(135deg, #FFB300 0%, #FF8F00 100%) !important;
  color: #1A1A1A !important;
  font-weight: 800 !important;
  box-shadow: 0 6px 20px rgba(255, 179, 0, 0.4), 0 2px 6px rgba(0, 0, 0, 0.1) !important;
  margin-bottom: 8px;
  animation: pulseGold 2.2s infinite ease-in-out;
  border: 1px solid rgba(255, 238, 88, 0.6) !important;
}

.btn-gift-shortcut:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 8px 26px rgba(255, 179, 0, 0.55), 0 3px 8px rgba(0, 0, 0, 0.12) !important;
}

.btn-gift-shortcut:active {
  transform: scale(0.97);
}

.gift-btn-emoji {
  font-size: 24px;
  display: inline-block;
  animation: wiggleGift 2.4s infinite ease-in-out;
}

@keyframes wiggleGift {
  0%, 70%, 100% {
    transform: rotate(0deg);
  }
  75% {
    transform: rotate(-14deg) scale(1.15);
  }
  80% {
    transform: rotate(12deg) scale(1.15);
  }
  85% {
    transform: rotate(-8deg);
  }
  90% {
    transform: rotate(6deg);
  }
  95% {
    transform: rotate(0deg);
  }
}

@keyframes pulseGold {
  0%, 100% {
    box-shadow: 0 6px 20px rgba(255, 179, 0, 0.4), 0 2px 6px rgba(0, 0, 0, 0.1);
  }
  50% {
    box-shadow: 0 8px 30px rgba(255, 179, 0, 0.75), 0 4px 10px rgba(0, 0, 0, 0.15);
  }
}

.intro-gift-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #FFF8E1;
  color: #E65100;
  border: 1px solid #FFE082;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  margin-left: 8px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, background-color 0.15s ease;
}

.intro-gift-badge:hover {
  transform: scale(1.05);
  background-color: #FFECB3;
}

.guest-card-completed-badge {
  display: inline-block;
  font-size: 15px;
  margin-left: 6px;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
  animation: wiggleGift 3.2s infinite ease-in-out;
}