:root {
  --bg: #0f172a;
  --bg-card: #111827;
  --accent: #22c55e;
  --accent-soft: rgba(34, 197, 94, 0.15);
  --text: #e5e7eb;
  --muted: #9ca3af;
  --danger: #f97373;
  --border: #1f2937;
  --radius: 16px;
  --shadow: 0 14px 28px rgba(0, 0, 0, 0.35);
}

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

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: radial-gradient(circle at top, #1e293b 0, #020617 55%);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 960px;
  margin: 0 auto;
  padding: 8px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  margin-bottom: 8px;
}

.app-header h1 {
  font-size: 1.1rem;
  margin: 0;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lang-btn {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  cursor: pointer;
}

.lang-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}

.small-btn {
  border-radius: 999px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.7);
  color: var(--text);
  cursor: pointer;
  font-size: 0.75rem;
}

.hidden {
  display: none !important;
}

main {
  padding: 0 4px 12px;
}

.card {
  background: linear-gradient(145deg, #020617, #020617);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(148, 163, 184, 0.25);
  margin-bottom: 12px;
}

.card h2,
.card h3 {
  margin-top: 0;
  margin-bottom: 8px;
}

.error-text {
  color: var(--danger);
  font-size: 0.8rem;
  min-height: 1.1rem;
}

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

/* Auth */

.auth-card {
  max-width: 420px;
  margin: 16px auto;
}

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

.auth-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.85rem;
}

input[type="text"],
input[type="password"],
input[type="number"] {
  background: #020617;
  border-radius: 10px;
  border: 1px solid var(--border);
  padding: 7px 9px;
  color: var(--text);
  font-size: 0.9rem;
}

input:focus {
  outline: none;
  border-color: var(--accent);
}

.primary-btn {
  appearance: none;
  border: none;
  border-radius: 999px;
  padding: 8px 14px;
  background: linear-gradient(135deg, #22c55e, #4ade80);
  color: #022c22;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  margin-top: 6px;
}

.primary-btn.disabled {
  opacity: 0.4;
  cursor: default;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.tab {
  flex: 1;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  padding: 4px 0;
  font-size: 0.85rem;
  cursor: pointer;
}

.tab.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}

/* Nav tabs */

.nav-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
}

.nav-tab {
  flex: 1;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #020617;
  color: var(--muted);
  padding: 6px 4px;
  font-size: 0.8rem;
  cursor: pointer;
}

.nav-tab.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}

/* Lists & chips */

.simple-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
}

.simple-list li {
  padding: 4px 0;
  border-bottom: 1px dashed rgba(148, 163, 184, 0.3);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
}

.chip {
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.8);
  color: var(--muted);
  font-size: 0.8rem;
  cursor: pointer;
}

.chip.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}

/* Inline form */

.inline-form {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.inline-form input {
  flex: 1;
}

/* Game area */

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.focus-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8rem;
  color: var(--muted);
}

#round-info {
  font-size: 0.9rem;
  margin: 4px 0 8px;
}

.score-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.score-row-name {
  flex: 1;
  font-size: 0.9rem;
}

.score-row input[type="number"] {
  width: 80px;
}

#round-progress {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 6px;
}

/* Summary table */

.summary-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.summary-table th,
.summary-table td {
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
  padding: 4px 2px;
  text-align: left;
}

.summary-table tbody tr:first-child {
  font-weight: 600;
  color: var(--accent);
}

/* History detail */

.history-expand-btn {
  margin-bottom: 6px;
}

.round-header {
  cursor: pointer;
  background: rgba(15, 23, 42, 0.8);
}

.round-header:hover {
  background: rgba(34, 197, 94, 0.08);
}

.round-toggle {
  font-size: 0.8rem;
  opacity: 0.8;
}

.round-detail.round-winner td {
  font-weight: 600;
  color: var(--accent);
}

/* Charts */

.chart-block {
  margin-top: 10px;
}

/* Focus mode */

body.focus-mode .nav-tabs,
body.focus-mode #view-home,
body.focus-mode #view-players,
body.focus-mode #view-stats,
body.focus-mode #game-summary {
  display: none !important;
}

body.focus-mode #view-new-game {
  display: block;
}

body.focus-mode .app-header h1 {
  font-size: 0.95rem;
}

body.focus-mode .header-right {
  gap: 4px;
}

/* Desktop tweaks */

@media (min-width: 768px) {
  .app {
    padding: 12px 16px 24px;
  }

  .app-header h1 {
    font-size: 1.2rem;
  }
}

/* =========================
   Home page enhancements
   ========================= */

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

/* Hero row */

.home-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 4px;
}

.home-hero-text {
  flex: 1;
}

.home-hero-image-wrap {
  flex-shrink: 0;
}

.home-hero-image {
  display: block;
  width: 180px;
  max-width: 40vw;
  border-radius: 14px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.7);
  /* removed border so there is no visible box/line */
  border: none;
}

/* Section dividers */

.home-section,
.home-columns {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid rgba(148, 163, 184, 0.18);
}

.home-section-title {
  margin: 0 0 6px;
  font-size: 0.95rem;
}

/* Quick stats pills */

.home-stats-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.home-stat-pill {
  min-width: 140px;
  padding: 8px 12px;
  border-radius: 999px;
  background: radial-gradient(
    circle at top left,
    rgba(34, 197, 94, 0.22),
    rgba(15, 23, 42, 0.95)
  );
  border: 1px solid rgba(148, 163, 184, 0.6);
  font-size: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
}

.home-stat-label {
  color: var(--muted);
}

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

/* Last game line */

.home-last-game {
  margin-top: 6px;
  font-size: 0.82rem;
}

/* Leaders + fun fact columns */

.home-columns {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.home-column {
  flex: 1;
  min-width: 220px;
}

/* Leaders */

.home-leaders-list {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
}

.home-leader-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  padding: 4px 8px;
  border-radius: 10px;
}

.home-leader-item:first-child {
  background: radial-gradient(
    circle at left,
    rgba(34, 197, 94, 0.28),
    rgba(15, 23, 42, 0.95)
  );
}

/* NEW: separate icon + rank so numbers align nicely */
.home-leader-icon {
  width: 20px;
  font-size: 0.9rem;
  text-align: center;
}

.home-leader-rank {
  width: 32px;
  font-size: 0.82rem;
  color: var(--muted);
}

.home-leader-name {
  flex: 1;
}

.home-leader-detail {
  font-size: 0.8rem;
  color: var(--muted);
}

.home-leader-empty {
  font-size: 0.85rem;
  color: var(--muted);
}

/* Fun fact */

.home-funfact-text {
  font-size: 0.85rem;
  margin-top: 4px;
  font-style: italic;
  border-left: 2px solid rgba(148, 163, 184, 0.5);
  padding-left: 8px;
}

/* Footer */

.app-footer {
  margin-top: 8px;
  padding: 6px 10px 16px;
  text-align: center;
  font-size: 0.75rem;
  color: var(--muted);
}

/* Responsive tweaks for home hero */

@media (max-width: 640px) {
  .home-hero {
    align-items: flex-start;
  }

  .home-hero-image {
    width: 140px;
  }
}
