/* 샤봇 따라하기 — 밤 무대 + 조명 + 이퀄라이저 */
.stage.ec { --btn-a: #ffe066; --btn-b: #ffab1f; --btn-edge: #c76a00;
  padding: 8px; gap: 8px; touch-action: none; overscroll-behavior: none;
  background: radial-gradient(120% 80% at 50% 0%, #2c2470 0%, #1a1745 50%, #0c0b24 100%); }
.stage.ec::before { content: ''; position: absolute; inset: 0; pointer-events: none; opacity: 0.6; z-index: 0;
  background: radial-gradient(40% 30% at 12% 88%, rgba(23, 179, 155, 0.16), transparent 70%), radial-gradient(40% 30% at 88% 16%, rgba(255, 107, 90, 0.13), transparent 70%), radial-gradient(35% 25% at 85% 85%, rgba(255, 200, 61, 0.1), transparent 70%), radial-gradient(35% 25% at 15% 15%, rgba(154, 107, 255, 0.14), transparent 70%); }
/* 단추가 빛날 때 무대 전체가 그 색으로 물든다 */
.ec-glow { position: absolute; inset: 0; pointer-events: none; z-index: 0; opacity: 0;
  background: radial-gradient(55% 55% at var(--gx, 50%) var(--gy, 50%), var(--gc, #7b6cff), transparent 70%); }
.ec-glow.beat { animation: ec-beat 0.55s ease-out; }
@keyframes ec-beat { 0% { opacity: 0.42; } 100% { opacity: 0; } }
/* 위에서 내려오는 무대 조명 */
.ec-beams { position: absolute; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.ec-beams i { position: absolute; top: -10%; width: 22%; height: 120%; transform-origin: 50% 0; filter: blur(6px); opacity: 0.16; animation: ec-sweep 7s ease-in-out infinite alternate;
  background: linear-gradient(rgba(255, 255, 255, 0.9), transparent 75%); clip-path: polygon(45% 0, 55% 0, 100% 100%, 0 100%); }
.ec-beams i:nth-child(1) { left: 6%; background: linear-gradient(#7ff5dd, transparent 75%); }
.ec-beams i:nth-child(2) { left: 28%; background: linear-gradient(#ffb8ad, transparent 75%); animation-delay: -2s; animation-duration: 8s; }
.ec-beams i:nth-child(3) { left: 50%; background: linear-gradient(#fff1b0, transparent 75%); animation-delay: -4s; }
.ec-beams i:nth-child(4) { left: 72%; background: linear-gradient(#d4c2ff, transparent 75%); animation-delay: -1s; animation-duration: 9s; }
@keyframes ec-sweep { from { transform: rotate(-18deg); } to { transform: rotate(18deg); } }
/* 바닥 이퀄라이저 */
.ec-eq { position: absolute; left: 0; right: 0; bottom: 0; height: 13%; display: flex; align-items: flex-end; gap: 3px; padding: 0 4px; pointer-events: none; z-index: 0; opacity: 0.2; }
.ec-eq i { flex: 1; height: var(--h); border-radius: 4px 4px 0 0; transform-origin: 50% 100%; animation: ec-eq var(--d) ease-in-out var(--dl) infinite alternate;
  background: linear-gradient(#ffe066, #ff6b5a 40%, #9a6bff); }
@keyframes ec-eq { from { transform: scaleY(0.15); } to { transform: scaleY(1); } }
.ec.b0 .ec-eq i { background: linear-gradient(#7ff5dd, #17b39b); } .ec.b1 .ec-eq i { background: linear-gradient(#ffb8ad, #ff6b5a); }
.ec.b2 .ec-eq i { background: linear-gradient(#fff1b0, #ffc83d); } .ec.b3 .ec-eq i { background: linear-gradient(#d4c2ff, #9a6bff); }

/* ── 공통 HUD 알약 ── */
.ec-hud { position: relative; z-index: 2; display: flex; gap: 8px; justify-content: center; flex-wrap: nowrap; max-width: 100%; }
.ec-hud .pill { min-width: 0; display: flex; align-items: center; gap: 6px; padding: 4px 14px 4px 5px; border-radius: 999px; text-align: left;
  background: linear-gradient(rgba(10, 8, 40, 0.55), rgba(10, 8, 40, 0.72)); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 3px 0 rgba(0, 0, 0, 0.3); border: 1.5px solid rgba(255, 255, 255, 0.16); }
.ec-hud .pill svg { width: 28px; height: 28px; flex: none; padding: 3px; border-radius: 50%; background: rgba(255, 255, 255, 0.14); }
.ec-hud .pill b { font-family: "Fredoka", var(--title); font-weight: 600; font-size: 21px; line-height: 1.25; min-width: 1.2em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.ec-hud .v-mode { font-family: var(--title) !important; font-weight: 400 !important; font-size: 19px !important; color: #9fe9db; max-width: 7em; }
.ec-hud .v-best { color: #ffd23f; }

/* ── 공통 입체 PLAY 단추 ── */
.aaa-play { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-width: 230px; max-width: 100%;
  padding: 14px 38px 16px; border: 0; border-radius: 22px; cursor: pointer; overflow: hidden;
  font-family: "Black Han Sans", var(--title); font-size: 32px; line-height: 1.05; color: #fff; letter-spacing: 0.01em;
  -webkit-text-stroke: 1.5px var(--btn-edge); paint-order: stroke fill; text-shadow: 0 3px 0 var(--btn-edge);
  background: linear-gradient(var(--btn-a), var(--btn-b)); box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.6), inset 0 -4px 0 rgba(0, 0, 0, 0.12), 0 7px 0 var(--btn-edge), 0 14px 26px rgba(0, 0, 0, 0.35);
  animation: aaa-breathe 2.4s ease-in-out infinite; transition: transform 0.08s, box-shadow 0.08s; }
.aaa-play::after { content: ''; position: absolute; top: -20%; bottom: -20%; width: 40%; left: -60%; transform: skewX(-20deg);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.55), transparent); animation: aaa-shine 3s ease-in-out infinite; }
.aaa-play .pl-ico { font-size: 0.7em; -webkit-text-stroke: 0; text-shadow: none; opacity: 0.95; }
.aaa-play:hover { filter: brightness(1.06); }
.aaa-play:active { transform: translateY(6px) scale(0.98); box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.5), 0 1px 0 var(--btn-edge), 0 4px 10px rgba(0, 0, 0, 0.3); animation: none; }
@keyframes aaa-breathe { 50% { transform: scale(1.045); } }
@keyframes aaa-shine { 0%, 55% { left: -60%; } 85%, 100% { left: 130%; } }

.ec-wrap { position: relative; z-index: 1; flex: none; }
.ec-cv { display: block; touch-action: none; -webkit-touch-callout: none; filter: drop-shadow(0 18px 30px rgba(0, 0, 0, 0.45)); }
.ec-msg { position: relative; z-index: 1; margin: 0; min-height: 30px; font-family: var(--title); font-size: 22px; line-height: 30px; color: #cfd3ff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; text-align: center; transition: color 0.15s; -webkit-text-stroke: 4px rgba(10, 8, 40, 0.7); paint-order: stroke fill; }
.ec-msg.watch { color: #c9ceff; }
.ec-msg.turn { color: #9fe9db; }
.ec-msg.turn.rev { color: #ffb8ad; }
.ec-msg.good { color: #ffd23f; animation: ec-pop 0.3s ease-out; }
.ec-msg.bad { color: #ff8a7d; animation: ec-pop 0.3s ease-out; }
@keyframes ec-pop { 0% { transform: scale(0.8); } 60% { transform: scale(1.12); } 100% { transform: scale(1); } }

/* 처음 안내 손가락 */
.tut { position: absolute; z-index: 5; pointer-events: none; transform: translate(-30%, -10%); }
.tut[hidden] { display: none; }
.tut-hand { font-size: 48px; filter: drop-shadow(0 4px 4px rgba(0, 0, 0, 0.5)); animation: ec-tap 0.8s ease-in-out infinite; transform-origin: 30% 10%; }
.tut-tip { position: absolute; top: 58px; left: 50%; transform: translateX(-40%); white-space: nowrap; padding: 6px 12px; border-radius: 12px; font-family: var(--title); font-size: 17px; color: #2b2470; background: #fff; box-shadow: 0 4px 0 rgba(0, 0, 0, 0.25); }
@keyframes ec-tap { 0%, 100% { transform: translateY(8px); } 45% { transform: translateY(-6px) rotate(-6deg); } 55% { transform: translateY(2px) scale(0.9); } }

/* 가로로 넓고 낮은 화면(폰 가로): 점수판 · 글을 왼쪽에 세로로 */
.stage.ec.side { display: grid; grid-template-columns: auto auto; grid-template-rows: auto auto; align-content: center; justify-content: center; column-gap: 18px; row-gap: 10px; }
.ec.side .ec-hud { grid-column: 1; grid-row: 1; flex-direction: column; align-self: end; }
.ec.side .ec-msg { grid-column: 1; grid-row: 2; align-self: start; width: 120px; white-space: normal; font-size: 17px; line-height: 21px; }
.ec.side .ec-wrap { grid-column: 2; grid-row: 1 / 3; }

/* ── 제목 화면: 뒤의 놀이판이 보이게 위 · 아래만 어둡게 ── */
.ec .ec-title { background: linear-gradient(rgba(10, 8, 36, 0.92) 0%, rgba(10, 8, 36, 0.5) 26%, rgba(10, 8, 36, 0.5) 52%, rgba(10, 8, 36, 0.94) 72%); backdrop-filter: none; padding: 10px 14px; touch-action: pan-y; }
.t-wrap { position: relative; width: min(470px, 100%); height: 100%; max-height: 100%; display: flex; flex-direction: column; align-items: center; text-align: center; overflow: auto; scrollbar-width: none; }
.t-logo { margin: 4px 0 0; font-family: "Black Han Sans", var(--title); font-weight: 400; font-size: clamp(44px, 11vw, 64px); line-height: 1.05; transform: rotate(-2deg); }
.t-logo span { display: inline-block; background: linear-gradient(90deg, #7ff5dd, #fff1b0 35%, #ffb8ad 65%, #d4c2ff); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 3px 0 #1d1660) drop-shadow(0 -2px 0 #1d1660) drop-shadow(3px 0 0 #1d1660) drop-shadow(-3px 0 0 #1d1660) drop-shadow(0 8px 0 #0a0826);
  animation: ec-logo 2.6s ease-in-out infinite; }
@keyframes ec-logo { 50% { transform: translateY(-4px) scale(1.02); } }
.t-sub { margin: 8px 0 0; color: #dcd8ff; font-size: 15px; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7); }
.t-gap { flex: 1; min-height: 40px; }
.ec .ec-seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: 100%; margin: 0 0 6px; }
.md-tab { position: relative; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 9px 4px 7px; border-radius: 18px; cursor: pointer; color: #fff; min-width: 0;
  border: 2px solid rgba(255, 255, 255, 0.16); background: linear-gradient(rgba(36, 30, 100, 0.85), rgba(18, 14, 60, 0.92)); box-shadow: 0 5px 0 rgba(5, 4, 20, 0.6); transition: transform 0.15s cubic-bezier(0.3, 1.6, 0.5, 1); }
.md-tab:hover { transform: translateY(-2px); }
.md-tab.on { border-color: #3ee0b5; background: linear-gradient(#3a2f9e, #261d78); box-shadow: 0 5px 0 #120c4a, 0 0 0 3px rgba(62, 224, 181, 0.3), 0 0 22px rgba(62, 224, 181, 0.3); transform: translateY(-3px); }
.md-tab b { font-family: var(--title); font-weight: 400; font-size: 20px; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.md-tab small { font-size: 11.5px; font-weight: 600; color: #a9afd6; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.md-tab.on small { color: #9fe9db; }
.md-ico { display: grid; grid-template-columns: repeat(2, 11px); gap: 2px; width: 24px; height: 24px; margin-bottom: 3px; transform: rotate(45deg); }
.md-ico em { border-radius: 3px; background: #17b39b; }
.md-ico em:nth-child(2) { background: #ff6b5a; } .md-ico em:nth-child(3) { background: #9a6bff; } .md-ico em:nth-child(4) { background: #ffc83d; }
.md-fast em { animation: ec-blink 0.5s steps(2) infinite; } .md-fast em:nth-child(2) { animation-delay: 0.12s; } .md-fast em:nth-child(3) { animation-delay: 0.37s; } .md-fast em:nth-child(4) { animation-delay: 0.25s; }
.md-normal em { animation: ec-blink 1.2s steps(2) infinite; } .md-normal em:nth-child(2) { animation-delay: 0.3s; } .md-normal em:nth-child(3) { animation-delay: 0.9s; } .md-normal em:nth-child(4) { animation-delay: 0.6s; }
.md-reverse { transform: rotate(45deg) scaleX(-1); }
.md-reverse em { animation: ec-blink 1.2s steps(2) infinite; } .md-reverse em:nth-child(2) { animation-delay: 0.9s; } .md-reverse em:nth-child(3) { animation-delay: 0.3s; } .md-reverse em:nth-child(4) { animation-delay: 0.6s; }
@keyframes ec-blink { 50% { opacity: 0.3; } }
.md-stars { display: flex; gap: 1px; }
.md-stars svg { width: 14px; height: 14px; fill: rgba(255, 255, 255, 0.2); }
.md-stars svg.on { fill: #ffd23f; }
.ec .ec-desc { font-size: 13.5px; margin: 2px 0 14px; color: #c9ceff; min-height: 1.4em; }
.t-total { display: inline-flex; align-items: center; margin: 14px 0 4px; padding: 4px 14px 4px 8px; border-radius: 999px; background: rgba(15, 10, 50, 0.6); font-family: "Fredoka", var(--title); font-size: 17px; color: #ffe9a8; }
.t-total svg { width: 20px; height: 20px; fill: #ffd23f; margin-right: 5px; }
.stage:has(.ec-title:not([hidden])) .ec-hud, .stage:has(.ec-title:not([hidden])) .ec-msg { visibility: hidden; }

/* ── 결과 화면 ── */
.ec .ec-end { background: rgba(8, 6, 30, 0.66); backdrop-filter: blur(5px); overflow: auto; touch-action: pan-y; }
.r-card { position: relative; width: min(400px, 100%); text-align: center; padding: 46px 22px 20px; margin: 22px 0 6px; border-radius: 28px; color: #fff;
  background: linear-gradient(170deg, #3a2f9e, #261d78 55%, #18124f); border: 3px solid rgba(160, 140, 255, 0.7); box-shadow: 0 10px 0 #0c0830, 0 26px 50px rgba(0, 0, 0, 0.5), 0 0 40px rgba(123, 108, 255, 0.3), inset 0 2px 0 rgba(255, 255, 255, 0.25); }
.r-card.in { animation: ec-cardin 0.55s cubic-bezier(0.25, 1.5, 0.45, 1); }
@keyframes ec-cardin { from { transform: translateY(40px) scale(0.7); opacity: 0; } }
.r-ribbon { position: absolute; left: 50%; top: 0; transform: translate(-50%, -30%); width: max-content; max-width: 108%; padding: 10px 30px 12px; font-family: "Black Han Sans", var(--title); font-size: 26px; white-space: nowrap;
  color: #fff; background: linear-gradient(#21d3a6, #0f9f7c); border-radius: 14px; box-shadow: 0 5px 0 #08664f, 0 10px 18px rgba(0, 0, 0, 0.3); text-shadow: 0 2px 0 #08664f; }
.r-ribbon::before, .r-ribbon::after { content: ''; position: absolute; top: 12px; width: 22px; height: 100%; background: #0b7a5f; z-index: -1; }
.r-ribbon::before { left: -14px; clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, 40% 50%); }
.r-ribbon::after { right: -14px; clip-path: polygon(0 0, 100% 0, 60% 50%, 100% 100%, 0 100%); }
.r-stars { display: flex; justify-content: center; align-items: flex-end; gap: 6px; margin: 4px 0 0; }
.rs { width: 64px; height: 64px; display: block; opacity: 0.35; transform: scale(0.85); }
.rs.s2 { width: 84px; height: 84px; margin-bottom: 10px; }
.rs svg { width: 100%; height: 100%; fill: #0f0b3a; stroke: rgba(255, 255, 255, 0.25); stroke-width: 1; }
.rs.pop { opacity: 1; animation: ec-star 0.5s cubic-bezier(0.25, 1.8, 0.45, 1) forwards; }
.rs.on svg { fill: #ffd23f; stroke: #fff6b0; stroke-width: 1.2; filter: drop-shadow(0 3px 0 #c77a00) drop-shadow(0 0 10px rgba(255, 220, 80, 0.8)); }
@keyframes ec-star { from { transform: scale(2.4) rotate(-40deg); opacity: 0; } to { transform: scale(1) rotate(0); opacity: 1; } }
.r-score b { display: block; font-family: "Fredoka", var(--title); font-weight: 600; font-size: 60px; line-height: 1.1; color: #fff; text-shadow: 0 4px 0 #0c0830, 0 0 22px rgba(160, 140, 255, 0.6); font-variant-numeric: tabular-nums; }
.r-best-badge { display: inline-block; margin: 2px 0 8px; padding: 5px 14px; border-radius: 999px; font-family: var(--title); font-size: 18px; color: #4a2300; background: linear-gradient(#fff1a0, #ffc83d); box-shadow: 0 3px 0 #c77a00; animation: ec-badge 0.6s cubic-bezier(0.25, 1.8, 0.45, 1); }
.r-best-badge[hidden] { display: none; }
@keyframes ec-badge { from { transform: scale(0) rotate(-10deg); } }
.ec .ec-end .end-msg { margin: 0 0 10px; color: #cfd3ff; font-size: 14px; }
.r-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 6px 0 12px; }
.r-stats div { display: flex; flex-direction: column; align-items: center; padding: 8px 4px; border-radius: 16px; background: rgba(5, 4, 30, 0.4); box-shadow: inset 0 2px 0 rgba(0, 0, 0, 0.2); min-width: 0; }
.r-stats svg { width: 26px; height: 26px; }
.r-stats b { font-family: "Fredoka", var(--title); font-weight: 600; font-size: 26px; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.r-stats .e-mode { font-family: var(--title); font-weight: 400; color: #9fe9db; }
.r-stats span { font-size: 11px; color: #b9b4ff; }
.r-next { margin: 0 0 14px; padding: 7px 10px; border-radius: 12px; font-size: 14px; color: #ffe9a8; background: rgba(255, 210, 63, 0.12); border: 1px dashed rgba(255, 210, 63, 0.45); }
.r-card .aaa-play { width: 100%; }
.r-links { display: flex; gap: 8px; margin-top: 16px; }
.r-link { flex: 1; padding: 9px 6px; border-radius: 12px; font: inherit; font-size: 13px; color: #dcd8ff; background: rgba(255, 255, 255, 0.08); border: 1px solid rgba(255, 255, 255, 0.16); text-align: center; text-decoration: none; cursor: pointer; }
.r-link:hover { background: rgba(255, 255, 255, 0.16); }

@media (max-width: 520px) {
  .ec-hud { gap: 5px; }
  .ec-hud .pill { padding: 3px 11px 3px 4px; gap: 4px; }
  .ec-hud .pill svg { width: 25px; height: 25px; }
  .ec-hud .pill b { font-size: 19px; }
  .aaa-play { font-size: 28px; min-width: 200px; }
  .md-tab b { font-size: 18px; }
}
@media (max-height: 640px) {
  .t-sub { display: none; }
  .t-gap { min-height: 10px; }
  .t-logo { font-size: 40px; }
}
@media (max-height: 480px) and (min-width: 560px) {
  .ec .ec-title { background: rgba(10, 8, 36, 0.75); }
  .t-gap { display: none; }
  .t-total { display: none; }
}
