html, body { margin: 0; height: 100%; background: #1b0f2e; overflow: hidden; overscroll-behavior: none; }
body { touch-action: none; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent;
  font-family: "Trebuchet MS", system-ui, sans-serif; }
canvas { display: block; width: 100vw; height: 100vh; height: 100dvh; touch-action: none; }
.mute, .home { position: fixed; top: max(10px, env(safe-area-inset-top)); width: 46px; height: 46px; border-radius: 50%;
  border: 3px solid #2a1440; background: #ffd23f; font-size: 22px; line-height: 1; cursor: pointer; z-index: 5;
  display: flex; align-items: center; justify-content: center; padding: 0; text-decoration: none; color: #2a1440; }
.mute { right: 10px; }
.home { left: 10px; font-weight: 900; }

/* On screen touch controls for the 2 player games (see touchpad.js). */
.tp { display: none; position: fixed; inset: 0; z-index: 4; pointer-events: none; touch-action: none; }
.tp.on { display: block; }
.tp-p { position: fixed; pointer-events: none; --flip: 0; }
.tp-stick { position: absolute; width: 176px; height: 176px; display: flex; align-items: center; justify-content: center; pointer-events: auto; touch-action: none; }
.tp-base { position: relative; width: 140px; height: 140px; border-radius: 50%; background: rgba(255, 255, 255, 0.22); border: 4px solid var(--pc); box-shadow: 0 0 0 3px rgba(42, 20, 64, 0.55); }
.tp-base.hot { background: rgba(255, 255, 255, 0.38); }
.tp-knob { position: absolute; left: 50%; top: 50%; width: 68px; height: 68px; margin: -34px 0 0 -34px; border-radius: 50%; background: var(--pc); border: 4px solid #fff; box-shadow: 0 3px 0 rgba(42, 20, 64, 0.6); }
.tp-arrow { position: absolute; width: 0; height: 0; border: 7px solid transparent; opacity: 0.8; }
.tp-up { left: 50%; top: 5px; margin-left: -7px; border-bottom-color: #fff; }
.tp-down { left: 50%; bottom: 5px; margin-left: -7px; border-top-color: #fff; }
.tp-left { top: 50%; left: 5px; margin-top: -7px; border-right-color: #fff; }
.tp-right { top: 50%; right: 5px; margin-top: -7px; border-left-color: #fff; }
.tp-btn { position: absolute; width: 104px; height: 104px; border-radius: 50%; background: var(--pc); border: 5px solid #fff; box-shadow: 0 5px 0 rgba(42, 20, 64, 0.7);
  color: #fff; font: 900 15px/1.1 "Trebuchet MS", system-ui, sans-serif; text-align: center; display: flex; align-items: center; justify-content: center; padding: 8px; box-sizing: border-box;
  text-shadow: 0 2px 0 rgba(42, 20, 64, 0.7); pointer-events: auto; touch-action: none; opacity: 0.92; }
.tp-btn.hot { transform: translateY(4px); box-shadow: 0 1px 0 rgba(42, 20, 64, 0.7); opacity: 1; }
.tp-join { position: absolute; left: 0; right: 0; top: -34px; text-align: center; color: #fff; font: 900 20px "Trebuchet MS", system-ui, sans-serif; text-shadow: 0 2px 0 #2a1440, 0 0 8px #2a1440;
  pointer-events: auto; touch-action: none; padding: 4px 0; animation: tp-pulse 1.2s ease-in-out infinite; }
.tp-p.joined .tp-join { display: none; }
.tp-p.joined .tp-base { border-style: solid; }
@keyframes tp-pulse { 50% { transform: scale(1.08); } }
.tp-pause { position: fixed; top: max(10px, env(safe-area-inset-top)); left: 50%; margin-left: -23px; width: 46px; height: 46px; border-radius: 50%; border: 3px solid #2a1440;
  background: #ffd23f; font: 900 18px/1 "Trebuchet MS", system-ui, sans-serif; color: #2a1440; padding: 0; pointer-events: auto; touch-action: none; display: none; }
.tp[data-phase="play"] .tp-pause, .tp[data-phase="count"] .tp-pause { display: block; }

/* Landscape: P1 bottom left, P2 bottom right. */
@media (orientation: landscape) {
  .tp-p { bottom: max(10px, env(safe-area-inset-bottom)); height: 176px; width: 300px; }
  .tp-p1 { left: max(8px, env(safe-area-inset-left)); }
  .tp-p2 { right: max(8px, env(safe-area-inset-right)); }
  .tp-p1 .tp-stick { left: 0; bottom: 0; } .tp-p1 .tp-btn { left: 188px; bottom: 26px; }
  .tp-p2 .tp-stick { right: 0; bottom: 0; } .tp-p2 .tp-btn { right: 188px; bottom: 26px; }
}
/* Short landscape phones: smaller controls (still 64px or more). */
@media (orientation: landscape) and (max-height: 430px) {
  .tp-p { height: 150px; width: 262px; }
  .tp-stick { width: 150px; height: 150px; } .tp-base { width: 124px; height: 124px; }
  .tp-btn { width: 92px; height: 92px; } .tp-p1 .tp-btn { left: 158px; bottom: 20px; } .tp-p2 .tp-btn { right: 158px; bottom: 20px; }
}
/* Portrait: P1 at the bottom, P2 on top and turned 180 degrees. */
@media (orientation: portrait) {
  .tp-p { left: 0; right: 0; height: 176px; }
  .tp-p1 { bottom: max(12px, env(safe-area-inset-bottom)); }
  .tp-p2 { top: 66px; transform: rotate(180deg); --flip: 1; }
  .tp-p .tp-stick { left: 10px; bottom: 0; } .tp-p .tp-btn { right: 22px; bottom: 26px; }
  .tp-p2 .tp-join { transform: none; }
}
