:root {
  --ink: #2d334d; --soft: rgba(45, 51, 77, .66); --line: rgba(45, 51, 77, .12); --cream: #fffaf2; --card: rgba(255, 250, 242, .95); --red: #ea5550; --green: #39ad6f; --gold: #ffd15c; --mint: #9ed9c8; --pink: #e86a9a;
  --shadow: 0 14px 36px rgba(90, 60, 40, .2); --sans: 'Nunito', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #f6e6da; font: 600 15px/1.45 var(--sans); color: var(--ink); -webkit-font-smoothing: antialiased; user-select: none; -webkit-user-select: none; }
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; }
button:focus-visible { outline: 3px solid var(--pink); outline-offset: 2px; }
kbd { display: inline-block; min-width: 22px; padding: 1px 6px; margin: 0 1px; border-radius: 6px; background: #fff; box-shadow: 0 1px 0 2px var(--line); font: 800 12px/1.5 var(--sans); text-align: center; color: var(--ink); }
h1 span, h2 em { font-style: normal; color: var(--red); }

/* ---------- screens ---------- */
.screen { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 20px; overflow-y: auto; }
.screen.dim { background: rgba(246, 230, 218, .55); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
#sPause { z-index: 30; }
.screen.side { place-items: center start; padding-left: max(20px, 5vw); background: linear-gradient(90deg, rgba(255, 246, 234, .96), rgba(255, 246, 234, .8) 34%, rgba(255, 246, 234, 0) 62%); }
.hero { width: min(470px, 100%); display: flex; flex-direction: column; gap: 12px; align-items: stretch; }
.kicker { font-weight: 800; font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--red); }
.hero h1 { margin: -6px 0 0; font-size: clamp(54px, 8vw, 92px); font-weight: 900; letter-spacing: -.03em; line-height: .95; }
.hero p { margin: 0 0 4px; max-width: 40ch; font-size: 17px; color: var(--soft); }
.me { display: flex; align-items: center; gap: 12px; padding: 8px 18px 8px 10px; border-radius: 999px; background: var(--card); box-shadow: var(--shadow); text-align: left; }
.me img { flex: none; width: 54px; height: 54px; border-radius: 50%; background: #ffe6c9; }
.me span { flex: 1; min-width: 0; }
.me small { display: block; font-weight: 800; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--soft); }
.me b { display: block; font-size: 19px; font-weight: 900; }
.me em { font-style: normal; font-weight: 800; font-size: 13px; color: var(--red); }
.menu { display: flex; flex-direction: column; gap: 10px; }
.cta { display: block; width: 100%; padding: 15px 24px; border-radius: 22px; background: linear-gradient(135deg, #f0655f, #e04a50); box-shadow: 0 12px 26px rgba(224, 74, 80, .34); border: 2px solid rgba(255, 255, 255, .4); font-weight: 900; font-size: 21px; color: #fff; text-align: left; transition: transform .12s; }
.cta small { display: block; margin-top: 1px; font-weight: 600; font-size: 14px; color: rgba(255, 255, 255, .9); }
.cta.alt { background: var(--ink); box-shadow: 0 12px 26px rgba(45, 51, 77, .3); }
.cta.net { background: linear-gradient(135deg, #46b98a, #2f9a72); box-shadow: 0 12px 26px rgba(47, 154, 114, .3); }
.cta:disabled { background: rgba(45, 51, 77, .14); box-shadow: none; color: var(--soft); cursor: default; transform: none; }
.cta.small { width: auto; padding: 12px 28px; border-radius: 999px; font-size: 16.5px; text-align: center; }
.cta:hover { transform: translateY(-2px); }
.ghost { padding: 11px 20px; border-radius: 999px; background: var(--card); box-shadow: 0 4px 14px rgba(90, 60, 40, .12); font-weight: 800; font-size: 14.5px; color: var(--ink); align-self: flex-start; }
.ghost:hover { background: #fff; }
.ghost.off { color: var(--soft); text-decoration: line-through; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; margin-top: 8px; }
.opt label { display: block; margin-bottom: 5px; font-weight: 800; font-size: 11.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--soft); }
.opts { display: flex; flex-wrap: wrap; gap: 14px 22px; }
.seg { display: inline-flex; padding: 4px; border-radius: 999px; background: rgba(45, 51, 77, .09); }
.seg button { padding: 7px 16px; border-radius: 999px; background: none; font-weight: 800; font-size: 14px; color: var(--soft); }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 2px 8px rgba(90, 60, 40, .16); }
.how { display: flex; flex-direction: column; gap: 6px; padding: 14px 18px; border-radius: 20px; background: var(--card); box-shadow: 0 4px 14px rgba(90, 60, 40, .1); font-size: 14px; color: var(--soft); }
.how b { font-weight: 900; font-size: 15px; color: var(--ink); }
.panel { display: flex; flex-direction: column; gap: 12px; width: min(470px, 100%); max-height: calc(100vh - 40px); padding: 26px; border-radius: 28px; background: var(--card); box-shadow: 0 24px 60px rgba(90, 60, 40, .26); overflow-y: auto; }
.panel.wide { width: min(940px, 100%); }
.panel.narrow { width: min(320px, 100%); align-items: stretch; text-align: center; }
.panel.narrow .ghost { align-self: stretch; }
.panel h2 { margin: -6px 0 2px; font-size: 34px; font-weight: 900; letter-spacing: -.02em; line-height: 1.1; }
.note { margin: 0; color: var(--soft); min-height: 1.4em; }
.avatars { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; }
.avatars button { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 12px 8px 14px; border-radius: 22px; background: #fff3e3; border: 3px solid transparent; }
.avatars button:hover, .avatars button.on { border-color: var(--red); background: #fff; box-shadow: 0 10px 24px rgba(224, 74, 80, .22); }
.avatars img { width: 100%; max-width: 140px; aspect-ratio: 1; border-radius: 50%; background: linear-gradient(180deg, #ffe1c2, #fff3e3); }
.avatars b { margin-top: 6px; font-size: 18px; font-weight: 900; line-height: 1.15; text-align: center; }
.avatars small { font-weight: 700; font-size: 12.5px; color: var(--soft); }
.avatars em { margin-top: 4px; padding: 2px 10px; border-radius: 999px; background: rgba(45, 51, 77, .08); font-style: normal; font-weight: 800; font-size: 12px; }
.avatars.rivals { grid-template-columns: repeat(auto-fit, minmax(112px, 1fr)); }
.avatars.rivals b { font-size: 14.5px; }

.avatars.duo { grid-template-columns: 1fr 1fr; }
.avatars button:disabled { cursor: default; }
.avatars button:disabled:hover { border-color: transparent; background: #fff3e3; box-shadow: none; }
.slot { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 190px; padding: 14px; border-radius: 22px; border: 3px dashed var(--line); text-align: center; color: var(--soft); }
.slot b { font-weight: 800; }
.slot small { font-weight: 700; font-size: 12.5px; }
.rooms { display: flex; flex-direction: column; gap: 8px; max-height: 44vh; overflow-y: auto; }
.rooms button { display: flex; align-items: center; gap: 12px; padding: 8px 16px 8px 10px; border-radius: 18px; background: #fff3e3; border: 2px solid transparent; text-align: left; }
.rooms button:hover:enabled { border-color: var(--green); background: #fff; }
.rooms button:disabled { opacity: .6; cursor: default; }
.rooms .faces { display: flex; }
.rooms img { width: 44px; height: 44px; border-radius: 50%; background: #ffe1c2; }
.rooms img + img { margin-left: -12px; }
.rooms span:nth-child(2) { flex: 1; min-width: 0; }
.rooms b { display: block; font-weight: 900; font-size: 16px; }
.rooms small { font-weight: 700; font-size: 12.5px; color: var(--soft); }
.rooms em { padding: 5px 14px; border-radius: 999px; background: var(--green); color: #fff; font-style: normal; font-weight: 800; font-size: 13px; }
.rooms button:disabled em { background: rgba(45, 51, 77, .14); color: var(--soft); }

/* ---------- the bracket ---------- */
.tree { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(0, .8fr); gap: 16px; align-items: stretch; }
.tree .col { display: flex; flex-direction: column; gap: 8px; }
.ties { flex: 1; display: flex; flex-direction: column; justify-content: space-around; gap: 10px; }
.tree h3 { margin: 0; font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--soft); flex: none; }
.tie { border-radius: 16px; background: #fff3e3; overflow: hidden; border: 2px solid transparent; }
.tie.next { border-color: var(--red); box-shadow: 0 8px 20px rgba(224, 74, 80, .2); }
.tie div { display: flex; align-items: center; gap: 8px; padding: 5px 12px 5px 6px; min-height: 42px; }
.tie div + div { border-top: 1px solid var(--line); }
.tie img { width: 32px; height: 32px; border-radius: 50%; background: #ffe1c2; }
.tie b { flex: 1; min-width: 0; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tie i { font-style: normal; font-weight: 900; font-size: 17px; }
.tie .lost { opacity: .5; }
.tie .win i { color: var(--green); }
.tie .me b { color: var(--red); }
.tbd { color: var(--soft); font-weight: 700 !important; padding-left: 8px; }
.cup { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; flex: 1; padding: 14px; border-radius: 20px; background: linear-gradient(180deg, #fff0c4, #ffe199); text-align: center; }
.cup img { width: 96px; height: 96px; border-radius: 50%; background: #fff7df; }
.cup b { font-size: 17px; font-weight: 900; }
.cup .tbd { font-size: 44px; padding: 0; }

/* ---------- result ---------- */
.stats { width: 100%; border-collapse: collapse; }
.stats td { width: 30%; padding: 6px 4px; text-align: center; font-weight: 900; font-size: 18px; }
.stats th { padding: 6px 4px; text-align: center; font-weight: 700; font-size: 13px; color: var(--soft); }
.stats tr + tr { border-top: 1px solid var(--line); }
.stats .who img { display: block; width: 84px; height: 84px; margin: 0 auto 2px; border-radius: 50%; background: #ffe1c2; }
.stats .who b { font-size: 16px; }

/* ---------- the match ---------- */
#hud { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
#hud .tr { position: absolute; top: 16px; right: 16px; display: flex; gap: 8px; pointer-events: auto; }
#hud .tr button { padding: 9px 16px; border-radius: 999px; background: var(--card); box-shadow: 0 4px 14px rgba(90, 60, 40, .14); font-weight: 800; font-size: 13.5px; }
#hud .tr button.off { color: var(--soft); text-decoration: line-through; }
.score { position: absolute; left: 16px; top: 16px; width: min(360px, calc(100vw - 36px)); border-radius: 22px; background: rgba(45, 51, 77, .93); box-shadow: 0 16px 40px rgba(45, 51, 77, .35); color: #fff; overflow: hidden; }
.score header { padding: 8px 16px 6px; font-weight: 800; font-size: 11.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--mint); }
.prow { display: flex; align-items: center; gap: 10px; padding: 7px 16px 7px 10px; border-left: 6px solid transparent; }
.prow + .prow { border-top: 1px solid rgba(255, 255, 255, .1); }
.prow.on { background: rgba(255, 255, 255, .1); border-left-color: var(--gold); }
.prow img { width: 46px; height: 46px; border-radius: 50%; background: rgba(255, 255, 255, .16); }
.prow span { flex: 1; min-width: 0; }
.prow b { display: block; font-size: 17px; font-weight: 900; line-height: 1.15; }
.prow small { display: block; font-weight: 700; font-size: 12px; color: rgba(255, 255, 255, .62); }
.prow i { min-width: 28px; padding: 2px 0; border-radius: 9px; background: rgba(255, 255, 255, .14); font-style: normal; font-weight: 900; font-size: 15px; text-align: center; }
.prow em { min-width: 76px; font-style: normal; font: 900 34px/1 'Inter', var(--sans); text-align: right; letter-spacing: -.02em; }
.prow.on em { color: var(--gold); }
.mid { position: absolute; right: 18px; bottom: 18px; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.visit { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 20px; background: var(--card); box-shadow: var(--shadow); }
.visit i { display: grid; place-items: center; width: 62px; height: 44px; border-radius: 13px; background: #fff; box-shadow: inset 0 0 0 2px var(--line); font-style: normal; font: 900 19px/1 'Inter', var(--sans); }
.visit i.empty { background: rgba(45, 51, 77, .06); box-shadow: none; }
.visit i.t { background: var(--red); color: #fff; box-shadow: none; }
.visit i.d { background: var(--green); color: #fff; box-shadow: none; }
.visit i.miss { color: var(--soft); font-size: 14px; }
.visit b { min-width: 64px; padding: 0 8px; font: 900 30px/1 'Inter', var(--sans); text-align: center; }
.visit.bust b { color: var(--red); }
.hint { min-height: 30px; padding: 5px 14px; border-radius: 999px; background: rgba(45, 51, 77, .88); color: #fff; font-weight: 700; font-size: 13.5px; }
.hint:empty { visibility: hidden; }
.hint small { font-size: 12px; color: var(--mint); }
.hint b { margin-left: 3px; padding: 1px 8px; border-radius: 8px; background: rgba(255, 255, 255, .16); font: 900 14px/1.4 'Inter', var(--sans); }
.top { position: absolute; left: 50%; bottom: 20px; transform: translateX(-50%); display: flex; flex-direction: column-reverse; align-items: center; gap: 8px; width: min(560px, calc(100vw - 420px)); }
.tip { padding: 8px 18px; border-radius: 999px; background: var(--card); box-shadow: 0 4px 14px rgba(90, 60, 40, .14); font-weight: 800; font-size: 14px; text-align: center; opacity: 0; transition: opacity .2s; }
.tip.show { opacity: 1; }
.tip.good { background: var(--green); color: #fff; }
.tip.bad { background: var(--ink); color: #fff; }
#nerve { padding: 6px 16px; border-radius: 999px; background: var(--red); color: #fff; font-weight: 800; font-size: 13px; animation: beat .7s ease-in-out infinite; }
@keyframes beat { 0%, 100% { transform: scale(1); } 30% { transform: scale(1.06); } }
.call { position: absolute; left: 50%; top: 21%; transform: translate(-50%, -50%) scale(.7); display: flex; flex-direction: column; align-items: center; opacity: 0; transition: opacity .18s, transform .28s cubic-bezier(.2, 1.6, .4, 1); text-align: center; white-space: nowrap; }
.call.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.call b { font: 900 clamp(54px, 9vw, 120px)/1 'Inter', var(--sans); letter-spacing: -.03em; color: #fff; -webkit-text-stroke: 10px var(--ink); paint-order: stroke fill; text-shadow: 0 10px 0 rgba(45, 51, 77, .25); }
.call span { margin-top: 10px; padding: 5px 18px; border-radius: 999px; background: var(--ink); color: #fff; font-weight: 800; font-size: 17px; }
.call span:empty { display: none; }
.call.plain b { font-size: clamp(44px, 6vw, 80px); }
.call.max b, .call.win b { color: var(--gold); }
.call.ton b { color: #ffe9a8; }
.call.bad b { color: #ffb3ae; font-size: clamp(44px, 7vw, 90px); }
.call.vs b { font-size: clamp(34px, 5vw, 64px); }
@media (max-width: 760px) { .tree { grid-template-columns: 1fr 1fr; } .top { width: calc(100vw - 32px); bottom: 96px; } }
