/* fly-game shared styles: kawaii pastel */
:root {
  --ink: #4a3f5e;
  --pink: #ff8fb3;
  --pink-d: #f06a93;
  --mint: #7fe3c3;
  --sky: #aee3ff;
  --cream: #fff8ec;
  --yellow: #ffd66e;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; height: 100%;
  font-family: "Hiragino Maru Gothic ProN", "Hiragino Sans", "Noto Sans JP", sans-serif;
  color: var(--ink); background: var(--cream);
  overflow: hidden;
}
button {
  font-family: inherit; cursor: pointer; border: none;
}
#game-canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#vignette {
  position: fixed; inset: 0; z-index: 4; pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 58%, rgba(74,63,94,.20) 100%);
}

/* ---------- overlays (title / lobby / result) ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255, 248, 236, 0.82); backdrop-filter: blur(3px);
  padding: 20px;
}
.overlay.hidden { display: none; }
.card {
  background: #fff; border-radius: 28px; padding: 32px 36px;
  box-shadow: 0 12px 40px rgba(240, 106, 147, 0.18);
  border: 4px solid #ffe3ee;
  text-align: center; max-width: 560px; width: 100%;
  max-height: 92vh; overflow-y: auto;
}
.card h1 {
  margin: 0 0 4px; font-size: clamp(28px, 5vw, 44px); color: var(--pink-d);
  letter-spacing: 2px;
}
.card h1 .fly { display: inline-block; animation: buzz 0.6s ease-in-out infinite alternate; }
@keyframes buzz { from { transform: translateY(0) rotate(-6deg); } to { transform: translateY(-8px) rotate(6deg); } }
.subtitle { margin: 0 0 18px; font-size: 15px; color: #8a7ba3; }
.diff-row { display: flex; gap: 10px; justify-content: center; margin: 14px 0 20px; flex-wrap: wrap; }
.diff-btn {
  padding: 10px 18px; border-radius: 999px; font-size: 16px; font-weight: bold;
  background: #f3efff; color: var(--ink); border: 3px solid transparent;
  transition: transform 0.12s;
}
.diff-btn:hover { transform: scale(1.06); }
.diff-btn.selected { background: #ffe3ee; border-color: var(--pink); color: var(--pink-d); }
.big-btn {
  display: inline-block; margin-top: 6px; padding: 14px 44px; font-size: 20px; font-weight: bold;
  color: #fff; background: linear-gradient(180deg, var(--pink), var(--pink-d));
  border-radius: 999px; box-shadow: 0 6px 0 #c94f78, 0 10px 20px rgba(240,106,147,.35);
  transition: transform 0.1s;
}
.big-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #c94f78; }
.big-btn:disabled { filter: grayscale(0.8); opacity: 0.55; cursor: default; }
.big-btn.mint { background: linear-gradient(180deg, #6fd8b4, #3fb98f); box-shadow: 0 6px 0 #2c8a68, 0 10px 20px rgba(63,185,143,.35); }
.big-btn.mint:active { box-shadow: 0 2px 0 #2c8a68; }
.link-btn { background: none; color: #8a7ba3; text-decoration: underline; font-size: 14px; margin-top: 14px; }
.room-code {
  font-size: clamp(48px, 10vw, 84px); font-weight: bold; letter-spacing: 14px;
  color: var(--pink-d); background: #fff0f5; border: 4px dashed var(--pink);
  border-radius: 20px; padding: 8px 8px 8px 22px; margin: 12px 0;
}
.url-line { font-size: clamp(15px, 3vw, 20px); background: #f3efff; border-radius: 12px; padding: 10px; margin: 10px 0; word-break: break-all; }
.status-line { margin: 12px 0; font-size: 17px; min-height: 26px; }
.status-line .dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: #ccc; margin-right: 8px; }
.status-line.ok .dot { background: #3fb98f; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 0.4; } }
.result-emoji { font-size: 72px; }
.result-title { font-size: 34px; margin: 6px 0; color: var(--pink-d); }
.result-time { font-size: 20px; margin: 8px 0; }
.commentary { background: #fff8ec; border-radius: 14px; padding: 12px; font-size: 15px; margin: 12px 0; color: #6b5d84; }
.tiny-note { font-size: 12px; color: #aaa; margin-top: 16px; }
.stat-row { display: flex; gap: 10px; justify-content: center; margin: 14px 0; flex-wrap: wrap; }
.stat { background: #f3efff; border-radius: 16px; padding: 12px 18px; min-width: 110px; }
.stat-num { font-size: 22px; font-weight: bold; color: var(--pink-d); }
.stat-label { font-size: 12px; color: #8a7ba3; margin-top: 2px; }
.fact { font-size: 14px; margin: 8px 0; color: #6b5d84; line-height: 1.6; }
.link-row { display: flex; gap: 14px; justify-content: center; margin-top: 12px; flex-wrap: wrap; }
.link-row a { color: var(--pink-d); font-weight: bold; font-size: 15px; }
#qr-box { width: 180px; height: 180px; margin: 10px auto 4px; background: #fff; padding: 10px; border-radius: 16px; border: 3px solid #ffe3ee; }
#qr-box svg { width: 100%; height: 100%; display: block; }

/* ---------- HUD (in-canvas overlays as DOM) ---------- */
#hud {
  position: fixed; top: 0; left: 0; right: 0; z-index: 5;
  display: flex; justify-content: center; gap: 12px; padding: 10px;
  pointer-events: none;
}
.hud-pill {
  background: rgba(255,255,255,.92); border-radius: 999px; padding: 8px 18px;
  font-size: 17px; font-weight: bold; box-shadow: 0 4px 14px rgba(74,63,94,.12);
  border: 3px solid #ffe3ee;
}
#balance-wrap {
  position: fixed; left: 14px; bottom: 14px; z-index: 5;
  background: rgba(255,255,255,.92); border-radius: 18px; padding: 10px 14px;
  border: 3px solid #ffe3ee; text-align: center; pointer-events: none;
}
#balance-wrap .label { font-size: 13px; margin-bottom: 4px; }
#toast {
  position: fixed; left: 50%; top: 34%; transform: translateX(-50%) scale(0.6); z-index: 8;
  font-size: clamp(34px, 7vw, 64px); font-weight: bold; color: var(--pink-d);
  text-shadow: 3px 3px 0 #fff; opacity: 0; pointer-events: none;
  transition: opacity .18s, transform .18s;
}
#toast.show { opacity: 1; transform: translateX(-50%) scale(1); }
#thought {
  position: fixed; z-index: 6; display: none;
  background: rgba(255,255,255,.95); border: 3px solid #d9b8ff; border-radius: 14px;
  padding: 8px 12px; font-size: 13px; color: #6b5d84; pointer-events: none;
  max-width: 240px; transform: translate(-10%, -100%);
  box-shadow: 0 4px 14px rgba(74,63,94,.15);
}

/* ---------- controller page ---------- */
#ctl-root { height: 100dvh; display: flex; flex-direction: column; align-items: center; padding: 18px; touch-action: none; user-select: none; -webkit-user-select: none; }
#ctl-root h2 { margin: 6px 0 2px; color: var(--pink-d); }
#code-input {
  font-size: 40px; letter-spacing: 10px; text-align: center; text-transform: uppercase;
  border: 4px solid var(--pink); border-radius: 16px; padding: 8px 8px 8px 18px;
  width: 260px; margin: 14px 0; color: var(--ink); background: #fff;
}
#pedal-btn {
  width: min(72vw, 300px); height: min(72vw, 300px); border-radius: 50%;
  font-size: 30px; font-weight: bold; color: #fff;
  background: radial-gradient(circle at 35% 30%, #ffb3c9, var(--pink-d));
  box-shadow: 0 10px 0 #c94f78, 0 16px 30px rgba(240,106,147,.4);
  touch-action: none;
}
#pedal-btn:active { transform: translateY(6px) scale(0.97); box-shadow: 0 4px 0 #c94f78; }
#tilt-zone { width: 100%; max-width: 420px; margin-top: 18px; text-align: center; }
#tilt-bar { height: 26px; border-radius: 999px; background: #eee3f5; position: relative; overflow: hidden; border: 3px solid #e2d4f0; }
#tilt-fill { position: absolute; top: 0; bottom: 0; left: 50%; width: 0; background: var(--mint); border-radius: 999px; }
#tilt-knob { position: absolute; top: -3px; width: 8px; height: 32px; background: var(--ink); border-radius: 4px; left: calc(50% - 4px); }
.ctl-row { display: flex; gap: 12px; margin-top: 12px; justify-content: center; }
.ctl-btn {
  padding: 14px 26px; font-size: 18px; font-weight: bold; border-radius: 16px;
  background: #f3efff; border: 3px solid #e2d4f0; color: var(--ink); touch-action: none;
}
.ctl-btn:active { background: #e2d4f0; }
#ctl-status { margin-top: 10px; font-size: 14px; color: #8a7ba3; min-height: 20px; }
#ctl-speed { font-size: 22px; font-weight: bold; margin-top: 6px; }
.hidden { display: none !important; }

/* ===== baseball ===== */
.howto { text-align: left; display: inline-block; margin: 8px 0 4px; }
.howto p { margin: 6px 0; font-size: 15px; color: #6b5d84; }
#pitch-name, #judge {
  display: none;
  position: fixed; left: 50%; top: 26%;
  transform: translate(-50%, -50%);
  font-size: 64px; font-weight: bold; z-index: 30;
  text-shadow: 3px 3px 0 #fff, -2px -2px 0 #fff, 2px -2px 0 #fff, -2px 2px 0 #fff;
  pointer-events: none; white-space: nowrap;
}
#judge { top: 40%; font-size: 52px; }
#pitch-name.pop, #judge.pop { animation: banner-pop 0.45s ease-out; }
@keyframes banner-pop {
  0% { transform: translate(-50%, -50%) scale(0.3); opacity: 0; }
  60% { transform: translate(-50%, -50%) scale(1.15); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}
#bat-status { font-size: 22px; font-weight: bold; color: #4a3f5e; margin: 14px 0 6px; }
#sensor-status { font-size: 13px; color: #8a7ba3; margin-top: 2px; min-height: 18px; }
#swing-hint { font-size: 13px; color: #8a7ba3; text-align: center; line-height: 1.7; margin-top: 8px; }
#touch-zone {
  width: 92%; max-width: 420px; min-height: 230px; margin: 12px 0 4px;
  border: 3px dashed #f06a93; border-radius: 24px; background: #fff7fa;
  display: flex; align-items: center; justify-content: center;
  touch-action: none; user-select: none; -webkit-user-select: none;
}
#touch-zone.swung { border-color: #ff5b5b; border-style: solid; background: #ffe3ee; }
#touch-label { font-size: 18px; font-weight: bold; color: #4a3f5e; text-align: center; line-height: 1.9; pointer-events: none; }
#touch-label span { font-size: 14px; color: #8a7ba3; font-weight: normal; }
#ctl-score { font-size: 20px; font-weight: bold; color: #4a3f5e; margin-top: 6px; }
#swing-flash {
  position: fixed; inset: 0; pointer-events: none; z-index: 60;
  background: radial-gradient(circle, rgba(255,255,255,.85), transparent 70%);
  opacity: 0; display: none;
}
