* { 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; } }
/* ---------- Racket Shop ---------- */
.shopbtn {
  font: inherit; font-size: 22px; font-weight: bold; color: #fff; border: none; border-radius: 18px; cursor: pointer;
  padding: 12px 20px; margin: 4px 0 6px; min-height: 56px;
  background: linear-gradient(135deg, #8a2be2, #3a6bff); box-shadow: 0 6px 0 #2a137a;
}
.shopbtn:active { transform: translateY(4px); }
.shopbtn .bal { background: rgba(255,255,255,.22); border-radius: 12px; padding: 2px 10px; margin-left: 6px; }
.earned { font-size: 20px; font-weight: bold; color: #2a1a5e; background: #fff6c7; border: 3px solid #ffd84d;
  border-radius: 16px; padding: 8px 12px; margin: 0 0 10px; }
.earned:empty { display: none; }
.earned .tot { font-size: 28px; color: #e08a00; display: block; }
.earned .why { font-size: 16px; font-weight: normal; color: #5a4a8e; }
.shoppanel { max-width: 760px; max-height: calc(100% - 8px); overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: linear-gradient(180deg, #fff 0%, #f3edff 100%); padding: 16px 18px 14px; }
.shoppanel h1 { font-size: 40px; margin: 0 0 4px; color: #6a2be2; }
.wallet { display: inline-block; font-size: 30px; font-weight: bold; color: #2a1a5e; background: #ffe14d;
  border-radius: 20px; padding: 6px 22px; box-shadow: 0 5px 0 #d4a800; }
.panel p.shophint { font-size: 18px; margin: 10px 0 8px; }
.shopgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 6px 0 8px; }
@media (max-width: 560px) { .shopgrid { grid-template-columns: repeat(2, 1fr); } }
.rk { background: #fff; border: 4px solid #e2d8ff; border-radius: 20px; padding: 8px 8px 10px; display: flex; flex-direction: column; align-items: center; }
.rk.equipped { border-color: #2ec46d; box-shadow: 0 0 0 3px #b6f0cf; }
.rk.special { border-color: #b14bff; background: linear-gradient(160deg, #fff 0%, #efe4ff 60%, #e1ecff 100%); }
.rk canvas { width: 110px; height: 110px; }
.rk .nm { font-size: 22px; font-weight: bold; color: #2a1a5e; }
.rk .bl { font-size: 14px; color: #6a5a9e; min-height: 18px; margin-bottom: 6px; }
.rk button { font: inherit; font-size: 21px; font-weight: bold; color: #fff; border: none; border-radius: 16px;
  min-height: 56px; width: 100%; cursor: pointer; padding: 8px 6px; }
.rk button:active { transform: translateY(3px); }
.rk button.buy { background: #ff9a3c; box-shadow: 0 5px 0 #c76a12; }
.rk button.buy.cant { background: #c9bfe6; box-shadow: 0 5px 0 #9a8fc0; }
.rk button.use { background: #3a86ff; box-shadow: 0 5px 0 #1f56b8; }
.rk button.on { background: #2ec46d; box-shadow: 0 5px 0 #1b8a4a; }
.shopmsg { min-height: 30px; font-size: 21px; font-weight: bold; color: #6a2be2; margin: 4px 0 8px; }
.shopmsg.need { color: #e0457a; }
@media (max-height: 820px) {
  .shoppanel { padding: 10px 14px 10px; }
  .shoppanel h1 { font-size: 32px; margin: 0 0 2px; }
  .wallet { font-size: 24px; padding: 3px 18px; }
  .panel p.shophint { font-size: 16px; margin: 6px 0 4px; }
  .shopgrid { gap: 10px; }
  .rk { padding: 4px 6px 8px; }
  .rk canvas { width: 76px; height: 76px; }
  .rk .bl { font-size: 13px; margin-bottom: 4px; }
  .shopmsg { min-height: 26px; font-size: 19px; margin: 2px 0 6px; }
}
