:root {
  color-scheme: dark;
  --bg: #080d12;
  --surface: #111922;
  --surface-2: #17212c;
  --surface-3: #1d2a36;
  --line: #293846;
  --text: #f4f8f7;
  --muted: #8e9ca8;
  --primary: #75efc4;
  --primary-dark: #071510;
  --gold: #f5bd4f;
  --danger: #ff6478;
  --team-a: #75efc4;
  --team-b: #6aaeff;
  --shadow: 0 24px 70px rgba(0, 0, 0, .38);
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: Inter, "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  background:
    radial-gradient(circle at 80% 0, rgba(245, 189, 79, .09), transparent 28rem),
    radial-gradient(circle at 10% 10%, rgba(117, 239, 196, .08), transparent 26rem),
    var(--bg);
}
button, input, select { font: inherit; }
button { border: 0; cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid rgba(117, 239, 196, .45);
  outline-offset: 2px;
}
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(27px, 4vw, 42px); }
h2 { margin-bottom: 0; font-size: 20px; }
.app { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 20;
  width: 224px; padding: 24px 16px;
  border-right: 1px solid var(--line);
  background: rgba(9, 14, 20, .96);
  display: flex; flex-direction: column;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 0 8px 28px; }
.brand-mark {
  width: 40px; height: 40px; display: grid; place-items: center;
  border-radius: 12px; color: var(--primary-dark); background: var(--primary);
  font-size: 21px; font-weight: 1000;
}
.brand strong, .brand small { display: block; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 9px; letter-spacing: .16em; }
.side-nav { display: grid; gap: 7px; }
.side-nav button {
  display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 0 14px;
  border-radius: 12px; color: var(--muted); background: transparent; text-align: left; font-weight: 800;
}
.side-nav button span { width: 22px; font-size: 18px; }
.side-nav button.is-active { color: var(--primary); background: rgba(117, 239, 196, .09); }
.sidebar-room { margin-top: auto; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.sidebar-room small, .sidebar-room strong, .sidebar-room span { display: block; }
.sidebar-room small, .sidebar-room span { color: var(--muted); font-size: 10px; }
.sidebar-room strong { margin: 6px 0; color: var(--gold); }
.main { margin-left: 224px; width: min(1180px, calc(100% - 224px)); padding: 28px 34px 100px; }
.topbar, .panel-head, .section-intro, .room-banner, .round-toolbar, .sticky-action {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.topbar { margin-bottom: 25px; }
.eyebrow { margin-bottom: 6px; color: var(--primary); font-size: 10px; font-weight: 900; letter-spacing: .16em; }
.top-actions, .banner-actions { display: flex; gap: 8px; }
.view { display: none; animation: enter .22s ease; }
.view.is-active { display: block; }
@keyframes enter { from { opacity: 0; transform: translateY(5px); } }
.home-grid, .dashboard-grid, .records-grid { display: grid; grid-template-columns: 1.25fr .9fr; gap: 18px; }
.hero-card, .join-card, .panel, .room-banner {
  border: 1px solid var(--line); border-radius: 20px; background: rgba(17, 25, 34, .92); box-shadow: var(--shadow);
}
.hero-card, .join-card { min-height: 500px; padding: clamp(24px, 4vw, 48px); }
.hero-card {
  background:
    linear-gradient(135deg, rgba(117, 239, 196, .11), transparent 46%),
    var(--surface);
}
.hero-card h2 { margin: 28px 0 14px; font-size: clamp(36px, 6vw, 68px); line-height: 1.06; }
.hero-card h2 em { color: var(--primary); font-style: normal; }
.hero-card > p { max-width: 520px; color: var(--muted); line-height: 1.75; }
.join-card h2 { margin: 10px 0 30px; font-size: 30px; }
.live-pill, .status-pill, .gold-pill {
  display: inline-flex; padding: 7px 10px; border-radius: 999px; font-size: 10px; font-weight: 900;
}
.live-pill, .status-pill { color: var(--primary); background: rgba(117, 239, 196, .1); }
.gold-pill { color: var(--gold); background: rgba(245, 189, 79, .12); }
.stack-field { display: grid; gap: 8px; margin-top: 20px; color: var(--muted); font-size: 12px; }
input, select {
  width: 100%; min-height: 48px; border: 1px solid var(--line); border-radius: 12px;
  padding: 0 13px; color: var(--text); background: #0c131b;
}
.primary, .secondary, .ghost, .danger-ghost, .small-button, .text-button {
  min-height: 44px; border-radius: 12px; padding: 0 16px; font-weight: 900;
}
.primary { color: var(--primary-dark); background: var(--primary); }
.secondary { color: var(--text); background: var(--surface-3); border: 1px solid #3a4b5b; }
.ghost { color: var(--text); background: transparent; border: 1px solid var(--line); }
.danger-ghost { color: var(--danger); background: transparent; border: 1px solid rgba(255, 100, 120, .3); }
.small-button { color: var(--primary); background: rgba(117, 239, 196, .09); }
.text-button { min-height: auto; padding: 5px; color: var(--primary); background: transparent; }
.wide { width: 100%; margin-top: 14px; }
.icon-only { width: 44px; padding: 0; }
.mode-preview { display: grid; gap: 8px; margin-top: 28px; }
.mode-preview div { display: flex; justify-content: space-between; padding: 12px; border-radius: 11px; color: var(--muted); background: #0d141c; }
.mode-preview strong { color: var(--text); font-size: 11px; }
.room-banner { margin-bottom: 18px; padding: 22px; }
.room-banner h2 { margin-bottom: 6px; font-size: 27px; }
.room-banner p:last-child { margin: 0; color: var(--muted); font-size: 12px; }
.panel { padding: 20px; }
.panel-head { margin-bottom: 15px; }
.stack { display: grid; gap: 18px; }
.player-list { display: grid; gap: 8px; }
.player-row {
  display: grid; grid-template-columns: 42px 1fr auto auto; gap: 10px; align-items: center;
  padding: 11px; border: 1px solid var(--line); border-radius: 13px; background: #0d141c;
}
.avatar { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 11px; background: var(--surface-3); font-weight: 900; }
.player-name-input { min-height: 38px; padding: 0 9px; background: transparent; }
.team-toggle { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.team-toggle button { width: 34px; height: 34px; color: var(--muted); background: transparent; font-weight: 900; }
.team-toggle button.is-active[data-team="A"] { color: var(--primary-dark); background: var(--team-a); }
.team-toggle button.is-active[data-team="B"] { color: white; background: var(--team-b); }
.remove-player { width: 34px; height: 34px; color: var(--danger); background: transparent; }
.rule-main { padding: 16px; border-radius: 14px; background: linear-gradient(135deg, rgba(117, 239, 196, .09), transparent), #0d141c; }
.rule-main strong { display: block; font-size: 20px; }
.rule-main span { display: block; margin-top: 6px; color: var(--muted); font-size: 11px; }
.rule-tags { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.rule-tags span { padding: 6px 8px; border-radius: 99px; color: var(--muted); background: var(--surface-3); font-size: 9px; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin: 15px 0; padding: 4px; border-radius: 12px; background: #0b1219; }
.segmented button { min-height: 40px; border-radius: 9px; color: var(--muted); background: transparent; font-weight: 800; }
.segmented button.is-active { color: var(--primary); background: var(--surface-3); }
.segmented.compact { display: flex; margin: 0; }
.segmented.compact button { min-width: 70px; }
.section-intro { margin-bottom: 18px; }
.section-intro h2 { font-size: 27px; }
.round-toolbar { margin-bottom: 15px; padding: 12px 15px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.round-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.round-card { padding: 17px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.round-card.team-a { border-top: 3px solid var(--team-a); }
.round-card.team-b { border-top: 3px solid var(--team-b); }
.round-card-head { display: flex; justify-content: space-between; margin-bottom: 14px; }
.round-card-head span { color: var(--muted); font-size: 10px; }
.input-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.input-grid label { display: grid; gap: 6px; color: var(--muted); font-size: 10px; }
.input-grid input { text-align: center; font-size: 18px; font-weight: 900; }
.sticky-action { position: sticky; bottom: 78px; margin-top: 18px; padding: 12px; border: 1px solid var(--line); border-radius: 15px; background: rgba(8, 13, 18, .9); backdrop-filter: blur(12px); justify-content: flex-end; }
.rounding-switch {
  display: flex; align-items: center; gap: 14px; margin-bottom: 15px; padding: 15px;
  border: 1px solid var(--line); border-radius: 15px; background: var(--surface); cursor: pointer;
}
.rounding-switch div { margin-right: auto; }
.rounding-switch strong, .rounding-switch span { display: block; }
.rounding-switch span { margin-top: 5px; color: var(--muted); font-size: 10px; }
.rounding-switch input { position: absolute; opacity: 0; width: 1px; }
.rounding-switch i { width: 46px; height: 26px; padding: 3px; border-radius: 99px; background: #364351; transition: .2s; }
.rounding-switch i::after { display: block; width: 20px; height: 20px; border-radius: 50%; content: ""; background: white; transition: .2s; }
.rounding-switch input:checked + i { background: var(--primary); }
.rounding-switch input:checked + i::after { transform: translateX(20px); background: var(--primary-dark); }
.result-list { display: grid; gap: 9px; }
.result-row {
  display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: center;
  padding: 16px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface);
}
.result-row h3 { margin: 0 0 6px; font-size: 15px; }
.formula { color: var(--muted); font-size: 10px; line-height: 1.6; }
.score-value { color: var(--primary); font-size: 24px; font-weight: 1000; }
.summary-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 18px; }
.summary-card { padding: 17px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); color: var(--muted); font-size: 10px; }
.summary-card strong { display: block; margin-top: 6px; color: var(--text); font-size: 21px; }
.summary-card.gold strong { color: var(--gold); }
.ranking-list, .history-list { display: grid; gap: 6px; }
.rank-row, .history-item {
  display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: center;
  padding: 12px 4px; border-top: 1px solid var(--line);
}
.rank-row:first-child, .history-item:first-child { border-top: 0; }
.rank-number { color: var(--gold); font-weight: 1000; }
.rank-row small, .history-item small { display: block; margin-top: 4px; color: var(--muted); }
.rank-score { color: var(--primary); font-size: 17px; font-weight: 1000; }
.history-item { grid-template-columns: 1fr auto; }
.empty { padding: 30px 10px; color: var(--muted); text-align: center; }
.bottom-nav { display: none; }
.modal { position: fixed; inset: 0; z-index: 50; display: none; }
.modal.is-open { display: block; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.72); backdrop-filter: blur(4px); }
.modal-panel {
  position: absolute; top: 0; right: 0; width: min(480px, 100%); height: 100%;
  padding: 24px; overflow: auto; border-left: 1px solid var(--line); background: #0d141c; box-shadow: var(--shadow);
}
.mode-cards { display: grid; gap: 9px; margin: 20px 0; }
.mode-cards button { padding: 15px; border: 1px solid var(--line); border-radius: 13px; color: var(--text); background: var(--surface); text-align: left; }
.mode-cards button strong, .mode-cards button span { display: block; }
.mode-cards button span { margin-top: 5px; color: var(--muted); font-size: 10px; }
.mode-cards button.is-active { border-color: var(--primary); background: rgba(117, 239, 196, .08); }
details { margin: 15px 0; padding: 15px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); }
summary { cursor: pointer; font-weight: 900; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.settings-grid label { display: grid; gap: 6px; color: var(--muted); font-size: 10px; }
.check-field { grid-template-columns: auto 1fr; align-items: center; }
.check-field input { width: 20px; min-height: 20px; }
.toast {
  position: fixed; z-index: 80; left: 50%; bottom: 28px; transform: translate(-50%, 20px);
  padding: 11px 16px; border-radius: 99px; color: var(--primary-dark); background: var(--primary);
  font-weight: 900; opacity: 0; pointer-events: none; transition: .2s;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 900px) {
  .sidebar { display: none; }
  .main { width: 100%; margin: 0; padding: 20px 14px 110px; }
  .bottom-nav {
    position: fixed; z-index: 30; left: 10px; right: 10px; bottom: max(10px, env(safe-area-inset-bottom));
    display: grid; grid-template-columns: repeat(4, 1fr); padding: 7px;
    border: 1px solid var(--line); border-radius: 18px; background: rgba(12, 18, 25, .94);
    box-shadow: var(--shadow); backdrop-filter: blur(14px);
  }
  .bottom-nav button { min-height: 50px; border-radius: 12px; color: var(--muted); background: transparent; font-size: 10px; font-weight: 900; }
  .bottom-nav button span { display: block; margin-bottom: 3px; font-size: 17px; }
  .bottom-nav button.is-active { color: var(--primary); background: rgba(117, 239, 196, .08); }
  .home-grid, .dashboard-grid, .records-grid { grid-template-columns: 1fr; }
  .hero-card, .join-card { min-height: auto; }
  .hero-card h2 { font-size: 43px; }
  .round-grid { grid-template-columns: 1fr; }
  .sticky-action { bottom: 82px; }
}
@media (max-width: 560px) {
  .topbar { align-items: flex-start; }
  .room-banner, .section-intro { align-items: flex-start; flex-direction: column; }
  .banner-actions { width: 100%; }
  .banner-actions button { flex: 1; }
  .round-toolbar { align-items: stretch; flex-direction: column; }
  .segmented.compact { display: grid; grid-template-columns: repeat(3, 1fr); width: 100%; }
  .input-grid { grid-template-columns: repeat(2, 1fr); }
  .summary-cards { grid-template-columns: 1fr 1fr; }
  .summary-card:first-child { grid-column: 1 / -1; }
  .settings-grid { grid-template-columns: 1fr; }
}
