/* ==========================================================================
   MIND MELD ONLINE - PREMIUM CSS STYLING
   ========================================================================== */

/* Variables and Theme Tokens */
:root {
  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Lora', Georgia, serif;
  --font-mono: 'Courier Prime', Courier, monospace;

  /* Cozy Tabletop HSL Color System */
  --bg-dark: hsl(38, 25%, 92%); /* Warm eggshell/paper background */
  --bg-card: hsl(38, 30%, 97%); /* Very light cream cards */
  --bg-card-hover: hsl(38, 25%, 95%);
  --bg-input: hsl(38, 15%, 94%);
  
  --border-light: hsl(24, 15%, 80%); /* Soft ink-line grey */
  --border-focus: hsl(28, 60%, 50%); /* Terracotta border on focus */
  --border-success: hsl(145, 45%, 35%); /* Soft forest/sage green border */

  --text-primary: hsl(24, 18%, 16%); /* Deep ink charcoal/brown */
  --text-secondary: hsl(24, 12%, 35%); /* Soft graphite */
  --text-muted: hsl(24, 8%, 52%); /* Faded pencil grey */
  
  --accent-cyan: hsl(165, 45%, 35%); /* Matte Forest Green/Teal */
  --accent-violet: hsl(28, 60%, 56%); /* Cozy Terracotta Orange */
  --accent-purple: hsl(38, 55%, 48%); /* Matte Mustard Yellow */
  --accent-gold: hsl(42, 70%, 46%); /* Vintage Gold */
  
  --danger: hsl(4, 65%, 48%); /* Warm Brick Red */
  --success: hsl(145, 45%, 35%); /* Sage / Forest Green */
  
  --shadow-sm: 0 2px 4px rgba(42, 39, 37, 0.06), 0 1px 2px rgba(42, 39, 37, 0.03);
  --shadow-lg: 0 10px 24px -4px rgba(42, 39, 37, 0.1), 0 4px 12px -2px rgba(42, 39, 37, 0.05);
  --shadow-glow-cyan: 0 0 0 3px hsla(165, 45%, 35%, 0.15);
  --shadow-glow-violet: 0 0 0 3px hsla(28, 60%, 56%, 0.15);

  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.25, 0.8, 0.25, 1);
  --transition-slow: 0.5s cubic-bezier(0.25, 0.8, 0.25, 1);
  
  --glass-blur: 0px;
}

/* Reset and Global Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-dark);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-x: hidden;
  padding: 20px;
  position: relative;
}

/* Helper Utilities */
.d-none {
  display: none !important;
}

.accent-text {
  color: var(--accent-violet);
}

/* ==========================================================================
   COZY DOTTED PAPER BACKDROP
   ========================================================================== */
.gradient-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: -100;
  background-color: var(--bg-dark);
  background-image: 
    radial-gradient(hsla(24, 15%, 35%, 0.1) 1.2px, transparent 1.2px);
  background-size: 20px 20px;
  opacity: 0.9;
}

.g1, .g2, .g3 {
  display: none !important;
}

@keyframes float-slow {
  0% { transform: translate(0, 0) rotate(0deg); }
  100% { transform: translate(100px, 80px) rotate(360deg); }
}

@keyframes float-pulse {
  0% { transform: translate(-50%, -50%) scale(0.9); opacity: 0.3; }
  100% { transform: translate(-45%, -55%) scale(1.2); opacity: 0.6; }
}

/* ==========================================================================
   APP SHELL LAYOUT
   ========================================================================== */
.app-container {
  width: 100%;
  max-width: 680px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

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

.logo {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 3rem;
  letter-spacing: -0.5px;
  margin-bottom: 6px;
  animation: intro-fade-down 0.8s cubic-bezier(0.16, 1, 0.3, 1);
  color: var(--text-primary);
}

.tagline {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 1rem;
  color: var(--text-secondary);
  font-weight: 400;
  letter-spacing: 0px;
}

/* ==========================================================================
   COZY TABLETOP GAME CARD
   ========================================================================== */
.game-card {
  background-color: var(--bg-card);
  border: 1.5px solid var(--border-light);
  border-radius: 14px;
  padding: 36px 32px;
  box-shadow: var(--shadow-lg);
  min-height: 420px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  overflow: hidden;
  transition: transform var(--transition-normal);
}

/* Screens System */
.screen {
  display: none;
  opacity: 0;
  transform: translateY(15px);
}

.screen.active {
  display: flex;
  flex-direction: column;
  gap: 28px;
  animation: screen-transition var(--transition-normal) forwards;
}

@keyframes screen-transition {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ==========================================================================
   BUTTONS AND INPUT CONTROLS
   ========================================================================== */
.btn {
  font-family: var(--font-display);
  font-weight: 700;
  padding: 14px 24px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 1rem;
  text-decoration: none;
  box-shadow: var(--shadow-sm);
}

.btn-primary {
  background-color: var(--accent-cyan);
  color: var(--bg-card);
  border: 1.5px solid hsl(165, 45%, 28%);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  background-color: hsl(165, 45%, 30%);
  box-shadow: var(--shadow-lg);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

.btn-accent {
  background-color: var(--accent-violet);
  color: var(--bg-card);
  border: 1.5px solid hsl(28, 60%, 48%);
}

.btn-accent:hover:not(:disabled) {
  transform: translateY(-2px);
  background-color: hsl(28, 60%, 50%);
  box-shadow: var(--shadow-lg);
}

.btn-accent:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

.btn-secondary {
  background-color: var(--bg-input);
  border: 1.5px solid var(--border-light);
  color: var(--text-primary);
}

.btn-secondary:hover:not(:disabled) {
  background-color: var(--bg-card-hover);
  border-color: var(--text-muted);
  transform: translateY(-1px);
}

.btn-secondary:active:not(:disabled) {
  transform: translateY(0);
}

.btn-danger {
  background-color: hsla(4, 65%, 48%, 0.1);
  border: 1.5px solid var(--danger);
  color: var(--danger);
}

.btn-danger:hover:not(:disabled) {
  background-color: hsla(4, 65%, 48%, 0.2);
}

.btn-tiny {
  padding: 6px 12px;
  font-size: 0.75rem;
  border-radius: 6px;
}

.btn-small {
  padding: 10px 18px;
  font-size: 0.85rem;
}

.btn-large {
  padding: 16px 32px;
  font-size: 1.1rem;
}

.btn-full {
  width: 100%;
}

.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

.btn-icon {
  font-size: 1.25rem;
}

/* Input Styles */
input[type="text"] {
  width: 100%;
  padding: 14px 18px;
  border-radius: 8px;
  border: 1.5px solid var(--border-light);
  background-color: var(--bg-input);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 1rem;
  outline: none;
  transition: all var(--transition-fast);
}

input[type="text"]:focus {
  border-color: var(--accent-cyan);
  box-shadow: var(--shadow-glow-cyan);
  background-color: var(--bg-card);
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.input-group label {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
  font-weight: 700;
  font-family: var(--font-display);
}

.divider {
  display: flex;
  align-items: center;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  letter-spacing: 1px;
  font-weight: 700;
  font-family: var(--font-display);
  margin: 12px 0;
}

.divider::before, .divider::after {
  content: '';
  flex: 1;
  border-bottom: 1.5px solid var(--border-light);
}

.divider span {
  padding: 0 15px;
}

/* ==========================================================================
   SCREEN 1: WELCOME SPECIFICS
   ========================================================================== */
.welcome-hero {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  margin-bottom: 8px;
}

.brain-icon-wrapper {
  background: hsla(28, 60%, 56%, 0.08);
  border: 1.5px solid var(--border-light);
  padding: 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
}

.brain-icon {
  width: 50px;
  height: 50px;
  color: var(--accent-violet);
  filter: none;
}

.mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.btn-mode {
  text-align: left;
  flex-direction: row;
  justify-content: flex-start;
  padding: 16px;
  height: auto;
  align-items: flex-start;
}

.btn-mode .btn-icon {
  font-size: 1.8rem;
  background-color: hsla(24, 12%, 35%, 0.06);
  border: 1px solid var(--border-light);
  padding: 8px;
  border-radius: 8px;
}

.btn-text-wrapper {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.btn-title {
  font-size: 1rem;
  color: var(--text-primary);
  font-weight: 700;
}

.btn-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 400;
  line-height: 1.25;
}

.online-box {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.join-code-group {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
}

.join-code-group input {
  text-transform: uppercase;
  text-align: center;
  letter-spacing: 4px;
  font-weight: 700;
  font-family: var(--font-mono);
}

/* ==========================================================================
   SCREEN 2: LOBBY SPECIFICS
   ========================================================================== */
.lobby-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1.5px solid var(--border-light);
  padding-bottom: 20px;
}

.room-code-display {
  display: flex;
  align-items: center;
  gap: 16px;
}

.code-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 1px;
}

#lobby-room-code {
  font-family: var(--font-mono);
  font-size: 2.2rem;
  letter-spacing: 2px;
  color: var(--accent-violet);
  text-shadow: none;
}

.lobby-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.role-column {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.role-column h3 {
  font-family: var(--font-display);
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  border-bottom: 1.5px solid var(--border-light);
  padding-bottom: 6px;
}

.slot-count {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.player-list-box {
  background-color: var(--bg-input);
  border: 1.5px solid var(--border-light);
  border-radius: 8px;
  min-height: 140px;
  max-height: 200px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding: 8px;
  gap: 6px;
}

.player-list-box.list-empty::after {
  content: 'Empty slot(s)';
  color: var(--text-muted);
  font-size: 0.8rem;
  font-style: italic;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}

.player-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  font-size: 0.9rem;
}

.player-row.is-me {
  border-color: var(--accent-cyan);
  background-color: hsla(165, 45%, 35%, 0.06);
}

.player-row.is-ready {
  border-color: var(--success);
  background: hsla(145, 45%, 35%, 0.06);
}

.player-row-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ready-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--text-muted);
}

.ready-dot.ready {
  background-color: var(--success);
  box-shadow: none;
}

.lobby-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  border-top: 1.5px solid var(--border-light);
  padding-top: 20px;
}

.status-msg {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-style: italic;
}

/* ==========================================================================
   SCREEN 3: GAME BOARD SPECIFICS
   ========================================================================== */
.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1.5px solid var(--border-light);
  padding-bottom: 16px;
}

.round-indicator {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.25rem;
  color: var(--accent-cyan);
  letter-spacing: 0.5px;
}

.meld-targets-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  background-color: var(--bg-input);
  border: 1.5px dashed var(--border-light);
  padding: 24px;
  border-radius: 12px;
}

.target-subtitle {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
  font-weight: 700;
}

.meld-targets {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  width: 100%;
}

.meld-target-bubble {
  background-color: var(--bg-card);
  border: 1.5px solid var(--border-light);
  padding: 12px 24px;
  border-radius: 8px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.4rem;
  color: var(--text-primary);
  text-shadow: none;
  box-shadow: var(--shadow-sm);
  text-transform: capitalize;
}

.meld-target-bubble.initial {
  background-color: var(--bg-input);
  border: 1.5px dashed var(--border-light);
  font-size: 1.1rem;
  color: var(--text-muted);
  font-style: italic;
  font-weight: 400;
}

.target-plus {
  font-size: 1.5rem;
  color: var(--text-muted);
  font-weight: 700;
}

.readiness-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  font-size: 0.8rem;
}

.readiness-tag {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background-color: var(--bg-input);
  border: 1.5px solid var(--border-light);
  border-radius: 6px;
  color: var(--text-secondary);
}

.readiness-tag.ready {
  border-color: var(--success);
  background-color: hsla(145, 45%, 35%, 0.08);
  color: var(--success);
}

.readiness-tag-icon {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--text-muted);
}

.readiness-tag.ready .readiness-tag-icon {
  background-color: var(--success);
  box-shadow: none;
}

.action-box {
  display: flex;
  flex-direction: column;
  gap: 16px;
  background-color: var(--bg-input);
  padding: 24px;
  border-radius: 12px;
  border: 1.5px solid var(--border-light);
}

.user-role-badge {
  align-self: center;
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 4px 12px;
  border-radius: 4px;
  background-color: var(--accent-violet);
  color: var(--bg-card);
  border: 1px solid hsl(28, 60%, 48%);
  text-transform: uppercase;
}

.input-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
}

.masked-input-wrapper {
  position: relative;
  width: 100%;
}

.mask-feedback {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--bg-card);
  border: 1.5px solid var(--border-success);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--success);
  font-weight: 600;
  font-size: 0.9rem;
  gap: 8px;
}

.input-tip {
  font-size: 0.75rem;
  font-family: var(--font-body);
  font-style: italic;
  color: var(--text-muted);
  text-align: center;
}

/* Floating/Embed Live Scoreboard panel */
.spectator-leaderboard-panel {
  background-color: var(--bg-input);
  border: 1.5px solid var(--border-light);
  border-radius: 8px;
  padding: 14px;
}

.spectator-leaderboard-panel h4 {
  font-family: var(--font-display);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  border-bottom: 1.5px solid var(--border-light);
  padding-bottom: 4px;
}

.sidebar-score-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  padding: 4px 6px;
  border-radius: 4px;
}

.sidebar-score-row:hover {
  background-color: var(--bg-card-hover);
}

.sidebar-score-pts {
  font-weight: 700;
  color: var(--accent-cyan);
}

/* ==========================================================================
   SCREEN 4: ROUND REVEAL STYLES
   ========================================================================== */
.reveal-cards-container {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  margin: 10px 0;
}

.reveal-card-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  flex: 1;
  max-width: 200px;
}

.reveal-player-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.vs-bubble {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-input);
  border: 1.5px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-secondary);
}

/* 3D Flip Card Implementation */
.word-card {
  perspective: 1000px;
  width: 100%;
  height: 120px;
}

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  text-align: center;
  transition: transform var(--transition-slow);
  transform-style: preserve-3d;
}

.word-card.revealed .card-inner {
  transform: rotateY(180deg);
}

.card-front, .card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
}

.card-front {
  background-color: var(--accent-violet);
  background-image: 
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.05) 0px, rgba(255, 255, 255, 0.05) 2px, transparent 2px, transparent 10px);
  border: 2px dashed rgba(255, 255, 255, 0.35);
  color: var(--bg-card);
  font-size: 2.2rem;
  font-family: var(--font-display);
  font-weight: 800;
  box-shadow: var(--shadow-sm);
}

.card-back {
  background-color: var(--bg-card);
  border: 2px solid var(--border-light);
  color: var(--text-primary);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.6rem;
  text-transform: capitalize;
  transform: rotateY(180deg);
  box-shadow: var(--shadow-sm);
}

.word-card.matched .card-back {
  border-color: var(--success);
  color: var(--success);
  background-color: hsla(145, 45%, 35%, 0.08);
}

/* Spectator Round Guess Statuses */
.round-guesses-box {
  background-color: var(--bg-input);
  border: 1.5px solid var(--border-light);
  border-radius: 8px;
  padding: 16px;
}

.round-guesses-box h4 {
  font-family: var(--font-display);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.guesses-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.guess-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  font-size: 0.85rem;
}

.guess-row-left {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.guess-val {
  font-weight: 700;
  color: var(--text-primary);
  text-transform: capitalize;
}

.score-badge {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
}

.score-badge.match-single {
  background-color: hsla(165, 45%, 35%, 0.1);
  color: var(--accent-cyan);
  border: 1.5px solid var(--accent-cyan);
}

.score-badge.match-double {
  background-color: hsla(42, 70%, 46%, 0.1);
  color: var(--accent-gold);
  border: 1.5px solid var(--accent-gold);
  animation: bounce 0.6s infinite alternate;
}

.score-badge.mismatch {
  background-color: var(--bg-input);
  color: var(--text-muted);
  border: 1.5px solid var(--border-light);
}

.outcome-status {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  text-align: center;
  margin: 12px 0;
  letter-spacing: 0.5px;
}

.outcome-status.match {
  color: var(--success);
  text-shadow: none;
}

.outcome-status.mismatch {
  color: var(--accent-cyan);
}

/* Transition / Countdown Bar */
.countdown-bar-container {
  width: 100%;
  height: 6px;
  background-color: var(--border-light);
  border-radius: 3px;
  overflow: hidden;
}

.countdown-bar {
  height: 100%;
  width: 100%;
  background: var(--accent-cyan);
  border-radius: 3px;
  transform-origin: left;
  animation: countdown-anim 6s linear forwards;
}

@keyframes countdown-anim {
  from { transform: scaleX(1); }
  to { transform: scaleX(0); }
}

.animate-pulse {
  animation: pulse-glow 1.5s infinite alternate;
}

@keyframes pulse-glow {
  0% { transform: scale(0.98); opacity: 0.8; }
  100% { transform: scale(1.02); opacity: 1; }
}

@keyframes bounce {
  0% { transform: translateY(0); }
  100% { transform: translateY(-3px); }
}

/* ==========================================================================
   SCREEN 5: VICTORY AND STATS SPECIFICS
   ========================================================================== */
.completed-hero {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.victory-trophy {
  font-size: 4.5rem;
  filter: none;
  animation: float-slow 3s infinite alternate ease-in-out;
}

.completed-hero h2 {
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: var(--accent-gold);
}

.victory-congrats {
  font-family: var(--font-body);
  font-style: italic;
  color: var(--text-secondary);
}

.stats-summary-card {
  display: flex;
  justify-content: space-around;
  background-color: var(--bg-input);
  border: 1.5px solid var(--border-light);
  border-radius: 12px;
  padding: 20px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.stat-val {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--accent-cyan);
}

#stat-meld-word {
  text-transform: capitalize;
  color: var(--success);
}

.stat-lbl {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  font-weight: 700;
}

.history-path-box {
  background-color: var(--bg-card);
  border: 1.5px dashed var(--border-light);
  border-radius: 12px;
  padding: 20px;
  max-height: 240px;
  overflow-y: auto;
}

.history-path-box h3 {
  font-family: var(--font-display);
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  margin-bottom: 12px;
  border-bottom: 1.5px solid var(--border-light);
  padding-bottom: 6px;
}

.history-path-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-path-node {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background-color: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  font-size: 0.9rem;
}

.history-path-num {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--text-muted);
}

.history-path-words {
  display: flex;
  gap: 12px;
  font-family: var(--font-display);
  font-weight: 700;
}

.history-path-word {
  text-transform: capitalize;
}

.history-path-word.a { color: var(--accent-cyan); }
.history-path-word.b { color: var(--accent-violet); }

.history-path-word.match-word {
  color: var(--success) !important;
}

/* Final Leaderboard Box */
.final-leaderboard-box {
  background-color: var(--bg-input);
  border: 1.5px solid var(--border-light);
  border-radius: 12px;
  padding: 20px;
}

.final-leaderboard-box h3 {
  font-family: var(--font-display);
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.final-leaderboard {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.final-leaderboard-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 0.95rem;
  background-color: var(--bg-card);
  border: 1px solid var(--border-light);
}

.final-leaderboard-row.gold-place {
  background: hsla(42, 70%, 46%, 0.06);
  border-color: hsla(42, 70%, 46%, 0.3);
}

.final-leaderboard-row.silver-place {
  background: hsla(24, 12%, 35%, 0.05);
  border-color: rgba(24, 12%, 35%, 0.15);
}

.final-leaderboard-row-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.trophy-badge {
  font-size: 1.1rem;
}

.completed-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ==========================================================================
   PERSISTENT HISTORY LOG PANEL (COLLAPSIBLE FOOTER)
   ========================================================================== */
.game-history-log {
  background-color: var(--bg-card);
  border: 1.5px solid var(--border-light);
  border-radius: 12px;
  padding: 12px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: max-height var(--transition-normal);
}

.btn-toggle-history {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  outline: none;
}

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

.history-log-content {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 150px;
  overflow-y: auto;
  padding-right: 4px;
}

.history-row-item {
  display: flex;
  justify-content: space-between;
  padding: 6px 10px;
  background-color: var(--bg-input);
  border-radius: 4px;
  border: 1px solid var(--border-light);
  font-size: 0.8rem;
}

.history-row-item span {
  font-weight: 500;
}

.history-row-words {
  text-transform: capitalize;
  font-weight: 700;
  color: var(--accent-cyan);
}

/* ==========================================================================
   TOAST SYSTEM
   ========================================================================== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 10000;
}

.toast {
  background-color: var(--bg-card);
  border: 1.5px solid var(--border-light);
  border-left: 4px solid var(--accent-cyan);
  padding: 14px 20px;
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  font-size: 0.85rem;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 250px;
  max-width: 350px;
  transform: translateX(100%);
  animation: toast-slide-in 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.toast.toast-danger {
  border-left-color: var(--danger);
}

.toast.toast-success {
  border-left-color: var(--success);
}

@keyframes toast-slide-in {
  to { transform: translateX(0); }
}

/* ==========================================================================
   RESPONSIVENESS AND TABLET/MOBILE ADAPTABILITY
   ========================================================================== */
@media (max-width: 768px) {
  body {
    padding: 16px 10px;
  }
  
  .logo {
    font-size: 2.2rem;
  }
  
  .game-card {
    padding: 20px 16px;
  }
  
  .mode-grid {
    grid-template-columns: 1fr;
  }
  
  .lobby-content {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  
  .completed-actions {
    grid-template-columns: 1fr;
  }
  
  .reveal-cards-container {
    gap: 8px;
  }
  
  .word-card {
    height: 100px;
  }
  
  .card-front {
    font-size: 1.5rem;
  }
  
  .card-back {
    font-size: 1.2rem;
  }
  
  .vs-bubble {
    width: 32px;
    height: 32px;
    font-size: 0.75rem;
  }
}

@keyframes intro-fade-down {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
