@font-face { font-family: "PS2P"; src: url("lib/font/ps2p.woff2") format("woff2"); font-display: block; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #0b0f1a; color: #f4f4f4; font-family: "PS2P", monospace; overflow: hidden; }
#stage { position: relative; width: min(100vw, 133.333vh); height: min(75vw, 100vh); margin: 0 auto; top: 50%; transform: translateY(-50%); }
#game { width: 100%; height: 100%; display: block; image-rendering: pixelated; image-rendering: crisp-edges; background: #000; }

.overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(6, 10, 22, .78); }
.hidden { display: none !important; }
.panel { width: min(92%, 720px); max-height: 96%; overflow: auto; background: #101828; border: 4px solid #f4f4f4; box-shadow: 0 0 0 4px #000, 8px 8px 0 4px #000; padding: 18px 22px; text-align: center; }
.panel.small { width: min(80%, 420px); }
h1 { font-size: clamp(22px, 4.4vw, 40px); margin: 6px 0 6px; color: #ffd23f; text-shadow: 4px 4px 0 #c2410c; letter-spacing: 2px; }
h1 span { color: #7dd3fc; text-shadow: 4px 4px 0 #1d4ed8; margin-left: 14px; }
h2 { font-size: 20px; color: #ffd23f; text-shadow: 3px 3px 0 #c2410c; }
.tag { font-size: 9px; color: #a5b4fc; margin: 0 0 14px; line-height: 1.6; }
.row { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 8px 0; flex-wrap: wrap; }
.row label { font-size: 9px; width: 120px; text-align: right; color: #cbd5e1; }
.seg { display: flex; gap: 4px; flex-wrap: wrap; }
button { font-family: inherit; cursor: pointer; }
.seg button { font-size: 9px; padding: 7px 9px; background: #1e293b; color: #e2e8f0; border: 2px solid #475569; }
.seg button.on { background: #ffd23f; color: #111; border-color: #fff; }
.starts { display: flex; gap: 12px; justify-content: center; margin: 16px 0 6px; flex-wrap: wrap; }
.big { font-size: 11px; padding: 12px 14px; background: #22c55e; color: #052e16; border: 3px solid #fff; box-shadow: 4px 4px 0 #000; margin: 6px; }
.big.alt { background: #38bdf8; color: #082f49; }
.big.two { background: #fb7185; color: #4c0519; }
.big:hover { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 #000; }
.big:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 #000; }
.how { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; text-align: left; font-size: 8px; line-height: 1.9; color: #cbd5e1; margin-top: 12px; }
.how > div { border: 2px dashed #334155; padding: 8px 10px; }
.how b { color: #ffd23f; }
.tip { font-size: 8px; color: #86efac; line-height: 1.7; margin: 12px 0 4px; }
.rec { font-size: 8px; color: #94a3b8; margin: 6px 0 0; line-height: 1.7; }
.err { font-size: 8px; color: #fca5a5; min-height: 10px; line-height: 1.6; }
#overStats { font-size: 9px; line-height: 2; color: #cbd5e1; }

#camBox { position: fixed; right: 10px; bottom: 10px; background: #000; border: 3px solid #f4f4f4; box-shadow: 4px 4px 0 #000; z-index: 5; }
#cam { display: block; width: 320px; height: 240px; }
#camStatus { font-size: 8px; padding: 5px 6px; background: #101828; color: #ffd23f; line-height: 1.5; max-width: 320px; }
@media (max-width: 700px) { .how { grid-template-columns: 1fr; } #cam { width: 150px; height: 112px; } #camStatus { max-width: 150px; } }

/* ---- cover page */
.cover { flex-direction: column; background: radial-gradient(ellipse at center, rgba(10, 16, 30, .78), rgba(6, 10, 22, .96)); overflow: hidden; z-index: 6; cursor: pointer; }
.coverInner { text-align: center; }
.coverTitle { font-size: clamp(34px, 8vw, 84px); margin: 0; line-height: 1.15; letter-spacing: 3px; }
.coverTitle b { display: inline-block; font-weight: normal; opacity: 0; transform: translateY(75vh); animation: coverRise 1.3s cubic-bezier(.2, .9, .25, 1.12) .2s forwards; }
.coverTitle .w1 { color: #ffd23f; text-shadow: 6px 6px 0 #c2410c; }
.coverTitle .w2 { color: #7dd3fc; text-shadow: 6px 6px 0 #1d4ed8; margin-left: .5em; animation-delay: .55s; }
.coverBall { width: 18px; height: 18px; margin: 0 auto 22px; background: #e5f97a; border-radius: 50%; box-shadow: inset -3px -3px 0 #a3b81f, 3px 3px 0 #000; opacity: 0;
  animation: coverFade .3s ease 1.6s forwards, coverHop .55s ease-in-out 1.6s infinite alternate; }
.coverTag { font-size: clamp(8px, 1.4vw, 12px); color: #a5b4fc; opacity: 0; margin: 20px 0 28px; animation: coverFade .6s ease 1.8s forwards; }
.coverBtn { font-size: clamp(11px, 1.8vw, 16px); padding: 14px 24px; opacity: 0; animation: coverFade .5s ease 2.2s forwards; }
.coverHint { font-size: 8px; color: #94a3b8; opacity: 0; margin-top: 16px; animation: coverFade .5s ease 2.4s forwards; }
@keyframes coverRise { 0% { opacity: 0; transform: translateY(75vh); } 40% { opacity: 1; } 100% { opacity: 1; transform: none; } }
@keyframes coverFade { to { opacity: 1; } }
@keyframes coverHop { from { transform: translateY(0); } to { transform: translateY(-28px); } }
@keyframes coverBlink { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .cover * { animation: none !important; opacity: 1 !important; transform: none !important; } }

/* ---- menu layout: PLAY and SETTINGS side by side */
.menuPanel { width: min(94%, 880px); }
.menuGrid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 4px; }
.card { border: 3px solid #334155; background: #0b1220; padding: 10px 14px 6px; box-shadow: 4px 4px 0 #000; }
.card h3 { font-size: 11px; color: #ffd23f; margin: 2px 0 12px; letter-spacing: 1px; }
.big.wide { display: block; width: 100%; margin: 0 0 11px; text-align: left; }
.card .row { flex-direction: column; gap: 6px; margin: 4px 0 10px; }
.card .row label { width: auto; text-align: center; }
.card .seg { justify-content: center; }
.card .tip { margin: -4px 0 8px; }
.menuFoot { display: flex; gap: 12px; justify-content: center; margin-top: 12px; flex-wrap: wrap; }
.big.gold { background: #facc15; color: #422006; }
.big.ghost { background: #1e293b; color: #e2e8f0; }
@media (max-width: 700px) { .menuGrid { grid-template-columns: 1fr; } }

/* ---- locker room: big preview on the left, tabbed options on the right */
.locker { width: min(94%, 900px); }
.lockGrid { display: grid; grid-template-columns: auto 1fr; gap: 18px; align-items: start; text-align: left; margin-top: 4px; }
.lockLeft { text-align: center; }
.lockWho { justify-content: center; margin: 0 0 10px; }
.lockWho button { font-size: 10px; padding: 8px 14px; }
.lockPrev { border: 3px solid #334155; background: #0b1220; padding: 6px; box-shadow: 4px 4px 0 #000; }
#lockCv { width: 400px; height: 224px; image-rendering: pixelated; image-rendering: crisp-edges; display: block; }
.lockLeft .tip { max-width: 412px; margin: 10px auto 0; }
.lockTabs { display: flex; gap: 0; border-bottom: 3px solid #334155; margin-bottom: 12px; }
.lockTabs button { flex: 1; font-size: 10px; padding: 10px 6px; background: #1e293b; color: #94a3b8; border: 3px solid #334155; border-bottom: none; margin-right: -3px; }
.lockTabs button.on { background: #ffd23f; color: #111; border-color: #fff; }
.lockOpts { min-height: 230px; }
.optRow { margin: 0 0 14px; }
.optRow > span { display: block; font-size: 9px; color: #cbd5e1; margin-bottom: 7px; }
.optRow .seg { gap: 6px; }
.optRow .seg button { font-size: 9px; padding: 7px 10px; }
.optRow .seg button.sw { width: 28px; height: 28px; padding: 0; border: 3px solid #0b1220; box-shadow: 0 0 0 2px #475569; }
.optRow .seg button.sw:hover { box-shadow: 0 0 0 2px #cbd5e1; }
.optRow .seg button.sw.on { box-shadow: 0 0 0 3px #fff, 0 0 0 5px #ffd23f; }
@media (max-width: 820px) { .lockGrid { grid-template-columns: 1fr; } .lockLeft { justify-self: center; } #lockCv { width: 300px; height: 168px; } }

/* ---- two players: both must be ready */
.readyPlayers { display: flex; gap: 10px; justify-content: center; margin: 6px 0 10px; }
.readyPlayers span { font-size: 9px; padding: 9px 10px; border: 3px solid #475569; background: #1e293b; color: #cbd5e1; min-width: 150px; }
.readyPlayers span.on { border-color: #fff; background: #22c55e; color: #052e16; }
.big:disabled { background: #334155; color: #94a3b8; cursor: default; transform: none; box-shadow: 4px 4px 0 #000; }
/* phones held sideways (short screens): small camera preview that sits in the empty space beside the court */
@media (max-height: 560px) {
  #camBox { right: 4px; bottom: 4px; border-width: 2px; }
  #cam { width: 168px; height: 126px; }
  #camStatus { max-width: 168px; font-size: 7px; padding: 3px 4px; }
}

/* ---- touch controls (phones / tablets) */
#touchUI { position: fixed; inset: 0; pointer-events: none; z-index: 7; }
#touchUI .tpad, #touchUI .tpause { pointer-events: auto; touch-action: none; user-select: none; -webkit-user-select: none; }
.stick { position: fixed; bottom: 18px; width: 128px; height: 128px; border-radius: 50%; background: rgba(15, 23, 42, .55); border: 3px solid rgba(255, 255, 255, .55); touch-action: none; }
.knob { position: absolute; left: 50%; top: 50%; width: 54px; height: 54px; margin: -27px 0 0 -27px; border-radius: 50%; background: rgba(255, 210, 63, .9); border: 3px solid #fff; box-shadow: 2px 2px 0 #000; }
.tbtns { position: fixed; bottom: 18px; display: flex; gap: 12px; align-items: flex-end; }
.tbtn { font-family: inherit; font-size: 10px; color: #111; border: 3px solid #fff; border-radius: 50%; box-shadow: 3px 3px 0 #000; touch-action: none; }
.tbtn.swing { width: 92px; height: 92px; background: rgba(34, 197, 94, .92); }
.tbtn.lob { width: 66px; height: 66px; background: rgba(56, 189, 248, .92); margin-bottom: 36px; }
.tbtn.down { transform: scale(.92); filter: brightness(1.2); }
.tpause { position: fixed; top: 10px; right: 10px; width: 46px; height: 46px; font-size: 18px; background: rgba(15, 23, 42, .75); color: #fff; border: 3px solid #fff; border-radius: 10px; }
/* one player: joystick bottom-left, buttons bottom-right */
#touchUI.one .tpad[data-p="0"] .stick { left: 18px; }
#touchUI.one .tpad[data-p="0"] .tbtns { right: 18px; }
/* two players: P1 on the left (stick, buttons above it), P2 on the right */
#touchUI.two .stick { width: 112px; height: 112px; }
#touchUI.two .tbtn.swing { width: 72px; height: 72px; }
#touchUI.two .tbtn.lob { width: 54px; height: 54px; margin-bottom: 0; }
#touchUI.two .tpad[data-p="0"] .stick { left: 14px; }
#touchUI.two .tpad[data-p="0"] .tbtns { left: 14px; bottom: 142px; }
#touchUI.two .tpad[data-p="1"] .stick { right: 14px; }
#touchUI.two .tpad[data-p="1"] .tbtns { right: 14px; bottom: 142px; flex-direction: row-reverse; }
#touchUI.two .tpad[data-p="0"] .knob { background: rgba(250, 204, 21, .9); }
#touchUI.two .tpad[data-p="1"] .knob { background: rgba(251, 113, 133, .9); }
@media (max-height: 430px) { .stick { width: 104px; height: 104px; } .tbtn.swing { width: 76px; height: 76px; } .tbtn.lob { width: 56px; height: 56px; margin-bottom: 24px; }
  #touchUI.two .tpad .tbtns { bottom: 124px !important; } #touchUI.two .stick { width: 96px; height: 96px; } }
/* practice (warm-up for new players) */
.pracRow { display: flex; gap: 8px; margin: 0 0 11px; }
.pracRow .big.prac { flex: 1; margin: 0; padding: 9px 6px; font-size: 9px; line-height: 1.6; background: #a78bfa; color: #2e1065; }
/* credit line: bottom of the cover page and the menu */
.credit { font-size: 8px; color: #94a3b8; letter-spacing: 1px; margin: 10px 0 0; }
.coverCredit { position: absolute; left: 0; right: 0; bottom: 14px; margin: 0; text-align: center; opacity: 0; animation: coverFade .6s ease 2.6s forwards; }
