:root {
  --bg: #06070b;
  --bg-elevated: rgba(15, 18, 26, 0.88);
  --bg-elevated-strong: rgba(24, 29, 40, 0.96);
  --panel-border: rgba(255, 255, 255, 0.08);
  --panel-border-strong: rgba(151, 164, 255, 0.22);
  --text: #f5f7fb;
  --muted: #9fa9bc;
  --accent: #8ea0ff;
  --accent-strong: #c7a76b;
  --danger: #ff6b7f;
  --success: #66d3a6;
  --warning: #f8c56a;
  --chart-positive: rgba(102, 211, 166, 0.9);
  --chart-negative: rgba(255, 107, 127, 0.9);
  --shadow: 0 30px 70px rgba(0, 0, 0, 0.48);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(142, 160, 255, 0.2), transparent 28%),
    radial-gradient(circle at top right, rgba(199, 167, 107, 0.14), transparent 24%),
    linear-gradient(180deg, #0b0d13 0%, #06070b 45%, #030406 100%);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

.backdrop {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(120deg, rgba(255, 255, 255, 0.018), transparent 22%, transparent 78%, rgba(255, 255, 255, 0.018)),
    radial-gradient(circle at 50% 0%, rgba(142, 160, 255, 0.08), transparent 40%);
}

.app-shell {
  position: relative;
  width: min(1440px, calc(100% - 32px));
  margin: 24px auto 32px;
  display: grid;
  gap: 24px;
}

.public-shell {
  width: min(1180px, calc(100% - 32px));
}

.panel {
  background: linear-gradient(180deg, rgba(19, 23, 32, 0.92), rgba(10, 12, 18, 0.92));
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.hero {
  padding: 28px;
  display: block;
  overflow: hidden;
  position: relative;
}

.hero-content {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.74rem;
  color: var(--accent-strong);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2.4rem, 5vw, 4.3rem);
  line-height: 0.95;
}

h2 {
  font-size: 1.35rem;
}

.hero-copy,
.helper,
.chart-meta,
.game-notes,
.entry-meta {
  color: var(--muted);
  line-height: 1.5;
}

.hero-stats {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-self: stretch;
}

.stat-card {
  padding: 18px;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.01));
  min-width: 0;
  min-height: 100%;
}

.stat-label {
  color: var(--muted);
  font-size: 0.84rem;
  margin-bottom: 8px;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
}

.stat-person-name {
  display: block;
  overflow-wrap: anywhere;
  margin-bottom: 6px;
}

.stat-person-amount {
  display: block;
  white-space: nowrap;
}

.stat-amount-positive {
  color: var(--chart-positive);
}

.stat-amount-negative {
  color: var(--chart-negative);
}

.workspace {
  display: grid;
  gap: 24px;
  width: 100%;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  align-items: start;
}

.admin-workspace {
  grid-template-columns: minmax(320px, 520px) minmax(0, 1fr);
}

.control-column,
.main-column {
  display: grid;
  gap: 24px;
  min-width: 0;
}

.public-main .panel {
  padding: 24px;
}

.control-column .panel,
.main-column .panel {
  padding: 24px;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  margin-bottom: 18px;
}

.stack-form,
.field-grid,
.field {
  display: grid;
  gap: 14px;
}

.field label {
  font-size: 0.92rem;
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  background: var(--bg-elevated-strong);
  color: var(--text);
  padding: 13px 14px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(142, 160, 255, 0.6);
  box-shadow: 0 0 0 4px rgba(142, 160, 255, 0.14);
}

textarea {
  resize: vertical;
  min-height: 96px;
}

.button-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.button {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  cursor: pointer;
  transition: transform 0.14s ease, opacity 0.2s ease, background 0.2s ease;
  font-weight: 600;
}

.button:hover {
  opacity: 0.96;
}

.button:active {
  transform: translateY(1px);
}

.button-primary {
  background: linear-gradient(135deg, #eef1ff 0%, #93a4ff 10%, #6479ff 100%);
  color: #050814;
}

.button-secondary {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.button-danger {
  background: rgba(255, 107, 127, 0.13);
  color: #ffc0ca;
  border: 1px solid rgba(255, 107, 127, 0.24);
}

.file-button {
  position: relative;
  overflow: hidden;
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.status {
  min-height: 1.2rem;
  color: var(--muted);
  font-size: 0.94rem;
  margin-top: 10px;
}

.status.error {
  color: var(--danger);
}

.status.success {
  color: var(--success);
}

.list-block,
.history-grid {
  display: grid;
  gap: 12px;
}

.player-card,
.history-card {
  padding: 16px;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.025), rgba(255, 255, 255, 0.01));
}

.player-card {
  display: grid;
  gap: 12px;
}

.player-row,
.history-top,
.totals {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.player-actions,
.history-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.button-micro {
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 0.84rem;
}

.table-shell {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.02);
}

.admin-workspace .table-shell {
  overflow-x: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
}

.admin-workspace table {
  table-layout: fixed;
}

th,
td {
  padding: 12px 10px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.admin-workspace th,
.admin-workspace td {
  padding: 10px 8px;
}

.admin-workspace th:first-child,
.admin-workspace td:first-child {
  width: 52px;
}

.admin-workspace th:nth-child(2),
.admin-workspace td:nth-child(2) {
  width: 24%;
}

.admin-workspace th:nth-child(3),
.admin-workspace td:nth-child(3),
.admin-workspace th:nth-child(4),
.admin-workspace td:nth-child(4) {
  width: 24%;
}

.admin-workspace th:nth-child(5),
.admin-workspace td:nth-child(5) {
  width: 18%;
}

th {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 600;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.currency-cell.positive,
.metric-positive {
  color: var(--success);
}

.currency-cell.negative,
.metric-negative {
  color: var(--danger);
}

.currency-input {
  min-width: 120px;
}

.admin-workspace .currency-input {
  min-width: 0;
  width: 100%;
  padding: 10px 10px;
}

.admin-workspace .currency-cell {
  font-size: 0.92rem;
}

.checkbox-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.checkbox-wrap input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.totals {
  margin-top: 6px;
  padding: 14px 16px;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.03);
}

.chart-card {
  min-height: 300px;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.015)),
    rgba(4, 6, 10, 0.6);
  padding: 16px;
}

.chart-tall {
  min-height: 340px;
}

.legend {
  margin-top: 14px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 0.88rem;
}

.legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.empty-state {
  min-height: 160px;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
  border: 1px dashed rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.history-card {
  display: grid;
  gap: 14px;
}

.history-title {
  font-size: 1.05rem;
  font-weight: 700;
}

.history-gridline {
  display: grid;
  gap: 10px;
}

.history-entry {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
}

.metric-pill {
  display: inline-grid;
  gap: 2px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  line-height: 1.2;
}

.metric-pill-label {
  color: var(--muted);
  font-size: 0.8rem;
}

.metric-pill-value {
  font-weight: 600;
  white-space: nowrap;
}

.hidden {
  display: none !important;
}

svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.axis-label,
.axis-value,
.chart-label {
  fill: var(--muted);
  font-size: 12px;
}

.grid-line {
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 1;
}

.line-path {
  fill: none;
  stroke-width: 3;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.zero-line {
  stroke: rgba(199, 167, 107, 0.45);
  stroke-width: 1.5;
  stroke-dasharray: 4 4;
}

.bar-positive {
  fill: var(--chart-positive);
}

.bar-negative {
  fill: var(--chart-negative);
}

@media (max-width: 1100px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .hero-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 20px, 1440px);
    margin: 10px auto 20px;
  }

  .control-column .panel,
  .main-column .panel,
  .hero {
    padding: 18px;
  }

  .hero-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .chart-card {
    min-height: 240px;
    padding: 10px;
  }

  .chart-tall {
    min-height: 280px;
  }

  .axis-label,
  .axis-value,
  .chart-label {
    font-size: 14px;
  }

  .section-heading,
  .player-row,
  .history-top,
  .totals {
    display: grid;
  }

  .admin-workspace .table-shell {
    overflow-x: auto;
  }

  .admin-workspace table {
    table-layout: auto;
  }

  .admin-workspace th,
  .admin-workspace td {
    width: auto;
  }
}

@media (max-width: 520px) {
  .hero-stats {
    grid-template-columns: 1fr;
  }

  .chart-card {
    min-height: 220px;
    padding: 8px;
  }

  .chart-tall {
    min-height: 250px;
  }
}
