:root {
  color-scheme: dark;
  --bg: #07090d;
  --panel: #111720;
  --panel-2: #171f2b;
  --line: #263243;
  --text: #f4f7fb;
  --muted: #9aa8bb;
  --blue: #33b5ff;
  --gold: #f2b84b;
  --green: #41d88d;
  --red: #ff6575;
  --shadow: 0 22px 60px rgba(0, 0, 0, .32);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 20% 0%, rgba(51, 181, 255, .14), transparent 23rem),
    radial-gradient(circle at 100% 12%, rgba(242, 184, 75, .11), transparent 24rem),
    var(--bg);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.auth-view {
  min-height: 100vh;
  width: 100vw;
  display: grid;
  place-items: center;
  padding: 12px;
}

.auth-card,
.panel-card,
.hero-card,
.modal-card {
  border: 1px solid var(--line);
  background: rgba(17, 23, 32, .94);
  box-shadow: var(--shadow);
}

.auth-card {
  width: min(420px, calc(100vw - 24px));
  border-radius: 20px;
  padding: 24px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
}

.logo {
  width: 74px;
  display: block;
  flex: 0 0 auto;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--gold);
  font-size: .78rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 2.45rem;
  line-height: 1;
}

.title-lockup {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.partner-logo {
  width: 58px;
  height: 58px;
  object-fit: contain;
  flex: 0 0 auto;
}

h2 {
  margin-bottom: 0;
  font-size: 1.55rem;
}

h3 {
  margin-bottom: 0;
  font-size: 1.05rem;
}

.auth-tabs,
.tabbar {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #0b1018;
}

.auth-tabs button,
.tabbar button {
  min-height: 42px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.auth-tabs button.active,
.tabbar button.active {
  background: var(--blue);
  color: #07101a;
}

.auth-form,
.game-form {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 800;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0b1018;
  color: var(--text);
  padding: 13px 12px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--blue);
}

.primary-btn,
.secondary-btn,
.small-btn,
.text-btn,
.icon-btn {
  border: 0;
  border-radius: 12px;
  font-weight: 900;
}

.primary-btn {
  min-height: 46px;
  background: var(--blue);
  color: #06111b;
}

.secondary-btn,
.small-btn,
.text-btn,
.icon-btn {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
}

.small-btn {
  min-height: 38px;
  padding: 0 12px;
}

.danger-btn {
  border-color: rgba(255, 101, 117, .42);
  background: rgba(255, 101, 117, .12);
  color: #ff9aa5;
}

.text-btn {
  min-height: 42px;
}

.message {
  min-height: 20px;
  margin: 0;
  color: var(--gold);
  font-size: .86rem;
  font-weight: 700;
}

.message.error {
  color: var(--red);
}

.app-view {
  min-height: 100vh;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: max(12px, env(safe-area-inset-top)) 14px 10px;
  background: rgba(7, 9, 13, .88);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(38, 50, 67, .55);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand > img {
  width: 38px;
  height: 38px;
  object-fit: contain;
}

.brand-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-title img {
  width: 42px;
  height: 42px;
  object-fit: contain;
  flex: 0 0 auto;
}

.brand span {
  display: block;
  color: var(--muted);
  font-size: .77rem;
  font-weight: 800;
}

.brand strong {
  display: block;
  font-size: 1.16rem;
  line-height: 1.05;
}

.icon-btn {
  width: 42px;
  height: 42px;
}

.main-content {
  width: min(880px, 100%);
  margin: 0 auto;
  padding: 14px 12px 88px;
}

.pull-refresh-hint {
  position: fixed;
  top: calc(72px + env(safe-area-inset-top));
  left: 50%;
  z-index: 4;
  width: max-content;
  max-width: 100%;
  margin: 0;
  padding: 7px 13px;
  border: 1px solid rgba(51, 181, 255, .35);
  border-radius: 999px;
  background: rgba(11, 16, 24, .92);
  color: var(--blue);
  font-size: .78rem;
  font-weight: 900;
  opacity: 0;
  transform: translate(-50%, -8px);
  pointer-events: none;
  transition: opacity .16s ease, transform .16s ease;
}

.pull-refresh-hint.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.hero-card {
  border-radius: 18px;
  padding: 18px;
  margin-bottom: 12px;
  display: grid;
  gap: 14px;
}

.hero-profile {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.profile-avatar {
  width: 58px;
  height: 58px;
  border: 1px solid rgba(51, 181, 255, .34);
  border-radius: 50%;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: linear-gradient(145deg, rgba(51, 181, 255, .18), rgba(242, 184, 75, .15));
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 900;
}

.profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero-identity {
  min-width: 0;
}

.hero-identity h2 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-light {
  min-width: 74px;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 13px;
  display: grid;
  place-items: center;
  gap: 4px;
  padding: 7px 9px;
  background: rgba(11, 16, 24, .72);
}

.status-light span {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 4px rgba(154, 168, 187, .12);
}

.status-light strong {
  font-size: .68rem;
  line-height: 1;
  text-transform: uppercase;
}

.status-light.green span {
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(65, 216, 141, .12);
}

.status-light.yellow span {
  background: var(--gold);
  box-shadow: 0 0 0 4px rgba(242, 184, 75, .14);
}

.status-light.red span {
  background: var(--red);
  box-shadow: 0 0 0 4px rgba(255, 101, 117, .13);
}

.hero-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(82px, 1fr));
  gap: 8px;
}

.hero-metrics article {
  min-width: 0;
  border: 1px solid rgba(38, 50, 67, .78);
  border-radius: 12px;
  background: rgba(11, 16, 24, .72);
  padding: 10px;
}

.hero-metrics span {
  display: block;
  color: var(--muted);
  font-size: .68rem;
  font-weight: 900;
  text-transform: uppercase;
}

.hero-metrics strong {
  display: block;
  margin-top: 4px;
  font-size: 1.2rem;
  line-height: 1;
}

.tabbar {
  position: sticky;
  top: 69px;
  z-index: 4;
  grid-template-columns: repeat(4, 1fr);
  margin-bottom: 12px;
}

.tab-panel {
  display: grid;
  gap: 12px;
}

.panel-card {
  border-radius: 16px;
  padding: 15px;
}

.form-grid,
.score-grid {
  display: grid;
  grid-template-columns: 1fr 86px 1.1fr;
  gap: 10px;
}

.score-grid {
  grid-template-columns: 1fr 1fr;
}

.teams-entry {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.team-head {
  margin-bottom: 8px;
  font-weight: 900;
}

.team-head.win {
  color: var(--green);
}

.team-head.loss {
  color: var(--red);
}

.slots {
  display: grid;
  gap: 8px;
}

.slots select {
  min-height: 44px;
}

.form-actions {
  display: flex;
  gap: 8px;
}

.form-actions > * {
  flex: 1;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.badge {
  border-radius: 999px;
  padding: 5px 10px;
  background: rgba(51, 181, 255, .14);
  color: var(--blue);
  font-weight: 900;
  font-size: .8rem;
}

.game-list,
.ranking-list,
.player-list,
.user-list,
.compact-list {
  display: grid;
  gap: 9px;
}

.game-item,
.ranking-item,
.player-item,
.user-item,
.compact-item,
.summary-card {
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #0b1018;
  padding: 12px;
}

.game-item-head,
.row-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}

.game-teams {
  display: grid;
  gap: 6px;
  margin: 10px 0;
  color: var(--muted);
  font-size: .92rem;
}

.game-teams strong {
  color: var(--text);
}

.game-date-group {
  display: grid;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(11, 16, 24, .58);
  overflow: hidden;
}

.game-date-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  cursor: pointer;
  list-style: none;
}

.game-date-head::-webkit-details-marker {
  display: none;
}

.game-date-head strong {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .88rem;
}

.game-date-head strong::before {
  content: '›';
  color: var(--blue);
  font-size: 1.15rem;
  line-height: 1;
  transition: transform .16s ease;
}

.game-date-group[open] .game-date-head strong::before {
  transform: rotate(90deg);
}

.game-date-games {
  display: grid;
  gap: 8px;
  padding: 0 10px 10px;
}

.item-actions {
  display: flex;
  gap: 7px;
}

.item-actions button {
  min-height: 34px;
  padding: 0 10px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.summary-card span {
  display: block;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 800;
}

.summary-card strong {
  display: block;
  margin-top: 6px;
  font-size: 1.7rem;
}

.stats-overview {
  display: grid;
  gap: 12px;
}

.stats-filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.stat-section {
  padding: 0;
  overflow: hidden;
}

.stat-section summary {
  min-height: 58px;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 15px;
  cursor: pointer;
}

.stat-section summary::-webkit-details-marker {
  display: none;
}

.stat-section summary span {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.02rem;
  font-weight: 900;
}

.stat-section summary span::before {
  content: "›";
  width: 24px;
  height: 24px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: rgba(51, 181, 255, .14);
  color: var(--blue);
  transition: transform .16s ease;
}

.stat-section[open] summary span::before {
  transform: rotate(90deg);
}

.stat-section summary strong {
  min-width: 34px;
  border-radius: 999px;
  padding: 5px 9px;
  background: rgba(242, 184, 75, .14);
  color: var(--gold);
  text-align: center;
  font-size: .82rem;
}

.stat-section .ranking-list,
.stat-section .compact-list,
.stat-section .profile-stats {
  padding: 0 15px 15px;
}

.profile-stats {
  display: grid;
  gap: 12px;
}

.profile-grid,
.profile-columns {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.profile-stats h4 {
  margin: 2px 0 8px;
  color: var(--muted);
  font-size: .82rem;
  text-transform: uppercase;
}

.duel-card {
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #0b1018;
  padding: 12px;
}

.duel-progress span {
  background: linear-gradient(90deg, var(--gold), #ffe19a);
}

.stats-chart {
  display: grid;
  gap: 10px;
}

.chart-block {
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #0b1018;
  padding: 12px;
}

.chart-title {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.chart-row {
  display: grid;
  grid-template-columns: minmax(68px, 1fr) minmax(86px, 1.6fr) 46px;
  gap: 8px;
  align-items: center;
  min-height: 28px;
}

.chart-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: .86rem;
  font-weight: 800;
}

.chart-row strong {
  text-align: right;
  font-size: .82rem;
}

.chart-track {
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: #202a38;
}

.chart-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), #7be0ff);
}

.chart-track.games i {
  background: linear-gradient(90deg, var(--gold), #ffe19a);
}

.chart-track.teams i,
.team-progress span {
  background: linear-gradient(90deg, var(--green), #95ffc5);
}

.progress {
  height: 8px;
  border-radius: 999px;
  background: #202a38;
  overflow: hidden;
  margin-top: 8px;
}

.progress span {
  display: block;
  height: 100%;
  background: var(--blue);
}

.mini-filter {
  width: 86px;
  grid-template-columns: 28px 1fr;
  align-items: center;
}

.mini-filter input {
  padding: 8px;
}

.inline-form {
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-bottom: 12px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: end center;
  padding: 12px;
  background: rgba(0, 0, 0, .62);
}

.modal-card {
  width: min(520px, 100%);
  border-radius: 18px;
  padding: 16px;
  display: grid;
  gap: 12px;
}

.user-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.user-password-controls {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.user-password-controls input {
  min-width: 0;
}

@media (min-width: 720px) {
  .teams-entry {
    grid-template-columns: 1fr 1fr;
  }

  .summary-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .stats-chart {
    grid-template-columns: repeat(2, 1fr);
  }

  .chart-block.wide {
    grid-column: 1 / -1;
  }

  .stats-filters,
  .profile-columns {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 420px) {
  .form-grid {
    grid-template-columns: 1fr 76px;
  }

  .form-grid label:nth-child(3) {
    grid-column: 1 / -1;
  }

  .tabbar button {
    font-size: .78rem;
  }

  .user-password-controls {
    grid-template-columns: 1fr;
  }
}
