/* Odds Mountain — Dark Poker Lounge Theme */

:root {
  --bg: #0a1a0a;
  --bg-felt: #0d1f0d;
  --card-bg: #1a1a2e;
  --card-border: #c4a44a;
  --card-glow: rgba(196, 164, 74, 0.4);
  --gold: #c4a44a;
  --gold-light: #e0c96a;
  --text: #f0f0f0;
  --text-dim: #8a8a9a;
  --text-muted: #5a5a6a;
  --red: #d44;
  --green: #4a4;
  --correct-bg: rgba(196, 164, 74, 0.15);
  --incorrect-bg: rgba(204, 68, 68, 0.15);
}

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

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

body {
  background-image:
    radial-gradient(ellipse at 50% 30%, rgba(20, 60, 20, 0.3) 0%, transparent 70%),
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 2px,
      rgba(255,255,255,0.008) 2px,
      rgba(255,255,255,0.008) 4px
    );
  background-color: var(--bg);
}

/* ========== SCREENS ========== */

.screen {
  display: none;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  padding: 2rem 1rem;
}

.screen.active {
  display: flex;
}

/* ========== TITLE / MENU SCREEN ========== */

#menu-screen {
  justify-content: center;
  gap: 2rem;
}

.title {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 3rem;
  font-weight: bold;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  text-shadow:
    0 0 20px rgba(196, 164, 74, 0.3),
    0 2px 4px rgba(0,0,0,0.5);
  text-align: center;
}

.subtitle {
  font-size: 0.95rem;
  color: var(--text-dim);
  text-align: center;
  margin-top: -0.5rem;
}

.login-form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  width: 100%;
  max-width: 320px;
}

.login-form input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--text-muted);
  border-radius: 8px;
  background: rgba(26, 26, 46, 0.8);
  color: var(--text);
  font-size: 1rem;
  text-align: center;
  outline: none;
  transition: border-color 0.2s;
}

.login-form input:focus {
  border-color: var(--gold);
}

.login-form input::placeholder {
  color: var(--text-muted);
}

/* ========== BUTTONS ========== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 2rem;
  border: 2px solid var(--gold);
  border-radius: 8px;
  background: transparent;
  color: var(--gold);
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: all 0.2s;
  text-transform: uppercase;
  min-width: 160px;
}

.btn:hover {
  background: var(--gold);
  color: var(--bg);
  box-shadow: 0 0 20px var(--card-glow);
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.4;
  cursor: default;
  pointer-events: none;
}

.btn-small {
  padding: 0.5rem 1.2rem;
  font-size: 0.85rem;
  min-width: auto;
}

.btn-danger {
  border-color: var(--red);
  color: var(--red);
}

.btn-danger:hover {
  background: var(--red);
  color: white;
  box-shadow: 0 0 20px rgba(204, 68, 68, 0.4);
}

/* ========== GAME SCREEN ========== */

#game-screen {
  padding-top: 1rem;
  gap: 1rem;
}

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 480px;
  padding: 0 0.5rem;
}

.game-header .level {
  font-family: Georgia, serif;
  font-size: 1.1rem;
  color: var(--gold);
}

.game-header .score {
  font-size: 0.95rem;
  color: var(--text-dim);
}

.game-header .elo {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.game-instructions {
  font-size: 0.85rem;
  color: var(--text-dim);
  text-align: center;
  max-width: 400px;
  line-height: 1.4;
}

.game-instructions .arrow {
  color: var(--gold);
  font-size: 1.1rem;
}

/* ========== CARD LADDER ========== */

.card-ladder {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  max-width: 480px;
  padding: 1rem 0;
  position: relative;
}

.ladder-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  padding: 0 0.5rem;
  pointer-events: none; /* Labels are never interactive */
}

.ladder-label.top {
  margin-bottom: 0.25rem;
}

.ladder-label.bottom {
  margin-top: 0.25rem;
}

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

/* ========== CARDS ========== */

.card {
  display: flex;
  align-items: center;
  padding: 0.7rem 1rem;
  background: var(--card-bg);
  border: 1.5px solid rgba(196, 164, 74, 0.3);
  border-radius: 8px;
  cursor: grab;
  user-select: none;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s, opacity 0.15s;
  position: relative;
  min-height: 52px;
}

.card:hover {
  border-color: var(--gold);
  box-shadow: 0 0 12px var(--card-glow);
  transform: translateX(2px);
}

.card:active {
  cursor: grabbing;
}

.card .card-cat {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: rgba(255,255,255,0.06);
  padding: 2px 6px;
  border-radius: 3px;
  margin-right: 0.75rem;
  flex-shrink: 0;
  min-width: 52px;
  text-align: center;
}

.card .card-text {
  font-size: 0.9rem;
  color: var(--text);
  flex: 1;
  line-height: 1.3;
}

.card .card-handle {
  color: var(--text-muted);
  font-size: 1rem;
  margin-left: 0.5rem;
  opacity: 0.5;
  flex-shrink: 0;
}

/* Card states */
.card.dragging {
  opacity: 0.2;
  border-style: dashed;
  border-color: var(--gold);
  background: transparent;
}

.card.locked {
  opacity: 0.6;
  border-color: rgba(196, 164, 74, 0.12);
  cursor: default;
}

.card.locked:hover {
  border-color: rgba(196, 164, 74, 0.12);
  box-shadow: none;
  transform: none;
}

.card.locked .card-handle {
  display: none;
}

.card.locked .card-check {
  color: var(--gold);
  margin-left: 0.5rem;
  font-size: 0.8rem;
  opacity: 0.6;
}

.card.correct-flash {
  animation: correctFlash 0.6s ease;
}

.card.incorrect-flash {
  animation: incorrectFlash 0.6s ease;
  border-color: var(--red) !important;
}

.card.highlight-misplaced {
  border-color: var(--red);
  background: var(--incorrect-bg);
  box-shadow: 0 0 15px rgba(204, 68, 68, 0.3);
}

.card.highlight-correct-pos {
  border-color: var(--gold);
  background: var(--correct-bg);
  box-shadow: 0 0 15px var(--card-glow);
}

.card.new-card {
  animation: slideIn 0.4s ease;
}

/* Ghost card during drag */
.card-ghost {
  border: 1.5px solid var(--gold);
  background: var(--card-bg);
  border-radius: 8px;
  box-shadow:
    0 8px 32px rgba(0,0,0,0.6),
    0 0 20px var(--card-glow),
    0 0 0 1px var(--gold);
  opacity: 0.95;
  transform: scale(1.03);
}

@keyframes correctFlash {
  0% { background: var(--card-bg); }
  50% { background: var(--correct-bg); border-color: var(--gold); }
  100% { background: var(--card-bg); }
}

@keyframes incorrectFlash {
  0% { background: var(--card-bg); }
  50% { background: var(--incorrect-bg); }
  100% { background: var(--card-bg); }
}

@keyframes slideIn {
  0% { opacity: 0; transform: translateX(-20px); }
  100% { opacity: 1; transform: translateX(0); }
}

/* ========== GAME ACTIONS ========== */

.game-actions {
  display: flex;
  gap: 1rem;
  margin-top: 0.5rem;
}

/* ========== RESULT SCREEN ========== */

#result-screen {
  justify-content: center;
  gap: 1.5rem;
}

.result-title {
  font-family: Georgia, serif;
  font-size: 2rem;
  text-align: center;
}

.result-title.win {
  color: var(--gold);
  text-shadow: 0 0 20px rgba(196, 164, 74, 0.3);
}

.result-title.lose {
  color: var(--red);
}

.result-details {
  text-align: center;
  line-height: 1.6;
  color: var(--text-dim);
  max-width: 400px;
}

.result-details .stat-line {
  display: flex;
  justify-content: space-between;
  padding: 0.3rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.result-details .stat-line .label {
  color: var(--text-muted);
}

.result-details .stat-line .value {
  color: var(--text);
  font-weight: 600;
}

.result-explanation {
  max-width: 420px;
  text-align: center;
  padding: 1rem;
  background: rgba(26, 26, 46, 0.6);
  border: 1px solid rgba(196, 164, 74, 0.2);
  border-radius: 8px;
}

.result-explanation .misplaced-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.result-explanation .comparison {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: center;
}

.result-explanation .comparison .arrow-label {
  font-size: 0.75rem;
  color: var(--gold);
}

.mini-card {
  display: inline-block;
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  font-size: 0.85rem;
  white-space: nowrap;
}

.mini-card.misplaced {
  background: var(--incorrect-bg);
  border: 1px solid var(--red);
  color: var(--red);
}

.mini-card.correct {
  background: var(--correct-bg);
  border: 1px solid var(--gold);
  color: var(--gold);
}

.mini-card .pct {
  font-weight: 600;
  margin-left: 0.5rem;
}

/* ========== WIN SCREEN ========== */

#win-screen {
  justify-content: center;
  gap: 2rem;
}

.trophy {
  font-size: 4rem;
  text-shadow: 0 0 30px rgba(196, 164, 74, 0.5);
}

.win-stats {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  text-align: center;
}

.win-stats .big-score {
  font-family: Georgia, serif;
  font-size: 2.5rem;
  color: var(--gold);
}

.win-actions {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
}

/* ========== LEADERBOARD ========== */

#leaderboard-screen {
  gap: 1.5rem;
  padding-top: 2rem;
}

.leaderboard-table {
  width: 100%;
  max-width: 420px;
  border-collapse: collapse;
}

.leaderboard-table th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 0.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  text-align: left;
}

.leaderboard-table td {
  padding: 0.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  font-size: 0.9rem;
}

.leaderboard-table tr:nth-child(-n+3) td:first-child {
  color: var(--gold);
  font-weight: 600;
}

.leaderboard-table .elo-col {
  text-align: right;
  font-weight: 600;
}

.leaderboard-empty {
  color: var(--text-muted);
  font-style: italic;
  padding: 2rem;
  text-align: center;
}

/* ========== RESPONSIVE ========== */

@media (max-width: 520px) {
  .title {
    font-size: 2.2rem;
  }

  .card {
    padding: 0.6rem 0.75rem;
  }

  .card .card-cat {
    display: none;
  }

  .card .card-text {
    font-size: 0.82rem;
  }

  .game-header {
    flex-wrap: wrap;
    gap: 0.25rem;
  }
}

/* ========== UTILITY ========== */

.hidden {
  display: none !important;
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }

.fade-in {
  animation: fadeIn 0.3s ease;
}

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

/* Progress bar for level */
.level-progress {
  width: 100%;
  max-width: 480px;
  height: 4px;
  background: rgba(255,255,255,0.06);
  border-radius: 2px;
  overflow: hidden;
}

.level-progress .fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold), var(--gold-light));
  border-radius: 2px;
  transition: width 0.4s ease;
}
