@font-face {
  font-family: Copa Pixel;
  src: url("/games/ranking-balls/versus/copa-pixel.ttf") format("truetype");
  font-display: swap;
}
:root {
  color-scheme: dark;
  font-family: system-ui, sans-serif;
  color: #f4f9f4;
  background: #091c17;
  --muted: #c1d7cc;
  --gold: #ffe097;
  --line: #527d6d;
  --panel: #142f27;
}
* { box-sizing: border-box }
[hidden] { display: none !important }
body {
  margin: 0;
  min-height: 100dvh;
  background: linear-gradient(180deg, #2b12354a, #171023ea),
    #0b201b url("/games/ranking-balls/versus/ranking-stadium.webp") center top / cover no-repeat fixed;
}
.lobby {
  position: relative;
  isolation: isolate;
  width: min(100%, 30rem);
  margin: auto;
  padding: clamp(1.2rem, 4vh, 3rem) 1.1rem 2rem;
}
.lobby {
  --panel: #29172c;
  --line: #a87b44;
  --gold: #f2b752;
  --muted: #efddbb;
}
.lobby header { text-align: center; margin-bottom: 1.25rem }
h1 { font: clamp(2rem, 8.5vw, 3.15rem)/1.08 Copa Pixel, system-ui, sans-serif; margin: .45rem 0; color: #ffe9ae; text-shadow: 0 4px #20102b }
h2 { font-size: 1.2rem; margin: 0 0 .65rem }
p { color: var(--muted); margin: .65rem 0 }
.cup-name { font: .91rem Copa Pixel, system-ui, sans-serif; text-transform: uppercase; letter-spacing: .15em; color: #ffe9ae }
.yumi-stage {
  position: relative;
  display: grid;
  place-items: center;
  height: clamp(9rem, 27vh, 14rem);
  margin-top: .45rem;
  isolation: isolate;
}
.yumi-play {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: contain;
}
#setup, #room, .ranking {
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: .75rem;
  padding: clamp(.8rem, 4vw, 1.25rem);
  box-shadow: 0 6px 0 #160e21, 0 15px 30px #140d1c66;
}
#setup:has(.game-modes:not([hidden])) { background: #29172cdf }
label { display: block; font-size: .85rem; font-weight: 650; margin-bottom: .35rem }
input, button, a { font: inherit }
input, button, #share-result { border-radius: .55rem; min-height: 2.75rem }
input { width: 100%; min-width: 0; padding: .65rem .7rem; background: #160f21; border: 1px solid var(--line); color: inherit }
button, #share-result {
  padding: .58rem .75rem;
  background: #24473a;
  border: 1px solid var(--line);
  color: inherit;
  font-weight: 680;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}
button:focus-visible, a:focus-visible, input:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px }
button:disabled { opacity: .55; cursor: default }
.primary { width: 100%; background: var(--gold); color: #241a09; border-color: var(--gold); margin-top: .6rem }
.game-modes { display: grid; gap: .85rem }
.mode-card {
  display: flex;
  min-height: 5rem;
  align-items: center;
  gap: .9rem;
  padding: .65rem .85rem;
  color: #ffe9ae;
  border: 2px solid var(--gold);
  border-radius: .55rem;
  box-shadow: inset 0 -5px #0003, 0 4px #180c21;
  text-decoration: none;
}
.mode-card.solo { background: linear-gradient(#9c3b55, #662039) }
.mode-card.duel { background: linear-gradient(#245d93, #193554) }
.mode-card:hover { filter: brightness(1.15) }
.mode-card strong { display: block; font: clamp(1.15rem, 5vw, 1.55rem) Copa Pixel, system-ui, sans-serif }
.mode-card small { display: block; margin-top: .2rem }
.mode-card img, .mode-vs { width: 3rem; flex: none }
.mode-vs { font: 1.35rem Copa Pixel, system-ui, sans-serif; text-align: center; color: #fff0bd }
.versus-heading, .room-links { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .55rem }
.versus-heading { margin-bottom: .95rem }
.versus-heading h2 { margin: 0; font: 1.3rem Copa Pixel, system-ui, sans-serif; color: #ffe9ae }
.versus-heading h2 span { font-size: .75rem }
.versus-heading a, .room-links a { color: #ffe9ae; font-size: .82rem }
.join, .actions { display: flex; gap: .5rem }
.actions { flex-wrap: wrap; margin: .75rem 0 .4rem }
.actions > * { flex: 1 }
.lobby button:not(.primary, .quiet) { background: #233c60 }
#join-form { border-top: 1px solid #a87b4480; margin-top: 1rem; padding-top: .9rem }
#code { text-transform: uppercase }
#code::placeholder { text-transform: none }
#room { text-align: center }
.room-code {
  font: clamp(1rem, 5.5vw, 2.25rem) Copa Pixel, ui-monospace, monospace;
  letter-spacing: .09em;
  overflow-wrap: anywhere;
  background: #1b1026;
  border: 1px solid #a87b4480;
  border-radius: .45rem;
  padding: .55rem .2rem;
  color: #ffe9ae;
  user-select: all;
}
.quiet { background: transparent }
#notice { min-height: 1rem; font-size: .88rem; text-align: center }
#notice:empty { min-height: 0 }
.ranking { margin-top: 1rem }
.ranking table { border-collapse: collapse; width: 100%; font-size: .88rem }
.ranking th, .ranking td { text-align: right; padding: .45rem .2rem; border-bottom: 1px solid #a87b444a }
.ranking th:nth-child(2), .ranking td:nth-child(2) { text-align: left; overflow-wrap: anywhere }
.ranking th { color: var(--muted) }
.ranking td:nth-child(3) { color: var(--gold) }
.ranking-links { display: flex; flex-wrap: wrap; gap: .6rem 1rem; margin-top: .75rem; font-size: .84rem }
.ranking-links a { color: #ffe9ae }
.music-control { display: block; margin: .95rem auto 0 }
.match {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(100%, 54rem);
  margin: auto;
  height: 100dvh;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  background: #0b261f;
}
.rival {
  display: flex;
  align-items: center;
  gap: clamp(.35rem, 2vw, .85rem);
  background: linear-gradient(115deg, #13392e, #10261f);
  border-bottom: 1px solid var(--line);
  padding: .35rem .65rem;
}
.rival-visual { display: flex; align-items: center; flex: none }
#rival-board { display: block; width: clamp(74px, 23vw, 122px); max-height: clamp(74px, 16dvh, 126px); height: auto; object-fit: contain }
.yumi-next { flex: none; width: clamp(36px, 12vw, 58px); height: clamp(77px, 13dvh, 106px); display: flex; flex-direction: column; align-items: center; gap: .08rem }
.yumi-next span { font-size: .6rem; color: var(--muted) }
.yumi-next .next-ball { width: 22px; height: 22px; object-fit: contain }
.yumi-next .yumi { min-height: 0; flex: 1; width: 100%; object-fit: contain; object-position: center top }
.rival-info { min-width: 0; flex: 1; display: grid; gap: .2rem }
.scoreboard {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: .25rem;
  padding: .34rem;
  background: #081e17;
  border: 1px solid #4d7463;
  border-radius: .65rem;
}
.score-side { min-width: 0; text-align: center }
.score-side span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: .72rem }
.score-side strong { display: block; color: var(--gold); font-size: clamp(1.1rem, 5vw, 1.65rem); line-height: 1.1; font-variant-numeric: tabular-nums; overflow-wrap: anywhere }
.versus { color: var(--muted); font-size: .64rem; font-weight: 800 }
.match-actions { display: flex; justify-content: flex-end; align-items: center; gap: .35rem }
#match-info { color: var(--muted); font-size: .7rem; line-height: 1.2; flex: 1 }
#options { min-height: 2rem; padding: .28rem .53rem; font-size: .77rem }
.field { position: relative; min-height: 0 }
iframe { display: block; width: 100%; height: 100%; border: 0; background: #0b2c24 }
.result {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(88%, 22rem);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 1.25rem;
  text-align: center;
  box-shadow: 0 0 0 100vmax #05150eb8;
}
.result button { width: 100%; margin-top: .45rem }
.result [role="status"] { font-size: .85rem }
.result a { display: block; margin-top: 1rem }
#match-options { width: min(90%, 22rem); padding: 1.1rem; background: var(--panel); color: inherit; border: 1px solid var(--line); border-radius: 1rem }
#match-options::backdrop { background: #06150ec7 }
#match-options button { width: 100%; margin-top: .45rem }
#match-options p { min-height: 1.15rem; font-size: .85rem }
#confirm-abandon { background: #71334b; border-color: #d57c96 }
