:root { font-size: clamp(10px, calc(min(2.5vh, 1.55vw) + 3px), 21px); --red: #d8302b; --red2: #a81c1c; --gold: #ffc93c; --ink: #2a1a0e; --cream: #fff6e0; --green: #2f8f3a; }
@media (max-aspect-ratio: 4/5) { :root { font-size: clamp(11px, 3.7vw, 18px); } }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #1d5a2a; font-family: "Trebuchet MS", "Segoe UI", Roboto, Arial, sans-serif; color: var(--ink); user-select: none; -webkit-user-select: none; touch-action: none; overscroll-behavior: none; }
canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; touch-action: manipulation; }
.hide { display: none !important; }

#hud { position: fixed; top: max(6px, env(safe-area-inset-top)); right: 6px; display: flex; gap: 6px; z-index: 20; }
.round { width: 2.6rem; height: 2.6rem; min-width: 34px; min-height: 34px; border-radius: 50%; background: rgba(255, 246, 224, .92); border: 3px solid var(--ink); display: grid; place-items: center; padding: 0; box-shadow: 0 3px 0 var(--ink); }
.round svg { width: 60%; height: 60%; fill: none; stroke: var(--ink); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.round svg .fill { fill: var(--ink); stroke: none; }
#btnMute .off { display: none; } #btnMute.muted .on { display: none; } #btnMute.muted .off { display: inline; }
#btnMusic.off { opacity: .45; }
#hint { position: fixed; left: 50%; bottom: 6px; transform: translateX(-50%); z-index: 15; background: rgba(42, 26, 14, .78); color: #fff; padding: .3rem .8rem; border-radius: 99px; font-size: .85rem; pointer-events: none; max-width: 94vw; width: max-content; text-align: center; line-height: 1.25; }

/* touch pads */
#touch { position: fixed; inset: auto 0 0 0; z-index: 12; pointer-events: none; display: flex; justify-content: space-between; padding: 0 max(8px, env(safe-area-inset-left)) max(8px, env(safe-area-inset-bottom)); }
.pad { display: grid; grid-template-columns: repeat(2, var(--b)); gap: 8px; --b: clamp(46px, 11vmin, 76px); pointer-events: auto; }
#touch.solo .pad#padR { display: none; }
#touch.solo { justify-content: stretch; }
#touch.solo .pad#padL { grid-template-columns: repeat(2, var(--b)) 1fr repeat(2, var(--b)); width: 100%; }
#touch.solo .pad#padL .j { grid-column: 4; grid-row: 1; } #touch.solo .pad#padL .k { grid-column: 5; grid-row: 1; }
.pad button { width: var(--b); height: var(--b); border-radius: 18px; background: rgba(255, 246, 224, .55); border: 3px solid rgba(42, 26, 14, .75); font-weight: 800; font-size: calc(var(--b) * .3); color: var(--ink); }
.pad button.j { background: rgba(255, 201, 60, .7); } .pad button.k { background: rgba(216, 48, 43, .75); color: #fff; }
.pad button.on { transform: scale(.92); filter: brightness(1.2); }
#padR button.k { background: rgba(40, 110, 210, .75); }

/* panels */
.panel { position: fixed; inset: 0; z-index: 30; display: none; align-items: center; justify-content: center; padding: 8px; background: rgba(30, 20, 8, .38); }
.panel.show { display: flex; }
.card { background: var(--cream); border: 4px solid var(--ink); border-radius: 22px; box-shadow: 0 6px 0 var(--ink); padding: 1rem 1.2rem; max-height: calc(100% - 4px); max-width: 100%; overflow: auto; text-align: center; position: relative; }
.card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: .55rem; background: repeating-linear-gradient(90deg, var(--red) 0 1.4rem, var(--gold) 1.4rem 2.8rem); border-radius: 18px 18px 0 0; }
#menu { background: rgba(30, 20, 8, .25); }
.mcard { display: flex; gap: 1.2rem; align-items: center; width: min(62rem, 100%); text-align: left; padding: 1.1rem 1.3rem .9rem; }
.mcard .left { flex: 1 1 45%; display: flex; flex-direction: column; align-items: center; text-align: center; min-width: 0; }
.mcard .right { flex: 1 1 55%; display: flex; flex-direction: column; gap: .5rem; min-width: 0; }
#mascot { width: min(14rem, 30vh); height: auto; filter: drop-shadow(0 4px 0 rgba(42, 26, 14, .25)); }
h1 { margin: .1rem 0 0; font-size: 2.5rem; line-height: 1.05; color: var(--red); text-shadow: 0 3px 0 var(--gold), 0 4px 0 var(--ink); letter-spacing: .5px; }
.sub { font-weight: 800; font-size: 1.1rem; color: var(--green); margin-top: .25rem; }
.intro { margin: .45rem 0 0; font-size: .92rem; line-height: 1.35; }
.big { display: block; width: 100%; background: linear-gradient(var(--red), var(--red2)); color: #fff; font-weight: 900; font-size: 1.6rem; padding: .55rem .6rem; border-radius: 16px; border: 3px solid var(--ink); box-shadow: 0 4px 0 var(--ink); letter-spacing: .5px; text-shadow: 0 2px 0 rgba(0, 0, 0, .3); }
.big small { display: block; font-size: .8rem; font-weight: 700; opacity: .95; letter-spacing: 0; }
.big:active, .mode:active, .small:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--ink); }
.modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: .45rem; }
.mode { background: var(--gold); border: 3px solid var(--ink); border-radius: 14px; box-shadow: 0 3px 0 var(--ink); padding: .4rem .3rem; text-align: center; line-height: 1.15; }
.mode b { display: block; font-size: 1.05rem; } .mode i { display: block; font-style: normal; font-size: .75rem; opacity: .85; }
.row { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.lbl { font-weight: 800; font-size: .85rem; min-width: 5.8rem; }
.teams { display: flex; gap: .3rem; flex-wrap: wrap; flex: 1; }
.teams button { padding: 2px; border-radius: 7px; background: transparent; border: 2px solid transparent; line-height: 0; }
.teams button img { width: 2.3rem; height: 1.55rem; border-radius: 4px; border: 2px solid var(--ink); display: block; }
.teams button.sel { border-color: var(--red); background: var(--gold); }
.teamName { font-weight: 800; font-size: .85rem; color: var(--red); }
.seg { display: inline-flex; border: 3px solid var(--ink); border-radius: 12px; overflow: hidden; }
.seg button { background: #fff; padding: .25rem .8rem; font-weight: 800; font-size: .9rem; border-right: 2px solid var(--ink); }
.seg button:last-child { border-right: 0; }
.seg button.sel { background: var(--green); color: #fff; }
.keys { display: flex; flex-wrap: wrap; gap: .3rem .8rem; font-size: .8rem; align-items: center; }
.k { display: inline-block; min-width: 1.5rem; padding: 0 .3rem; margin-right: 2px; border: 2px solid var(--ink); border-bottom-width: 4px; border-radius: 6px; background: #fff; font-weight: 800; text-align: center; font-size: .78rem; }
.tch { opacity: .8; }
.stats { font-size: .78rem; opacity: .85; }
.rt { font-size: 2.2rem; font-weight: 900; color: var(--red); text-shadow: 0 3px 0 var(--gold); margin-top: .2rem; }
.score { font-size: 2.8rem; font-weight: 900; margin: .2rem 0; }
.score img { width: 2.6rem; height: 1.75rem; border: 2px solid var(--ink); border-radius: 4px; vertical-align: middle; margin: 0 .5rem; }
.rs { font-size: 1rem; margin: .2rem 0 .6rem; max-width: 30rem; }
.btns { display: flex; flex-direction: column; gap: .45rem; align-items: stretch; min-width: 15rem; }
.small { background: #fff; border: 3px solid var(--ink); border-radius: 12px; padding: .35rem 1rem; font-weight: 800; box-shadow: 0 3px 0 var(--ink); font-size: 1rem; }
#result .card, #pause .card, #cup .card { min-width: min(22rem, 100%); display: flex; flex-direction: column; align-items: center; }
.bracket { display: grid; grid-template-columns: repeat(4, auto); gap: .3rem 1rem; align-items: center; font-size: .85rem; margin: .4rem 0; }
.bracket .col { display: flex; flex-direction: column; gap: .3rem; justify-content: space-around; height: 100%; }
.bracket .t { display: flex; align-items: center; gap: .3rem; background: #fff; border: 2px solid var(--ink); border-radius: 8px; padding: .12rem .4rem; white-space: nowrap; font-weight: 700; }
.bracket .t img { width: 1.5rem; height: 1rem; border: 1px solid var(--ink); border-radius: 2px; }
.bracket .t.me { background: var(--gold); }
.bracket .t.out { opacity: .4; text-decoration: line-through; }
.bracket .t.tbd { color: #999; }
.bracket h4 { margin: 0 0 .2rem; font-size: .8rem; color: var(--green); }

@media (max-height: 560px) {
  #mascot { width: min(10rem, 28vh); }
  h1 { font-size: 2.1rem; }
  .card { padding: .7rem .9rem; }
  .mcard { padding: .8rem 1rem .6rem; }
}
@media (max-height: 400px) {
  #mascot { width: 6.5rem; }
  .intro { font-size: .82rem; }
  .big { font-size: 1.35rem; padding: .4rem; }
  .rt { font-size: 1.7rem; } .score { font-size: 2.1rem; }
  .bracket { font-size: .75rem; gap: .15rem .6rem; }
}
@media (max-aspect-ratio: 4/5) {
  .mcard { flex-direction: column; gap: .5rem; padding: 1rem .8rem .8rem; }
  .mcard .left { flex: none; }
  .mcard .right { flex: none; width: 100%; }
  #mascot { width: min(9rem, 24vh); }
  .ttl h1 { font-size: 2.2rem; }
  .bracket { grid-template-columns: repeat(2, auto); }
}
.bracket .col { justify-content: flex-start; align-self: stretch; }
.bracket .lst { flex: 1; display: flex; flex-direction: column; justify-content: space-around; gap: .3rem; }
