:root {
  --ink: #17322e;
  --muted: #60736f;
  --paper: #f8f5ed;
  --card: #fffdf8;
  --green: #0b3d35;
  --green-2: #146b5a;
  --orange: #ee6c32;
  --yellow: #f5c84c;
  --blue: #2c6e9b;
  --line: #dfe3da;
  --shadow: 0 14px 40px rgba(20, 49, 43, .09);
}

* { box-sizing: border-box; }
html { background: var(--paper); color: var(--ink); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
body { margin: 0; min-width: 320px; }
button, input, select { font: inherit; }
button { cursor: pointer; }

.hero { background: var(--green); color: white; overflow: hidden; padding: 42px max(24px, calc((100vw - 1120px) / 2)) 24px; position: relative; }
.hero::after { background: repeating-linear-gradient(90deg, transparent 0 39px, rgba(255,255,255,.035) 40px), repeating-linear-gradient(0deg, transparent 0 39px, rgba(255,255,255,.035) 40px); content: ""; inset: 0; pointer-events: none; position: absolute; }
.hero__inner { align-items: center; display: flex; justify-content: space-between; margin: auto; max-width: 1120px; position: relative; z-index: 1; }
.eyebrow, .kicker { color: var(--orange); font-size: .72rem; font-weight: 800; letter-spacing: .13em; margin: 0 0 7px; text-transform: uppercase; }
h1 { font-family: Georgia, serif; font-size: clamp(2.6rem, 7vw, 5.2rem); font-weight: 500; letter-spacing: -.055em; line-height: .95; margin: 0; }
.hero__strap { color: rgba(255,255,255,.69); margin: 16px 0 0; }
.ball { background: #fff7dc; border-radius: 50%; box-shadow: inset -12px -8px 0 rgba(238,108,50,.12), 0 20px 50px rgba(0,0,0,.23); height: clamp(78px, 12vw, 130px); margin-right: 5vw; position: relative; transform: rotate(-13deg); width: clamp(78px, 12vw, 130px); }
.ball::after { color: var(--orange); content: "PORTUGAL\A 2026"; font-size: clamp(.48rem, 1vw, .72rem); font-weight: 900; left: 50%; line-height: 1.1; position: absolute; text-align: center; top: 50%; transform: translate(-50%,-50%); white-space: pre; }
.progress-wrap { margin: 34px auto 0; max-width: 1120px; position: relative; z-index: 1; }
.progress-copy { color: rgba(255,255,255,.72); display: flex; font-size: .78rem; justify-content: space-between; margin-bottom: 8px; }
.progress { background: rgba(255,255,255,.13); border-radius: 99px; height: 5px; overflow: hidden; }
.progress span { background: var(--orange); display: block; height: 100%; transition: width .5s ease; width: 0; }

.tabs { background: var(--green); display: flex; gap: 8px; justify-content: center; padding: 0 20px; position: sticky; top: 0; z-index: 10; }
.tab { background: transparent; border: 0; border-bottom: 3px solid transparent; color: rgba(255,255,255,.58); font-size: .86rem; font-weight: 750; padding: 16px 18px 14px; }
.tab:hover, .tab.is-active { border-bottom-color: var(--orange); color: white; }

main { margin: 0 auto; max-width: 1120px; padding: 40px 24px 80px; }
.view { display: none; }
.view.is-active { display: block; }
.section-heading { align-items: end; display: flex; gap: 20px; justify-content: space-between; margin-bottom: 24px; }
h2 { font-family: Georgia, serif; font-size: clamp(2rem, 5vw, 3.1rem); font-weight: 500; letter-spacing: -.035em; margin: 0; }
h3 { font-size: 1.05rem; margin: 0; }
.round-filter { color: var(--muted); display: grid; font-size: .72rem; font-weight: 800; gap: 4px; letter-spacing: .08em; text-transform: uppercase; }
select { background: var(--card); border: 1px solid var(--line); border-radius: 8px; color: var(--ink); padding: 9px 30px 9px 10px; }
.pill { background: #e1ece8; border-radius: 99px; color: var(--green-2); font-size: .72rem; font-weight: 850; padding: 8px 12px; text-transform: uppercase; }

.next-card { align-items: center; background: var(--orange); border-radius: 16px; color: white; display: grid; grid-template-columns: auto 1fr auto; gap: 20px; margin-bottom: 32px; padding: 20px 24px; box-shadow: var(--shadow); }
.next-card__label { color: #56220d; font-size: .68rem; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; }
.next-card__players { font-family: Georgia, serif; font-size: clamp(1.4rem, 4vw, 2rem); text-align: center; }
.next-card__players em { font-family: inherit; font-size: .75em; opacity: .65; padding: 0 10px; }
.round { margin: 0 0 30px; }
.round__title { align-items: center; color: var(--muted); display: flex; font-size: .73rem; font-weight: 850; letter-spacing: .11em; margin: 0 0 9px; text-transform: uppercase; }
.round__title::after { background: var(--line); content: ""; flex: 1; height: 1px; margin-left: 12px; }
.match-list { background: var(--card); border: 1px solid var(--line); border-radius: 13px; box-shadow: 0 5px 20px rgba(20,49,43,.04); overflow: hidden; }
.match { align-items: center; background: transparent; border: 0; border-bottom: 1px solid var(--line); color: var(--ink); display: grid; gap: 10px; grid-template-columns: 35px minmax(0,1fr) auto minmax(0,1fr) 28px; padding: 15px 17px; text-align: left; width: 100%; }
.match:last-child { border-bottom: 0; }
.match:hover { background: #fbf7ed; }
.match__number { color: #a2aca9; font-size: .7rem; font-weight: 800; }
.match__player:first-of-type { text-align: right; }
.match__player { font-weight: 750; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.match__score { background: #edf1ed; border-radius: 7px; color: var(--muted); font-size: .76rem; font-weight: 800; min-width: 42px; padding: 5px 7px; text-align: center; }
.match.is-complete .match__score { background: var(--green); color: white; }
.match__edit { color: #a2aca9; font-size: 1rem; }
.button { border: 0; border-radius: 9px; font-weight: 800; padding: 11px 16px; }
.button--primary { background: var(--green); color: white; }
.button--light { background: white; color: var(--orange); }
.button--quiet { background: #eceee9; color: var(--muted); }
.button:disabled { cursor: not-allowed; opacity: .45; }

.table-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; }
.table-scroll { overflow-x: auto; }
table { border-collapse: collapse; font-size: .87rem; width: 100%; }
th { background: #edf1ed; color: var(--muted); font-size: .67rem; letter-spacing: .08em; padding: 11px 14px; text-align: center; text-transform: uppercase; }
th:nth-child(2), td:nth-child(2) { text-align: left; }
td { border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; padding: 14px; text-align: center; }
td:first-child { color: var(--muted); font-weight: 900; width: 34px; }
td:nth-child(2) { font-weight: 800; min-width: 110px; }
tr.cut td { border-top: 2px solid var(--orange); }
.rank-badge { align-items: center; background: #edf1ed; border-radius: 50%; display: inline-flex; height: 26px; justify-content: center; width: 26px; }
tr:nth-child(-n+4) .rank-badge { background: #f7e7b2; color: #735817; }
.action-panel, .notice { background: #e9efec; border-left: 4px solid var(--green-2); border-radius: 8px; color: var(--muted); margin-top: 22px; padding: 17px 20px; }
.action-panel { align-items: center; display: flex; gap: 18px; justify-content: space-between; }
.action-panel strong { color: var(--ink); display: block; margin-bottom: 3px; }

.brackets { display: grid; gap: 24px; grid-template-columns: 1fr 1fr; margin-top: 24px; }
.bracket { background: var(--card); border: 1px solid var(--line); border-radius: 15px; box-shadow: var(--shadow); overflow: hidden; }
.bracket__head { align-items: center; display: flex; gap: 13px; padding: 20px; }
.bracket__head > span { font-size: 2rem; }
.bracket__head p { color: var(--muted); font-size: .68rem; font-weight: 850; letter-spacing: .1em; margin: 0 0 3px; text-transform: uppercase; }
.bracket--gold .bracket__head { background: #f5e8bd; }
.bracket--blue .bracket__head { background: #dceaf3; }
.bracket .match { padding: 17px 18px; }
.bracket-round { color: var(--muted); font-size: .66rem; font-weight: 900; letter-spacing: .1em; padding: 15px 18px 5px; text-transform: uppercase; }

.rules-grid { display: grid; gap: 15px; grid-template-columns: repeat(4,1fr); }
.rule-card { background: var(--card); border: 1px solid var(--line); border-radius: 13px; min-height: 210px; padding: 21px; }
.rule-card > strong { color: var(--orange); font-family: Georgia, serif; font-size: 1.7rem; font-weight: 500; }
.rule-card h3 { margin: 24px 0 8px; }
.rule-card p, .settings-card p { color: var(--muted); font-size: .86rem; line-height: 1.55; margin: 0; }
.settings-card { align-items: center; background: var(--green); border-radius: 13px; color: white; display: flex; justify-content: space-between; margin-top: 18px; padding: 22px; }
.format-list { display: grid; gap: 5px; font-size: .78rem; line-height: 1.5; }
.format-list span { color: rgba(255,255,255,.68); }
.format-list b { color: white; display: inline-block; min-width: 132px; }
.segmented { background: rgba(255,255,255,.11); border-radius: 9px; display: flex; padding: 3px; }
.segmented button { background: transparent; border: 0; border-radius: 7px; color: rgba(255,255,255,.65); font-size: .78rem; font-weight: 800; padding: 9px 12px; }
.segmented button.is-active { background: white; color: var(--green); }
.segmented button:disabled { cursor: not-allowed; opacity: .45; }
.small-print { color: var(--muted); font-size: .73rem; text-align: center; }

dialog { background: var(--card); border: 0; border-radius: 17px; color: var(--ink); max-width: 520px; padding: 0; width: calc(100% - 30px); }
dialog::backdrop { backdrop-filter: blur(4px); background: rgba(5,25,22,.68); }
dialog form { padding: 28px; position: relative; }
.dialog-close { background: #edf0eb; border: 0; border-radius: 50%; color: var(--muted); font-size: 1.5rem; height: 34px; line-height: 1; position: absolute; right: 20px; top: 20px; width: 34px; }
dialog h2 { font-size: clamp(1.45rem, 5vw, 2rem); margin: 4px 40px 25px 0; }
.dialog-format { color: var(--muted); font-size: .78rem; font-weight: 750; margin: -17px 0 20px; }
dialog h2 em { color: var(--muted); font-family: Georgia,serif; font-size: .65em; font-weight: 400; padding: 0 4px; }
.score-head, .game-row { align-items: center; display: grid; gap: 10px; grid-template-columns: 1fr 84px 84px; }
.score-head { color: var(--muted); font-size: .7rem; font-weight: 850; padding: 0 0 7px; text-align: center; text-transform: uppercase; }
.score-head span { text-align: left; }
.game-row { border-top: 1px solid var(--line); padding: 9px 0; }
.game-row label { color: var(--muted); font-size: .8rem; }
.game-row input { background: white; border: 1px solid var(--line); border-radius: 8px; font-size: 1.05rem; font-weight: 800; padding: 10px 5px; text-align: center; width: 100%; }
.game-row input:focus { border-color: var(--orange); outline: 3px solid rgba(238,108,50,.13); }
.form-error { color: #a73323; font-size: .78rem; min-height: 20px; }
.dialog-actions { display: flex; justify-content: space-between; margin-top: 8px; }
.toast { background: var(--ink); border-radius: 9px; bottom: 24px; color: white; font-size: .82rem; left: 50%; opacity: 0; padding: 11px 16px; pointer-events: none; position: fixed; transform: translate(-50%, 20px); transition: .22s; z-index: 50; }
.toast.is-visible { opacity: 1; transform: translate(-50%,0); }
.empty-player { color: #9eaaa6; font-style: italic; font-weight: 500; }

@media (max-width: 760px) {
  .hero { padding-top: 30px; }
  .ball { margin-right: 0; }
  .hero__strap { font-size: .85rem; }
  .tabs { justify-content: flex-start; overflow-x: auto; }
  .tab { flex: 0 0 auto; padding-left: 13px; padding-right: 13px; }
  main { padding: 30px 14px 70px; }
  .brackets, .rules-grid { grid-template-columns: 1fr; }
  .rule-card { min-height: 0; }
  .rule-card h3 { margin-top: 12px; }
  .next-card { grid-template-columns: 1fr auto; padding: 17px; }
  .next-card__label { grid-column: 1 / -1; }
  .next-card__players { text-align: left; }
  .match { grid-template-columns: 24px minmax(0,1fr) auto minmax(0,1fr) 18px; padding: 14px 10px; }
  .match__player { font-size: .86rem; }
  .settings-card { align-items: stretch; flex-direction: column; gap: 18px; }
  .segmented button { flex: 1; }
  .action-panel { align-items: stretch; flex-direction: column; }
  .section-heading { align-items: center; }
}

@media (max-width: 420px) {
  .ball { height: 68px; width: 68px; }
  .hero__strap { max-width: 220px; }
  .score-head, .game-row { grid-template-columns: 1fr 70px 70px; }
  dialog form { padding: 24px 18px; }
}
