/* ==================== BASE ==================== */
:root {
  --bg: #0d0d0d;
  --surface: #1a1a1a;
  --surface2: #2a2a2a;
  --border: #3a3a3a;
  --button-surface: #171925;
  --button-surface-soft: #202333;
  --primary: #d600e6;
  --primary-dark: #b000c0;
  --primary-glow: rgba(214, 0, 230, 0.15);
  --accent: #ff00ff;
  --gradient-start: #8c1dff;
  --gradient-mid: #d100f7;
  --gradient-end: #ff00a8;
  --gradient-line: linear-gradient(135deg, var(--gradient-start) 0%, var(--gradient-mid) 52%, var(--gradient-end) 100%);
  --danger: #ff5f6d;
  --danger-dark: #d74250;
  --warning: #ffb020;
  --text: #f5f5f5;
  --text-dim: #888888;
  --gold: #ffd700;
  --silver: #c0c0c0;
  --bronze: #cd7f32;
  --green: #00e676;
  --radius: 14px;
  --safe-top: env(safe-area-inset-top, 20px);
  --safe-bottom: env(safe-area-inset-bottom, 20px);
}

html {
  background: var(--bg);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

button, input, select, textarea, a, [onclick] {
  -webkit-appearance: none;
  touch-action: manipulation;
  cursor: pointer;
}

input[type="text"],
input[type="number"] {
  -webkit-appearance: none;
  appearance: none;
  cursor: text;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

body.modal-open {
  overflow: hidden;
}

body.license-locked {
  overflow: hidden;
}

#app {
  max-width: 760px;
  margin: 0 auto;
  padding: var(--safe-top) 16px var(--safe-bottom);
  padding-bottom: calc(var(--safe-bottom) + 20px);
  transition: filter 0.25s ease, opacity 0.25s ease;
}

#display-app {
  display: none;
}

body.view-display #app {
  display: none;
}

body.view-display #display-app {
  display: block;
}

body.license-locked #app {
  pointer-events: none;
  user-select: none;
  filter: blur(14px) saturate(0.7);
  opacity: 0.28;
}

/* ==================== SCREENS ==================== */
.screen { display: none; }
.screen.active { display: block; animation: fadeIn 0.25s ease; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==================== HEADER ==================== */
.header {
  text-align: center;
  padding: 20px 0 16px;
  position: relative;
}

.header h1 {
  font-size: clamp(30px, 5vw, 40px);
  font-weight: 900;
  letter-spacing: 0.02em;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: 0 10px 30px rgba(214, 0, 230, 0.18);
}

.subtitle {
  color: var(--text-dim);
  font-size: 14px;
  margin-top: 6px;
  max-width: 34rem;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.5;
}

.tournament-header {
  padding-top: 28px;
}

.back-btn {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  background:
    linear-gradient(180deg, rgba(20, 22, 33, 0.98), rgba(13, 13, 13, 0.98)) padding-box,
    var(--gradient-line) border-box;
  border: 1px solid transparent;
  color: white;
  font-size: 22px;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.28);
}

.icon-btn {
  position: absolute;
  right: 0;
  top: 24px;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  border: 1px solid transparent;
  background:
    linear-gradient(180deg, rgba(20, 22, 33, 0.98), rgba(13, 13, 13, 0.98)) padding-box,
    var(--gradient-line) border-box;
  color: #ff3cdb;
  font-size: 18px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.25);
}

.header-actions {
  position: absolute;
  right: 0;
  top: 20px;
  display: flex;
  gap: 10px;
}

.header-actions .icon-btn {
  position: static;
}

.icon-btn-secondary {
  color: white;
  font-size: 13px;
  letter-spacing: 0.08em;
}

/* ==================== CARD ==================== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

/* ==================== FORM ==================== */
.form-group {
  margin-bottom: 20px;
}

.form-group.compact {
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.form-group.compact label {
  min-width: 80px;
  font-size: 14px;
  margin-bottom: 0;
}

.form-group.compact input {
  flex: 1;
}

.form-group label {
  display: block;
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}

.form-group small {
  display: block;
  color: var(--text-dim);
  font-size: 12px;
  margin-top: 6px;
}

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

.mode-option {
  width: 100%;
  text-align: left;
  background:
    linear-gradient(180deg, rgba(29, 31, 44, 0.98), rgba(18, 19, 29, 0.98)) padding-box,
    linear-gradient(135deg, rgba(185, 70, 255, 0.18), rgba(255, 0, 168, 0.08)) border-box;
  border: 1px solid transparent;
  border-radius: 14px;
  padding: 16px;
  color: var(--text);
  transition: transform 0.15s ease, box-shadow 0.2s ease, filter 0.2s ease;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.14);
}

.mode-option:active {
  transform: scale(0.985);
}

.mode-option.active {
  background:
    linear-gradient(180deg, rgba(29, 31, 44, 0.98), rgba(18, 19, 29, 0.98)) padding-box,
    var(--gradient-line) border-box;
  box-shadow: 0 0 0 1px rgba(214, 0, 230, 0.14), 0 18px 34px rgba(214, 0, 230, 0.16);
  filter: saturate(1.08);
}

.mode-option-title {
  display: block;
  font-size: 16px;
  font-weight: 800;
  margin-bottom: 6px;
}

.mode-option-text {
  display: block;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-dim);
}

.court-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.court-field {
  background: rgba(42, 42, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 12px;
}

.court-field label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
}

.court-field select {
  margin-top: 8px;
}

input[type="text"],
input[type="number"],
select {
  width: 100%;
  padding: 12px 16px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s;
  cursor: pointer;
}

select {
  padding-right: 40px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--accent) 50%),
    linear-gradient(135deg, var(--accent) 50%, transparent 50%);
  background-position:
    calc(100% - 20px) calc(50% - 2px),
    calc(100% - 14px) calc(50% - 2px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

input:focus,
select:focus {
  border-color: var(--primary);
}

/* ==================== STEPPER ==================== */
.stepper {
  display: flex;
  align-items: center;
  gap: 12px;
}

.stepper input {
  text-align: center;
  width: 80px;
  font-size: 22px;
  font-weight: 700;
}

.stepper input[readonly] {
  cursor: default;
}

.stepper input:disabled {
  opacity: 0.65;
}

.stepper-btn {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  border: 1px solid transparent;
  background:
    linear-gradient(135deg, rgba(140, 29, 255, 0.98), rgba(255, 0, 168, 0.98)) padding-box,
    linear-gradient(135deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.02)) border-box;
  color: white;
  font-size: 24px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, filter 0.15s;
  box-shadow: 0 16px 32px rgba(143, 28, 255, 0.22);
}

.stepper-btn:active {
  transform: scale(0.95);
  filter: brightness(0.92);
}

.stepper-btn:disabled {
  opacity: 0.4;
  transform: none;
}

/* ==================== BUTTONS ==================== */
.btn {
  position: relative;
  padding: 14px 24px;
  border-radius: 18px;
  border: 1px solid transparent;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s ease, filter 0.2s ease;
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.18);
}

.btn:active {
  transform: scale(0.97);
}

.btn.primary {
  background:
    linear-gradient(96deg, var(--gradient-start) 0%, var(--gradient-mid) 48%, var(--gradient-end) 100%) padding-box,
    linear-gradient(135deg, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0.08)) border-box;
  color: white;
  box-shadow: 0 18px 34px rgba(201, 0, 242, 0.28);
}

.btn.primary:active {
  filter: brightness(0.92);
}

.btn.secondary {
  background:
    linear-gradient(180deg, rgba(24, 26, 39, 0.98), rgba(18, 19, 29, 0.98)) padding-box,
    var(--gradient-line) border-box;
  color: white;
}

.btn.ghost {
  background:
    linear-gradient(180deg, rgba(19, 21, 32, 0.98), rgba(13, 14, 21, 0.98)) padding-box,
    linear-gradient(135deg, rgba(140, 29, 255, 0.7), rgba(255, 0, 168, 0.9)) border-box;
  color: white;
}

.btn.accent {
  background:
    linear-gradient(96deg, #6a2dff 0%, #ff00a8 100%) padding-box,
    linear-gradient(135deg, rgba(255, 255, 255, 0.24), rgba(255, 255, 255, 0.04)) border-box;
  color: white;
  box-shadow: 0 18px 34px rgba(190, 0, 214, 0.22);
}

.btn.danger {
  background:
    linear-gradient(96deg, #ff4c78 0%, #ff7b54 100%) padding-box,
    linear-gradient(135deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0.04)) border-box;
  color: white;
}

.btn.danger:active {
  filter: brightness(0.92);
}

.btn.full {
  width: 100%;
  display: block;
}

/* ==================== TABS ==================== */
.tab-bar {
  display: flex;
  gap: 4px;
  background: linear-gradient(180deg, rgba(31, 33, 48, 0.96), rgba(22, 23, 34, 0.98));
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 18px;
  padding: 4px;
  margin-top: 12px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.tab {
  flex: 1;
  padding: 10px;
  border: none;
  background: transparent;
  color: #ff3cdb;
  font-size: 14px;
  font-weight: 700;
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.tab.active {
  background: linear-gradient(96deg, var(--gradient-start) 0%, var(--gradient-mid) 52%, var(--gradient-end) 100%);
  color: white;
  box-shadow: 0 10px 22px rgba(203, 0, 233, 0.3);
}

.tab-content { display: none; padding-top: 16px; }
.tab-content.active { display: block; }

/* ==================== ROUND ==================== */
.round-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.round-header h2 {
  font-size: 20px;
  font-weight: 700;
}

.badge {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.badge.active {
  background: var(--primary-glow);
  color: var(--primary);
}

.badge.completed {
  background: rgba(0, 230, 118, 0.15);
  color: var(--green);
}

/* ==================== MATCH CARD ==================== */
.match-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.court-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid transparent;
  background:
    linear-gradient(180deg, rgba(19, 21, 32, 0.98), rgba(13, 14, 21, 0.98)) padding-box,
    var(--gradient-line) border-box;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  color: white;
  letter-spacing: 1px;
  margin-bottom: 12px;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.16);
}

button.court-label {
  appearance: none;
}

.court-label.editable::after {
  content: 'Bearbeiten';
  font-size: 10px;
  letter-spacing: 0.05em;
  color: rgba(255, 55, 223, 0.95);
}

.match-teams {
  display: flex;
  align-items: center;
  gap: 8px;
}

.team {
  flex: 1;
  text-align: center;
}

.team-players {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}

.player-chip {
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.vs {
  font-size: 14px;
  font-weight: 800;
  color: var(--text-dim);
  flex-shrink: 0;
}

.score-input {
  width: 80px !important;
  text-align: center;
  font-size: 20px !important;
  font-weight: 800;
  padding: 10px 4px !important;
  background: var(--surface2);
  border: 2px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  margin: 0 auto;
  display: block;
  -moz-appearance: textfield;
  cursor: text;
}

.score-picker {
  cursor: pointer;
}

.score-input::-webkit-outer-spin-button,
.score-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.score-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.score-input:disabled {
  opacity: 0.5;
}

/* ==================== ROUND ACTIONS ==================== */
.round-actions {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.management-card {
  margin-top: 16px;
}

.management-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 6px;
}

.management-text {
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 14px;
}

.management-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.license-summary {
  background: linear-gradient(180deg, rgba(214, 0, 230, 0.12), rgba(42, 42, 42, 0.9));
  border: 1px solid rgba(214, 0, 230, 0.18);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 14px;
}

.license-summary strong {
  display: block;
  font-size: 14px;
  margin-bottom: 6px;
}

.license-summary p {
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.5;
}

.license-summary p + p {
  margin-top: 4px;
}

.warning-text {
  color: var(--warning);
}

/* ==================== RANKING ==================== */
.ranking-board {
  padding: 16px 18px;
}

.ranking-topline {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 12px;
}

.ranking-topline h3 {
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 4px;
}

.ranking-topline p,
.ranking-hint {
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.45;
}

.ranking-table-head {
  display: grid;
  grid-template-columns: 58px 76px minmax(0, 1fr) 72px;
  gap: 10px;
  padding: 0 0 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.ranking-table {
  display: grid;
}

.ranking-row {
  display: grid;
  grid-template-columns: 58px 76px minmax(0, 1fr) 72px;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.ranking-row:last-child {
  border-bottom: none;
}

.rank-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  padding: 8px 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 15px;
  font-weight: 900;
  color: white;
}

.rank-name {
  min-width: 0;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rank-points {
  font-size: 15px;
  font-weight: 800;
  color: var(--primary);
  text-align: right;
}

.rank-trend {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 62px;
  padding: 6px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.rank-trend.up {
  background: rgba(0, 230, 118, 0.14);
  color: var(--green);
}

.rank-trend.down {
  background: rgba(255, 95, 109, 0.16);
  color: #ff8792;
}

.rank-trend.flat,
.rank-trend.final {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-dim);
}

.top-1 .rank-pill {
  background: linear-gradient(180deg, rgba(255, 215, 0, 0.28), rgba(255, 215, 0, 0.12));
  border-color: rgba(255, 215, 0, 0.28);
}

.top-2 .rank-pill {
  background: linear-gradient(180deg, rgba(192, 192, 192, 0.26), rgba(192, 192, 192, 0.12));
  border-color: rgba(192, 192, 192, 0.26);
}

.top-3 .rank-pill {
  background: linear-gradient(180deg, rgba(205, 127, 50, 0.26), rgba(205, 127, 50, 0.12));
  border-color: rgba(205, 127, 50, 0.26);
}

/* ==================== PODIUM ==================== */
.podium {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 8px;
  padding: 30px 10px 20px;
}

.podium-place {
  text-align: center;
  flex: 1;
  max-width: 120px;
}

.podium-name {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.podium-points {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.podium-block {
  font-size: 24px;
  font-weight: 900;
  border-radius: 10px 10px 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

.first .podium-block {
  height: 100px;
  background: linear-gradient(180deg, var(--gold), #b8860b);
}

.first .podium-name { color: var(--gold); }

.second .podium-block {
  height: 70px;
  background: linear-gradient(180deg, var(--silver), #808080);
}

.second .podium-name { color: var(--silver); }

.third .podium-block {
  height: 50px;
  background: linear-gradient(180deg, var(--bronze), #8b4513);
}

.third .podium-name { color: var(--bronze); }

/* ==================== HISTORY ==================== */
.history-focus {
  background:
    radial-gradient(circle at top right, rgba(214, 0, 230, 0.18), transparent 32%),
    linear-gradient(180deg, rgba(42, 42, 42, 0.98), rgba(18, 18, 18, 1));
  border: 1px solid rgba(214, 0, 230, 0.18);
}

.history-focus-kicker {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--primary);
  margin-bottom: 10px;
}

.history-focus-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
}

.history-focus-head h3 {
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 4px;
}

.history-focus-head p {
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.5;
}

.history-round-grid {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.history-match-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 14px;
  padding: 14px;
}

.history-match-card .court-label {
  margin-bottom: 10px;
}

.history-match-teams {
  display: grid;
  gap: 8px;
}

.history-match-teams .player-chip {
  text-align: left;
}

.history-schedule {
  display: grid;
  gap: 12px;
}

.schedule-round {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.schedule-round.active {
  border-color: rgba(214, 0, 230, 0.35);
  box-shadow: 0 16px 32px rgba(214, 0, 230, 0.12);
}

.schedule-round.completed {
  border-color: rgba(0, 230, 118, 0.18);
}

.schedule-round.upcoming {
  border-color: rgba(255, 255, 255, 0.06);
}

.schedule-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.schedule-title {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.schedule-title h4 {
  font-size: 18px;
  font-weight: 800;
}

.schedule-title p {
  color: var(--text-dim);
  font-size: 13px;
}

.schedule-match-row {
  display: grid;
  grid-template-columns: auto 1fr auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

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

.schedule-team {
  font-size: 13px;
  line-height: 1.5;
}

.schedule-team strong {
  display: block;
  font-size: 14px;
  font-weight: 700;
}

.schedule-score {
  min-width: 72px;
  text-align: center;
  font-size: 13px;
  font-weight: 800;
  color: var(--primary);
}

.schedule-score.completed {
  color: var(--green);
}

.schedule-vs {
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.schedule-note {
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.55;
  padding-top: 4px;
}

.history-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.empty-text {
  color: var(--text-dim);
  text-align: center;
  padding: 20px;
}

/* ==================== DIALOG ==================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: rgba(5, 5, 12, 0.78);
  backdrop-filter: blur(10px);
  z-index: 999;
}

.modal-overlay.active {
  display: flex;
}

.modal-card {
  width: min(100%, 420px);
  background: linear-gradient(180deg, rgba(214, 0, 230, 0.1), rgba(26, 26, 26, 0.98));
  border: 1px solid rgba(214, 0, 230, 0.22);
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.45);
}

.modal-title {
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 10px;
}

.modal-message {
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.6;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 18px;
}

.score-pad-card {
  width: min(100%, 440px);
}

.score-pad-subtitle {
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: 14px;
}

.score-pad-display {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 88px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(24, 26, 39, 0.98), rgba(18, 19, 29, 0.98));
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 42px;
  font-weight: 900;
  color: white;
  margin-bottom: 16px;
}

.score-pad-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.score-pad-key {
  min-height: 68px;
  border-radius: 18px;
  border: 1px solid transparent;
  background:
    linear-gradient(180deg, rgba(20, 22, 33, 0.98), rgba(13, 13, 13, 0.98)) padding-box,
    var(--gradient-line) border-box;
  color: white;
  font-size: 28px;
  font-weight: 800;
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.22);
}

.score-pad-action,
.score-pad-confirm {
  font-size: 16px;
}

.score-pad-confirm {
  background:
    linear-gradient(96deg, var(--gradient-start) 0%, var(--gradient-mid) 48%, var(--gradient-end) 100%) padding-box,
    linear-gradient(135deg, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0.08)) border-box;
}

/* ==================== LICENSE OVERLAY ==================== */
.license-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: max(24px, var(--safe-top)) 16px max(24px, var(--safe-bottom));
  background:
    radial-gradient(circle at top, rgba(214, 0, 230, 0.25), transparent 38%),
    linear-gradient(180deg, rgba(5, 5, 12, 0.96), rgba(13, 13, 13, 0.98));
  z-index: 1200;
}

.license-overlay.active {
  display: flex;
}

.license-shell {
  width: min(100%, 440px);
}

.license-card {
  background: rgba(26, 26, 26, 0.94);
  border: 1px solid rgba(214, 0, 230, 0.22);
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.45);
}

.license-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(214, 0, 230, 0.15);
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 14px;
}

.license-title {
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 10px;
}

.license-text {
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.65;
}

.license-info {
  margin-top: 18px;
  margin-bottom: 18px;
  display: grid;
  gap: 10px;
}

.license-info-item {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
}

.license-info-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-bottom: 6px;
}

.license-info-value {
  font-size: 14px;
  line-height: 1.45;
  word-break: break-word;
}

.license-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
}

.license-field {
  width: 100%;
  padding: 14px 16px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: 16px;
  outline: none;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.license-field:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.license-error {
  min-height: 20px;
  color: #ff9aa5;
  font-size: 13px;
  line-height: 1.5;
}

.license-help {
  margin-top: 16px;
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.6;
}

.license-help a {
  color: var(--primary);
}

/* ==================== DISPLAY VIEW ==================== */
.display-shell {
  min-height: 100vh;
  min-height: 100dvh;
  padding: max(20px, var(--safe-top)) 20px max(20px, var(--safe-bottom));
  background:
    radial-gradient(circle at top right, rgba(214, 0, 230, 0.14), transparent 28%),
    radial-gradient(circle at top left, rgba(140, 29, 255, 0.18), transparent 24%),
    linear-gradient(180deg, #0d0d0d 0%, #12121b 100%);
}

.display-header-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.display-kicker {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 8px;
}

.display-header-bar h1 {
  font-size: clamp(34px, 5vw, 56px);
  font-weight: 900;
  line-height: 1.05;
}

.display-status-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.display-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.05);
  color: white;
  font-size: 13px;
  font-weight: 800;
}

.display-action-chip {
  cursor: pointer;
  background:
    linear-gradient(180deg, rgba(24, 26, 39, 0.98), rgba(18, 19, 29, 0.98)) padding-box,
    var(--gradient-line) border-box;
  border: 1px solid transparent;
}

.display-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(360px, 0.95fr);
  gap: 18px;
  align-items: stretch;
}

.display-panel {
  background: rgba(26, 26, 26, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 24px;
  padding: 18px;
  box-shadow: 0 22px 44px rgba(0, 0, 0, 0.22);
}

.display-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.display-section-head h2 {
  font-size: clamp(24px, 3vw, 34px);
  font-weight: 900;
  line-height: 1.1;
}

.display-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.display-badge.active {
  background: rgba(214, 0, 230, 0.16);
  color: #ff4fe8;
}

.display-badge.completed {
  background: rgba(0, 230, 118, 0.15);
  color: var(--green);
}

.display-badge.upcoming,
.display-badge.neutral {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-dim);
}

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

.display-match-card {
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(255, 255, 255, 0.035);
  padding: 16px;
}

.display-match-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
}

.display-team-block {
  display: grid;
  gap: 6px;
}

.display-team-block strong {
  font-size: 18px;
  font-weight: 800;
  line-height: 1.2;
}

.display-team-block span {
  font-size: 16px;
  color: var(--text-dim);
  line-height: 1.2;
}

.display-match-score {
  min-width: 74px;
  text-align: center;
  font-size: 20px;
  font-weight: 900;
  color: var(--primary);
}

.display-match-score.completed {
  color: var(--green);
}

.display-ranking-head,
.display-ranking-row {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) 80px 74px;
  gap: 10px;
  align-items: center;
}

.display-ranking-head {
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0 0 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.display-ranking-grid {
  display: grid;
  gap: 6px;
  padding-top: 10px;
}

.display-ranking-row {
  min-height: 42px;
  padding: 6px 0;
}

.display-rank-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  padding: 8px 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 15px;
  font-weight: 900;
}

.display-rank-name {
  min-width: 0;
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.display-rank-trend {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 32px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
}

.display-rank-trend.up {
  background: rgba(0, 230, 118, 0.14);
  color: var(--green);
}

.display-rank-trend.down {
  background: rgba(255, 95, 109, 0.16);
  color: #ff8792;
}

.display-rank-trend.flat {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-dim);
}

.display-rank-points {
  text-align: right;
  font-size: 16px;
  font-weight: 900;
  color: white;
}

.display-empty {
  min-height: calc(100vh - 80px);
  min-height: calc(100dvh - 80px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.display-empty .display-panel {
  width: min(100%, 640px);
  text-align: center;
}

.display-empty h2 {
  font-size: 34px;
  font-weight: 900;
  margin-bottom: 10px;
}

.display-empty p,
.display-note {
  color: var(--text-dim);
  font-size: 16px;
  line-height: 1.6;
}

/* ==================== PLAYER NAMES SCROLL ==================== */
#player-names-list {
  max-height: 55vh;
  overflow-y: auto;
  margin-bottom: 16px;
  padding-right: 4px;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 520px) {
  .court-grid {
    grid-template-columns: 1fr;
  }

  .match-teams {
    flex-direction: column;
    align-items: stretch;
  }

  .team {
    width: 100%;
  }

  .vs {
    padding: 2px 0;
  }

  .history-focus-head,
  .schedule-header {
    flex-direction: column;
    align-items: stretch;
  }

  .schedule-match-row {
    grid-template-columns: auto minmax(0, 1fr) auto minmax(0, 1fr) auto;
    gap: 6px;
  }

  .schedule-team {
    font-size: 12px;
  }

  .schedule-team strong {
    font-size: 13px;
  }

  .schedule-score {
    text-align: right;
    margin: 0;
    min-width: 54px;
    font-size: 12px;
  }

  .ranking-table-head,
  .ranking-row {
    grid-template-columns: 48px 64px minmax(0, 1fr) 60px;
  }

  .ranking-topline {
    display: block;
  }

  .ranking-hint {
    margin-top: 6px;
  }

  .display-header-bar,
  .display-section-head {
    flex-direction: column;
    align-items: stretch;
  }

  .display-layout,
  .display-match-grid {
    grid-template-columns: 1fr;
  }

  .display-ranking-head,
  .display-ranking-row {
    grid-template-columns: 48px minmax(0, 1fr) 64px 58px;
  }

  .display-team-block strong {
    font-size: 15px;
  }

  .display-team-block span {
    font-size: 13px;
  }
}

@media (max-width: 380px) {
  .player-chip { font-size: 11px; }
  .score-input { width: 70px !important; font-size: 18px !important; }
  .form-group.compact {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }

  .form-group.compact label {
    min-width: 0;
  }
}

@media (min-width: 900px) and (orientation: landscape) {
  #app {
    max-width: 1180px;
    padding-left: 28px;
    padding-right: 28px;
  }

  .header {
    padding: 14px 0 12px;
  }

  .tournament-header {
    padding-top: 18px;
  }

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

  .match-card {
    margin-bottom: 0;
    padding: 14px;
  }

  .player-chip {
    font-size: 12px;
    padding: 5px 8px;
  }

  .score-input {
    width: 68px !important;
    font-size: 19px !important;
    padding: 8px 4px !important;
  }

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

  .ranking-board {
    padding: 18px 20px;
  }

  .ranking-table {
    column-count: 2;
    column-gap: 18px;
  }

  .ranking-table-head,
  .ranking-row {
    grid-template-columns: 68px 92px minmax(0, 1fr) 90px;
  }

  .ranking-row {
    break-inside: avoid;
    padding: 7px 0;
  }

  .rank-name {
    font-size: 15px;
  }

  .display-shell {
    padding-left: 28px;
    padding-right: 28px;
  }
}
