@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=Inter:wght@300;400;500;600&display=swap');

:root {
  --primary: #D4A5A5;
  --secondary: #C48B8B;
  --muted: #B37171;
  --light: #9E5757;
  --bg: #FFF5F5;
  --white: #FFFFFF;
  --tile-bg: #F7F1E3;
  --tile-border: #C7B198;
  --tile-selected: #2C3E50;
  --tile-selected-text: #FFFFFF;
  --success: #27AE60;
  --error: #E74C3C;
  --warning: #F39C12;
  --info: #3498DB;
  --card-shadow: 0 2px 12px rgba(44, 62, 80, 0.08);
  --depth-shadow: 0 4px 20px rgba(44, 62, 80, 0.12);
}

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

html {
  scroll-behavior: smooth;
}

::selection {
  background: var(--primary);
  color: var(--white);
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
}

/* ===== Loading Screen ===== */
.loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  gap: 2rem;
}

.loading-tiles {
  display: flex;
  gap: 0.4rem;
}

.loading-tile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: var(--tile-bg);
  border: 2px solid var(--tile-border);
  border-radius: 6px;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--primary);
  animation: tileFloat 1.2s ease-in-out infinite;
}

.loading-tile:nth-child(1) { animation-delay: 0s; }
.loading-tile:nth-child(2) { animation-delay: 0.1s; }
.loading-tile:nth-child(3) { animation-delay: 0.2s; }
.loading-tile:nth-child(4) { animation-delay: 0.3s; }
.loading-tile:nth-child(5) { animation-delay: 0.4s; }
.loading-tile:nth-child(6) { animation-delay: 0.5s; }
.loading-tile:nth-child(7) { animation-delay: 0.6s; }
.loading-tile:nth-child(8) { animation-delay: 0.7s; }

@keyframes tileFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.loading-text {
  color: var(--muted);
  font-size: 0.95rem;
}

/* ===== Lobby ===== */
.lobby-container {
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.lobby-header {
  text-align: center;
  margin-bottom: 2.5rem;
}

.logo-tiles {
  display: flex;
  justify-content: center;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.logo-tile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  background: var(--tile-bg);
  border: 2px solid var(--tile-border);
  border-radius: 8px;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1.4rem;
  color: var(--primary);
  box-shadow: 0 3px 0 var(--tile-border), 0 4px 8px rgba(44,62,80,0.1);
  transition: transform 0.2s ease;
}

.logo-tile:hover {
  transform: translateY(-3px);
}

.lobby-subtitle {
  color: var(--muted);
  font-size: 1rem;
  margin-top: 0.5rem;
}

.lobby-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

@media (max-width: 640px) {
  .lobby-cards {
    grid-template-columns: 1fr;
  }
}

.lobby-card {
  background: var(--white);
  border-radius: 16px;
  padding: 2rem;
  box-shadow: var(--card-shadow);
  border: 1px solid rgba(189, 195, 199, 0.3);
}

.lobby-card h2 {
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
}

.lobby-card p {
  color: var(--muted);
  font-size: 0.88rem;
  margin-bottom: 1.5rem;
  line-height: 1.5;
}

.join-input-group {
  display: flex;
  gap: 0.5rem;
}

.room-code-input {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 2px solid var(--light);
  border-radius: 10px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 3px;
  text-align: center;
  text-transform: uppercase;
  color: var(--primary);
  background: var(--bg);
  outline: none;
  transition: border-color 0.2s ease;
  min-height: 48px;
}

.room-code-input:focus {
  border-color: var(--primary);
}

.room-code-input::placeholder {
  letter-spacing: 2px;
  color: var(--light);
}

/* ===== Buttons ===== */
.btn-primary {
  background: var(--primary);
  color: var(--white);
  border: none;
  border-radius: 10px;
  padding: 0.75rem 1.5rem;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 48px;
  white-space: nowrap;
}

.btn-primary:hover:not(:disabled) {
  background: var(--secondary);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(44, 62, 80, 0.25);
}

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

.btn-secondary {
  background: var(--bg);
  color: var(--primary);
  border: 2px solid var(--light);
  border-radius: 10px;
  padding: 0.65rem 1.25rem;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 44px;
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--primary);
  background: var(--white);
}

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

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: none;
  padding: 0.5rem 1rem;
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  font-size: 0.88rem;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s ease;
  min-height: 44px;
}

.btn-ghost:hover {
  color: var(--primary);
  background: rgba(44, 62, 80, 0.06);
}

/* ===== Active Games ===== */
.active-games {
  margin-bottom: 2rem;
}

.active-games h3 {
  font-size: 1rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
}

.active-game-card {
  display: flex;
  align-items: center;
  background: var(--white);
  border: 1px solid rgba(189, 195, 199, 0.3);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  margin-bottom: 0.5rem;
  cursor: pointer;
  transition: all 0.2s ease;
  gap: 1rem;
}

.active-game-card:hover {
  box-shadow: var(--card-shadow);
  border-color: var(--primary);
}

.game-code {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 2px;
  color: var(--primary);
}

.game-players {
  color: var(--muted);
  font-size: 0.85rem;
  flex: 1;
}

.game-arrow {
  color: var(--light);
  font-size: 1.2rem;
}

/* ===== Rules ===== */
.lobby-rules {
  background: var(--white);
  border-radius: 16px;
  padding: 2rem;
  box-shadow: var(--card-shadow);
  border: 1px solid rgba(189, 195, 199, 0.3);
}

.lobby-rules h3 {
  font-size: 1.1rem;
  margin-bottom: 1.25rem;
}

.rules-grid {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.rule-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.92rem;
  color: var(--secondary);
  line-height: 1.4;
}

.rule-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
}

/* ===== Game Container ===== */
.game-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 1rem 2rem;
  animation: fadeIn 0.4s ease;
}

/* ===== Game Header ===== */
.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0;
  border-bottom: 1px solid rgba(189, 195, 199, 0.4);
  margin-bottom: 0.5rem;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.header-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
}

.room-badge {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--muted);
  letter-spacing: 1px;
  cursor: pointer;
  padding: 0.2rem 0.6rem;
  border-radius: 6px;
  transition: background 0.2s ease;
}

.room-badge:hover {
  background: rgba(44, 62, 80, 0.06);
}

.turn-indicator {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 500;
}

.turn-indicator.my-turn {
  color: var(--success);
  font-weight: 600;
  animation: pulseGlow 2s ease-in-out infinite;
}

@keyframes pulseGlow {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.tiles-remaining {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
}

.share-banner {
  background: var(--primary);
  color: var(--white);
  text-align: center;
  padding: 0.6rem;
  border-radius: 8px;
  font-size: 0.88rem;
  margin-bottom: 0.75rem;
  animation: fadeIn 0.3s ease;
}

.share-banner strong {
  letter-spacing: 3px;
  font-family: 'Space Grotesk', sans-serif;
}

/* ===== Tabs ===== */
.game-tabs {
  display: flex;
  gap: 0;
  background: var(--white);
  border-radius: 12px;
  padding: 0.3rem;
  box-shadow: var(--card-shadow);
  margin-bottom: 1.25rem;
  border: 1px solid rgba(189, 195, 199, 0.3);
}

.tab-btn {
  flex: 1;
  padding: 0.65rem 1rem;
  background: transparent;
  border: none;
  border-radius: 9px;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 44px;
}

.tab-btn.active {
  background: var(--primary);
  color: var(--white);
  box-shadow: 0 2px 8px rgba(44, 62, 80, 0.2);
}

.tab-btn:hover:not(.active) {
  color: var(--primary);
  background: var(--bg);
}

/* ===== Message Toast ===== */
.message-toast {
  text-align: center;
  padding: 0.7rem 1rem;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 1rem;
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.message-toast.success {
  background: rgba(39, 174, 96, 0.12);
  color: var(--success);
  border: 1px solid rgba(39, 174, 96, 0.2);
}

.message-toast.error {
  background: rgba(231, 76, 60, 0.12);
  color: var(--error);
  border: 1px solid rgba(231, 76, 60, 0.2);
}

.message-toast.info {
  background: rgba(52, 152, 219, 0.12);
  color: var(--info);
  border: 1px solid rgba(52, 152, 219, 0.2);
}

/* ===== Waiting Room ===== */
.waiting-room {
  text-align: center;
  background: var(--white);
  border-radius: 20px;
  padding: 3rem 2rem;
  box-shadow: var(--depth-shadow);
  border: 1px solid rgba(189, 195, 199, 0.2);
}

.waiting-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  animation: tileFloat 2s ease-in-out infinite;
}

.waiting-room h2 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.share-instruction {
  color: var(--muted);
  margin-bottom: 2rem;
}

.code-highlight {
  display: inline-block;
  background: var(--tile-bg);
  border: 2px solid var(--tile-border);
  padding: 0.3rem 0.8rem;
  border-radius: 8px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.2rem;
  letter-spacing: 4px;
  color: var(--primary);
  margin-left: 0.3rem;
}

.players-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.player-chip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg);
  border-radius: 50px;
  padding: 0.5rem 1rem 0.5rem 0.5rem;
  font-weight: 500;
  font-size: 0.9rem;
  animation: fadeIn 0.3s ease;
}

.player-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 0.85rem;
}

.host-badge {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--warning);
  background: rgba(243, 156, 18, 0.12);
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
}

.player-count {
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 1.5rem;
}

.btn-start {
  padding: 0.9rem 2.5rem;
  font-size: 1.05rem;
}

.waiting-text {
  color: var(--muted);
  font-style: italic;
  font-size: 0.9rem;
}

/* ===== Tile Rack ===== */
.rack-section {
  background: var(--white);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: var(--card-shadow);
  border: 1px solid rgba(189, 195, 199, 0.2);
  margin-bottom: 1.25rem;
}

.rack-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--muted);
  margin-bottom: 1rem;
  font-weight: 600;
}

.tile-rack {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.tile {
  width: 56px;
  height: 62px;
  background: var(--tile-bg);
  border: 2.5px solid var(--tile-border);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
  box-shadow: 0 3px 0 var(--tile-border), 0 4px 8px rgba(0,0,0,0.05);
}

.tile:hover:not(.disabled) {
  transform: translateY(-4px);
  box-shadow: 0 6px 0 var(--tile-border), 0 8px 16px rgba(0,0,0,0.08);
}

.tile.selected {
  background: var(--tile-selected);
  border-color: var(--primary);
  color: var(--tile-selected-text);
  transform: translateY(-6px);
  box-shadow: 0 6px 0 rgba(44,62,80,0.4), 0 10px 20px rgba(44,62,80,0.15);
}

.tile.selected .tile-letter {
  color: var(--white);
}

.tile.selected .tile-points {
  color: rgba(255, 255, 255, 0.7);
}

.tile.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.tile-letter {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1.3rem;
  color: var(--primary);
  line-height: 1;
}

.tile-points {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--muted);
  position: absolute;
  bottom: 4px;
  right: 6px;
}

@media (max-width: 480px) {
  .tile {
    width: 46px;
    height: 52px;
  }
  .tile-letter {
    font-size: 1.1rem;
  }
}

/* ===== Word Section ===== */
.word-section {
  background: var(--white);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: var(--card-shadow);
  border: 1px solid rgba(189, 195, 199, 0.2);
  margin-bottom: 1.25rem;
}

.word-display {
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
}

.word-tiles-preview {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-wrap: wrap;
  justify-content: center;
}

.preview-tile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 44px;
  background: var(--primary);
  color: var(--white);
  border-radius: 6px;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1.15rem;
  animation: popIn 0.15s ease;
}

@keyframes popIn {
  from { transform: scale(0.7); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.word-score-preview {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--success);
  margin-left: 0.75rem;
}

.word-hint {
  color: var(--light);
  font-size: 0.95rem;
  font-style: italic;
}

.action-buttons {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  justify-content: center;
}

.btn-submit {
  flex: 1;
  min-width: 160px;
}

/* ===== Letter Values ===== */
.letter-values-section {
  background: var(--white);
  border-radius: 16px;
  padding: 1rem 1.5rem;
  box-shadow: var(--card-shadow);
  border: 1px solid rgba(189, 195, 199, 0.2);
  margin-bottom: 1.25rem;
}

.letter-values-section summary {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--muted);
  cursor: pointer;
  padding: 0.25rem 0;
  list-style: none;
}

.letter-values-section summary::before {
  content: '▸ ';
}

.letter-values-section[open] summary::before {
  content: '▾ ';
}

.values-grid {
  padding-top: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.value-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.value-pts {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--primary);
  min-width: 40px;
  background: var(--bg);
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  text-align: center;
}

.value-letters {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 500;
  font-size: 0.88rem;
  color: var(--secondary);
  letter-spacing: 2px;
}

/* ===== Scoreboard ===== */
.scoreboard-section {
  animation: fadeIn 0.3s ease;
}

.scoreboard-section h3 {
  font-size: 1.1rem;
  margin-bottom: 1.25rem;
}

.stats-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--white);
  border-radius: 12px;
  padding: 1.25rem;
  text-align: center;
  box-shadow: var(--card-shadow);
  border: 1px solid rgba(189, 195, 199, 0.2);
}

.stat-card.highlight {
  background: var(--primary);
  border-color: var(--primary);
}

.stat-card.highlight .stat-value {
  color: var(--white);
  font-size: 1rem;
}

.stat-card.highlight .stat-label {
  color: rgba(255, 255, 255, 0.7);
}

.stat-value {
  display: block;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1.6rem;
  color: var(--primary);
  margin-bottom: 0.2rem;
}

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

.player-scores {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.score-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--white);
  border-radius: 14px;
  padding: 1rem 1.25rem;
  box-shadow: var(--card-shadow);
  border: 2px solid transparent;
  transition: all 0.2s ease;
}

.score-row.is-me {
  border-color: rgba(44, 62, 80, 0.15);
  background: rgba(44, 62, 80, 0.02);
}

.score-row.active-turn {
  border-color: var(--success);
  box-shadow: 0 0 0 3px rgba(39, 174, 96, 0.1);
}

.score-rank {
  font-size: 1.3rem;
  flex-shrink: 0;
  width: 36px;
  text-align: center;
}

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

.score-name {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.you-badge {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--info);
  background: rgba(52, 152, 219, 0.1);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
}

.turn-badge {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--success);
  background: rgba(39, 174, 96, 0.1);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
}

.score-details {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.15rem;
}

.score-total {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1.5rem;
  color: var(--primary);
  flex-shrink: 0;
}

/* ===== History ===== */
.history-section {
  animation: fadeIn 0.3s ease;
}

.history-section h3 {
  font-size: 1.1rem;
  margin-bottom: 1rem;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--white);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  animation: fadeIn 0.2s ease;
}

.history-player {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--secondary);
  min-width: 80px;
}

.history-word {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 1px;
  color: var(--primary);
  flex: 1;
}

.history-word.skipped {
  color: var(--muted);
  font-weight: 400;
  font-style: italic;
  letter-spacing: 0;
}

.history-score {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--success);
  background: rgba(39, 174, 96, 0.08);
  padding: 0.2rem 0.6rem;
  border-radius: 6px;
}

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--light);
}

.empty-icon {
  font-size: 3rem;
  display: block;
  margin-bottom: 1rem;
}

.empty-state p {
  font-size: 0.95rem;
}

/* ===== Game Over ===== */
.game-over {
  text-align: center;
  background: var(--white);
  border-radius: 20px;
  padding: 3rem 2rem;
  box-shadow: var(--depth-shadow);
  border: 1px solid rgba(189, 195, 199, 0.2);
}

.trophy {
  font-size: 4rem;
  margin-bottom: 0.5rem;
  animation: tileFloat 1.5s ease-in-out infinite;
}

.game-over h2 {
  font-size: 1.8rem;
  margin-bottom: 0.5rem;
}

.winner-text {
  color: var(--success);
  font-weight: 600;
  font-size: 1.1rem;
  margin-bottom: 2rem;
}

.final-standings {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 400px;
  margin: 0 auto;
}

.standing-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  background: var(--bg);
}

.standing-row.winner {
  background: var(--primary);
  color: var(--white);
}

.standing-rank {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 0.9rem;
  min-width: 28px;
}

.standing-name {
  flex: 1;
  font-weight: 600;
  font-size: 0.95rem;
}

.standing-score {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1rem;
}

.standing-row.winner .standing-score {
  color: rgba(255, 255, 255, 0.9);
}

/* ===== Global Responsive ===== */
@media (max-width: 640px) {
  .lobby-container {
    padding: 1.5rem 1rem;
  }

  .logo-tile {
    width: 38px;
    height: 38px;
    font-size: 1.1rem;
  }

  .lobby-card {
    padding: 1.5rem;
  }

  .game-header {
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
  }

  .action-buttons {
    flex-direction: column;
  }

  .action-buttons .btn-primary,
  .action-buttons .btn-secondary,
  .action-buttons .btn-ghost {
    width: 100%;
  }

  .stats-cards {
    grid-template-columns: 1fr 1fr;
  }

  .history-player {
    min-width: 60px;
    font-size: 0.78rem;
  }
}

/* ===== Focus Styles ===== */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
```

<!-- WALKTHROUGH_SCRIPT:
[
  {"step": 1, "narration": "Welcome to WordPlay! This is a multiplayer word game where players take turns building words from random letter tiles.", "view": "lobby", "highlight_selector": ".logo-tiles", "wait_for": "tap_to_continue"},
  {"step": 2, "narration": "Create a new game to get a room code, or enter a friend's code to join their game.", "view": "lobby", "highlight_selector": ".lobby-cards", "wait_for": "tap_to_continue"},
  {"step": 3, "narration": "Share the room code with friends. Once at least 2 players have joined, the host can start the game.", "view": "waiting", "highlight_selector": ".code-highlight", "wait_for": "tap_to_continue"},
  {"step": 4, "narration": "On your turn, tap tiles from your rack to build a word. Selected tiles highlight and the word preview shows your score.", "view": "game", "highlight_selector": ".tile-rack", "wait_for": "user_interaction"},
  {"step": 5, "narration": "Submit your word to score points! Words are validated against the dictionary. Longer words earn bonus points.", "view": "game", "highlight_selector": ".btn-submit", "wait_for": "user_interaction"},
  {"step": 6, "narration": "You can also swap tiles you don't want, or skip your turn if you're stuck.", "view": "game", "highlight_selector": ".action-buttons", "wait_for": "tap_to_continue"},
  {"step": 7, "narration": "Check the Scores tab to see standings and stats, or the History tab for a log of all moves.", "view": "game", "highlight_selector": ".game-tabs", "wait_for": "tap_to_continue"},
  {"step": 8, "narration": "The game ends when all tiles are used up. The player with the highest score wins! Have fun!", "view": "game", "highlight_selector": ".game-container", "wait_for": "tap_to_continue"}
]
-->

.turn-timer-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: rgba(52, 152, 219, 0.08);
  border: 1px solid rgba(52, 152, 219, 0.18);
  color: var(--info);
  border-radius: 12px;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  font-weight: 600;
}

.turn-timer-label {
  font-size: 0.9rem;
}

.turn-timer-value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.95rem;
  color: var(--primary);
}

.turn-timer-value.urgent {
  color: var(--error);
  animation: pulseGlow 1s ease-in-out infinite;
}

@media (max-width: 640px) {
  .turn-timer-banner {
    flex-direction: column;
    align-items: flex-start;
  }
}

.presence-badge {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  white-space: nowrap;
}

.presence-connected {
  color: var(--muted);
  background: rgba(127, 140, 141, 0.1);
}

.presence-ready {
  color: var(--info);
  background: rgba(52, 152, 219, 0.1);
}

.presence-host {
  color: var(--warning);
  background: rgba(243, 156, 18, 0.12);
}

.presence-in-turn {
  color: var(--success);
  background: rgba(39, 174, 96, 0.1);
}

.presence-in-game {
  color: var(--secondary);
  background: rgba(52, 73, 94, 0.1);
}

.presence-finished {
  color: var(--primary);
  background: rgba(44, 62, 80, 0.08);
}

.chat-sidebar {
  background: var(--white);
  border-radius: 16px;
  padding: 1.25rem;
  box-shadow: var(--card-shadow);
  border: 1px solid rgba(189, 195, 199, 0.3);
  margin-bottom: 2rem;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.chat-header h3 {
  font-size: 1rem;
  margin-bottom: 0.25rem;
}

.chat-header p {
  color: var(--muted);
  font-size: 0.85rem;
}

.chat-toggle-btn {
  min-height: 40px;
}

.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 280px;
  overflow-y: auto;
  padding-right: 0.25rem;
  margin-bottom: 1rem;
}

.chat-empty {
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
  padding: 1.5rem 1rem;
  background: var(--bg);
  border-radius: 12px;
}

.chat-message {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.chat-message.mine {
  align-items: flex-end;
}

.chat-message-meta {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.75rem;
  color: var(--muted);
  padding: 0 0.25rem;
}

.chat-author {
  font-weight: 600;
  color: var(--secondary);
}

.chat-bubble {
  max-width: 85%;
  background: var(--bg);
  color: var(--secondary);
  border-radius: 14px;
  padding: 0.7rem 0.9rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-message.mine .chat-bubble {
  background: var(--primary);
  color: var(--white);
}

.chat-input-group {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
}

.chat-input {
  flex: 1;
  resize: none;
  min-height: 56px;
  padding: 0.8rem 0.95rem;
  border: 2px solid var(--light);
  border-radius: 12px;
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  color: var(--primary);
  background: var(--bg);
  outline: none;
}

.chat-input:focus {
  border-color: var(--primary);
}

.chat-input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.chat-send-btn {
  min-width: 92px;
}

@media (max-width: 640px) {
  .chat-header,
  .chat-input-group {
    flex-direction: column;
    align-items: stretch;
  }

  .chat-send-btn {
    width: 100%;
  }

  .chat-bubble {
    max-width: 100%;
  }
}

.leaderboard-panel { margin-top: 1rem; padding: 1rem; border-radius: 16px; background: rgba(255, 255, 255, 0.04); border: 1px solid rgba(255, 255, 255, 0.08); }
.leaderboard-panel-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 0.75rem; }
.leaderboard-panel-header strong { display: block; }
.leaderboard-panel-header span, .leaderboard-note { font-size: 0.875rem; opacity: 0.75; }
.leaderboard-list { display: grid; gap: 0.6rem; }
.leaderboard-row { display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem 0.85rem; border-radius: 12px; background: rgba(255, 255, 255, 0.03); }
.leaderboard-rank { width: 2.2rem; font-weight: 700; opacity: 0.9; }
.leaderboard-player { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.leaderboard-player strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leaderboard-player span, .leaderboard-score { font-size: 0.875rem; opacity: 0.8; }
.leaderboard-score { font-weight: 700; white-space: nowrap; }
.leaderboard-empty-state { padding: 0.9rem; opacity: 0.75; text-align: center; }

.hint-section {
  background: var(--white);
  border-radius: 16px;
  padding: 1rem 1.25rem;
  box-shadow: var(--card-shadow);
  border: 1px solid rgba(189, 195, 199, 0.2);
  margin-bottom: 1rem;
}

.hint-actions {
  display: flex;
  justify-content: center;
  margin-bottom: 0.75rem;
}

.hint-panel {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  background: var(--bg);
  border-radius: 12px;
  padding: 0.9rem;
}

.hint-panel-header {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.hint-panel-header strong {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.95rem;
}

.hint-panel-header span {
  color: var(--muted);
  font-size: 0.82rem;
}

.hint-input {
  width: 100%;
  resize: vertical;
  min-height: 72px;
  padding: 0.75rem 0.9rem;
  border: 2px solid var(--light);
  border-radius: 10px;
  font-family: 'Inter', sans-serif;
  font-size: 0.92rem;
  color: var(--primary);
  background: var(--white);
  outline: none;
}

.hint-input:focus {
  border-color: var(--primary);
}

.hint-result {
  padding: 0.85rem 0.95rem;
  border-radius: 10px;
  background: rgba(52, 152, 219, 0.1);
  color: var(--secondary);
  line-height: 1.45;
  font-size: 0.94rem;
  border: 1px solid rgba(52, 152, 219, 0.16);
}

.hint-result.consumed {
  background: rgba(39, 174, 96, 0.08);
  border-color: rgba(39, 174, 96, 0.16);
}

@media (max-width: 640px) {
  .hint-section {
    padding: 0.9rem;
  }
}

.history-export-panel {
  background: var(--white);
  border-radius: 14px;
  padding: 1rem 1.15rem;
  box-shadow: var(--card-shadow);
  border: 1px solid rgba(189, 195, 199, 0.2);
  margin-bottom: 1rem;
}

.history-export-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.history-export-header strong {
  display: block;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.98rem;
  margin-bottom: 0.2rem;
}

.history-export-header span,
.history-export-note {
  font-size: 0.86rem;
  color: var(--muted);
  line-height: 1.45;
}

.history-export-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.history-export-btn {
  min-height: 40px;
  padding: 0.6rem 1rem;
}

.history-export-note {
  padding-top: 0.1rem;
}

@media (max-width: 640px) {
  .history-export-header,
  .history-export-actions {
    width: 100%;
  }

  .history-export-header {
    flex-direction: column;
  }

  .history-export-actions {
    justify-content: stretch;
  }

  .history-export-btn {
    flex: 1;
  }
}
