:root {
  --primary: #D97706;
  --primary-hover: #B45309;
  --primary-light: rgba(217, 119, 6, 0.15);
  --accent: #EA580C;
  --accent-glow: rgba(234, 88, 12, 0.35);
  --bg-dark: #0B0F19;
  --bg-card: #131B2E;
  --bg-card-hover: #1E293B;
  --bg-input: #0F172A;
  --border: rgba(255, 255, 255, 0.08);
  --border-active: rgba(217, 119, 6, 0.5);
  --text-main: #F8FAFC;
  --text-muted: #94A3B8;
  --success: #10B981;
  --success-bg: rgba(16, 185, 129, 0.15);
  --error: #EF4444;
  --error-bg: rgba(239, 68, 68, 0.15);
  --warning: #F59E0B;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
}

[data-theme="light"] {
  --bg-dark: #F8FAFC;
  --bg-card: #FFFFFF;
  --bg-card-hover: #F1F5F9;
  --bg-input: #F1F5F9;
  --border: rgba(0, 0, 0, 0.08);
  --border-active: rgba(217, 119, 6, 0.6);
  --text-main: #0F172A;
  --text-muted: #64748B;
  --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Navbar */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  background: rgba(19, 27, 46, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--text-main);
  font-weight: 700;
  font-size: 1.25rem;
}

.brand-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 15px var(--accent-glow);
  font-size: 1.2rem;
}

.nav-links {
  display: flex;
  gap: 0.5rem;
}

.nav-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.95rem;
}

.nav-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-main);
}

.nav-btn.active {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--border-active);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.icon-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-main);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.icon-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--primary);
}

/* User Fruit Tag in Nav */
.user-fruit-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border-active);
  padding: 0.35rem 0.85rem;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: 0 0 10px rgba(217, 119, 6, 0.2);
}

/* Main Container */
.main-container {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
}

/* Views */
.view {
  display: none;
  animation: fadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.view.active {
  display: block;
}

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

/* Lobby View */
.hero-card {
  background: linear-gradient(135deg, rgba(217, 119, 6, 0.12), rgba(19, 27, 46, 0.95));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  text-align: center;
  margin-bottom: 2rem;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.hero-card::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, var(--accent-glow) 0%, transparent 60%);
  opacity: 0.15;
  pointer-events: none;
}

.hero-title {
  font-size: 2.4rem;
  font-weight: 800;
  margin-bottom: 0.75rem;
  background: linear-gradient(90deg, #F8FAFC, #F59E0B, #EA580C);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-subtitle {
  color: var(--text-muted);
  font-size: 1.1rem;
  max-width: 650px;
  margin: 0 auto 1.75rem auto;
  line-height: 1.6;
}

.join-panel {
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.input-group {
  display: flex;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.35rem 0.5rem;
}

.input-group:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

.text-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-main);
  padding: 0.75rem 1rem;
  font-size: 1rem;
  outline: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #FFFFFF;
  border: none;
  padding: 0.85rem 1.5rem;
  border-radius: var(--radius-md);
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  box-shadow: 0 4px 15px var(--accent-glow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px var(--accent-glow);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border);
  padding: 0.85rem 1.5rem;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--primary);
}

/* Arena Grid */
.arena-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 1.5rem;
}

@media (max-width: 860px) {
  .arena-grid {
    grid-template-columns: 1fr;
  }
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-size: 1.2rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Fruit Players Grid in Lobby */
.players-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
  max-height: 380px;
  overflow-y: auto;
  padding-right: 0.5rem;
}

.player-card {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  position: relative;
  transition: transform 0.2s, border-color 0.2s;
}

.player-card:hover {
  transform: translateY(-3px);
  border-color: var(--primary);
}

.player-card.self {
  border-color: var(--primary);
  background: var(--primary-light);
}

.player-avatar {
  font-size: 2.2rem;
  margin-bottom: 0.5rem;
}

.player-name {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 0.2rem;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.player-region {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.player-badge {
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  border-radius: 12px;
  font-weight: 600;
}

.badge-host {
  background: #F59E0B;
  color: #000;
}

.badge-ready {
  background: var(--success);
  color: #fff;
}

/* Question Screen */
.question-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.question-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.tag {
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.tag-foundations { background: rgba(59, 130, 246, 0.2); color: #60A5FA; border: 1px solid rgba(59, 130, 246, 0.4); }
.tag-intermediate { background: rgba(245, 158, 11, 0.2); color: #FBBF24; border: 1px solid rgba(245, 158, 11, 0.4); }
.tag-professional { background: rgba(239, 68, 68, 0.2); color: #F87171; border: 1px solid rgba(239, 68, 68, 0.4); }

.tag-domain {
  background: var(--bg-input);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

/* Circular Timer */
.timer-container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.circular-timer {
  position: relative;
  width: 56px;
  height: 56px;
}

.circular-timer svg {
  transform: rotate(-90deg);
  width: 56px;
  height: 56px;
}

.circular-timer circle {
  fill: none;
  stroke-width: 4;
}

.timer-bg {
  stroke: rgba(255, 255, 255, 0.1);
}

.timer-progress {
  stroke: var(--primary);
  stroke-linecap: round;
  transition: stroke-dashoffset 1s linear, stroke 0.3s ease;
}

.timer-urgent {
  stroke: var(--error) !important;
  filter: drop-shadow(0 0 6px rgba(239, 68, 68, 0.6));
}

.timer-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-weight: 800;
  font-size: 1.1rem;
}

/* Question Content */
.scenario-box {
  background: rgba(217, 119, 6, 0.06);
  border-left: 4px solid var(--primary);
  padding: 1rem 1.25rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin-bottom: 1.25rem;
  color: var(--text-main);
  line-height: 1.6;
  font-size: 0.95rem;
}

.scenario-title {
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 0.3rem;
}

.question-text {
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.5;
  margin-bottom: 1.5rem;
}

/* Hint Button & Card */
.hint-container {
  margin-bottom: 1.5rem;
}

.hint-btn {
  background: rgba(245, 158, 11, 0.15);
  color: #FBBF24;
  border: 1px dashed rgba(245, 158, 11, 0.5);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.2s;
}

.hint-btn:hover {
  background: rgba(245, 158, 11, 0.25);
  border-color: #FBBF24;
}

.hint-card {
  display: none;
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-top: 0.75rem;
  color: #FDE68A;
  font-size: 0.95rem;
  line-height: 1.5;
  animation: fadeIn 0.3s;
}

/* Options Grid */
.options-grid {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-bottom: 1.5rem;
}

.option-card {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.1rem 1.25rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: all 0.2s;
  position: relative;
  text-align: left;
}

.option-card:hover:not(.locked) {
  border-color: var(--primary);
  background: var(--bg-card-hover);
  transform: translateX(4px);
}

.option-card.selected {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: 0 0 15px rgba(217, 119, 6, 0.2);
}

.option-card.correct {
  border-color: var(--success) !important;
  background: var(--success-bg) !important;
  box-shadow: 0 0 15px rgba(16, 185, 129, 0.3);
}

.option-card.incorrect {
  border-color: var(--error) !important;
  background: var(--error-bg) !important;
  box-shadow: 0 0 15px rgba(239, 68, 68, 0.3);
}

.option-letter {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
  flex-shrink: 0;
}

.option-card.selected .option-letter {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.option-text {
  font-size: 1rem;
  line-height: 1.45;
  color: var(--text-main);
}

/* Privacy Answered Presence Strip */
.presence-strip {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  padding: 0.75rem 1rem;
  background: var(--bg-input);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.presence-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-right: 0.5rem;
}

.presence-fruit {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.85rem;
  padding: 0.25rem 0.6rem;
  border-radius: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
}

.presence-fruit.answered {
  border-color: var(--success);
  background: var(--success-bg);
}

/* Rationale Reveal Box */
.rationale-box {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-top: 1.5rem;
  animation: fadeIn 0.4s;
}

.rationale-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 0.75rem;
  font-size: 1.05rem;
}

.rationale-text {
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--text-main);
}

/* Podium & Winner Ceremony */
.winner-ceremony {
  text-align: center;
  padding: 2.5rem 1.5rem;
}

.winner-crown {
  font-size: 4rem;
  margin-bottom: 0.5rem;
  animation: bounce 1.5s infinite alternate;
}

@keyframes bounce {
  from { transform: translateY(0); }
  to { transform: translateY(-10px); }
}

.winner-name {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
  color: var(--primary);
}

.podium-container {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 1.5rem;
  margin: 2.5rem 0;
  flex-wrap: wrap;
}

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

.podium-avatar {
  font-size: 3rem;
  margin-bottom: 0.5rem;
}

.podium-player-name {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 0.25rem;
}

.podium-score {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.podium-bar {
  width: 100%;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 800;
  color: #fff;
}

.podium-1 .podium-bar { height: 160px; background: linear-gradient(180deg, #F59E0B, #B45309); box-shadow: 0 0 20px rgba(245, 158, 11, 0.4); }
.podium-2 .podium-bar { height: 120px; background: linear-gradient(180deg, #94A3B8, #475569); }
.podium-3 .podium-bar { height: 90px; background: linear-gradient(180deg, #B45309, #78350F); }

/* Question Bank View */
.filter-bar {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.select-input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  outline: none;
}

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

.questions-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.question-item-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  cursor: pointer;
  transition: all 0.2s;
}

.question-item-card:hover {
  border-color: var(--primary);
  background: var(--bg-card-hover);
}

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

.question-item-title {
  font-weight: 700;
  font-size: 1.05rem;
}

.question-item-body {
  display: none;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.question-item-card.expanded .question-item-body {
  display: block;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

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

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  max-width: 650px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 2rem;
  box-shadow: var(--shadow);
  position: relative;
}

.modal-close {
  position: absolute;
  top: 1.25rem;
  right: 1.25rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
}

/* Footer */
.footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
  margin-top: auto;
}
