:root {
  color-scheme: light;
  --bg: #f3f6f1;
  --panel: #ffffff;
  --ink: #14201b;
  --muted: #6a766f;
  --line: #dce6dd;
  --green: #1f8f5f;
  --lime: #d7f36b;
  --blue: #1b6edc;
  --red: #ef5b5b;
  --shadow: 0 18px 50px rgba(31, 54, 43, 0.14);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 16% 0%, rgba(215, 243, 107, 0.35), transparent 32%),
    linear-gradient(180deg, #eef5ec 0%, #f8faf7 46%, #edf2ee 100%);
  color: var(--ink);
}

button {
  font: inherit;
}

.app-shell {
  width: min(100%, 520px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 16px 92px;
}

.topbar,
.section-head,
.leader-row,
.match-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.eyebrow,
.hero-label {
  margin: 0 0 4px;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.05;
}

h2 {
  font-size: 21px;
  line-height: 1.15;
}

.icon-button {
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  font-size: 22px;
  box-shadow: 0 8px 24px rgba(24, 38, 30, 0.08);
}

.hero-panel {
  margin: 20px 0 18px;
  padding: 22px;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(20, 32, 27, 0.92), rgba(31, 143, 95, 0.82)),
    linear-gradient(135deg, var(--green), var(--lime));
  color: #fff;
  box-shadow: var(--shadow);
}

.is-detail-view .hero-panel {
  display: none;
}

.is-detail-view .topbar {
  margin-bottom: 14px;
}

.hero-panel h2 {
  margin-bottom: 8px;
  font-size: 27px;
}

.hero-panel p {
  color: rgba(255, 255, 255, 0.78);
}

.hero-label {
  color: var(--lime);
}

.hero-players {
  display: inline-flex;
  margin-top: 12px;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 15px;
  font-weight: 850;
}

.hero-money {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.hero-money span {
  padding: 6px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.13);
  color: rgba(255, 255, 255, 0.86);
  font-size: 12px;
  font-weight: 600;
}

.screen {
  display: none;
}

.screen.is-active {
  display: block;
}

.section-head {
  margin: 16px 0 12px;
}

.section-head span {
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.stack,
.leaderboard,
.bracket {
  display: grid;
  gap: 12px;
}

.tournament-card,
.profile-card,
.leader-row,
.round-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 10px 26px rgba(24, 38, 30, 0.08);
}

.tournament-card {
  padding: 14px;
  cursor: pointer;
}

.tournament-card h2 {
  font-size: 19px;
  line-height: 1.18;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 12px;
}

.pill {
  padding: 6px 9px;
  border-radius: 999px;
  background: #eef5ec;
  color: var(--muted);
  font-size: 12px;
  font-weight: 550;
}

.tournament-meta-block {
  display: grid;
  gap: 7px;
  margin: 9px 0 9px;
  padding-left: 3px;
}

.date-line {
  color: var(--muted);
  font-size: 14px;
  font-weight: 450;
}

.players-badge {
  width: fit-content;
  padding: 6px 10px;
  border-radius: 999px;
  background: #e3f4e8;
  color: var(--green);
  font-size: 13px;
  font-weight: 650;
}

.money-line {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.money-pill {
  width: fit-content;
  margin: 0;
  padding: 7px 10px;
  border-radius: 999px;
  background: #eef5ec;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.money-pill.prize {
  background: #e3f4e8;
  color: var(--green);
}

.roster-carousel {
  display: flex;
  gap: 12px;
  margin: 4px -14px 10px;
  padding: 3px 14px 7px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.roster-carousel::-webkit-scrollbar {
  display: none;
}

.roster-player {
  width: 62px;
  flex: 0 0 62px;
  display: grid;
  justify-items: center;
  gap: 5px;
  text-align: center;
  cursor: pointer;
}

.roster-player strong {
  width: 100%;
  color: var(--ink);
  font-size: 11px;
  font-weight: 550;
  line-height: 1.12;
}

.roster-avatar-wrap {
  position: relative;
  width: 50px;
  height: 50px;
}

.roster-avatar {
  width: 50px;
  height: 50px;
  display: grid;
  place-items: center;
  border: 2px solid #fff;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--green), var(--blue));
  background-position: center;
  background-size: cover;
  color: #fff;
  font-size: 15px;
  font-weight: 850;
  box-shadow: 0 6px 14px rgba(24, 38, 30, 0.12);
}

.roster-avatar.has-image {
  color: transparent;
}

.rating-badge {
  position: absolute;
  right: -10px;
  top: -6px;
  min-width: 34px;
  padding: 4px 6px;
  border: 2px solid #fff;
  border-radius: 999px;
  background: #37bf5a;
  color: #fff;
  font-size: 11px;
  font-weight: 750;
  line-height: 1;
  box-shadow: 0 5px 12px rgba(21, 111, 53, 0.22);
}

.roster-empty {
  margin: 3px 0 10px;
  padding: 9px 10px;
  border: 1px dashed #cfe1d3;
  border-radius: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 450;
}

.card-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.primary,
.secondary {
  min-height: 38px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 650;
}

.primary {
  border: 0;
  background: var(--green);
  color: #fff;
}

.secondary {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

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

.leader-row {
  padding: 13px;
}

.rank {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-weight: 900;
}

.leader-main {
  flex: 1;
  min-width: 0;
}

.leader-main strong,
.leader-main span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leader-main span,
.score span,
.profile-card p {
  color: var(--muted);
  font-size: 13px;
}

.score {
  text-align: right;
}

.score strong {
  display: block;
  font-size: 18px;
}

.profile-card {
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 22px;
  text-align: center;
}

.avatar,
.small-avatar {
  width: 76px;
  height: 76px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--green), var(--blue));
  background-position: center;
  background-size: cover;
  color: #fff;
  font-size: 24px;
  font-weight: 950;
}

.avatar.has-image,
.small-avatar.has-image {
  color: transparent;
}

.small-avatar {
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  font-size: 15px;
}

.profile-avatar-note {
  max-width: 240px;
}

.stats-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.stats-grid div {
  min-width: 0;
  padding: 12px 8px;
  border-radius: 8px;
  background: #eef5ec;
}

.stats-grid strong,
.stats-grid span {
  display: block;
}

.stats-grid strong {
  font-size: 18px;
}

.stats-grid span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.round-card {
  padding: 14px;
}

.round-title {
  margin-bottom: 10px;
  color: var(--green);
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
}

.back-button {
  min-height: 42px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 850;
}

.detail-card {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 10px 26px rgba(24, 38, 30, 0.08);
}

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

.participant-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  cursor: pointer;
}

.player-detail-card {
  margin-top: 2px;
}

.participant-main {
  flex: 1;
  min-width: 0;
}

.participant-main strong,
.participant-main span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.participant-main span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.participant-number {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #eef5ec;
  color: var(--green);
  font-weight: 950;
}

.match-row {
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.match-row:first-of-type {
  border-top: 0;
}

.match-players {
  min-width: 0;
  font-weight: 800;
}

.match-players span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.winner {
  color: var(--green);
  font-size: 13px;
  font-weight: 850;
}

.empty-state {
  padding: 18px;
  border: 1px dashed #bccabe;
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.tabbar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  width: min(100%, 520px);
  margin: 0 auto;
  padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(20, 32, 27, 0.08);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(18px);
}

.tabbar.has-admin {
  grid-template-columns: repeat(5, 1fr);
}

.tab {
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.tab.is-active {
  background: var(--ink);
  color: #fff;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 86px;
  left: 16px;
  width: min(488px, calc(100% - 32px));
  margin: 0 auto;
  padding: 13px 14px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  text-align: center;
  box-shadow: var(--shadow);
}

.admin-panel {
  display: grid;
  gap: 12px;
}

.admin-card,
.standing-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 10px 26px rgba(24, 38, 30, 0.08);
}

.admin-card {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.admin-card header,
.admin-match-head,
.standing-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.admin-card h3 {
  margin: 0;
  font-size: 17px;
  line-height: 1.2;
}

.admin-card p,
.admin-card span,
.standing-row span {
  color: var(--muted);
  font-size: 12px;
}

.admin-actions {
  display: grid;
  gap: 8px;
}

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

.admin-match:first-of-type {
  padding-top: 0;
  border-top: 0;
}

.admin-match-head strong {
  min-width: 0;
  font-size: 13px;
}

.admin-result-grid {
  display: grid;
  grid-template-columns: 1fr 58px 58px 1fr;
  gap: 7px;
}

.admin-result-grid input {
  min-width: 0;
  height: 36px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
}

.standing-row {
  padding: 10px 12px;
}

.standing-main {
  min-width: 0;
}

.standing-main strong {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.standing-points {
  flex: 0 0 auto;
  color: var(--green);
  font-weight: 850;
}

@media (max-width: 380px) {
  .app-shell {
    padding-right: 12px;
    padding-left: 12px;
  }

  .hero-panel {
    padding: 18px;
  }

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