:root {
  color-scheme: light;
  --plum: #4a1259;
  --plum-soft: #8a5a99;
  --pink: #ff3fa4;
  --pink-pale: #ffe3f3;
  --lilac: #c084fc;
  --card: #fff8fc;
  --border: #f7b6dc;
  --gold: #f5c542;
  --gold-foil: linear-gradient(115deg, #b8860b 0%, #ffe680 22%, #f5c542 40%, #fff6c2 55%, #d4a017 75%, #ffe680 100%);
  --error: #d6004c;
  --display: "Great Vibes", "Snell Roundhand", cursive;
  --royal: "Cinzel Decorative", "Cinzel", Georgia, serif;
  --body: "Quicksand", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--plum);
  font-family: var(--body);
  font-weight: 500;
  /* Sparkles scattered over a very pink sky. */
  background:
    radial-gradient(circle, #fff 0 1.5px, transparent 2.5px) 0 0 / 90px 90px,
    radial-gradient(circle, #fff6c2 0 1px, transparent 2px) 45px 30px / 130px 130px,
    radial-gradient(circle, #ffffffaa 0 2px, transparent 3px) 20px 70px / 210px 210px,
    linear-gradient(160deg, #ff5fb7 0%, #ff8fd0 25%, #d58cff 60%, #8f5bff 100%) fixed;
}

main {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 8px 16px 64px;
}

/* ---- hero ---- */

.hero {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 16px 8px;
  text-align: center;
}

.crown {
  font-size: clamp(2.6rem, 8vw, 4.5rem);
  line-height: 1;
  filter: drop-shadow(0 4px 0 #b8860b88);
  animation: bob 3s ease-in-out infinite;
}

.title {
  display: block;
  padding: 0.1em 0.2em 0.15em;
  font-family: var(--display);
  font-size: clamp(3.4rem, 13vw, 7.5rem);
  line-height: 1.05;
  text-decoration: none;
  background: var(--gold-foil);
  background-size: 250% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 3px 0 #7a1d6f) drop-shadow(0 6px 10px #4a125966);
  animation: shimmer 6s linear infinite;
}

.tagline {
  margin: 4px 0 0;
  font-family: var(--royal);
  font-weight: 700;
  font-size: clamp(0.8rem, 2.6vw, 1.15rem);
  letter-spacing: 0.08em;
  color: #fff;
  text-shadow: 0 2px 0 #b3147a, 0 0 14px #ff3fa4;
}

/* An eight-point gold starburst seal reading "30". */
.seal {
  position: absolute;
  top: 26px;
  right: 24px;
  width: 92px;
  height: 92px;
  display: grid;
  place-items: center;
  transform: rotate(12deg);
  animation: wobble 4s ease-in-out infinite;
}

.seal::before, .seal::after {
  content: "";
  position: absolute;
  inset: 8px;
  background: var(--gold-foil);
  border: 2px solid #fff6c2;
  box-shadow: 0 4px 10px #4a125955;
}

.seal::after { transform: rotate(45deg); }

.seal span {
  position: relative;
  z-index: 1;
  font-family: var(--royal);
  font-weight: 900;
  font-size: 2rem;
  color: #b3147a;
  text-shadow: 0 1px 0 #fff6c2;
}

@media (max-width: 700px) {
  .seal { top: 10px; right: 6px; width: 60px; height: 60px; }
  .seal span { font-size: 1.25rem; }
}

/* ---- floating decorations ---- */

.floaties { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }

.floaties span {
  position: absolute;
  bottom: -12vh;
  opacity: 0.6;
  animation: float-up linear infinite;
}

@keyframes float-up {
  from { transform: translateY(0) rotate(-12deg); }
  50% { transform: translateY(-62vh) translateX(24px) rotate(12deg); }
  to { transform: translateY(-125vh) rotate(-12deg); }
}

@keyframes shimmer { to { background-position: 250% 0; } }
@keyframes bob { 50% { transform: translateY(-6px) rotate(-4deg); } }
@keyframes wobble { 50% { transform: rotate(-6deg) scale(1.06); } }
@keyframes sparkle-row { 50% { background-position: 100% 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; }
}

/* ---- headings and text ---- */

h1 {
  margin: 12px 0 8px;
  text-align: center;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(2.4rem, 8vw, 4rem);
  color: #fff;
  text-shadow: 0 3px 0 #b3147a, 0 0 18px #ff3fa4;
}

h2 {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin: 36px 0 14px;
  font-family: var(--royal);
  font-weight: 900;
  font-size: clamp(1.2rem, 4vw, 1.7rem);
  letter-spacing: 0.06em;
  color: #fff;
  text-shadow: 0 2px 0 #b3147a, 0 0 16px #ff3fa4;
}

h2::before, h2::after { content: "✦ ❀ ✦"; font-size: 0.7em; color: #fff6c2; letter-spacing: 0.2em; }

h3 { margin: 20px 0 8px; font-family: var(--royal); font-size: 0.95rem; color: var(--plum); }
h4 { margin: 16px 0 6px; font-size: 0.9rem; color: var(--plum-soft); }

.muted { color: var(--plum-soft); }
.centre { text-align: center; }
.error { color: var(--error); min-height: 1.2em; }
a { color: #b3147a; font-weight: 700; }
#status { position: relative; z-index: 1; text-align: center; color: #fff; }

main > p.muted, main > p > a { color: #fff; font-weight: 700; text-shadow: 0 1px 0 #b3147a, 0 0 10px #b3147a; }

.dot {
  display: inline-block;
  width: 0.8em;
  height: 0.8em;
  margin-right: 0.5em;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--gold);
}

.badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--gold-foil);
  color: #7a1d6f;
  font-family: var(--body);
  font-size: 0.75em;
  font-weight: 700;
  text-shadow: none;
  transform: rotate(-6deg);
}

/* ---- tables ---- */

/* Every card is a gold-trimmed jewellery box. */
.table-wrap, .event-card, .match, .event, .admin section, #login {
  background: var(--card);
  border: 3px solid var(--gold);
  border-radius: 22px;
  box-shadow: 0 0 0 4px #ffffff99, 0 0 0 6px #ff8fd0, 0 12px 28px #4a125955;
}

.table-wrap { overflow-x: auto; }

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

th, td {
  padding: 12px 9px;
  text-align: center;
  border-bottom: 1px dashed var(--border);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

tr:last-child td { border-bottom: none; }
tr:nth-child(odd) td { background: #fff0f9; }

th {
  background: linear-gradient(180deg, #ff5fb7, #e0359a);
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  border-bottom: 3px solid var(--gold);
}

th a { color: #fff; }
th.event-col { white-space: normal; min-width: 4.6rem; }
.name { text-align: left; }
td.name { font-weight: 700; font-size: 1.05rem; }
td.total { color: #b3147a; font-weight: 700; font-size: 1.2rem; }
.members { font-weight: 500; font-size: 0.8rem; margin-top: 2px; }

/* Whoever is in the lead gets the full gold-leaf treatment. */
tr.leader td {
  background: linear-gradient(100deg, #ffe680, #fff6c2 30%, #ffd84d 55%, #fff6c2 80%, #ffe680) 0 0 / 200% 100%;
  animation: sparkle-row 5s ease-in-out infinite;
  font-weight: 700;
}

/* ---- event list ---- */

.event-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
}

.event-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px;
  color: var(--plum);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: transform 0.15s;
}

.event-card:hover { transform: rotate(-1.5deg) scale(1.03); }
.event-card strong { font-family: var(--royal); font-size: 1rem; color: #b3147a; }

/* ---- bracket ---- */

.bracket { display: flex; gap: 24px; overflow-x: auto; padding: 10px 10px 16px; }
.round { display: flex; flex-direction: column; min-width: 200px; }
.round h3 { margin-top: 0; color: #fff; text-shadow: 0 2px 0 #b3147a; }
.round-matches { display: flex; flex-direction: column; justify-content: space-around; gap: 18px; flex: 1; }

.match { border-radius: 16px; overflow: hidden; }

.side {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  color: var(--plum-soft);
}

.side + .side { border-top: 1px dashed var(--border); }
.side.winner { background: linear-gradient(100deg, #ffe680, #fff6c2); color: #b3147a; font-weight: 700; }
.side.winner .side-name::after { content: " 👑"; }
.side-score { font-variant-numeric: tabular-nums; }

/* ---- admin ---- */

.admin main { max-width: 900px; padding-bottom: 120px; }
.admin section, #login { margin-bottom: 28px; padding: 4px 18px 16px; }
#login { padding-top: 18px; }
.admin section h2 { color: #b3147a; text-shadow: none; margin-top: 16px; }
.admin section h2::before, .admin section h2::after { color: var(--gold); }

input, select, button {
  font: inherit;
  color: var(--plum);
  background: #fff;
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 8px 10px;
}

input:focus, select:focus { outline: 3px solid #ff8fd0; border-color: var(--pink); }
input[type="color"] { padding: 2px; width: 44px; height: 38px; }
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--pink); }
input:disabled, select:disabled { opacity: 0.4; }

button {
  background: var(--gold-foil);
  color: #7a1d6f;
  border: 2px solid #fff6c2;
  border-radius: 999px;
  padding: 8px 18px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 3px 0 #b8860b;
}

button:active { transform: translateY(2px); box-shadow: 0 1px 0 #b8860b; }
button:disabled { opacity: 0.6; }
button.secondary { background: #fff; color: var(--plum); border: 2px solid var(--border); box-shadow: none; font-weight: 500; }
button.danger { color: var(--error); }
button.remove { background: none; border: none; box-shadow: none; color: var(--plum-soft); padding: 4px 8px; }

.field { display: flex; flex-direction: column; gap: 6px; color: var(--plum-soft); font-size: 0.85rem; margin-bottom: 12px; }
.check { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }

.row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.row input[type="text"] { flex: 1; min-width: 8rem; }

.add-row { display: flex; gap: 8px; margin: 12px 0; }
.add-row input { flex: 1; min-width: 0; }

.event { padding: 12px 16px; margin-bottom: 14px; border-width: 2px; box-shadow: none; background: #fff0f9; }
.event summary { cursor: pointer; }
.event[open] summary { margin-bottom: 16px; }

.config {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0 16px;
  align-items: end;
}

.config > button { margin-bottom: 12px; }

table.entry { width: auto; }
table.entry th, table.entry td { padding: 6px 10px; border: none; background: none; }
table.entry th { color: var(--plum-soft); }
table.entry input[type="number"], table.entry input[type="text"] { width: 9rem; text-align: center; }

.match-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.match-row .side-name, .match-row select { flex: 1; min-width: 7rem; }
.match-row input[type="number"] { width: 4.5rem; text-align: center; }
.event-actions { margin-top: 20px; }

.save-bar {
  position: fixed;
  z-index: 2;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 12px 16px;
  background: var(--card);
  border-top: 3px solid var(--gold);
  box-shadow: 0 -6px 20px #4a125944;
}

/* The hidden attribute must win over the display rules above. */
[hidden] { display: none !important; }

/* Rotating decorations near the edge must not make the page scroll sideways. */
html { overflow-x: clip; }
