/* ===== RESET & BASE ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --accent: #06b6d4;
  --accent-dark: #0891b2;
  --accent-light: rgba(6, 182, 212, 0.15);
  --accent-glow: rgba(6, 182, 212, 0.3);

  --bg: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
  --bg-card: linear-gradient(145deg, #1e293b, #334155);
  --bg-card-hover: linear-gradient(145deg, #263347, #3d5068);
  --bg-input: #0f172a;
  --bg-surface: #1e293b;

  --text: #e2e8f0;
  --text-heading: #f1f5f9;
  --text-muted: #94a3b8;
  --border: rgba(255,255,255,0.08);
  --border-focus: var(--accent);

  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 4px 20px rgba(0,0,0,0.4);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.5);
  --font: 'Segoe UI', Tahoma, 'Arial Hebrew', Arial, sans-serif;
}

html {
  direction: rtl;
  font-size: 16px;
}

body {
  font-family: var(--font);
  background: var(--bg);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

/* ===== TYPOGRAPHY ===== */
h1 { font-size: clamp(1.8rem, 5vw, 2.4rem); font-weight: 800; }
h2 { font-size: clamp(1.2rem, 4vw, 1.6rem); font-weight: 700; }
h3 { font-size: 1.05rem; font-weight: 600; color: var(--text-heading); }

/* ===== LAYOUT ===== */
.container {
  max-width: 600px;
  margin: 0 auto;
  padding: 1rem;
}

.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 0.85rem;
  position: relative;
  overflow: hidden;
}

/* Accent top line on cards */
.card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), transparent);
  opacity: 0.6;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  font-family: var(--font);
  transition: all 0.15s ease;
  text-decoration: none;
  width: 100%;
  min-height: 48px;
}

.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff;
  box-shadow: 0 4px 15px var(--accent-glow);
}
.btn-primary:hover:not(:disabled) {
  box-shadow: 0 6px 20px var(--accent-glow);
  filter: brightness(1.1);
}

.btn-accent {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff;
  box-shadow: 0 4px 15px rgba(245,158,11,0.3);
}
.btn-accent:hover:not(:disabled) { filter: brightness(1.1); }

.btn-outline {
  background: transparent;
  color: var(--accent);
  border: 2px solid var(--accent);
}
.btn-outline:hover:not(:disabled) { background: var(--accent-light); }

.btn-danger {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #fff;
}

.btn-ghost {
  background: rgba(255,255,255,0.07);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover:not(:disabled) { background: rgba(255,255,255,0.12); }

.btn-sm {
  padding: 0.35rem 0.8rem;
  font-size: 0.85rem;
  min-height: 34px;
  width: auto;
}

/* ===== FORM ===== */
.input {
  width: 100%;
  padding: 0.7rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg-input);
  transition: border-color 0.15s, box-shadow 0.15s;
  text-align: right;
  direction: rtl;
}

.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.input::placeholder { color: #475569; }

label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.form-group { margin-bottom: 1rem; }

/* ===== HEADER ===== */
.app-header {
  text-align: center;
  padding: 1.5rem 1rem 1rem;
  border-bottom: 1px solid var(--border);
  background: rgba(0,0,0,0.2);
  position: relative;
}

.app-header h1 {
  background: linear-gradient(90deg, #67e8f9, #a78bfa, #06b6d4);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.app-header p {
  color: var(--text-muted);
  margin-top: 0.2rem;
  font-size: 0.9rem;
}

.back-link {
  position: absolute;
  top: 1rem;
  left: 1rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  transition: color 0.15s;
}
.back-link:hover { color: var(--accent); }

/* ===== SCREENS ===== */
.screen { display: none; }
.screen.active { display: block; }

/* ===== PLAYER LIST ===== */
.player-list { list-style: none; }

.player-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
}
.player-item:last-child { border-bottom: none; }

.player-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent-light);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
  border: 1px solid var(--accent-glow);
}
.player-avatar.ai { background: rgba(245,158,11,0.15); color: #fbbf24; border-color: rgba(245,158,11,0.3); }

.player-name { flex: 1; font-weight: 500; color: var(--text); }

.badge {
  font-size: 0.68rem;
  padding: 0.18rem 0.45rem;
  border-radius: 99px;
  font-weight: 600;
}
.badge-host { background: var(--accent-light); color: var(--accent); }
.badge-ai { background: rgba(245,158,11,0.15); color: #fbbf24; }

/* ===== GAME SCREEN ===== */
#screen-game .container { max-width: 700px; }

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

.letter-badge {
  font-size: 2.6rem;
  font-weight: 900;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 20px var(--accent-glow);
}

.game-info { flex: 1; }

.timer-bar-wrap {
  background: rgba(255,255,255,0.1);
  border-radius: 99px;
  height: 8px;
  overflow: hidden;
  margin-top: 0.35rem;
}

.timer-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #67e8f9);
  border-radius: 99px;
  transition: width 1s linear, background 0.5s;
}
.timer-bar.urgent { background: linear-gradient(90deg, var(--danger), #fca5a5); }

.timer-text { font-size: 1.1rem; font-weight: 700; color: var(--accent); }
.timer-text.urgent { color: var(--danger); }

/* Categories form */
.categories-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem;
}
@media (max-width: 480px) {
  .categories-grid { grid-template-columns: 1fr; }
}

.category-field label { font-size: 0.82rem; margin-bottom: 0.2rem; }

/* ===== SCORES ===== */
.score-table { width: 100%; border-collapse: collapse; }

.score-table th {
  text-align: right;
  padding: 0.45rem 0.7rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.score-table td {
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
  color: var(--text);
}

.score-table tr:last-child td { border-bottom: none; }

/* Legacy classes kept for compatibility */
.points-unique { color: var(--success); font-weight: 700; }
.points-shared { color: var(--warning); font-weight: 600; }
.points-zero   { color: #475569; }

/* New scoring tiers */
.points-15 { color: #22d3ee; font-weight: 800; }   /* sole valid answer */
.points-10 { color: var(--success); font-weight: 700; }
.points-5  { color: var(--warning); font-weight: 600; }

/* Dispute row states */
tr.word-checking td  { opacity: 0.75; }
tr.word-accepted td:nth-child(2) { color: var(--success); }
tr.word-rejected td  { color: #f87171; text-decoration: line-through; opacity: 0.6; }

/* Old disputed style still used in practice mode */
tr.disputed td {
  background: rgba(239,68,68,0.08);
  color: #f87171;
  text-decoration: line-through;
  opacity: 0.7;
}

/* Dispute proof / vote UI */
.dispute-extra-row td { padding: 0; border-bottom: none; }
.dispute-warning {
  background: rgba(245,158,11,0.1);
  border-right: 3px solid var(--warning);
  border-radius: 6px;
  padding: 0.6rem 0.75rem;
  margin: 0.3rem 0 0.5rem;
  font-size: 0.85rem;
  color: var(--text);
}
.dispute-proof-box {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.85rem;
  resize: vertical;
  min-height: 60px;
  margin-top: 0.35rem;
  direction: rtl;
}
.dispute-proof-box:focus { outline: none; border-color: var(--accent); }

.dispute-vote-btn {
  padding: 0.25rem 0.85rem;
  font-size: 0.82rem;
  border-radius: 6px;
  cursor: pointer;
  border: 1.5px solid;
  background: transparent;
  font-family: var(--font);
  font-weight: 600;
  min-height: unset;
  width: auto;
}
.dispute-vote-btn.accept { border-color: var(--success); color: var(--success); }
.dispute-vote-btn.accept:hover { background: rgba(34,197,94,0.12); }
.dispute-vote-btn.reject { border-color: var(--danger); color: var(--danger); }
.dispute-vote-btn.reject:hover { background: rgba(239,68,68,0.12); }

.dispute-flag-btn {
  opacity: 0.4;
  font-size: 0.8rem !important;
  padding: 0.15rem 0.4rem !important;
  min-height: unset !important;
  width: auto !important;
  transition: opacity 0.15s;
}
.dispute-flag-btn:hover { opacity: 1; }

/* ===== PRACTICE RESULTS ===== */
.practice-result-card {
  border-right: 4px solid var(--border);
  padding: 0.85rem 1rem;
  margin-bottom: 0.5rem;
}
.practice-result-card.result-valid   { border-color: var(--success); background: linear-gradient(145deg, #1e293b, #14532d22); }
.practice-result-card.result-unverified { border-color: var(--warning); background: linear-gradient(145deg, #1e293b, #92400e22); }
.practice-result-card.result-wrong  { border-color: var(--danger); background: linear-gradient(145deg, #1e293b, #7f1d1d22); }
.practice-result-card.result-empty  { border-color: var(--border); }

/* ===== ROOM CODE ===== */
.room-code {
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: 0.3em;
  color: var(--accent);
  text-align: center;
  background: var(--accent-light);
  border: 1px solid var(--accent-glow);
  border-radius: var(--radius-sm);
  padding: 0.7rem;
  cursor: pointer;
  transition: opacity 0.15s, box-shadow 0.15s;
  font-family: monospace;
}
.room-code:hover { box-shadow: 0 0 15px var(--accent-glow); }
.room-code:active { opacity: 0.7; }

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 50%;
  transform: translateX(50%);
  background: #1e293b;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.7rem 1.5rem;
  border-radius: var(--radius);
  font-weight: 500;
  z-index: 1000;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.2s ease;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateX(50%) translateY(16px); }
  to   { opacity: 1; transform: translateX(50%) translateY(0); }
}

/* ===== WINNER BANNER ===== */
.winner-banner { text-align: center; padding: 1.5rem 1rem; }
.winner-trophy { font-size: 3.5rem; margin-bottom: 0.4rem; }
.winner-name {
  font-size: 1.4rem;
  font-weight: 800;
  background: linear-gradient(90deg, #fbbf24, #f59e0b);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ===== DIVIDER ===== */
.divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-muted);
  font-size: 0.82rem;
  margin: 0.85rem 0;
}
.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ===== UTILITY ===== */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); font-size: 0.88rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.hidden { display: none !important; }
