:root {
  --ink: #17231d;
  --muted: #617067;
  --paper: #f4f1e8;
  --card: #fffdf7;
  --line: #d8ded5;
  --green: #126b47;
  --green-dark: #0a4b32;
  --lime: #d9ff64;
  --coral: #ff7657;
  --blue: #d8edff;
  --shadow: 0 18px 50px rgba(23, 35, 29, 0.11);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 8%, rgba(217, 255, 100, 0.28), transparent 28rem),
    radial-gradient(circle at 95% 35%, rgba(216, 237, 255, 0.7), transparent 28rem),
    var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.page-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

.hero {
  position: relative;
  overflow: hidden;
  margin: 24px 0;
  padding: clamp(28px, 6vw, 68px);
  color: white;
  border-radius: 32px;
  background: var(--green);
  box-shadow: var(--shadow);
}

.hero::after {
  position: absolute;
  right: -90px;
  bottom: -180px;
  width: 420px;
  height: 420px;
  border: 54px solid rgba(255, 255, 255, 0.09);
  border-radius: 50%;
  content: "";
}

.hero__eyebrow,
.kicker {
  display: block;
  margin-bottom: 7px;
  color: var(--green);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.hero__eyebrow {
  color: var(--lime);
}

.hero h1 {
  position: relative;
  z-index: 1;
  max-width: 780px;
  margin: 0;
  font-size: clamp(2.5rem, 7vw, 5.9rem);
  font-weight: 900;
  letter-spacing: -0.075em;
  line-height: 0.86;
}

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

.hero h1 strong {
  display: block;
  margin-top: 18px;
  color: var(--lime);
  font-size: 0.46em;
  letter-spacing: -0.035em;
  line-height: 1.05;
}

.hero > p {
  position: relative;
  z-index: 1;
  max-width: 560px;
  margin: 24px 0 0;
  color: rgba(255, 255, 255, 0.78);
  font-size: clamp(1rem, 2vw, 1.2rem);
}

.hero__stats {
  position: absolute;
  z-index: 1;
  right: clamp(28px, 6vw, 68px);
  bottom: clamp(28px, 6vw, 58px);
  display: flex;
  gap: 12px;
}

.hero__stats div {
  min-width: 104px;
  padding: 14px 18px;
  color: var(--ink);
  border-radius: 18px;
  background: white;
}

.hero__stats strong,
.hero__stats span {
  display: block;
}

.hero__stats strong {
  font-size: 1.7rem;
}

.hero__stats span {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(390px, 1.1fr);
  gap: 20px;
  align-items: start;
}

.panel,
.save-panel,
.predictions {
  border: 1px solid rgba(23, 35, 29, 0.08);
  border-radius: 26px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.panel {
  padding: 24px;
}

.panel__header,
.section-heading {
  display: flex;
  gap: 18px;
  align-items: center;
  justify-content: space-between;
}

h2 {
  margin: 0;
  font-size: clamp(1.55rem, 3vw, 2.25rem);
  letter-spacing: -0.04em;
}

.helper,
.save-panel p {
  margin: 8px 0 20px;
  color: var(--muted);
  font-size: 0.92rem;
}

.button {
  min-height: 42px;
  padding: 0 16px;
  border: 0;
  border-radius: 12px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, opacity 160ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-2px);
}

.button:focus-visible,
.club-card:focus-visible,
.table-slot:focus-visible,
.pool-dropzone:focus-visible,
input:focus-visible {
  outline: 3px solid var(--coral);
  outline-offset: 3px;
}

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

.button--quiet {
  background: #edf0e9;
}

.button--primary {
  color: white;
  background: var(--green);
}

.club-pool {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  min-height: 188px;
}

.club-card {
  display: flex;
  min-width: 0;
  height: 58px;
  padding: 7px 10px;
  gap: 9px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
  cursor: grab;
  user-select: none;
  transition: border 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.club-card:hover {
  border-color: var(--green);
  box-shadow: 0 7px 18px rgba(18, 107, 71, 0.12);
  transform: translateY(-2px);
}

.club-card:active {
  cursor: grabbing;
}

.club-card.is-selected {
  border-color: var(--coral);
  box-shadow: 0 0 0 3px rgba(255, 118, 87, 0.2);
}

.club-card.is-dragging {
  opacity: 0.45;
}

.club-card img,
.prediction-list img {
  width: 36px;
  height: 36px;
  object-fit: contain;
}

.club-card span {
  overflow: hidden;
  font-size: 0.82rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pool-dropzone {
  display: none;
  margin-top: 12px;
  padding: 15px;
  color: var(--muted);
  border: 2px dashed var(--line);
  border-radius: 14px;
  text-align: center;
  font-size: 0.82rem;
  font-weight: 800;
}

.pool-dropzone.is-visible {
  display: block;
}

.pool-dropzone.is-over {
  color: var(--green);
  border-color: var(--green);
  background: rgba(217, 255, 100, 0.18);
}

.league-table {
  display: grid;
  margin: 20px 0 0;
  padding: 0;
  gap: 6px;
  counter-reset: place;
  list-style: none;
}

.table-slot {
  display: grid;
  grid-template-columns: 34px 1fr;
  min-height: 52px;
  overflow: hidden;
  border: 1px dashed #cbd2c8;
  border-radius: 13px;
  background: rgba(237, 240, 233, 0.5);
  cursor: pointer;
  counter-increment: place;
  transition: background 140ms ease, border 140ms ease, transform 140ms ease;
}

.table-slot::before {
  display: grid;
  color: var(--muted);
  background: #edf0e9;
  place-items: center;
  font-size: 0.8rem;
  font-weight: 900;
  content: counter(place);
}

.table-slot:nth-child(1)::before {
  color: var(--green-dark);
  background: var(--lime);
}

.table-slot:nth-child(n + 18)::before {
  color: white;
  background: var(--coral);
}

.table-slot.is-over {
  border-color: var(--green);
  background: rgba(217, 255, 100, 0.28);
  transform: scale(1.01);
}

.table-slot__empty {
  display: flex;
  padding: 0 14px;
  align-items: center;
  color: #9aa49d;
  font-size: 0.78rem;
  font-weight: 700;
}

.table-slot .club-card {
  height: 50px;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.table-slot .club-card:hover {
  box-shadow: none;
  transform: none;
}

.table-slot .club-card img {
  width: 34px;
  height: 34px;
}

.save-panel {
  display: grid;
  grid-template-columns: 1fr minmax(320px, 0.8fr);
  gap: 40px;
  align-items: end;
  margin-top: 20px;
  padding: 28px;
}

.save-panel.is-ready {
  border-color: var(--green);
  background:
    linear-gradient(110deg, rgba(217, 255, 100, 0.15), transparent 50%),
    var(--card);
}

.save-form label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.8rem;
  font-weight: 900;
}

.save-form__row {
  display: flex;
  gap: 9px;
}

.save-form input {
  min-width: 0;
  flex: 1;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
}

.predictions {
  margin-top: 20px;
  padding: 28px;
}

.local-pill {
  padding: 8px 12px;
  color: var(--green);
  border-radius: 999px;
  background: rgba(217, 255, 100, 0.45);
  font-size: 0.72rem;
  font-weight: 900;
}

.prediction-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
  margin-top: 22px;
}

.prediction-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: white;
}

.prediction-card__header {
  display: flex;
  padding: 16px;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.prediction-card h3 {
  margin: 0;
  font-size: 1.05rem;
}

.prediction-card time {
  color: var(--muted);
  font-size: 0.7rem;
}

.delete-button {
  width: 32px;
  height: 32px;
  padding: 0;
  color: var(--muted);
  border: 0;
  border-radius: 50%;
  background: #edf0e9;
  cursor: pointer;
}

.prediction-list {
  margin: 0;
  padding: 10px 14px 14px 46px;
}

.prediction-list li {
  min-height: 34px;
  padding: 4px 0;
  font-size: 0.78rem;
  font-weight: 750;
}

.prediction-list li::marker {
  color: var(--muted);
  font-weight: 900;
}

.prediction-list img {
  width: 24px;
  height: 24px;
  margin: -4px 8px -7px 0;
}

footer {
  padding: 30px 0 40px;
  color: var(--muted);
  text-align: center;
  font-size: 0.78rem;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 5;
  padding: 13px 18px;
  color: white;
  border-radius: 12px;
  background: var(--ink);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.group-gateway {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 36px;
  margin-bottom: 20px;
  padding: clamp(24px, 5vw, 48px);
  border: 1px solid rgba(23, 35, 29, 0.08);
  border-radius: 26px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.group-gateway__intro p,
.group-choice p,
.group-status p {
  color: var(--muted);
  line-height: 1.55;
}

.group-gateway__actions {
  display: grid;
  gap: 12px;
}

.group-choice {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: white;
}

.group-choice h3 {
  margin: 0;
}

.group-choice p {
  margin: 6px 0 14px;
  font-size: 0.85rem;
}

.join-form {
  display: flex;
  gap: 8px;
}

.join-form input,
.group-code {
  min-width: 0;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
}

.join-form input {
  min-height: 42px;
  flex: 1;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.group-status {
  display: flex;
  gap: 20px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding: 18px 22px;
  color: white;
  border-radius: 18px;
  background: var(--green-dark);
  box-shadow: var(--shadow);
}

.group-status .kicker {
  color: var(--lime);
}

.group-status p {
  margin: 0;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.8rem;
}

.group-status__code {
  display: flex;
  gap: 10px;
  align-items: center;
}

.group-code {
  min-height: 42px;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: clamp(0.68rem, 1.6vw, 0.9rem);
  font-weight: 900;
  letter-spacing: 0.04em;
}

.button--light {
  color: var(--green-dark);
  background: var(--lime);
}

.button--danger {
  color: #9a321f;
  background: #fff0ec;
}

.form-error {
  min-height: 1.2em;
  margin: 8px 0 0;
  color: #b6422c;
  font-size: 0.78rem;
  font-weight: 750;
}

.prediction-card__actions {
  display: flex;
  gap: 6px;
}

.icon-button {
  min-height: 32px;
  padding: 0 10px;
  border: 0;
  border-radius: 9px;
  background: #edf0e9;
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 850;
}

.loading-card,
.empty-card {
  grid-column: 1 / -1;
  padding: 28px;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 16px;
  text-align: center;
}

.save-form__actions {
  display: flex;
  gap: 9px;
}

.share-dialog {
  width: min(430px, calc(100% - 28px));
  padding: 30px;
  color: var(--ink);
  border: 0;
  border-radius: 24px;
  background: var(--card);
  box-shadow: 0 28px 90px rgba(10, 75, 50, 0.3);
}

.share-dialog::backdrop {
  background: rgba(10, 30, 21, 0.65);
  backdrop-filter: blur(5px);
}

.share-dialog h2 {
  padding-right: 28px;
}

.share-dialog > p:not(.form-error) {
  margin: 8px 0 18px;
  color: var(--muted);
}

.share-dialog__close {
  position: absolute;
  top: 15px;
  right: 15px;
  width: 36px;
  height: 36px;
  color: var(--muted);
  border: 0;
  border-radius: 50%;
  background: #edf0e9;
  cursor: pointer;
  font-size: 1.4rem;
}

.qr-frame {
  display: grid;
  min-height: 280px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: white;
  place-items: center;
}

.qr-frame span {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 750;
}

.qr-frame img {
  display: block;
  width: 280px;
  max-width: 100%;
  height: auto;
}

.share-code {
  display: block;
  margin: 14px 0;
  color: var(--green-dark);
  text-align: center;
  font-size: 1.25rem;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.share-dialog__actions {
  display: flex;
  gap: 9px;
  justify-content: center;
}

[hidden] {
  display: none !important;
}

@media (max-width: 820px) {
  .hero {
    padding-bottom: 122px;
  }

  .hero__stats {
    right: auto;
    bottom: 24px;
    left: 28px;
  }

  .workspace,
  .save-panel,
  .group-gateway {
    grid-template-columns: 1fr;
  }

  .save-panel {
    gap: 10px;
  }
}

@media (max-width: 520px) {
  .page-shell {
    width: min(100% - 18px, 1180px);
  }

  .hero {
    margin-top: 9px;
    border-radius: 22px;
  }

  .hero h1 {
    letter-spacing: -0.06em;
  }

  .hero__stats div {
    min-width: 94px;
  }

  .panel,
  .save-panel,
  .predictions {
    padding: 18px;
    border-radius: 20px;
  }

  .club-pool {
    grid-template-columns: 1fr;
  }

  .save-form__row {
    align-items: stretch;
    flex-direction: column;
  }

  .save-form input,
  .save-form .button {
    min-height: 48px;
  }

  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .join-form,
  .group-status,
  .group-status__code {
    align-items: stretch;
    flex-direction: column;
  }

  .group-code {
    min-height: 46px;
  }

  .share-dialog {
    padding: 24px 18px;
  }

  .share-dialog__actions {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
