:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
  --ink: #122225;
  --muted: #68787a;
  --surface: #ffffff;
  --background: #f3f7f6;
  --teal: #0a7b72;
  --teal-dark: #065f59;
  --teal-soft: #dff2ef;
  --blue: #3478c8;
  --blue-soft: #e7f0fb;
  --line: #dce6e4;
  --danger: #bd3b43;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--background);
  color: var(--ink);
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}

button, input, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px max(20px, env(safe-area-inset-left));
  background: linear-gradient(145deg, #eff9f7, #fff);
  border-bottom: 1px solid var(--line);
}

h1, h2, p { margin: 0; }
h1 { font-size: 32px; letter-spacing: -1px; }
h2 { font-size: 20px; letter-spacing: -.35px; }
.eyebrow { color: var(--teal); font-size: 11px; font-weight: 800; letter-spacing: 1.5px; }

.icon-button, .close-button {
  border: 0;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  font-size: 30px;
  line-height: 1;
  color: white;
  background: var(--teal);
}

main { max-width: 760px; margin: 0 auto; padding: 18px 16px 124px; }

.summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 7px 24px rgba(27, 67, 63, .07);
  overflow: hidden;
}

.summary div { text-align: center; padding: 16px 6px; border-right: 1px solid var(--line); }
.summary div:last-child { border-right: 0; }
.summary strong { display: block; font-size: 23px; }
.summary span { color: var(--muted); font-size: 12px; }

.toolbar { display: flex; justify-content: space-between; align-items: center; margin: 24px 4px 10px; }
.text-button { border: 0; color: var(--teal); background: transparent; font-weight: 650; padding: 8px 0; }

.player-list { display: grid; gap: 10px; }
.player-row {
  display: grid;
  grid-template-columns: 34px minmax(90px, 1fr) auto 34px;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 15px;
}
.player-row.absent { opacity: .61; }

.presence-control input { position: absolute; opacity: 0; }
.checkmark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 2px solid #a9bab7;
  border-radius: 9px;
  color: transparent;
}
.presence-control input:checked + .checkmark { background: var(--teal); border-color: var(--teal); color: white; }

.name-input { width: 100%; border: 0; outline: 0; color: var(--ink); font-weight: 650; font-size: 16px; background: transparent; }
.strength-control { display: flex; flex-direction: column; color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .5px; }
.strength-input { border: 0; border-radius: 9px; background: var(--teal-soft); color: var(--teal-dark); font-size: 16px; font-weight: 800; padding: 5px 9px; }
.delete-button { border: 0; background: transparent; color: #91a09e; font-size: 25px; padding: 0; }

.empty-state { text-align: center; padding: 58px 20px; color: var(--muted); }
.empty-state h2 { color: var(--ink); margin: 14px 0 7px; }
.empty-state p { line-height: 1.45; max-width: 340px; margin: 0 auto 20px; }
.ball { display: grid; place-items: center; margin: auto; width: 62px; height: 62px; border-radius: 50%; color: white; background: var(--teal); font-size: 28px; }

.split-bar {
  position: fixed;
  z-index: 4;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: rgba(243, 247, 246, .9);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}

.primary-button, .secondary-button {
  display: block;
  width: min(100%, 728px);
  margin: 0 auto;
  border: 0;
  border-radius: 14px;
  padding: 14px 18px;
  font-weight: 750;
}
.primary-button { background: var(--teal); color: white; box-shadow: 0 8px 18px rgba(10, 123, 114, .2); }
.primary-button small { display: block; margin-top: 2px; opacity: .75; font-weight: 500; }
.primary-button:disabled { background: #9daaa8; box-shadow: none; }
.secondary-button { background: var(--teal-soft); color: var(--teal-dark); }

dialog { border: 0; width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; padding: 0; background: var(--background); }
dialog::backdrop { background: rgba(10, 30, 29, .25); }
.result-shell { max-width: 760px; margin: auto; padding: calc(28px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom)); }
.result-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.result-heading h2 { font-size: 30px; margin-top: 3px; }
.close-button { background: #e2e9e8; color: var(--ink); }
.quality-badge { text-align: center; padding: 9px; color: var(--teal-dark); background: var(--teal-soft); border-radius: 12px; font-weight: 700; margin-bottom: 14px; }
.teams-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.team-card { background: white; border: 1px solid var(--line); border-radius: 18px; overflow: hidden; }
.team-card header { display: flex; justify-content: space-between; align-items: center; padding: 15px; font-size: 12px; font-weight: 850; letter-spacing: 1px; }
.team-card header strong { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; font-size: 17px; }
.team-a header { background: var(--teal-soft); color: var(--teal-dark); }
.team-a header strong { background: var(--teal); color: white; }
.team-b header { background: var(--blue-soft); color: #245b98; }
.team-b header strong { background: var(--blue); color: white; }
.team-card ol { list-style: none; margin: 0; padding: 4px 14px 14px; }
.team-card li { display: flex; justify-content: space-between; gap: 8px; padding: 12px 2px; border-bottom: 1px solid var(--line); font-weight: 650; }
.team-card li:last-child { border-bottom: 0; }
.team-card li span { color: var(--muted); font-weight: 700; }
#reroll { margin-bottom: 10px; }

@media (max-width: 480px) {
  .teams-grid { grid-template-columns: 1fr; }
  .player-row { grid-template-columns: 32px minmax(75px, 1fr) auto 28px; gap: 7px; }
}

@media (prefers-reduced-motion: no-preference) {
  .player-row { animation: appear .18s ease-out; }
  @keyframes appear { from { opacity: 0; transform: translateY(4px); } }
}
