/* ============================================================
   Hangman Fun Land — Warm Cozy Arcade Design System
   Supports Light (Cozy Pastel) & Dark (Cozy Night) Themes
   ============================================================ */

:root {
  --bg-page: #fdf8f2;
  --bg-gradient: radial-gradient(circle at 12% 10%, #fff1e6 0%, #fdf8f2 45%, #eef2ff 100%);
  --bg-card: rgba(255, 255, 255, 0.92);
  --bg-card-solid: #ffffff;
  --bg-soft: #f4f1ea;
  --bg-input: #f8fafc;
  --border: rgba(148, 163, 184, 0.25);
  --border-strong: rgba(148, 163, 184, 0.45);
  --text-main: #1e293b;
  --text-muted: #64748b;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-soft: rgba(99, 102, 241, 0.12);
  --accent: #f97316;
  --accent-hover: #ea580c;
  --success: #22c55e;
  --success-soft: rgba(34, 197, 94, 0.16);
  --warning: #f59e0b;
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.14);
  --ground-color: rgba(180, 83, 9, 0.12);
  --shadow-sm: 0 4px 12px rgba(30, 41, 59, 0.06);
  --shadow-md: 0 12px 30px rgba(30, 41, 59, 0.08);
  --shadow-lg: 0 20px 48px rgba(30, 41, 59, 0.14);
  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 26px;
  --font-ui: 'Kanit', 'Segoe UI', Tahoma, sans-serif;
  --font-game: 'Fredoka', 'Kanit', sans-serif;
}

body.theme-dark {
  --bg-page: #0f172a;
  --bg-gradient: radial-gradient(circle at 12% 10%, #1e1b4b 0%, #0f172a 55%, #172554 100%);
  --bg-card: rgba(30, 41, 59, 0.88);
  --bg-card-solid: #1e293b;
  --bg-soft: rgba(51, 65, 85, 0.72);
  --bg-input: #0f172a;
  --border: rgba(148, 163, 184, 0.2);
  --border-strong: rgba(148, 163, 184, 0.35);
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --primary: #818cf8;
  --primary-hover: #6366f1;
  --primary-soft: rgba(129, 140, 248, 0.18);
  --ground-color: rgba(251, 191, 36, 0.12);
  --shadow-sm: 0 4px 14px rgba(0, 0, 0, 0.28);
  --shadow-md: 0 12px 32px rgba(0, 0, 0, 0.36);
  --shadow-lg: 0 22px 54px rgba(0, 0, 0, 0.5);
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  font-family: var(--font-ui);
  color: var(--text-main);
  background: var(--bg-page);
  background-image: var(--bg-gradient);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

button, input, select {
  font-family: inherit;
  color: inherit;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--text-muted);
}

/* ==================== BACKGROUND DECOR ==================== */
.bg-decor {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.42;
  animation: blobFloat 18s ease-in-out infinite alternate;
}

body.theme-dark .blob {
  opacity: 0.22;
}

.blob-1 {
  width: 340px;
  height: 340px;
  background: #fde68a;
  top: -80px;
  left: -60px;
}

.blob-2 {
  width: 380px;
  height: 380px;
  background: #fbcfe8;
  bottom: -100px;
  right: -80px;
  animation-delay: -6s;
}

.blob-3 {
  width: 300px;
  height: 300px;
  background: #bae6fd;
  top: 42%;
  right: 18%;
  animation-delay: -11s;
}

@keyframes blobFloat {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(28px, -24px) scale(1.08); }
}

#confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9999;
  display: none;
}

/* ==================== TOASTS ==================== */
.toast-container {
  position: fixed;
  top: 76px;
  right: 18px;
  z-index: 9000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 340px;
}

.toast {
  background: var(--bg-card-solid);
  border: 1px solid var(--border);
  border-left: 5px solid var(--primary);
  box-shadow: var(--shadow-md);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 0.94rem;
  font-weight: 500;
  animation: toastIn 0.25s ease-out;
}

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

@keyframes toastIn {
  from { opacity: 0; transform: translateX(24px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ==================== TOPBAR ==================== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(14px);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 10px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  text-align: left;
  transition: transform 0.15s ease;
}

.brand:hover { transform: scale(1.02); }

.brand-logo {
  font-size: 1.9rem;
  line-height: 1;
}

.brand-text strong {
  display: block;
  font-family: var(--font-game);
  font-size: 1.15rem;
  letter-spacing: 0.2px;
  color: var(--primary);
}

.brand-text small {
  display: block;
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-top: -2px;
}

.topbar-stats {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  font-size: 0.88rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  cursor: pointer;
  font-size: 1.1rem;
  display: grid;
  place-items: center;
  transition: transform 0.14s ease, background 0.15s ease;
}

.icon-btn:hover {
  transform: translateY(-2px);
  background: var(--primary-soft);
}

/* ==================== LAYOUT & SCREENS ==================== */
.app-container {
  position: relative;
  z-index: 1;
  max-width: 1120px;
  margin: 0 auto;
  padding: 22px 18px 54px;
}

.screen {
  display: none;
  animation: fadeUp 0.28s ease-out;
}

.screen.active {
  display: block;
}

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

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  backdrop-filter: blur(10px);
}

/* ==================== BUTTONS ==================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 14px;
  padding: 11px 20px;
  font-size: 0.96rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.14s ease, box-shadow 0.16s ease, background 0.16s ease, opacity 0.16s ease;
}

.btn:hover:not(:disabled) {
  transform: translateY(-2px);
}

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

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

.btn-lg {
  padding: 13px 24px;
  font-size: 1.03rem;
  border-radius: 16px;
}

.btn-sm {
  padding: 7px 13px;
  font-size: 0.85rem;
  border-radius: 11px;
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #ffffff;
  box-shadow: 0 8px 20px rgba(99, 102, 241, 0.28);
}

.btn-primary:hover:not(:disabled) {
  box-shadow: 0 12px 26px rgba(99, 102, 241, 0.38);
}

.btn-accent {
  background: linear-gradient(135deg, #fb923c, #f97316);
  color: #ffffff;
  box-shadow: 0 8px 20px rgba(249, 115, 22, 0.26);
}

.btn-soft {
  background: var(--primary-soft);
  color: var(--primary);
}

.btn-ghost {
  background: var(--bg-soft);
  color: var(--text-main);
  border: 1px solid var(--border);
}

.btn-danger-soft {
  background: var(--danger-soft);
  color: var(--danger);
}

/* ==================== HOME HERO ==================== */
.hero-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 32px;
  display: grid;
  grid-template-columns: 1.35fr 0.85fr;
  gap: 28px;
  align-items: center;
  margin-bottom: 28px;
}

.hero-pill {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 0.86rem;
  font-weight: 600;
  margin-bottom: 12px;
}

.hero-card h1 {
  margin: 0 0 12px;
  font-size: clamp(1.8rem, 3.6vw, 2.55rem);
  line-height: 1.2;
}

.gradient-text {
  background: linear-gradient(135deg, #6366f1, #ec4899, #f97316);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-desc {
  margin: 0 0 22px;
  font-size: 1rem;
  line-height: 1.65;
  color: var(--text-muted);
}

.hero-cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.mascot-card {
  background: linear-gradient(145deg, rgba(254, 240, 138, 0.28), rgba(196, 181, 253, 0.24));
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.mascot-svg {
  width: 176px;
  height: 176px;
}

.mascot-bob {
  animation: gentleBob 2.6s ease-in-out infinite;
  transform-origin: 115px 48px;
}

@keyframes gentleBob {
  0%, 100% { transform: rotate(-2.5deg); }
  50% { transform: rotate(2.5deg); }
}

.mascot-tiles {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.mascot-tiles span {
  width: 36px;
  height: 38px;
  border-radius: 10px;
  background: var(--bg-card-solid);
  border: 2px solid var(--primary);
  display: grid;
  place-items: center;
  font-family: var(--font-game);
  font-weight: 700;
  color: var(--primary);
  box-shadow: 0 4px 0 rgba(99, 102, 241, 0.22);
}

/* ==================== MODE GRID ==================== */
.section-title {
  margin: 0 0 14px;
  font-size: 1.32rem;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

.mode-card {
  position: relative;
  text-align: left;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  padding: 22px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.mode-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-md);
}

.mode-solo:hover { border-color: #22c55e; }
.mode-ai:hover { border-color: #6366f1; }
.mode-online:hover { border-color: #f97316; }

.mode-icon {
  font-size: 2.3rem;
  width: 58px;
  height: 58px;
  border-radius: 16px;
  background: var(--bg-soft);
  display: grid;
  place-items: center;
}

.mode-body h3 {
  margin: 0 0 6px;
  font-size: 1.18rem;
}

.mode-body p {
  margin: 0 0 12px;
  font-size: 0.92rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.mode-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.mode-tags span {
  font-size: 0.78rem;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--text-main);
}

.mode-arrow {
  position: absolute;
  top: 20px;
  right: 20px;
  font-size: 1.25rem;
  color: var(--text-muted);
  transition: transform 0.16s ease;
}

.mode-card:hover .mode-arrow {
  transform: translateX(4px);
  color: var(--primary);
}

/* ==================== STAGE MAP ==================== */
.screen-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}

.screen-header h2 {
  margin: 0 0 4px;
  font-size: 1.45rem;
}

.screen-header p {
  margin: 0;
  font-size: 0.94rem;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.filter-chip {
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.15s ease;
}

.filter-chip.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 6px 16px rgba(99, 102, 241, 0.25);
}

.stage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(295px, 1fr));
  gap: 16px;
}

.stage-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 12px;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  position: relative;
  overflow: hidden;
}

.stage-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 5px;
  background: var(--stage-accent, var(--primary));
}

.stage-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
}

.stage-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.stage-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.stage-icon-box {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 1.65rem;
  color: #ffffff;
  flex-shrink: 0;
}

.stage-num {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
}

.stage-name {
  margin: 0;
  font-size: 1.12rem;
  line-height: 1.25;
}

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

.diff-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}

.stage-desc {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.45;
  flex: 1;
}

.stage-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  font-size: 0.86rem;
}

.stage-stars {
  font-size: 1rem;
  letter-spacing: 2px;
}

/* ==================== FORMS & SETUP PANELS ==================== */
.setup-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.setup-block h3 {
  margin: 0 0 12px;
  font-size: 1.08rem;
}

.bot-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.bot-card {
  text-align: left;
  background: var(--bg-soft);
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  padding: 16px;
  cursor: pointer;
  transition: all 0.16s ease;
}

.bot-card:hover { transform: translateY(-2px); }

.bot-card.active {
  background: var(--primary-soft);
  border-color: var(--primary);
}

.bot-card .bot-avatar {
  font-size: 2rem;
  display: block;
  margin-bottom: 6px;
}

.bot-card strong {
  display: block;
  font-size: 1.02rem;
}

.bot-card small {
  display: inline-block;
  margin: 4px 0 6px;
  font-weight: 600;
  color: var(--primary);
}

.bot-card p {
  margin: 0;
  font-size: 0.84rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.submode-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.submode-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  text-align: left;
  background: var(--bg-soft);
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  padding: 16px;
  cursor: pointer;
  transition: all 0.16s ease;
}

.submode-card.active {
  background: var(--primary-soft);
  border-color: var(--primary);
}

.submode-icon {
  font-size: 1.8rem;
  line-height: 1;
}

.submode-card p {
  margin: 4px 0 0;
  font-size: 0.86rem;
  color: var(--text-muted);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.form-row.three-col {
  grid-template-columns: 1.1fr 1.3fr 0.8fr;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-muted);
}

.text-input, .select-input {
  width: 100%;
  padding: 11px 14px;
  border-radius: 12px;
  border: 1.5px solid var(--border-strong);
  background: var(--bg-input);
  font-size: 0.96rem;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.text-input:focus, .select-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.input-with-btn {
  display: flex;
  gap: 8px;
}

.code-input {
  text-transform: uppercase;
  font-family: var(--font-game);
  letter-spacing: 2px;
  font-weight: 700;
}

.setup-footer {
  display: flex;
  justify-content: flex-end;
}

/* ==================== ONLINE LOBBY ==================== */
.online-profile-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  margin-bottom: 18px;
}

.inline-field {
  flex-direction: row;
  align-items: center;
  gap: 10px;
}

.inline-field .text-input {
  width: 220px;
}

.env-badge {
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 0.85rem;
  font-weight: 600;
}

.online-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
  margin-bottom: 18px;
}

.online-card h3 {
  margin: 0 0 8px;
}

.online-card p {
  margin: 0 0 16px;
  font-size: 0.92rem;
}

.room-lobby {
  margin-bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.room-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.room-label {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.room-code-box {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}

.room-code-box strong {
  font-family: var(--font-game);
  font-size: 2rem;
  letter-spacing: 5px;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 4px 16px;
  border-radius: 14px;
}

.transport-note {
  font-size: 0.86rem;
  color: var(--text-muted);
  background: var(--bg-soft);
  padding: 9px 14px;
  border-radius: 12px;
}

.players-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 14px;
}

.player-slot {
  background: var(--bg-soft);
  border: 2px dashed var(--border-strong);
  border-radius: 16px;
  padding: 16px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.player-slot.filled {
  border-style: solid;
  border-color: var(--success);
  background: var(--success-soft);
}

.player-avatar {
  font-size: 2rem;
}

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

.vs-badge {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f97316, #ec4899);
  color: #ffffff;
  font-family: var(--font-game);
  font-weight: 700;
  display: grid;
  place-items: center;
}

.lobby-settings {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.guest-waiting {
  text-align: center;
  padding: 14px;
  border-radius: 14px;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 500;
}

.challenge-builder h3 {
  margin: 0 0 6px;
}

.challenge-builder .muted {
  margin: 0 0 14px;
  font-size: 0.9rem;
}

.challenge-actions {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.challenge-output {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 0.84rem;
  word-break: break-all;
}

/* ==================== GAME ARENA ==================== */
.game-hud {
  display: grid;
  grid-template-columns: auto 1.3fr 1fr auto;
  align-items: center;
  gap: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}

.hud-stage-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hud-icon {
  font-size: 1.75rem;
}

.hud-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.hud-timer-wrap {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.timer-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.timer-clock {
  font-family: var(--font-game);
  font-size: 1.12rem;
  font-weight: 700;
}

.timer-clock.warning { color: var(--warning); }
.timer-clock.danger {
  color: var(--danger);
  animation: pulseFast 0.65s ease-in-out infinite;
}

@keyframes pulseFast {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.07); }
}

.pause-btn {
  border: none;
  background: var(--bg-soft);
  border-radius: 8px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 0.9rem;
}

.timer-bar-track {
  height: 9px;
  border-radius: 999px;
  background: var(--bg-soft);
  overflow: hidden;
}

.timer-bar-fill {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #22c55e, #4ade80);
  transition: width 0.3s linear, background 0.3s ease;
}

.timer-bar-fill.warning { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.timer-bar-fill.danger { background: linear-gradient(90deg, #ef4444, #fb7185); }

.hud-score-wrap {
  display: flex;
  gap: 12px;
}

.hud-mini-stat {
  background: var(--bg-soft);
  border-radius: 12px;
  padding: 6px 12px;
  text-align: center;
  min-width: 70px;
}

.hud-mini-stat span {
  display: block;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.hud-mini-stat strong {
  font-family: var(--font-game);
  font-size: 1.05rem;
}

/* ==================== OPPONENT PANEL ==================== */
.opponent-panel {
  display: grid;
  grid-template-columns: 1.1fr 1fr 1.1fr;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  border: 2px solid var(--primary-soft);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: 14px;
}

.opp-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.opp-avatar {
  font-size: 1.9rem;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--primary-soft);
  display: grid;
  place-items: center;
}

.opp-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.opp-score {
  font-size: 0.78rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-soft);
  font-weight: 600;
}

.opp-status {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.opp-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

.opp-progress-tiles {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
}

.opp-dot {
  width: 18px;
  height: 22px;
  border-radius: 5px;
  background: var(--bg-soft);
  border: 1.5px solid var(--border-strong);
  font-family: var(--font-game);
  font-size: 0.72rem;
  display: grid;
  place-items: center;
  font-weight: 700;
}

.opp-dot.found {
  background: var(--success-soft);
  border-color: var(--success);
  color: var(--success);
}

.opp-hearts {
  font-size: 0.84rem;
  letter-spacing: 1px;
}

.opp-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.opp-bubble {
  background: var(--primary-soft);
  color: var(--primary);
  padding: 6px 12px;
  border-radius: 14px 14px 4px 14px;
  font-size: 0.85rem;
  font-weight: 500;
  max-width: 100%;
}

.emoji-bar {
  display: flex;
  gap: 6px;
}

.emoji-btn {
  border: 1px solid var(--border);
  background: var(--bg-soft);
  border-radius: 10px;
  padding: 4px 8px;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.14s ease;
}

.emoji-btn:hover {
  transform: scale(1.2);
}

.duel-setter-panel {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.duel-setter-panel h3 {
  margin: 0;
}

/* ==================== PLAY BOARD ==================== */
.play-board {
  display: grid;
  grid-template-columns: 0.82fr 1.38fr;
  gap: 18px;
  align-items: stretch;
}

.gallows-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
}

.lives-row {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 10px;
  border-bottom: 1px dashed var(--border);
}

.lives-label {
  font-size: 0.86rem;
  color: var(--text-muted);
}

.lives-hearts {
  font-size: 1.05rem;
  letter-spacing: 2px;
}

.lives-count {
  font-family: var(--font-game);
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--primary);
}

.svg-stage {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 0 4px;
}

.hangman-svg {
  width: 100%;
  max-width: 245px;
  height: auto;
}

.hm-part {
  opacity: 0;
  transform-origin: center;
  transition: opacity 0.28s ease, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  transform: scale(0.8);
}

.hm-part.shown {
  opacity: 1;
  transform: scale(1);
}

.hangman-svg.shake {
  animation: gentleShake 0.36s ease;
}

@keyframes gentleShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.hangman-svg.celebrate #hm-character {
  animation: jumpCelebrate 0.6s ease-in-out infinite alternate;
}

@keyframes jumpCelebrate {
  from { transform: translateY(0); }
  to { transform: translateY(-9px); }
}

.hm-speech {
  margin-top: 8px;
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--bg-soft);
  font-size: 0.88rem;
  font-weight: 500;
  text-align: center;
  color: var(--text-main);
}

/* ==================== WORD CARD & KEYBOARD ==================== */
.word-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
}

.word-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.category-pill, .length-pill {
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 600;
}

.category-pill {
  background: var(--primary-soft);
  color: var(--primary);
}

.length-pill {
  background: var(--bg-soft);
  color: var(--text-muted);
}

.hint-banner {
  background: rgba(245, 158, 11, 0.14);
  border: 1.5px solid rgba(245, 158, 11, 0.35);
  border-radius: 14px;
  padding: 10px 14px;
  font-size: 0.94rem;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  animation: fadeUp 0.2s ease;
}

.word-tiles {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  padding: 12px 4px;
  min-height: 82px;
  align-items: center;
}

.letter-tile {
  width: clamp(34px, 4.6vw, 52px);
  height: clamp(44px, 5.6vw, 60px);
  border-radius: 14px;
  border: 2px solid var(--border-strong);
  border-bottom: 4px solid var(--border-strong);
  background: var(--bg-soft);
  display: grid;
  place-items: center;
  font-family: var(--font-game);
  font-size: clamp(1.25rem, 2.5vw, 1.75rem);
  font-weight: 700;
  color: var(--text-main);
  transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.letter-tile.revealed {
  background: var(--bg-card-solid);
  border-color: var(--primary);
  border-bottom-color: var(--primary);
  color: var(--primary);
  animation: popTile 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.letter-tile.missed {
  background: var(--danger-soft);
  border-color: var(--danger);
  border-bottom-color: var(--danger);
  color: var(--danger);
}

@keyframes popTile {
  0% { transform: scale(0.7); }
  70% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

.powerup-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.power-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 12px;
  border: 1.5px solid var(--border-strong);
  background: var(--bg-card-solid);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.power-btn:hover:not(:disabled) {
  border-color: var(--primary);
  background: var(--primary-soft);
  transform: translateY(-2px);
}

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

.power-count {
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--primary);
  color: #ffffff;
  font-size: 0.75rem;
  display: inline-grid;
  place-items: center;
}

.spectator-banner {
  text-align: center;
  padding: 12px;
  border-radius: 14px;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}

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

.kb-row {
  display: flex;
  justify-content: center;
  gap: 6px;
}

.key-btn {
  flex: 0 1 48px;
  height: 48px;
  border-radius: 12px;
  border: 1.5px solid var(--border-strong);
  border-bottom: 4px solid var(--border-strong);
  background: var(--bg-card-solid);
  font-family: var(--font-game);
  font-size: 1.08rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s ease, background 0.15s ease, border-color 0.15s ease;
  user-select: none;
}

.key-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  border-color: var(--primary);
  color: var(--primary);
}

.key-btn:active:not(:disabled) {
  transform: translateY(1px);
}

.key-btn.correct {
  background: var(--success);
  border-color: #16a34a;
  color: #ffffff;
}

.key-btn.wrong {
  background: var(--bg-soft);
  border-color: var(--border);
  color: var(--text-muted);
  opacity: 0.48;
  text-decoration: line-through;
}

.key-btn:disabled {
  cursor: default;
}

/* ==================== MODALS ==================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(15, 23, 42, 0.56);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  padding: 18px;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-card {
  width: 100%;
  max-width: 470px;
  background: var(--bg-card-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 28px 24px;
  text-align: center;
  animation: popModal 0.26s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-sm { max-width: 390px; }

@keyframes popModal {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

.res-emoji {
  font-size: 3.3rem;
  line-height: 1;
  margin-bottom: 10px;
}

.modal-card h2 {
  margin: 0 0 6px;
  font-size: 1.48rem;
}

.res-word-box {
  margin: 16px 0;
  padding: 14px;
  border-radius: 16px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
}

.res-word-box small {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.res-word {
  font-family: var(--font-game);
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--primary);
  margin: 4px 0 2px;
}

.res-meaning {
  font-size: 1rem;
  font-weight: 600;
}

.res-stars {
  font-size: 2rem;
  letter-spacing: 6px;
  margin: 8px 0;
}

.res-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 14px 0 18px;
}

.res-stat-item {
  background: var(--bg-soft);
  border-radius: 12px;
  padding: 8px;
}

.res-stat-item span {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.res-stat-item strong {
  font-family: var(--font-game);
  font-size: 1.08rem;
}

.res-actions {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.help-list {
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 16px 0 20px;
}

.help-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--bg-soft);
  padding: 11px 13px;
  border-radius: 14px;
}

.help-item span {
  font-size: 1.4rem;
  line-height: 1.2;
}

.help-item p {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.45;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 920px) {
  .hero-card {
    grid-template-columns: 1fr;
    padding: 24px;
  }
  .mode-grid, .bot-grid, .online-grid {
    grid-template-columns: 1fr;
  }
  .play-board {
    grid-template-columns: 1fr;
  }
  .game-hud {
    grid-template-columns: auto 1fr;
  }
  .hud-timer-wrap, .hud-score-wrap {
    grid-column: 1 / -1;
  }
  .opponent-panel {
    grid-template-columns: 1fr;
    text-align: center;
  }
  .opp-left, .opp-right {
    justify-content: center;
    align-items: center;
  }
}

@media (max-width: 640px) {
  .topbar-stats {
    display: none;
  }
  .submode-grid, .form-row, .form-row.three-col {
    grid-template-columns: 1fr;
  }
  .players-row {
    grid-template-columns: 1fr;
  }
  .vs-badge {
    margin: 0 auto;
  }
  .key-btn {
    height: 44px;
    font-size: 0.98rem;
    flex: 1 1 28px;
  }
  .kb-row {
    gap: 4px;
  }
}

/* ==================== CONTEXTUAL CARNIVAL & STAGE VISUAL ARTWORK ==================== */
.hero-card.has-carnival-art {
  background: linear-gradient(115deg, rgba(255, 255, 255, 0.94) 0%, rgba(255, 248, 238, 0.88) 58%, rgba(255, 255, 255, 0.45) 100%),
    url('/images/games/hangman-hero.jpg') center/cover no-repeat !important;
  border: 2px solid rgba(245, 158, 11, 0.45);
}
body.dark-mode .hero-card.has-carnival-art,
body.theme-dark .hero-card.has-carnival-art {
  background: linear-gradient(115deg, rgba(15, 23, 42, 0.92) 0%, rgba(30, 27, 75, 0.85) 58%, rgba(15, 23, 42, 0.65) 100%),
    url('/images/games/hangman-hero.jpg') center/cover no-repeat !important;
}
.stage-card.has-stage-photo {
  padding: 0 !important;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.stage-photo-banner {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 10px 12px;
}
.stage-photo-banner::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.25) 0%, rgba(15, 23, 42, 0.58) 100%);
}
.stage-photo-num, .stage-photo-banner .diff-pill {
  position: relative;
  z-index: 2;
}
.stage-photo-num {
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.78);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  border: 1px solid rgba(255, 255, 255, 0.35);
}
.stage-card-body {
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}
