/* ── RESET & BASE ─────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #0b1a10;
  --bg2: rgba(15, 34, 23, 0.7);
  --bg3: rgba(21, 45, 30, 0.8);
  --felt: #173623;
  --border: rgba(180,150,60,0.18);
  --border2: rgba(180,150,60,0.35);
  --gold: #c9a84c;
  --gold2: #e8c97a;
  --gold3: #f5e0a0;
  --text: #f0ead8;
  --text2: #a89f82;
  --text3: #6b6450;
  --red: #c0392b;
  --red2: #e74c3c;
  --red-bg: rgba(192,57,43,0.12);
  --green: #27ae60;
  --green2: #2ecc71;
  --green-bg: rgba(39,174,96,0.12);
  --radius: 16px;
  --radius-sm: 8px;
  --shadow: 0 8px 40px rgba(0,0,0,0.6);
  --blur: blur(14px);
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', sans-serif;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── NOISE TEXTURE ─────────────────────────────── */
body::before {
  content: '';
  position: fixed; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none; z-index: 0; opacity: 0.6;
}

body::after {
  content: '';
  position: fixed; inset: 0;
  background-image:
    repeating-linear-gradient(45deg, transparent, transparent 40px, rgba(201,168,76,0.018) 40px, rgba(201,168,76,0.018) 41px),
    repeating-linear-gradient(-45deg, transparent, transparent 40px, rgba(201,168,76,0.018) 40px, rgba(201,168,76,0.018) 41px);
  pointer-events: none; z-index: 0;
}

/* ── LAYOUT ────────────────────────────────────── */
#root { position: relative; z-index: 1; max-width: 720px; margin: 0 auto; padding: 0 16px 80px; }

/* ── HEADER / NAV ──────────────────────────────── */
header {
  padding: 36px 0 24px;
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  margin-bottom: 28px;
  animation: fadeDown 0.5s ease both;
}
.logo { font-family: 'Playfair Display', serif; font-size: 32px; font-weight: 700; color: var(--gold2); line-height: 1; text-shadow: 0 2px 20px rgba(201,168,76,0.4); }
.logo span { color: var(--gold); opacity: 0.5; font-size: 22px; margin: 0 4px; }
.logo-sub { font-family: 'DM Mono', monospace; font-size: 10px; letter-spacing: 0.22em; color: var(--text3); text-transform: uppercase; margin-top: 4px; }
.nav-links { display: flex; gap: 4px; }
.nav-link {
  padding: 8px 16px; font-family: 'DM Mono', monospace; font-size: 11px;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--text3);
  text-decoration: none; border-radius: var(--radius-sm);
  transition: all 0.2s; border: 1px solid transparent;
}
.nav-link:hover { color: var(--gold2); background: rgba(201,168,76,0.06); }
.nav-link.active { color: var(--gold2); border-color: var(--border2); background: rgba(201,168,76,0.08); }

/* ── PANELS ────────────────────────────────────── */
.panel {
  background: var(--bg2); backdrop-filter: var(--blur);
  border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; box-shadow: 0 8px 32px rgba(0,0,0,0.3);
  margin-bottom: 20px;
}
.panel-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(23, 54, 35, 0.5);
}
.panel-title { font-family: 'Playfair Display', serif; font-size: 16px; font-weight: 600; color: var(--gold2); }
.panel-body { padding: 20px; }

/* ── BUTTONS ───────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 10px 20px; font-family: 'DM Sans', sans-serif;
  font-size: 13px; font-weight: 500; border-radius: var(--radius-sm);
  border: 1px solid var(--border2); background: rgba(255,255,255,0.02);
  backdrop-filter: var(--blur); color: var(--text2); cursor: pointer;
  transition: all 0.25s; letter-spacing: 0.02em;
}
.btn:hover { border-color: var(--gold); color: var(--gold2); background: rgba(201,168,76,0.08); }
.btn:active { transform: scale(0.95); }

.btn-gold {
  background: linear-gradient(135deg, #c9a84c, #e8c97a 50%, #c9a84c);
  background-size: 200% auto; border: none;
  color: #1a1000; font-weight: 600;
  box-shadow: 0 4px 20px rgba(201,168,76,0.35);
}
.btn-gold:hover { background-position: right center; box-shadow: 0 6px 28px rgba(201,168,76,0.5); transform: translateY(-1px); }
.btn-gold:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; }

/* ── FORM ELEMENTS ─────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.form-group:last-child { margin-bottom: 0; }
.form-label { font-family: 'DM Mono', monospace; font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--text3); }
input[type=text], input[type=number], select {
  background: rgba(21,45,30,0.6); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 11px 14px;
  font-family: 'DM Sans', sans-serif; font-size: 14px;
  color: var(--text); width: 100%; transition: all 0.2s; outline: none;
}
input::placeholder { color: var(--text3); }
input:focus, select:focus { border-color: var(--gold); box-shadow: 0 0 12px rgba(201,168,76,0.12); }

.input-with-btn { display: flex; gap: 8px; }
.input-with-btn input { flex: 1; }
.input-with-btn .btn { white-space: nowrap; padding: 10px 18px; }

/* ── PLAYER CARD (Session) ─────────────────────── */
.player-card {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid rgba(180,150,60,0.1);
  animation: slideIn 0.3s ease both;
  transition: background 0.15s;
}
.player-card:last-child { border-bottom: none; }
.player-card:hover { background: rgba(201,168,76,0.03); }

.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Playfair Display', serif; font-size: 14px; font-weight: 700;
  flex-shrink: 0; border: 1.5px solid rgba(255,255,255,0.12);
  box-shadow: inset 0 2px 4px rgba(255,255,255,0.08);
}
.player-info { flex: 1; min-width: 0; }
.player-name { font-family: 'Playfair Display', serif; font-size: 15px; font-weight: 600; color: var(--text); }
.player-amount { font-family: 'DM Mono', monospace; font-size: 12px; color: var(--text2); margin-top: 2px; }

/* ── COUNTER BUTTONS ───────────────────────────── */
.counter-group { display: flex; align-items: center; gap: 6px; }
.btn-counter {
  width: 38px; height: 38px; border-radius: 50%;
  border: 1.5px solid var(--border2); background: rgba(255,255,255,0.03);
  color: var(--gold2); font-size: 20px; font-weight: 600;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all 0.2s; font-family: 'DM Sans', sans-serif;
  -webkit-tap-highlight-color: transparent;
}
.btn-counter:hover { border-color: var(--gold); background: rgba(201,168,76,0.1); box-shadow: 0 0 12px rgba(201,168,76,0.2); transform: scale(1.1); }
.btn-counter:active { transform: scale(0.9); }
.btn-counter:disabled { opacity: 0.25; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-counter.btn-minus { color: var(--red2); border-color: rgba(192,57,43,0.3); }
.btn-counter.btn-minus:hover { border-color: var(--red2); background: rgba(192,57,43,0.1); box-shadow: 0 0 12px rgba(231,76,60,0.2); }
.buyin-count {
  font-family: 'Playfair Display', serif; font-size: 22px; font-weight: 700;
  color: var(--gold2); min-width: 32px; text-align: center;
  text-shadow: 0 0 10px rgba(201,168,76,0.3);
}

.btn-remove {
  width: 28px; height: 28px; border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.08); background: transparent;
  color: var(--text3); font-size: 14px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s; margin-left: 8px;
}
.btn-remove:hover { border-color: var(--red2); color: var(--red2); background: var(--red-bg); }

/* ── POT DISPLAY ───────────────────────────────── */
.pot-total {
  font-family: 'DM Mono', monospace; font-size: 13px; font-weight: 500;
  color: var(--gold); letter-spacing: 0.06em;
  padding: 4px 12px; border: 1px solid var(--border2); border-radius: 99px;
  background: rgba(201,168,76,0.06);
}

/* ── END SESSION BUTTON ────────────────────────── */
.btn-end-session {
  width: 100%; justify-content: center; padding: 16px;
  font-size: 15px; border-radius: var(--radius);
  margin-top: 8px;
}

/* ── EMPTY STATE ───────────────────────────────── */
.empty-state { text-align: center; padding: 48px 20px; color: var(--text3); }
.empty-suits { font-size: 36px; opacity: 0.2; letter-spacing: 8px; margin-bottom: 12px; }
.empty-msg { font-family: 'Playfair Display', serif; font-size: 16px; color: var(--text2); margin-bottom: 6px; }
.empty-hint { font-size: 12px; color: var(--text3); }

/* ── MODAL ─────────────────────────────────────── */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.65);
  backdrop-filter: blur(6px); z-index: 200;
  display: none; align-items: center; justify-content: center; padding: 16px;
}
.overlay.open { display: flex; }
.modal {
  background: var(--bg2); backdrop-filter: var(--blur);
  border: 1px solid var(--border2); border-radius: var(--radius);
  width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.7);
  animation: popIn 0.3s cubic-bezier(0.34,1.56,0.64,1) both;
}
.modal-header {
  padding: 20px 24px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; background: var(--bg2); z-index: 2;
}
.modal-title { font-family: 'Playfair Display', serif; font-size: 18px; font-weight: 700; color: var(--gold2); }
.modal-close {
  width: 32px; height: 32px; border: 1px solid var(--border);
  background: transparent; border-radius: var(--radius-sm);
  color: var(--text3); cursor: pointer; font-size: 16px;
  display: flex; align-items: center; justify-content: center; transition: all 0.2s;
}
.modal-close:hover { border-color: var(--red2); color: var(--red2); background: var(--red-bg); transform: rotate(90deg); }
.modal-body { padding: 20px 24px; }
.modal-footer {
  padding: 16px 24px; display: flex; gap: 10px; justify-content: flex-end;
  border-top: 1px solid var(--border);
  position: sticky; bottom: 0; background: var(--bg2); z-index: 2;
}

/* ── SETTLEMENT STYLES ─────────────────────────── */
.settle-section-title {
  font-family: 'DM Mono', monospace; font-size: 10px;
  letter-spacing: 0.15em; text-transform: uppercase;
  color: var(--text3); margin-bottom: 12px; margin-top: 20px;
}
.settle-section-title:first-child { margin-top: 0; }

.settle-player-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid rgba(180,150,60,0.08);
}
.settle-player-row:last-child { border-bottom: none; }
.settle-name { flex: 1; font-size: 14px; font-weight: 500; }
.settle-bought { font-family: 'DM Mono', monospace; font-size: 11px; color: var(--text3); margin-right: 10px; }
.settle-input { width: 80px; text-align: center; padding: 8px; font-size: 14px; }

.settle-validation {
  font-family: 'DM Mono', monospace; font-size: 12px; padding: 10px 14px;
  border-radius: var(--radius-sm); margin-top: 12px; text-align: center;
}
.settle-validation.valid { background: var(--green-bg); color: var(--green2); border: 1px solid rgba(39,174,96,0.3); }
.settle-validation.invalid { background: var(--red-bg); color: var(--red2); border: 1px solid rgba(192,57,43,0.3); }

.result-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0; border-bottom: 1px solid rgba(180,150,60,0.06);
  font-size: 13px;
}
.result-row:last-child { border-bottom: none; }
.result-profit { font-family: 'DM Mono', monospace; font-weight: 500; font-size: 14px; }
.result-profit.up { color: var(--green2); }
.result-profit.down { color: var(--red2); }
.result-profit.even { color: var(--text3); }

.transfer-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  background: rgba(201,168,76,0.04); border: 1px solid var(--border);
  border-radius: var(--radius-sm); margin-bottom: 8px;
  font-size: 13px;
}
.transfer-arrow { color: var(--gold); font-size: 16px; }
.transfer-amount { font-family: 'DM Mono', monospace; font-weight: 600; color: var(--gold2); margin-left: auto; }

/* ── FILTER TABS (Leaderboard) ─────────────────── */
.filter-tabs {
  display: flex; gap: 4px; margin-bottom: 24px;
  padding: 4px; background: rgba(15,34,23,0.5);
  border-radius: var(--radius-sm); border: 1px solid var(--border);
}
.filter-tab {
  flex: 1; padding: 10px 12px; font-family: 'DM Mono', monospace;
  font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text3); cursor: pointer; text-align: center;
  border-radius: 6px; transition: all 0.2s; background: transparent; border: none;
}
.filter-tab:hover { color: var(--text2); }
.filter-tab.active { color: var(--gold2); background: rgba(201,168,76,0.12); box-shadow: 0 2px 8px rgba(0,0,0,0.2); }

/* ── LEADERBOARD TABLE ─────────────────────────── */
.lb-table { width: 100%; border-collapse: collapse; }
.lb-head th {
  font-family: 'DM Mono', monospace; font-size: 10px;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--text3);
  padding: 10px 14px; text-align: left;
  border-bottom: 1px solid var(--border); font-weight: 400;
}
.lb-row {
  border-bottom: 1px solid rgba(180,150,60,0.08);
  transition: all 0.15s; animation: slideIn 0.3s ease both;
}
.lb-row:last-child { border-bottom: none; }
.lb-row:hover { background: rgba(201,168,76,0.05); }
.lb-row td { padding: 14px; vertical-align: middle; }

.rank { font-family: 'Playfair Display', serif; font-size: 18px; font-weight: 700; color: var(--text3); }
.rank.gold { color: var(--gold2); text-shadow: 0 0 12px rgba(201,168,76,0.5); }
.rank.silver { color: #ccc; }
.rank.bronze { color: #cd7f32; }

.lb-name { font-family: 'Playfair Display', serif; font-size: 14px; font-weight: 600; }
.lb-meta { font-family: 'DM Mono', monospace; font-size: 10px; color: var(--text3); margin-top: 2px; }
.lb-profit { font-family: 'DM Mono', monospace; font-size: 14px; font-weight: 600; text-align: right; }
.lb-profit.up { color: var(--green2); }
.lb-profit.down { color: var(--red2); }
.lb-stat { font-family: 'DM Mono', monospace; font-size: 12px; color: var(--text2); }

/* ── RECENT SESSIONS (Leaderboard) ─────────────── */
.session-card {
  padding: 14px 18px; border-bottom: 1px solid rgba(180,150,60,0.08);
  animation: slideIn 0.3s ease both;
}
.session-card:last-child { border-bottom: none; }
.session-date { font-family: 'DM Mono', monospace; font-size: 10px; color: var(--text3); letter-spacing: 0.1em; }
.session-meta { font-size: 12px; color: var(--text2); margin-top: 4px; }
.session-players { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 8px; }
.session-player-chip {
  font-family: 'DM Mono', monospace; font-size: 11px; padding: 3px 10px;
  border-radius: 99px; border: 1px solid var(--border);
}
.session-player-chip.up { color: var(--green2); border-color: rgba(39,174,96,0.3); background: var(--green-bg); }
.session-player-chip.down { color: var(--red2); border-color: rgba(192,57,43,0.3); background: var(--red-bg); }
.session-player-chip.even { color: var(--text3); }

/* ── TOAST ─────────────────────────────────────── */
#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(10px);
  background: rgba(21,45,30,0.95); backdrop-filter: var(--blur);
  border: 1px solid var(--gold); border-radius: var(--radius);
  padding: 12px 24px; font-size: 13px; color: var(--gold2);
  font-family: 'DM Mono', monospace; z-index: 999;
  opacity: 0; transition: all 0.3s; pointer-events: none;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5); max-width: 90vw; text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── ANIMATIONS ────────────────────────────────── */
@keyframes fadeDown { from { opacity: 0; transform: translateY(-14px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideIn { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: translateX(0); } }
@keyframes popIn { from { opacity: 0; transform: scale(0.92) translateY(8px); } to { opacity: 1; transform: scale(1) translateY(0); } }

/* ── RESPONSIVE ────────────────────────────────── */
@media (max-width: 520px) {
  .logo { font-size: 26px; }
  .player-card { padding: 12px 14px; gap: 10px; }
  .btn-counter { width: 36px; height: 36px; font-size: 18px; }
  .buyin-count { font-size: 20px; min-width: 28px; }
  .avatar { width: 36px; height: 36px; font-size: 13px; }
  .lb-head th:nth-child(4), .lb-row td:nth-child(4) { display: none; }
  .filter-tab { font-size: 10px; padding: 8px 6px; }
}

/* ── SCROLLBAR ─────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold); }
