/* ==========================================================================
   Header Component & Stats
   ========================================================================== */
.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,
.logo-area h2,
.logo-area .logo-title {
  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;
}

.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 1.2s ease-in-out infinite;
}

.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);
}

.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: minmax(0, 1fr) 300px;
  gap: 1.25rem;
  flex: 1 0 auto;
  min-height: 360px;
}

/* Battle Arena */
.arena {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 1.25rem;
  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;
  min-height: 360px;
}

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

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

.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;
}

/* Enemy Area */
.enemy-card-placeholder {
  flex: 1;
  display: flex;
  flex-direction: column;
  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: 0.5rem;
}

.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: minmax(0, 1fr) 260px;
  gap: 1rem;
  align-items: end;
}

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

.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: 100%;
  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 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;
}

.jester-token.highlight {
  border-color: var(--color-gold);
  background: var(--color-gold-glow);
  box-shadow:
    var(--shadow-gold),
    0 0 15px var(--color-gold-glow);
  animation: jesterPulse 1s ease-in-out infinite alternate;
}

/* 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 1 auto;
  max-height: 280px;
  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;
}

/* Right Column */
.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;
}

/* Active Players Section */
.players-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;
}

.players-hud-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 180px;
  overflow-y: auto;
}

.player-hud-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.55rem 0.8rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-md);
  transition: all var(--transition-smooth);
}

.player-hud-item.active-turn {
  background: var(--color-gold-glow);
  border-color: var(--color-gold);
  box-shadow: 0 0 10px var(--color-gold-glow);
}

.player-hud-item.active-turn .player-hud-cards {
  animation: hud-cards-pulse 1.5s ease-in-out infinite;
}

.player-hud-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.player-hud-email {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-text-primary);
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}

.player-hud-status {
  font-size: 0.65rem;
  color: var(--color-text-secondary);
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.player-hud-cards {
  font-family: var(--font-family-title);
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--color-gold);
  white-space: nowrap;
}

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

.player-controls {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 0.75rem 1.25rem;
  background: var(--color-bg-card);
  backdrop-filter: var(--blur-glass);
  border: var(--border-glass);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-glass);
}

.player-controls-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  gap: 1rem;
  flex-wrap: wrap;
}

.game-status-banner {
  font-family: var(--font-family-title);
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: 0.5px;
  transition:
    color 0.3s ease,
    text-shadow 0.3s ease;
}

.game-status-banner.turn-player {
  color: var(--color-sapphire);
  text-shadow: 0 0 10px var(--color-sapphire-glow);
}

.game-status-banner.turn-player.turn-waiting {
  color: var(--color-text-secondary);
  text-shadow: none;
  opacity: 0.8;
}

.game-status-banner.turn-discard {
  color: var(--color-ruby);
  text-shadow: 0 0 10px var(--color-ruby-glow);
}

.game-status-banner.turn-discard.turn-waiting {
  color: var(--color-amber);
  text-shadow: 0 0 10px var(--color-amber-glow);
  opacity: 0.8;
}

.game-status-banner.status-won {
  color: var(--color-emerald);
  text-shadow: 0 0 10px var(--color-emerald-glow);
}

.game-status-banner.status-lost {
  color: var(--color-ruby);
  text-shadow: 0 0 10px var(--color-ruby-glow);
}

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

.hand-container {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  height: 200px;
  position: relative;
  perspective: 1000px;
  padding-top: 15px;
  width: 100%;
  min-width: 0;
  overflow: visible;
}

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

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

.hand-row .playing-card.selected {
  margin-left: 2px !important;
  margin-right: 2px !important;
}

/* ==========================================================================
   Card Styling: Playing Card & Bosses
   ========================================================================== */
.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;
  z-index: 1;
  transition:
    transform var(--transition-smooth),
    border var(--transition-fast),
    box-shadow var(--transition-smooth),
    margin var(--transition-fast),
    z-index var(--transition-fast);
}

@media (hover: hover) and (pointer: fine) {
  .playing-card:not(.boss-card):hover {
    z-index: 30;
    transform: translateY(-16px) rotate(1deg) scale(1.03);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.6);
    border-color: hsla(0, 0%, 100%, 0.25);
  }
}

.playing-card:not(.boss-card):focus-visible {
  outline: 2px solid var(--color-gold);
  outline-offset: 2px;
  z-index: 30;
  transform: translateY(-16px) scale(1.03);
  box-shadow:
    0 15px 30px rgba(0, 0, 0, 0.6),
    0 0 12px var(--color-gold-glow);
}

.playing-card.selected {
  z-index: 20;
  transform: translateY(-20px) scale(1.04);
  border: 2px solid var(--color-gold);
  box-shadow:
    0 0 15px var(--color-gold-glow),
    0 15px 30px rgba(0, 0, 0, 0.6);
}

.playing-card.selected:hover {
  z-index: 35;
  transform: translateY(-24px) scale(1.05);
}

.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);
}

.playing-card.suit-jester {
  color: hsl(265, 85%, 65%);
  border-color: hsl(265, 80%, 45%);
  box-shadow: 0 0 10px hsla(265, 80%, 45%, 0.35);
}

@media (hover: hover) and (pointer: fine) {
  .playing-card.suit-jester:hover {
    border-color: hsl(265, 80%, 60%);
    box-shadow: 0 0 15px hsla(265, 80%, 60%, 0.5);
  }
}

.playing-card.suit-jester.selected {
  border-color: var(--color-gold);
  box-shadow:
    0 0 15px var(--color-gold-glow),
    0 15px 30px rgba(0, 0, 0, 0.6);
}

.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 {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 2.2rem;
}

/* Boss Card */
.playing-card.boss-card {
  cursor: default;
  width: 130px;
  height: 185px;
  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);
}

.boss-card .card-center {
  font-size: 3rem;
  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-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 Tooltips */
@media (hover: hover) and (pointer: fine) {
  .playing-card:not(.boss-card):hover {
    z-index: 100 !important;
  }
}

.card-tooltip {
  position: absolute;
  bottom: 104%;
  left: 50%;
  transform: translateX(-50%) translateY(10px) scale(0.95);
  width: 210px;
  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.6rem 0.75rem;
  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;
  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;
}

.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-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);
}

.tooltip-immunity-warning {
  margin-top: 0.5rem;
  padding: 0.4rem 0.5rem;
  background: hsla(342, 85%, 52%, 0.15);
  border: 1px solid var(--color-ruby);
  border-radius: var(--radius-sm);
  color: var(--color-ruby);
  font-size: 0.65rem;
  line-height: 1.35;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  box-shadow: 0 0 8px var(--color-ruby-glow);
}

@media (hover: hover) and (pointer: fine) {
  .playing-card.enemy-immune:hover {
    border-color: var(--color-ruby);
    box-shadow:
      0 15px 30px rgba(0, 0, 0, 0.6),
      0 0 15px var(--color-ruby-glow);
  }
}

.playing-card.enemy-immune:focus-visible {
  outline-color: var(--color-ruby);
  box-shadow:
    0 15px 30px rgba(0, 0, 0, 0.6),
    0 0 15px var(--color-ruby-glow);
}

.playing-card:not(.selected):hover .card-tooltip,
.playing-card:not(.selected):focus-visible .card-tooltip {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0) scale(1);
}

.playing-card.selected .card-tooltip,
.playing-card.selected:hover .card-tooltip {
  display: none !important;
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

.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);
}

.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);
}

/* Combo Calculator HUD */
.combo-calculator-panel {
  width: 100%;
  min-height: 142px;
  height: auto;
  box-sizing: border-box;
  margin-top: 0.5rem;
  border-radius: var(--radius-md);
  background: hsla(225, 24%, 10%, 0.85);
  backdrop-filter: blur(12px);
  border: 1px solid hsla(0, 0%, 100%, 0.08);
  padding: 0.5rem 0.75rem;
  box-shadow: inset 0 1px 0 hsla(0, 0%, 100%, 0.05);
  transition: all var(--transition-normal);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.combo-calc-body {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  height: 100%;
  justify-content: space-between;
}

.combo-status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
}

.combo-status-bar.standby {
  background: hsla(225, 20%, 15%, 0.4);
  border: 1px solid hsla(0, 0%, 100%, 0.05);
  color: var(--color-text-muted);
}

.combo-status-bar.valid {
  background: hsla(152, 60%, 40%, 0.15);
  border: 1px solid hsla(152, 60%, 45%, 0.3);
  color: var(--color-emerald);
}

.combo-status-bar.invalid {
  background: hsla(342, 85%, 52%, 0.15);
  border: 1px solid hsla(342, 85%, 52%, 0.3);
  color: var(--color-ruby);
}

.combo-values-summary {
  font-family: var(--font-family-mono, monospace);
  font-size: 0.82rem;
  letter-spacing: 0.5px;
}

.combo-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.4rem;
}

.combo-stat-card {
  background: hsla(225, 24%, 15%, 0.6);
  border: 1px solid hsla(0, 0%, 100%, 0.06);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.4rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.combo-stat-card.rage-active {
  border-color: var(--color-emerald);
  box-shadow: 0 0 8px var(--color-emerald-glow);
  background: hsla(152, 60%, 40%, 0.15);
}

.combo-stat-card.stat-immune {
  border-color: var(--color-ruby);
  opacity: 0.75;
  background: hsla(342, 85%, 52%, 0.1);
}

.combo-stat-card .stat-header {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  font-size: 0.65rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.combo-stat-card .stat-value {
  font-size: 1.1rem;
  font-weight: 800;
  font-family: var(--font-family-title);
  color: var(--color-text-primary);
  line-height: 1.2;
}

.combo-stat-card.stat-damage .stat-value {
  color: var(--color-gold);
}
.combo-stat-card.stat-hearts .stat-value {
  color: var(--color-ruby);
}
.combo-stat-card.stat-diamonds .stat-value {
  color: var(--color-amber);
}
.combo-stat-card.stat-spades .stat-value {
  color: var(--color-sapphire);
}

.combo-stat-card .stat-subtext {
  font-size: 0.6rem;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.combo-combat-forecast {
  display: flex;
  align-items: center;
  justify-content: space-around;
  background: hsla(225, 24%, 7%, 0.5);
  border-radius: var(--radius-sm);
  padding: 0.3rem 0.5rem;
  font-size: 0.72rem;
  border-top: 1px dashed hsla(0, 0%, 100%, 0.08);
}

/* Dedicated Discard HUD */
.discard-hud-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: hsla(225, 24%, 14%, 0.6);
  border: 1px solid hsla(0, 0%, 100%, 0.08);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  margin-top: 0.25rem;
}

.discard-hud-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 600;
}

.discard-hud-label {
  color: var(--color-text-secondary);
  font-family: var(--font-family-title);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 0.75rem;
}

.discard-hud-val {
  font-size: 1.15rem;
  font-weight: 800;
  font-family: var(--font-family-title);
}

.discard-hud-target {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--color-text-muted);
}

.discard-progress-outer {
  width: 100%;
  height: 8px;
  background: hsla(0, 0%, 0%, 0.4);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid hsla(0, 0%, 100%, 0.05);
}

.discard-progress-inner {
  height: 100%;
  background: linear-gradient(to right, var(--color-amber), var(--color-gold));
  border-radius: 6px;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 8px var(--color-amber-glow);
}

.discard-progress-inner.valid {
  background: linear-gradient(
    to right,
    var(--color-emerald),
    var(--color-gold)
  );
  box-shadow: 0 0 10px var(--color-emerald-glow);
}

/* Rules dialog scroll */
.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;
}

.text-emerald {
  color: var(--color-emerald);
}
.text-amber {
  color: var(--color-amber);
}
.text-gold {
  color: var(--color-gold);
}

/* Jester Choose Dialog */
.jester-choose-btn {
  width: 100%;
  padding: 0.75rem;
  font-family: var(--font-family-sans);
  font-weight: 600;
  font-size: 0.9rem;
  text-align: left;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  color: var(--color-text-primary);
  cursor: pointer;
  transition: all var(--transition-smooth);
}

.jester-choose-btn:hover {
  background: var(--color-gold-glow);
  border-color: var(--color-gold);
  transform: translateY(-2px);
}

/* Responsive queries for Game */
@media (max-width: 900px) {
  body {
    padding: 0.75rem;
  }

  .app-container {
    height: auto;
    min-height: calc(100dvh - 1.5rem);
    margin: 0 auto;
    gap: 0.75rem;
  }

  .view-layout {
    gap: 0.75rem;
  }

  .game-board {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 140px;
    gap: 0.5rem;
    min-height: 380px;
  }

  .arena {
    grid-column: 1;
    grid-row: 1;
    padding: 0.75rem;
    gap: 0.75rem;
    grid-template-columns: 105px 1fr;
  }

  .right-column {
    grid-column: 1;
    grid-row: 2;
    height: 100%;
    gap: 0.5rem !important;
  }

  .log-section {
    padding: 0.4rem 0.6rem;
    height: 100%;
  }

  .players-section {
    padding: 0.35rem 0.6rem !important;
  }

  .players-section h3 {
    display: none;
  }

  .players-hud-container {
    flex-direction: row;
    max-height: none;
    overflow-y: visible;
    overflow-x: auto;
    gap: 0.4rem;
  }

  .player-hud-item {
    flex: 1 0 auto;
    padding: 0.25rem 0.5rem;
    min-width: 100px;
    max-width: 150px;
    flex-direction: row;
    gap: 0.35rem;
  }

  .player-hud-email {
    font-size: 0.7rem;
    max-width: 65px;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
  }

  .player-hud-status {
    font-size: 0.55rem;
  }

  .player-hud-cards {
    font-size: 0.75rem;
  }

  .log-container {
    padding: 0.4rem;
    gap: 0.25rem;
  }

  .player-board {
    display: grid;
    grid-template-columns: 1fr 75px;
    gap: 0.5rem;
    align-items: flex-end;
  }

  .player-resources-container {
    width: 75px;
  }

  .player-resources {
    width: 75px;
    height: auto;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.25rem;
    border-radius: var(--radius-md);
  }

  .resource-section {
    flex: none;
    width: 100%;
  }

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

  .jester-section h3,
  .jester-section .section-help {
    display: none;
  }

  .jester-tokens {
    flex-direction: column;
    gap: 0.4rem;
    width: 100%;
  }

  .jester-token {
    padding: 0.25rem;
    width: 100%;
  }

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

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

  .playing-card.boss-card {
    width: 95px;
    height: 142px;
  }

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

  .boss-health-container {
    padding: 0.25rem;
    gap: 0.2rem;
  }

  .boss-stats {
    font-size: 0.6rem;
    font-weight: 500;
  }

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

  .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: 165px;
    padding-top: 25px;
    box-sizing: border-box;
    overflow-x: auto;
    scrollbar-width: thin;
    width: 100%;
  }

  .hand-row {
    display: flex;
    justify-content: flex-start;
    align-items: flex-end;
    min-width: max-content;
    padding: 0 0.5rem;
  }

  .playing-card.selected {
    transform: translateY(-20px) scale(1.05);
  }

  .player-controls {
    flex-direction: column;
    gap: 0.5rem;
    align-items: center;
    text-align: center;
    padding: 0.5rem 0.75rem;
  }

  .game-status-banner {
    font-size: 0.85rem;
    width: 100%;
  }

  .action-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.4rem;
    width: 100%;
  }

  .btn {
    min-width: auto;
    padding: 0.35rem 0.7rem;
    font-size: 0.7rem;
  }
}

@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;
  }
}

@media (max-width: 600px) {
  .game-header {
    padding: 0.5rem;
    gap: 0.5rem;
  }

  .logo-area h1,
  .logo-area h2,
  .logo-area .logo-title {
    font-size: 1.2rem;
    letter-spacing: 1px;
  }

  .back-btn {
    margin-left: 0.5rem;
    padding: 0.3rem 0.6rem;
    font-size: 0.7rem;
  }

  .deck-stats {
    gap: 0.4rem;
  }

  .stat-box {
    padding: 0.3rem 0.5rem;
    gap: 0.3rem;
  }

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

  .stat-label {
    display: none;
  }

  .stat-value {
    font-size: 0.9rem;
  }

  .castle-stat-box {
    min-width: auto;
  }

  .castle-breakdown {
    display: none;
  }

  .combo-calculator-panel {
    height: auto;
  }

  .combo-stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .combo-combat-forecast {
    flex-direction: column;
    gap: 0.3rem;
    align-items: flex-start;
  }
}
