:root {
  --ink: #4a3953;
  --ink2: #8b7897;
  --cream: #fffaf3;
  --pink: #ff8db6;
  --pink2: #ffc4da;
  --sky: #74c0ff;
  --butter: #ffd25e;
  --mint: #7fdcb5;
  --lav: #b39cff;
  --nav: 0px;
  --beat: 1.07s;
  font-family: 'Jua', system-ui, sans-serif;
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  overflow: hidden;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  background: #ffe1ee radial-gradient(#ffd0e3 2px, transparent 2.5px) 0 0 / 26px 26px;
}
input { user-select: text; -webkit-user-select: text; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--sky); outline-offset: 3px; }
[hidden] { display: none !important; }
svg { fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
h2, h3 { font-weight: normal; }

/* ---------- 앱 뼈대: 세로 모바일 = 위 상단바 · 아래 탭바 ---------- */
#app {
  position: relative;
  width: 100%;
  max-width: 480px;
  height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  isolation: isolate;
  container-type: inline-size;
  display: grid;
  grid-template: "top" auto "main" 1fr "nav" auto / 100%;
}
@media (orientation: portrait) and (min-width: 560px) and (min-height: 760px) {
  #app {
    height: min(calc(100dvh - 40px), 960px);
    margin-top: max(20px, calc((100dvh - 960px) / 2));
    border: 4px solid var(--ink);
    border-radius: 40px;
    box-shadow: 0 12px 0 var(--ink), 0 30px 60px rgba(74, 57, 83, .25);
  }
}
#topbar {
  grid-area: top;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(env(safe-area-inset-top) + 10px) 12px 6px;
}
#main { grid-area: main; position: relative; z-index: 2; min-height: 0; }
#nav {
  grid-area: nav;
  z-index: 3;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 2px;
  padding: 6px 6px calc(env(safe-area-inset-bottom) + 6px);
  background: rgba(255, 250, 243, .95);
  border-top: 3px solid var(--ink);
}
#nav button {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 5px 0;
  font-size: 12px;
  color: var(--ink2);
  background: none;
  border: 0;
  border-radius: 14px;
}
#nav button svg { width: 26px; height: 26px; }
#nav button[aria-current="page"] { color: var(--ink); background: var(--pink2); }
#nav .dot { position: absolute; top: 2px; right: 20%; width: 11px; height: 11px; background: #ff5c8a; border: 2px solid #fff; border-radius: 50%; }
#app.bare #topbar, #app.bare #nav { visibility: hidden; }

/* ---------- 배경 장면 ---------- */
#scene { position: absolute; inset: 0; overflow: hidden; container-type: size; z-index: 0; }
#scene .sky { position: absolute; inset: 0; background: linear-gradient(180deg, #9ad3ff 0%, #c4c3ff 40%, #ffd0e6 72%, #fff0dc 100%); }
#scene .night { background: linear-gradient(180deg, #1f1b4d 0%, #3d2f7a 45%, #8a5a9e 80%, #c98bb0 100%); opacity: 0; transition: opacity 1.2s; }
.sun {
  position: absolute;
  top: 6%;
  right: -12%;
  width: 70cqmin;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, #fffbe8 0 18%, rgba(255, 244, 205, .75) 30%, rgba(255, 236, 214, 0) 68%);
  animation: glow 5s ease-in-out infinite;
  transition: opacity 1.2s;
}
@keyframes glow { 50% { scale: 1.08; } }
.cloud {
  position: absolute;
  left: 0;
  top: var(--top);
  width: min(var(--w), 360px);
  aspect-ratio: 200 / 90;
  opacity: var(--o, .95);
  animation: drift var(--d) linear var(--delay) infinite;
  filter: drop-shadow(0 4px 0 rgba(160, 140, 220, .18));
}
@keyframes drift { from { transform: translateX(-100%); } to { transform: translateX(100cqw); } }
.hills { position: absolute; left: 0; bottom: 0; width: 100%; height: 34%; transition: filter 1.2s; }
#sceneFx { position: absolute; inset: 0; width: 100%; height: 100%; }
#scene[data-mode="game"] .night, #scene[data-mode="result"] .night { opacity: 1; }
#scene[data-mode="game"] .sun, #scene[data-mode="result"] .sun { opacity: .3; }
#scene[data-mode="game"] .hills, #scene[data-mode="result"] .hills { filter: brightness(.5) saturate(.8); }
#scene[data-mode="game"] .cloud { opacity: .15; }

.stage { position: absolute; left: 0; right: 0; bottom: 14%; height: 40%; display: none; }
#scene[data-mode="title"] .stage, #scene[data-mode="home"] .stage { display: block; }
#scene[data-mode="home"] .stage { bottom: 30%; height: 34%; }
.stage::after {
  content: '';
  position: absolute;
  left: 15%;
  right: 15%;
  bottom: -3%;
  height: 9%;
  border-radius: 50%;
  background: radial-gradient(rgba(74, 57, 83, .22), transparent 70%);
}
.trio {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: min(86%, 150cqh);
  translate: -50% 0;
  transform-origin: 50% 100%;
  animation: squish var(--beat) ease-in-out infinite;
  pointer-events: auto;
  cursor: pointer;
}
@keyframes squish { 0%, 100% { transform: scale(1.03, .97); } 50% { transform: translateY(-7%) scale(.98, 1.03); } }
.trio.jump { animation: jump .6s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes jump { 40% { transform: translateY(-22%) scale(.95, 1.06) rotate(-3deg); } }
.buddy { position: absolute; left: var(--x); bottom: var(--y); width: min(17%, 90px); animation: hop var(--beat) ease-in-out var(--dl) infinite; }
@keyframes hop { 0%, 100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-18%) rotate(4deg); } }
.bubble {
  position: absolute;
  left: 50%;
  bottom: 92%;
  translate: -50% 0;
  padding: 8px 18px;
  font-size: 20px;
  white-space: nowrap;
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 20px;
  box-shadow: 0 4px 0 var(--ink);
  animation: popIn .35s cubic-bezier(.3, 1.6, .5, 1);
}
@keyframes popIn { from { opacity: 0; scale: .4; } }

/* ---------- 화면 공통 ---------- */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  gap: 12px;
  padding: 6px 14px 18px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}
.screen.active { display: flex; animation: screenIn .4s cubic-bezier(.2, .9, .3, 1.15); }
.screen.full { z-index: 5; padding: calc(env(safe-area-inset-top) + 14px) 16px calc(env(safe-area-inset-bottom) + 18px); }
@keyframes screenIn { from { opacity: 0; transform: translateY(12px) scale(.98); } }
.spacer { flex: 1; }
.row { display: flex; gap: 12px; justify-content: center; }
.row > *, .row > form > * { flex: 1; }
.row > form { display: contents; }
.head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.head h2 {
  flex: 1;
  margin: 0;
  font-size: 28px;
  color: #fff;
  -webkit-text-stroke: 6px var(--ink);
  paint-order: stroke fill;
}
.head .hint { flex-basis: 100%; }
.hint { margin: 0; font-size: 14px; color: var(--ink2); }
.sub { margin: 8px 0 -2px; font-size: 20px; }
.sub small { font-size: 13px; color: var(--ink2); }

.logo {
  display: flex;
  justify-content: center;
  margin: 0;
  font-size: clamp(60px, 19cqw, 96px);
  font-weight: normal;
  line-height: 1;
  color: #fff;
  -webkit-text-stroke: 9px var(--ink);
  paint-order: stroke fill;
  text-shadow: 0 8px 0 var(--ink);
}
.logo span { display: inline-block; animation: hop var(--beat) ease-in-out infinite; }
.logo span:nth-child(1) { color: #ffd6e7; }
.logo span:nth-child(2) { animation-delay: -.25s; }
.logo span:nth-child(3) { color: #cfe8ff; animation-delay: -.5s; }
.ribbon {
  align-self: center;
  margin: 6px 0 0;
  padding: 6px 26px;
  font-size: 21px;
  color: #fff;
  background: linear-gradient(#ffa6c6, #ff7eab);
  border: 3px solid var(--ink);
  border-radius: 999px;
  box-shadow: 0 5px 0 var(--ink);
  rotate: -3deg;
}
.hero { display: flex; flex-direction: column; align-items: center; }
#title .hero { margin-top: 6dvh; }
.touch {
  margin: auto auto 4dvh;
  padding: 10px 26px;
  font-size: 22px;
  color: #fff;
  background: rgba(74, 57, 83, .55);
  border: 0;
  border-radius: 999px;
  animation: blink 1.4s ease-in-out infinite;
}
@keyframes blink { 50% { opacity: .45; } }

/* ---------- 버튼 · 공통 부품 ---------- */
.btn {
  --c1: #ffa8c8;
  --c2: #ff7eab;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  font-size: 20px;
  color: #fff;
  background: linear-gradient(var(--c1), var(--c2));
  border: 3px solid var(--ink);
  border-radius: 22px;
  box-shadow: 0 6px 0 var(--ink), inset 0 4px 0 rgba(255, 255, 255, .45), inset 0 -4px 0 rgba(0, 0, 0, .08);
  text-shadow: 0 2px 0 rgba(74, 57, 83, .35);
  transition: transform .08s, box-shadow .08s;
}
.btn:active:not(:disabled) { transform: translateY(5px); box-shadow: 0 1px 0 var(--ink), inset 0 4px 0 rgba(255, 255, 255, .45); }
.btn svg { width: 22px; height: 22px; flex: none; }
.btn.blue { --c1: #9fd4ff; --c2: #5fb1f5; }
.btn.butter { --c1: #ffe08d; --c2: #ffc23d; }
.btn.mint { --c1: #a6edcd; --c2: #5ccb9b; }
.btn.plain { --c1: #fff; --c2: #f3eaf5; color: var(--ink); text-shadow: none; }
.btn.big { font-size: 25px; padding: 14px 18px; }
.btn.small { font-size: 15px; padding: 6px 12px; border-radius: 16px; box-shadow: 0 4px 0 var(--ink); }
.btn.small svg { width: 18px; height: 18px; }
.btn:disabled { filter: grayscale(.7) opacity(.65); cursor: default; }
@media (hover: hover) {
  .btn:hover:not(:disabled), .icon-btn:hover, .song:hover, .ccard:hover, .slot:hover { filter: brightness(1.05); }
}
.icon-btn {
  position: relative;
  flex: none;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  padding: 0;
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 50%;
  box-shadow: 0 4px 0 var(--ink);
}
.icon-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.icon-btn svg { width: 24px; height: 24px; }
.link { align-self: center; padding: 6px; font-size: 16px; color: var(--ink2); background: none; border: 0; text-decoration: underline; text-underline-offset: 4px; }
.card-box, .panel {
  background: var(--cream);
  border: 3px solid var(--ink);
  border-radius: 26px;
  box-shadow: 0 6px 0 var(--ink);
}
.seg { display: flex; padding: 4px; background: #f1e5f3; border: 3px solid var(--ink); border-radius: 999px; }
.seg button { flex: 1; padding: 8px 6px; font-size: 17px; color: var(--ink2); background: none; border: 0; border-radius: 999px; white-space: nowrap; }
.seg button[aria-pressed="true"] { color: #fff; background: var(--pink); box-shadow: 0 3px 0 var(--ink); text-shadow: 0 2px 0 rgba(74, 57, 83, .3); }
.seg.small button { padding: 5px 10px; font-size: 14px; }
.seg small { font-size: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-b { padding: 3px 10px; font-size: 13px; background: #fff; border: 2px solid var(--ink); border-radius: 999px; white-space: nowrap; }
.chip-b.syn { background: #ffe9a8; }
.chip-b.none { color: var(--ink2); border-style: dashed; }
.tag { display: inline-block; padding: 2px 10px; font-size: 13px; background: #fff; border: 2px solid var(--ink); border-radius: 999px; }
.stars { color: #ffb400; font-size: 13px; letter-spacing: -1px; -webkit-text-stroke: 1px var(--ink); paint-order: stroke fill; }

/* ---------- 상단바 ---------- */
.chip {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  margin-right: auto;
  padding: 3px 14px 3px 3px;
  text-align: left;
  background: rgba(255, 255, 255, .92);
  border: 3px solid var(--ink);
  border-radius: 999px;
  box-shadow: 0 4px 0 var(--ink);
}
.chip:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.chip img { width: 40px; height: 40px; object-fit: cover; background: #fff; border: 2px solid var(--ink); border-radius: 50%; }
.who { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.who b { font-size: 16px; font-weight: normal; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 96px; }
.lvrow { display: flex; align-items: center; gap: 5px; }
.lv { padding: 0 6px; font-size: 11px; font-style: normal; background: var(--butter); border: 2px solid var(--ink); border-radius: 999px; }
.exp { width: 52px; height: 8px; overflow: hidden; background: #efe4f3; border: 2px solid var(--ink); border-radius: 99px; }
.exp i { display: block; width: 0; height: 100%; background: linear-gradient(90deg, var(--mint), var(--sky)); transition: width .6s; }
.wallet { display: flex; flex-direction: column; gap: 3px; }
.money {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 86px;
  padding: 1px 10px 1px 3px;
  font-size: 15px;
  background: rgba(255, 255, 255, .92);
  border: 2px solid var(--ink);
  border-radius: 999px;
}
.money svg { width: 20px; height: 20px; }
.money b { font-weight: normal; font-variant-numeric: tabular-nums; }
.money.bump { animation: bump .5s; }
@keyframes bump { 30% { scale: 1.15; } }

/* ---------- 홈 ---------- */
#home .hero { margin-top: 1dvh; }
#home .logo { font-size: clamp(48px, 14cqw, 70px); -webkit-text-stroke-width: 7px; text-shadow: 0 6px 0 var(--ink); }
#home .ribbon { font-size: 17px; padding: 4px 20px; }
#home { pointer-events: none; }
#home > * { pointer-events: auto; }
#home .spacer { pointer-events: none; }
.home-panel { display: flex; flex-direction: column; gap: 12px; }
.play { align-self: center; width: min(86%, 340px); font-size: 32px; padding: 14px; animation: breathe var(--beat) ease-in-out infinite; }
.play svg { width: 30px; height: 30px; }
@keyframes breathe { 50% { scale: 1.05; } }
.home-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mini {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  min-height: 74px;
  padding: 8px 12px;
  text-align: left;
  background: rgba(255, 250, 243, .94);
  border: 3px solid var(--ink);
  border-radius: 20px;
  box-shadow: 0 5px 0 var(--ink);
}
.mini b { font-size: 16px; font-weight: normal; }
.mini small { font-size: 12px; color: var(--ink2); }
.mini.on { background: linear-gradient(#fff3c4, #ffe08d); }
.mini .faces { display: flex; }
.mini .faces img { width: 30px; height: 30px; margin-right: -6px; background: #fff; border: 2px solid var(--ink); border-radius: 50%; }

/* ---------- 곡 선택 ---------- */
.song-list { display: grid; gap: 10px; }
.song {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 8px 12px 8px 8px;
  text-align: left;
  background: var(--cream);
  border: 3px solid var(--ink);
  border-radius: 22px;
  box-shadow: 0 5px 0 var(--ink);
}
.song:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--ink); }
.song img { width: 72px; height: 72px; object-fit: cover; border: 3px solid var(--ink); border-radius: 16px; }
.song .t { display: block; font-size: 19px; line-height: 1.2; }
.song .m { display: block; margin-top: 2px; font-size: 13px; color: var(--ink2); }
.song .bestline { color: #e5487f; }
.lvl { display: grid; place-items: center; min-width: 48px; padding: 4px 6px; font-size: 13px; line-height: 1.1; text-align: center; background: var(--butter); border: 2px solid var(--ink); border-radius: 14px; }
.lvl b { display: block; font-size: 20px; font-weight: normal; }
.song.locked img { filter: grayscale(.85) brightness(.95); }
.song .lockp { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 13px; }
.song .lockp svg { width: 22px; height: 22px; }
.song .lockp span { display: flex; align-items: center; gap: 2px; }
.song .lockp span svg { width: 16px; height: 16px; }

/* ---------- 팀 ---------- */
.slots { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.slot {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  aspect-ratio: 3 / 4;
  padding: 6px 4px;
  background: rgba(255, 255, 255, .6);
  border: 3px dashed var(--ink2);
  border-radius: 18px;
  transition: transform .15s;
}
.slot.filled { background: linear-gradient(#fff, var(--c)); border: 3px solid var(--ink); box-shadow: 0 4px 0 var(--ink); }
.slot img { width: 78%; aspect-ratio: 1; object-fit: contain; }
.slot .nm { width: 100%; font-size: 12px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slot .key { position: absolute; top: 3px; left: 7px; font-size: 12px; color: var(--ink2); }
.slot .plus { font-size: 28px; color: var(--ink2); }
.slot[aria-pressed="true"] { outline: 4px solid var(--pink); outline-offset: 2px; transform: translateY(-4px); }
.buffbox { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; }
.buffbox h3 { margin: 0; font-size: 16px; }
.syn-list { display: flex; flex-direction: column; gap: 4px; margin: 0; padding: 0; list-style: none; }
.syn-list li { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink2); }
.syn-list li.on { color: var(--ink); }
.syn-list li.on::before { content: '✦'; color: #ffb400; }
.syn-list li:not(.on)::before { content: '·'; }
.syn-list .fs { display: inline-flex; }
.syn-list .fs img { width: 20px; height: 20px; margin-right: -4px; border: 1.5px solid var(--ink); border-radius: 50%; background: #fff; filter: grayscale(1) opacity(.5); }
.syn-list .fs img.have { filter: none; }
.roster { display: grid; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); grid-auto-rows: max-content; gap: 10px; }
.ccard {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 0 6px;
  overflow: hidden;
  background: var(--rbg);
  border: 3px solid var(--ink);
  border-radius: 16px;
  box-shadow: 0 4px 0 var(--ink);
}
.ccard img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; }
.ccard .nm { width: 100%; padding: 0 4px; font-size: 12px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ccard .inteam { position: absolute; top: 4px; left: 4px; padding: 0 6px; font-size: 11px; color: #fff; background: var(--pink); border: 2px solid var(--ink); border-radius: 999px; }
.ccard.locked img { filter: brightness(0) opacity(.25); }
.r1 { --rbg: linear-gradient(160deg, #e9fbf2, #b7ecd3); --rc: #5cc290; }
.r2 { --rbg: linear-gradient(160deg, #eef6ff, #c6defd 60%, #e2ecff); --rc: #4aa3f0; }
.r3 { --rbg: linear-gradient(160deg, #f6eeff, #dcc6ff 50%, #ffd9ea); --rc: #a066f0; }
.r4 { --rbg: linear-gradient(160deg, #fff7d1, #ffd6a8 45%, #f6c4ff); --rc: #ffa800; }
.ccard.r3:not(.locked) { box-shadow: 0 4px 0 var(--ink), 0 0 12px rgba(160, 102, 240, .55); }
.ccard.r4:not(.locked) { box-shadow: 0 4px 0 var(--ink), 0 0 14px rgba(255, 196, 0, .75); }

/* ---------- 뽑기 ---------- */
.banner {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
  padding: 16px 16px 14px;
  text-align: center;
  background: linear-gradient(135deg, #ffe3f0, #e4e0ff 50%, #d8f3ff);
  border: 3px solid var(--ink);
  border-radius: 28px;
  box-shadow: 0 7px 0 var(--ink);
}
.banner::before {
  content: '';
  position: absolute;
  inset: -50%;
  background: repeating-conic-gradient(rgba(255, 255, 255, .45) 0 10deg, transparent 10deg 20deg);
  animation: spin 30s linear infinite;
}
@keyframes spin { to { rotate: 360deg; } }
.banner > * { position: relative; }
.banner-art img { width: min(80%, 360px); animation: squish var(--beat) ease-in-out infinite; transform-origin: 50% 100%; }
.banner h2 { margin: 6px 0 2px; font-size: 28px; color: #fff; -webkit-text-stroke: 6px var(--ink); paint-order: stroke fill; }
.banner p { margin: 2px 0; font-size: 15px; }
.banner .pity { color: #e5487f; }
.pulls .btn { flex-direction: column; gap: 2px; }
.pulls small { display: flex; align-items: center; gap: 4px; font-size: 15px; }
.pulls small svg { width: 18px; height: 18px; }
.gacha-info { margin: 0; padding: 12px 14px 12px 32px; font-size: 14px; line-height: 1.6; background: rgba(255, 250, 243, .9); border: 3px solid var(--ink); border-radius: 20px; }
.gacha-info b { font-weight: normal; color: #e5487f; }

.overlay.reveal { z-index: 20; display: flex; flex-direction: column; justify-content: center; align-items: stretch; gap: 18px; padding: 20px; background: radial-gradient(circle at 50% 40%, #6b4fa3, #241a3d 75%); }
.reveal-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; width: min(100%, 640px); margin: 0 auto; }
.reveal-grid.one { grid-template-columns: minmax(0, 200px); justify-content: center; }
.reveal .row { width: min(100%, 420px); margin: 0 auto; }
.rcard { aspect-ratio: 3 / 4; perspective: 700px; cursor: pointer; }
.rcard .in { position: relative; width: 100%; height: 100%; transition: transform .55s cubic-bezier(.3, 1.3, .5, 1); transform-style: preserve-3d; }
.rcard.open .in { transform: rotateY(180deg); }
.rcard .face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  overflow: hidden;
  backface-visibility: hidden;
  border: 3px solid var(--ink);
  border-radius: 14px;
}
.rcard .back { justify-content: center; font-size: 34px; color: #fff; background: repeating-linear-gradient(45deg, #ff9ec4 0 12px, #ffb7d3 12px 24px); }
.rcard.r3 .back { background: repeating-linear-gradient(45deg, #ffcf5c 0 12px, #ffe08d 12px 24px); animation: shake .5s infinite; }
@keyframes shake { 25% { rotate: -2deg; } 75% { rotate: 2deg; } }
.rcard .front { transform: rotateY(180deg); background: var(--rbg); }
.rcard .front img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.rcard .front .nm { position: relative; width: 100%; padding: 2px 2px 4px; overflow: hidden; font-size: 10px; white-space: nowrap; text-overflow: ellipsis; text-align: center; color: #fff; background: rgba(74, 57, 83, .78); }
.rcard .front .lbl { position: absolute; top: 4px; left: 4px; padding: 0 5px; font-size: 10px; color: #fff; background: #ff5c8a; border: 1.5px solid #fff; border-radius: 99px; }
.rcard .front .lbl.up { background: #5fb1f5; }
.rcard .front .lbl.gem { background: #8e72e8; }
.rcard.r3.open .front { box-shadow: 0 0 22px 4px #ffd25e; }

/* ---------- 상점 ---------- */
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 8px;
  text-align: center;
  background: var(--cream);
  border: 3px solid var(--ink);
  border-radius: 20px;
  box-shadow: 0 5px 0 var(--ink);
}
.item .ic { display: grid; place-items: center; height: 54px; font-size: 40px; }
.item .ic svg { width: 46px; height: 46px; }
.item .ic img { height: 54px; width: 54px; object-fit: cover; border: 2px solid var(--ink); border-radius: 12px; }
.item b { font-size: 16px; font-weight: normal; }
.item p { margin: 0; font-size: 12px; color: var(--ink2); }
.item .own { font-size: 12px; color: #e5487f; }
.item .btn { margin-top: auto; width: 100%; }
.price svg { width: 18px; height: 18px; }
.shop-grid.faces { grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); }
.shop-grid.faces .item img { width: 56px; height: 56px; border-radius: 50%; }

/* ---------- 업적 ---------- */
.daily {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: linear-gradient(120deg, #fff3c4, #ffd9ea);
  border: 3px solid var(--ink);
  border-radius: 22px;
  box-shadow: 0 5px 0 var(--ink);
}
.daily .ic { font-size: 40px; }
.daily div { flex: 1; }
.daily b { display: block; font-size: 18px; font-weight: normal; }
.daily small { font-size: 13px; color: var(--ink2); }
.quest-list { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none; }
.quest {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--cream);
  border: 3px solid var(--ink);
  border-radius: 20px;
}
.quest.ready { background: linear-gradient(120deg, #fff, #fff3c4); }
.quest.done { opacity: .6; }
.quest b { font-size: 17px; font-weight: normal; }
.quest p { margin: 0 0 4px; font-size: 13px; color: var(--ink2); }
.quest .prog { height: 9px; overflow: hidden; background: #efe4f3; border: 2px solid var(--ink); border-radius: 99px; }
.quest .prog i { display: block; height: 100%; background: linear-gradient(90deg, var(--mint), var(--sky)); }
.quest small { font-size: 12px; color: var(--ink2); }
.quest .btn { min-width: 92px; }
.reward { display: inline-flex; align-items: center; gap: 3px; }
.reward svg { width: 16px; height: 16px; }

/* ---------- 랭킹 ---------- */
.songtabs { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 8px; scrollbar-width: thin; }
.songtabs button {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 88px;
  padding: 6px 4px;
  font-size: 12px;
  line-height: 1.2;
  background: rgba(255, 255, 255, .88);
  border: 3px solid var(--ink);
  border-radius: 18px;
  box-shadow: 0 4px 0 var(--ink);
}
.songtabs img { width: 50px; height: 50px; object-fit: cover; border: 2px solid var(--ink); border-radius: 12px; }
.songtabs button[aria-pressed="true"] { background: var(--pink2); translate: 0 3px; box-shadow: 0 1px 0 var(--ink); }
.ranklist { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0 2px 8px; list-style: none; counter-reset: r; }
.ranklist li { counter-increment: r; display: flex; align-items: center; gap: 10px; padding: 6px 12px 6px 6px; background: var(--cream); border: 3px solid var(--ink); border-radius: 20px; }
.ranklist li::before { content: counter(r); display: grid; place-items: center; flex: none; width: 32px; height: 32px; font-size: 17px; background: #fff; border: 2px solid var(--ink); border-radius: 50%; }
.ranklist li:nth-child(1)::before { background: #ffd25e; }
.ranklist li:nth-child(2)::before { background: #e3e6f0; }
.ranklist li:nth-child(3)::before { background: #f5c08f; }
.ranklist li.me { background: #ffe3ee; }
.ranklist img { width: 40px; height: 40px; object-fit: cover; background: #fff; border: 2px solid var(--ink); border-radius: 50%; }
.ranklist .nm { flex: 1; min-width: 0; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ranklist .sc { font-size: 17px; font-variant-numeric: tabular-nums; }
.ranklist .rk { width: 28px; font-size: 18px; text-align: center; color: #e5487f; }
.ranklist .empty { justify-content: center; padding: 26px; font-size: 17px; color: var(--ink2); }
.ranklist .empty::before { display: none; }

/* ---------- 로그인 시트 ---------- */
.sheet {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: calc(env(safe-area-inset-bottom) + 12px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 16px 12px;
  background: var(--cream);
  border: 3px solid var(--ink);
  border-radius: 30px;
  box-shadow: 0 8px 0 var(--ink);
  animation: sheetUp .5s cubic-bezier(.2, .9, .3, 1.12);
}
@keyframes sheetUp { from { transform: translateY(110%); } }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 15px; }
.field > span { padding-left: 6px; }
.field input { width: 100%; padding: 11px 16px; font: inherit; font-size: 18px; color: var(--ink); background: #fff; border: 3px solid var(--ink); border-radius: 18px; outline: none; }
.field input:focus { box-shadow: 0 0 0 4px var(--pink2); }
.err { min-height: 1.2em; margin: 0; font-size: 15px; color: #e5487f; text-align: center; }
.avatars { display: grid; grid-auto-flow: column; grid-template-rows: repeat(2, 54px); grid-auto-columns: 54px; gap: 8px; padding: 4px 2px 8px; overflow-x: auto; scrollbar-width: thin; }
.av { width: 54px; height: 54px; padding: 0; overflow: hidden; background: #fff; border: 3px solid var(--ink); border-radius: 50%; transition: scale .15s; }
.av img { display: block; width: 100%; height: 100%; object-fit: cover; }
.av[aria-pressed="true"] { border-color: var(--pink); box-shadow: 0 0 0 3px var(--ink); scale: 1.08; }

/* ---------- 게임 ---------- */
#game { padding: 0; }
#field { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
.hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(env(safe-area-inset-top) + 8px) 12px 0;
  pointer-events: none;
}
.hud > * { pointer-events: auto; }
.songbar { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.songbar b { font-size: 15px; font-weight: normal; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #fff; -webkit-text-stroke: 4px var(--ink); paint-order: stroke fill; }
.progress { height: 10px; overflow: hidden; background: rgba(255, 255, 255, .5); border: 2px solid var(--ink); border-radius: 99px; }
.progress i { display: block; width: 0; height: 100%; background: linear-gradient(90deg, var(--pink), var(--butter)); }
.score { font-size: 28px; font-variant-numeric: tabular-nums; color: #fff; -webkit-text-stroke: 6px var(--ink); paint-order: stroke fill; }
.hp { display: flex; align-items: center; gap: 6px; pointer-events: none; }
.hp svg { width: 24px; height: 24px; flex: none; }
.hp .bar { flex: 1; height: 13px; overflow: hidden; background: rgba(255, 255, 255, .6); border: 2px solid var(--ink); border-radius: 99px; }
.hp .bar i { display: block; width: 100%; height: 100%; background: linear-gradient(90deg, #ff7fa8, #ffb3cf); transition: width .2s; }
.hp b { min-width: 58px; font-size: 13px; font-weight: normal; text-align: right; color: #fff; -webkit-text-stroke: 4px var(--ink); paint-order: stroke fill; }
.hp.low .bar i { background: #ff5c5c; animation: blink .5s infinite; }
.hp.top { position: absolute; top: calc(env(safe-area-inset-top) + 64px); left: 14px; right: 14px; }
.gside { display: none; }
.combo { position: absolute; top: 28%; left: 0; right: 0; display: flex; flex-direction: column; align-items: center; color: #fff; pointer-events: none; -webkit-text-stroke: 7px var(--ink); paint-order: stroke fill; }
.combo b { font-size: 60px; font-weight: normal; line-height: 1; }
.combo small { font-size: 17px; letter-spacing: 5px; -webkit-text-stroke-width: 5px; }
.judge { position: absolute; top: 44%; left: 0; right: 0; font-size: 42px; text-align: center; pointer-events: none; opacity: 0; -webkit-text-stroke: 7px var(--ink); paint-order: stroke fill; }
.judge.perfect { color: #fff; text-shadow: 0 0 18px #ffd25e, 0 0 6px #ff8db6; }
.judge.great { color: #ffd6e6; }
.judge.good { color: #c4f3dc; }
.judge.miss { color: #b9adc4; }
.judge.revive { color: #ffe08d; }
.overlay { position: absolute; inset: 0; z-index: 10; display: grid; place-items: center; background: rgba(40, 26, 62, .55); backdrop-filter: blur(4px); }
#ready { background: none; backdrop-filter: none; pointer-events: none; }
.readytext { margin: 0; font-size: 54px; color: #fff; -webkit-text-stroke: 8px var(--ink); paint-order: stroke fill; animation: popIn .4s cubic-bezier(.3, 1.6, .5, 1); }
.panel { display: flex; flex-direction: column; gap: 12px; width: min(86%, 340px); padding: 20px; animation: popIn .35s cubic-bezier(.3, 1.4, .5, 1); }
.panel h2 { margin: 0 0 4px; font-size: 28px; text-align: center; }
.loading { z-index: 30; align-content: center; gap: 8px; font-size: 22px; color: #fff; }
.loading img { width: 90px; animation: hop .5s ease-in-out infinite; }
.loading p { margin: 0; -webkit-text-stroke: 5px var(--ink); paint-order: stroke fill; }

/* ---------- 결과 ---------- */
#result { justify-content: center; }
.result { width: 100%; max-width: 760px; align-self: center; gap: 8px; padding: 14px; }
.rhead { display: flex; align-items: center; gap: 12px; }
.rhead img { width: 60px; height: 60px; object-fit: cover; border: 3px solid var(--ink); border-radius: 16px; }
.rhead div { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; font-size: 20px; }
.rbody { display: flex; flex-direction: column; gap: 8px; }
.rleft { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.stamp {
  display: grid;
  place-items: center;
  width: 112px;
  height: 112px;
  font-size: 76px;
  line-height: 1;
  color: #fff;
  -webkit-text-stroke: 8px var(--ink);
  paint-order: stroke fill;
  background: conic-gradient(#ffd25e, #ff8db6, #b39cff, #74c0ff, #7fdcb5, #ffd25e);
  border: 4px solid var(--ink);
  border-radius: 50%;
  box-shadow: 0 6px 0 var(--ink);
  animation: stamp .7s cubic-bezier(.3, 1.6, .5, 1) both .2s;
}
.stamp.r-B { background: radial-gradient(#9fd4ff, #5fb1f5); }
.stamp.r-C { background: radial-gradient(#a6edcd, #5ccb9b); }
.stamp.r-D, .stamp.fail { background: radial-gradient(#ddd2e6, #b6a6c4); }
@keyframes stamp { from { opacity: 0; scale: 2.6; rotate: -25deg; } }
.rclear { margin: 4px 0 0; font-size: 22px; color: #e5487f; }
.rclear.fail { color: var(--ink2); }
.rscore { margin: 0; font-size: 40px; font-variant-numeric: tabular-nums; color: #fff; -webkit-text-stroke: 7px var(--ink); paint-order: stroke fill; }
.rbonus { margin: 0; font-size: 14px; color: var(--ink2); }
.badges { display: flex; gap: 8px; margin: 0; }
.badge { padding: 3px 12px; font-size: 14px; color: #fff; background: #ff6fa5; border: 2px solid var(--ink); border-radius: 999px; animation: popIn .4s 1s both cubic-bezier(.3, 1.6, .5, 1); }
.badge.fc { background: var(--sky); }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 0; padding: 0; list-style: none; }
.stats li { display: flex; justify-content: space-between; padding: 5px 12px; font-size: 15px; background: #fff; border: 2px solid var(--ink); border-radius: 14px; }
.stats li:last-child { grid-column: span 2; }
.stats .perfect { color: #e5487f; }
.stats .great { color: #e09a00; }
.stats .good { color: #2e9e6e; }
.stats .miss { color: var(--ink2); }
.rewards { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.rewards span { display: inline-flex; align-items: center; gap: 4px; padding: 3px 12px; font-size: 15px; background: #fff3c4; border: 2px solid var(--ink); border-radius: 999px; animation: popIn .4s 1.2s both; }
.rewards svg { width: 18px; height: 18px; }
.note { margin: 0; font-size: 14px; text-align: center; color: var(--ink2); }
#result > .row { width: 100%; max-width: 760px; align-self: center; }

/* ---------- 다이얼로그 ---------- */
dialog {
  width: min(92vw, 420px);
  max-height: 90dvh;
  padding: 20px;
  color: var(--ink);
  background: var(--cream);
  border: 3px solid var(--ink);
  border-radius: 30px;
  box-shadow: 0 8px 0 var(--ink);
  overflow-y: auto;
}
dialog[open] { display: flex; flex-direction: column; gap: 12px; animation: popIn .3s cubic-bezier(.3, 1.4, .5, 1); }
dialog::backdrop { background: rgba(40, 26, 62, .5); backdrop-filter: blur(3px); }
dialog h2 { margin: 0; font-size: 26px; text-align: center; }
dialog form { display: contents; }
.x { position: absolute; top: 10px; right: 10px; display: grid; place-items: center; width: 38px; height: 38px; padding: 0; background: #fff; border: 3px solid var(--ink); border-radius: 50%; }
.x svg { width: 18px; height: 18px; }
.sd-top { display: flex; gap: 14px; align-items: center; padding-right: 30px; }
.sd-top img { width: 110px; height: 110px; flex: none; object-fit: cover; border: 3px solid var(--ink); border-radius: 22px; box-shadow: 0 5px 0 var(--ink); }
.sd-top h2 { text-align: left; font-size: 22px; line-height: 1.2; }
.sd-top p { margin: 4px 0 0; font-size: 14px; color: var(--ink2); }
.sd-top .best { color: #e5487f; }
.sd-box { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; background: #fff; border: 2px solid var(--ink); border-radius: 18px; }
.sd-box > span { font-size: 14px; color: var(--ink2); }
.boosters { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.boost { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 4px; font-size: 12px; background: var(--cream); border: 2px solid var(--ink); border-radius: 14px; }
.boost .ic { font-size: 26px; line-height: 1; }
.boost[aria-pressed="true"] { background: #ffe08d; box-shadow: 0 0 0 3px var(--pink); }
.boost:disabled { opacity: .45; }
.cd-card { position: relative; align-self: center; width: 180px; aspect-ratio: 3 / 4; overflow: hidden; background: var(--rbg); border: 3px solid var(--ink); border-radius: 20px; box-shadow: 0 6px 0 var(--ink); }
.cd-card img { width: 100%; height: 100%; object-fit: cover; }
.cd-card.locked img { filter: brightness(0) opacity(.25); }
.cd-sub { margin: -6px 0 0; text-align: center; color: var(--ink2); }
.cd-stages { display: flex; flex-direction: column; gap: 4px; margin: 0; padding: 0; list-style: none; }
.cd-stages li { display: flex; justify-content: space-between; padding: 5px 12px; font-size: 14px; color: var(--ink2); background: #fff; border: 2px solid #e4d9ea; border-radius: 12px; }
.cd-stages li.on { color: var(--ink); border-color: var(--ink); background: #fff3c4; }
.slider { display: flex; flex-direction: column; gap: 6px; font-size: 17px; }
.slider span { display: flex; justify-content: space-between; }
.slider b { font-weight: normal; color: #e5487f; }
.slider small { font-size: 13px; color: var(--ink2); }
input[type="range"] { width: 100%; accent-color: var(--pink); }
.toggle { display: flex; align-items: center; justify-content: space-between; font-size: 17px; }
.toggle input { width: 24px; height: 24px; accent-color: var(--pink); }
.bigav { align-self: center; width: 96px; height: 96px; object-fit: cover; border: 3px solid var(--ink); border-radius: 50%; box-shadow: 0 5px 0 var(--ink); }
.pplays, .plabel { margin: 0; text-align: center; color: var(--ink2); }
.plabel { text-align: left; color: var(--ink); }
.plabel small { color: var(--ink2); }
.pbest { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; list-style: none; max-height: 160px; overflow-y: auto; }
.pbest li { display: flex; justify-content: space-between; gap: 8px; padding: 6px 12px; font-size: 14px; background: #fff; border: 2px solid var(--ink); border-radius: 14px; }

.overlay.maint { z-index: 60; background: radial-gradient(circle at 50% 35%, #ffe3f0, #e4e0ff 60%, #d8f3ff); backdrop-filter: none; }
.maint .panel { align-items: center; text-align: center; }
.maint .panel img { width: 96px; animation: hop 1.2s ease-in-out infinite; }
.maint .panel p { margin: 0; font-size: 18px; line-height: 1.5; word-break: keep-all; }
.maint .panel small { color: var(--ink2); }
.maint .panel .btn { align-self: stretch; }
.maint-bar { position: absolute; top: 0; left: 50%; z-index: 45; margin: 0; padding: 2px 12px; font-size: 12px; color: #fff; background: #e5487f; border-radius: 0 0 10px 10px; translate: -50% 0; pointer-events: none; }

.toast {
  position: absolute;
  left: 50%;
  top: 40%;
  z-index: 40;
  max-width: 90%;
  padding: 10px 20px;
  font-size: 17px;
  white-space: nowrap;
  color: #fff;
  background: var(--ink);
  border-radius: 999px;
  translate: -50% -14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, translate .25s;
}
.toast.show { opacity: 1; translate: -50% 0; }

/* ---------- 가로 화면 (PC · 태블릿 · 가로 모바일): 왼쪽 메뉴 + 넓은 본문 ---------- */
@media (orientation: landscape) and (min-width: 640px) {
  :root { --nav: 210px; }
  #app {
    max-width: none;
    grid-template: "nav top" auto "nav main" 1fr / var(--nav) 1fr;
  }
  #nav {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: calc(env(safe-area-inset-top) + 14px) 12px 14px calc(env(safe-area-inset-left) + 12px);
    border-top: 0;
    border-right: 3px solid var(--ink);
  }
  #nav::before {
    content: '먼작귀';
    margin: 0 0 10px;
    font-size: 40px;
    text-align: center;
    color: #fff;
    -webkit-text-stroke: 7px var(--ink);
    paint-order: stroke fill;
  }
  #nav button { flex-direction: row; justify-content: flex-start; gap: 12px; padding: 10px 14px; font-size: 19px; }
  #nav .dot { top: 8px; right: 12px; }
  #topbar { padding: calc(env(safe-area-inset-top) + 12px) 22px 6px; }
  .who b { max-width: 160px; }
  .wallet { flex-direction: row; gap: 8px; }
  .money { min-width: 110px; font-size: 17px; padding: 3px 12px 3px 4px; }
  .money svg { width: 24px; height: 24px; }
  .screen { padding: 8px 24px 24px; }

  #home.active { display: grid; grid-template-columns: 1fr minmax(320px, 400px); grid-template-rows: auto 1fr; align-items: start; }
  #home .hero, #home .home-panel { grid-column: 2; }
  #home .spacer { display: none; }
  #home .home-panel { align-self: end; }
  #scene[data-mode="home"] .stage { left: var(--nav); right: 440px; bottom: 10%; height: 62%; }

  #title.active { display: grid; grid-template-columns: 1fr minmax(340px, 420px); align-items: center; gap: 24px; }
  #title .hero { grid-column: 1; align-self: start; margin-top: 4dvh; }
  #title .touch { grid-column: 1; grid-row: 2; }
  #title .sheet { position: static; grid-column: 2; grid-row: 1 / span 2; }
  #scene[data-mode="title"] .stage { right: 46%; bottom: 8%; height: 52%; }

  .song-list { grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
  .slots { max-width: 560px; }
  #team.active { display: grid; grid-template-columns: minmax(300px, 560px) 1fr; grid-template-rows: auto auto 1fr; align-content: start; align-items: start; column-gap: 24px; }
  #team .team-top, #team .buffbox { grid-column: 1; }
  #team .team-top { position: static; }
  #team .rtabs { grid-column: 2; grid-row: 1; align-self: center; }
  #team .roster { grid-column: 2; grid-row: 2 / span 2; align-content: start; }
  .roster { grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); }
  #gacha.active { display: grid; grid-template-columns: 1fr minmax(280px, 360px); grid-template-rows: auto 1fr auto; align-content: start; gap: 16px 20px; }
  #gacha .btabs { grid-column: 1 / -1; }
  #gacha .banner { grid-column: 1; grid-row: 2 / span 2; }
  #gacha .gacha-info { grid-column: 2; grid-row: 2; align-self: start; }
  #gacha .pulls { grid-column: 2; grid-row: 3; flex-direction: column; position: static; }
  .result { padding: 18px 22px; }
  .rbody { display: grid; grid-template-columns: 1fr 1.2fr; align-items: center; gap: 16px; }

  /* 게임: 가운데 건반 + 양옆 팀 · 점수 패널 */
  .hud { padding-left: 18px; padding-right: 18px; }
  .hp.top { display: none; }
  .gside {
    position: absolute;
    top: 76px;
    bottom: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: min(260px, calc(50% - min(220px, 18%) - 36px));
    padding: 14px;
    overflow-y: auto;
    background: rgba(255, 250, 243, .92);
    border: 3px solid var(--ink);
    border-radius: 24px;
    box-shadow: 0 6px 0 var(--ink);
  }
  .gside.left { right: calc(50% + min(220px, 18%) + 18px); }
  .gside.right { left: calc(50% + min(220px, 18%) + 18px); }
  .gside h3 { margin: 0; font-size: 14px; color: var(--ink2); }
  .gside .big { margin: 0 0 6px; font-size: 34px; font-variant-numeric: tabular-nums; }
  .gteam { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; list-style: none; }
  .gteam li { display: flex; align-items: center; gap: 8px; font-size: 14px; }
  .gteam img { width: 34px; height: 34px; background: #fff; border: 2px solid var(--ink); border-radius: 50%; }
  .gteam small { display: block; font-size: 11px; color: var(--ink2); }
  .gside .hp { margin-top: auto; }
  .gside .hp b { color: var(--ink); -webkit-text-stroke: 0; }
  .gcount { display: flex; flex-direction: column; gap: 4px; margin: 0; padding: 0; list-style: none; font-size: 15px; }
  .gcount li { display: flex; justify-content: space-between; }
  .combo, .judge { left: 50%; right: auto; translate: -50% 0; }
}

/* 가로 모바일: 높이가 낮으니 메뉴는 아이콘 위주, 여백 줄이기 */
@media (orientation: landscape) and (min-width: 640px) and (max-height: 540px) {
  :root { --nav: 80px; }
  #nav { gap: 2px; padding: 6px; }
  #nav::before { display: none; }
  #nav button { flex-direction: column; justify-content: center; gap: 0; padding: 5px 2px; font-size: 11px; }
  #nav button svg { width: 24px; height: 24px; }
  #topbar { padding-top: calc(env(safe-area-inset-top) + 6px); }
  .chip img { width: 34px; height: 34px; }
  .icon-btn { width: 40px; height: 40px; }
  .screen { padding: 4px 16px 14px; }
  .screen.full { padding-top: 10px; padding-bottom: 10px; }
  .logo { font-size: 52px; }
  #home .logo { font-size: 42px; }
  .play { font-size: 26px; padding: 10px; }
  .mini { min-height: 60px; }
  #title .hero { margin-top: 0; }
  .sheet { padding: 10px 14px; gap: 6px; max-height: calc(100dvh - 24px); overflow-y: auto; }
  .field input { padding: 7px 14px; }
  .btn.big { font-size: 21px; padding: 9px 14px; }
  .banner-art img { width: min(70%, 260px); }
  .gside { top: 64px; bottom: 10px; padding: 10px; gap: 4px; }
  .gside .big { font-size: 24px; margin: 0; }
  .gteam img { width: 26px; height: 26px; }
  .hud { padding-top: 6px; }
  .combo { top: 20%; }
  .combo b { font-size: 44px; }
  .judge { top: 40%; font-size: 34px; }
  .stamp { width: 84px; height: 84px; font-size: 56px; }
  .rscore { font-size: 30px; }
  .result { gap: 4px; padding: 10px 16px; }
  #result.active { justify-content: flex-start; gap: 8px; }
  dialog { max-height: 94dvh; padding: 14px; gap: 8px; }
  .sd-top img { width: 76px; height: 76px; }
}

/* =====================================================================
   새 기능: 우편함 · 5단계 난이도 · 랭킹 팝업 · 끌어서 장착 · 진화 · 배너 · 업적 분류 · 축하 연출
   ===================================================================== */

img { -webkit-user-drag: none; }
.icon-btn .dot { position: absolute; top: -3px; right: -3px; width: 13px; height: 13px; background: #ff5c8a; border: 2px solid #fff; border-radius: 50%; }
#topbar .icon-btn { width: 42px; height: 42px; }
.empty { list-style: none; padding: 22px 8px; text-align: center; color: var(--ink2); }

/* 난이도 색 */
.d-easy { --dc: #4fbf86; }
.d-normal { --dc: #3d9bec; }
.d-hard { --dc: #ff9d1c; }
.d-expert { --dc: #ff4f86; }
.d-master { --dc: #9a5cf0; }

/* 홈 카드 */
.mini em { font-style: normal; font-size: 13px; color: #e5487f; }

/* 곡 목록: 자켓 + 난이도 5칸 레벨 */
.song { grid-template-columns: 72px 1fr auto; }
.song .info { min-width: 0; }
.song .t { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lvs { display: flex; gap: 3px; margin-top: 4px; }
.lvs i { display: grid; place-items: center; min-width: 25px; height: 21px; padding: 0 3px; font-size: 13px; font-style: normal; color: #fff; background: var(--dc); border: 2px solid var(--ink); border-radius: 8px; text-shadow: 0 1px 0 rgba(74, 57, 83, .4); }
img.jc { object-fit: contain !important; background: var(--jc); }

/* 곡 창: 넓은 화면은 왼쪽 랭킹, 모바일은 난이도 아래 */
dialog.wide { width: min(94vw, 880px); }
.sd-grid { display: grid; gap: 10px; grid-template-areas: "top" "diff" "rank" "buff" "boost" "start"; min-width: 0; }
.sd-top { grid-area: top; }
.diffs { grid-area: diff; display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; }
.sd-rank { grid-area: rank; }
.sd-buffs { grid-area: buff; }
.sd-boost { grid-area: boost; }
.sd-start { grid-area: start; display: flex; }
.sd-start .btn { flex: 1; }
.diffs button { position: relative; display: flex; flex-direction: column; align-items: center; gap: 0; padding: 6px 2px 5px; font-size: 11px; color: var(--ink); background: #fff; border: 3px solid var(--ink); border-radius: 14px; box-shadow: 0 3px 0 var(--ink); }
.diffs button b { font-size: 22px; font-weight: normal; line-height: 1.1; color: var(--dc); -webkit-text-stroke: 1px var(--ink); paint-order: stroke fill; }
.diffs button small { position: absolute; top: -9px; right: -5px; padding: 0 5px; font-size: 11px; color: #fff; background: #e5487f; border: 2px solid var(--ink); border-radius: 99px; }
.diffs button[aria-checked="true"] { color: #fff; background: var(--dc); translate: 0 2px; box-shadow: 0 1px 0 var(--ink); }
.diffs button[aria-checked="true"] b { color: #fff; }
.sd-rank { display: flex; flex-direction: column; gap: 6px; min-width: 0; padding: 10px; background: linear-gradient(160deg, #fff7dc, #ffe6f0); border: 2px solid var(--ink); border-radius: 18px; }
.sd-rank h3 { display: flex; align-items: center; gap: 6px; margin: 0; font-size: 17px; }
.sd-rank h3 svg { width: 20px; height: 20px; }
.sd-rank h3 small { font-size: 12px; color: var(--ink2); }
.sd-me { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; padding: 6px 10px; font-size: 13px; background: #fff; border: 2px dashed #e5487f; border-radius: 12px; }
.sd-me b { font-size: 20px; font-weight: normal; color: #e5487f; }
.sd-me em { margin-left: auto; font-style: normal; font-variant-numeric: tabular-nums; }
.ranklist.compact { max-height: 220px; overflow-y: auto; gap: 5px; padding: 0; counter-reset: none; }
.ranklist.compact li { padding: 3px 8px 3px 3px; gap: 6px; border-width: 2px; border-radius: 14px; }
.ranklist.compact li::before { width: 24px; height: 24px; font-size: 13px; }
.ranklist.compact img { width: 28px; height: 28px; }
.ranklist.compact .nm, .ranklist.compact .sc { font-size: 14px; }
.ranklist.compact .rk { width: 20px; font-size: 14px; }
.ranklist li[data-n]::before { content: attr(data-n); }
.ranklist li.empty { justify-content: center; border-style: dashed; }
.ranklist li.empty::before { display: none; }
@media (min-width: 720px) {
  .sd-grid { grid-template-columns: 290px minmax(0, 1fr); grid-template-areas: "rank top" "rank diff" "rank buff" "rank boost" "rank start"; align-items: start; column-gap: 16px; }
  .sd-rank { align-self: stretch; }
  .ranklist.compact { max-height: none; flex: 1; }
}

/* 팀: 위쪽(칸)은 스크롤해도 따라와서 카드를 끌어다 놓을 수 있다 */
.team-top { position: sticky; top: -6px; z-index: 3; display: flex; flex-direction: column; gap: 8px; margin: -6px -14px 0; padding: 6px 14px 8px; background: linear-gradient(rgba(255, 233, 243, .97) 85%, rgba(255, 233, 243, 0)); }
.tpower { padding: 3px 12px; font-size: 14px; background: #fff; border: 2px solid var(--ink); border-radius: 999px; }
.tpower b { font-weight: normal; font-size: 18px; color: #e5487f; font-variant-numeric: tabular-nums; }
.slot { touch-action: pan-y; }
.slot.filled { border-color: var(--rc, var(--ink)); }
.slot .pw { font-size: 11px; color: var(--ink2); }
.slot .bdg, .ccard .bdg { position: absolute; font-size: 16px; line-height: 1; }
.slot .bdg { top: 18px; right: 6px; }
.slots.dropping .slot { outline: 3px dashed var(--pink); outline-offset: 2px; }
.slot.over { transform: translateY(-6px) scale(1.04); background: #fff3c4; outline-style: solid !important; }
.drag-ghost { position: fixed; left: 0; top: 0; z-index: 100; width: 68px; height: 68px; padding: 4px; background: #fff; border: 3px solid var(--ink); border-radius: 50%; box-shadow: 0 10px 20px rgba(74, 57, 83, .35); pointer-events: none; animation: popIn .2s; }
.rtabs { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rtabs .seg { flex: 1; }
.rtabs small { color: var(--ink2); }
.ccard { touch-action: pan-y; -webkit-touch-callout: none; }
.ccard img.wide, .cd-card img.wide, .nc-card img.wide, .rcard img.wide, .art img.wide { object-fit: contain; }
.rbadge { position: absolute; top: 4px; right: 4px; z-index: 1; padding: 0 6px; font-size: 11px; line-height: 1.5; color: #fff; background: var(--rc); border: 2px solid var(--ink); border-radius: 999px; text-shadow: 0 1px 0 rgba(74, 57, 83, .4); }
.ccard .bdg { top: 26px; right: 6px; }
.ccard .meta { display: flex; align-items: center; justify-content: center; gap: 4px; width: 100%; padding: 0 3px; font-size: 11px; white-space: nowrap; }
.ccard .stg { color: #e09a00; }
.ccard .pw, .pw { color: #e5487f; font-variant-numeric: tabular-nums; }
.evo { color: #ffb400; letter-spacing: -1px; -webkit-text-stroke: .6px var(--ink); paint-order: stroke fill; }
.syn-list button { display: flex; align-items: center; gap: 6px; width: 100%; padding: 3px 6px; font-size: 13px; text-align: left; color: var(--ink2); background: none; border: 0; border-radius: 10px; }
.syn-list button:hover { background: #fff5f9; }
.syn-list button.on { color: var(--ink); }
.syn-list button.on::before { content: '✦'; color: #ffb400; }
.syn-list li::before { display: none; }
.buffbox h3 small { font-size: 12px; color: var(--ink2); }

/* 캐릭터 창 · 진화 */
.cd-card { position: relative; }
.cd-card.e1 { box-shadow: 0 6px 0 var(--ink), 0 0 14px 3px #b9e4ff; }
.cd-card.e2 { box-shadow: 0 6px 0 var(--ink), 0 0 18px 5px #ffd25e; }
.cd-card.e3 { box-shadow: 0 6px 0 var(--ink), 0 0 22px 7px #ff9ed2; animation: evoGlow 2.4s linear infinite; }
@keyframes evoGlow { 50% { box-shadow: 0 6px 0 var(--ink), 0 0 26px 9px #a9d8ff; } }
.cd-card .bdg { position: absolute; bottom: 6px; right: 8px; font-size: 26px; }
.cd-line { align-self: center; margin: -4px 0 0; padding: 6px 14px; font-size: 16px; background: #fff; border: 2px solid var(--ink); border-radius: 16px; animation: popIn .3s cubic-bezier(.3, 1.6, .5, 1); }
#cdName small { font-size: 15px; color: #e09a00; }
.cd-sub b { font-weight: normal; color: #e5487f; }
.cd-stages { display: grid; grid-template-columns: 1fr 1fr; }
.cd-stages li { font-size: 12px; padding: 4px 8px; }
.cd-stages li.got { color: var(--ink); }
.cd-evo { display: flex; flex-direction: column; gap: 8px; }
.evo-head, .evo-done { margin: 0; text-align: center; font-size: 17px; }
.evo-head b, .evo-done b { font-weight: normal; color: #e5487f; }
.evo-gain { margin: 0; padding: 8px 10px; font-size: 13px; text-align: center; line-height: 1.6; background: #fff; border: 2px solid var(--ink); border-radius: 14px; }
.evo-gain b { font-weight: normal; color: #e5487f; }
.evo-req { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.evo-req li { display: inline-flex; align-items: center; gap: 3px; padding: 2px 10px; font-size: 13px; color: var(--ink2); background: #f3eaf5; border: 2px solid #d9cce0; border-radius: 999px; }
.evo-req li.ok { color: var(--ink); background: #dff7ea; border-color: #4fbf86; }
.evo-req li.ok::before { content: '✔'; color: #2e9e6e; }
.evo-req svg { width: 16px; height: 16px; }
.prog { display: block; height: 10px; overflow: hidden; background: #efe4f3; border: 2px solid var(--ink); border-radius: 99px; }
.prog i { display: block; height: 100%; background: linear-gradient(90deg, var(--mint), var(--sky)); transition: width .3s; }
.mats { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 6px; max-height: 210px; overflow-y: auto; padding: 2px; }
.mat { position: relative; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 5px 2px; font-size: 11px; background: var(--rbg); border: 2px solid var(--ink); border-radius: 14px; }
.mat img { width: 38px; height: 38px; }
.mat .nm { width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; text-align: center; }
.mat .cnt { padding: 0 6px; font-size: 12px; background: #fff; border-radius: 99px; }
.mat.on { outline: 3px solid var(--pink); outline-offset: 1px; }
.mat.on .cnt { color: #fff; background: #e5487f; }
.mat .inteam { position: absolute; top: 2px; left: 2px; padding: 0 4px; font-size: 10px; color: #fff; background: var(--pink); border-radius: 99px; }

/* 뽑기: 배너 6종 */
.btabs { display: flex; gap: 6px; overflow-x: auto; padding: 2px 2px 8px; margin: 0 -2px; scrollbar-width: none; scroll-snap-type: x proximity; }
.btabs::-webkit-scrollbar { display: none; }
.btabs button { flex: none; display: flex; align-items: center; gap: 5px; padding: 7px 12px; font-size: 14px; white-space: nowrap; background: rgba(255, 255, 255, .9); border: 3px solid var(--ink); border-radius: 999px; box-shadow: 0 3px 0 var(--ink); scroll-snap-align: start; }
.btabs button span { font-size: 17px; }
.btabs button[aria-selected="true"] { color: #fff; background: var(--pink); translate: 0 2px; box-shadow: 0 1px 0 var(--ink); text-shadow: 0 1px 0 rgba(74, 57, 83, .4); }
.banner p b { font-weight: normal; color: #e5487f; }
.banner .rates { position: relative; display: flex; flex-wrap: wrap; justify-content: center; gap: 5px; margin: 6px 0 2px; }
.banner .rates span { padding: 1px 9px; font-size: 13px; color: #fff; background: var(--rc); border: 2px solid var(--ink); border-radius: 999px; text-shadow: 0 1px 0 rgba(74, 57, 83, .4); }
.art { position: relative; display: flex; justify-content: center; align-items: flex-end; height: min(34vh, 210px); }
.art.one img { height: 100%; aspect-ratio: 3 / 4; object-fit: cover; background: var(--rbg); border: 3px solid var(--ink); border-radius: 18px; box-shadow: 0 0 22px rgba(255, 196, 0, .8); animation: squish var(--beat) ease-in-out infinite; transform-origin: 50% 100%; }
.art.faces { align-items: center; gap: 4px; }
.art.faces img { width: 23%; max-width: 96px; background: #fff; border: 3px solid var(--ink); border-radius: 50%; animation: hop var(--beat) ease-in-out infinite; }
.art.faces img:nth-child(2n) { animation-delay: -.5s; }
.art.fan img { width: 28%; max-width: 120px; aspect-ratio: 3 / 4; margin: 0 -4%; object-fit: cover; background: linear-gradient(160deg, #f6eeff, #dcc6ff); border: 3px solid var(--ink); border-radius: 14px; }
.art.fan img:nth-child(1) { rotate: -12deg; }
.art.fan img:nth-child(2) { rotate: -4deg; translate: 0 -8px; }
.art.fan img:nth-child(3) { rotate: 4deg; translate: 0 -8px; }
.art.fan img:nth-child(4) { rotate: 12deg; }
.pk { position: absolute; top: 4px; left: 50%; translate: -50% 0; padding: 2px 12px; font-size: 14px; color: #fff; background: #ff5c8a; border: 2px solid var(--ink); border-radius: 999px; rotate: -6deg; }
.banner-art { position: relative; }
.pulls { position: sticky; bottom: 0; z-index: 2; padding: 6px 0 2px; }
.pulls .btn[hidden] + .btn { flex: 1; }

/* 뽑기 결과: 직접 눌러서 뒤집기 · 높은 등급은 뒷면이 반짝 */
.rcard { display: block; width: 100%; padding: 0; color: inherit; background: none; border: 0; font: inherit; }
.rcard .in { display: block; }
.rcard .face { display: flex; }
.rcard .back span { animation: none; }
.rcard:not(.open):hover .in { transform: translateY(-4px) rotate(-2deg); }
.rcard.r2 .back { background: repeating-linear-gradient(45deg, #8ec5ff 0 12px, #b5d9ff 12px 24px); }
.rcard.r3 .back { background: repeating-linear-gradient(45deg, #b48cff 0 12px, #d2b8ff 12px 24px); animation: glowR3 1.4s ease-in-out infinite; }
.rcard.r4 .back { background: repeating-linear-gradient(45deg, #ffcf5c 0 12px, #fff0b3 12px 24px); animation: glowR4 .9s ease-in-out infinite, shake .5s infinite; }
@keyframes glowR3 { 50% { box-shadow: 0 0 16px 4px #c9a6ff; filter: brightness(1.12); } }
@keyframes glowR4 { 0%, 100% { box-shadow: 0 0 12px 3px #ffe08d; filter: brightness(1); } 50% { box-shadow: 0 0 26px 9px #fff3b0; filter: brightness(1.35); } }
.rcard.r3.open .front { box-shadow: 0 0 18px 3px #c9a6ff; }
.rcard.r4.open .front { box-shadow: 0 0 24px 6px #ffd25e; }
.rcard .front .rbadge { top: auto; bottom: 22px; right: 3px; font-size: 9px; padding: 0 4px; }
.reveal-hint { margin: 0; text-align: center; font-size: 20px; color: #fff; -webkit-text-stroke: 5px var(--ink); paint-order: stroke fill; }
.overlay.reveal.flash::after { content: ''; position: absolute; inset: 0; background: radial-gradient(circle, rgba(255, 244, 180, .9), rgba(255, 244, 180, 0) 70%); pointer-events: none; animation: flashOnce .9s ease-out forwards; }
@keyframes flashOnce { from { opacity: 1; } to { opacity: 0; } }
#revealOk:disabled { filter: grayscale(.6) opacity(.6); }
.overlay.newcard { z-index: 25; background: radial-gradient(circle at 50% 40%, rgba(255, 233, 160, .55), rgba(36, 26, 61, .92) 70%); cursor: pointer; }
.nc-box { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; color: #fff; animation: ncZoom .5s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes ncZoom { from { opacity: 0; scale: .3; rotate: -10deg; filter: brightness(2.5); } }
.nc-new { margin: 0; font-size: 34px; color: #ffe08d; -webkit-text-stroke: 7px var(--ink); paint-order: stroke fill; }
.nc-card { width: min(56vw, 240px); aspect-ratio: 3 / 4; overflow: hidden; background: var(--rbg); border: 4px solid var(--ink); border-radius: 20px; box-shadow: 0 0 40px 8px rgba(255, 220, 120, .8); }
.nc-card img { width: 100%; height: 100%; object-fit: cover; }
.nc-rarity { margin: 4px 0 0; font-size: 20px; -webkit-text-stroke: 4px var(--ink); paint-order: stroke fill; }
.nc-box h2 { margin: 0; font-size: 30px; -webkit-text-stroke: 6px var(--ink); paint-order: stroke fill; }
.nc-line { margin: 0; font-size: 18px; color: #ffe3ee; }
.nc-box small { opacity: .75; }

/* 업적: 오늘의 보상 · 분류 */
.qpane { display: flex; flex-direction: column; gap: 10px; }
.online { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px 8px; }
.on-head { display: flex; justify-content: space-between; align-items: baseline; }
.on-head b { font-size: 18px; font-weight: normal; }
.on-head small { color: #e5487f; }
.on-track { position: relative; height: 72px; margin: 4px 22px 0 10px; }
.on-track .prog { position: absolute; top: 14px; left: 0; right: 0; }
.on-step { position: absolute; top: 0; translate: -50% 0; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 0; background: none; border: 0; }
.on-step .r { display: inline-flex; align-items: center; gap: 2px; min-width: 38px; min-height: 34px; padding: 2px 6px; font-size: 11px; background: #fff; border: 2px solid var(--ink); border-radius: 12px; }
.on-step .r svg { width: 13px; height: 13px; }
.on-step small { font-size: 11px; color: var(--ink2); }
.on-step.ready .r { background: #fff3c4; border-color: #e5487f; animation: breathe .9s ease-in-out infinite; }
.on-step.got .r { color: #2e9e6e; background: #dff7ea; }
.on-step:disabled { cursor: default; }
.cats { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; }
.cats button { padding: 4px 11px; font-size: 13px; background: #fff; border: 2px solid var(--ink); border-radius: 999px; }
.cats button i { margin-left: 4px; padding: 0 5px; font-size: 11px; font-style: normal; color: #fff; background: #ff5c8a; border-radius: 99px; }
.cats button[aria-pressed="true"] { color: #fff; background: var(--ink); }
.hide-done { display: inline-flex; align-items: center; gap: 4px; margin-left: auto; font-size: 13px; color: var(--ink2); }
.hide-done input { width: 18px; height: 18px; accent-color: var(--pink); }
.ach-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 14px; color: var(--ink2); }
.quest .cat { margin-right: 6px; padding: 0 6px; font-size: 11px; color: #fff; background: var(--ink2); border-radius: 99px; vertical-align: 2px; }
.quest .btn .reward { flex-wrap: wrap; justify-content: center; }

/* 랭킹 화면 */
.diffseg { margin-top: 8px; }
.diffseg button[aria-pressed="true"] { background: var(--dc); }
.my-rank { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; padding: 8px 14px; font-size: 14px; background: #fff; border: 3px dashed #e5487f; border-radius: 18px; }
.my-rank:empty { display: none; }
.my-rank b { font-size: 20px; font-weight: normal; color: #e5487f; }

/* 게임: FAST/SLOW · 콤보 응원 */
.timing { position: absolute; top: calc(44% + 46px); left: 0; right: 0; font-size: 17px; text-align: center; letter-spacing: 2px; pointer-events: none; opacity: 0; -webkit-text-stroke: 4px var(--ink); paint-order: stroke fill; }
.timing.fast { color: #8fd3ff; }
.timing.slow { color: #ffb36b; }
.cheer { position: absolute; top: calc(env(safe-area-inset-top) + 92px); left: 50%; translate: -50% 0; display: flex; align-items: center; gap: 8px; max-width: 92%; padding: 4px 14px 4px 4px; background: #fff; border: 3px solid var(--ink); border-radius: 999px; box-shadow: 0 4px 0 var(--ink); pointer-events: none; animation: popIn .35s cubic-bezier(.3, 1.6, .5, 1); }
.cheer img { width: 40px; height: 40px; }
.cheer p { margin: 0; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* 결과: 신기록 축하 · 랭킹 순위 */
.board { margin: 0; padding: 8px 12px; font-size: 14px; text-align: center; line-height: 1.5; background: #fff7dc; border: 2px solid var(--ink); border-radius: 14px; animation: popIn .4s 1.1s both cubic-bezier(.3, 1.6, .5, 1); }
.board b { font-weight: normal; font-size: 18px; color: #e5487f; }
.board em { font-style: normal; color: #2e9e6e; }
.celebrate { position: absolute; inset: 0; z-index: 12; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; pointer-events: none; background: radial-gradient(circle, rgba(255, 240, 180, .55), transparent 65%); animation: celebFade 2.6s ease-out forwards; }
@keyframes celebFade { 0%, 75% { opacity: 1; } 100% { opacity: 0; } }
.celebrate .nr { margin: 0; font-size: clamp(44px, 13cqw, 76px); color: #fff; -webkit-text-stroke: 9px var(--ink); paint-order: stroke fill; text-shadow: 0 0 24px #ffd25e, 0 0 6px #ff8db6; animation: nrPop .8s cubic-bezier(.2, 1.6, .4, 1) both, nrHue 1.2s linear infinite; }
@keyframes nrPop { from { scale: 3; rotate: -14deg; opacity: 0; } }
@keyframes nrHue { 50% { color: #ffe08d; } }
.celebrate .nr-sub { margin: 0; font-size: 22px; color: #fff; -webkit-text-stroke: 5px var(--ink); paint-order: stroke fill; animation: popIn .4s .5s both; }

/* 설정: 키 바꾸기 */
.keys { display: flex; flex-direction: column; gap: 6px; font-size: 17px; }
.keys small { font-size: 12px; color: var(--ink2); }
.keygrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.keygrid button { display: flex; flex-direction: column; align-items: center; padding: 6px 2px; background: #fff; border: 3px solid var(--ink); border-radius: 14px; box-shadow: 0 3px 0 var(--ink); }
.keygrid button small { font-size: 10px; }
.keygrid button b { font-size: 18px; font-weight: normal; }
.keygrid button.listening { background: #fff3c4; border-color: #e5487f; animation: blink .8s infinite; }
.keygrid button.listening b { font-size: 12px; }
.keys .btn { align-self: flex-start; }

/* 내 정보 · 닉네임 변경 */
.pname { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; }
.rename { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.rename input { flex: 1; min-width: 140px; padding: 8px 12px; font: inherit; font-size: 16px; color: var(--ink); background: #fff; border: 3px solid var(--ink); border-radius: 14px; outline: none; }
.rename small { flex-basis: 100%; font-size: 12px; color: var(--ink2); }

/* 우편함 */
.mail-top { display: flex; align-items: center; justify-content: space-between; }
.mail-top small { color: var(--ink2); }
.mail-list, .ask-list { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; list-style: none; max-height: 56dvh; overflow-y: auto; }
.mail { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; padding: 8px 10px; background: #fff; border: 2px solid var(--ink); border-radius: 16px; }
.mail.unread { background: #fff7dc; }
.mail.got { opacity: .65; }
.mail .mi { font-size: 26px; }
.mail b { display: block; font-size: 15px; font-weight: normal; }
.mail p { margin: 2px 0; font-size: 13px; line-height: 1.45; color: var(--ink2); word-break: keep-all; overflow-wrap: anywhere; }
.mail small { font-size: 11px; color: var(--ink2); }
.mail .btn { min-width: 70px; }

/* 문의하기 */
.field textarea { width: 100%; padding: 10px 14px; font: inherit; font-size: 16px; color: var(--ink); background: #fff; border: 3px solid var(--ink); border-radius: 18px; outline: none; resize: vertical; user-select: text; -webkit-user-select: text; }
.field textarea:focus { box-shadow: 0 0 0 4px var(--pink2); }
.field small { color: var(--ink2); }
.ask-list { max-height: 30dvh; }
.ask-list li { padding: 8px 10px; font-size: 14px; background: #fff; border: 2px solid #e4d9ea; border-radius: 14px; }
.ask-list li.empty { border: 0; background: none; }
.ask-list b { font-weight: normal; }
.ask-list .cat { margin-right: 6px; padding: 0 6px; font-size: 11px; color: #fff; background: var(--ink2); border-radius: 99px; }
.ask-list .st { float: right; font-size: 12px; color: var(--ink2); }
.ask-list .st.done { color: #2e9e6e; }
.ask-list p { margin: 4px 0 0; font-size: 13px; color: #e5487f; }

/* 화면 · 창 안의 칸들이 공간이 모자라도 찌그러지지 않고 스크롤되게 */
.screen > *, dialog[open] > * { flex-shrink: 0; }
.mats > p { grid-column: 1 / -1; }
.team-top { background: linear-gradient(#ffe9f3 88%, rgba(255, 233, 243, 0)); }
.rcard .front .rbadge { top: 4px; right: 4px; bottom: auto; }
.screen .hint, .sub small { text-shadow: 0 0 3px #fff, 0 0 6px #fff; }
.toast { width: max-content; white-space: normal; text-align: center; word-break: keep-all; }
/* 접속 시간 보상: 단계를 같은 간격으로 놓고, 막대는 단계 사이를 나눠 채운다 */
.on-track { display: grid; grid-template-columns: repeat(5, 1fr); height: auto; margin: 4px 0 0; }
.on-track .prog { position: absolute; top: 15px; left: 10%; right: 10%; }
.on-step { position: relative; top: auto; translate: none; justify-self: center; }
/* 모바일 세로 화면: 팀은 카드 목록을 먼저, 버프 · 시너지 설명은 아래로 */
@media (orientation: portrait), (max-width: 639px) {
  #team .buffbox { order: 5; }
}

/* 모바일: 창은 아래에서 올라오는 시트로, 누르기 쉬운 크기로 */
@media (max-width: 560px) {
  dialog, dialog.wide {
    width: 100vw;
    max-width: 100vw;
    max-height: 92dvh;
    margin: auto 0 0;
    padding: 18px 14px calc(env(safe-area-inset-bottom) + 14px);
    border-width: 3px 0 0;
    border-radius: 28px 28px 0 0;
    box-shadow: 0 -6px 0 var(--ink);
  }
  dialog[open] { animation: sheetUp .35s cubic-bezier(.2, .9, .3, 1.1); }
  .sd-top img { width: 84px; height: 84px; }
  .sd-top h2 { font-size: 20px; }
  .sd-start { position: sticky; bottom: calc(-14px - env(safe-area-inset-bottom)); margin: 0 -14px calc(-14px - env(safe-area-inset-bottom)); padding: 8px 14px calc(env(safe-area-inset-bottom) + 12px); background: linear-gradient(rgba(255, 250, 243, 0), var(--cream) 30%); }
  .diffs button { font-size: 10px; }
  .boosters .boost { font-size: 11px; }
  .roster { grid-template-columns: repeat(auto-fill, minmax(94px, 1fr)); }
  .head h2 { font-size: 26px; }
  #songs .head .hint { order: 3; }
  .reveal-grid { gap: 6px; }
  .rcard .front .nm { font-size: 9px; }
  .rcard .lbl { font-size: 9px; }
  .celebrate .nr { -webkit-text-stroke-width: 7px; }
}
@media (max-width: 380px) {
  .money { min-width: 74px; font-size: 14px; }
  .who b { max-width: 70px; }
  .lvs i { min-width: 22px; font-size: 12px; }
}

/* =====================================================================
   여백 줄이기: 간격 · 패딩 · 크기를 줄여 화면이 늘어져 보이지 않게
   ===================================================================== */
#nav { grid-template-columns: repeat(7, 1fr); gap: 0; padding: 4px 4px calc(env(safe-area-inset-bottom) + 4px); }
#nav button { padding: 4px 0; font-size: 11px; border-radius: 12px; }
#nav button svg { width: 23px; height: 23px; }
#topbar { gap: 6px; padding: calc(env(safe-area-inset-top) + 8px) 10px 4px; }
.chip img { width: 36px; height: 36px; }
.screen { gap: 8px; padding: 4px 12px 14px; }
.head { gap: 8px; }
.head h2 { font-size: 24px; -webkit-text-stroke-width: 5px; }
.head .count { font-size: 14px; color: var(--ink2); text-shadow: 0 0 3px #fff; }
.btn { padding: 9px 15px; font-size: 18px; border-radius: 18px; box-shadow: 0 5px 0 var(--ink), inset 0 3px 0 rgba(255, 255, 255, .45), inset 0 -3px 0 rgba(0, 0, 0, .08); }
.btn.big { padding: 10px 16px; font-size: 21px; }
.btn.small { padding: 5px 10px; font-size: 14px; border-radius: 14px; }
.card-box, .panel { border-radius: 20px; box-shadow: 0 4px 0 var(--ink); }
.cats button { padding: 3px 10px; }
/* 홈 */
.home-cards { gap: 8px; }
.mini { min-height: 58px; padding: 6px 10px; border-radius: 16px; box-shadow: 0 4px 0 var(--ink); }
.play { padding: 10px; font-size: 26px; }
@media (orientation: portrait), (max-width: 639px) {
  #scene[data-mode="home"] .stage { bottom: 25%; height: 42%; }
}
/* 곡 목록 */
.song-list { gap: 7px; }
.song { grid-template-columns: 56px 1fr auto; gap: 10px; padding: 5px 10px 5px 5px; border-radius: 16px; box-shadow: 0 3px 0 var(--ink); }
.song img { width: 56px; height: 56px; border-width: 2px; border-radius: 12px; }
.song .t { font-size: 16px; }
.song .m { margin-top: 0; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.song .m b { font-weight: normal; }
.lvs { margin-top: 2px; }
.lvs i { min-width: 21px; height: 18px; font-size: 12px; border-width: 1.5px; border-radius: 6px; }
/* 팀 */
.team-top { gap: 6px; margin: -4px -12px 0; padding: 4px 12px 6px; }
.slots { gap: 6px; }
.slot { aspect-ratio: 5 / 6; border-radius: 14px; }
.slot img { width: 64%; }
.roster { grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 7px; }
.ccard { border-radius: 12px; box-shadow: 0 3px 0 var(--ink); }
.ccard .nm { font-size: 11px; }
.ccard .meta { font-size: 10px; }
.rbadge { padding: 0 5px; font-size: 10px; }
.buffbox { gap: 6px; padding: 8px 10px; }
.syn-list button { padding: 2px 4px; font-size: 12px; }
.sortsel { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--ink2); }
.sortsel select { padding: 3px 6px; font: inherit; font-size: 13px; color: var(--ink); background: #fff; border: 2px solid var(--ink); border-radius: 10px; }
/* 뽑기 */
.banner { padding: 10px 12px; border-radius: 22px; box-shadow: 0 5px 0 var(--ink); }
.banner h2 { margin: 2px 0 0; font-size: 23px; }
.art { height: min(24vh, 160px); }
.banner-art img { width: min(62%, 280px); }
.btabs button { padding: 5px 10px; font-size: 13px; }
.gacha-info { padding: 8px 12px 8px 28px; font-size: 13px; line-height: 1.5; }
/* 상점 */
.shop-grid { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.item { padding: 8px 6px; border-radius: 16px; box-shadow: 0 4px 0 var(--ink); }
.item .ic { height: 42px; font-size: 30px; }
.item .ic svg { width: 36px; height: 36px; }
.item .ic img { width: 44px; height: 44px; }
.item b { font-size: 14px; }
/* 업적 */
.daily { gap: 10px; padding: 8px 12px; border-radius: 18px; box-shadow: 0 4px 0 var(--ink); }
.daily .ic { font-size: 30px; }
.daily b { font-size: 16px; }
.online { padding: 8px 12px 4px; }
.quest-list { gap: 6px; }
.quest { gap: 8px; padding: 7px 10px; border-radius: 14px; }
.quest b { font-size: 15px; }
.quest p { margin: 0 0 3px; font-size: 12px; }
.quest .prog { height: 7px; }
.quest .btn { min-width: 74px; }
.btn.more { align-self: center; }
/* 랭킹 */
.ranklist { gap: 6px; }
.ranklist li { gap: 8px; padding: 4px 10px 4px 4px; border-radius: 16px; }
.ranklist li::before { width: 28px; height: 28px; font-size: 15px; }
.ranklist img { width: 34px; height: 34px; }
.ranklist .nm, .ranklist .sc { font-size: 15px; }
.songtabs button { width: 78px; padding: 4px; }
.songtabs img { width: 44px; height: 44px; }
/* 창 */
@media (min-width: 561px) {
  dialog { padding: 16px; }
}
dialog[open] { gap: 10px; }
dialog h2 { font-size: 23px; }
.sd-top img { width: 92px; height: 92px; }
.cd-card { width: 150px; }
/* PC: 본문이 화면 끝까지 늘어나지 않게 가운데로 모은다 */
@media (orientation: landscape) and (min-width: 640px) and (min-height: 541px) {
  :root { --nav: 180px; }
  #nav button { padding: 8px 12px; font-size: 17px; }
  .screen:not(.full) { max-width: 1120px; margin: 0 auto; padding: 6px 20px 20px; }
  .song-list { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
  .roster { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); }
}

/* =====================================================================
   v3: 신화 등급 · 의상 테마 · 새 난이도 · 출석부 · 공지 · 점검 예고 · 등급 확정 뽑기 · 진화 · 랭킹 시상대 · 광고
   ===================================================================== */

/* 신화 등급: 무지갯빛 */
.r5 { --rbg: linear-gradient(135deg, #ffe0ec, #fff3c2 25%, #d7f7ff 50%, #e7dcff 75%, #ffe0ec); --rc: #ff3d6e; }
.rbadge.r5, .banner .rates span.r5, .until-sum .r5, .until-grade .r5[aria-pressed="true"] { background: linear-gradient(90deg, #ff5d8f, #ffb03a, #4ec3ff, #a66bff); }
.ccard.r5:not(.locked), .slot.r5, .cd-card.r5, .nc-card.r5 { animation: mythGlow 2.4s linear infinite; }
@keyframes mythGlow {
  0%, 100% { box-shadow: 0 4px 0 var(--ink), 0 0 14px 2px rgba(255, 61, 110, .75); }
  33% { box-shadow: 0 4px 0 var(--ink), 0 0 16px 3px rgba(255, 190, 60, .85); }
  66% { box-shadow: 0 4px 0 var(--ink), 0 0 16px 3px rgba(80, 170, 255, .85); }
}
.rcard.r5 .back { background: repeating-linear-gradient(45deg, #ff9ec4 0 10px, #ffe08d 10px 20px, #9ee3ff 20px 30px, #c9b3ff 30px 40px); animation: glowR5 .8s ease-in-out infinite, shake .45s infinite; }
@keyframes glowR5 { 50% { box-shadow: 0 0 30px 10px #fff; filter: brightness(1.35) saturate(1.3); } }
.rcard.r5.open .front { box-shadow: 0 0 24px 6px #ff8fc0, 0 0 40px 12px #9fe0ff; }
.rcard.r4 .back { animation: glowR4 .9s ease-in-out infinite, shake .5s infinite; }
.overlay.reveal.myth::after { background: conic-gradient(from 0deg, rgba(255, 120, 170, .7), rgba(255, 220, 120, .7), rgba(120, 210, 255, .7), rgba(190, 150, 255, .7), rgba(255, 120, 170, .7)); animation: flashOnce 1.4s ease-out forwards; }
.nc-card.r5 { box-shadow: 0 0 40px 10px rgba(255, 140, 190, .9), 0 0 70px 20px rgba(130, 200, 255, .6); }

/* 의상 테마: 카드 그림(배경이 투명) 뒤에 테마 배경 + 의상 소품(이모지) */
.fx-music { --fx: radial-gradient(circle at 82% 18%, #fff 0 7%, transparent 8%), linear-gradient(160deg, #fff0f7, #e3d8ff); }
.fx-idol { --rbg: radial-gradient(ellipse at 50% -10%, #fff 0 22%, transparent 62%), linear-gradient(160deg, #ffd1e3, #ff9cc5); }
.fx-idol img { mix-blend-mode: multiply; } /* 이 그림만 배경이 흰색이라 카드 배경과 곱해서 물들인다 */
.fx-sakura { --fx: radial-gradient(circle at 18% 22%, #fff 0 3px, transparent 4px) 0 0 / 34px 34px, radial-gradient(circle at 70% 64%, #ffb3cf 0 4px, transparent 5px) 0 0 / 42px 42px, linear-gradient(160deg, #fff0f6, #ffc8dd); }
.fx-summer { --fx: radial-gradient(circle at 82% 16%, #fff6b0 0 10%, transparent 11%), linear-gradient(#a8e6ff 0 62%, #ffe7a3 62%); }
.fx-ghost { --fx: radial-gradient(circle at 50% 35%, #f7f9ff, #cfdaf0 60%, #9aaccc); }
.fx-xmas { --fx: radial-gradient(#fff 1.5px, transparent 2px) 0 0 / 14px 14px, linear-gradient(160deg, #e3fbe9, #ffd3d3); }
.fx-dessert { --fx: repeating-linear-gradient(45deg, #fff6e9 0 10px, #ffeaf3 10px 20px); }
.fx-gamer { --fx: linear-gradient(rgba(255, 255, 255, .13) 1px, transparent 1px) 0 0 / 10px 10px, linear-gradient(90deg, rgba(255, 255, 255, .13) 1px, transparent 1px) 0 0 / 10px 10px, linear-gradient(160deg, #2d3a7a, #4d74d9); }
.fx-book { --fx: repeating-linear-gradient(0deg, transparent 0 15px, rgba(120, 90, 60, .13) 15px 16px), linear-gradient(160deg, #fbf4e6, #e6d4b5); }
.fx-chef { --fx: conic-gradient(#fff 25%, #ffe1e1 0 50%, #fff 0 75%, #ffe1e1 0) 0 0 / 18px 18px; }
.fx-halloween { --fx: radial-gradient(circle at 50% 115%, #ffae4a, #8a3ab9 62%, #34184d); }
.fx-knight { --fx: radial-gradient(circle at 50% 30%, #fff, #dfe6f1 55%, #aebcd3); }
.fx-space { --fx: radial-gradient(#fff 1px, transparent 1.6px) 0 0 / 18px 18px, radial-gradient(#fff 1px, transparent 1.6px) 9px 9px / 18px 18px, linear-gradient(#1c2156, #4351b3); }
.fx-detective { --fx: radial-gradient(circle at 72% 28%, rgba(255, 255, 255, .55) 0 18%, transparent 19%), linear-gradient(160deg, #f1e6cf, #c2a57b); }
.fx-ninja { --fx: repeating-linear-gradient(135deg, rgba(255, 255, 255, .06) 0 8px, transparent 8px 16px), linear-gradient(160deg, #4a5270, #1f2433); }
.fx-magic { --fx: radial-gradient(circle, #fff 0 1.5px, transparent 2.5px) 0 0 / 22px 22px, linear-gradient(160deg, #ebe2ff, #a68cff); }
.fx-royal { --fx: repeating-linear-gradient(45deg, rgba(255, 255, 255, .38) 0 6px, transparent 6px 18px), linear-gradient(160deg, #fff4cf, #ffcf5a); }
.fx-myth { --fx: radial-gradient(circle, #fff 0 1.5px, transparent 2.5px) 0 0 / 20px 20px, linear-gradient(135deg, #ffd6e8, #fff2b3 30%, #c9f5ff 60%, #e2d4ff); }
.fx-gold { --fx: radial-gradient(circle at 50% 40%, #fffbe2, #ffd864 55%, #e3a500); }
.fx-galaxy { --fx: radial-gradient(#fff 1px, transparent 1.6px) 0 0 / 16px 16px, radial-gradient(circle at 30% 30%, #9a86ff, #3a2a8f 55%, #170f45); }
[class*="fx-"]:not(.slot) > img, [class*="fx-"] .front > img, img[class*="fx-"] { background: var(--fx, var(--rbg)) !important; }
.fx-gold:not(.locked) img, img.fx-gold { filter: sepia(.55) saturate(2.4) hue-rotate(-10deg) brightness(1.04); }
.fx-ghost:not(.locked) img, img.fx-ghost { opacity: .88; filter: saturate(.5) brightness(1.06); }
.ccard, .rcard .front, .nc-card, .cd-card, .ef-card { container-type: inline-size; }
:is(.ccard, .rcard .front, .nc-card, .cd-card, .ef-card) > .bdg {
  position: absolute; top: 19%; right: 5%; bottom: auto; left: auto; z-index: 1; font-size: 22cqw; line-height: 1; rotate: 12deg; pointer-events: none;
  filter: drop-shadow(0 2px 0 #fff) drop-shadow(0 0 4px rgba(255, 255, 255, .9));
}
.ccard.locked > .bdg { display: none; }

/* 새 난이도 3개 */
.d-extreme { --dc: #e8364d; }
.d-inferno { --dc: #8e1f2f; }
.d-chaos { --dc: #2e2a3a; }
.diffs { grid-template-columns: repeat(4, 1fr); }
#rankDiff { display: grid; grid-template-columns: repeat(4, 1fr); border-radius: 18px; }
#rankDiff button { padding: 4px 2px; font-size: 12px; }
.lvs { flex-wrap: wrap; gap: 2px; }
.lvs i { min-width: 19px; padding: 0 2px; }
/* 곡 목록: 자켓 + 정보 두 칸. 잠긴 곡은 자켓 아래쪽에 자물쇠 · 가격 띠 */
.song { grid-template-columns: 56px minmax(0, 1fr); }
.song .jk { position: relative; display: block; width: 56px; height: 56px; }
.song .jk img { display: block; }
.song .lockp { position: absolute; left: 0; right: 0; bottom: 0; flex-direction: row; justify-content: center; gap: 1px; padding: 1px 0; font-size: 10px; line-height: 1.3;
  color: #fff; background: rgba(74, 57, 83, .86); border-radius: 0 0 10px 10px; }
.song .lockp svg { width: 11px; height: 11px; }
.song .lockp svg:first-child { stroke: #fff; }

/* 홈: 프로필 아래 공지사항 · 문의하기 (세로) · 광고 · 맨 아래 버전 */
.home-top { display: flex; align-items: flex-start; gap: 8px; }
.home-top .hero { flex: 1; min-width: 0; }
#home .home-top .logo { font-size: clamp(50px, 15.5cqw, 84px); }
.home-links { display: flex; flex-direction: column; gap: 7px; padding-top: 2px; }
.home-links > button { position: relative; display: flex; align-items: center; justify-content: center; gap: 5px; min-width: 112px; padding: 6px 12px;
  font-size: 15px; color: var(--ink); background: rgba(255, 255, 255, .94); border: 2px solid var(--ink); border-radius: 999px; box-shadow: 0 3px 0 var(--ink); }
.home-links b { font-weight: normal; }
.home-links > button:active { translate: 0 2px; box-shadow: 0 1px 0 var(--ink); }
.notice-btn .dot { position: absolute; top: -4px; right: -4px; width: 12px; height: 12px; background: #ff5c8a; border: 2px solid #fff; border-radius: 50%; }
#home .spacer { min-height: 16dvh; }
/* 홈 캐릭터 무대: 연주하기 버튼 바로 위에 서도록 (광고가 뜨면 그만큼 위로) · 무대 높이에 맞춰 크기 조절 */
.stage { container-type: size; }
.trio { width: min(86cqw, 190cqh); }
@media (orientation: portrait), (max-width: 639px) {
  #scene[data-mode="home"] .stage { top: 190px; bottom: 300px; height: auto; }
  #app.ad-on #scene[data-mode="home"] .stage { bottom: 410px; }
}
@media (orientation: landscape) and (min-width: 640px) {
  #app.ad-on #scene[data-mode="home"] .stage { bottom: calc(10% + 110px); }
}

/* 프로필 칸: 조금 더 크게 */
.chip { gap: 9px; padding: 4px 16px 4px 4px; }
.chip img { width: 44px; height: 44px; }
.who b { font-size: 17px; }
.lv { padding: 0 7px; font-size: 12px; }
.exp { width: 62px; height: 9px; }
.ad-box { display: flex; justify-content: center; min-width: 0; overflow: hidden; }
.ad-box.mo { min-height: 100px; margin: 0 -8px; }
.ad-box.pc { min-height: 90px; }
.ask-btn { display: inline-flex; align-items: center; gap: 4px; padding: 3px 12px; font-size: 13px; color: var(--ink); background: rgba(255, 255, 255, .92); border: 2px solid var(--ink); border-radius: 999px; }
.ask-btn b { font-weight: normal; }
.home-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; }
.ver-label { font-size: 11px; color: var(--ink2); text-shadow: 0 0 3px #fff; }
.title-ver { position: absolute; left: 0; right: 0; bottom: calc(env(safe-area-inset-bottom) + 6px); text-align: center; }
.nav-foot { display: none; }
@media (orientation: landscape) and (min-width: 640px) {
  #nav .nav-foot { display: flex; flex-direction: column; align-items: stretch; gap: 6px; margin-top: auto; }
  #nav .ask-btn { justify-content: center; padding: 6px 10px; font-size: 15px; box-shadow: 0 3px 0 var(--ink); }
  .nav-foot .ver-label { text-align: center; }
  .home-foot { display: none; }
  #home.active { grid-template-rows: auto auto 1fr auto; }
  #home .home-top { display: contents; }
  #home .hero { grid-column: 2; grid-row: 1; }
  #home .home-links { grid-column: 2; grid-row: 2; flex-direction: row; justify-content: center; margin-top: 8px; }
  #home .home-links .ask-btn { display: none; } /* PC는 왼쪽 메뉴 맨 아래에 있다 */
  #home .home-top .logo { font-size: clamp(60px, 19cqw, 96px); }
  #home .home-panel { grid-row: 3; }
  #home .ad-box { grid-column: 1 / -1; grid-row: 4; justify-self: center; width: 100%; }
  .chip img { width: 50px; height: 50px; }
  .who b { max-width: 180px; font-size: 19px; }
  .exp { width: 90px; }

  /* 뽑기: 배너 그림 · 글자를 배너 칸 가운데로, 버튼은 1회 | 10회 + 아래 확정 뽑기 */
  #gacha .banner { justify-content: center; gap: 4px; }
  #gacha .art { height: min(36vh, 280px); }
  #gacha .banner-art img { width: min(60%, 380px); }
  #gacha .pulls { display: grid; grid-template-columns: 1fr 1fr; align-content: end; gap: 10px; }
  #gacha .pulls .until, #gacha .pulls .btn[hidden] + .btn { grid-column: 1 / -1; }
}
/* 큰 PC 화면: 본문 · 상단바 · 창을 통째로 키운다 (글자 · 박스가 작아 보이지 않게) */
@media (orientation: landscape) and (min-width: 1100px) and (min-height: 600px) {
  #main, #topbar { zoom: 1.2; }
  dialog { zoom: 1.1; max-height: calc(90dvh / 1.1); }
  #scene[data-mode="home"] .stage { right: 520px; }
}
@media (orientation: landscape) and (min-width: 1500px) and (min-height: 850px) {
  :root { --nav: 250px; }
  #nav { zoom: 1.25; } /* 칸 너비(250px)를 같이 키워서 안쪽은 그대로 200px */
  #main, #topbar { zoom: 1.3; }
  dialog { zoom: 1.2; max-height: calc(90dvh / 1.2); }
  #scene[data-mode="home"] .stage { right: 600px; }
}
@media (orientation: landscape) and (min-width: 640px) and (max-height: 540px) {
  #nav .ask-btn b { display: none; }
  #nav .ask-btn { padding: 4px; font-size: 18px; }
  #home .home-top .logo { font-size: 42px; }
  #gacha .art { height: min(30vh, 150px); }
}

/* 월간 출석부 */
.attend-sum { margin: -4px 0 0; font-size: 13px; text-align: center; color: var(--ink2); }
.attend-sum b { font-weight: normal; color: #e5487f; }
.attend-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin: 0; padding: 0; list-style: none; }
.attend-grid li { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; min-height: 52px; padding: 3px 1px; text-align: center; background: #fff; border: 2px solid #e4d9ea; border-radius: 12px; }
.attend-grid small { font-size: 10px; color: var(--ink2); }
.attend-grid .reward { flex-direction: column; gap: 0; font-size: 10px; line-height: 1.15; }
.attend-grid .reward svg { width: 13px; height: 13px; }
.attend-grid li.big { background: linear-gradient(160deg, #fff7d1, #ffe08d); border-color: #e0a800; }
.attend-grid li.got { background: #f3eaf5; border-color: #d9cce0; }
.attend-grid li.got .reward { opacity: .35; }
.attend-grid li i { position: absolute; inset: 0; display: grid; place-items: center; font-size: 22px; font-style: normal; color: #e5487f; rotate: -12deg; text-shadow: 0 0 4px #fff; }
.attend-grid li.next { border-color: #e5487f; box-shadow: 0 0 0 3px #ffd0e1; animation: breathe .9s ease-in-out infinite; }

/* 공지사항 */
.notice-list { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; list-style: none; max-height: 62dvh; overflow-y: auto; }
.notice-list details { background: #fff; border: 2px solid var(--ink); border-radius: 16px; }
.notice-list summary { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; padding: 8px 12px; cursor: pointer; list-style: none; }
.notice-list summary::-webkit-details-marker { display: none; }
.notice-list summary b { flex: 1; min-width: 60%; font-size: 15px; font-weight: normal; }
.notice-list summary small { flex-basis: 100%; font-size: 11px; color: var(--ink2); }
.notice-list .ver { padding: 0 8px; font-size: 12px; color: #fff; background: #e5487f; border-radius: 99px; }
.notice-list p { margin: 0; padding: 0 12px 10px; font-size: 13px; line-height: 1.6; word-break: keep-all; overflow-wrap: anywhere; user-select: text; -webkit-user-select: text; }

/* 가입 축하 + 사용법 */
.welcome[open] { align-items: center; text-align: center; max-width: 420px; }
.w-art { display: grid; place-items: center; height: 120px; }
.w-art img { height: 120px; max-width: 100%; object-fit: contain; animation: squish var(--beat) ease-in-out infinite; transform-origin: 50% 100%; }
.w-art span { font-size: 72px; animation: hop var(--beat) ease-in-out infinite; }
.w-text { margin: 0; font-size: 15px; line-height: 1.6; word-break: keep-all; }
.w-dots { display: flex; gap: 6px; justify-content: center; }
.w-dots i { width: 8px; height: 8px; background: #e4d9ea; border-radius: 50%; }
.w-dots i.on { width: 22px; background: var(--pink); border-radius: 99px; }
.welcome .row { align-self: stretch; }

/* 팀 꽉 찼을 때 바꾸기 */
.swap-title { margin: -4px 0 0; font-size: 14px; text-align: center; color: var(--ink2); }
.swap-title b { font-weight: normal; color: #e5487f; }
.swap-list { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.swap-list .delta { width: 100%; font-size: 11px; text-align: center; }
.swap-list .delta.up { color: #2e9e6e; }
.swap-list .delta.down { color: #e5487f; }

/* 등급 확정 뽑기 */
.until-pane { display: flex; flex-direction: column; gap: 10px; }
.until-pane .hint b { font-weight: normal; color: #e5487f; }
.until-grade { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 6px; }
.until-grade button { display: flex; flex-direction: column; align-items: center; padding: 6px 4px; color: var(--ink); background: #fff; border: 3px solid var(--rc); border-radius: 16px; box-shadow: 0 3px 0 var(--ink); }
.until-grade button b { font-size: 16px; font-weight: normal; }
.until-grade button small { font-size: 11px; color: var(--ink2); }
.until-grade button[aria-pressed="true"] { color: #fff; background: var(--rc); translate: 0 2px; box-shadow: 0 1px 0 var(--ink); text-shadow: 0 1px 0 rgba(74, 57, 83, .4); }
.until-grade button[aria-pressed="true"] small { color: #fff; }
.until-pane .sortsel { justify-content: center; }
.until-cost { margin: 0; font-size: 14px; line-height: 1.6; text-align: center; }
.until-cost svg { width: 15px; height: 15px; vertical-align: -2px; }
.until-cost small { color: var(--ink2); }
.until-head { margin: 0; font-size: 19px; text-align: center; }
.until-head b { font-weight: normal; color: #e5487f; }
.until-head small { display: block; font-size: 13px; color: var(--ink2); }
.rtxt { padding: 0 8px; color: #fff; background: var(--rc); border-radius: 99px; }
.r5.rtxt { background: linear-gradient(90deg, #ff5d8f, #ffb03a, #4ec3ff, #a66bff); }
.until-hit { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.until-hit:empty { display: none; }
.until-hit .nc-card { position: relative; width: 150px; animation: ncZoom .5s cubic-bezier(.2, 1.4, .4, 1); }
.until-hit b { font-size: 20px; font-weight: normal; }
.until-hit .lbl { padding: 0 8px; font-size: 12px; color: #fff; background: #ff5c8a; border-radius: 99px; }
.until-hit .lbl.up { background: #5fb1f5; }
.until-hit .lbl.gem { background: #8e72e8; }
.until-sum { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; }
.until-sum span { display: inline-flex; align-items: center; gap: 2px; padding: 1px 9px; font-size: 13px; color: #fff; background: var(--rc); border: 2px solid var(--ink); border-radius: 999px; }
.until-sum .gem { color: var(--ink); background: #fff; }
.until-sum svg { width: 14px; height: 14px; }
.until-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 5px; max-height: 30dvh; overflow-y: auto; padding: 2px; }
.ug { position: relative; display: flex; flex-direction: column; align-items: center; padding: 3px 2px; background: var(--rbg); border: 2px solid var(--rc); border-radius: 12px; }
.ug img { width: 38px; height: 38px; }
.ug small { width: 100%; overflow: hidden; font-size: 9px; text-align: center; white-space: nowrap; text-overflow: ellipsis; }
.ug i { position: absolute; top: 1px; right: 3px; font-size: 11px; font-style: normal; color: #e5487f; text-shadow: 0 0 3px #fff; }
.ug em { position: absolute; top: 1px; left: 2px; padding: 0 3px; font-size: 8px; font-style: normal; color: #fff; background: #ff5c8a; border-radius: 99px; }
.pulls { flex-wrap: wrap; }
.pulls .until { flex-basis: 100%; padding: 6px 12px; }
.pulls .until span { font-size: 17px; }
.pulls .until small { font-size: 12px; }

/* 점검 예고 */
.sched[open] { align-items: center; text-align: center; max-width: 400px; }
.sched img { width: 84px; animation: hop 1.2s ease-in-out infinite; }
.sched-when { margin: 0; padding: 6px 14px; font-size: 19px; color: #e5487f; background: #fff3f7; border: 2px dashed #e5487f; border-radius: 14px; }
.sched-msg { margin: 0; font-size: 15px; line-height: 1.6; word-break: keep-all; }
.sched small { font-size: 12px; color: var(--ink2); }
.sched form { display: flex; align-self: stretch; }
.sched form .btn { flex: 1; }
.sched-bar { position: absolute; top: 0; left: 50%; z-index: 44; max-width: 92%; margin: 0; padding: 2px 12px; overflow: hidden; font-size: 12px; color: #fff; white-space: nowrap; text-overflow: ellipsis; background: #ff9d1c; border: 0; border-radius: 0 0 10px 10px; translate: -50% 0; }
#maintHint { font-size: 12px; }
#app:has(#schedBar:not([hidden])) #topbar, #app:has(#maintBar:not([hidden])) #topbar { padding-top: calc(env(safe-area-inset-top) + 24px); } /* 띠가 코인 칸을 가리지 않게 */

/* 메뉴 탭: 조금 더 크게 */
#nav { padding: 6px 6px calc(env(safe-area-inset-bottom) + 6px); }
#nav button { gap: 3px; padding: 6px 0; font-size: 13px; border-radius: 14px; }
#nav button svg { width: 27px; height: 27px; }
@media (orientation: landscape) and (min-width: 640px) {
  :root { --nav: 200px; }
  #nav { gap: 6px; padding: calc(env(safe-area-inset-top) + 14px) 12px 14px calc(env(safe-area-inset-left) + 12px); }
  #nav button { gap: 12px; padding: 11px 14px; font-size: 19px; }
  #nav button svg { width: 28px; height: 28px; }
}
@media (orientation: landscape) and (min-width: 640px) and (max-height: 540px) {
  :root { --nav: 86px; }
  #nav { gap: 2px; padding: 6px; }
  #nav button { gap: 1px; padding: 5px 2px; font-size: 12px; }
  #nav button svg { width: 26px; height: 26px; }
}

/* 진화: 지금 → 진화 후 · 성공 확률 원 그래프 · 재료 +/− */
.evo-flow { display: flex; align-items: center; justify-content: center; gap: 10px; }
.evo-flow > div { position: relative; width: 92px; aspect-ratio: 3 / 4; overflow: hidden; background: var(--rbg); border: 3px solid var(--ink); border-radius: 16px; }
.evo-flow > div img { width: 100%; height: 100%; object-fit: cover; }
.evo-flow > div > span { position: absolute; left: 0; right: 0; bottom: 0; padding: 1px 0; font-size: 12px; text-align: center; background: rgba(255, 255, 255, .85); }
.evo-from { filter: saturate(.75); }
.evo-to.e1 { box-shadow: 0 0 14px 3px #b9e4ff; }
.evo-to.e2 { box-shadow: 0 0 18px 5px #ffd25e; }
.evo-to.e3 { box-shadow: 0 0 22px 7px #ff9ed2; animation: evoGlow 2.4s linear infinite; }
.evo-arrow { font-size: 28px; color: #e5487f; animation: nudge 1s ease-in-out infinite; }
@keyframes nudge { 50% { translate: 4px 0; } }
.evo-name { margin: 0; text-align: center; font-size: 18px; }
.evo-name b { font-weight: normal; color: #e5487f; }
.evo-stats { display: grid; gap: 3px; margin: 0; padding: 8px 10px; list-style: none; font-size: 13px; background: #fff; border: 2px solid var(--ink); border-radius: 14px; }
.evo-stats li { display: flex; align-items: center; gap: 6px; }
.evo-stats span { min-width: 64px; color: var(--ink2); }
.evo-stats i { font-style: normal; color: var(--ink2); }
.evo-stats b { font-weight: normal; color: #e5487f; }
.evo-rate { display: flex; align-items: center; gap: 12px; padding: 8px 10px; background: linear-gradient(120deg, #fff, #fff3f8); border: 2px solid var(--ink); border-radius: 16px; }
.evo-rate .ring { flex: none; display: grid; place-content: center; width: 78px; height: 78px; text-align: center; border-radius: 50%;
  background: radial-gradient(closest-side, #fff 76%, transparent 78%), conic-gradient(#ff5c8a calc(var(--p) * 1%), #efe4f3 0); }
.evo-rate .ring b { font-size: 22px; font-weight: normal; line-height: 1; color: #e5487f; }
.evo-rate .ring small { font-size: 10px; color: var(--ink2); }
.evo-rate p { margin: 0 0 2px; font-size: 14px; }
.evo-rate em { font-style: normal; color: #2e9e6e; }
.evo-rate small { font-size: 11px; line-height: 1.4; color: var(--ink2); }
.mats-head { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; flex-wrap: wrap; }
.mats-head b { font-size: 15px; font-weight: normal; }
.mats-head small { font-size: 11px; color: var(--ink2); }
.mats { grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); max-height: 230px; }
.mat { padding: 4px 3px; }
.mat .pic { position: relative; padding: 0; background: none; border: 0; }
.mat .step { display: flex; align-items: center; justify-content: space-between; width: 100%; }
.mat .step button { width: 24px; height: 24px; padding: 0; font-size: 16px; line-height: 1; background: #fff; border: 2px solid var(--ink); border-radius: 50%; }
.mat .step button:disabled { opacity: .35; }
.mat .step b { font-size: 12px; font-weight: normal; font-variant-numeric: tabular-nums; }
.mat.on .step b { color: #e5487f; }
.evo-tools { display: flex; gap: 6px; }
.evo-tools .btn { flex: 1; padding: 5px 4px; font-size: 13px; }
.evo-go { flex-direction: column; gap: 0; }
.evo-go small { font-size: 12px; opacity: .9; }

/* 진화 연출 창 */
dialog.evo-fx { width: min(88vw, 320px); margin: auto; padding: 22px 16px; overflow: visible; text-align: center; color: #fff; background: radial-gradient(circle at 50% 40%, #6b4fa3, #241a3d 80%); border: 3px solid #fff; border-radius: 28px; box-shadow: 0 6px 0 var(--ink); }
dialog.evo-fx[open] { align-items: center; animation: popIn .3s cubic-bezier(.3, 1.4, .5, 1); }
.ef-card { position: relative; width: 150px; aspect-ratio: 3 / 4; overflow: hidden; background: var(--rbg); border: 4px solid #fff; border-radius: 20px; }
.ef-card img { width: 100%; height: 100%; object-fit: cover; }
.ef-card .evo { position: absolute; left: 0; right: 0; bottom: 4px; font-size: 22px; }
.ef-msg { margin: 0; font-size: 20px; line-height: 1.4; }
.ef-msg b { display: block; font-weight: normal; color: #ffe08d; }
.ef-msg small { display: block; margin-top: 2px; font-size: 12px; color: #e6dcff; }
.evo-fx.charging .ef-card { animation: shake .18s infinite, chargeGlow 1.6s ease-in forwards; }
@keyframes chargeGlow { from { box-shadow: 0 0 0 0 #fff; filter: brightness(1); } to { box-shadow: 0 0 40px 18px #fff; filter: brightness(2.2); } }
.evo-fx.ok .ef-card { animation: evoBurst .7s cubic-bezier(.2, 1.4, .4, 1); box-shadow: 0 0 30px 10px #ffe08d, 0 0 60px 20px #ff9ed2; }
@keyframes evoBurst { from { scale: 1.4; filter: brightness(3); } }
.evo-fx.fail .ef-card { animation: evoFail .6s ease-out; filter: grayscale(.8) brightness(.8); }
.evo-fx.fail .ef-card::after { content: ''; position: absolute; inset: 0; background: linear-gradient(115deg, transparent 46%, #fff 47%, transparent 49%), linear-gradient(65deg, transparent 52%, #fff 53%, transparent 55%); }
@keyframes evoFail { 20% { translate: -8px 0; } 40% { translate: 8px 0; } 60% { translate: -5px 0; } 80% { translate: 4px 0; } }
.evo-fx.fail .ef-msg { color: #ffd0dc; }

/* 상점 환전 */
.item .own.out { color: var(--ink2); }
.item .soldout { width: 100%; margin-top: auto; opacity: .6; cursor: default; }

/* 랭킹: 제목 · 내 순위 카드 · 1~3위 시상대 · 4위부터 목록 */
.rank-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rank-title b { font-size: 18px; font-weight: normal; }
.rank-title small { font-size: 12px; color: var(--ink2); }
.rank-title .tag { color: #fff; background: var(--dc); }
.my-rank { align-items: center; gap: 12px; padding: 8px 14px; background: linear-gradient(120deg, #fff, #ffe9f2); border-style: solid; }
.mr-pos { display: flex; flex-direction: column; align-items: center; line-height: 1; }
.mr-pos small { font-size: 11px; color: var(--ink2); }
.mr-pos b { font-size: 34px; color: #e5487f; font-variant-numeric: tabular-nums; }
.mr-pos i { font-size: 15px; font-style: normal; }
.mr-info { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.mr-score { font-size: 18px; font-variant-numeric: tabular-nums; }
.mr-info small { font-size: 12px; color: var(--ink2); }
.mr-goal b { font-weight: normal; color: #e5487f; }
.mr-none { margin: 0; font-size: 14px; color: var(--ink2); }
.podium { display: grid; grid-template-columns: repeat(3, 1fr); align-items: end; gap: 6px; padding: 4px 4px 0; }
.podium:empty { display: none; }
.pod { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0; }
.pod .medal { font-size: 26px; line-height: 1; }
.pod img { width: 54px; height: 54px; object-fit: cover; background: #fff; border: 3px solid var(--ink); border-radius: 50%; }
.pod.p1 img { width: 70px; height: 70px; border-color: #e0a800; box-shadow: 0 0 14px rgba(255, 196, 0, .8); }
.pod .nm { max-width: 100%; overflow: hidden; font-size: 14px; font-weight: normal; white-space: nowrap; text-overflow: ellipsis; }
.pod .sc { font-size: 13px; color: #e5487f; font-variant-numeric: tabular-nums; }
.pod .base { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 100%; margin-top: 2px; font-size: 22px; color: #fff;
  background: linear-gradient(#ffd0e1, #ff9ec4); border: 3px solid var(--ink); border-bottom: 0; border-radius: 14px 14px 0 0; -webkit-text-stroke: 4px var(--ink); paint-order: stroke fill; }
.pod .base small { font-size: 12px; -webkit-text-stroke: 3px var(--ink); }
.pod.p1 .base { height: 64px; background: linear-gradient(#fff0a8, #ffc23d); }
.pod.p2 .base { height: 46px; background: linear-gradient(#f4f6fb, #c9cfdf); }
.pod.p3 .base { height: 34px; background: linear-gradient(#ffe2c7, #f0a66b); }
.pod.me .nm { color: #e5487f; }
.podium + .ranklist { margin-top: -8px; padding-top: 8px; border-top: 3px solid var(--ink); }
.ranklist li:nth-child(odd):not(.me):not(.empty) { background: #fff; }
.ranklist li.me { background: #ffe3ee; border-color: #e5487f; }
.ranklist .sc { margin-left: auto; }
.ranklist.compact li:nth-child(1)::before { content: '🥇'; background: none; border: 0; font-size: 18px; }
.ranklist.compact li:nth-child(2)::before { content: '🥈'; background: none; border: 0; font-size: 18px; }
.ranklist.compact li:nth-child(3)::before { content: '🥉'; background: none; border: 0; font-size: 18px; }

/* 우편 지우기 */
.mail-top { gap: 6px; }
.mail-top small { flex: 1; }
#mailClean.sure { color: #fff; background: #e5487f; }
.mact { display: flex; align-items: center; gap: 4px; }
.mail .del { display: grid; place-items: center; width: 32px; height: 32px; padding: 0; color: var(--ink2); background: #fff; border: 2px solid #e4d9ea; border-radius: 50%; }
.mail .del svg { width: 17px; height: 17px; }
.mail .del:hover { color: #e5487f; border-color: #e5487f; }

@media (max-width: 560px) {
  .swap-list { gap: 5px; }
  .attend-grid li { min-height: 48px; }
}

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