/* ── MADX Clash — Styles ────────────────────────────────────────────────────── */

:root {
  --bg: #080c14;
  --bg-panel: #131c2e;
  --bg-panel2: #1a2540;
  --border: rgba(200,146,42,0.15);
  --border2: rgba(200,146,42,0.25);
  --gold: #c8922a;
  --gold-dim: rgba(200,146,42,0.45);
  --text: #94a3b8;
  --text-bright: #e2ddd5;
  --text-dim: #64748b;
  --success: #4dc44d;
  --error: #e74c3c;
  --info: #4a9eff;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  overflow: hidden;
}

/* ── Topbar ────────────────────────────────────────────────────────────────── */
.clash-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 48px;
  padding: 0 20px;
  background: var(--bg-panel);
  border-bottom: 1px solid rgba(200,146,42,0.2);
  flex-shrink: 0;
}

.clash-logo {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-bright);
  text-decoration: none;
  letter-spacing: 0.5px;
}

.clash-logo .logo-accent {
  color: var(--gold);
}

.clash-topbar-right a {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 12px;
  transition: color 0.2s;
}

.clash-topbar-right a:hover {
  color: var(--text);
}

/* ── Layout ────────────────────────────────────────────────────────────────── */
#clash-app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.clash-screen {
  display: none;
  flex: 1;
  overflow-y: auto;
}

.clash-screen.active {
  display: flex;
  flex-direction: column;
}

/* ── Login Screen ──────────────────────────────────────────────────────────── */
#login-screen {
  align-items: center;
  justify-content: center;
}

.login-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.login-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-bright);
  text-align: center;
}

.login-subtitle {
  font-size: 13px;
  color: var(--text-dim);
  text-align: center;
  margin-top: -12px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 12px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-group input {
  background: var(--bg);
  border: 1px solid var(--border2);
  border-radius: 6px;
  color: var(--text-bright);
  font-size: 14px;
  padding: 10px 14px;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
}

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

.btn-primary {
  background: var(--gold);
  color: #1a1400;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 700;
  padding: 12px;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
  font-family: inherit;
}

.btn-primary:hover {
  opacity: 0.9;
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border2);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  padding: 10px;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
  font-family: inherit;
}

.btn-secondary:hover {
  border-color: var(--text);
  color: var(--text-bright);
}

.login-error {
  color: var(--error);
  font-size: 13px;
  text-align: center;
  min-height: 18px;
}

/* ── Lobby Screen ──────────────────────────────────────────────────────────── */
#lobby-screen {
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.lobby-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.lobby-header {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.lobby-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-bright);
}

.lobby-balance {
  font-size: 13px;
  color: var(--text-dim);
}

.lobby-balance span {
  color: var(--gold);
  font-weight: 600;
}

.lobby-section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-dim);
  margin-bottom: -10px;
}

.stake-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stake-btn {
  background: var(--bg);
  border: 1px solid var(--border2);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  padding: 12px;
  cursor: pointer;
  transition: all 0.18s;
  font-family: inherit;
  text-align: center;
}

.stake-btn:hover {
  border-color: var(--gold-dim);
  color: var(--text-bright);
}

.stake-btn.selected {
  border-color: var(--gold);
  background: rgba(200,146,42, 0.08);
  color: var(--gold);
}

.lobby-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Waiting spinner */
.waiting-area {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 10px 0;
}

.waiting-area.active {
  display: flex;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border2);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.waiting-text {
  font-size: 13px;
  color: var(--text-dim);
  text-align: center;
}

/* How to play */
.how-to-play {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
}

.how-to-play h4 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-dim);
  margin-bottom: 10px;
}

.how-to-play ol {
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.how-to-play li {
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
}

.lobby-error {
  color: var(--error);
  font-size: 13px;
  text-align: center;
  min-height: 18px;
}

/* ── Game Screen ───────────────────────────────────────────────────────────── */
#game-screen {
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.game-layout {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

/* Opponent area — top ~40% */
.opp-area {
  flex: 0 0 40%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
}

.opp-label {
  font-size: 12px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.opp-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-bright);
}

.opp-hand {
  display: flex;
  flex-direction: row;
  gap: 8px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}

.played-card-area {
  min-height: 110px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.played-label {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.played-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

/* Center status bar — ~10% */
.center-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 20px;
  background: var(--bg-panel2);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  gap: 10px;
  min-height: 64px;
}

.center-bar-side {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex: 1;
}

.pips {
  display: flex;
  gap: 6px;
}

.pip {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--border2);
  background: transparent;
  transition: background 0.3s, border-color 0.3s;
}

.pip.filled {
  background: var(--gold);
  border-color: var(--gold);
}

.player-name-bar {
  font-size: 12px;
  color: var(--text-dim);
}

.center-bar-middle {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
}

.round-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-dim);
}

.vs-divider {
  font-size: 20px;
  font-weight: 800;
  color: var(--gold-dim);
}

.game-status-msg {
  font-size: 13px;
  color: var(--text);
  text-align: center;
  min-height: 18px;
}

/* My area — ~50% */
.my-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px;
}

.my-hand {
  display: flex;
  flex-direction: row;
  gap: 8px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}

.my-label {
  font-size: 12px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ── Cards ─────────────────────────────────────────────────────────────────── */
.clash-card {
  width: 70px;
  height: 100px;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.18s, box-shadow 0.18s, border-color 0.18s, opacity 0.18s;
  position: relative;
  user-select: none;
  flex-shrink: 0;
  border: 2px solid transparent;
}

/* Card face */
.card-face {
  width: 100%;
  height: 100%;
  border-radius: 6px;
  background: #f8f4e8;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 4px 5px;
  overflow: hidden;
}

.card-top {
  align-self: flex-start;
  font-weight: 700;
  font-size: 14px;
  line-height: 1;
}

.card-suit {
  font-size: 28px;
  line-height: 1;
}

.card-bottom {
  align-self: flex-end;
  font-weight: 700;
  font-size: 14px;
  line-height: 1;
  transform: rotate(180deg);
}

.red-card {
  color: #cc2222;
}

.black-card {
  color: #1a1a1a;
}

/* Card back */
.card-back {
  width: 100%;
  height: 100%;
  border-radius: 6px;
  background: linear-gradient(135deg, #2a1a3a 0%, #1a0f2a 50%, #2a1a3a 100%);
  border: 2px solid #4a3060;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

/* States */
.clash-card:hover:not(.locked):not(.dimmed) {
  transform: translateY(-10px);
  box-shadow: 0 8px 24px rgba(200,146,42, 0.35);
  border-color: var(--gold-dim);
}

.clash-card.selected {
  transform: translateY(-15px);
  box-shadow: 0 10px 30px rgba(200,146,42, 0.55);
  border-color: var(--gold);
}

.clash-card.locked {
  transform: translateY(-15px);
  box-shadow: 0 10px 30px rgba(200,146,42, 0.4);
  border-color: var(--gold);
  cursor: default;
}

.clash-card.dimmed {
  opacity: 0.3;
  pointer-events: none;
}

.clash-card.winner-card {
  box-shadow: 0 6px 24px rgba(77, 196, 77, 0.6);
  border-color: var(--success) !important;
}

.clash-card.loser-card {
  opacity: 0.5;
  box-shadow: 0 4px 12px rgba(231, 76, 60, 0.4);
  border-color: var(--error) !important;
}

/* Opponent played indicator */
.opp-played-indicator {
  font-size: 12px;
  color: var(--info);
  font-style: italic;
  min-height: 16px;
}

/* ── Result Screen ─────────────────────────────────────────────────────────── */
#result-screen {
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.result-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px 32px;
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  text-align: center;
}

.result-icon {
  font-size: 56px;
}

.result-title {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: 2px;
}

.result-win {
  color: var(--gold);
}

.result-loss {
  color: var(--error);
}

.result-draw {
  color: var(--info);
}

.result-amount {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-bright);
}

.result-amount.positive {
  color: var(--success);
}

.result-amount.negative {
  color: var(--error);
}

.result-scores {
  font-size: 14px;
  color: var(--text-dim);
}

.result-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-height: 700px) {
  .clash-card {
    width: 56px;
    height: 80px;
  }
  .card-suit {
    font-size: 22px;
  }
  .card-top, .card-bottom {
    font-size: 12px;
  }
  .opp-area {
    flex: 0 0 38%;
  }
}

@media (max-width: 420px) {
  .clash-card {
    width: 58px;
    height: 84px;
  }
  .my-hand, .opp-hand {
    gap: 5px;
  }
  .lobby-card, .login-card, .result-card {
    padding: 24px 18px;
  }
}
