:root {
  color-scheme: dark;
  --bg: #07110e;
  --surface: #0d1d18;
  --surface-2: #11261f;
  --line: rgba(210, 231, 218, 0.13);
  --muted: #91a69c;
  --text: #f2f6f3;
  --lime: #b7ef6f;
  --mint: #69ddb5;
  --gold: #e7bd6b;
  --red: #ff806f;
  --blue: #78b7ff;
  --font: "IBM Plex Sans Thai", system-ui, sans-serif;
  --display: "Manrope", "IBM Plex Sans Thai", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 80% -10%, rgba(105, 221, 181, 0.13), transparent 34rem),
    radial-gradient(circle at -10% 25%, rgba(183, 239, 111, 0.06), transparent 30rem),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.5;
}

button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }

.noise {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 160 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.55'/%3E%3C/svg%3E");
}

[hidden] { display: none !important; }

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.login-card {
  width: min(100%, 470px);
  padding: 1.5rem;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: linear-gradient(145deg, rgba(17, 38, 31, 0.98), rgba(8, 22, 17, 0.98));
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.42);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 3.2rem;
  height: 3.2rem;
  margin-bottom: 1.25rem;
  border: 1px solid rgba(183, 239, 111, 0.4);
  border-radius: 13px;
  background: rgba(183, 239, 111, 0.09);
  color: var(--lime);
  font-family: var(--display);
  font-weight: 800;
  transform: rotate(-4deg);
}

.eyebrow, .section-kicker {
  margin: 0 0 0.35rem;
  color: var(--mint);
  font-family: var(--display);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.13em;
}

.login-card h1, .hero h1, .section-heading h2 { margin: 0; line-height: 1.2; }
.login-card h1 { font-size: clamp(1.75rem, 8vw, 2.35rem); }
.login-description { margin: 0.7rem 0 1.35rem; color: var(--muted); }

.login-card label {
  display: block;
  margin-bottom: 0.42rem;
  color: #c4d2cb;
  font-size: 0.8rem;
  font-weight: 600;
}

.login-row { display: grid; gap: 0.6rem; }
.login-row input, .search-box input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  background: rgba(0, 0, 0, 0.2);
  color: var(--text);
}

.login-row input { min-height: 48px; padding: 0 0.85rem; }
.login-row input:focus, .search-box input:focus { border-color: var(--mint); box-shadow: 0 0 0 3px rgba(105, 221, 181, 0.09); }
.login-row button {
  min-height: 48px;
  padding: 0 1rem;
  border: 0;
  border-radius: 10px;
  background: var(--lime);
  color: #102014;
  font-weight: 800;
}

.form-error { min-height: 1.4em; margin: 0.4rem 0 0; color: var(--red); font-size: 0.8rem; }
.login-note { margin: 1rem 0 0; color: #6f857b; font-size: 0.72rem; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 17, 14, 0.85);
  backdrop-filter: blur(18px);
}

.topbar-inner {
  width: min(100%, 1220px);
  min-height: 62px;
  margin: 0 auto;
  padding: 0 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.wordmark {
  color: var(--text);
  font-family: var(--display);
  font-weight: 800;
  text-decoration: none;
  letter-spacing: -0.04em;
}
.wordmark strong { color: var(--lime); }
.wordmark small { margin-left: 0.45rem; color: var(--muted); font-size: 0.55rem; letter-spacing: 0.13em; }
.top-actions { display: flex; align-items: center; gap: 0.45rem; }
.live-status { display: none; color: var(--muted); font-size: 0.75rem; }
.live-status i { width: 0.45rem; height: 0.45rem; border-radius: 50%; background: var(--gold); box-shadow: 0 0 10px currentColor; }
.live-status.is-live i { background: var(--mint); }
.live-status.is-error i { background: var(--red); }
.icon-button, .text-button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--text);
}
.icon-button { width: 38px; font-size: 1.3rem; }
.icon-button.is-loading { animation: spin 0.8s linear infinite; }
.text-button { padding: 0 0.75rem; color: var(--muted); }

.report-shell { width: min(100%, 1220px); margin: 0 auto; padding: 1.25rem 1rem 3rem; }
.hero { display: grid; gap: 1.5rem; padding: 2.5rem 0 3rem; }
.hero h1 { font-family: var(--display); font-size: clamp(2.15rem, 10vw, 4.75rem); letter-spacing: -0.055em; }
.hero h1 span { color: var(--lime); }
.hero-copy { max-width: 660px; margin: 1rem 0 0; color: var(--muted); font-size: 0.95rem; }

.hero-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.025);
  align-self: end;
}
.hero-meta div { min-width: 0; }
.hero-meta span { display: block; color: var(--muted); font-size: 0.68rem; }
.hero-meta strong { display: block; overflow: hidden; color: #dce9e2; font-size: 0.8rem; text-overflow: ellipsis; white-space: nowrap; }
.hero-meta a { grid-column: 1 / -1; color: var(--mint); font-size: 0.75rem; text-decoration: none; }

.section-block { padding: 2.4rem 0; border-top: 1px solid var(--line); }
.section-heading { display: grid; gap: 0.65rem; margin-bottom: 1.2rem; }
.section-heading h2 { font-size: clamp(1.5rem, 6vw, 2.25rem); }
.section-heading > p { max-width: 520px; margin: 0; color: var(--muted); font-size: 0.82rem; }

.metric-grid, .money-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.65rem; }
.metric-card, .money-card {
  min-width: 0;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.025);
}
.metric-card span, .money-card span { display: block; min-height: 2.7em; color: var(--muted); font-size: 0.72rem; }
.metric-card strong, .money-card strong {
  display: block;
  overflow: hidden;
  font-family: var(--display);
  font-size: clamp(1.55rem, 7vw, 2.5rem);
  letter-spacing: -0.055em;
  line-height: 1.1;
  text-overflow: ellipsis;
}
.metric-card small, .money-card small { display: block; margin-top: 0.25rem; color: #6e8379; font-size: 0.66rem; }
.metric-card.featured { border-color: rgba(183, 239, 111, 0.33); background: linear-gradient(145deg, rgba(183, 239, 111, 0.11), rgba(255, 255, 255, 0.02)); }
.metric-card.featured strong, .metric-card.accent strong, .money-card.bet strong { color: var(--lime); }
.metric-card.accent-two strong, .money-card.win strong { color: var(--mint); }
.money-card.loss strong { color: var(--red); }

.completion-layout { display: grid; gap: 0.65rem; }
.completion-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.completion-grid .metric-card { padding: 0.85rem; }
.completion-grid .metric-card strong { font-size: clamp(1.4rem, 6vw, 2.3rem); }

.panel {
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(13, 29, 24, 0.72);
}
.panel-title { display: flex; align-items: baseline; justify-content: space-between; gap: 0.8rem; margin-bottom: 1rem; }
.panel-title h3 { margin: 0; font-size: 1rem; }
.panel-title span { color: var(--muted); font-size: 0.65rem; text-align: right; }
.bar-list { display: grid; gap: 0.8rem; }
.bar-row-head { display: flex; justify-content: space-between; gap: 0.7rem; margin-bottom: 0.3rem; color: #cbd8d1; font-size: 0.75rem; }
.bar-row-head strong { font-family: var(--display); }
.bar-track { height: 8px; overflow: hidden; border-radius: 99px; background: rgba(255, 255, 255, 0.07); }
.bar-fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--mint), var(--lime)); transition: width 0.5s ease; }

.stage-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.55rem; }
.stage-item { padding: 0.75rem; border-radius: 10px; background: rgba(255, 255, 255, 0.035); }
.stage-item span { display: block; color: var(--muted); font-size: 0.68rem; }
.stage-item strong { font-family: var(--display); font-size: 1.45rem; }
.two-column { display: grid; gap: 0.65rem; }

.table-heading { align-items: end; }
.search-box { color: var(--muted); font-size: 0.7rem; }
.search-box input { min-height: 40px; margin-top: 0.25rem; padding: 0 0.75rem; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; background: rgba(13, 29, 24, 0.62); }
table { width: 100%; min-width: 850px; border-collapse: collapse; }
th, td { padding: 0.8rem 0.75rem; border-bottom: 1px solid rgba(210, 231, 218, 0.08); text-align: left; white-space: nowrap; }
th { position: sticky; top: 0; background: #10231d; color: var(--muted); font-size: 0.66rem; font-weight: 600; }
td { color: #dce7e1; font-size: 0.76rem; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(255, 255, 255, 0.025); }
.player-name { max-width: 145px; overflow: hidden; font-weight: 700; text-overflow: ellipsis; }
.tag { display: inline-flex; padding: 0.16rem 0.42rem; border-radius: 99px; background: rgba(105, 221, 181, 0.1); color: var(--mint); font-size: 0.62rem; }
.number-positive { color: var(--mint); }
.number-negative { color: var(--red); }
.empty-state { padding: 2rem; color: var(--muted); text-align: center; }

.activity-list { display: grid; gap: 0.5rem; }
.activity-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.7rem;
  padding: 0.8rem;
  border: 1px solid rgba(210, 231, 218, 0.08);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.018);
}
.activity-dot { width: 0.55rem; height: 0.55rem; margin-top: 0.4rem; border-radius: 50%; background: var(--blue); box-shadow: 0 0 10px rgba(120, 183, 255, 0.3); }
.activity-dot.game_finished { background: var(--gold); }
.activity-dot.final { background: var(--lime); }
.activity-main { min-width: 0; }
.activity-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.25rem 0.8rem; }
.activity-head strong { font-size: 0.78rem; }
.activity-head time { color: var(--muted); font-size: 0.66rem; }
.activity-detail { margin: 0.18rem 0 0; overflow: hidden; color: #8fa49a; font-size: 0.68rem; text-overflow: ellipsis; white-space: nowrap; }

.source-grid { display: grid; gap: 0.6rem; }
.source-card { padding: 0.9rem; border: 1px solid var(--line); border-radius: 11px; background: rgba(255, 255, 255, 0.022); }
.source-card-head { display: flex; justify-content: space-between; gap: 0.75rem; }
.source-card strong { font-size: 0.82rem; }
.source-card p { margin: 0.35rem 0 0; overflow: hidden; color: var(--muted); font-size: 0.68rem; text-overflow: ellipsis; white-space: nowrap; }
.source-state { color: var(--mint); font-size: 0.65rem; }
.source-state.error { color: var(--red); }

footer { display: flex; flex-direction: column; gap: 0.15rem; padding-top: 2rem; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.7rem; }
footer strong { color: #cbd8d1; font-family: var(--display); }

.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 30;
  max-width: calc(100vw - 2rem);
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #142820;
  color: var(--text);
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.35);
  font-size: 0.76rem;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: 0.2s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }

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

@media (min-width: 520px) {
  .login-row { grid-template-columns: 1fr auto; }
  .login-row button { padding-inline: 1.25rem; }
  .live-status { display: inline-flex; align-items: center; gap: 0.4rem; }
  .source-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (min-width: 760px) {
  .report-shell { padding-inline: 1.5rem; }
  .hero { grid-template-columns: minmax(0, 1.5fr) minmax(260px, 0.6fr); align-items: end; padding: 4.5rem 0 5rem; }
  .section-heading { grid-template-columns: minmax(0, 1fr) minmax(260px, 0.55fr); align-items: end; }
  .metric-grid.traffic-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .metric-card, .money-card { padding: 1.2rem; }
  .metric-card span, .money-card span { min-height: auto; }
  .money-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .money-card.bet { grid-column: span 2; }
  .completion-layout { grid-template-columns: minmax(0, 0.9fr) minmax(340px, 1.1fr); }
  .two-column { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .table-heading { grid-template-columns: 1fr 230px; }
  .activity-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  footer { flex-direction: row; justify-content: space-between; }
}

@media (min-width: 1100px) {
  .report-shell { padding-inline: 2rem; }
  .money-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); }
  .money-card.bet { grid-column: span 2; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
