:root {
  color-scheme: light dark;
  --bg: #f5f7fb;
  --panel: rgba(255, 255, 255, 0.92);
  --panel-solid: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --line: rgba(17, 24, 39, 0.1);
  --soft: rgba(15, 23, 42, 0.06);
  --accent: #0a84ff;
  --accent-strong: #006adc;
  --green: #16a34a;
  --red: #e11d48;
  --orange: #f59e0b;
  --blue-soft: #e8f2ff;
  --shadow: 0 18px 48px rgba(15, 23, 42, 0.1);
  --shadow-soft: 0 10px 30px rgba(15, 23, 42, 0.07);
  --radius: 22px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #090b10;
    --panel: rgba(22, 26, 34, 0.9);
    --panel-solid: #161a22;
    --text: #f8fafc;
    --muted: #9ca3af;
    --line: rgba(255, 255, 255, 0.12);
    --soft: rgba(255, 255, 255, 0.08);
    --accent: #0a84ff;
    --accent-strong: #409cff;
    --blue-soft: rgba(10, 132, 255, 0.18);
    --shadow: 0 18px 52px rgba(0, 0, 0, 0.32);
    --shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.22);
  }
}

[hidden] {
  display: none !important;
}

* {
  box-sizing: border-box;
}

html {
  width: 100%;
  min-height: 100%;
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 20% 0%, rgba(10, 132, 255, 0.08), transparent 28rem),
    linear-gradient(180deg, rgba(255, 255, 255, 0.28), transparent 18rem),
    var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

body[data-view="login"] {
  overflow-x: hidden;
  overflow-y: auto;
}

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

button {
  border: 0;
  cursor: pointer;
  transition: transform 0.16s ease, background-color 0.16s ease, box-shadow 0.16s ease, opacity 0.16s ease;
}

button:active {
  transform: scale(0.98);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.is-busy button {
  pointer-events: none;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel-solid);
  color: var(--text);
  font-size: 16px;
  line-height: 1.25;
  padding: 11px 13px;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease;
}

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

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(10, 132, 255, 0.72);
  box-shadow: 0 0 0 4px rgba(10, 132, 255, 0.15);
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

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

.login-view {
  display: grid;
  min-height: 100vh;
  min-height: 100svh;
  align-items: start;
  justify-items: center;
  padding: calc(44px + env(safe-area-inset-top)) 20px calc(22px + env(safe-area-inset-bottom));
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.52), rgba(255, 255, 255, 0)),
    var(--bg);
}

.login-stack {
  display: grid;
  width: min(420px, 100%);
  min-height: calc(100svh - 66px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  grid-template-rows: auto 1fr;
  gap: 18px;
}

.login-card {
  position: relative;
  overflow: hidden;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 32px 28px 28px;
  text-align: center;
  backdrop-filter: blur(24px);
}

.login-card::before {
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background: linear-gradient(90deg, var(--red), var(--accent), var(--green));
  content: "";
}

.login-icon {
  width: 82px;
  height: 82px;
  border-radius: 22px;
  margin-bottom: 18px;
  box-shadow: 0 12px 26px rgba(15, 23, 42, 0.12);
}

.eyebrow {
  color: var(--accent);
  font-size: 13px;
  font-weight: 760;
}

.login-card h1 {
  margin-top: 7px;
  font-size: 30px;
  letter-spacing: 0;
}

.muted {
  color: var(--muted);
}

.login-form {
  display: grid;
  gap: 15px;
  margin-top: 24px;
  text-align: left;
}

.login-form input {
  min-height: 48px;
  border-radius: 16px;
}

.login-footer {
  align-self: end;
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  text-align: center;
}

.login-footer strong {
  color: var(--text);
  font-size: 13px;
}

.app-shell {
  width: 100%;
  max-width: 100vw;
  min-height: 100vh;
  overflow-x: hidden;
  padding-bottom: calc(80px + env(safe-area-inset-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(22px);
}

.brand {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.brand img {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.12);
}

.brand strong {
  display: block;
  font-size: 18px;
  line-height: 1.1;
}

.brand span {
  display: block;
  max-width: 45vw;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-actions {
  display: flex;
  flex: none;
  min-width: 0;
  align-items: center;
  gap: 8px;
}

.page-host {
  width: min(1040px, 100%);
  max-width: 100vw;
  margin: 0 auto;
  padding: 16px;
  animation: page-in 0.22s ease both;
}

.page {
  display: grid;
  gap: 16px;
}

@keyframes page-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hero-card,
.card,
.stat-card,
.list-card,
.form-card {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(18px);
}

.hero-card {
  display: grid;
  gap: 16px;
  border-radius: 28px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent) 10%, transparent), transparent 44%),
    var(--panel);
  padding: 20px;
}

.hero-title {
  display: flex;
  min-width: 0;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.hero-title > div,
.list-top > div,
.section-title > h2 {
  min-width: 0;
}

.hero-title h1 {
  font-size: 28px;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.card,
.form-card,
.list-card {
  border-radius: var(--radius);
  padding: 16px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-title h2 {
  font-size: 18px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.stat-card {
  min-height: 104px;
  border-radius: 20px;
  background: color-mix(in srgb, var(--panel-solid) 82%, transparent);
  padding: 14px;
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.stat-card strong {
  display: block;
  margin-top: 8px;
  font-size: 25px;
  line-height: 1.12;
  overflow-wrap: anywhere;
}

.stat-card small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
}

.number-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.ball {
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  background: var(--soft);
  color: var(--text);
  font-size: 14px;
  font-weight: 760;
}

.ball.front {
  background: rgba(225, 29, 72, 0.12);
  color: var(--red);
}

.ball.back {
  background: rgba(10, 132, 255, 0.14);
  color: var(--accent);
}

.plus {
  color: var(--muted);
  font-weight: 800;
}

.primary,
.secondary,
.ghost,
.danger,
.chip,
.icon-button {
  min-height: 42px;
  border-radius: 999px;
  padding: 0 16px;
  font-weight: 750;
}

.primary {
  background: var(--accent);
  color: white;
  box-shadow: 0 10px 22px rgba(10, 132, 255, 0.22);
}

.primary:active {
  background: var(--accent-strong);
}

.secondary {
  background: var(--soft);
  color: var(--text);
}

.ghost,
.icon-button {
  background: transparent;
  color: var(--text);
}

.icon-button {
  background: var(--soft);
}

.danger {
  background: rgba(225, 29, 72, 0.12);
  color: var(--red);
}

.small {
  min-height: 34px;
  padding: 0 12px;
  font-size: 13px;
}

.full {
  width: 100%;
}

.button-row,
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  align-items: center;
}

.chip {
  min-height: 36px;
  background: var(--soft);
  color: var(--muted);
  font-size: 13px;
}

.chip.active {
  background: var(--blue-soft);
  color: var(--accent-strong);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.inline-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.switch-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.switch-row label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.switch-row input {
  width: 18px;
  min-height: auto;
}

.list {
  display: grid;
  gap: 10px;
}

.list-item {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: color-mix(in srgb, var(--panel-solid) 84%, transparent);
  padding: 13px;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.04);
}

.list-top {
  display: flex;
  min-width: 0;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.list-top strong {
  display: block;
  font-size: 16px;
  overflow-wrap: anywhere;
}

.meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  background: var(--soft);
  color: var(--muted);
  padding: 0 9px;
  font-size: 12px;
  font-weight: 760;
  white-space: nowrap;
}

.pill.win {
  background: rgba(22, 163, 74, 0.12);
  color: var(--green);
}

.pill.loss {
  background: rgba(225, 29, 72, 0.12);
  color: var(--red);
}

.pill.pending {
  background: rgba(245, 158, 11, 0.13);
  color: var(--orange);
}

.entry-row {
  display: grid;
  gap: 8px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.entry-row:first-child {
  border-top: 0;
}

.entry-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.mini-stats {
  gap: 8px;
}

.mini-stats .stat-card {
  min-height: 72px;
  border-radius: 15px;
  padding: 10px;
  box-shadow: none;
}

.mini-stats .stat-card strong {
  margin-top: 5px;
  font-size: 18px;
}

.mini-stats .stat-card small {
  margin-top: 5px;
}

details {
  margin-top: 10px;
}

summary {
  color: var(--accent-strong);
  cursor: pointer;
  font-size: 13px;
  font-weight: 760;
}

.empty {
  display: grid;
  place-items: center;
  min-height: 120px;
  border: 1px dashed var(--line);
  border-radius: 18px;
  color: var(--muted);
  text-align: center;
}

.bar-list {
  display: grid;
  gap: 8px;
}

.bar-row {
  display: grid;
  grid-template-columns: 34px 1fr 34px;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}

.bar-track {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--soft);
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: calc(94px + env(safe-area-inset-bottom));
  left: 18px;
  z-index: 80;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: color-mix(in srgb, var(--panel-solid) 94%, transparent);
  box-shadow: var(--shadow);
  color: var(--text);
  padding: 13px 15px;
  text-align: center;
  backdrop-filter: blur(20px);
}

body[data-view="login"] .toast {
  bottom: calc(24px + env(safe-area-inset-bottom));
}

.tabbar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
  width: 100%;
  max-width: 100vw;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(22px);
}

.tab {
  position: relative;
  min-width: 0;
  min-height: 48px;
  border-radius: 16px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.tab.active {
  background: var(--blue-soft);
  color: var(--accent-strong);
}

.tab.active::before {
  position: absolute;
  top: 6px;
  left: 50%;
  width: 18px;
  height: 3px;
  border-radius: 999px;
  background: var(--accent);
  content: "";
  transform: translateX(-50%);
}

.positive {
  color: var(--green);
}

.negative {
  color: var(--red);
}

.center {
  text-align: center;
}

@media (min-width: 760px) {
  .page-host {
    padding: 24px;
  }

  .hero-card {
    grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
    align-items: center;
    padding: 26px;
  }

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

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

  .form-grid .wide,
  .form-grid .button-row,
  .form-grid .switch-row {
    grid-column: 1 / -1;
  }

  .tabbar {
    right: auto;
    bottom: 24px;
    left: 50%;
    width: min(720px, calc(100% - 32px));
    transform: translateX(-50%);
    border: 1px solid var(--line);
    border-radius: 24px;
    box-shadow: var(--shadow);
  }

  .toast {
    right: 28px;
    bottom: 108px;
    left: auto;
    width: 360px;
  }
}

@media (max-width: 420px) {
  .page-host {
    padding: 12px;
  }

  .topbar {
    gap: 8px;
    padding-right: 12px;
    padding-left: 12px;
  }

  .brand {
    gap: 8px;
  }

  .brand span {
    max-width: 34vw;
  }

  .topbar-actions {
    gap: 6px;
  }

  .topbar-actions .icon-button,
  .topbar-actions .ghost {
    min-height: 34px;
    padding: 0 10px;
    font-size: 13px;
  }

  .hero-title h1 {
    font-size: 24px;
  }

  .inline-fields {
    grid-template-columns: 1fr;
  }
}

@media (max-height: 640px) {
  .login-view {
    padding-top: calc(24px + env(safe-area-inset-top));
  }

  .login-stack {
    gap: 12px;
  }

  .login-card {
    padding: 26px 22px 22px;
  }

  .login-icon {
    width: 68px;
    height: 68px;
    margin-bottom: 14px;
  }

  .login-form {
    gap: 12px;
    margin-top: 18px;
  }
}
