:root {
  color-scheme: dark;
  --bg: #08111f;
  --bg-soft: #0f1a2c;
  --panel: rgba(14, 22, 38, 0.9);
  --panel-strong: #12203a;
  --text: #f3f6fb;
  --muted: #95a4be;
  --brand: #74d2ff;
  --brand-strong: #3ca6ff;
  --accent: #8ef0b3;
  --danger: #ff7b8b;
  --border: rgba(255, 255, 255, 0.09);
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.35);
  --radius: 24px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(116, 210, 255, 0.18), transparent 30%),
    radial-gradient(circle at bottom right, rgba(142, 240, 179, 0.12), transparent 35%),
    linear-gradient(180deg, #050a12 0%, var(--bg) 45%, #060d18 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
textarea {
  font: inherit;
}

.app-shell {
  max-width: 980px;
  margin: 0 auto;
  padding: calc(18px + env(safe-area-inset-top)) calc(14px + env(safe-area-inset-right)) calc(28px + env(safe-area-inset-bottom)) calc(14px + env(safe-area-inset-left));
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.top1-logo {
  display: inline-flex;
  align-items: center;
  gap: 0.05em;
  font-family: Inter, Arial, Helvetica, sans-serif;
  font-size: clamp(2rem, 6vw, 5rem);
  font-weight: 900;
  line-height: 1;
  text-decoration: none;
  letter-spacing: -0.08em;
}

.top1-logo__top {
  color: #ffffff;
}

.top1-logo__one {
  color: #f5b700;
  font-style: italic;
  transform: translateY(-0.02em);
}

.topbar h1 {
  flex: 1 1 auto;
  min-width: 0;
  font-size: clamp(1.1rem, 3vw, 1.7rem);
}

body[data-view="landing"] .topbar {
  justify-content: flex-start;
}

body[data-view="landing"] .topbar h1,
body[data-view="landing"] .admin-link {
  display: none;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--brand);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
  font-weight: 700;
}

h1 {
  margin: 0;
  font-size: clamp(1.35rem, 4vw, 2.2rem);
  line-height: 1.05;
}

.admin-link,
.ghost-button,
.primary-button,
.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease, opacity 160ms ease;
}

.admin-link:hover,
.ghost-button:hover,
.primary-button:hover,
.danger-button:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.18);
}

.primary-button {
  background: linear-gradient(135deg, var(--brand-strong), var(--brand));
  color: #03101c;
  font-weight: 800;
  border: 0;
  box-shadow: 0 10px 30px rgba(60, 166, 255, 0.25);
}

.primary-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.danger-button {
  border-color: rgba(255, 123, 139, 0.3);
  background: rgba(255, 123, 139, 0.08);
  color: #ffd4db;
}

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

.hero-card,
.panel {
  background: linear-gradient(180deg, rgba(19, 28, 48, 0.95), rgba(11, 18, 32, 0.95));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hero-card {
  padding: 18px;
}

.hero-copy {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
  text-align: center;
}

.hero-copy p,
.subtle {
  margin: 0;
  color: var(--muted);
}

.event-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.92rem;
}

.chip-warning {
  border-color: rgba(255, 196, 92, 0.25);
  background: rgba(255, 196, 92, 0.1);
  color: #ffe6b3;
}

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

.player-tile {
  position: relative;
  overflow: hidden;
  border-radius: 22px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
  min-height: 168px;
  padding: 14px;
  text-align: left;
  color: var(--text);
  cursor: pointer;
  display: grid;
  gap: 12px;
}

.player-tile.selected {
  outline: 2px solid var(--brand);
  box-shadow: 0 0 0 6px rgba(60, 166, 255, 0.12);
}

.player-photo {
  position: relative;
  height: 170px;
  background: linear-gradient(135deg, rgba(116, 210, 255, 0.18), rgba(142, 240, 179, 0.12));
}

.player-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.player-photo .fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: rgba(255, 255, 255, 0.88);
}

.player-topline {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 8px;
}

.player-number {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(116, 210, 255, 0.14);
  border: 1px solid rgba(116, 210, 255, 0.22);
  color: var(--text);
  font-weight: 800;
}

.player-body {
  display: grid;
  gap: 6px;
  align-content: end;
}

.player-name {
  font-size: 1.02rem;
  font-weight: 800;
}

.player-team {
  color: var(--muted);
  font-size: 0.88rem;
}

.player-votes {
  color: var(--muted);
  font-size: 0.88rem;
}

.team-section {
  display: grid;
  gap: 12px;
  padding: 14px;
  border-radius: 22px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
}

.team-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
}

.team-header h2,
.team-editor-header h3 {
  margin: 0;
}

.team-editor {
  display: grid;
  gap: 16px;
  padding: 16px;
  border-radius: 22px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
}

.team-editor.is-hidden {
  display: none;
}

.team-editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.team-players {
  display: grid;
  gap: 10px;
}

.team-player-row {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.schedule-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.schedule-field input[type="datetime-local"] {
  width: 100%;
}

.jersey-badge {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  padding: 8px 10px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 900;
  gap: 2px;
}

.jersey-badge span {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.jersey-badge.goalkeeper {
  background: rgba(255, 196, 92, 0.1);
  border-color: rgba(255, 196, 92, 0.2);
}

.action-bar,
.summary-bar {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: grid;
  gap: 12px;
  padding: 12px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  margin: 0 -14px -28px;
  background: linear-gradient(180deg, rgba(6, 13, 24, 0), rgba(6, 13, 24, 0.88) 18%, rgba(6, 13, 24, 0.98));
  backdrop-filter: blur(12px);
}

.summary-card,
.form-card,
.event-card {
  padding: 16px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
}

.summary-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.summary-card strong {
  display: block;
  margin-top: 4px;
}

.stack {
  display: grid;
  gap: 12px;
}

.form-grid {
  display: grid;
  gap: 12px;
}

.field {
  display: grid;
  gap: 8px;
}

.field label {
  font-size: 0.92rem;
  color: var(--muted);
}

.field input,
.field textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  padding: 13px 14px;
  outline: none;
  font-size: 16px;
}

.field input:focus,
.field textarea:focus {
  border-color: rgba(116, 210, 255, 0.45);
  box-shadow: 0 0 0 4px rgba(116, 210, 255, 0.1);
}

.player-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  align-items: center;
}

.player-row button {
  min-height: 46px;
}

.event-list {
  display: grid;
  gap: 12px;
}

.event-card {
  display: grid;
  gap: 10px;
}

.event-card header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.event-card h2,
.event-card h3 {
  margin: 0;
}

.event-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.winner-banner {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 14px;
  align-items: center;
  padding: 16px;
  border-radius: 22px;
  background: linear-gradient(135deg, rgba(142, 240, 179, 0.18), rgba(116, 210, 255, 0.12));
  border: 1px solid rgba(142, 240, 179, 0.28);
}

.results-panel {
  padding: 14px;
}

.results-layout {
  display: grid;
  gap: 14px;
}

.results-chart-card,
.results-table-card {
  display: grid;
  gap: 14px;
  padding: 16px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
}

.results-section-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  flex-wrap: wrap;
}

.results-section-header h2 {
  margin: 0;
}

.pie-chart {
  position: relative;
  width: min(100%, 320px);
  aspect-ratio: 1;
  margin: 4px auto 0;
  border-radius: 50%;
  overflow: hidden;
  background: var(--pie-gradient, conic-gradient(from 0deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.1)));
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.12),
    0 12px 30px rgba(0, 0, 0, 0.18);
}

.pie-chart::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  pointer-events: none;
}

.pie-chart.single {
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.06),
    0 12px 30px rgba(0, 0, 0, 0.18);
}

.pie-chart.single::before {
  box-shadow: none;
}

.pie-chart.empty {
  background: radial-gradient(circle at center, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03));
}

.pie-chart::after {
  content: "";
  position: absolute;
  inset: 20px;
  border-radius: 50%;
  background: rgba(8, 17, 31, 0.82);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.pie-chart__labels {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.pie-chart__segment-label {
  position: absolute;
  top: 50%;
  left: 50%;
  color: #f8fbff;
  font-size: 0.9rem;
  font-weight: 800;
  line-height: 1;
  transform:
    translate(-50%, -50%) rotate(var(--label-angle)) translateX(var(--label-distance)) rotate(calc(var(--label-angle) * -1));
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.35);
  white-space: nowrap;
}

.pie-chart__center {
  position: absolute;
  inset: 50%;
  z-index: 2;
  display: grid;
  place-items: center;
  gap: 2px;
  width: 120px;
  height: 120px;
  transform: translate(-50%, -50%);
  text-align: center;
}

.pie-chart__center strong {
  font-size: 2rem;
  line-height: 1;
}

.pie-chart__center span {
  color: var(--muted);
  font-size: 0.9rem;
}

.chart-legend {
  display: grid;
  gap: 10px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.chart-legend__item {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.chart-legend__swatch {
  width: 12px;
  height: 12px;
  margin-top: 4px;
  border-radius: 999px;
}

.chart-legend__label {
  display: grid;
  gap: 2px;
}

.chart-legend__label strong {
  font-size: 0.94rem;
}

.chart-legend__label span {
  color: var(--muted);
  font-size: 0.86rem;
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.results-table {
  width: 100%;
  border-collapse: collapse;
}

.results-table th,
.results-table td {
  padding: 12px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  text-align: left;
  vertical-align: top;
}

.results-table th {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.results-table tbody tr:last-child td {
  border-bottom: 0;
}

.player-number-table {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--swatch) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--swatch) 30%, transparent);
  color: var(--text);
  font-weight: 800;
}

.table-player-name {
  font-weight: 800;
}

.table-player-meta {
  color: var(--muted);
  font-size: 0.76rem;
  margin-top: 2px;
}

.winner-banner img,
.winner-avatar {
  width: 88px;
  height: 88px;
  border-radius: 22px;
  object-fit: cover;
  background: rgba(255, 255, 255, 0.08);
}

.winner-avatar {
  display: grid;
  place-items: center;
  font-size: 2rem;
  font-weight: 900;
}

.status-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 0.92rem;
}

.vote-count-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.vote-burst {
  position: absolute;
  top: -14px;
  right: -16px;
  padding: 3px 8px;
  border-radius: 999px;
  background: linear-gradient(135deg, #f5b700, #ffe08a);
  color: #0f172a;
  font-size: 0.78rem;
  font-weight: 900;
  box-shadow: 0 10px 24px rgba(245, 183, 0, 0.22);
  animation: voteBurstPop 900ms ease-out forwards;
  pointer-events: none;
}

.vote-burst--presence {
  background: linear-gradient(135deg, #8ef0b3, #d4ffd9);
  box-shadow: 0 10px 24px rgba(142, 240, 179, 0.22);
}

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

.vote-stat {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
}

.vote-stat__label {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.vote-stat__value {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  font-size: 1.75rem;
  font-weight: 900;
  line-height: 1;
}

@keyframes voteBurstPop {
  0% {
    transform: translateY(10px) scale(0.5);
    opacity: 0;
  }

  18% {
    opacity: 1;
  }

  48% {
    transform: translateY(-3px) scale(1.08);
    opacity: 1;
  }

  100% {
    transform: translateY(-18px) scale(0.92);
    opacity: 0;
  }
}

.empty-state {
  padding: 18px;
  border-radius: 22px;
  border: 1px dashed rgba(255, 255, 255, 0.18);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.02);
}

.notice {
  color: var(--muted);
  font-size: 0.92rem;
}

.landing-card {
  max-width: 520px;
  margin: 0 auto;
}

.landing-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.landing-matchday-section {
  display: grid;
}

.landing-matchday-panel {
  display: grid;
  gap: 10px;
  padding: 18px;
  border-radius: 22px;
  background: linear-gradient(135deg, rgba(116, 210, 255, 0.14), rgba(142, 240, 179, 0.12));
  border: 1px solid rgba(116, 210, 255, 0.24);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.18);
  margin-bottom: 2px;
}

.landing-matchday-panel .eyebrow {
  color: var(--accent);
}

.landing-matchday-panel strong {
  font-size: 1.2rem;
  line-height: 1.15;
}

.landing-matchday-panel span:nth-of-type(2) {
  color: var(--text);
  font-size: 0.98rem;
}

.landing-matchday-panel span:last-child {
  color: var(--muted);
  font-size: 0.9rem;
}

.landing-matchday-button {
  width: 100%;
  min-height: 52px;
  margin-top: 6px;
}

.landing-form input {
  min-height: 60px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  padding: 0 18px;
  font-size: 1.4rem;
  letter-spacing: 0.28em;
  text-align: center;
  text-transform: lowercase;
}

.landing-form input::placeholder {
  color: rgba(149, 164, 190, 0.6);
  letter-spacing: 0.35em;
}

.landing-form input:focus {
  outline: 2px solid rgba(116, 210, 255, 0.32);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (min-width: 760px) {
  .app-shell {
    padding: 24px 20px 36px;
  }

  .hero-card,
  .panel {
    padding: 22px;
  }

  .action-bar,
  .summary-bar {
    margin-left: 0;
    margin-right: 0;
    border-radius: 24px;
  }

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

  .player-row {
    grid-template-columns: 1fr 1fr auto;
  }

  .team-player-row {
    grid-template-columns: 92px minmax(0, 1fr);
  }

  .schedule-control {
    grid-template-columns: minmax(0, 1fr) auto;
  }
}