:root {
  --eid-green: #1B5E20;
  --eid-green-light: #4CAF50;
  --eid-gold: #FFD700;
  --eid-gold-dark: #B8860B;
  --eid-dark: #0D1117;
  --eid-bg: #F5F0E8;
  --eid-card: #FFFFFF;
  --eid-text: #1a1a2e;
  --eid-correct: #2E7D32;
  --eid-wrong: #C62828;
  --eid-nuke: #4A0000;
}

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

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, var(--eid-bg) 0%, #E8F5E9 100%);
  color: var(--eid-text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* RTL Support */
[dir="rtl"] { direction: rtl; text-align: right; }
[dir="rtl"] .text-left { text-align: right; }
[dir="rtl"] .ml-2 { margin-left: 0; margin-right: 0.5rem; }
[dir="rtl"] .mr-2 { margin-right: 0; margin-left: 0.5rem; }

/* Top bar */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 1rem;
  background: var(--eid-green);
  color: white;
  position: sticky;
  top: 0;
  z-index: 100;
}

.top-bar button {
  background: rgba(255,255,255,0.2);
  border: none;
  color: white;
  padding: 0.4rem 0.8rem;
  border-radius: 0.5rem;
  cursor: pointer;
  font-size: 0.85rem;
}

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

.container.wide {
  max-width: 1000px;
}

/* Cards */
.card {
  background: var(--eid-card);
  border-radius: 1rem;
  padding: 1.5rem;
  margin-bottom: 1rem;
  box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}

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

/* Landing page */
.landing {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
  text-align: center;
  gap: 1.5rem;
}

.landing h1 {
  font-size: 2.5rem;
  color: var(--eid-green);
  margin-bottom: 0.5rem;
}

.landing .subtitle {
  color: var(--eid-gold-dark);
  font-size: 1.2rem;
  margin-bottom: 1rem;
}

.landing .eid-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 1rem 2rem;
  border: none;
  border-radius: 0.75rem;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  width: 100%;
  max-width: 300px;
}

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

.btn-primary {
  background: var(--eid-green);
  color: white;
}
.btn-primary:hover:not(:disabled) { background: #2E7D32; }

.btn-secondary {
  background: var(--eid-gold);
  color: var(--eid-dark);
}
.btn-secondary:hover:not(:disabled) { background: var(--eid-gold-dark); color: white; }

.btn-danger {
  background: var(--eid-wrong);
  color: white;
}

.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  max-width: none;
  width: auto;
}

/* Form inputs */
.input {
  width: 100%;
  padding: 0.875rem 1rem;
  border: 2px solid #E0E0E0;
  border-radius: 0.75rem;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}
.input:focus { border-color: var(--eid-green); }

/* Modal overlay */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1rem;
}

.modal {
  background: white;
  border-radius: 1rem;
  padding: 2rem;
  width: 100%;
  max-width: 400px;
  animation: fadeIn 0.2s ease;
}

.modal h2 { margin-bottom: 1rem; color: var(--eid-green); }
.modal .input { margin-bottom: 1rem; }

/* Timer bar */
.timer-bar-container {
  width: 100%;
  height: 8px;
  background: #E0E0E0;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 1rem;
}

.timer-bar {
  height: 100%;
  background: var(--eid-green-light);
  border-radius: 4px;
  transition: width 1s linear;
}

.timer-bar.warning { background: #FF9800; }
.timer-bar.danger { background: var(--eid-wrong); }

.timer-text {
  text-align: center;
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--eid-green);
  margin-bottom: 0.5rem;
}

.timer-text.warning { color: #FF9800; }
.timer-text.danger { color: var(--eid-wrong); }

/* Answer buttons */
.answers-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-top: 1rem;
}

.answer-btn {
  min-height: 70px;
  padding: 1rem;
  border: 3px solid #E0E0E0;
  border-radius: 1rem;
  background: white;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  word-wrap: break-word;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

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

.answer-btn.selected {
  border-color: #1976D2;
  background: #E3F2FD;
  color: #1976D2;
}

.answer-btn.correct {
  border-color: var(--eid-correct);
  background: #E8F5E9;
  color: var(--eid-correct);
  animation: pulse 0.5s ease;
}

.answer-btn.wrong {
  border-color: var(--eid-wrong);
  background: #FFEBEE;
  color: var(--eid-wrong);
  animation: shake 0.5s ease;
}

.answer-btn.nuke {
  border-color: var(--eid-nuke);
  background: #1a0000;
  color: #ff4444;
  animation: shake 0.8s ease;
}

/* Answer colors */
.answer-btn:nth-child(1) { border-color: #E53935; }
.answer-btn:nth-child(1):hover:not(:disabled) { background: #FFEBEE; }
.answer-btn:nth-child(2) { border-color: #1E88E5; }
.answer-btn:nth-child(2):hover:not(:disabled) { background: #E3F2FD; }
.answer-btn:nth-child(3) { border-color: #FDD835; }
.answer-btn:nth-child(3):hover:not(:disabled) { background: #FFFDE7; }
.answer-btn:nth-child(4) { border-color: #43A047; }
.answer-btn:nth-child(4):hover:not(:disabled) { background: #E8F5E9; }

/* Question text */
.question-text {
  font-size: 1.3rem;
  font-weight: 600;
  text-align: center;
  padding: 1rem 0;
  line-height: 1.5;
}

.question-number {
  text-align: center;
  color: #888;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

/* Points feedback */
.points-feedback {
  text-align: center;
  font-size: 2rem;
  font-weight: bold;
  padding: 1rem;
  animation: slideUp 0.3s ease;
}

.points-feedback.positive { color: var(--eid-correct); }
.points-feedback.negative { color: var(--eid-wrong); }
.points-feedback.nuke { color: var(--eid-nuke); font-size: 3rem; }

/* Leaderboard */
.leaderboard {
  list-style: none;
  padding: 0;
}

.leaderboard-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #F0F0F0;
  animation: slideUp 0.3s ease;
}

.leaderboard-item:last-child { border-bottom: none; }

.leaderboard-rank {
  font-weight: bold;
  width: 2rem;
  color: #888;
}

.leaderboard-name {
  flex: 1;
  font-weight: 500;
}

.leaderboard-score {
  font-weight: bold;
  color: var(--eid-green);
}

.leaderboard-item.nuked .leaderboard-score {
  color: var(--eid-wrong);
}

.leaderboard-item.top-1 { background: linear-gradient(90deg, rgba(255,215,0,0.15), transparent); }
.leaderboard-item.top-2 { background: linear-gradient(90deg, rgba(192,192,192,0.15), transparent); }
.leaderboard-item.top-3 { background: linear-gradient(90deg, rgba(205,127,50,0.15), transparent); }

/* Podium */
.podium {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 0.5rem;
  padding: 2rem 0;
}

.podium-place {
  text-align: center;
  border-radius: 1rem 1rem 0 0;
  padding: 1rem 1.5rem;
  min-width: 100px;
}

.podium-place.first {
  background: linear-gradient(180deg, #FFD700, #FFA000);
  min-height: 160px;
  order: 2;
}

.podium-place.second {
  background: linear-gradient(180deg, #C0C0C0, #9E9E9E);
  min-height: 120px;
  order: 1;
}

.podium-place.third {
  background: linear-gradient(180deg, #CD7F32, #8B5E3C);
  min-height: 90px;
  order: 3;
}

.podium-name {
  font-weight: bold;
  font-size: 1rem;
  color: white;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.podium-score {
  font-size: 0.85rem;
  color: rgba(255,255,255,0.9);
}

.podium-prize {
  font-weight: bold;
  font-size: 1.1rem;
  color: white;
  margin-top: 0.5rem;
}

.podium-emoji {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

/* Shame wall */
.shame-wall {
  text-align: center;
  padding: 1rem;
  background: #FFF3E0;
  border-radius: 1rem;
  margin-top: 1rem;
}

.shame-wall h3 { color: var(--eid-wrong); margin-bottom: 0.75rem; }

.shame-item {
  display: inline-block;
  padding: 0.5rem 1rem;
  margin: 0.25rem;
  background: white;
  border-radius: 0.5rem;
  font-weight: 500;
}

/* Lobby */
.player-list {
  list-style: none;
  padding: 0;
}

.player-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #F0F0F0;
}

.player-item .status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 0.5rem;
  display: inline-block;
}

.status-dot.online { background: var(--eid-green-light); }
.status-dot.offline { background: #BDBDBD; }

/* Waiting animation */
.waiting {
  text-align: center;
  padding: 2rem;
  color: #888;
}

.waiting-dots::after {
  content: '';
  animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
  0% { content: ''; }
  25% { content: '.'; }
  50% { content: '..'; }
  75% { content: '...'; }
}

/* Game Master tabs */
.tabs {
  display: flex;
  border-bottom: 2px solid #E0E0E0;
  margin-bottom: 1rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tab {
  padding: 0.75rem 1.25rem;
  border: none;
  background: none;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  color: #888;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
}

.tab.active {
  color: var(--eid-green);
  border-bottom-color: var(--eid-green);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* Question editor */
.question-card {
  background: #FAFAFA;
  border: 1px solid #E0E0E0;
  border-radius: 0.75rem;
  padding: 1rem;
  margin-bottom: 0.75rem;
}

.question-card .question-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.answer-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.5rem;
}

.answer-row input[type="text"] {
  flex: 1;
}

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

/* Player management table */
.player-table {
  width: 100%;
  border-collapse: collapse;
}

.player-table th, .player-table td {
  padding: 0.5rem;
  text-align: left;
  border-bottom: 1px solid #E0E0E0;
}

.player-table th {
  font-weight: 600;
  color: #888;
  font-size: 0.85rem;
}

/* Score adjustment */
.score-adjust {
  display: flex;
  gap: 0.25rem;
  align-items: center;
}

.score-adjust input {
  width: 60px;
  padding: 0.25rem;
  text-align: center;
  border: 1px solid #DDD;
  border-radius: 0.25rem;
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

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

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 50%, 90% { transform: translateX(-5px); }
  30%, 70% { transform: translateX(5px); }
}

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

/* Responsive */
@media (max-width: 480px) {
  .answers-grid { grid-template-columns: 1fr; }
  .podium-place { min-width: 80px; padding: 0.75rem 1rem; }
  .question-text { font-size: 1.1rem; }
  .container { padding: 0.5rem; }
  .landing h1 { font-size: 2rem; }
}

/* Master controls */
.game-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.game-controls .btn { width: auto; flex: 1; min-width: 120px; }

/* Toast notifications */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--eid-dark);
  color: white;
  padding: 0.75rem 1.5rem;
  border-radius: 0.75rem;
  z-index: 300;
  animation: slideUp 0.3s ease;
  font-size: 0.9rem;
}

.toast.error { background: var(--eid-wrong); }
.toast.success { background: var(--eid-correct); }

/* Footer */
.site-footer {
  text-align: center;
  padding: 1.5rem 1rem;
  margin-top: 2rem;
  opacity: 0.5;
  transition: opacity 0.3s;
}
.site-footer:hover { opacity: 0.8; }
.site-footer img {
  height: 40px;
  width: auto;
  filter: grayscale(100%);
}
