/* ==========================================================================
   Design System & Custom Properties
   ========================================================================== */
:root {
  /* Typography */
  --font-family-title: 'Outfit', sans-serif;
  --font-family-sans: 'Inter', sans-serif;

  /* Colors */
  --color-bg-darkest: hsl(225, 25%, 7%);
  --color-bg-darker: hsl(225, 20%, 12%);
  --color-bg-card: hsla(225, 18%, 18%, 0.65);
  
  /* Harmonious, Curated Palette */
  --color-gold: hsl(45, 95%, 50%);
  --color-gold-glow: hsla(45, 95%, 50%, 0.35);
  --color-ruby: hsl(342, 85%, 52%);
  --color-ruby-glow: hsla(342, 85%, 52%, 0.3);
  --color-amber: hsl(35, 95%, 55%);
  --color-amber-glow: hsla(35, 95%, 55%, 0.3);
  --color-emerald: hsl(152, 75%, 43%);
  --color-emerald-glow: hsla(152, 75%, 43%, 0.3);
  --color-sapphire: hsl(207, 85%, 52%);
  --color-sapphire-glow: hsla(207, 85%, 52%, 0.3);
  
  --color-text-primary: hsl(225, 25%, 95%);
  --color-text-secondary: hsl(225, 15%, 70%);
  --color-text-muted: hsl(225, 12%, 50%);
  
  /* Borders and Blurs */
  --border-glass: 1px solid hsla(0, 0%, 100%, 0.08);
  --border-glass-focus: 1px solid hsla(0, 0%, 100%, 0.2);
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;
  --blur-glass: blur(16px);
  
  /* Shadows */
  --shadow-glass: 0 8px 32px 0 rgba(0, 0, 0, 0.45);
  --shadow-gold: 0 0 20px var(--color-gold-glow);
  
  /* Animations */
  --transition-smooth: 0.25s cubic-bezier(0.25, 0.8, 0.25, 1);
  --transition-fast: 0.15s ease;
}

/* ==========================================================================
   Global Reset & Base Styles
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--color-bg-darkest);
  background-image: radial-gradient(circle at 50% 30%, hsl(225, 25%, 15%) 0%, var(--color-bg-darkest) 70%);
  color: var(--color-text-primary);
  font-family: var(--font-family-sans);
  min-height: 100dvh;
  overflow-x: hidden;
  display: flex;
  padding: 1.5rem;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--color-bg-darkest);
}
::-webkit-scrollbar-thumb {
  background: hsl(225, 15%, 22%);
  border-radius: var(--radius-sm);
}
::-webkit-scrollbar-thumb:hover {
  background: hsl(225, 15%, 30%);
}

/* App Container */
.app-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 1200px;
  min-height: 850px;
  height: calc(100dvh - 3rem);
  margin: auto;
  gap: 1.5rem;
}

/* ==========================================================================
   Header Component
   ========================================================================== */
.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  background: var(--color-bg-card);
  backdrop-filter: var(--blur-glass);
  border: var(--border-glass);
  box-shadow: var(--shadow-glass);
  border-radius: var(--radius-lg);
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-area h1 {
  font-family: var(--font-family-title);
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: 2px;
  background: linear-gradient(135deg, hsl(0, 0%, 100%) 30%, var(--color-gold) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.25rem 0.6rem;
  border-radius: 50px;
  letter-spacing: 1px;
}

.solo-badge {
  background: var(--color-gold-glow);
  color: var(--color-gold);
  border: 1px solid var(--color-gold);
}

.deck-stats {
  display: flex;
  gap: 1.25rem;
}

.stat-box {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: hsla(0, 0%, 100%, 0.04);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid hsla(0, 0%, 100%, 0.05);
}

.stat-icon {
  font-size: 1.3rem;
}

.stat-value-container {
  display: flex;
  flex-direction: column;
}

.stat-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  color: var(--color-text-muted);
  letter-spacing: 0.5px;
}

.stat-value {
  font-family: var(--font-family-title);
  font-weight: 700;
  font-size: 1.1rem;
}

/* Castle Breakdown */
.castle-stat-box {
  gap: 0.6rem;
  min-width: 15.5rem; /* Make it wider to accommodate the breakdown elements comfortably */
}

.castle-breakdown {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding-left: 0.6rem;
  border-left: 1px solid hsla(0, 0%, 100%, 0.08);
}

.castle-breakdown-items {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.castle-type-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.7rem;
  transition: opacity var(--transition-smooth);
}

.castle-type-label {
  font-weight: 700;
  color: var(--color-text-secondary);
  min-width: 2rem;
  font-family: var(--font-family-title);
}

.castle-type-pips {
  display: flex;
  gap: 0.25rem;
  align-items: center;
}

.pip {
  font-size: 0.75rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 1px 4px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  transition: all var(--transition-smooth);
}

.pip.suit-hearts { color: var(--color-ruby); }
.pip.suit-diamonds { color: var(--color-amber); }
.pip.suit-clubs { color: var(--color-emerald); }
.pip.suit-spades { color: var(--color-sapphire); }

.pip.pip-defeated {
  text-decoration: line-through;
  opacity: 0.12;
  background: rgba(0, 0, 0, 0.25);
  border: 1px dashed rgba(255, 255, 255, 0.04);
  filter: grayscale(100%);
}

.pip.pip-waiting {
  opacity: 0.9;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.pip.pip-fighting {
  opacity: 1;
  font-weight: 700;
  animation: pip-pulse 2s infinite ease-in-out;
}

.pip.pip-fighting.suit-hearts {
  background: rgba(244, 63, 94, 0.18);
  border: 1px solid var(--color-ruby);
  box-shadow: 0 0 8px var(--color-ruby-glow);
}
.pip.pip-fighting.suit-diamonds {
  background: rgba(245, 158, 11, 0.18);
  border: 1px solid var(--color-amber);
  box-shadow: 0 0 8px var(--color-amber-glow);
}
.pip.pip-fighting.suit-clubs {
  background: rgba(16, 185, 129, 0.18);
  border: 1px solid var(--color-emerald);
  box-shadow: 0 0 8px var(--color-emerald-glow);
}
.pip.pip-fighting.suit-spades {
  background: rgba(59, 130, 246, 0.18);
  border: 1px solid var(--color-sapphire);
  box-shadow: 0 0 8px var(--color-sapphire-glow);
}

@keyframes pip-pulse {
  0% { transform: scale(1.1); }
  50% { transform: scale(1.28); }
  100% { transform: scale(1.1); }
}

.castle-type-fraction {
  font-family: var(--font-family-title);
  font-weight: 700;
  font-size: 0.6rem;
  color: var(--color-text-muted);
  min-width: 1.5rem;
}

.castle-type-row.cleared {
  opacity: 0.5;
}

.castle-type-row.cleared .castle-type-label {
  text-decoration: line-through;
  color: var(--color-emerald);
}

.castle-type-row.cleared .castle-type-fraction {
  color: var(--color-emerald);
}

.castle-next {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.65rem;
  margin-top: 0.15rem;
  padding-top: 0.25rem;
  border-top: 1px solid hsla(0, 0%, 100%, 0.05);
}

.castle-next-label {
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.castle-next-value {
  font-family: var(--font-family-title);
  font-weight: 700;
  font-size: 0.7rem;
  color: var(--color-gold);
  text-shadow: 0 0 6px var(--color-gold-glow);
}

/* ==========================================================================
   Main Game Board Layout
   ========================================================================== */
.game-board {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 1.5rem;
  flex: 1;
  min-height: 0; /* Important for scrollable grid items */
}

/* Battle Arena */
.arena {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 1.5rem;
  background: var(--color-bg-card);
  backdrop-filter: var(--blur-glass);
  border: var(--border-glass);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-glass);
  padding: 1.5rem;
  min-height: 0;
}

.arena-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: 0;
}

.arena-section h2 {
  font-family: var(--font-family-title);
  font-size: 1.1rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--color-text-secondary);
  letter-spacing: 1px;
}

/* Enemy Area */
.enemy-card-placeholder {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  background: hsla(0, 0%, 0%, 0.2);
  border: 2px dashed hsla(0, 0%, 100%, 0.05);
  border-radius: var(--radius-lg);
  padding: 1rem;
}

.no-enemy {
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

/* Active Cards Area */
.active-play-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.combat-modifiers {
  display: flex;
  gap: 0.5rem;
}

.modifier-tag {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.shield-tag {
  background: var(--color-sapphire-glow);
  color: var(--color-sapphire);
  border: 1px solid var(--color-sapphire);
}

.double-tag {
  background: var(--color-emerald-glow);
  color: var(--color-emerald);
  border: 1px solid var(--color-emerald);
}

.active-cards-grid {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: flex-start;
  align-items: center;
  background: hsla(0, 0%, 0%, 0.1);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  border: 1px solid hsla(0, 0%, 100%, 0.02);
  overflow-y: auto;
}

.no-cards {
  color: var(--color-text-muted);
  width: 100%;
  text-align: center;
  font-size: 0.9rem;
}

/* ==========================================================================
   Player Resources & Reference Panel
   ========================================================================== */
.player-board {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 1.5rem;
  align-items: end;
}

.player-resources-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 300px;
}

.hand-size-indicator {
  font-family: var(--font-family-title);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--color-text-secondary);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 0.5rem;
}

.hand-size-value {
  font-family: var(--font-family-title);
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--color-gold);
  text-shadow: 0 0 8px var(--color-gold-glow);
}

.player-resources {
  background: var(--color-bg-card);
  backdrop-filter: var(--blur-glass);
  border: var(--border-glass);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-glass);
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 300px;
  height: auto;
  box-sizing: border-box;
}

.resource-section {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.resource-section h3 {
  font-family: var(--font-family-title);
  font-size: 0.8rem;
  text-transform: uppercase;
  color: var(--color-text-secondary);
  letter-spacing: 0.8px;
  margin-bottom: 0.25rem;
}

.resource-section .section-help {
  font-size: 0.62rem;
  color: var(--color-text-muted);
  margin-bottom: 0.35rem;
}

.jester-section {
  /* no border or padding needed at top now */
}

/* Jester Tokens */
.jester-tokens {
  display: flex;
  gap: 1rem;
}

.jester-token {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  background: hsla(0, 0%, 100%, 0.05);
  border: 1px solid hsla(0, 0%, 100%, 0.08);
  border-radius: var(--radius-md);
  padding: 0.4rem 0.5rem;
  cursor: pointer;
  color: var(--color-text-primary);
  font-family: var(--font-family-sans);
  transition: all var(--transition-smooth);
}

.jester-token:hover:not(:disabled) {
  background: var(--color-gold-glow);
  border-color: var(--color-gold);
  box-shadow: var(--shadow-gold);
  transform: translateY(-2px);
}

.jester-token:disabled {
  opacity: 0.25;
  cursor: not-allowed;
  filter: grayscale(1);
}

.jester-icon {
  font-size: 1.4rem;
}

.jester-text {
  font-size: 0.7rem;
  font-weight: 500;
}

/* Battle Log */
.log-section {
  background: var(--color-bg-card);
  backdrop-filter: var(--blur-glass);
  border: var(--border-glass);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-glass);
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
}

.log-section h3 {
  font-family: var(--font-family-title);
  font-size: 0.95rem;
  text-transform: uppercase;
  color: var(--color-text-secondary);
  letter-spacing: 0.8px;
  margin-bottom: 0.5rem;
}

.log-container {
  flex: 1;
  overflow-y: auto;
  font-size: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.75rem;
  background: hsla(0, 0%, 0%, 0.25);
  border-radius: var(--radius-md);
  border: 1px solid hsla(0, 0%, 100%, 0.02);
}

.log-entry {
  line-height: 1.4;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid hsla(0, 0%, 100%, 0.02);
}

.log-entry.system { color: var(--color-text-muted); font-style: italic; }
.log-entry.player { color: var(--color-text-primary); }
.log-entry.enemy { color: var(--color-ruby); }
.log-entry.heal { color: var(--color-ruby); font-weight: 500; }
.log-entry.draw { color: var(--color-amber); font-weight: 500; }
.log-entry.shield { color: var(--color-sapphire); font-weight: 500; }
.log-entry.clubs { color: var(--color-emerald); font-weight: 500; }
.log-entry.victory { color: var(--color-gold); font-weight: bold; font-size: 0.8rem; }
.log-entry.defeat { color: var(--color-ruby); font-weight: bold; font-size: 0.8rem; }

/* ==========================================================================
   Player Area: Controls and Hand
   ========================================================================== */
.player-area {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.player-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.5rem;
  background: var(--color-bg-card);
  backdrop-filter: var(--blur-glass);
  border: var(--border-glass);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-glass);
}

.game-status-banner {
  font-family: var(--font-family-title);
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: 0.5px;
}

.action-buttons {
  display: flex;
  gap: 0.75rem;
}

.hand-container {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  height: 190px;
  position: relative;
  perspective: 1000px;
}

.hand-row {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  max-width: 100%;
  padding: 0 1rem;
}

.hand-row .playing-card:not(:last-child) {
  margin-right: -15px;
}

/* ==========================================================================
   Card Styling: Playing Card
   ========================================================================== */
.playing-card {
  width: 110px;
  height: 165px;
  background: linear-gradient(135deg, hsl(225, 15%, 20%) 0%, hsl(225, 15%, 13%) 100%);
  border: 1px solid hsla(0, 0%, 100%, 0.1);
  border-radius: var(--radius-md);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
  position: relative;
  cursor: pointer;
  user-select: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 0.6rem;
  transition: transform var(--transition-smooth), border var(--transition-fast), box-shadow var(--transition-smooth);
}

.playing-card:hover {
  transform: translateY(-20px) rotate(1deg) scale(1.03);
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.6);
  border-color: hsla(0, 0%, 100%, 0.25);
}

/* Card Selection */
.playing-card.selected {
  transform: translateY(-30px) scale(1.05);
  border: 2px solid var(--color-gold);
  box-shadow: 0 0 15px var(--color-gold-glow), 0 15px 30px rgba(0, 0, 0, 0.6);
}

/* Suits Color Rules */
.playing-card.suit-hearts { color: var(--color-ruby); }
.playing-card.suit-diamonds { color: var(--color-amber); }
.playing-card.suit-clubs { color: var(--color-emerald); }
.playing-card.suit-spades { color: var(--color-sapphire); }

/* Card Corners */
.card-corner {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.1;
  font-family: var(--font-family-title);
  font-weight: 700;
  font-size: 0.95rem;
}

.card-corner span:nth-child(2) {
  font-size: 0.85rem;
}

.card-corner.bottom-right {
  transform: rotate(180deg);
  align-self: flex-end;
}

/* Card Center Symbol */
.card-center {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 2.2rem;
}

/* Boss Card Styling */
.playing-card.boss-card {
  cursor: default;
  width: 140px;
  height: 210px;
  background: linear-gradient(135deg, hsl(225, 20%, 25%) 0%, hsl(225, 20%, 12%) 100%);
  border: 1px solid var(--color-gold);
  box-shadow: 0 0 15px var(--color-gold-glow);
  transform: none !important;
}

.boss-card .card-center {
  font-size: 3.5rem;
  color: var(--color-gold);
  text-shadow: 0 0 10px var(--color-gold-glow);
}

.boss-label {
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--color-gold);
  border: 1px solid var(--color-gold);
  padding: 0.1rem 0.3rem;
  border-radius: 4px;
  margin-top: 0.25rem;
}

/* Boss Health Overlay */
.boss-health-container {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  background: hsla(0, 0%, 0%, 0.4);
  border-radius: var(--radius-sm);
  padding: 0.5rem;
  border: 1px solid hsla(0, 0%, 100%, 0.05);
}

.boss-hp-bar-outer {
  width: 100%;
  height: 6px;
  background: hsla(0, 0%, 0%, 0.6);
  border-radius: 10px;
  overflow: hidden;
}

.boss-hp-bar-inner {
  height: 100%;
  background: linear-gradient(to right, var(--color-ruby), var(--color-amber));
  width: 100%;
  transition: width 0.3s ease;
}

.boss-stats {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  font-weight: 600;
}

.boss-atk { color: var(--color-ruby); }
.boss-hp { color: var(--color-amber); }

/* Card shake animation on damage */
.boss-card.damaged {
  animation: shake 0.4s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-10px) rotate(-1deg); }
  40%, 80% { transform: translateX(10px) rotate(1deg); }
}

/* ==========================================================================
   Buttons & UI Elements
   ========================================================================== */
.btn {
  font-family: var(--font-family-sans);
  font-weight: 600;
  font-size: 0.8rem;
  padding: 0.5rem 1.25rem;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 100px;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--color-gold);
  color: var(--color-bg-darkest);
}
.btn-primary:hover:not(:disabled) {
  background: hsl(45, 95%, 60%);
  box-shadow: 0 0 10px var(--color-gold-glow);
}

.btn-secondary {
  background: hsla(0, 0%, 100%, 0.08);
  color: var(--color-text-primary);
  border: 1px solid hsla(0, 0%, 100%, 0.1);
}
.btn-secondary:hover:not(:disabled) {
  background: hsla(0, 0%, 100%, 0.15);
}

.btn-danger {
  background: var(--color-ruby);
  color: var(--color-text-primary);
  box-shadow: 0 0 10px var(--color-ruby-glow);
}
.btn-danger:hover:not(:disabled) {
  background: hsl(342, 85%, 60%);
}

.btn-outline {
  background: transparent;
  color: var(--color-text-secondary);
  border: 1px solid hsla(0, 0%, 100%, 0.1);
}
.btn-outline:hover:not(:disabled) {
  color: var(--color-text-primary);
  border-color: hsla(0, 0%, 100%, 0.3);
}

.btn-warning {
  color: var(--color-amber);
  border-color: var(--color-amber-glow);
}
.btn-warning:hover:not(:disabled) {
  background: var(--color-amber-glow);
  color: var(--color-text-primary);
}

.hidden {
  display: none !important;
}

/* ==========================================================================
   Dialog (Modal) Overlay Styles
   ========================================================================== */
dialog {
  border: var(--border-glass-focus);
  border-radius: var(--radius-lg);
  background: hsl(225, 20%, 14%);
  color: var(--color-text-primary);
  box-shadow: var(--shadow-glass), 0 0 100px rgba(0, 0, 0, 0.8);
  padding: 2rem;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-width: 500px;
  width: 90%;
  outline: none;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
}

.dialog-content {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.dialog-content h2 {
  font-family: var(--font-family-title);
  font-weight: 700;
  font-size: 1.5rem;
  color: var(--color-gold);
}

.rules-scroll {
  max-height: 300px;
  overflow-y: auto;
  font-size: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding-right: 0.5rem;
  color: var(--color-text-secondary);
  line-height: 1.5;
}

.rules-scroll h3 {
  color: var(--color-text-primary);
  font-size: 0.95rem;
}

.rules-scroll ol, .rules-scroll ul {
  padding-left: 1.25rem;
}

.rules-scroll li {
  margin-bottom: 0.35rem;
}

.text-hearts { color: var(--color-ruby); font-weight: 600; }
.text-diamonds { color: var(--color-amber); font-weight: 600; }
.text-clubs { color: var(--color-emerald); font-weight: 600; }
.text-spades { color: var(--color-sapphire); font-weight: 600; }

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

.text-center {
  text-align: center;
}

#game-over-title {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

#game-over-message {
  color: var(--color-text-secondary);
  font-size: 1rem;
  margin-bottom: 1rem;
}

/* ==========================================================================
   Responsive Queries
   ========================================================================== */
@media (max-width: 900px) {
  body {
    padding: 0.75rem;
  }
  
  .app-container {
    height: 100dvh;
    min-height: auto;
    margin: 0 auto;
    gap: 0.75rem;
  }
  
  .game-board {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 140px;
    gap: 0.75rem;
  }
  
  .arena {
    grid-column: 1;
    grid-row: 1;
  }

  .right-column {
    grid-column: 1;
    grid-row: 2;
    height: 100%;
  }

  .log-section {
    padding: 0.5rem 0.75rem;
    height: 100%;
  }

  .player-board {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    align-items: stretch;
  }

  .player-resources-container {
    width: 100%;
  }

  .player-resources {
    width: 100%;
    height: auto;
    flex-direction: row;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
  }

  .resource-section {
    flex: 1;
  }

  .jester-section {
    border-top: none;
    padding-top: 0;
  }

  .jester-tokens {
    flex-direction: row;
  }

  .jester-token {
    padding: 0.4rem;
  }

  .jester-icon {
    font-size: 1.2rem;
  }

  .jester-text {
    font-size: 0.65rem;
  }

  .arena {
    padding: 1rem;
    gap: 1rem;
    grid-template-columns: 140px 1fr;
  }

  .playing-card.boss-card {
    width: 120px;
    height: 180px;
  }

  .boss-card .card-center {
    font-size: 2.8rem;
  }

  .playing-card {
    width: 80px;
    height: 120px;
    padding: 0.4rem;
  }

  .card-center {
    font-size: 1.6rem;
  }

  .card-corner {
    font-size: 0.75rem;
  }

  .card-corner span:nth-child(2) {
    font-size: 0.75rem;
  }
  
  .hand-container {
    height: 140px;
  }

  .playing-card.selected {
    transform: translateY(-20px) scale(1.05);
  }
  
  .player-controls {
    padding: 0.5rem 1rem;
  }

  .action-buttons {
    gap: 0.4rem;
  }

  .btn {
    min-width: auto;
    padding: 0.4rem 0.8rem;
    font-size: 0.75rem;
  }
}

/* ==========================================================================
   New Layout Utilities: Immunity Notes & Suit Guide
   ========================================================================== */
.enemy-section-header {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.immunity-help-text {
  font-size: 0.65rem;
  color: var(--color-ruby);
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}



/* ==========================================================================
   Views & View Manager
   ========================================================================== */
.view-container {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.view-container.hidden {
  display: none !important;
}

/* ==========================================================================
   Auth Screen Styling
   ========================================================================== */
#auth-view {
  justify-content: center;
  align-items: center;
}

.auth-card {
  background: var(--color-bg-card);
  backdrop-filter: var(--blur-glass);
  border: var(--border-glass);
  box-shadow: var(--shadow-glass);
  border-radius: var(--radius-lg);
  padding: 3rem 2.5rem;
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.auth-title {
  font-family: var(--font-family-title);
  font-size: 2.8rem;
  font-weight: 800;
  letter-spacing: 4px;
  background: linear-gradient(135deg, hsl(0, 0%, 100%) 30%, var(--color-gold) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

.auth-badge {
  margin-top: -0.5rem;
  margin-bottom: 0.5rem;
}

.auth-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.auth-form h2 {
  font-family: var(--font-family-title);
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--color-text-primary);
  text-align: center;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-group label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--color-text-secondary);
  letter-spacing: 0.5px;
}

.form-group input {
  background: hsla(0, 0%, 0%, 0.35);
  border: var(--border-glass);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  color: var(--color-text-primary);
  font-family: var(--font-family-sans);
  font-size: 0.85rem;
  transition: all var(--transition-fast);
  width: 100%;
}

.form-group input:focus {
  outline: none;
  border-color: var(--color-gold);
  box-shadow: 0 0 8px var(--color-gold-glow);
  background: hsla(0, 0%, 0%, 0.5);
}

.password-input-container {
  position: relative;
  display: flex;
  align-items: center;
}

.password-input-container input {
  padding-right: 2.5rem;
}

.btn-toggle-password {
  position: absolute;
  right: 0.75rem;
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition-fast);
}

.btn-toggle-password:hover {
  color: var(--color-text-primary);
}

.btn-block {
  width: 100%;
  padding: 0.75rem;
  font-size: 0.9rem;
}

.auth-switch {
  font-size: 0.8rem;
  color: var(--color-text-secondary);
  text-align: center;
  margin-top: 0.5rem;
}

.auth-switch a {
  color: var(--color-gold);
  text-decoration: none;
  font-weight: 600;
  transition: color var(--transition-fast);
}

.auth-switch a:hover {
  color: hsl(45, 95%, 60%);
  text-decoration: underline;
}

.auth-error-msg {
  width: 100%;
  background: var(--color-ruby-glow);
  border: 1px solid var(--color-ruby);
  color: var(--color-text-primary);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  text-align: center;
  line-height: 1.4;
}

/* ==========================================================================
   Email Verification Screen
   ========================================================================== */
#verify-email-view {
  justify-content: center;
  align-items: center;
}

.verify-card {
  max-width: 460px;
}

.verify-content {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  text-align: center;
}

.verify-content h2 {
  font-family: var(--font-family-title);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--color-text-primary);
}

.verify-icon {
  font-size: 3.5rem;
  animation: verify-pulse 2s ease-in-out infinite;
  filter: drop-shadow(0 0 12px var(--color-gold-glow));
}

@keyframes verify-pulse {
  0%, 100% { transform: scale(1); opacity: 0.9; }
  50% { transform: scale(1.1); opacity: 1; }
}

.verify-description {
  font-size: 0.85rem;
  color: var(--color-text-secondary);
  line-height: 1.6;
  max-width: 360px;
}

.verify-description strong {
  color: var(--color-gold);
  word-break: break-all;
}

.verify-actions {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.verify-status {
  font-size: 0.8rem;
  min-height: 1.2em;
  transition: color var(--transition-fast);
}

.verify-status-success {
  color: var(--color-emerald);
}

.verify-status-error {
  color: var(--color-ruby);
}

/* ==========================================================================
   Dashboard Screen Styling
   ========================================================================== */
.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  background: var(--color-bg-card);
  backdrop-filter: var(--blur-glass);
  border: var(--border-glass);
  box-shadow: var(--shadow-glass);
  border-radius: var(--radius-lg);
  margin-bottom: 1.5rem;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user-email {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--color-text-secondary);
}

.dashboard-content {
  display: grid;
  grid-template-columns: 1.2fr 2fr;
  gap: 1.5rem;
  flex: 1;
  min-height: 0;
}

.dashboard-card {
  background: var(--color-bg-card);
  backdrop-filter: var(--blur-glass);
  border: var(--border-glass);
  box-shadow: var(--shadow-glass);
  border-radius: var(--radius-lg);
  padding: 2rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.promo-card {
  justify-content: center;
  align-items: flex-start;
  gap: 1.5rem;
  background-image: radial-gradient(circle at 100% 100%, var(--color-gold-glow) 0%, transparent 60%);
}

.promo-card h2 {
  font-family: var(--font-family-title);
  font-size: 2rem;
  font-weight: 700;
  color: var(--color-gold);
}

.promo-card p {
  color: var(--color-text-secondary);
  font-size: 0.95rem;
  line-height: 1.6;
}

.btn-lg {
  padding: 0.85rem 2rem;
  font-size: 0.95rem;
  border-radius: var(--radius-md);
}

.list-card {
  gap: 1.5rem;
}

.list-card h2 {
  font-family: var(--font-family-title);
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--color-text-primary);
}

.running-games-grid {
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  padding-right: 0.5rem;
}

.no-active-games {
  grid-column: 1 / -1;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.9rem;
  border: 1px dashed hsla(0, 0%, 100%, 0.05);
  border-radius: var(--radius-md);
  padding: 3rem;
  background: hsla(0, 0%, 0%, 0.15);
}

/* Running Game Card */
.game-card-item {
  background: hsla(0, 0%, 100%, 0.03);
  border: 1px solid hsla(0, 0%, 100%, 0.06);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  transition: all var(--transition-smooth);
}

.game-card-item:hover {
  background: hsla(0, 0%, 100%, 0.06);
  border-color: hsla(0, 0%, 100%, 0.12);
  transform: translateY(-2px);
}

.game-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.game-card-boss {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.95rem;
}

.game-card-boss.hearts { color: var(--color-ruby); }
.game-card-boss.diamonds { color: var(--color-amber); }
.game-card-boss.clubs { color: var(--color-emerald); }
.game-card-boss.spades { color: var(--color-sapphire); }

.game-card-suit-icon {
  font-size: 1.1rem;
}

.game-card-boss-name {
  font-family: var(--font-family-title);
}

.game-card-health-indicator {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.game-card-hp-bar {
  width: 100%;
  height: 4px;
  background: hsla(0, 0%, 0%, 0.4);
  border-radius: 4px;
  overflow: hidden;
}

.game-card-hp-fill {
  height: 100%;
  background: linear-gradient(to right, var(--color-ruby), var(--color-amber));
}

.game-card-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--color-text-muted);
}

.game-card-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.game-card-actions .btn {
  flex: 1;
}

.btn-resign-icon {
  flex: 0 0 35px !important;
  min-width: auto;
  background: hsla(342, 85%, 52%, 0.1);
  color: var(--color-ruby);
  border: 1px solid var(--color-ruby-glow);
}

.btn-resign-icon:hover {
  background: var(--color-ruby);
  color: var(--color-text-primary);
}

/* Back button in game */
.back-btn {
  margin-left: 1rem;
}

@media (max-width: 800px) {
  .dashboard-content {
    grid-template-columns: 1fr;
    overflow-y: auto;
  }
  .promo-card {
    padding: 1.5rem;
  }
}

/* ==========================================================================
   Card Tooltip Styling
   ========================================================================== */
.playing-card {
  position: relative;
}

/* Elevate card on hover to prevent adjacent overlapping cards from covering the tooltip */
.playing-card:hover {
  z-index: 100 !important;
}

.card-tooltip {
  position: absolute;
  bottom: 112%; /* Render above the card with some spacing */
  left: 50%;
  transform: translateX(-50%) translateY(10px) scale(0.95);
  width: 220px;
  background: hsla(225, 24%, 10%, 0.98);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid hsla(0, 0%, 100%, 0.08);
  border-radius: var(--radius-md);
  padding: 0.75rem 0.9rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), 0 0 1px 1px hsla(0, 0%, 100%, 0.05);
  opacity: 0;
  visibility: hidden;
  pointer-events: none; /* Avoid stealing mouse events when not active */
  transition: opacity 0.22s cubic-bezier(0.4, 0, 0.2, 1), 
              transform 0.22s cubic-bezier(0.4, 0, 0.2, 1),
              visibility 0.22s;
  z-index: 200;
  text-align: left;
  color: var(--color-text-secondary);
  font-family: var(--font-family-sans);
  font-size: 0.72rem;
  line-height: 1.4;
  box-sizing: border-box;
}

/* Add a tiny triangle arrow at the bottom of the tooltip */
.card-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border-width: 6px 6px 0;
  border-style: solid;
  border-color: hsla(225, 24%, 10%, 0.98) transparent transparent;
  display: block;
  width: 0;
  z-index: 1;
}

.card-tooltip::before {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border-width: 7px 7px 0;
  border-style: solid;
  border-color: hsla(0, 0%, 100%, 0.08) transparent transparent;
  display: block;
  width: 0;
  z-index: 0;
}

/* Tooltip headers and highlights */
.tooltip-title {
  font-family: var(--font-family-title);
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  margin-bottom: 0.35rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  letter-spacing: 0.5px;
}

.tooltip-summary {
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: 0.35rem;
}

.tooltip-detail {
  font-size: 0.68rem;
  color: var(--color-text-muted);
}

.tooltip-companion {
  margin-top: 0.4rem;
  padding-top: 0.4rem;
  border-top: 1px dashed hsla(0, 0%, 100%, 0.08);
  font-size: 0.65rem;
  color: var(--color-gold);
}

/* Show tooltip on hover */
.playing-card:hover .card-tooltip {
  opacity: 1;
  visibility: visible;
  pointer-events: auto; /* If user hovers tooltip, allow reading it cleanly */
  transform: translateX(-50%) translateY(0) scale(1);
}

/* Suit-specific border accent colors and glow effects for tooltips */
.playing-card.suit-hearts .card-tooltip {
  border-color: var(--color-ruby);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), 0 0 12px var(--color-ruby-glow);
}
.playing-card.suit-hearts .card-tooltip::before {
  border-color: var(--color-ruby) transparent transparent;
}
.playing-card.suit-hearts .tooltip-title {
  color: var(--color-ruby);
}

.playing-card.suit-diamonds .card-tooltip {
  border-color: var(--color-amber);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), 0 0 12px var(--color-amber-glow);
}
.playing-card.suit-diamonds .card-tooltip::before {
  border-color: var(--color-amber) transparent transparent;
}
.playing-card.suit-diamonds .tooltip-title {
  color: var(--color-amber);
}

.playing-card.suit-clubs .card-tooltip {
  border-color: var(--color-emerald);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), 0 0 12px var(--color-emerald-glow);
}
.playing-card.suit-clubs .card-tooltip::before {
  border-color: var(--color-emerald) transparent transparent;
}
.playing-card.suit-clubs .tooltip-title {
  color: var(--color-emerald);
}

.playing-card.suit-spades .card-tooltip {
  border-color: var(--color-sapphire);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), 0 0 12px var(--color-sapphire-glow);
}
.playing-card.suit-spades .card-tooltip::before {
  border-color: var(--color-sapphire) transparent transparent;
}
.playing-card.suit-spades .tooltip-title {
  color: var(--color-sapphire);
}

/* Boss specific tooltip styling */
.playing-card.boss-card .card-tooltip {
  width: 240px;
  border-color: var(--color-gold);
  box-shadow: 0 0 15px var(--color-gold-glow), 0 10px 30px rgba(0, 0, 0, 0.6);
}
.playing-card.boss-card .card-tooltip::before {
  border-color: var(--color-gold) transparent transparent;
}
.playing-card.boss-card .tooltip-title {
  color: var(--color-gold);
}

/* Adjustments for responsiveness - tooltips on smaller screens */
@media (max-width: 800px) {
  .card-tooltip {
    width: 180px;
    padding: 0.5rem 0.6rem;
    font-size: 0.65rem;
    bottom: 108%;
  }
  .tooltip-title {
    font-size: 0.72rem;
    margin-bottom: 0.2rem;
  }
  .tooltip-summary {
    font-size: 0.65rem;
    margin-bottom: 0.2rem;
  }
  .tooltip-detail {
    font-size: 0.6rem;
  }
  .tooltip-companion {
    margin-top: 0.3rem;
    padding-top: 0.3rem;
  }
  .playing-card.boss-card .card-tooltip {
    width: 200px;
  }
}

/* Right Column wrapper (holds log only) */
.right-column {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: 0;
  height: 100%;
}

.right-column .log-section {
  flex: 1;
  min-height: 0;
  height: auto; /* sized by flexbox */
}


