:root {
  --ink: #17120f;
  --muted: #6e625d;
  --paper: #f7f0e6;
  --panel: #fffaf3;
  --line: #dfd2c5;
  --orange: #b8791f;
  --gold: #d8a63b;
  --gold-dark: #a97118;
  --gold-light: #f5d98a;
  --blue: #42acd6;
  --red: #ed1b2f;
  --green: #277e58;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: Inter, system-ui, sans-serif; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
.fixture-shell { min-height: 100vh; }
.login-panel { display: grid; place-items: center; min-height: 100vh; padding: 2rem; text-align: center; }
.login-panel > * { width: min(100%, 28rem); }
.brand-mark { width: auto; color: #ffdc19; font-family: Impact, Haettenschweiler, 'Arial Narrow Bold', sans-serif; font-size: clamp(2rem, 6vw, 4.5rem); font-style: italic; letter-spacing: -0.04em; line-height: 0.95; text-shadow: 3px 3px 0 #ed1b2f, 7px 7px 0 #101820; transform: rotate(-2deg); }
.brand-mark span { display: block; font-size: 0.38em; letter-spacing: 0.16em; }
.brand-logo { display: block; width: min(100%, 38rem); height: auto; margin: 0 auto; filter: drop-shadow(0.35rem 0.35rem 0 rgba(0, 0, 0, 0.18)); }
.kicker { margin: 0; color: var(--orange); font-size: 0.72rem; font-weight: 800; letter-spacing: 0.22em; text-transform: uppercase; }
.login-panel h1, .fixture-header h1, .bracket-heading h2, .panel-heading h2 { margin: 0; font-family: Georgia, 'Times New Roman', serif; font-weight: 600; }
.login-panel h1 { margin-top: 2rem; font-size: clamp(2.4rem, 7vw, 4.5rem); }
.login-copy { margin: 1rem auto 2rem; color: var(--muted); line-height: 1.6; }
.login-form { display: grid; gap: 1rem; text-align: left; }
label { display: grid; gap: 0.45rem; color: var(--muted); font-size: 0.8rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
input, textarea { width: 100%; border: 1px solid var(--line); border-radius: 0.7rem; background: var(--panel); color: var(--ink); padding: 0.85rem 1rem; outline: none; }
input:focus, textarea:focus { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(196, 85, 32, 0.14); }
textarea { min-height: 10rem; resize: vertical; line-height: 1.5; }
.primary-button, .secondary-button, .ghost-button, .text-button { border: 0; border-radius: 999px; font-size: 0.76rem; font-weight: 800; letter-spacing: 0.1em; }
.primary-button { background: linear-gradient(135deg, var(--gold), var(--gold-dark, #a97118)); color: #24170b; padding: 0.95rem 1.3rem; box-shadow: 0 10px 24px rgba(174, 119, 28, 0.3); }
.primary-button:hover { background: var(--gold-light); transform: translateY(-1px); }
.secondary-button { border: 1px solid var(--gold-dark, #a97118); background: transparent; color: var(--gold-dark, #a97118); padding: 0.8rem 1rem; }
.secondary-button:hover { background: #f5e8c5; }
.ghost-button { border: 1px solid rgba(255,255,255,.5); background: transparent; color: #fff; padding: 0.7rem 1rem; }
.ghost-button:hover { background: rgba(255,255,255,.12); }
.text-button { padding: 0.25rem 0; background: transparent; color: var(--muted); text-decoration: underline; text-underline-offset: 0.2rem; }
.podium-admin { display: grid; gap: 0.7rem; margin-top: 1rem; border-top: 1px solid var(--line); padding-top: 1.2rem; }
.podium-admin .panel-heading h2 { font-size: 1.8rem; }
.podium-status { margin: 0; color: var(--muted); font-size: 0.88rem; line-height: 1.5; }
.podium-admin select { width: 100%; border: 1px solid var(--line); border-radius: 0.7rem; background: var(--panel); color: var(--ink); padding: 0.7rem; }
.login-error { margin: 0; color: var(--red); font-size: 0.85rem; }
.fixture-app[hidden], .bracket[hidden] { display: none; }
.fixture-header { display: flex; justify-content: space-between; gap: 2rem; align-items: center; padding: 2rem clamp(1.25rem, 5vw, 5rem); background: linear-gradient(135deg, #173b52, #0a607c); border-bottom: 5px solid var(--gold); }
.fixture-header .kicker { color: var(--gold-light); }
.public-fixture .fixture-header > div { flex: 1; text-align: center; }
.public-logo { display: block; width: min(100%, 25rem); height: auto; margin: 0 auto 1rem; filter: drop-shadow(0.25rem 0.25rem 0 rgba(0, 0, 0, 0.18)); }
.fixture-header h1 { color: #fff8e8; font-size: clamp(2.8rem, 7vw, 6rem); line-height: 0.95; text-shadow: 3px 3px 0 rgba(0,0,0,.2); }
.fixture-header p:last-child { margin: 0.75rem 0 0; color: #dceef0; }
.live-timer { display: flex; align-items: center; justify-content: center; gap: 2rem; min-height: 8.5rem; border-top: 5px solid var(--gold); border-bottom: 1px solid var(--line); background: #101820; color: #fff8e8; }
.live-timer[hidden] { display: none; }
.timer-label { color: var(--gold-light); font-size: clamp(1.3rem, 2.8vw, 2.1rem); font-weight: 900; letter-spacing: 0.18em; }
.timer-display { color: #ff6b22; font-family: 'Courier New', monospace; font-size: clamp(4rem, 10vw, 7rem); font-variant-numeric: tabular-nums; letter-spacing: 0.04em; line-height: 1; text-shadow: 0 0 18px rgba(255, 107, 34, 0.35); }
.timer-match { max-width: min(50rem, 48vw); color: #dceef0; font-size: clamp(1.25rem, 2.5vw, 1.8rem); font-weight: 700; line-height: 1.35; text-align: center; }
.fixture-layout { display: grid; grid-template-columns: minmax(17rem, 23rem) minmax(0, 1fr); gap: 1.5rem; width: min(100% - 2rem, 1400px); margin: 1.5rem auto; }
.public-bracket-panel { width: min(100% - 2rem, 1400px); margin: 1.5rem auto; }
.public-back { text-decoration: none; }
.control-panel, .bracket-panel { border: 1px solid var(--line); border-radius: 1rem; background: var(--panel); box-shadow: 0 18px 50px rgba(56, 37, 20, 0.08); }
.control-panel { display: flex; flex-direction: column; gap: 0.8rem; align-self: start; padding: 1.25rem; }
.panel-heading h2 { margin-top: 0.35rem; font-size: 2.2rem; }
.control-actions { display: grid; gap: 0.6rem; }
.match-size-control { display: grid; grid-template-columns: 1fr 1fr; align-items: center; gap: 0.6rem; }
.match-size-control select { width: 100%; border: 1px solid var(--line); border-radius: 0.7rem; background: var(--panel); color: var(--ink); padding: 0.7rem; }
.participant-summary { color: var(--orange); font-size: 0.82rem; font-weight: 800; }
.participant-list { display: grid; gap: 0.4rem; max-height: 18rem; margin: 0; padding: 0; overflow: auto; list-style: none; }
.participant-list li { display: flex; justify-content: space-between; gap: 0.5rem; align-items: center; border-bottom: 1px solid var(--line); padding: 0.5rem 0; font-size: 0.9rem; }
.remove-participant { border: 0; background: transparent; color: var(--red); font-size: 1.2rem; }
.bracket-panel { min-width: 0; overflow: hidden; padding: 1.5rem; }
.bracket-heading { display: flex; justify-content: space-between; gap: 2rem; align-items: end; margin-bottom: 1.25rem; }
.bracket-heading h2 { margin-top: 0.4rem; font-size: clamp(2rem, 4vw, 3.5rem); }
.bracket-note { max-width: 18rem; margin: 0; color: var(--muted); font-size: 0.85rem; line-height: 1.5; text-align: right; }
.bracket-empty { display: grid; place-items: center; min-height: 24rem; border: 1px dashed var(--line); border-radius: 0.8rem; color: var(--muted); text-align: center; }
.bracket-empty[hidden] { display: none; }
.bracket-empty span { color: var(--orange); font-size: 2rem; }
.bye-notice { margin-bottom: 1rem; border: 1px solid #b9d9c8; border-radius: 0.75rem; background: #edf8f1; color: #155838; padding: 0.8rem 1rem; font-size: 0.85rem; line-height: 1.5; }
.bye-notice strong { display: block; margin-bottom: 0.25rem; font-size: 0.75rem; letter-spacing: 0.12em; text-transform: uppercase; }
.bracket-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin: 0 0 0.6rem; color: var(--muted); font-size: 0.75rem; font-weight: 700; text-align: center; }
.bracket-toolbar[hidden] { display: none; }
.scroll-button { display: grid; place-items: center; width: 2.2rem; height: 2.2rem; border: 1px solid var(--line); border-radius: 50%; background: var(--panel); color: var(--orange); font-size: 1.2rem; font-weight: 800; }
.scroll-button:hover { background: #f5dfd0; }
.bracket-viewport { max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-color: var(--orange) var(--line); scrollbar-width: auto; }
.bracket { display: flex; gap: 1rem; width: max-content; min-width: 100%; padding: 0.5rem 0 1rem; }
.round { display: flex; flex: 1 0 12rem; flex-direction: column; justify-content: center; gap: 0.8rem; min-width: 12rem; }
.round-title { margin: 0 0 0.5rem; color: var(--gold-dark); font-size: 0.72rem; font-weight: 900; letter-spacing: 0.18em; text-align: center; text-transform: uppercase; }
.round:last-child .round-title { color: var(--gold-dark); font-size: 0.72rem; }
.final-round { min-width: 18rem; }
.final-round .round-title { color: var(--red); font-size: 1.2rem; letter-spacing: 0.24em; }
.final-round .match { border: 3px solid var(--gold); border-radius: 1rem; background: #fff9e6; box-shadow: 0 20px 42px rgba(174, 119, 28, 0.3); padding: 0.9rem; }
.final-round .qualifier-note { color: var(--red); font-size: 0.8rem; font-weight: 900; letter-spacing: 0.14em; }
.final-round .match-button { padding: 0.85rem 0.7rem; font-size: 1.05rem; font-weight: 700; }
.match { display: grid; gap: 0.3rem; position: relative; border: 1px solid #d5b56d; border-radius: 0.65rem; background: #fffdf8; padding: 0.45rem; box-shadow: 0 8px 20px rgba(95, 63, 18, 0.08); }
.match-group { border-color: #d5b56d; background: #fffdf8; }
.qualifier-note { padding: 0.15rem 0.2rem 0.35rem; color: var(--gold-dark); font-size: 0.62rem; font-weight: 900; letter-spacing: 0.12em; text-align: center; }
.round:last-child .match { border: 2px solid var(--gold); box-shadow: 0 12px 28px rgba(174, 119, 28, 0.2); }
.match::after { content: ''; position: absolute; top: 50%; right: -1rem; width: 1rem; border-top: 1px solid var(--line); }
.round:last-child .match::after { display: none; }
.match-button { width: 100%; border: 1px solid transparent; border-radius: 0.4rem; background: #f4ebe0; color: var(--ink); padding: 0.55rem 0.45rem; font-size: 0.78rem; text-align: left; }
.match-button:not(:disabled):hover, .match-button.winner { border-color: var(--gold-dark); background: #f6d889; color: #24170b; font-weight: 800; }
.match-button:disabled { color: #a69a91; cursor: default; font-style: italic; }
.match-button.pending { background: #f6f0e9; color: #95877d; font-size: 0.7rem; }
.match-timer-button { border: 1px solid var(--gold); border-radius: 0.35rem; background: #fff7df; color: var(--gold-dark); padding: 0.35rem 0.45rem; font-size: 0.64rem; font-weight: 900; letter-spacing: 0.08em; }
.match-timer-button:hover { background: var(--gold-light); }
.public-podium { margin-top: 2rem; border-top: 1px solid var(--line); padding-top: 2rem; text-align: center; }
.public-podium > .kicker { font-size: clamp(1rem, 2vw, 1.35rem); letter-spacing: 0.24em; }
.admin-podium { margin-top: 2.5rem; }
.public-podium h2 { margin: 0.35rem 0 1.25rem; font-family: Georgia, 'Times New Roman', serif; font-size: clamp(2rem, 5vw, 3.5rem); }
.podium-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; align-items: end; max-width: 58rem; margin: 0 auto; }
.podium-card { display: grid; gap: 0.7rem; min-height: 8rem; place-items: center; border: 2px solid var(--gold); border-radius: 0.9rem 0.9rem 0 0; background: #f8eed7; padding: 1rem; color: var(--ink); }
.podium-card span { color: var(--gold-dark); font-size: clamp(1.15rem, 2.5vw, 1.65rem); font-weight: 900; letter-spacing: 0.16em; }
.podium-card strong { font-family: Georgia, 'Times New Roman', serif; font-size: clamp(1rem, 2.2vw, 1.5rem); }
.podium-first { min-height: 10rem; border-color: #c99718; background: linear-gradient(145deg, #f3c84b, #ffed9e); }
.podium-first span { color: #8a5a00; }
.podium-second { border-color: #9aa0a6; background: linear-gradient(145deg, #cfd3d8, #f1f3f5); }
.podium-second span { color: #4d5560; }
.podium-third { min-height: 7rem; border-color: #a95c2a; background: linear-gradient(145deg, #c47a48, #edb080); }
.podium-third span { color: #713412; }

@media (max-width: 850px) {
  .fixture-layout { grid-template-columns: 1fr; }
  .control-panel { position: static; }
  .bracket-panel { padding: 1rem; }
}

@media (max-width: 600px) {
  .fixture-header { align-items: flex-start; flex-direction: column; }
  .bracket-heading { align-items: flex-start; flex-direction: column; gap: 0.5rem; }
  .bracket-note { text-align: left; }
  .live-timer { flex-wrap: wrap; gap: 0.7rem 1rem; min-height: 9rem; padding: 1rem; }
  .timer-match { flex-basis: 100%; max-width: none; text-align: center; }
  .podium-cards { grid-template-columns: 1fr; max-width: 22rem; }
  .podium-card, .podium-first, .podium-third { min-height: 5.5rem; border-radius: 0.8rem; }
}
