:root {
  --bg: #f5f4ef;
  --panel: #ffffff;
  --panel-2: #efeee8;
  --ink: #15181c;
  --muted: #6b727a;
  --line: #d9d6cc;
  --line-strong: #b9b5a8;
  --accent: #0e5c45;
  --accent-2: #0a4433;
  --accent-ink: #ffffff;
  --danger: #9f2b22;
  --win: #12603f;
  --radius: 6px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;
}

html[data-theme="night"] {
  --bg: #0c0e10;
  --panel: #14181b;
  --panel-2: #1a1f23;
  --ink: #e7eaec;
  --muted: #8f979f;
  --line: #262c31;
  --line-strong: #39424a;
  --accent: #33bd88;
  --accent-2: #1d8f66;
  --accent-ink: #06120c;
  --danger: #e27067;
  --win: #4fd39c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
.inline { display: inline; }

.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 0 16px; height: 56px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; letter-spacing: .1em; font-size: 13px; text-transform: uppercase; }
.brand .dot { width: 9px; height: 9px; background: var(--accent); border-radius: 50%; }

.top-right { display: flex; align-items: center; gap: 8px; }

.chip {
  font-family: var(--mono); font-size: 12px; color: var(--muted);
  border: 1px solid var(--line); padding: 5px 9px; border-radius: var(--radius);
  white-space: nowrap;
}
.chip b { color: var(--ink); }

.theme-btn, .link-btn, .btn {
  font: inherit; cursor: pointer; border-radius: var(--radius);
  background: transparent; color: var(--ink);
}
.theme-btn {
  border: 1px solid var(--line); padding: 5px 10px; font-size: 12px; color: var(--muted);
}
.theme-btn:hover, .link-btn:hover { color: var(--ink); border-color: var(--line-strong); }
.link-btn { border: 0; padding: 5px 2px; font-size: 12px; color: var(--muted); text-decoration: underline; }

html[data-theme="day"] .t-night, html[data-theme="night"] .t-day { display: none; }

.tabs {
  display: flex; gap: 2px; overflow-x: auto;
  background: var(--panel); border-bottom: 1px solid var(--line);
  padding: 0 10px;
}
.tabs a {
  padding: 11px 12px; font-size: 13px; color: var(--muted);
  border-bottom: 2px solid transparent; white-space: nowrap; position: relative;
}
.tabs a.on { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.tabs a:hover { color: var(--ink); }

.dot-badge {
  position: absolute; top: 8px; right: 3px; width: 6px; height: 6px;
  background: var(--danger); border-radius: 50%;
}

.wrap { max-width: 900px; margin: 0 auto; padding: 20px 16px 64px; }

h1 { font-size: 19px; letter-spacing: -.01em; margin: 0 0 4px; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); margin: 26px 0 10px; font-weight: 600; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.small { font-size: 12px; }
.right { text-align: right; }

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px;
}
.card + .card { margin-top: 12px; }

.flash {
  border: 1px solid var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--panel));
  padding: 10px 12px; border-radius: var(--radius); margin-bottom: 14px; font-size: 14px;
}
.flash.bad { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, var(--panel)); }

.empty { color: var(--muted); border: 1px dashed var(--line); padding: 18px; text-align: center; border-radius: var(--radius); font-size: 14px; }

/* ------------- auth ------------- */
.auth { max-width: 380px; margin: 8vh auto 0; }
.auth h1 { font-size: 22px; }
.auth .switch { font-size: 13px; color: var(--muted); margin-top: 14px; }
.auth .switch a { text-decoration: underline; color: var(--ink); }

/* ------------- form ------------- */
label { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 0 0 5px; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--panel);
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  padding: 11px 12px; margin-bottom: 13px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input.mono, .amount { font-family: var(--mono); font-size: 16px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line-strong); padding: 11px 16px; font-weight: 600; font-size: 14px;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-2); }
.btn.wide { width: 100%; }
.btn.ghost { background: transparent; }
.btn.danger { border-color: var(--danger); color: var(--danger); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

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

/* ------------- sesi / angka ------------- */
.session-bar { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.session-code { font-family: var(--mono); font-size: 15px; letter-spacing: .06em; }
.timer { font-family: var(--mono); font-size: 26px; font-variant-numeric: tabular-nums; }
.timer.low { color: var(--danger); }
.bar { height: 3px; background: var(--line); margin: 10px 0 16px; }
.bar span { display: block; height: 100%; background: var(--accent); width: 100%; }

.nums { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.nums label { margin: 0; }
.nums input { display: none; }
.nums span {
  display: flex; align-items: center; justify-content: center;
  height: 58px; font-family: var(--mono); font-size: 20px; font-weight: 600;
  border: 1px solid var(--line-strong); border-radius: var(--radius); cursor: pointer;
  background: var(--panel);
}
.nums input:checked + span { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.nums input:focus-visible + span { outline: 2px solid var(--accent); }

.dirs { display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(2, 52px); gap: 8px; margin-top: 12px; }
.dirs label { margin: 0; }
.dirs input { display: none; }
.dirs span {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  border: 1px solid var(--line-strong); border-radius: var(--radius); cursor: pointer;
  font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted);
  background: var(--panel);
}
.dirs span b { font-family: var(--mono); font-size: 15px; }
.dirs input:checked + span { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.dirs .d-utara { grid-column: 2; grid-row: 1; }
.dirs .d-barat { grid-column: 1; grid-row: 2; }
.dirs .d-timur { grid-column: 3; grid-row: 2; }
.dirs .d-selatan { grid-column: 2; grid-row: 2; }

.bet-status { border-left: 3px solid var(--accent); background: var(--panel-2); padding: 12px; border-radius: var(--radius); font-size: 14px; }
.bet-status.win { border-color: var(--win); }
.bet-status.lost { border-color: var(--danger); }

.balance { display: flex; align-items: baseline; gap: 8px; }
.balance b { font-family: var(--mono); font-size: 30px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }

/* ------------- tabel ------------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 600; }
td.mono, td .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }

.badge { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; padding: 3px 7px; border-radius: 3px; border: 1px solid var(--line-strong); color: var(--muted); white-space: nowrap; }
.badge.ok { border-color: var(--win); color: var(--win); }
.badge.bad { border-color: var(--danger); color: var(--danger); }
.badge.win { border-color: var(--win); color: var(--win); }
.badge.lost { border-color: var(--danger); color: var(--danger); }

.acts { display: flex; gap: 6px; flex-wrap: wrap; }
.acts .btn { padding: 6px 10px; font-size: 12px; }

.foot {
  display: flex; justify-content: space-between; gap: 10px;
  border-top: 1px solid var(--line); padding: 12px 16px; font-size: 11px;
  color: var(--muted); text-transform: uppercase; letter-spacing: .08em;
}

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stats div { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; }
.stats b { display: block; font-family: var(--mono); font-size: 20px; }

@media (max-width: 560px) {
  input, select, textarea { font-size: 16px; padding: 12px; }
  .wrap { padding: 14px 12px 56px; }
  .nums span { height: 52px; font-size: 18px; }
  .row2 { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; }
  th:nth-child(n+4), td:nth-child(n+4) { display: none; }
  table.dense th:nth-child(n+4), table.dense td:nth-child(n+4) { display: table-cell; }
}
