@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@700;800;900&display=swap');

:root {
  /* Kings Gambit Dark Gold Palette */
  --color-primary: #facc15;
  /* Gold */
  --color-primary-dark: #ca8a04;
  /* Darker Gold for 3D effect */
  --color-secondary: #ef4444;
  /* Crimson Red */
  --color-secondary-dark: #b91c1c;
  --color-bg: #121212;
  --color-bg-alt: #262626;
  --color-text: #f5f5f5;
  --color-text-muted: #a3a3a3;
  --color-border: #404040;

  --radius-sm: 12px;
  --radius-md: 20px;
  --radius-lg: 30px;
  --radius-full: 999px;

  --transition-fast: 0.15s ease;
  --transition-bounce: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Nunito', sans-serif;
  background-color: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  /* Mobile-first constraints */
  max-width: 600px;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

h1,
h2,
h3 {
  font-weight: 800;
  letter-spacing: -0.5px;
}

/* Utilities */
.text-center {
  text-align: center;
}

.mt-4 {
  margin-top: 1rem;
}

.mb-4 {
  margin-bottom: 1rem;
}

.p-4 {
  padding: 1rem;
}

/* 3D Button Class */
.btn-3d {
  display: block;
  width: 100%;
  border: none;
  background-color: var(--color-primary);
  color: var(--color-bg);
  font-family: inherit;
  font-weight: 800;
  font-size: 1.2rem;
  padding: 16px 24px;
  border-radius: var(--radius-md);
  cursor: pointer;
  box-shadow: 0 5px 0 var(--color-primary-dark);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  text-decoration: none;
  text-align: center;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.btn-3d:active {
  transform: translateY(5px);
  box-shadow: 0 0px 0 var(--color-primary-dark);
}

.btn-3d.secondary {
  background-color: var(--color-bg-alt);
  color: var(--color-text);
  box-shadow: 0 5px 0 var(--color-border);
  border: 2px solid var(--color-border);
}

.btn-3d.secondary:active {
  transform: translateY(5px);
  box-shadow: 0 0px 0 var(--color-border);
}

/* Header */
.app-header {
  padding: 24px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid var(--color-border);
}

.app-title {
  color: var(--color-primary);
  font-size: 2rem;
  text-transform: uppercase;
}

.edit-btn {
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  text-transform: uppercase;
  padding: 8px;
}

/* Roster Grid */
.roster-container {
  padding: 24px 16px;
}

.roster-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  gap: 16px;
  justify-items: center;
}

/* Player Avatar */
.avatar-wrapper {
  position: relative;
  width: 70px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: grab;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.2s, opacity 0.2s;
  user-select: none;
  touch-action: none;
  /* Prevent scroll while dragging vertically slightly */
}

.avatar-wrapper.dragging {
  opacity: 0.5;
}

.avatar-wrapper.drag-over {
  transform: scale(1.1) rotate(2deg);
}

.drag-ghost {
  position: fixed;
  pointer-events: none;
  z-index: 1000;
  opacity: 0.9;
  transform: scale(1.1) translate(-50%, -50%);
  /* Center cursor */
  transform-origin: center center;
  filter: drop-shadow(0 10px 10px rgba(0, 0, 0, 0.5));
}

.avatar-wrapper:active {
  transform: scale(0.95);
}

.avatar {
  width: 60px;
  height: 60px;
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  background-color: var(--color-bg-alt);
  border: 3px solid var(--color-border);
  transition: all var(--transition-bounce);
  user-select: none;
}

.avatar-name {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--color-text-muted);
  text-align: center;
  width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color var(--transition-fast);
}

/* Active State */
.avatar-wrapper.is-active .avatar {
  border-color: var(--color-primary);
  background-color: rgba(250, 204, 21, 0.15);
  /* Faint gold bg */
  transform: scale(1.05);
}

.avatar-wrapper.is-active .avatar-name {
  color: var(--color-text);
}

/* Add Player Button */
.avatar-add {
  border: 3px dashed var(--color-border);
  color: var(--color-text-muted);
  background: none;
}

.avatar-add:active {
  transform: scale(0.95);
}

/* Edit Mode */
@keyframes wiggle {
  0% {
    transform: rotate(0deg);
  }

  25% {
    transform: rotate(-3deg);
  }

  50% {
    transform: rotate(0deg);
  }

  75% {
    transform: rotate(3deg);
  }

  100% {
    transform: rotate(0deg);
  }
}

.edit-mode .avatar-wrapper:not(.is-add-btn) {
  animation: wiggle 0.4s infinite;
}

/* Delete button in edit mode */
.delete-btn {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 24px;
  height: 24px;
  background-color: var(--color-secondary);
  color: white;
  border-radius: 50%;
  font-size: 14px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
  z-index: 10;
  cursor: pointer;
  /* Large hit-box for easy tapping */
  padding: 10px;
  box-sizing: content-box;
  margin: -10px;
  transform: scale(0);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.2s var(--transition-bounce), opacity 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.delete-btn:active {
  transform: scale(0.85);
}

.edit-mode .delete-btn {
  transform: scale(1);
  opacity: 1;
  pointer-events: auto;
}

/* Games List */
.games-container {
  padding: 24px 16px;
  border-top: 2px solid var(--color-border);
}

.game-card {
  display: block;
  padding: 20px;
  border-radius: var(--radius-lg);
  border: 2px solid var(--color-primary);
  background-color: var(--color-bg);
  text-decoration: none;
  color: var(--color-text);
  margin-bottom: 16px;
  box-shadow: 0 4px 0 var(--color-primary-dark);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.game-card:active {
  transform: translateY(4px);
  box-shadow: 0 0px 0 var(--color-primary-dark);
}

.game-card-title {
  font-size: 1.5rem;
  margin-bottom: 4px;
  color: var(--color-primary);
}

.game-card-desc {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  font-weight: 700;
}

.game-card.is-locked {
  border-color: var(--color-border);
  box-shadow: 0 4px 0 var(--color-border);
  background-color: var(--color-bg-alt);
  pointer-events: none;
  opacity: 0.7;
}

.game-card.is-locked .game-card-title {
  color: var(--color-text-muted);
}

/* Drawer */
.drawer-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast);
  z-index: 100;
}

.drawer-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

#frame-grid > .emoji-btn  {
  border-radius: 0 !important
}

.drawer {
  height: calc(100% - 128px);
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: var(--color-bg);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 24px;
  transform: translateY(100%);
  transition: transform var(--transition-bounce);
  z-index: 101;
  max-width: 600px;
  margin: 0 auto;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
}

.drawer.is-open {
  transform: translateY(0);
}

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

.drawer-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 8px;
}

.input-group {
  margin-bottom: 24px;
}

.input-label {
  display: block;
  font-weight: 800;
  margin-bottom: 8px;
  color: var(--color-text);
}

.input-text {
  width: 100%;
  padding: 16px;
  font-size: 1.2rem;
  font-family: inherit;
  font-weight: 700;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
  background-color: var(--color-bg-alt);
  transition: border-color var(--transition-fast);
  color: #fff;
}

.input-text:focus {
  outline: none;
  border-color: var(--color-primary);
  background-color: var(--color-bg);
}

/* Drawer UI elements */
.pack-tabs {
  display: flex;
  overflow-x: auto;
  gap: 8px;
  padding-bottom: 8px;
  scrollbar-width: none;
  /* Firefox */
  -ms-overflow-style: none;
  /* Internet Explorer 10+ */
}

.pack-tabs::-webkit-scrollbar {
  display: none;
  /* Safari and Chrome */
}

.pack-pill {
  white-space: nowrap;
  padding: 6px 12px;
  border-radius: 20px;
  background-color: var(--color-surface-hover);
  color: var(--color-text-muted);
  border: none;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s;
}

.pack-pill.active {
  background-color: var(--color-text);
  color: var(--color-bg);
}


.emoji-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(65px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
  max-height: 260px;
  overflow-y: auto;
  padding-right: 4px;
  min-height: 260px;
}

.emoji-btn {
  background-color: var(--color-bg-alt);
  border: 2px solid transparent;
  width: 100%;
  max-width: 80px;
  aspect-ratio: 1;
  margin: 0 auto;
  border-radius: var(--radius-md);
  font-size: 2rem;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: transform var(--transition-bounce), border-color 0.2s;
  overflow: hidden;
  padding: 0;
  min-width: 0;
  min-height: 0;
  -webkit-tap-highlight-color: transparent;
}

.emoji-btn.is-selected {
  border-color: var(--color-primary);
  background-color: rgba(250, 204, 21, 0.15);
}

/* Example Game specific */
.game-view {
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 24px;
}

.game-nav {
  position: absolute !important;
  top: 24px;
  left: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.game-nav-back {
  background: none;
  border: none;
  font-size: 2rem;
  font-weight: 900;
  color: var(--color-text-muted);
  cursor: pointer;
}

.game-center {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  margin-bottom: auto;
}

.roster-preview {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 32px;
  font-size: 1.5rem;
}

.giant-result {
  font-size: 3rem;
  font-weight: 900;
  color: var(--color-text);
  margin-top: 32px;
  animation: popIn var(--transition-bounce);
  display: none;
}

.giant-result.is-visible {
  display: block;
}

@keyframes popIn {
  0% {
    transform: scale(0.5);
    opacity: 0;
  }

  80% {
    transform: scale(1.1);
    opacity: 1;
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* --- Mutiny Styles --- */
.mutiny-container {
  min-height: 100vh;
  background-color: #0f172a;
  /* Deep navy */
  color: #f8fafc;
  display: flex;
  flex-direction: column;
  transition: background-color 0.5s ease;
}

.curse-reminders {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 320px;
}

.curse-reminder-item {
  background: rgba(239, 68, 68, 0.15);
  border: 2px solid #ef4444;
  border-radius: var(--radius-md);
  padding: 12px;
  color: #f8fafc;
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2);
}

.mutiny-container.flash-gold {
  background-color: #ca8a04 !important;
}

.mutiny-container.flash-red {
  background-color: #b91c1c !important;
}

.mutiny-container.flash-purple {
  background-color: #4c1d95 !important;
}

.cbtm-explanation-text {
  font-size: 1.05rem;
  color: #451a03;
  line-height: 1.6;
  margin-bottom: 16px;
  padding: 0px;
  background: rgba(120, 53, 15, 0.1);
  border-radius: var(--radius-md, 12px);
  border: 1px solid rgba(120, 53, 15, 0.2);

  overflow: hidden;
  height: 0px;

  transition: height 0.3s ease, padding 0.3s ease;
}

.cbtm-explanation-text.is-open {
  height: 325px;
  padding: 16px;
}

.cbtm-explanation-text strong {
  color: #92400e;
}

.modal-player-tag>span>img,
.modal-player-tag>span>canvas {
  transition: width 0.3s ease;
}

#mutiny-card-avatar {
  position: relative !important;
}

.modal-player-tag.is-shrunk>span>img,
.modal-player-tag.is-shrunk>span>canvas {
  width: 0% !important;
}

.mutiny-header {
  padding: 16px;
  display: flex;
  justify-content: flex-start;
}

.mutiny-header .edit-btn {
  color: #94a3b8;
}

.mutiny-arena {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 24px;
  margin-bottom: 80px;
  /* Room for turn bar */
}

/* The Mutiny Coin */
.mutiny-coin-wrapper {
  perspective: 1000px;
  margin-bottom: 48px;
}

.mutiny-coin {
  width: 140px;
  height: 140px;
  background: radial-gradient(circle at 30% 30%, #fef08a, #ca8a04);
  border-radius: 50%;
  border: 4px solid #854d0e;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.5), inset 0 0 15px rgba(255, 255, 255, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 4rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transform-style: preserve-3d;
  transition: transform 0.2s;
  user-select: none;
}

.mutiny-coin:active {
  transform: scale(0.95);
  box-shadow: 0 5px 10px rgba(0, 0, 0, 0.5), inset 0 0 15px rgba(255, 255, 255, 0.5);
}

.mutiny-coin.spin-fast {
  animation: coin-spin 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes coin-spin {
  0% {
    transform: rotateY(0deg) scale(1);
  }

  50% {
    transform: rotateY(1800deg) scale(1.3);
  }

  /* 5 full flips */
  100% {
    transform: rotateY(3600deg) scale(1);
  }
}

/* Mutiny Prompts */
.mutiny-prompt {
  font-size: 1.5rem;
  font-weight: 800;
  text-align: center;
  color: #94a3b8;
  /* Muted slate */
  min-height: 80px;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.5s ease, transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.mutiny-prompt.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Mutiny Bounty Modal */
.mutiny-card {
  background-color: #fde68a;
  /* Parchment */
  border-radius: 8px;
  /* Sharper edges */
  padding: 32px 24px;
  text-align: center;
  width: 100%;
  max-width: 400px;
  transform: scale(0.9);
  transition: transform var(--transition-bounce);
  border: 6px solid #92400e;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.7), inset 0 0 40px rgba(146, 64, 14, 0.2);
}

.rule-overlay.is-visible .mutiny-card {
  transform: scale(1);
  animation: popIn var(--transition-bounce);
}

.mutiny-card-title {
  color: #78350f;
  font-size: 2.2rem;
  margin-bottom: 16px;
  text-transform: uppercase;
  font-weight: 900;
  letter-spacing: -1px;
}

.mutiny-card-text {
  color: #451a03;
  font-size: 1.3rem;
  font-weight: 800;
  margin-bottom: 24px;
  line-height: 1.4;
}

/* Toast Notification */
.toast-container {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 90%;
  max-width: 400px;
  pointer-events: none;
}

.toast {
  background-color: var(--color-bg-alt);
  color: var(--color-text);
  padding: 12px 20px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
  font-weight: 700;
  font-size: 0.95rem;
  text-align: center;
  pointer-events: auto;
  opacity: 0;
  transform: translateY(-20px);
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

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

.mutiny-continue-btn {
  background-color: #92400e;
  color: #fde68a;
  box-shadow: 0 5px 0 #78350f;
}

.mutiny-continue-btn:active {
  box-shadow: 0 0px 0 #78350f;
}

/* Turn Bar Custom Navy */
.mutiny-turn-bar {
  background-color: #1e293b;
  border-top: 2px solid #334155;
}

.mutiny-turn-indicator {
  color: #fef08a;
}

/* --- Ring of Fire Styles --- */
.king-header {
  padding: 16px;
  justify-content: flex-start;
  gap: 16px;
}

.king-tracker {
  display: flex;
  gap: 8px;
  opacity: 0.8;
}

.glass-icon {
  font-size: 1.5rem;
  opacity: 0.3;
  transition: all var(--transition-bounce);
}

.glass-icon.filled {
  opacity: 1;
  transform: scale(1.2);
}

.rof-arena {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  height: calc(100vh - 150px);
  padding: 24px;
}

.deck-area {
  position: relative;
  width: 140px;
  height: 200px;
  perspective: 1000px;
}

/* Card 3D Setup */
.card {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: var(--radius-md);
  transform-style: preserve-3d;
  --rot: 0deg;
  transform: rotate(var(--rot));
  transition: transform 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275), top 0.2s, left 0.2s;
  cursor: pointer;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
  -webkit-tap-highlight-color: transparent;
}

.card:active {
  transform: scale(0.95) rotate(var(--rot));
}

.card-face {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: var(--radius-md);
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 3rem;
  font-weight: 900;
  border: 4px solid var(--color-bg);
}

.card-back {
  background: repeating-linear-gradient(45deg,
      var(--color-secondary),
      var(--color-secondary) 10px,
      var(--color-secondary-dark) 10px,
      var(--color-secondary-dark) 20px);
  transform: rotateY(0deg);
}

.card-front {
  background-color: var(--color-bg);
  color: var(--color-secondary);
  transform: rotateY(180deg);
}

.card-front.black-suit {
  color: var(--color-text);
}

/* Flipped state */
.card.is-flipped {
  transform: rotateY(180deg) scale(1.8) translateY(-30px) rotate(var(--rot));
  z-index: 100 !important;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}

.card.is-discarded {
  opacity: 0;
  transform: translateX(200px) rotateY(180deg) scale(0.8) rotate(var(--rot));
  pointer-events: none;
}

/* Turn Bar */
.turn-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: var(--color-bg-alt);
  padding: 16px 24px;
  border-top: 2px solid var(--color-border);
  box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.2);
  z-index: 5;
  display: flex;
  justify-content: center;
}

.turn-indicator {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--color-primary);
}

.turn-emoji {
  background-color: var(--color-bg);
  width: 40px;
  height: 40px;
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 0;
  border: 2px solid var(--color-border);
}

.turn-emoji.avatar {
  background-color: var(--color-surface);
  width: 70px;
  height: 70px;
  border-radius: var(--radius-md);
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 2.5rem;
  box-shadow: var(--shadow);
  border: 4px solid var(--color-surface-hover);
  transition: border-color 0.2s, background-color 0.2s;
  overflow: visible;
}

.avatar-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 0;
  pointer-events: none;
  -webkit-user-drag: none;
  user-select: none;
  display: block;
}

.avatar img,
.emoji-btn img {
  pointer-events: none;
  -webkit-user-drag: none;
  user-select: none;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 0;
  display: block;
}

/* Rule Overlay */
.rule-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.8);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast);
  z-index: 50;
}

.rule-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.rule-card {
  background-color: var(--color-bg);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  text-align: center;
  width: 100%;
  max-width: 400px;
  transform: scale(0.9);
  transition: transform var(--transition-bounce);
  border: 4px solid var(--color-primary);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}

.rule-overlay.is-visible .rule-card {
  transform: scale(1);
}

.rule-title {
  color: var(--color-primary);
  font-size: 2rem;
  margin-bottom: 12px;
  text-transform: uppercase;
}

.rule-text {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.rule-subtext {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  margin-bottom: 24px;
}

/* Blindfold Screen (The King) */
.blindfold-screen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #000000;
  z-index: 100;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 24px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s;
}

.blindfold-screen.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.blindfold-title {
  color: var(--color-secondary);
  font-size: 3rem;
  margin-bottom: 24px;
  text-shadow: 0 0 20px rgba(239, 68, 68, 0.5);
}

.blindfold-timer {
  font-size: 6rem;
  font-weight: 900;
  color: var(--color-primary);
  margin-bottom: 16px;
  text-shadow: 0 0 20px rgba(250, 204, 21, 0.5);
}

.blindfold-sub {
  color: #888;
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 48px;
}

.press-wrapper {
  position: relative;
  width: 100%;
  max-width: 300px;
}

.ready-btn {
  width: 100%;
  background: none;
  border: 4px solid var(--color-secondary);
  color: var(--color-text);
  font-family: inherit;
  font-size: 1.5rem;
  font-weight: 900;
  padding: 20px;
  border-radius: var(--radius-full);
  outline: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  position: relative;
  z-index: 2;
  overflow: hidden;
  cursor: pointer;
}

.press-progress {
  position: absolute;
  top: 4px;
  left: 4px;
  bottom: 4px;
  width: 0%;
  background-color: var(--color-secondary);
  border-radius: var(--radius-full);
  z-index: 1;
  pointer-events: none;
  transition: width 0.1s linear;
}

/* --- Mutiny Filter Drawer --- */
.game-nav-filter {
  background: none;
  border: none;
  font-size: 2rem;
  font-weight: 900;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  transition: color var(--transition-fast), transform var(--transition-fast);
}

.game-nav-filter:active {
  transform: scale(0.9);
  color: var(--color-primary);
}

.filter-drawer {
  max-height: 80vh;
  overflow-y: auto;
}

.filter-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.filter-tag-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 4px;
  border-bottom: 1px solid var(--color-border);
}

.filter-tag-row:last-child {
  border-bottom: none;
}

.filter-tag-label {
  font-size: 1.1rem;
  font-weight: 800;
  text-transform: capitalize;
  color: var(--color-text);
  display: flex;
  align-items: center;
  gap: 10px;
}

.filter-tag-icon {
  font-size: 1.3rem;
}

/* Toggle Switch */
.toggle-switch {
  position: relative;
  width: 56px;
  height: 32px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--color-bg-alt);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-full);
  transition: background-color 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  height: 24px;
  width: 24px;
  left: 2px;
  bottom: 2px;
  background-color: var(--color-text-muted);
  border-radius: 50%;
  transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275), background-color 0.25s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.toggle-switch input:checked + .toggle-slider {
  background-color: rgba(250, 204, 21, 0.2);
  border-color: var(--color-primary);
  box-shadow: 0 0 8px rgba(250, 204, 21, 0.3);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(24px);
  background-color: var(--color-primary);
}

/* --- Grand Prix Styles --- */
.gp-container {
  min-height: 100vh;
  background-color: #0f172a;
  color: #f8fafc;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding-top: 20px;
  position: relative;
  overflow: hidden;
}

.gp-panel {
  flex-grow: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
}

.gp-title {
  color: var(--color-primary);
  font-size: 3rem;
  font-weight: 900;
  text-transform: uppercase;
  text-shadow: 0 4px 10px rgba(0,0,0,0.5);
  margin-bottom: 8px;
}

.gp-subtitle {
  color: var(--color-text-muted);
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 16px;
}

.gp-heading {
  color: var(--color-secondary);
  font-size: 2rem;
  margin-bottom: 24px;
  font-weight: 900;
}

.gp-pass-name {
  font-size: 2.5rem;
  font-weight: 900;
  color: var(--color-primary);
  margin: 16px 0;
}

.ladder-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 400px;
}

.ladder-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--color-bg-alt);
  padding: 12px 24px;
  border-radius: var(--radius-md);
  border: 2px solid var(--color-border);
  transition: transform var(--transition-bounce);
}

.ladder-item-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.ladder-rank {
  font-size: 1.5rem;
  font-weight: 900;
  width: 30px;
  text-align: left;
}

.ladder-points {
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--color-primary);
}

/* Podium Styles */
.podium-container {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 12px;
  height: 200px;
  margin-bottom: 32px;
}

.podium-block {
  width: 90px;
  background: var(--color-bg-alt);
  border: 3px solid var(--color-primary);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding-top: 16px;
  font-size: 2rem;
  font-weight: 900;
  color: var(--color-primary);
  position: relative;
  box-shadow: inset 0 20px 30px rgba(0,0,0,0.5);
  transform: translateY(100vh);
  animation: dropIn var(--transition-bounce) forwards;
}

.podium-block.first { height: 160px; animation-delay: 0.4s; }
.podium-block.second { height: 120px; animation-delay: 0.2s; }
.podium-block.third { height: 90px; animation-delay: 0s; }

.podium-avatar {
  position: absolute;
  top: -60px;
  left: 50%;
  transform: translateX(-50%);
}

.podium-losers {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
  margin-top: 24px;
}

.podium-loser {
  opacity: 0.5;
  animation: wiggle 2s infinite ease-in-out;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

@keyframes dropIn {
  from { transform: translateY(100vh); }
  to { transform: translateY(0); }
}



/* --- THE GRAND PRIX EXPANSION (F1 LIVERY) --- */

:root {
  --color-fl: #a855f7;       /* Fastest Lap Purple */
  --color-timing: white;   /* Neon Cyan */
}

/* The Kerbs */
.gp-kerb {
  position: relative;
}
.gp-kerb::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 12px;
  background: repeating-linear-gradient(45deg, #ef4444, #ef4444 15px, #ffffff 15px, #ffffff 30px);
  z-index: 10;
  border-top-left-radius: inherit;
  border-top-right-radius: inherit;
  border-top: 2px solid rgba(0,0,0,0.2);
  border-bottom: 2px solid rgba(0,0,0,0.2);
}

/* Pavement Header */
.gp-container .game-nav {
  position: relative;
  top: 0;
  left: 0;
  right: 0;
  padding: 20px 24px 30px;
  background: #334155;
  background-image: url('data:image/svg+xml;utf8,<svg width="40" height="40" xmlns="http://www.w3.org/2000/svg"><filter id="n"><feTurbulence type="fractalNoise" baseFrequency="0.8" numOctaves="2" stitchTiles="stitch"/></filter><rect width="100%" height="100%" filter="url(%23n)" opacity="0.1"/></svg>');
  border-bottom: 12px solid transparent;
  margin-bottom: 10px;
  z-index: 100;
}

.gp-container .game-nav::after {
  content: '';
  position: absolute;
  bottom: -12px;
  left: 0;
  right: 0;
  height: 12px;
  background: repeating-linear-gradient(45deg, #ef4444, #ef4444 15px, #ffffff 15px, #ffffff 30px);
  border-top: 2px solid rgba(0,0,0,0.3);
  box-shadow: 0 4px 10px rgba(0,0,0,0.5);
}

/* Checkered Background */
.bg-checkered {
  background-color: var(--color-bg) !important;
  background-image: conic-gradient(at 50% 50%, rgba(255,255,255,0.02) 90deg, transparent 90deg 180deg, rgba(255,255,255,0.02) 180deg 270deg, transparent 270deg) !important;
  background-size: 40px 40px !important;
}

/* Gravel Trap */
.gravel-trap {
  background: #333 url('data:image/svg+xml;utf8,<svg width="20" height="20" xmlns="http://www.w3.org/2000/svg"><filter id="n"><feTurbulence type="fractalNoise" baseFrequency="0.9" numOctaves="3" stitchTiles="stitch"/></filter><rect width="100%" height="100%" filter="url(%23n)" opacity="0.2"/></svg>');
  opacity: 0.5;
  border-radius: var(--radius-md);
  padding: 16px;
  position: relative;
  overflow: hidden;
}

.f1-light {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background-color: #404040;
  transition: background-color 0.1s, box-shadow 0.1s;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.5);
}

/* Settings Options */
.settings-option {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  padding: 14px 16px;
  background: var(--color-bg-alt);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.settings-option:active {
  opacity: 0.8;
}

.settings-option.is-selected {
  border-color: var(--color-primary);
  background: color-mix(in srgb, var(--color-primary) 12%, var(--color-bg-alt));
}

.settings-option-label {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--color-text);
}

.settings-option.is-selected .settings-option-label {
  color: var(--color-primary);
}

.settings-option-desc {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

/* Avatar animation modes */
/* Animated once: play once and pause using animation-iteration-count */
body[data-avatar-mode="once"] .avatar-image {
  animation-iteration-count: 1;
  /* Note: GIF looping is controlled by the GIF file itself, not CSS.
     We work around this by re-assigning the src on each render so
     the GIF plays once from the start. */
}

/* Static mode is handled by the canvas snapshot in JS */
.avatar-static-canvas {
  display: block;
}

/* ============================================
   MUTINY — CREW MANIFEST STARTING SCREEN
   ============================================ */

.crew-manifest {
  position: fixed;
  inset: 0;
  background-color: #0f172a;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px 40px;
  z-index: 200;
  overflow-y: auto;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.crew-manifest.is-leaving {
  opacity: 0;
  transform: translateY(-30px);
  pointer-events: none;
}

.crew-manifest-header {
  width: 100%;
  text-align: center;
  padding-top: 72px;
  padding-bottom: 8px;
}

.crew-manifest-skull {
  font-size: 3.5rem;
  display: block;
  margin-bottom: 12px;
  filter: drop-shadow(0 4px 12px rgba(250,204,21,0.4));
  animation: crewSkullFloat 3s ease-in-out infinite;
}

@keyframes crewSkullFloat {
  0%, 100% { transform: translateY(0px) rotate(-3deg); }
  50%       { transform: translateY(-8px) rotate(3deg); }
}

.crew-manifest-title {
  font-size: 2.4rem;
  font-weight: 900;
  color: #facc15;
  text-transform: uppercase;
  letter-spacing: -1px;
  text-shadow: 0 4px 16px rgba(250,204,21,0.35);
  margin-bottom: 6px;
}

.crew-manifest-subtitle {
  font-size: 1rem;
  font-weight: 700;
  color: #64748b;
  margin-bottom: 0;
}

.crew-manifest-hint {
  font-size: 0.85rem;
  font-weight: 700;
  color: #475569;
  margin-top: 8px;
}

.crew-avatar-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 20px;
  width: 100%;
  padding: 24px 0 8px;
  flex: 1;
  align-content: center;
}

.crew-avatar-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  position: relative;
  -webkit-tap-highlight-color: transparent;
  transition: transform var(--transition-bounce);
}

.crew-avatar-item:active {
  transform: scale(0.92);
}

.crew-avatar-frame {
  width: 72px;
  height: 72px;
  border-radius: 0;
  background-color: #1e293b;
  border: 3px solid #334155;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.4rem;
  overflow: visible;
  position: relative;
  transition: border-color 0.25s ease, box-shadow 0.25s ease, background-color 0.25s ease;
}

.crew-avatar-item.has-card .crew-avatar-frame {
  border-color: #facc15;
  box-shadow: 0 0 18px rgba(250,204,21,0.4);
  background-color: rgba(250,204,21,0.08);
}

.crew-avatar-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
  pointer-events: none;
  -webkit-user-drag: none;
}

/* Badge shown when a card has been set */
.crew-card-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background-color: #facc15;
  color: #000;
  font-size: 0.75rem;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
  border: 2px solid #0f172a;
  opacity: 0;
  transform: scale(0);
  transition: opacity 0.2s var(--transition-bounce), transform 0.2s var(--transition-bounce);
  pointer-events: none;
}

.crew-avatar-item.has-card .crew-card-badge {
  opacity: 1;
  transform: scale(1);
}

.crew-avatar-name {
  font-size: 0.8rem;
  font-weight: 800;
  color: #64748b;
  text-align: center;
  max-width: 72px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color 0.2s ease;
}

.crew-avatar-item.has-card .crew-avatar-name {
  color: #fde68a;
}

.crew-set-sail-btn {
  background: linear-gradient(135deg, #facc15, #f59e0b);
  color: #1a0a00;
  box-shadow: 0 6px 0 #92400e;
  font-size: 1.3rem;
  letter-spacing: 1px;
  width: 100%;
  max-width: 320px;
  margin-top: 16px;
  position: relative;
  overflow: hidden;
}

.crew-set-sail-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.15), transparent);
  pointer-events: none;
}

.crew-set-sail-btn:active {
  box-shadow: 0 0 0 #92400e;
}

/* Wave divider */
.crew-wave {
  width: 100%;
  text-align: center;
  font-size: 1.4rem;
  letter-spacing: 4px;
  color: #1e3a5f;
  margin: 4px 0;
  user-select: none;
}

/* ============================================
   MUTINY — CARD BUILDER MODAL
   ============================================ */

#card-builder-overlay {
  z-index: 300;
}

.card-builder-modal {
  background-color: #fde68a;
  border-radius: 8px;
  padding: 28px 20px 24px;
  text-align: center;
  width: 100%;
  max-width: 420px;
  border: 6px solid #92400e;
  box-shadow: 0 8px 40px rgba(0,0,0,0.8), inset 0 0 40px rgba(146,64,14,0.15);
  transform: scale(0.9) translateY(20px);
  transition: transform var(--transition-bounce);
  max-height: 90vh;
  overflow-y: auto;
}

.rule-overlay.is-visible .card-builder-modal {
  transform: scale(1) translateY(0);
}

.card-builder-player-tag {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
  margin-bottom: 14px;
}

.card-builder-avatar {
  width: 42px;
  height: 42px;
  border-radius: 0;
  background-color: #92400e;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  overflow: visible;
  flex-shrink: 0;
}

.card-builder-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
  pointer-events: none;
}

.card-builder-player-name {
  font-size: 1.1rem;
  font-weight: 900;
  color: #78350f;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.card-builder-title {
  font-size: 1.3rem;
  font-weight: 900;
  color: #78350f;
  text-transform: uppercase;
  letter-spacing: -0.5px;
  margin-bottom: 12px;
}

/* The editable card text area */
.card-editable-wrapper {
  position: relative;
  margin-bottom: 14px;
}

.card-editable {
  width: 100%;
  min-height: 90px;
  background: rgba(146,64,14,0.08);
  border: 2px dashed #c2782f;
  border-radius: 8px;
  padding: 12px;
  font-family: 'Nunito', sans-serif;
  font-size: 1.1rem;
  font-weight: 800;
  color: #451a03;
  line-height: 1.5;
  text-align: left;
  outline: none;
  cursor: text;
  transition: border-color 0.2s, background 0.2s;
  word-break: break-word;
  -webkit-user-select: text;
  user-select: text;
}

.card-editable:focus {
  border-color: #92400e;
  background: rgba(146,64,14,0.12);
}

.card-editable:empty::before {
  content: attr(data-placeholder);
  color: #a87f55;
  font-weight: 700;
  pointer-events: none;
}

/* Token chips row */
.card-token-section {
  margin-bottom: 14px;
}

.card-token-label {
  font-size: 0.75rem;
  font-weight: 900;
  color: #92400e;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.card-token-row {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.card-token-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 7px 14px;
  background: #92400e;
  color: #fde68a;
  border: none;
  border-radius: var(--radius-full);
  font-family: 'Nunito', sans-serif;
  font-size: 0.9rem;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 3px 0 #78350f;
  transition: transform 0.1s ease, box-shadow 0.1s ease, background 0.15s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  draggable: true;
}

.card-token-chip:active {
  transform: translateY(3px);
  box-shadow: 0 0 0 #78350f;
}

.card-token-chip.inserting {
  background: #ca8a04;
  transform: scale(1.08) translateY(0);
}

/* Tag section */
.card-tag-section {
  margin-bottom: 16px;
}

.card-tag-label {
  font-size: 0.75rem;
  font-weight: 900;
  color: #92400e;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 8px;
}

.card-tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  justify-content: center;
}

.card-tag-pill {
  padding: 5px 12px;
  border-radius: var(--radius-full);
  background: rgba(146,64,14,0.12);
  border: 2px solid rgba(146,64,14,0.3);
  color: #92400e;
  font-family: 'Nunito', sans-serif;
  font-size: 0.8rem;
  font-weight: 900;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.card-tag-pill.is-active {
  background: #92400e;
  border-color: #78350f;
  color: #fde68a;
}

.card-tag-pill:active {
  transform: scale(0.94);
}

/* Builder action buttons */
.card-builder-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card-builder-save-btn {
  background-color: #92400e;
  color: #fde68a;
  box-shadow: 0 5px 0 #78350f;
  font-size: 1.1rem;
}

.card-builder-save-btn:active {
  box-shadow: 0 0 0 #78350f;
}

.card-builder-clear-btn {
  background-color: rgba(146,64,14,0.12);
  color: #78350f;
  border: 2px solid rgba(146,64,14,0.3);
  box-shadow: none;
  font-size: 0.9rem;
  padding: 12px 24px;
}

.card-builder-clear-btn:active {
  transform: scale(0.97);
}

/* Rope divider */
.card-rope-divider {
  border: none;
  border-top: 2px dashed rgba(146,64,14,0.3);
  margin: 12px 0;
}

/* ============================================
   CREW COMPASS — Phase 2 Visualiser
   ============================================ */

.group-visualizer {
  display: flex;
  align-items: center;
  justify-content: center;
  /* Enough room for the ring + active glow */
  width: 220px;
  height: 220px;
  margin: 0 auto 12px;
  position: relative;
  flex-shrink: 0;
}

.crew-ring {
  position: relative;
  width: 180px;
  height: 180px;
  /* animation-name driven by .rotateCW / .rotateCCW classes set by JS */
}

.crew-ring.rotateCW  { animation: rotateCW  12s linear infinite; }
.crew-ring.rotateCCW { animation: rotateCCW 12s linear infinite; }

@keyframes rotateCW  { from { transform: rotate(0deg);   } to { transform: rotate(360deg);  } }
@keyframes rotateCCW { from { transform: rotate(0deg);   } to { transform: rotate(-360deg); } }

.crew-ring-avatar {
  position: absolute;
  /* Centred on the ring's midpoint */
  top: 50%;
  left: 50%;
  width: 44px;
  height: 44px;
  margin-top: -22px;
  margin-left: -22px;
  border-radius: 0;
  background-color: #1e293b;
  border: 2px solid #334155;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  overflow: visible;
  transition: box-shadow 0.3s ease, border-color 0.3s ease;
}

/* Counter-rotate avatars so they always face up while the ring spins */
.crew-ring.rotateCW  .crew-ring-avatar { animation: counterRotateCW  12s linear infinite; }
.crew-ring.rotateCCW .crew-ring-avatar { animation: counterRotateCCW 12s linear infinite; }

/* Counter-rotation is the opposite direction to keep avatars upright */
@keyframes counterRotateCW  { from { transform: rotate(0deg);   } to { transform: rotate(-360deg); } }
@keyframes counterRotateCCW { from { transform: rotate(0deg);   } to { transform: rotate(360deg);  } }

.crew-ring-avatar img,
.crew-ring-avatar canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 0;
  pointer-events: none;
  display: block;
}

/* Active / starting player glows gold */
.crew-ring-avatar.is-active {
  border-color: #facc15;
  box-shadow:
    0 0 0 3px rgba(250,204,21,0.8),
    0 0 18px rgba(250,204,21,0.55),
    0 0 32px rgba(250,204,21,0.25);
  z-index: 5;
}

/* ============================================
   TRANSITION SYSTEM — Phase 3
   ============================================ */

/* Shared card shell */
.transition-card {
  background: linear-gradient(160deg, #0c1f3f 0%, #020a18 100%);
  border-radius: var(--radius-lg);
  padding: 40px 28px 36px;
  text-align: center;
  width: 100%;
  max-width: 360px;
  border: 2px solid #1e3a5f;
  box-shadow: 0 8px 40px rgba(0,0,0,0.8);
  position: relative;
  overflow: hidden;
  transform: scale(0.9);
  transition: transform var(--transition-bounce);
}

.rule-overlay.is-visible .transition-card {
  transform: scale(1);
}

/* ── Reverse Panel ── */
.reverse-panel {
  flex-direction: column;
  align-items: center;
  gap: 12px;
  position: relative;
  z-index: 2;
}

/* The SVG sits full-width behind the text */
.wind-lines {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}

/* Animated dash-offset for each wind line path */
.wind-line {
  stroke-dasharray: 320;
  stroke-dashoffset: 320;
  animation: windLineDraw 0.9s ease-out forwards;
}
.wl-1 { animation-delay: 0s;    }
.wl-2 { animation-delay: 0.15s; }
.wl-3 { animation-delay: 0.3s;  }

@keyframes windLineDraw {
  from { stroke-dashoffset: 320; opacity: 0.2; }
  60%  { stroke-dashoffset: 0;   opacity: 1;   }
  to   { stroke-dashoffset: -40; opacity: 0;   }
}

.reverse-icon {
  font-size: 3.5rem;
  position: relative;
  z-index: 2;
  animation: reverseIconSpin 0.7s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}

@keyframes reverseIconSpin {
  from { transform: rotate(-180deg) scale(0.4); opacity: 0; }
  to   { transform: rotate(0deg)    scale(1);   opacity: 1; }
}

.reverse-title {
  font-size: 1.8rem;
  font-weight: 900;
  color: #facc15;
  text-transform: uppercase;
  letter-spacing: -0.5px;
  text-shadow: 0 0 20px rgba(250,204,21,0.5);
  position: relative;
  z-index: 2;
  margin: 0;
}

.reverse-direction {
  font-size: 1rem;
  font-weight: 800;
  color: #94a3b8;
  letter-spacing: 0.5px;
  position: relative;
  z-index: 2;
  margin: 0;
}

/* ── Pass the Phone Panel ── */
.pass-panel {
  flex-direction: column;
  align-items: center;
  gap: 10px;
  position: relative;
  z-index: 2;
}

.pass-label {
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: #64748b;
  margin: 0;
}

.pass-avatar {
  width: 100px;
  height: 100px;
  border-radius: 0;
  background-color: #1e293b;
  border: 3px solid #facc15;
  box-shadow: 0 0 24px rgba(250,204,21,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  overflow: visible;
  animation: passAvatarPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}

@keyframes passAvatarPop {
  from { transform: scale(0.5); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

.pass-avatar img,
.pass-avatar canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
  pointer-events: none;
  display: block;
}

.pass-name {
  font-size: 2rem;
  font-weight: 900;
  color: #f8fafc;
  margin: 0;
}

.pass-hint {
  font-size: 0.85rem;
  font-weight: 700;
  color: #475569;
  margin: 0;
  letter-spacing: 0.5px;
}

/* ══════════════════════════════════════
   TREASURE CASE OPENING SCREEN
   ══════════════════════════════════════ */

/* Full-screen overlay — replaces the generic rule-overlay */
.treasure-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.88);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.treasure-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

/* Modal card */
.treasure-modal {
  position: relative;
  width: calc(100vw - 32px);
  max-width: 480px;
  background: linear-gradient(160deg, #0c1a3a 0%, #020a18 100%);
  border: 2px solid #facc15;
  border-radius: 16px;
  padding: 28px 0 24px;
  overflow: hidden;
  box-shadow: 0 0 60px rgba(250, 204, 21, 0.2), 0 24px 48px rgba(0,0,0,0.8);
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* Background GIF — tiny, bottom-right corner, decorative only */
.treasure-bg-gif {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.25;
  pointer-events: none;
  z-index: 0;
  border-radius: 0 0 14px 0;
}

/* All content sits above the gif */
.treasure-content {
  position: relative;
  z-index: 1;
}

/* Header */
.treasure-header {
  text-align: center;
  padding: 0 24px 20px;
  border-bottom: 1px solid rgba(250, 204, 21, 0.15);
}
.treasure-icon {
  font-size: 2.4rem;
  display: block;
  margin-bottom: 6px;
  filter: drop-shadow(0 0 12px rgba(250, 204, 21, 0.6));
}
.treasure-title {
  font-size: 1.4rem;
  font-weight: 900;
  color: #facc15;
  letter-spacing: 3px;
  text-transform: uppercase;
  margin: 0 0 4px;
}
.treasure-subtitle {
  font-size: 0.8rem;
  color: #94a3b8;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin: 0;
}

/* Reel strip */
.treasure-reel-wrap {
  position: relative;
  width: 100%;
  height: 108px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.4);
  border-top: 2px solid rgba(250, 204, 21, 0.25);
  border-bottom: 2px solid rgba(250, 204, 21, 0.25);
  margin: 20px 0;
}

/* Center marker line */
.treasure-reel-marker {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 3px;
  background: #facc15;
  box-shadow: 0 0 12px #facc15;
  transform: translateX(-50%);
  z-index: 5;
  pointer-events: none;
}
/* Marker arrows */
.treasure-reel-marker::before,
.treasure-reel-marker::after {
  content: '';
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
}
.treasure-reel-marker::before {
  top: 0;
  border-top: 8px solid #facc15;
}
.treasure-reel-marker::after {
  bottom: 0;
  border-bottom: 8px solid #facc15;
}

/* The scrolling track — horizontal, nowrap, no padding tricks */
.treasure-reel-track {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
  height: 100%;
  will-change: transform;
  padding: 0 8px;
}

/* Individual frame cards in the reel */
.treasure-reel-item {
  flex: 0 0 88px;
  width: 88px;
  height: 88px;
  background: #0f2040;
  border: 2px solid #1e3a5f;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: border-color 0.3s, box-shadow 0.3s, transform 0.3s;
}
.treasure-reel-item img,
.treasure-reel-item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  display: block;
}
.treasure-reel-item.is-winner {
  border-color: #facc15;
  box-shadow: 0 0 24px rgba(250, 204, 21, 0.6);
  transform: scale(1.08);
  z-index: 2;
}

/* Result reveal */
.treasure-result {
  text-align: center;
  padding: 0 24px 4px;
  animation: treasureReveal 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}
@keyframes treasureReveal {
  from { opacity: 0; transform: translateY(12px) scale(0.9); }
  to   { opacity: 1; transform: none; }
}
.treasure-winner-name {
  font-size: 1rem;
  font-weight: 800;
  color: #facc15;
  text-transform: uppercase;
  letter-spacing: 2px;
  margin: 0;
}

/* Actions */
.treasure-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 24px;
  animation: treasureReveal 0.4s 0.1s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}