* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: #8fcf6f;
  font-family: "M PLUS Rounded 1c", "Hiragino Maru Gothic ProN", system-ui, sans-serif;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  touch-action: none; overscroll-behavior: none;
}
button { font-family: inherit; touch-action: manipulation; cursor: pointer; }
.hidden { display: none !important; }

/* 縦向きでも横画面のレイアウトにするため、JSで回転させる */
#app { position: fixed; top: 0; left: 0; transform-origin: 0 0; overflow: hidden; }

#scene { position: absolute; inset: 0; width: 100%; height: 100%; }
/* ---- もりの背景（ゆれる葉・木もれ日・とぶちょうちょ・おちる葉） ---- */
#scene { pointer-events: none; }
#scene .item { pointer-events: auto; cursor: pointer; }
#scene .inner { transform-box: fill-box; transform-origin: center; }
.canopy { transform-origin: 800px -200px; animation: sway 7s ease-in-out infinite alternate; }
@keyframes sway { from { transform: rotate(-.8deg); } to { transform: rotate(.8deg); } }
.ray { animation: rayPulse 6s ease-in-out infinite alternate; }
.r2 { animation-delay: -2s; } .r3 { animation-delay: -4s; }
@keyframes rayPulse { from { opacity: .25; } to { opacity: .8; } }
.apple .inner { transform-origin: 30% 0; animation: appleSway 4s ease-in-out infinite alternate; }
@keyframes appleSway { from { transform: rotate(-2deg); } to { transform: rotate(2deg); } }
.bird .inner { animation: birdBob 2.4s ease-in-out infinite; }
@keyframes birdBob { 0%,100% { transform: none; } 50% { transform: translateY(-3px) rotate(-3deg); } }
.fly { animation: flyX linear infinite; }
.f1 { animation-duration: 26s; }
.f2 { animation-duration: 34s; animation-delay: -15s; animation-name: flyX2; }
@keyframes flyX { 0% { transform: translate(-100px, 150px); } 50% { transform: translate(800px, 90px); } 100% { transform: translate(1700px, 160px); } }
@keyframes flyX2 { 0% { transform: translate(1700px, 80px) scaleX(-1); } 50% { transform: translate(800px, 160px) scaleX(-1); } 100% { transform: translate(-100px, 100px) scaleX(-1); } }
.bob { animation: bob2 1.6s ease-in-out infinite alternate; }
@keyframes bob2 { from { transform: translateY(-14px); } to { transform: translateY(14px); } }
.wings { transform-box: fill-box; transform-origin: center; animation: flap .22s ease-in-out infinite alternate; }
@keyframes flap { from { transform: scaleX(1); } to { transform: scaleX(.35); } }
.lf { animation: leafFall linear infinite; opacity: 0; }
.l1 { animation-duration: 14s; } .l2 { animation-duration: 18s; animation-delay: -6s; } .l3 { animation-duration: 16s; animation-delay: -11s; }
.l4 { animation-duration: 20s; animation-delay: -3s; } .l5 { animation-duration: 17s; animation-delay: -9s; }
@keyframes leafFall { 0% { transform: translate(var(--x0, 300px), -20px) rotate(0); opacity: 0; } 8% { opacity: 1; }
  50% { transform: translate(calc(var(--x0, 300px) + 120px), 160px) rotate(200deg); } 100% { transform: translate(calc(var(--x0, 300px) - 60px), 330px) rotate(420deg); opacity: 0; } }
.l1 { --x0: 250px; } .l2 { --x0: 700px; } .l3 { --x0: 1050px; } .l4 { --x0: 1350px; } .l5 { --x0: 480px; }
/* さわったときの動き */
.inner.k-shake { animation: shake .18s ease-in-out 6 !important; }
@keyframes shake { 25% { transform: rotate(-5deg); } 75% { transform: rotate(5deg); } }
.inner.k-tweet { animation: tweet .35s ease-in-out 5 !important; }
@keyframes tweet { 50% { transform: translateY(-18px) scale(1.08); } }
.inner.k-twirl { animation: twirl 1s ease-in-out 2 !important; }
@keyframes twirl { 0% { transform: none; } 50% { transform: rotate(180deg) scale(1.6); } 100% { transform: rotate(360deg); } }
.fall-item { position: absolute; font-size: 26px; transform: translate(-50%, 0); animation: dropFall 1.2s ease-in forwards; }

/* ---- たいよう（さわると反応する） ---- */
#sun { position: absolute; top: 2%; left: 46%; width: 11%; aspect-ratio: 1; z-index: 2; cursor: pointer; touch-action: manipulation; }
#sun svg { position: relative; width: 100%; height: 100%; overflow: visible; }
#sun .rays { transform-origin: 50px 50px; animation: spin 18s linear infinite; }
#sun .raysWrap, #sun .face { transform-origin: 50px 50px; transition: transform .3s; }
#sun .glow { position: absolute; inset: -10%; border-radius: 50%; opacity: 0;
  background: radial-gradient(circle, rgba(255,250,190,1) 0%, rgba(255,220,80,.7) 40%, rgba(255,210,60,0) 70%); }
#sun .e-happy, #sun .e-wink, #sun .e-wow, #sun .e-dizzy, #sun .e-cool,
#sun .m-laugh, #sun .m-wow, #sun .m-wavy { display: none; }
#sun.r-laugh .e-normal, #sun.r-shine .e-normal, #sun.r-wink .e-normal, #sun.r-wow .e-normal, #sun.r-spin .e-normal, #sun.r-cool .e-normal { display: none; }
#sun.r-laugh .m-smile, #sun.r-wow .m-smile, #sun.r-spin .m-smile, #sun.r-shine .m-smile { display: none; }
#sun.r-laugh .e-happy, #sun.r-shine .e-happy, #sun.r-laugh .m-laugh, #sun.r-shine .m-laugh { display: inline; }
#sun.r-wink .e-wink, #sun.r-wow .e-wow, #sun.r-wow .m-wow, #sun.r-spin .e-dizzy, #sun.r-spin .m-wavy, #sun.r-cool .e-cool { display: inline; }
/* 1 わらう：ぴょんぴょん */
#sun.r-laugh { animation: sunLaugh .9s ease-in-out; }
@keyframes sunLaugh { 15%,45%,75% { transform: translateY(-14%) rotate(-6deg); } 30%,60%,90% { transform: translateY(0) rotate(6deg); } }
/* 2 ひかる：まぶしく光る */
#sun.r-shine .glow { animation: sunGlow 1.4s ease-out; }
#sun.r-shine .raysWrap { transform: scale(1.35); }
#sun.r-shine .rays { animation-duration: 1.2s; }
@keyframes sunGlow { 0% { opacity: 0; transform: scale(.6); } 25% { opacity: 1; transform: scale(2.2); } 100% { opacity: 0; transform: scale(2.6); } }
/* 3 ウインク */
#sun.r-wink .face { transform: rotate(-12deg) scale(1.08); }
/* 4 びっくり：とびあがる */
#sun.r-wow { animation: sunWow .8s cubic-bezier(.2,1.6,.4,1); }
@keyframes sunWow { 0% { transform: scale(1); } 30% { transform: translateY(-22%) scale(1.25); } 100% { transform: none; } }
/* 5 くるくる → めがまわる */
#sun.r-spin { animation: sunSpin 1s ease-in-out; }
@keyframes sunSpin { from { transform: rotate(0); } to { transform: rotate(720deg); } }
#sun.r-spin .face { animation: wobble .5s ease-in-out 1s 3; }
@keyframes wobble { 0%,100% { transform: rotate(0); } 25% { transform: rotate(-10deg); } 75% { transform: rotate(10deg); } }
/* 6 サングラスでかっこよく */
#sun.r-cool .face { animation: coolNod .6s ease-in-out 2; }
@keyframes coolNod { 50% { transform: rotate(8deg) translateY(4%); } }
#sunFx { position: absolute; inset: 0; pointer-events: none; z-index: 5; overflow: hidden; }
/* 上の帯のすき間は、たいようをさわれるように素通りさせる */
#top { pointer-events: none; }
#top > * { pointer-events: auto; }
#top .left, #top .right { pointer-events: none; }   /* ボタンのすき間は背景（りんご・小鳥など）をさわれるように */
#top .left > *, #top .right > * { pointer-events: auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- 上の帯 ---- */
#top {
  position: absolute; left: 0; right: 0; top: 0; height: 27%;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 6px max(10px, env(safe-area-inset-right)) 6px max(10px, env(safe-area-inset-left));
  z-index: 3;
}
#top .left, #top .right { display: flex; align-items: center; gap: 8px; }
.pill {
  border: 0; border-radius: 999px; padding: 0 16px; height: 48px; min-width: 48px;
  background: #fff; color: #45363a; font-size: 18px; font-weight: 700;
  box-shadow: 0 4px 0 rgba(0,0,0,.15);
}
.pill:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,.15); }
.pill.big { height: 54px; font-size: 20px; padding: 0 20px; background: #ffd84d; }
.pill.red { background: #ff8a8a; color: #fff; }
.seg { display: flex; background: rgba(255,255,255,.7); border-radius: 999px; padding: 4px; gap: 4px; box-shadow: 0 4px 0 rgba(0,0,0,.12); }
.seg button { border: 0; border-radius: 999px; height: 44px; padding: 0 14px; background: transparent; font-size: 17px; font-weight: 700; color: #45363a; }
.seg.small button { padding: 0 10px; font-size: 22px; }
.seg button.sel { background: #ff9ec7; color: #fff; }
.seg.small button.sel { background: #8fd0ff; }

#now {
  flex: 1; max-width: 340px; min-width: 0; background: rgba(255,255,255,.85); border-radius: 22px;
  padding: 6px 14px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  font-size: 18px; font-weight: 700; color: #45363a; box-shadow: 0 4px 0 rgba(0,0,0,.12);
}
#nowEmoji { font-size: 26px; }
#nowTitle { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
/* ---- 曲の進み具合（光るゲージ） ---- */
#bar { flex-basis: 100%; position: relative; height: 16px; margin: 4px 26px 2px 0; background: #fbeaf3;
  border-radius: 8px; box-shadow: inset 0 2px 3px rgba(0,0,0,.12); }
#barFill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 8px; overflow: hidden;
  background: linear-gradient(90deg, #ff6f9f, #ffb347, #ffd84d, #7ed957, #4fc3f7, #9575cd, #ff6f9f);
  background-size: 300% 100%; animation: rainbow 3s linear infinite;
  box-shadow: 0 0 8px 2px rgba(255,210,60,.85); transition: width .35s cubic-bezier(.3,1.4,.5,1); }
#barFill::after { content: ''; position: absolute; inset: 0;
  background: linear-gradient(110deg, transparent 30%, rgba(255,255,255,.75) 45%, transparent 60%);
  background-size: 200% 100%; animation: shine 1.4s linear infinite; }
@keyframes rainbow { to { background-position: 300% 0; } }
@keyframes shine { from { background-position: 150% 0; } to { background-position: -50% 0; } }
#bar.bump #barFill { animation: rainbow 3s linear infinite, barGlow .5s ease-out; }
@keyframes barGlow { 0% { box-shadow: 0 0 18px 8px rgba(255,240,120,1); } 100% { box-shadow: 0 0 8px 2px rgba(255,210,60,.85); } }
#barRunner { position: absolute; top: 50%; left: 0; font-size: 26px; line-height: 1; transform: translate(-50%, -58%);
  transition: left .35s cubic-bezier(.3,1.4,.5,1); filter: drop-shadow(0 2px 2px rgba(0,0,0,.25)); z-index: 2; }
#bar.bump #barRunner { animation: runHop .4s ease-out; }
@keyframes runHop { 40% { transform: translate(-50%, -105%) rotate(-10deg); } }
#barGoal { position: absolute; right: -26px; top: 50%; transform: translateY(-55%); font-size: 20px; }
#bar.near #barGoal { animation: bob .4s ease-in-out infinite alternate; }
.compact #bar { height: 13px; }
.compact #barRunner { font-size: 22px; }

#buddy { width: 70px; height: 70px; }
#buddy svg { width: 100%; height: 100%; }
#buddy.hop { animation: hop .35s ease-out; }
#buddy.dance { animation: dance .6s ease-in-out infinite; }
@keyframes hop { 30% { transform: translateY(-14px) scale(1.06); } }
@keyframes dance { 0%,100% { transform: rotate(-12deg) translateY(0); } 50% { transform: rotate(12deg) translateY(-12px); } }

/* ---- 鍵盤 ---- */
#kbWrap {
  position: absolute; left: max(2%, env(safe-area-inset-left)); right: max(2%, env(safe-area-inset-right));
  top: 29%; bottom: 3%; z-index: 2;
}
#kb {
  position: absolute; inset: 0; border-radius: 20px; overflow: hidden;
  background: #3a2a32; border: 6px solid #3a2a32; border-top-width: 12px;
  box-shadow: 0 8px 0 rgba(0,0,0,.18);
}
#fx { position: absolute; inset: 0; pointer-events: none; overflow: visible; }
.key { position: absolute; top: 0; }
.white {
  height: 100%; background: linear-gradient(#fbfaf6, #ffffff 80%, #ece9e2);
  border-left: 2px solid #d8d2c8; border-radius: 0 0 14px 14px;
  display: flex; align-items: flex-end; justify-content: center; padding-bottom: 12px;
}
.white .tab {
  width: 64%; aspect-ratio: 1; max-width: 60px; border-radius: 50%;
  background: var(--c); color: #fff; font-weight: 800; font-size: clamp(13px, 2.6vmin, 20px);
  display: flex; align-items: center; justify-content: center; text-shadow: 0 1px 2px rgba(0,0,0,.25);
}
.nolabels .white .tab { font-size: 0; width: 34%; }
.white.down { background: var(--c); }
.white.down .tab { background: #fff; color: var(--c); text-shadow: none; }
.black {
  height: 58%; z-index: 2; border-radius: 0 0 10px 10px;
  background: linear-gradient(#4a3a44, #241a20 90%); box-shadow: inset 0 -6px 0 #5b4954, 0 3px 4px rgba(0,0,0,.4);
}
.black.down { background: var(--c); box-shadow: inset 0 -3px 0 rgba(0,0,0,.2); }

/* 光る鍵盤（お手本） */
.key.target { animation: glow .9s ease-in-out infinite; z-index: 3; }
.white.target { background: linear-gradient(#fff7c2, #ffe86a); }
.black.target { background: linear-gradient(#ffe86a, #ffc928); }
@keyframes glow { 0%,100% { box-shadow: 0 0 0 4px var(--g1), 0 0 18px 6px var(--g3); } 50% { box-shadow: 0 0 0 6px var(--g2), 0 0 30px 14px var(--g3); } }
.star {
  position: absolute; font-size: 40px; transform: translate(-50%, -100%); z-index: 5;
  animation: bob .6s ease-in-out infinite alternate; filter: drop-shadow(0 2px 2px rgba(0,0,0,.2));
}
@keyframes bob { from { margin-top: 2px; } to { margin-top: -12px; } }

/* 押したときの音符・きらきら */
.note-fx { position: absolute; font-size: 34px; font-weight: 900; animation: floatUp 1.1s ease-out forwards; transform: translate(-50%, 0); text-shadow: 0 2px 0 #fff; }
@keyframes floatUp { to { margin-top: -120px; opacity: 0; transform: translate(-50%, 0) rotate(20deg) scale(1.3); } }
.spark { position: absolute; font-size: 40px; animation: pop .7s ease-out forwards; transform: translate(-50%, -50%); }
@keyframes pop { 0% { transform: translate(-50%,-50%) scale(.3); } 60% { transform: translate(-50%,-50%) scale(1.5); } 100% { transform: translate(-50%,-50%) scale(1.8); opacity: 0; } }

/* ---- 重ねる画面 ---- */
.overlay { position: absolute; inset: 0; z-index: 10; background: rgba(40,30,60,.35); display: flex; align-items: center; justify-content: center; }
.panel { position: relative; background: #fff; border-radius: 28px; padding: 16px 20px 20px; max-width: 94%; max-height: 92%; overflow-y: auto; box-shadow: 0 10px 0 rgba(0,0,0,.15); }
.panel h2 { margin: 0 0 12px; text-align: center; font-size: 22px; color: #45363a; }
.close { position: absolute; top: 4px; right: 8px; height: 36px; min-width: 36px; padding: 0; font-size: 16px; }
#songGrid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.song {
  border: 0; border-radius: 20px; padding: 10px 6px; min-width: 120px; background: var(--b, #fff3b8);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  box-shadow: 0 5px 0 rgba(0,0,0,.12); font-size: 15px; font-weight: 700; color: #45363a;
}
.song { position: relative; }
.song .stamp { position: absolute; top: 2px; right: 6px; font-size: 20px; animation: bob .8s ease-in-out infinite alternate; }
.song:active { transform: translateY(4px); box-shadow: 0 1px 0 rgba(0,0,0,.12); }
.song .e { font-size: 44px; line-height: 1.1; }
.song .t { line-height: 1.2; text-align: center; }
/* ---- できたね ---- */
#done { overflow: hidden; background: rgba(60,30,90,.45); }
.rays { position: absolute; left: 50%; top: 50%; width: 260vmax; height: 260vmax; margin: -130vmax 0 0 -130vmax;
  background: repeating-conic-gradient(rgba(255,240,150,.38) 0 10deg, rgba(255,255,255,0) 10deg 20deg);
  animation: spin 14s linear infinite; pointer-events: none; }
#fireworks { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.burst { position: absolute; transform: translate(-50%,-50%); animation: burst 1.3s ease-out forwards; }
@keyframes burst { 0% { transform: translate(-50%,-50%) scale(.2); opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy) + 40px)) scale(1.2) rotate(200deg); opacity: 0; } }
.done { text-align: center; z-index: 3; padding-top: 4px; background: linear-gradient(#fff, #fff6fb); border: 5px solid #ffd84d; }
.done .medal { font-size: 72px; line-height: 1; display: inline-block; filter: drop-shadow(0 4px 4px rgba(0,0,0,.25)); }
#done.play .medal { animation: medalIn .9s cubic-bezier(.2,1.6,.4,1) both, swing 1.6s ease-in-out .9s infinite; }
@keyframes medalIn { from { transform: scale(0) rotate(-180deg); } to { transform: scale(1) rotate(0); } }
@keyframes swing { 0%,100% { transform: rotate(-8deg); } 50% { transform: rotate(8deg); } }
#doneTitle { font-size: 34px; color: #ff6f9f; margin: 2px 0; text-shadow: 0 3px 0 #ffe1ee; }
#doneTitle span { display: inline-block; }
#done.play #doneTitle span { animation: letter .5s cubic-bezier(.2,1.8,.4,1) both, jump 1.2s ease-in-out 1.6s infinite; }
@keyframes letter { from { transform: translateY(-60px) scale(0); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes jump { 0%,100% { transform: none; } 15% { transform: translateY(-8px); } }
#doneSong { margin: 0 0 4px; font-size: 18px; font-weight: 700; color: #6b5a60; }
.stamps { margin: 0 0 10px; font-size: 16px; font-weight: 700; color: #b5892a; }
.done .row { transition: opacity .4s; }
.done .row.wait { opacity: 0; pointer-events: none; }
.compact .done .medal { font-size: 54px; }
.compact #doneTitle { font-size: 28px; }
.compact #doneSong { font-size: 15px; }
.done .row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
#confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.conf { position: absolute; top: -40px; font-size: 30px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(120vmax) rotate(540deg); } }

.sheet { width: 520px; }
.line { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid #eee; font-size: 16px; color: #45363a; }
.line input[type=checkbox] { width: 24px; height: 24px; accent-color: #ff6f9f; }
.line input[type=range] { width: 50%; accent-color: #ff6f9f; }
.note { font-size: 14px; color: #555; line-height: 1.6; }
.credit { font-size: 12px; color: #888; }
.sheet .pill.big { display: block; margin: 8px auto 0; }

#loading { position: absolute; inset: 0; z-index: 20; background: #8fcf6f; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #fff; font-size: 22px; font-weight: 800; }
#loading div { font-size: 80px; animation: dance .6s ease-in-out infinite; }
#loading.gone { opacity: 0; transition: opacity .4s; pointer-events: none; }
#toast { position: absolute; left: 50%; top: 32%; transform: translateX(-50%); z-index: 30; background: rgba(60,40,60,.85); color: #fff; padding: 10px 18px; border-radius: 20px; font-size: 16px; opacity: 0; transition: opacity .25s; pointer-events: none; white-space: nowrap; }
#toast.show { opacity: 1; }

/* 小さい画面（横向きのスマホ）：JSで #app に compact / narrow をつける */
.compact .pill.big { height: 48px; font-size: 18px; padding: 0 14px; }
.compact .seg button { height: 40px; font-size: 15px; padding: 0 10px; }
.compact .seg.small button { font-size: 20px; padding: 0 8px; }
.compact #buddy { width: 58px; height: 58px; }
.compact .song .e { font-size: 30px; }
.compact .panel h2 { font-size: 18px; margin-bottom: 8px; }
.compact .panel { padding: 10px 14px 14px; }
.compact .song { min-width: 0; font-size: 12px; padding: 6px 4px; border-radius: 16px; }
.narrow #alongBtn .lb, .narrow #songBtn span, .narrow #stopBtn span { display: none; }

/* ---- ことば（国旗） ---- */
#flags { display: flex; gap: 6px; background: rgba(255,255,255,.6); border-radius: 999px; padding: 4px; box-shadow: 0 4px 0 rgba(0,0,0,.12); }
.flag { width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: transparent; opacity: .55; transform: scale(.82); transition: transform .2s, opacity .2s; }
.flag svg { width: 100%; height: 100%; display: block; filter: drop-shadow(0 2px 2px rgba(0,0,0,.2)); }
.flag.sel { opacity: 1; transform: scale(1); animation: wiggle .5s ease-out; }
.flag:active { transform: scale(.9); }
@keyframes wiggle { 30% { transform: scale(1.15) rotate(-10deg); } 60% { transform: scale(1.05) rotate(8deg); } }
.compact .flag { width: 36px; height: 36px; }
.narrow #flags { gap: 2px; }
.narrow #buddy { width: 50px; height: 50px; }
.narrow #top { gap: 5px; padding-left: 6px; padding-right: 6px; }
.narrow #top .left, .narrow #top .right { gap: 5px; }
.narrow .flag { width: 32px; height: 32px; }
.narrow #lockBtn { width: 40px; min-width: 40px; height: 40px; }
.narrow #setBtn { width: 50px; height: 50px; }
.narrow .seg.small button { padding: 0 6px; font-size: 18px; }

/* ---- まってね：同じ鍵盤を続けて押すとき、押すたびに色が変わる ---- */
.key.target { --g1: #ffd84d; --g2: #ffb800; --g3: rgba(255,200,0,.9); }
.key.target.t1 { --g1: #ff8fc0; --g2: #ff4f9a; --g3: rgba(255,80,160,.85); }
.key.target.t2 { --g1: #7fd0ff; --g2: #2a9df4; --g3: rgba(40,150,255,.85); }
.key.target.t3 { --g1: #8fe37a; --g2: #3fbf3a; --g3: rgba(60,190,60,.85); }
.white.target.t1 { background: linear-gradient(#ffe3f0, #ff9ccb); }
.white.target.t2 { background: linear-gradient(#e2f4ff, #8fd3ff); }
.white.target.t3 { background: linear-gradient(#e6fbdf, #9fe88a); }
.black.target.t1 { background: linear-gradient(#ff9ccb, #ff5ea8); }
.black.target.t2 { background: linear-gradient(#8fd3ff, #3aa6f5); }
.black.target.t3 { background: linear-gradient(#9fe88a, #4cc94c); }
.key.target.flash { animation: flash .35s ease-out, glow .9s ease-in-out .35s infinite; }
@keyframes flash { 0% { filter: brightness(2) saturate(.3); transform: scaleY(.97); } 100% { filter: none; transform: none; } }

/* ---- まってね：しばらく押せないときの案内 ---- */
#kb .key { transition: filter .4s; }
#kb.hinting .key:not(.target) { filter: brightness(.55) saturate(.6); }
.hand { position: absolute; z-index: 7; font-size: 46px; transform: translate(-50%, -100%); pointer-events: none;
  animation: tap 0.9s ease-in-out infinite; filter: drop-shadow(0 3px 3px rgba(0,0,0,.3)); }
@keyframes tap { 0%,100% { margin-top: -18px; } 50% { margin-top: 0; } }
.ripple { position: absolute; z-index: 6; width: 30px; height: 30px; margin: -15px 0 0 -15px; border-radius: 50%;
  border: 5px solid #ffcf33; pointer-events: none; animation: ripple 1.3s ease-out infinite; }
@keyframes ripple { from { transform: scale(.4); opacity: 1; } to { transform: scale(4); opacity: 0; } }

/* ---- 音量（指で動かせる太いゲージ） ---- */
.line.vol { flex-wrap: wrap; }
.volBox { flex: 1; min-width: 240px; display: flex; align-items: center; gap: 10px; }
.vi { font-size: 22px; }
#volSlider { position: relative; flex: 1; height: 44px; touch-action: none; cursor: pointer; }
#volSlider::before { content: ''; position: absolute; left: 0; right: 0; top: 50%; height: 22px; margin-top: -11px;
  border-radius: 11px; background: #f2e6ec; box-shadow: inset 0 2px 4px rgba(0,0,0,.15); }
#volFill { position: absolute; left: 0; top: 50%; height: 22px; margin-top: -11px; border-radius: 11px;
  background: linear-gradient(90deg, #8fd0ff, #ff9ec7, #ff6f9f); }
#volKnob { position: absolute; top: 50%; width: 40px; height: 40px; margin: -20px 0 0 -20px; border-radius: 50%;
  background: #fff; border: 4px solid #ff6f9f; box-shadow: 0 3px 6px rgba(0,0,0,.25); transition: transform .1s; }
#volSlider.drag #volKnob { transform: scale(1.15); }

/* ---- 子どもロック（ながおしで ON / OFF） ---- */
@property --p { syntax: '<percentage>'; inherits: false; initial-value: 0%; }
#lockBtn { position: relative; padding: 0; width: 48px; overflow: hidden; }
#lockBtn .ic { position: relative; font-size: 22px; }
#lockBtn .ring { position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(#ff6f9f var(--p), transparent var(--p)); opacity: .55; --p: 0%; }
#lockBtn.pressing .ring { animation: fillRing 1.2s linear forwards; }
@keyframes fillRing { to { --p: 100%; } }
#lockBtn.locked { background: #ffe1ee; box-shadow: 0 4px 0 rgba(0,0,0,.15), 0 0 0 3px #ff6f9f inset; }
.compact #lockBtn { width: 44px; height: 44px; }

/* ---- 「いっしょに」の ON / OFF（OFFのときは まってね） ---- */
#alongBtn { color: #fff; text-shadow: 0 1px 0 rgba(0,0,0,.18); transition: background .25s, box-shadow .25s; }
#alongBtn .ic { display: inline-block; }
#alongBtn[data-mode="wait"]  { background: #6fcf5a; box-shadow: 0 4px 0 #46a535; }
#alongBtn[data-mode="magic"] { background: #a98bff; box-shadow: 0 4px 0 #7c5fe0; }
#alongBtn[data-mode="along"] { background: #ff8fbf; box-shadow: 0 4px 0 #e0689f; }
#alongBtn.pop { animation: modePop .45s ease-out; }
#alongBtn.pop .ic { animation: wiggle .5s ease-out; }
@keyframes modePop { 0% { transform: scale(.85); } 55% { transform: scale(1.12); } 100% { transform: scale(1); } }
.compact #alongBtn { height: 48px; font-size: 17px; }

/* ---- くまさん（さわると反応） ---- */
#buddy { cursor: pointer; touch-action: manipulation; flex-shrink: 0; }
#buddy svg { overflow: visible; }
#buddy.b-dance { animation: dance .5s ease-in-out infinite; }
#buddy.b-wave { animation: wave .45s ease-in-out 4; transform-origin: 50% 90%; }
@keyframes wave { 0%,100% { transform: rotate(0); } 25% { transform: rotate(-18deg); } 75% { transform: rotate(18deg); } }
#buddy.b-jump { animation: bigJump 1s cubic-bezier(.3,1.5,.5,1) 2; }
@keyframes bigJump { 0%,100% { transform: none; } 30% { transform: translateY(-40%) scale(1.15) rotate(-8deg); } 60% { transform: translateY(0) scale(1.1, .9); } }
#buddy.b-happy .eyes { opacity: 0; }
#buddy .happyEyes { display: none; }
#buddy.b-happy .happyEyes, #buddy.b-dance .happyEyes { display: inline; }
#buddy.b-dance .eyes { opacity: 0; }

/* ---- くまさんを真ん中に（太陽はなし） ---- */
#top .left, #top .right { flex: 1 1 0; min-width: 0; }
#top .right { justify-content: flex-end; }
#top .right #now { flex: 1 1 auto; min-width: 120px; max-width: 360px; }
.playing #flags { display: none; }   /* 曲の間は国旗をかくして、曲名ゲージを広く */
#buddy { width: 109px; height: 109px; margin: -8px 4px -14px; }
.compact #buddy { width: 94px; height: 94px; }
.narrow #buddy { width: 94px; height: 94px; }

/* ---- 背景・くまさんにさわったときの効果（鍵盤が光る・落ちてくる） ---- */
@keyframes dropFall { to { margin-top: 170px; opacity: 0; } }
.key.sparkle { animation: sparkleKey .7s ease-out; }
.white.sparkle { background: linear-gradient(#fff, var(--c)); }
.black.sparkle { background: var(--c); }
@keyframes sparkleKey { 0% { box-shadow: 0 0 0 4px #fff, 0 0 26px 10px var(--c); filter: brightness(1.25); } 100% { box-shadow: 0 0 0 0 transparent; filter: none; } }

/* ---- 弾いているあいだ：くまさんが鍵盤を見る・小鳥がのぞく・ほめる ---- */
#buddy svg { transition: transform .25s ease-out; }
#buddy.looking svg { transform: rotate(calc(var(--look, 0) * 14deg)) translateY(4%); }
#buddy .eyes { transition: transform .2s; }
#buddy.looking .eyes { transform: translate(calc(var(--look, 0) * 5px), 4px); }
#scene .bird .inner.peek { animation: peek .5s ease-out; }
@keyframes peek { 40% { transform: rotate(14deg) translateY(4px); } }
.bubble { position: absolute; z-index: 6; transform: translate(0, -10%); padding: 6px 14px; border-radius: 18px;
  background: #fff; color: #ff5f97; font-size: 20px; font-weight: 900; white-space: nowrap;
  box-shadow: 0 4px 0 rgba(0,0,0,.12); animation: bubble 1.9s ease-out forwards; pointer-events: none; }
.bubble::before { content: ''; position: absolute; left: -10px; top: 60%; border: 8px solid transparent; border-right-color: #fff; }
@keyframes bubble { 0% { transform: scale(.2); opacity: 0; } 15% { transform: scale(1.15); opacity: 1; } 25% { transform: scale(1); } 80% { opacity: 1; } 100% { transform: translateY(-14px); opacity: 0; } }

/* ---- せってい：アニメっぽい歯車（白い丸わくなし） ---- */
#setBtn { border: 0; padding: 0; background: transparent; box-shadow: none; width: 60px; height: 60px; flex-shrink: 0;
  display: grid; place-items: center; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
#setBtn svg { width: 100%; height: 100%; display: block; overflow: visible; filter: drop-shadow(0 3px 0 rgba(0,0,0,.18)); }
#setBtn .gear { transform-origin: 30px 30px; transform-box: view-box; animation: gearSpin 9s linear infinite; }
#setBtn.spin .gear { animation: gearSpin .8s linear infinite; }
#setBtn:active svg { transform: scale(.92); }
@keyframes gearSway { 0%, 100% { transform: rotate(-12deg); } 50% { transform: rotate(12deg); } }
@keyframes gearSpin { to { transform: rotate(360deg); } }
.compact #setBtn { width: 52px; height: 52px; }

/* ロック中は ことばボタンも押せない（うすく表示） */
#flags.locked { opacity: .45; filter: grayscale(.6); }

/* ===== Play版：休けい（またね）・おうちのひとへ ===== */
.gate { position: absolute; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; }
.gate.hidden { display: none; }
#rest { background: linear-gradient(#bfe8ff, #e9f8d9); flex-direction: column; }
.restBox { text-align: center; color: #5a3a2a; }
.restBear { font-size: 120px; line-height: 1; position: relative; display: inline-block; animation: restBob 2.4s ease-in-out infinite; }
.restBear .wave { position: absolute; right: -46px; top: 10px; font-size: 64px; transform-origin: 20% 90%; animation: restWave 1.2s ease-in-out infinite; }
#restTitle { font-size: 48px; margin: 10px 0 4px; color: #ff6f9f; text-shadow: 0 3px 0 #fff; }
#restMsg { font-size: 20px; margin: 0; }
.restTime { font-size: 15px; opacity: .7; margin-top: 8px; }
@keyframes restBob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes restWave { 0%, 100% { transform: rotate(-10deg); } 50% { transform: rotate(25deg); } }
.parentsBtn { position: absolute; right: 14px; bottom: 12px; border: 0; border-radius: 18px; padding: 8px 14px; font-size: 13px;
  background: rgba(255,255,255,.7); color: #7a6a70; overflow: hidden; touch-action: none; }
.parentsBtn .ring { position: absolute; left: 0; bottom: 0; height: 4px; width: 0; background: #ff8fbf; }
.parentsBtn.holding .ring { width: 100%; transition: width 2s linear; }
#parent { background: rgba(40,30,60,.45); }
#parent .panel { max-width: 460px; }
#parent .buy { background: #ffd84d; font-size: 22px; margin: 8px 0; }
#parent .buy[disabled] { opacity: .5; }
#parent .storeLink { display: inline-block; text-decoration: none; color: inherit; text-align: center; }
#parent .storeLink.hidden { display: none; }
.pState { font-weight: bold; color: #3a9a3a; min-height: 1.2em; }
#freeTimer { position: absolute; left: 50%; bottom: 4px; transform: translateX(-50%); z-index: 6; font-size: 12px; color: #fff;
  background: rgba(60,40,60,.45); padding: 2px 10px; border-radius: 10px; pointer-events: none; }
#freeTimer.hidden { display: none; }
.song.locked { filter: grayscale(.55) brightness(.95); }
.song .lockMark { position: absolute; right: 6px; top: 4px; font-size: 20px; }
.restBear .restSvg { width: 150px; height: 150px; display: block; }
.restBear .wave { right: -40px; top: 30px; }
#parent .panel { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; }
#parent .codeRow { display: flex; gap: 6px; margin-top: 6px; }
#parent .codeRow input { width: 180px; font-size: 15px; padding: 6px 10px; border-radius: 12px; border: 2px solid #e6d8c8; text-align: center; }
.privacyLink { font-size: 13px; color: #7a6a70; margin-top: 4px; }
#parent .panel { max-height: 94%; overflow-y: auto; justify-content: flex-start; }
#parent .panel > * { flex-shrink: 0; }
#parent .panel h2 { margin: 0; }
#parent .note { margin: 2px 0; }
#parent .pState:empty { display: none; }
