:root {
  color-scheme: dark;
  --tg-bg: #0f1720;
  --tg-surface: #16202b;
  --tg-text: #f4f7fb;
  --tg-muted: #8b9aae;
  --tg-accent: #6aa6ff;
  --tg-accent-soft: rgba(106, 166, 255, 0.16);
  --tg-violet: #8c63ff;
  --tg-success: #54cf95;
  --tg-success-soft: rgba(84, 207, 149, 0.16);
  --tg-warning: #f7c266;
  --tg-border: rgba(255, 255, 255, 0.08);
  --tg-divider: rgba(255, 255, 255, 0.07);
  --tg-shadow: 0 18px 48px rgba(4, 10, 18, 0.4);
  --place-gold: #f6b23b;
  --place-silver: #d0d6e1;
  --place-bronze: #ff9f57;
  --shell-max-width: 480px;
  font-family: "SF Pro Display", "Segoe UI Variable", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  background:
    radial-gradient(circle at top, rgba(76, 141, 255, 0.12), transparent 32%),
    linear-gradient(180deg, #101720 0%, #0b1017 100%);
  color: var(--tg-text);
}

button {
  font: inherit;
}

.app-shell {
  width: min(100%, var(--shell-max-width));
  min-height: 100vh;
  min-height: 100svh;
  margin: 0 auto;
  padding: calc(14px + env(safe-area-inset-top)) 16px 0;
}

.topbar {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0 0 8px;
}

.topbar--empty {
  min-height: 0;
  padding: 0;
}

.topbar__back {
  min-height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--tg-accent);
  font-size: 17px;
  font-weight: 500;
  cursor: pointer;
}

.content {
  padding: 0 0 calc(124px + env(safe-area-inset-bottom));
}

.screen-panel {
  border: 1px solid var(--tg-border);
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02)),
    var(--tg-surface);
  box-shadow: var(--tg-shadow);
  overflow: hidden;
}

.screen-panel--plain {
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
}

.screen-panel__head {
  padding: 18px 18px 6px;
}

.screen-panel__head.is-hidden {
  display: none;
}

.screen-panel__eyebrow {
  margin: 0;
  color: var(--tg-muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.screen-panel__heading {
  margin: 8px 0 0;
  font-size: 26px;
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.04em;
}

.screen-body {
  padding: 10px 18px 18px;
}

.screen-body--plain {
  padding: 8px 0 0;
}

.is-hidden {
  display: none;
}

.menu-list,
.signup-day-list,
.attendees-list {
  display: grid;
  gap: 14px;
}

.location-switcher,
.rating-period-switcher {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  gap: 4px;
  margin-bottom: 12px;
  padding: 4px;
  border: 1px solid var(--tg-border);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
}

.location-switcher__item,
.rating-period-switcher__item {
  min-width: 0;
  min-height: 40px;
  padding: 0 10px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: var(--tg-muted);
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.location-switcher__item.is-active,
.rating-period-switcher__item.is-active {
  background: var(--tg-accent-soft);
  color: var(--tg-text);
}

.location-switcher__item:disabled,
.rating-period-switcher__item:disabled {
  cursor: default;
  opacity: 0.72;
}

.menu-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 72px;
  padding: 0 20px;
  border: 1px solid var(--tg-border);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--tg-text);
  text-align: center;
  cursor: pointer;
}

.menu-button__label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.menu-button__icon {
  font-size: 20px;
  line-height: 1;
}

.menu-button__arrow {
  display: none;
}

.signup-day-button {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 68px;
  padding: 0 18px;
  border: 1px solid var(--tg-border);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--tg-text);
  cursor: pointer;
  text-align: left;
}

.signup-day-button__title {
  display: block;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.signup-day-button__meta {
  display: block;
  margin-top: 6px;
  color: var(--tg-muted);
  font-size: 13px;
  line-height: 1.35;
}

.signup-day-button:disabled {
  cursor: default;
  opacity: 0.72;
}

.subtle-note,
.empty-state {
  border: 1px solid var(--tg-border);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.04);
}

.subtle-note {
  margin-bottom: 12px;
  padding: 14px 16px;
  color: var(--tg-text);
  font-size: 13px;
  line-height: 1.5;
}

.empty-state {
  padding: 20px 16px;
  color: var(--tg-muted);
  text-align: center;
  font-size: 14px;
  line-height: 1.5;
}

.rating-shell {
  display: grid;
}

.rating-header {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 92px 78px;
  gap: 12px;
  align-items: center;
  padding: 0 4px 10px;
  border-bottom: 1px solid var(--tg-divider);
  color: var(--tg-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.rating-header__place {
  grid-column: 1;
}

.rating-header__record {
  grid-column: 3;
  text-align: right;
}

.rating-header__points {
  grid-column: 4;
  text-align: right;
}

.rating-list {
  display: grid;
}

.rating-row {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 92px 78px;
  gap: 12px;
  align-items: center;
  width: 100%;
  padding: 14px 4px;
  border: 0;
  border-bottom: 1px solid var(--tg-divider);
  background: transparent;
  color: var(--tg-text);
  cursor: pointer;
  text-align: left;
}

.rating-row:last-child {
  border-bottom: 0;
}

.rating-row__place {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: #a9b7c8;
}

.rating-row--1 .rating-row__place {
  color: var(--place-gold);
}

.rating-row--2 .rating-row__place {
  color: var(--place-silver);
}

.rating-row--3 .rating-row__place {
  color: var(--place-bronze);
}

.rating-row__name {
  min-width: 0;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rating-row__name--self {
  color: var(--tg-accent);
  text-shadow: 0 0 18px rgba(106, 166, 255, 0.18);
}

.rating-row__record {
  text-align: right;
}

.rating-row__record-main {
  display: block;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.15;
}

.rating-row__record-sub {
  display: block;
  margin-top: 4px;
  color: var(--tg-muted);
  font-size: 12px;
  line-height: 1;
}

.rating-row__points {
  text-align: right;
  font-size: 18px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.04em;
  color: var(--tg-violet);
}

.player-detail {
  display: grid;
  gap: 16px;
}

.player-detail__top {
  display: grid;
  gap: 6px;
}

.player-detail__place {
  color: var(--tg-accent);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.2;
}

.player-detail__name {
  margin: 0;
  font-size: 24px;
  font-weight: 800;
  line-height: 1.08;
  letter-spacing: 0;
}

.player-detail__season {
  color: var(--tg-muted);
  font-size: 13px;
  line-height: 1.35;
}

.player-stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.player-stat-pill {
  min-width: 0;
  padding: 12px 10px;
  border: 1px solid var(--tg-border);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
}

.player-stat-pill__label,
.player-stat-pill__value {
  display: block;
  min-width: 0;
}

.player-stat-pill__label {
  color: var(--tg-muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.25;
}

.player-stat-pill__value {
  margin-top: 7px;
  color: var(--tg-text);
  font-size: 15px;
  font-weight: 800;
  line-height: 1.15;
}

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

.role-stat-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px 58px;
  gap: 10px;
  align-items: center;
  min-height: 48px;
  padding: 0 12px;
  border: 1px solid var(--tg-border);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
}

.role-stat-row__label {
  min-width: 0;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.role-stat-row__value,
.role-stat-row__percent {
  text-align: right;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.2;
}

.role-stat-row__percent {
  color: var(--tg-muted);
}

.tak-rating-row {
  cursor: default;
}

.tak-rating-row__points-total,
.tak-rating-row__points-average {
  display: block;
}

.tak-rating-row__points-average {
  margin-top: 4px;
  color: var(--tg-muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

.tak-match-form {
  display: grid;
  gap: 16px;
}

.tak-team-card {
  display: grid;
  gap: 14px;
  padding: 0 0 16px;
  border-bottom: 1px solid var(--tg-divider);
}

.tak-team-card.is-winner .tak-team-card__title {
  color: var(--tg-success);
}

.tak-team-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.tak-team-card__title {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: 0;
}

.tak-winner-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--tg-border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--tg-text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
}

.tak-winner-control input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--tg-success);
}

.tak-team-card__players {
  display: grid;
  gap: 14px;
}

.tak-player-card {
  position: relative;
  display: grid;
  gap: 8px;
}

.tak-player-card__label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--tg-muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
  text-transform: uppercase;
}

.tak-player-card__auto {
  color: var(--tg-success);
  text-transform: none;
}

.tak-player-card__input {
  width: 100%;
  min-height: 46px;
  padding: 0 13px;
  border: 1px solid var(--tg-border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--tg-text);
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  outline: 0;
}

.tak-player-card__input:focus {
  border-color: rgba(106, 166, 255, 0.55);
  box-shadow: 0 0 0 3px var(--tg-accent-soft);
}

.tak-suggestion-anchor {
  position: relative;
  min-height: 0;
}

.tak-suggestion-list {
  position: absolute;
  z-index: 8;
  top: -2px;
  left: 0;
  right: 0;
  display: grid;
  max-height: 220px;
  overflow: auto;
  border: 1px solid rgba(106, 166, 255, 0.24);
  border-radius: 16px;
  background: rgba(18, 27, 38, 0.98);
  box-shadow: 0 16px 36px rgba(4, 10, 18, 0.48);
}

.tak-suggestion-list__group {
  padding: 10px 12px 6px;
  color: var(--tg-muted);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.2;
  text-transform: uppercase;
}

.tak-suggestion-list__status {
  padding: 12px;
  border-top: 1px solid var(--tg-divider);
  color: var(--tg-muted);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.2;
}

.tak-suggestion-item {
  min-height: 40px;
  padding: 0 12px;
  border: 0;
  border-top: 1px solid var(--tg-divider);
  background: transparent;
  color: var(--tg-text);
  cursor: pointer;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.2;
  text-align: left;
}

.tak-score-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.tak-score-button {
  min-width: 0;
  min-height: 42px;
  padding: 0;
  border: 1px solid var(--tg-border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--tg-text);
  cursor: pointer;
  font-size: 16px;
  font-weight: 900;
  line-height: 1;
}

.tak-score-button--bonus {
  color: var(--tg-warning);
}

.tak-score-button.is-active {
  border-color: rgba(106, 166, 255, 0.62);
  background: var(--tg-accent-soft);
  color: var(--tg-text);
}

.signup-card {
  border: 1px solid var(--tg-border);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.04);
  padding: 18px;
}

.signup-card__title {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.signup-card__meta {
  margin: 10px 0 0;
  color: var(--tg-muted);
  font-size: 14px;
  line-height: 1.45;
}

.signup-card__meta--lead {
  margin-top: 0;
}

.signup-card__status {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  margin-top: 14px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(84, 207, 149, 0.2);
  background: var(--tg-success-soft);
  color: var(--tg-success);
  font-size: 12px;
  font-weight: 700;
}

.attendees-list {
  margin-top: 16px;
}

.attendee {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
}

.attendee__name {
  min-width: 0;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.35;
}

.attendee__badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--tg-muted);
  font-size: 12px;
  font-weight: 700;
}

.attendee__badge--self {
  background: var(--tg-accent-soft);
  color: var(--tg-accent);
}

.attendee__badge--question {
  background: rgba(247, 194, 102, 0.12);
  color: var(--tg-warning);
}

.action-button {
  width: 100%;
  min-height: 56px;
  margin-top: 16px;
  border: 0;
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(106, 166, 255, 0.92), rgba(74, 142, 255, 0.84)),
    rgba(255, 255, 255, 0.04);
  color: var(--tg-text);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

.action-button.is-active,
.action-button.is-active:disabled {
  background: var(--tg-success-soft);
  color: var(--tg-success);
}

.action-button.is-danger {
  border: 1px solid rgba(255, 112, 112, 0.24);
  background: rgba(255, 112, 112, 0.12);
  color: #ff9a9a;
}

.action-button:disabled {
  cursor: default;
  opacity: 1;
  background: rgba(255, 255, 255, 0.08);
  color: var(--tg-muted);
}

.bottom-nav {
  position: fixed;
  z-index: 10;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  width: min(100%, var(--shell-max-width));
  padding: 12px 16px calc(16px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 26px 26px 0 0;
  background: rgba(14, 21, 30, 0.92);
  backdrop-filter: blur(24px);
}

.bottom-nav__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 68px;
  border: 0;
  border-radius: 20px;
  background: transparent;
  color: var(--tg-muted);
  cursor: pointer;
}

.bottom-nav__item.is-active {
  background:
    linear-gradient(180deg, rgba(106, 166, 255, 0.24), rgba(74, 142, 255, 0.18)),
    rgba(255, 255, 255, 0.04);
  color: var(--tg-text);
  transform: translateY(-1px);
}

.bottom-nav__icon {
  font-size: 22px;
  line-height: 1;
}

.bottom-nav__label {
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
}

@media (hover: hover) {
  .menu-button:hover,
  .rating-row:hover,
  .signup-day-button:hover:not(:disabled),
  .location-switcher__item:hover:not(:disabled),
  .rating-period-switcher__item:hover:not(:disabled),
  .tak-suggestion-item:hover,
  .tak-score-button:hover,
  .tak-winner-control:hover,
  .bottom-nav__item:hover,
  .topbar__back:hover {
    filter: brightness(1.06);
  }

  .action-button:hover:not(:disabled) {
    filter: brightness(1.04);
  }
}

@media (max-width: 360px) {
  .screen-panel__heading {
    font-size: 24px;
  }

  .rating-header,
  .rating-row {
    grid-template-columns: 42px minmax(0, 1fr) 74px 70px;
    gap: 8px;
  }

  .rating-row__name {
    font-size: 15px;
  }

  .rating-row__points {
    font-size: 16px;
  }
}

@media (min-width: 540px) {
  .app-shell {
    padding-left: 20px;
    padding-right: 20px;
  }
}
