:root {
  --bg: #f4efe2;
  --panel: rgba(255, 255, 255, 0.82);
  --panel-strong: #fffaf1;
  --text: #10203a;
  --muted: #516079;
  --line: rgba(16, 32, 58, 0.12);
  --accent: #e44d2e;
  --accent-dark: #b93119;
  --green: #00846d;
  --gold: #ffca58;
  --navy: #17315f;
  --shadow: 0 18px 40px rgba(16, 32, 58, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--text);
  font-family: "Manrope", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(255, 202, 88, 0.55), transparent 34%),
    radial-gradient(circle at bottom right, rgba(0, 132, 109, 0.2), transparent 30%),
    linear-gradient(180deg, #fdf6e6 0%, #eef5f2 100%);
}

img {
  max-width: 100%;
  display: block;
}

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

main {
  display: grid;
  gap: 1.5rem;
}

.page-shell {
  width: min(1240px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1rem 0 3rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem 0 1rem;
  position: relative;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.85rem;
  font-family: "Bebas Neue", sans-serif;
  font-size: 1.8rem;
  letter-spacing: 0.06em;
}

.brand img {
  width: 54px;
  height: 54px;
}

.site-menu {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 120;
}

.menu-toggle {
  list-style: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 54px;
  height: 54px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 250, 241, 0.94);
  color: var(--navy);
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 18px 40px rgba(16, 32, 58, 0.2);
}

.menu-toggle::-webkit-details-marker {
  display: none;
}

.menu-icon {
  width: 20px;
  display: grid;
  gap: 4px;
}

.menu-icon span {
  display: block;
  height: 2px;
  border-radius: 999px;
  background: var(--navy);
}

.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;
}

.menu-dropdown {
  position: absolute;
  top: calc(100% + 0.75rem);
  right: 0;
  min-width: 260px;
  display: grid;
  gap: 0.25rem;
  padding: 0.6rem;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 18px;
  background: rgba(255, 250, 241, 0.96);
  backdrop-filter: blur(16px);
  box-shadow: 0 24px 50px rgba(16, 32, 58, 0.16);
  z-index: 130;
}

.menu-dropdown a {
  display: block;
  padding: 0.8rem 0.9rem;
  border-radius: 12px;
  color: var(--muted);
  font-weight: 700;
}

.menu-dropdown a:hover {
  color: var(--accent-dark);
  background: rgba(255, 255, 255, 0.72);
}

.menu-divider {
  height: 1px;
  margin: 0.2rem 0;
  background: var(--line);
}

.hero,
.room-header,
.layout-grid,
.form-grid,
.info-grid {
  display: grid;
  gap: 1.25rem;
}

.hero {
  grid-template-columns: 1.3fr 0.9fr;
  align-items: center;
  min-height: 65vh;
}

.hero-copy h1,
.rules-panel h1,
.room-header h1 {
  margin: 0.3rem 0 0.9rem;
  font-size: clamp(2.8rem, 8vw, 5.6rem);
  line-height: 0.94;
  font-family: "Bebas Neue", sans-serif;
  letter-spacing: 0.02em;
}

.hero-text {
  max-width: 62ch;
  color: var(--muted);
  line-height: 1.7;
}

.eyebrow {
  margin: 0;
  color: var(--accent-dark);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.82rem;
}

.hero-actions,
.form-grid,
.info-grid,
.score-summary {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  padding: 0.9rem 1.3rem;
  font-weight: 800;
  cursor: pointer;
}

.button-primary {
  background: linear-gradient(135deg, var(--accent) 0%, #ff7d3a 100%);
  color: white;
  box-shadow: 0 10px 20px rgba(228, 77, 46, 0.25);
}

.button-secondary {
  background: rgba(23, 49, 95, 0.08);
  color: var(--navy);
}

.button-small {
  padding: 0.55rem 0.9rem;
  font-size: 0.88rem;
}

.access-button {
  width: 100%;
}

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

.panel,
.hero-panel,
.secret-card,
.score-tile,
.info-card,
.group-card,
.match-card,
.breakdown-card {
  background: var(--panel);
  backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: var(--shadow);
  border-radius: 24px;
}

.hero-panel {
  padding: 1.2rem;
  display: grid;
  gap: 1rem;
  overflow: hidden;
}

.hero-panel img {
  border-radius: 18px;
}

.hero-note,
.secret-card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 1rem 1.1rem;
  background: rgba(255, 255, 255, 0.85);
  border-radius: 18px;
}

.invite-stack,
.secret-grid {
  display: grid;
  gap: 0.9rem;
}

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

.share-card {
  display: grid;
  gap: 0.7rem;
  padding: 1rem 1.1rem;
  background: rgba(255, 255, 255, 0.85);
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: var(--shadow);
}

.share-input,
.share-text {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0.9rem 1rem;
  font: inherit;
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
}

.share-text {
  min-height: 110px;
  resize: vertical;
}

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

.info-card,
.form-panel,
.leaderboard-panel,
.rules-panel,
.breakdown-panel {
  padding: 1.3rem;
}

.info-card h2,
.form-panel h2,
.panel h2,
.breakdown-card h3 {
  margin: 0 0 0.4rem;
}

.form-note {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

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

.form-panel {
  display: grid;
  gap: 0.9rem;
}

.home-dialog {
  width: min(560px, calc(100% - 1.5rem));
  border: 0;
  padding: 1.3rem;
  border-radius: 28px;
  background: var(--panel-strong);
  box-shadow: 0 24px 70px rgba(16, 32, 58, 0.2);
}

.home-dialog::backdrop {
  background: rgba(16, 32, 58, 0.42);
  backdrop-filter: blur(6px);
}

.dialog-top {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.dialog-top h2 {
  margin: 0.35rem 0 0;
  font-size: 2rem;
  font-family: "Bebas Neue", sans-serif;
  letter-spacing: 0.03em;
}

.dialog-close {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 999px;
  background: rgba(23, 49, 95, 0.08);
  color: var(--navy);
  font: inherit;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.dialog-form {
  padding: 0;
}

label {
  display: grid;
  gap: 0.4rem;
  font-weight: 700;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 0.9rem 1rem;
  font: inherit;
  background: rgba(255, 255, 255, 0.9);
}

.flash-stack {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.flash {
  padding: 0.95rem 1.1rem;
  border-radius: 16px;
  background: #fff0df;
  border: 1px solid rgba(228, 77, 46, 0.14);
}

.toast-stack {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 40;
  display: grid;
  gap: 0.75rem;
  pointer-events: none;
}

.toast {
  min-width: min(320px, calc(100vw - 2rem));
  padding: 0.95rem 1.1rem;
  border-radius: 18px;
  color: white;
  box-shadow: 0 18px 40px rgba(16, 32, 58, 0.22);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

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

.toast-success {
  background: linear-gradient(135deg, #00846d 0%, #14a38b 100%);
}

.toast-error {
  background: linear-gradient(135deg, #b93119 0%, #e44d2e 100%);
}

.score-summary {
  align-items: stretch;
}

.score-tile {
  min-width: 150px;
  padding: 1rem 1.1rem;
  display: grid;
  gap: 0.2rem;
}

.score-tile strong {
  font-size: 2rem;
  font-family: "Bebas Neue", sans-serif;
  letter-spacing: 0.04em;
}

.leaderboard-table,
.matches-list,
.breakdown-panel,
.breakdown-group,
.rules-list {
  display: grid;
  gap: 1rem;
}

.section-stack,
.match-grid,
.group-section-body {
  display: grid;
  gap: 1rem;
}

.anchor-target {
  scroll-margin-top: 8rem;
}

.leader-row,
.match-result-row,
.match-meta,
.group-card-top,
.section-title {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.layout-grid {
  grid-template-columns: minmax(0, 1.6fr) minmax(310px, 0.85fr);
  align-items: start;
}

.room-layout {
  align-items: start;
}

.room-main {
  display: grid;
  gap: 1.2rem;
}

.left-column,
.right-column,
.group-grid {
  display: grid;
  gap: 1.2rem;
}

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

.group-section {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.58);
  overflow: hidden;
}

.group-section.is-locked {
  border-color: rgba(23, 49, 95, 0.2);
  background: linear-gradient(180deg, rgba(23, 49, 95, 0.08) 0%, rgba(255, 255, 255, 0.58) 100%);
}

.group-section.is-section-saved {
  border-color: rgba(0, 132, 109, 0.34);
  background: linear-gradient(180deg, rgba(11, 130, 108, 0.16) 0%, rgba(255, 255, 255, 0.62) 100%);
}

.group-section.is-section-dirty {
  border-color: rgba(255, 167, 38, 0.34);
  background: linear-gradient(180deg, rgba(255, 202, 88, 0.22) 0%, rgba(255, 255, 255, 0.62) 100%);
}

.group-section.is-section-missed {
  border-color: rgba(185, 49, 25, 0.28);
  background: linear-gradient(180deg, rgba(228, 77, 46, 0.15) 0%, rgba(255, 255, 255, 0.62) 100%);
}

.group-summary {
  list-style: none;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  padding: 1rem 1.1rem;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.55);
}

.group-summary::-webkit-details-marker {
  display: none;
}

.group-summary span {
  color: var(--muted);
  font-weight: 700;
}

.group-section.is-locked .group-summary {
  background: linear-gradient(90deg, rgba(23, 49, 95, 0.12) 0%, rgba(255, 255, 255, 0.55) 100%);
}

.group-section.is-section-saved .group-summary {
  background: linear-gradient(90deg, rgba(11, 130, 108, 0.18) 0%, rgba(255, 255, 255, 0.58) 100%);
}

.group-section.is-section-dirty .group-summary {
  background: linear-gradient(90deg, rgba(255, 202, 88, 0.24) 0%, rgba(255, 255, 255, 0.58) 100%);
}

.group-section.is-section-missed .group-summary {
  background: linear-gradient(90deg, rgba(228, 77, 46, 0.18) 0%, rgba(255, 255, 255, 0.58) 100%);
}

.group-section-body {
  padding: 0 1rem 1rem;
}

.grouped-card {
  padding: 1rem;
}

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

.group-card,
.match-card,
.breakdown-card {
  padding: 1rem;
}

.group-card,
.match-card {
  transition: background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.group-card.is-saved,
.match-card.is-saved {
  background: linear-gradient(180deg, rgba(11, 130, 108, 0.18) 0%, rgba(255, 255, 255, 0.88) 100%);
  border-color: rgba(0, 132, 109, 0.34);
}

.group-card.is-dirty,
.match-card.is-dirty {
  background: linear-gradient(180deg, rgba(255, 202, 88, 0.32) 0%, rgba(255, 255, 255, 0.88) 100%);
  border-color: rgba(255, 167, 38, 0.38);
}

.group-card.is-missed,
.match-card.is-missed {
  background: linear-gradient(180deg, rgba(228, 77, 46, 0.18) 0%, rgba(255, 255, 255, 0.9) 100%);
  border-color: rgba(185, 49, 25, 0.3);
}

.group-card.is-saving,
.match-card.is-saving {
  box-shadow: 0 20px 42px rgba(16, 32, 58, 0.2);
}

.group-card.is-locked:not(.is-saved):not(.is-dirty):not(.is-missed),
.match-card.is-locked:not(.is-saved):not(.is-dirty):not(.is-missed) {
  background: linear-gradient(180deg, rgba(23, 49, 95, 0.12) 0%, rgba(255, 255, 255, 0.88) 100%);
  border-color: rgba(23, 49, 95, 0.26);
}

.leader-breakdown {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.7);
  overflow: hidden;
}

.leader-breakdown summary {
  list-style: none;
}

.leader-breakdown summary::-webkit-details-marker {
  display: none;
}

.leader-breakdown-grid,
.result-score-grid {
  display: grid;
  gap: 0.9rem;
}

.leader-breakdown-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: 0 1rem 1rem;
}

.sortable-list {
  list-style: none;
  padding: 0;
  margin: 1rem 0 0;
  display: grid;
  gap: 0.65rem;
}

.sortable-item,
.team-chip {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.9);
}

.sortable-item {
  cursor: grab;
}

.sortable-item.dragging {
  opacity: 0.45;
}

.sortable-item img,
.team-chip img {
  width: 34px;
  height: 24px;
  object-fit: cover;
  border-radius: 4px;
  box-shadow: 0 2px 10px rgba(16, 32, 58, 0.15);
}

.team-avatar {
  width: 34px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: rgba(23, 49, 95, 0.12);
  font-weight: 800;
}

.position-badge {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  background: rgba(23, 49, 95, 0.08);
}

.teams-line,
.score-form {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.teams-line {
  justify-content: space-between;
  margin: 1rem 0;
}

.team-chip {
  min-width: 0;
  flex: 1;
}

.score-form input {
  width: 80px;
  text-align: center;
  font-size: 1.2rem;
  font-weight: 800;
}

.match-meta,
.match-result-row,
.leader-row span,
.breakdown-card summary,
.hero-note span,
.secret-card span {
  color: var(--muted);
}

.breakdown-card details {
  border-top: 1px solid var(--line);
  padding-top: 0.8rem;
}

.breakdown-page-grid,
.breakdown-summary-grid {
  display: grid;
  gap: 1rem;
}

.breakdown-summary-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.breakdown-page-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 1rem;
}

.breakdown-column {
  display: grid;
  gap: 1rem;
}

.breakdown-total {
  font-size: 1.2rem;
}

.breakdown-item {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.7);
  padding: 0.95rem 1rem;
}

.breakdown-item summary {
  list-style: none;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  cursor: pointer;
}

.breakdown-item summary::-webkit-details-marker {
  display: none;
}

.breakdown-item ul {
  margin: 0.9rem 0 0;
  padding-left: 1.2rem;
  display: grid;
  gap: 0.45rem;
}

.result-details {
  margin-top: 1rem;
  border-top: 1px solid var(--line);
  padding-top: 0.9rem;
  display: grid;
  gap: 0.9rem;
}

.result-heading {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  color: var(--muted);
  font-weight: 700;
}

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

.result-score-card,
.actual-order-panel {
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.84);
}

.result-score-top {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
}

.result-score-card ul {
  margin: 0.75rem 0 0;
  padding-left: 1.2rem;
  display: grid;
  gap: 0.4rem;
  color: var(--muted);
}

.actual-order-panel {
  margin-top: 0.9rem;
  display: grid;
  gap: 0.75rem;
}

.actual-order-list {
  margin: 0;
  padding-left: 1.3rem;
  display: grid;
  gap: 0.55rem;
}

.actual-order-list li {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.actual-order-list img {
  width: 34px;
  height: 24px;
  object-fit: cover;
  border-radius: 4px;
  box-shadow: 0 2px 10px rgba(16, 32, 58, 0.15);
}

.opponent-panel {
  margin-top: 1rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 0.45rem;
  color: var(--muted);
}

.opponent-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.35rem;
}

.opponent-list li {
  display: flex;
  gap: 0.5rem;
}

.breakdown-card ul {
  margin: 0.75rem 0 0;
  padding-left: 1.2rem;
}

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

@media (max-width: 980px) {
  .hero,
  .layout-grid,
  .info-grid,
  .form-grid,
  .group-grid,
  .rules-list,
  .secret-grid,
  .match-grid,
  .leader-breakdown-grid,
  .result-score-grid,
  .breakdown-page-grid,
  .breakdown-summary-grid {
    grid-template-columns: 1fr;
  }

  .hero {
    min-height: auto;
  }

  .hero-copy h1,
  .rules-panel h1,
  .room-header h1 {
    font-size: clamp(2.6rem, 18vw, 4.6rem);
  }

  .teams-line,
  .score-form,
  .match-meta,
  .match-result-row,
  .group-card-top,
  .section-title,
  .topbar,
  .dialog-top {
    flex-direction: column;
    align-items: flex-start;
  }

  .menu-dropdown {
    right: auto;
    left: auto;
    right: 0;
    min-width: min(280px, calc(100vw - 2rem));
  }
}
