* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden;
  position: fixed; inset: 0; overscroll-behavior: none;
  background: #1f9e5a;
  font-family: "Trebuchet MS", "Avenir Next", system-ui, -apple-system, sans-serif;
  -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none; -webkit-text-size-adjust: 100%;
}
canvas#court { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#topbar {
  position: absolute; top: 0; left: 0; right: 0; height: 64px;
  padding: max(8px, env(safe-area-inset-top)) 10px 0; display: flex; align-items: flex-start; justify-content: space-between;
  pointer-events: none; z-index: 2;
}
.iconbtn {
  pointer-events: auto; width: 52px; height: 52px; border-radius: 16px; border: none;
  background: rgba(255,255,255,.9); font-size: 28px; line-height: 52px; text-align: center;
  text-decoration: none; box-shadow: 0 4px 0 rgba(0,0,0,.2); cursor: pointer; padding: 0;
}
#scoreboard {
  background: #20265a; color: #fff; border-radius: 14px; padding: 4px 10px; font-size: 19px;
  box-shadow: 0 4px 0 rgba(0,0,0,.25); min-width: 230px;
}
#scoreboard .row { display: flex; align-items: center; gap: 8px; height: 26px; }
#scoreboard .who { flex: 1; text-align: left; font-weight: bold; }
#scoreboard .you .who { color: #ffb347; }
#scoreboard .cpu .who { color: #c9a6ff; }
#scoreboard .serve { width: 22px; font-size: 15px; visibility: hidden; }
#scoreboard .serve.on { visibility: visible; }
#scoreboard .games { width: 26px; text-align: center; background: #3a428f; border-radius: 6px; }
#scoreboard .pts { width: 40px; text-align: center; background: #ffe14d; color: #20265a; border-radius: 6px; font-weight: bold; }
.overlay {
  position: absolute; inset: 0; display: none; align-items: center; justify-content: center;
  background: rgba(20, 30, 80, .45); z-index: 5; padding: 16px;
}
.overlay.show { display: flex; }
.panel {
  background: #fff; color: #2a1a5e; border-radius: 28px; padding: 22px 26px 18px; max-width: 520px; width: 100%;
  text-align: center; box-shadow: 0 10px 0 #3b1f8f, 0 16px 40px rgba(0,0,0,.35);
}
.panel h1 { margin: 4px 0 8px; font-size: 44px; color: #ff5e7e; }
.panel p { font-size: 20px; margin: 6px 0 14px; line-height: 1.35; }
.panel .big { font-size: 72px; line-height: 1; }
.levels { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin: 8px 0 12px; }
.lvl {
  font: inherit; font-size: 24px; font-weight: bold; color: #fff; border: none; border-radius: 18px;
  padding: 14px 22px; min-width: 130px; cursor: pointer;
}
.lvl:active { transform: translateY(4px); }
.lvl.easy { background: #2ec46d; box-shadow: 0 6px 0 #1b8a4a; }
.lvl.medium { background: #ff9a3c; box-shadow: 0 6px 0 #c76a12; }
.lvl.hard { background: #ff4d6d; box-shadow: 0 6px 0 #b32843; }
.small { color: #6a4fc9; font-size: 17px; text-decoration: none; display: inline-block; margin-top: 4px; }
.modes { display: flex; gap: 10px; justify-content: center; margin: 6px 0 4px; }
.mode {
  font: inherit; font-size: 21px; font-weight: bold; color: #2a1a5e; background: #eee8ff; border: 3px solid #d6ccff;
  border-radius: 18px; padding: 10px 14px; flex: 1; max-width: 220px; cursor: pointer; line-height: 1.15;
}
.mode small { display: block; font-size: 15px; font-weight: bold; opacity: .85; }
.mode.on { background: #6a4fc9; border-color: #3b1f8f; color: #fff; box-shadow: 0 5px 0 #3b1f8f; }
.mode.on .tb { color: #9cd0ff; } .mode.on .tr { color: #ffb3b3; }
.tb { color: #1f6bff; } .tr { color: #e52b2b; }
.panel p.pick { margin: 0 0 4px; font-weight: bold; }
.lvl.games { min-width: 80px; background: linear-gradient(90deg, #2f7bff 50%, #ff3b3b 50%); box-shadow: 0 6px 0 #3b1f8f; }
[hidden] { display: none !important; }
body.two-p #scoreboard .you .who { color: #7cc0ff; }
body.two-p #scoreboard .cpu .who { color: #ff8a8a; }
body.two-p #scoreboard .you .pts { background: #5aa9ff; }
body.two-p #scoreboard .cpu .pts { background: #ff7b7b; }
@media (max-width: 420px) { #scoreboard { min-width: 0; font-size: 16px; } .lvl { min-width: 100px; font-size: 20px; } .lvl.games { min-width: 64px; } .mode { font-size: 18px; } }
