/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0f1117;
  --surface:   #1a1d27;
  --surface2:  #252836;
  --border:    #2e3347;
  --accent:    #6c63ff;
  --accent2:   #4ecca3;
  --danger:    #e05252;
  --warning:   #e0a952;
  --text:      #e8eaf0;
  --text-dim:  #7b8099;
  --radius:    12px;
  --shadow:    0 4px 24px rgba(0,0,0,.4);
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.5;
  min-height: 100vh;
}

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

/* ── Typography ───────────────────────────────────────────── */
h1 { font-size: 1.6rem; font-weight: 700; color: var(--accent); }
h2 { font-size: 1.2rem; font-weight: 600; margin-bottom: .75rem; }
h3 { font-size: 1rem; font-weight: 600; }
p  { color: var(--text-dim); font-size: .9rem; }

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

/* ── Forms ────────────────────────────────────────────────── */
label { display: block; font-size: .8rem; color: var(--text-dim); margin-bottom: .3rem; font-weight: 500; }

input[type="text"],
input[type="number"],
input[type="email"] {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: .65rem .9rem;
  font-size: 1rem;
  outline: none;
  transition: border-color .2s;
  -webkit-appearance: none;
}
input:focus { border-color: var(--accent); }

.form-group { margin-bottom: .85rem; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .7rem 1.2rem;
  border: none;
  border-radius: 8px;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; pointer-events: none; }

.btn-primary   { background: var(--accent);  color: #fff; }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-success   { background: var(--accent2); color: #0f1117; }
.btn-danger    { background: var(--danger);  color: #fff; }
.btn-sm        { padding: .4rem .8rem; font-size: .82rem; }
.btn-full      { width: 100%; }
.btn-icon      { padding: .5rem .7rem; font-size: 1.1rem; }

/* ── Player Rows ──────────────────────────────────────────── */
.player-row {
  display: flex;
  align-items: center;
  gap: .6rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .6rem .9rem;
  margin-bottom: .5rem;
}
.player-row .name { flex: 1; font-weight: 600; }
.player-row .badge {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: .2rem .65rem;
  font-size: .78rem;
  color: var(--text-dim);
}
.player-row .badge.paid { border-color: var(--accent2); color: var(--accent2); }

.rebuy-ctrl { display: flex; align-items: center; gap: .4rem; }
.rebuy-ctrl span { font-weight: 700; min-width: 1.5rem; text-align: center; }

/* ── Chip input rows ──────────────────────────────────────── */
.chip-row {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .8rem;
  margin-bottom: .5rem;
}
.chip-row .row-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: .5rem; }
.chip-row .row-header .name { font-weight: 600; }
.chip-row .chip-inputs { display: flex; gap: .5rem; align-items: center; }
.chip-row .chip-inputs input { flex: 1; }
.chip-row .pre-paid-label { font-size: .8rem; color: var(--text-dim); display: flex; align-items: center; gap: .4rem; margin-top: .4rem; }
.chip-row .pre-paid-label input[type=checkbox] { width: auto; }

/* ── Settlement ───────────────────────────────────────────── */
.payment-item {
  display: flex;
  align-items: center;
  gap: .6rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .8rem 1rem;
  margin-bottom: .5rem;
  flex-wrap: wrap;
}
.payment-item.confirmed    { opacity: .5; border-color: var(--accent2); }
.payment-item.pay-recipient { border-left: 3px solid var(--accent2); }
.payment-item.pay-sender    { border-left: 3px solid var(--warning); }
.payment-item.pay-unrelated { opacity: .45; }
.payment-item .payment-text { flex: 1; min-width: 0; }
.payment-item .amount { font-size: 1.15rem; font-weight: 700; color: var(--accent2); white-space: nowrap; }
.payment-item .paypal-link { font-size: .8rem; }
.payment-item .paypal-link a { color: #009cde; text-decoration: none; }

/* ── Alerts ───────────────────────────────────────────────── */
.alert {
  padding: .75rem 1rem;
  border-radius: 8px;
  margin-bottom: .85rem;
  font-size: .9rem;
}
.alert-error   { background: rgba(224,82,82,.15);  border: 1px solid var(--danger);  color: var(--danger); }
.alert-success { background: rgba(78,204,163,.15); border: 1px solid var(--accent2); color: var(--accent2); }
.alert-info    { background: rgba(108,99,255,.12); border: 1px solid var(--accent);  color: #a09bff; }

/* ── Code / Session ID ────────────────────────────────────── */
.session-code {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: .25rem;
  color: var(--accent2);
  text-align: center;
  padding: 1rem;
  font-family: monospace;
}

/* ── Tabs ─────────────────────────────────────────────────── */
.tabs { display: flex; gap: .5rem; margin-bottom: 1rem; }
.tab-btn {
  flex: 1;
  padding: .6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface2);
  color: var(--text-dim);
  font-weight: 600;
  cursor: pointer;
  font-size: .9rem;
  transition: all .2s;
}
.tab-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ── Status indicators ────────────────────────────────────── */
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: .4rem; }
.status-dot.active   { background: var(--accent2); box-shadow: 0 0 6px var(--accent2); }
.status-dot.settled  { background: var(--text-dim); }

/* ── Misc ─────────────────────────────────────────────────── */
.divider { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.flex { display: flex; }
.gap-1 { gap: .5rem; }
.text-center { text-align: center; }
.text-dim { color: var(--text-dim); font-size: .85rem; }
.text-green { color: var(--accent2); }
.text-red   { color: var(--danger); }
.hidden { display: none !important; }

.header {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: 1.5rem;
  padding-bottom: .75rem;
  border-bottom: 1px solid var(--border);
}
.header h1 { margin: 0; }
.header .emoji { font-size: 1.8rem; }

/* ── Add-Player row ───────────────────────────────────────── */
.player-add-form { display: flex; gap: .5rem; flex-wrap: wrap; }
.player-add-form input { flex: 1; min-width: 120px; }

/* ── Net summary table ────────────────────────────────────── */
.net-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.net-table td, .net-table th { padding: .35rem .5rem; }
.net-table tr:not(:last-child) td { border-bottom: 1px solid var(--border); }
.net-table th { font-size: .75rem; color: var(--text-dim); font-weight: 500; text-align: right; padding-bottom: .5rem; border-bottom: 1px solid var(--border); }
.net-table th.name-col { text-align: left; }
.net-table .name-col { font-weight: 600; }
.net-table .amount-col { text-align: right; font-weight: 700; }

/* ── Share link ───────────────────────────────────────────── */
.share-box {
  display: flex;
  align-items: center;
  gap: .5rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .5rem .75rem;
}
.share-box input { flex: 1; background: none; border: none; color: var(--text); font-size: .85rem; }
.share-box input:focus { outline: none; }

/* ── Mobile responsive ────────────────────────────────────── */
@media (max-width: 480px) {
  h1 { font-size: 1.3rem; }
  .session-code { font-size: 2rem; }
  .payment-item { flex-direction: column; align-items: flex-start; }
}
