:root {
  --bg-primary: #0b0f19;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.75);
  --bg-card-hover: rgba(31, 41, 55, 0.85);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: #6366f1;

  --accent-purple: #8b5cf6;
  --accent-indigo: #6366f1;
  --accent-pink: #ec4899;
  --accent-cyan: #06b6d4;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --shadow-glow: 0 0 25px rgba(99, 102, 241, 0.25);
  --shadow-card: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  background-image: 
    radial-gradient(circle at 15% 15%, rgba(99, 102, 241, 0.12) 0%, transparent 40%),
    radial-gradient(circle at 85% 85%, rgba(236, 72, 153, 0.1) 0%, transparent 45%);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Header & Top Bar */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  background: rgba(11, 15, 25, 0.8);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 50;
}

.logo-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  font-size: 1.7rem;
  background: linear-gradient(135deg, var(--accent-indigo), var(--accent-pink));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-title {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #ffffff, #cbd5e1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-badge {
  font-size: 0.65rem;
  background: rgba(99, 102, 241, 0.2);
  color: var(--accent-indigo);
  border: 1px solid rgba(99, 102, 241, 0.4);
  padding: 2px 7px;
  border-radius: 20px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.icon-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
  transform: scale(1.05);
}

/* Main Screen Container */
.main-viewport {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 16px;
  position: relative;
}

.screen {
  display: none;
  width: 100%;
  animation: fadeIn 0.3s ease;
}

.screen.active {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

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

/* Card Container Styles */
.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 32px;
  width: 100%;
  max-width: 480px;
}

.hero-tagline {
  text-align: center;
  margin-bottom: 24px;
}

.hero-tagline h1 {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 6px;
  background: linear-gradient(135deg, #ffffff, #94a3b8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

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

/* Form inputs & Avatar Picker */
.form-section {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.styled-input {
  width: 100%;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-family: inherit;
  transition: all 0.2s ease;
}

.styled-input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.avatar-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

.avatar-option {
  background: rgba(255, 255, 255, 0.04);
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 1.5rem;
  padding: 8px 0;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.avatar-option:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-2px);
}

.avatar-option.active {
  background: rgba(99, 102, 241, 0.25);
  border-color: var(--accent-indigo);
  transform: scale(1.1);
}

/* Action Cards Split */
.action-cards {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.action-box {
  background: rgba(15, 23, 42, 0.4);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
}

.action-title {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 12px;
  color: #e2e8f0;
}

.settings-row {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}

.setting-col {
  flex: 1;
}

.setting-col select {
  width: 100%;
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
}

.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, var(--accent-indigo), var(--accent-purple));
  color: #ffffff;
  border: none;
  padding: 12px 18px;
  font-size: 1rem;
  font-weight: 700;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
  opacity: 0.95;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
  width: 100%;
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  border: 1px solid var(--border-color);
  padding: 12px 18px;
  font-size: 1rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.14);
}

.join-row {
  display: flex;
  gap: 8px;
}

.room-input {
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 2px;
  text-align: center;
  font-size: 1.1rem;
}

/* Lobby Screen */
.lobby-header {
  text-align: center;
  margin-bottom: 24px;
}

.room-code-tag {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
  padding: 8px 20px;
  border-radius: 30px;
  margin: 12px 0 16px;
}

.room-code-tag span {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.room-code-tag b {
  font-size: 1.6rem;
  letter-spacing: 3px;
  color: #a5b4fc;
}

.lobby-share-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.players-roster-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.players-roster {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
  margin-bottom: 24px;
}

.player-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}

.player-card.self {
  border-color: rgba(99, 102, 241, 0.5);
  background: rgba(99, 102, 241, 0.1);
}

.p-avatar {
  font-size: 1.5rem;
}

.p-info {
  flex: 1;
}

.p-name {
  font-size: 0.95rem;
  font-weight: 600;
}

.crown-badge {
  font-size: 0.75rem;
  color: var(--accent-amber);
  margin-left: 4px;
}

.p-status {
  font-size: 0.75rem;
  color: var(--accent-emerald);
}

.waiting-hint {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 10px;
}

/* Game Arena Layout */
#screen-game {
  width: 100%;
  max-width: 1400px;
  height: calc(100vh - 80px);
  display: none;
  flex-direction: column;
  padding: 0;
}

#screen-game.active {
  display: flex;
}

.game-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  background: rgba(15, 23, 42, 0.6);
  border-radius: var(--radius-md);
  margin-bottom: 10px;
  border: 1px solid var(--border-color);
}

.game-stat-pill {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.timer-box {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #f87171;
  padding: 4px 14px;
  border-radius: 20px;
  font-size: 1.1rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 6px;
}

.pulse-warning {
  animation: pulseScale 0.5s infinite alternate;
  color: #ef4444;
  border-color: #ef4444;
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.5);
}

@keyframes pulseScale {
  from { transform: scale(1); }
  to { transform: scale(1.1); }
}

.word-bar {
  flex: 1;
  text-align: center;
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.letter-blank {
  display: inline-block;
  width: 18px;
  height: 4px;
  background: #cbd5e1;
  border-radius: 2px;
  margin: 0 3px;
  vertical-align: middle;
}

.word-space {
  display: inline-block;
  width: 16px;
}

.letter-hint {
  color: var(--accent-cyan);
  font-size: 1.4rem;
  font-weight: 800;
}

.revealed-word {
  color: var(--accent-emerald);
  font-weight: 800;
  letter-spacing: 2px;
}

.revealed-word-success {
  color: var(--accent-emerald);
  font-weight: 800;
  animation: glowGreen 1s ease infinite alternate;
}

/* 3-Column Game Grid */
.game-grid {
  display: grid;
  grid-template-columns: 240px 1fr 320px;
  gap: 12px;
  flex: 1;
  min-height: 0;
}

/* Left Column: Player Standings */
.leaderboard-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-header {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-color);
}

.game-players-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  flex: 1;
}

.game-player-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}

.game-player-row.self {
  border-color: rgba(99, 102, 241, 0.4);
  background: rgba(99, 102, 241, 0.1);
}

.game-player-row.guessed {
  border-color: rgba(16, 185, 129, 0.4);
  background: rgba(16, 185, 129, 0.1);
}

.gp-rank {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-dim);
  width: 20px;
}

.gp-avatar {
  font-size: 1.25rem;
}

.gp-info {
  flex: 1;
  overflow: hidden;
}

.gp-name {
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gp-score {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.guess-badge {
  color: var(--accent-emerald);
  font-weight: 800;
  font-size: 1.1rem;
}

/* Center Column: Canvas + Drawing Tools */
.canvas-panel {
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px;
  position: relative;
  min-height: 0;
}

.canvas-wrapper {
  flex: 1;
  position: relative;
  background: #ffffff;
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.1);
}

#drawing-canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* Drawer Controls Bar */
.drawer-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 6px 0;
  background: transparent;
  flex-wrap: wrap;
}

.tool-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tool-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s ease;
}

.tool-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

.tool-btn.active {
  background: var(--accent-indigo);
  border-color: var(--accent-indigo);
  color: #ffffff;
}

.palette-container {
  display: flex;
  align-items: center;
  gap: 4px;
}

.color-swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.color-swatch:hover {
  transform: scale(1.15);
}

.color-swatch.active {
  border-color: #ffffff;
  transform: scale(1.2);
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.6);
}

.color-picker-input {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: none;
  cursor: pointer;
  padding: 0;
}

.color-picker-input::-webkit-color-swatch-wrapper {
  padding: 0;
}

.color-picker-input::-webkit-color-swatch {
  border: 2px solid var(--border-color);
  border-radius: 50%;
}

.size-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.size-btn.active {
  background: rgba(99, 102, 241, 0.3);
  border-color: var(--accent-indigo);
}

.size-dot {
  background: #ffffff;
  border-radius: 50%;
}

/* Right Column: Chat & Guess Feed */
.chat-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  padding: 12px;
  min-height: 0;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 4px;
  margin-bottom: 10px;
}

.chat-row {
  font-size: 0.9rem;
  line-height: 1.4;
  word-break: break-word;
}

.chat-author {
  font-weight: 700;
  color: var(--accent-cyan);
  margin-right: 4px;
}

.chat-text {
  color: #e2e8f0;
}

.chat-system {
  color: var(--text-dim);
  font-size: 0.8rem;
  font-style: italic;
  display: block;
  text-align: center;
  margin: 4px 0;
}

.chat-correct {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  display: block;
  font-weight: 700;
  text-align: center;
}

.chat-row.guessed_only .chat-text {
  color: #6ee7b7;
  font-style: italic;
}

.chat-input-bar {
  display: flex;
  gap: 8px;
}

.chat-input {
  flex: 1;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
}

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

.btn-send {
  background: var(--accent-indigo);
  color: #ffffff;
  border: none;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.btn-send:hover {
  opacity: 0.9;
}

/* Close Guess Notification Toast */
.close-toast {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: rgba(245, 158, 11, 0.95);
  color: #000;
  font-weight: 800;
  font-size: 0.95rem;
  padding: 8px 18px;
  border-radius: 20px;
  box-shadow: 0 4px 15px rgba(245, 158, 11, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 100;
}

.close-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 15, 25, 0.85);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 16px;
}

.modal-overlay.active {
  display: flex;
}

.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 32px;
  max-width: 480px;
  width: 100%;
  text-align: center;
  animation: zoomIn 0.25s ease;
}

@keyframes zoomIn {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

.modal-title {
  font-size: 1.6rem;
  font-weight: 800;
  margin-bottom: 8px;
}

.modal-subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 24px;
}

.word-choices-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.word-choice-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  padding: 16px;
  border-radius: var(--radius-md);
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.word-choice-card:hover {
  background: rgba(99, 102, 241, 0.15);
  border-color: var(--accent-indigo);
  transform: translateY(-2px);
}

.wc-word {
  font-size: 1.25rem;
  font-weight: 800;
  text-transform: capitalize;
}

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

.wc-diff.easy { color: var(--accent-emerald); font-weight: 700; }
.wc-diff.medium { color: var(--accent-amber); font-weight: 700; }
.wc-diff.hard { color: var(--accent-rose); font-weight: 700; }

/* Podium Final Screen */
.podium-container {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 12px;
  margin: 32px 0 28px;
  min-height: 180px;
}

.podium-stand {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 90px;
}

.podium-stand.rank-1 { order: 2; }
.podium-stand.rank-2 { order: 1; }
.podium-stand.rank-3 { order: 3; }

.podium-avatar {
  font-size: 2.2rem;
  margin-bottom: 4px;
}

.podium-name {
  font-size: 0.85rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 90px;
}

.podium-score {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.podium-block {
  width: 100%;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  font-weight: 800;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.rank-1 .podium-block {
  height: 110px;
  background: linear-gradient(180deg, #f59e0b, #d97706);
}

.rank-2 .podium-block {
  height: 80px;
  background: linear-gradient(180deg, #94a3b8, #64748b);
}

.rank-3 .podium-block {
  height: 55px;
  background: linear-gradient(180deg, #b45309, #78350f);
}

/* Mobile Responsive */
@media (max-width: 900px) {
  .app-header {
    padding: 10px 16px;
  }

  .game-grid {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(280px, 1fr) 220px;
    gap: 8px;
  }

  .leaderboard-panel {
    max-height: 65px;
    padding: 6px 10px;
  }

  .panel-header {
    display: none;
  }

  .game-players-list {
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 6px;
  }

  .game-player-row {
    flex-shrink: 0;
    padding: 4px 8px;
  }

  .chat-panel {
    height: 200px;
  }

  .drawer-controls {
    gap: 6px;
  }

  .color-swatch {
    width: 20px;
    height: 20px;
  }
}
