/* ぽんぽこ リズム — 見た目。ライト=ひるの そら・ダーク=よるの そら。外部フォントは使わない */
:root {
  --bg: #e6f5ff;
  --sky1: #bfe5ff;
  --sky2: #eaf8ff;
  --lane: rgba(255, 255, 255, .38);
  --ground: #9bd67f;
  --ink: #2b2433;
  --sub: #5d5470;
  --card: #ffffff;
  --card-sh: #aac4d8;
  --panel: rgba(255, 255, 255, .94);
  --gold: #ffc53d;
  --focus: #2f7cf6;
  --ring: rgba(43, 36, 51, .55);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141b29;
    --sky1: #101a2e;
    --sky2: #233352;
    --lane: rgba(255, 255, 255, .07);
    --ground: #2f5a3d;
    --ink: #f3eefc;
    --sub: #b9c3da;
    --card: #2a3752;
    --card-sh: #0a0f19;
    --panel: rgba(20, 27, 41, .94);
    --focus: #ffc53d;
    --ring: rgba(243, 238, 252, .7);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: var(--bg); color: var(--ink); }
body {
  font-family: "Hiragino Maru Gothic ProN", "Hiragino Maru Gothic Pro", "BIZ UDPGothic", "Yu Gothic UI", Meiryo, system-ui, sans-serif;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  overscroll-behavior: none;
  overflow: hidden;
}
#app {
  position: fixed; inset: 0;
  display: grid; grid-template-rows: auto minmax(0, 1fr); grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  /* 画面の下 15% には押すものを置かない(手首が当たる) */
  padding: calc(env(safe-area-inset-top) + 8px) calc(env(safe-area-inset-right) + 10px) 15vh calc(env(safe-area-inset-left) + 10px);
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; margin: 0; cursor: pointer; touch-action: manipulation; }
button:focus-visible { outline: 4px solid var(--focus); outline-offset: 3px; }
svg { display: block; width: 100%; height: 100%; overflow: visible; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.logo { display: flex; align-items: center; gap: 8px; margin: 0; min-width: 0; font-size: clamp(17px, 4.6vw, 24px); font-weight: 900; white-space: nowrap; }
.logo img { width: 40px; height: 40px; flex-shrink: 0; }
@media (max-width: 440px) { .logo span { display: none; } }
.back, .snd { flex-shrink: 0; width: 52px; height: 56px; border-radius: 16px; background: var(--card); box-shadow: 0 4px 0 var(--card-sh); display: grid; place-items: center; }
.back svg { width: 30px; height: 30px; }
.snd svg { width: 32px; height: 32px; }
.spk { fill: var(--ink); }
.wave, .slash { fill: none; stroke: var(--ink); stroke-width: 3.5; stroke-linecap: round; }
.snd.off .wave, .snd:not(.off) .slash { display: none; }
.back:active, .snd:active { transform: translateY(3px); }

/* ---- ステージ ---- */
.stage { position: relative; min-height: 0; border: 3px solid var(--ink); border-radius: 22px; overflow: hidden; background: var(--sky2); touch-action: none; }
.cv { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.lanes { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); z-index: 2; }
.lane { position: relative; display: flex; align-items: flex-end; justify-content: center; padding-bottom: 8px; touch-action: none; -webkit-tap-highlight-color: transparent; }
.lane:focus-visible { outline-offset: -6px; }
.an { display: block; width: var(--an, 100px); height: var(--an, 100px); }
.an svg { transform-origin: 50% 100%; animation: breathe 2.6s ease-in-out infinite; }
.lane:nth-child(2) .an svg { animation-delay: -.8s; }
.lane:nth-child(3) .an svg { animation-delay: -1.6s; }
@keyframes breathe { 50% { transform: scale(1.02, .98); } }
.eh, .mo { display: none; }
.lane.hit .eo, .lane.hit .mc, .stage[data-st="end"] .eo, .stage[data-st="end"] .mc { display: none; }
.lane.hit .eh, .lane.hit .mo, .stage[data-st="end"] .eh, .stage[data-st="end"] .mo { display: inline; }
.stage[data-st="menu"] .lanes { visibility: hidden; }
.stage[data-st="end"] .lane { pointer-events: none; }
.stage[data-st="end"] .an svg { animation: dance .62s ease-in-out infinite; }
.stage[data-st="end"] .lane:nth-child(2) .an svg { animation-delay: -.2s; }
.stage[data-st="end"] .lane:nth-child(3) .an svg { animation-delay: -.4s; }
@keyframes dance { 25% { transform: translateY(-9%) rotate(-5deg); } 75% { transform: translateY(-9%) rotate(5deg); } }

.pops { position: absolute; inset: 0; pointer-events: none; z-index: 4; }
.pop {
  position: absolute; top: var(--popy, 40%); left: calc(var(--l, 0) * 33.333% + 16.667%); transform: translateX(-50%);
  padding: 6px 12px; border-radius: 16px; background: #fff; color: #2b2433; border: 3px solid #2b2433;
  font-size: clamp(16px, 4.2vw, 22px); font-weight: 900; white-space: nowrap;
}
.pop.great { background: #ffe066; }
.pop.good { background: #c8f2cf; }

.count { position: absolute; left: 50%; top: 8%; transform: translateX(-50%); display: flex; gap: 10px; padding: 8px 14px; border-radius: 999px; background: var(--panel); border: 3px solid var(--ink); z-index: 4; pointer-events: none; }
.count i { display: block; width: clamp(22px, 7vw, 34px); aspect-ratio: 1; border-radius: 50%; border: 3px solid var(--ink); background: transparent; }
.count i.on { background: var(--gold); animation: pip .18s ease-out; }
@keyframes pip { from { transform: scale(1.5); } }

/* ---- パネル(きょくを えらぶ / おわり) ---- */
.panel { position: absolute; z-index: 5; display: grid; place-items: center; padding: 10px; background: var(--panel); }
.panel.menu { inset: 0; }
.panel.end { left: 0; right: 0; top: 0; bottom: calc(var(--an, 100px) + 16px); background: transparent; }
.menubox, .endbox { display: flex; flex-direction: column; align-items: center; gap: 10px; width: min(100%, 560px); }
.mt, .endt { margin: 0; font-size: clamp(20px, 5.4vw, 28px); font-weight: 900; }
.songs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; width: 100%; }
.song {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-height: 100px; padding: 8px 4px; border-radius: 18px; background: var(--card); box-shadow: 0 4px 0 var(--card-sh);
}
.song[aria-pressed="true"] { box-shadow: 0 4px 0 var(--card-sh), 0 0 0 4px var(--gold); }
.song .si { width: 56px; height: 56px; }
.song .sn { font-size: clamp(14px, 3.9vw, 18px); font-weight: 900; white-space: nowrap; }
.spds { display: flex; gap: 10px; width: 100%; }
.spd {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 56px; padding: 4px 8px;
  border-radius: 16px; background: var(--card); box-shadow: 0 4px 0 var(--card-sh); font-size: clamp(15px, 4vw, 19px); font-weight: 900;
}
.spd[aria-pressed="true"] { box-shadow: 0 4px 0 var(--card-sh), 0 0 0 4px var(--gold); }
.spd .pi { width: 40px; height: 36px; flex-shrink: 0; }
.song:active, .spd:active, .btn:active { transform: translateY(3px); }

.stars { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px; max-width: 100%; min-height: 4px; }
.einfo { display: flex; flex-direction: column; align-items: center; gap: 8px; min-width: 0; max-width: 100%; }
.stars svg { width: var(--ss, 22px); height: var(--ss, 22px); flex: 0 0 auto; }
.stars svg path { fill: var(--gold); stroke: #2b2433; stroke-width: 1.6; stroke-linejoin: round; }
.stars svg:nth-child(4n+1) { animation: twinkle 1.2s ease-in-out infinite; }
@keyframes twinkle { 50% { transform: scale(1.25) rotate(8deg); } }
.endn { margin: 0; font-size: clamp(16px, 4.4vw, 22px); font-weight: 900; min-height: 1.2em; }
.btns { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.btn { min-height: 56px; min-width: 120px; padding: 6px 18px; border-radius: 18px; background: var(--card); box-shadow: 0 4px 0 var(--card-sh); font-size: clamp(16px, 4.4vw, 20px); font-weight: 900; }
.btn.big { background: var(--gold); color: #2b2433; box-shadow: 0 4px 0 #b88a14; }

/* スマホを横にしたとき */
@media (orientation: landscape) and (max-height: 600px) {
  .back, .snd { width: 48px; height: 48px; }
  .logo img { width: 32px; height: 32px; }
  .menubox, .endbox { gap: 6px; }
  .mt, .endt { font-size: 18px; }
  .songs { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
  .song { min-height: 76px; }
  .song .si { width: 40px; height: 40px; }
  .song .sn { font-size: 14px; }
  .spd { min-height: 52px; }
  .endbox { flex-direction: row; justify-content: center; width: 100%; max-width: none; gap: 14px; }
  .einfo { flex: 1; gap: 4px; }
  .btns { flex-direction: column; flex: 0 0 auto; gap: 8px; }
  .btn { min-height: 50px; min-width: 130px; }
  .panel { padding: 6px; }
  .panel.end { background: var(--panel); border-radius: 0 0 18px 18px; }
  .count { top: 4%; padding: 4px 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
