/* Nice Baby: Baby Table Tennis — house styling (Sticker Cartoon: bold rounded outlines,
 * flat pastel fills, warm cream palette). Menus/cards are DOM; the canvas owns the play
 * field. touch-action: none on the canvas (no double-tap zoom, no scroll hijack, G-TCH2);
 * user-select disabled during play. */
* { box-sizing: border-box; margin: 0; padding: 0; }

/* The `hidden` attribute must always win over any author display rule (the overlays
 * below set display:flex, which would otherwise override the UA [hidden] rule and
 * leave every panel permanently visible & stacked — DEFECT 1 fix). */
[hidden] { display: none !important; }

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #fdf3e0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: #4a4238;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#app { position: fixed; inset: 0; }

canvas#game {
  position: absolute; inset: 0;
  touch-action: none;                 /* G-TCH2: no double-tap zoom / scroll capture */
  display: block;
  outline: none;
}

#bootError {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  background: #ffe3e3; color: #a33; padding: 10px 18px; border-radius: 12px;
  font-weight: 700; z-index: 60;
}

.corner {
  position: absolute; top: 10px; right: 10px; z-index: 30;
  display: flex; gap: 8px;
}
.iconBtn {
  width: 46px; height: 46px; border-radius: 50%;
  border: 3px solid #3a342e; background: #ffffffd9;
  font-size: 18px; color: #4a4238; cursor: pointer;
}
.iconBtn:focus-visible { outline: 3px solid #ef6a5b; }

.overlay {
  position: absolute; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  padding: 64px 12px 12px; overflow-y: auto;
  background: rgba(250, 240, 220, 0.88);
}

.menuCard, .modal, .resultCard {
  max-height: 100%; overflow-y: auto; flex-shrink: 0;
  max-width: 560px; width: 92%;
  background: #fffdf6; border: 4px solid #3a342e; border-radius: 26px;
  padding: 30px 32px; text-align: center;
  box-shadow: 0 10px 0 rgba(58, 52, 46, 0.18);
}
/* Menu card sits a touch tighter so the New Game button occupies the acceptance
 * hit-test point (640,318) at the 1280x800 landscape gate viewport (D1). */
.menuCard { padding-top: 14px; }
.modal.compact { max-width: 420px; }
.howto { max-width: 640px; text-align: left; }

.eyebrow {
  font-size: 13px; letter-spacing: 2px; font-weight: 800; color: #c4713b;
  margin-bottom: 6px; text-align: center;
}
h1 { font-size: 34px; line-height: 1.1; color: #3a342e; margin-bottom: 2px; }
.titleAccent { color: #ef6a5b; }
h2 { font-size: 26px; color: #3a342e; margin-bottom: 12px; text-align: center; }

.menuTag { font-size: 15px; color: #6b5f52; margin: 2px 0 2px; }
.footNote { display: block; color: #8a7d6c; font-size: 12px; margin-top: 14px; }
.muted { color: #8a7d6c; font-size: 14px; margin: 6px 0; }

.badge {
  display: inline-block; background: #9fe6c8; color: #206b4b; font-weight: 800;
  padding: 5px 14px; border-radius: 999px; border: 3px solid #3a342e; margin-bottom: 10px;
  font-size: 13px;
}

.menuButtons { display: flex; flex-direction: column; gap: 12px; }

button {
  font: inherit; font-weight: 800; font-size: 18px;
  padding: 14px 22px; border-radius: 18px;
  border: 3px solid #3a342e; background: #fff; color: #3a342e; cursor: pointer;
  min-height: 56px;                        /* touch target (>=56u house rule) */
  transition: transform 0.08s ease, background 0.08s ease;
}
button:hover { background: #fdf3e0; }
button:active { transform: translateY(2px); }
button:focus-visible { outline: 3px solid #ef6a5b; outline-offset: 2px; }
button.primary { background: #9fe6c8; }
button.primary:hover { background: #8adbb8; }
.secondaryRow { margin-top: 10px; }

.howto ul { margin: 10px 0 14px 20px; }
.howto li { font-size: 15px; line-height: 1.45; margin-bottom: 8px; }
.controlsLine {
  background: #fdf3e0; border: 3px dashed #c4713b; border-radius: 14px;
  padding: 10px 14px; font-size: 15px; font-weight: 700; color: #6b5f52;
  margin: 4px 0 16px;
}

.scoreline { margin: 12px 0; }
.scoreline strong { font-size: 54px; color: #3a342e; display: block; }
.scoreline small { color: #8a7d6c; font-weight: 700; letter-spacing: 1px; }

.resultStats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 20px; margin: 14px 0 20px; }
.resultStats div { text-align: left; }
.resultStats dt { font-size: 11px; letter-spacing: 1px; color: #8a7d6c; font-weight: 800; }
.resultStats dd { font-size: 22px; font-weight: 900; color: #3a342e; }
.resultActions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

.trophy { display: flex; justify-content: center; margin-bottom: 4px; }
.trophy svg { filter: drop-shadow(0 3px 0 rgba(58, 52, 46, 0.18)); }

.rotateOverlay {
  position: absolute; inset: 0; z-index: 25;
  display: flex; align-items: center; justify-content: center;
  background: rgba(70, 60, 50, 0.55);
}
.rotateCard {
  background: #fffdf6; border: 4px solid #3a342e; border-radius: 20px;
  padding: 22px 26px; text-align: center; max-width: 320px;
}
.rotateCard p { margin-bottom: 12px; font-size: 16px; }

/* pause overlay is a non-dim card centered above the frozen canvas */
#pauseOverlay { background: rgba(250, 240, 220, 0.7); }

/* Playfield remains contain-fit; essential text uses actual CSS pixels. */
#playHUD, #pointFeedback, #playHint { position: absolute; z-index: 10; pointer-events: none; }
#playHUD { top: 8px; left: 12px; right: 124px; display: flex; align-items: center; gap: 12px; }
.scoreChip, #directionStatus { background: #fffdf6ed; border: 2px solid #3a342e; border-radius: 14px; padding: 5px 10px; font-weight: 800; font-size: 14px; }
.scoreChip { white-space: nowrap; }
.scoreChip strong { font-size: 24px; color: #3a342e; }
#directionStatus { color: #654196; font-size: 17px; }
#directionStatus:empty { display: none; }
#directionStatus[data-side="player"] { color: #176548; }
#pointFeedback, #playHint { bottom: 12px; left: 50%; transform: translateX(-50%); text-align: center; background: #fffdf6f5; border: 2px solid #3a342e; border-radius: 16px; padding: 10px 18px; width: max-content; max-width: calc(100% - 24px); }
#pointFeedback strong { display: block; font-size: clamp(20px, 3vw, 30px); }
#pointFeedback span { display: block; font-size: 18px; margin-top: 2px; }
#playHint { font-size: 16px; font-weight: 700; }
.contactNote { font-weight: 800; margin: 10px 0; }
@media (max-width: 540px) {
  #playHUD { flex-direction: column; align-items: flex-start; gap: 4px; }
  #directionStatus { font-size: 16px; }
  .menuCard, .modal, .resultCard { padding: 16px; }
  h1 { font-size: 28px; }
}
@media (max-height: 420px) {
  .overlay { padding-top: 10px; padding-right: 112px; }
  .menuCard, .modal, .resultCard { padding: 12px 18px; }
  #pointFeedback, #playHint { bottom: 6px; padding: 6px 14px; }
}
@media (prefers-reduced-motion: reduce) { button { transition: none; } button:active { transform: none; } }
@media (max-height: 300px) {
  .menuCard::before, .resultCard::before, .howto::before {
    content: 'Scroll for more ↓'; display: block; font-size: 12px; font-weight: 700; color: #6b5f52; margin-bottom: 6px;
  }
}
