* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%;
  height: 100%;
  height: var(--app-h, 100%);
  overflow: hidden;
  background: #f6e7c8;
  background: radial-gradient(circle at 50% 30%, #fff6dc 0%, #f3dfb6 60%, #e8cf9f 100%);
  font-family: "Jua", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
  color: #4a2f1c;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  overscroll-behavior: none;
  font-synthesis: none;
}

/* 세로형 모바일 비율 기준. PC에서는 가운데 세로 프레임으로 표시 */
#stage {
  position: relative;
  margin: 0 auto;
  width: 100vw;
  height: 100vh;
  height: var(--app-h, 100dvh);
  max-width: calc(var(--app-h, 100vh) * 0.5625);
  overflow: hidden;
  background: #cfe7f7 url("assets/bg.jpg") center center / cover no-repeat;
}
@media (min-aspect-ratio: 3/4) {
  #stage { box-shadow: 0 0 40px rgba(90, 60, 20, .25); }
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;   /* 입력은 아래 방향키가 받음 */
  z-index: 2;
}

/* ───────── HUD ───────── */
#hud {
  position: absolute;
  z-index: 5;
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 12px 0;
  pointer-events: none;
}
#lives {
  display: flex;
  gap: 2px;
  font-size: 20px;
  background: rgba(255, 255, 255, .55);
  border-radius: 999px;
  padding: 3px 10px 4px;
  min-height: 32px;
  align-items: center;
}
#lives .heart { display: inline-flex; width: 21px; height: 20px; transition: transform .2s; }
#lives .heart.lost { transform: scale(.82); }
#lives .heart.pop { animation: heartPop .5s ease-out; }
@keyframes heartPop {
  0% { transform: scale(1.6) rotate(-12deg); }
  60% { transform: scale(.7) rotate(6deg); }
  100% { transform: scale(.82); }
}
#score {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: .5px;
  background: rgba(255, 255, 255, .55);
  border-radius: 999px;
  padding: 6px 12px;
}
#score b { font-size: 17px; font-variant-numeric: tabular-nums; color: #e0567a; }
#score.bump b { animation: bump .2s ease-out; display: inline-block; }
@keyframes bump { 50% { transform: scale(1.25); } }

#combo {
  position: absolute;
  z-index: 5;
  left: 0; right: 0;
  top: 25%;
  text-align: center;
  font-size: 30px;
  font-weight: 900;
  color: #ff6a8c;
  -webkit-text-stroke: 2px #fff;
  paint-order: stroke fill;
  text-shadow: 0 3px 0 rgba(160, 60, 80, .35);
  pointer-events: none;
  opacity: 0;
}
#combo.show { animation: comboShow .9s ease-out forwards; }
@keyframes comboShow {
  0%   { opacity: 0; transform: scale(.4) translateY(10px); }
  20%  { opacity: 1; transform: scale(1.15) translateY(0); }
  35%  { transform: scale(1); }
  80%  { opacity: 1; }
  100% { opacity: 0; transform: translateY(-14px); }
}

/* ───────── 방향키 ───────── */
#dpad {
  --b: min(19vw, 78px, calc(var(--app-h, 100vh) * 0.095));
  position: absolute;
  z-index: 1;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 10px);
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(3, var(--b));
  grid-template-rows: repeat(2, var(--b));
  gap: 6px;
  grid-template-areas:
    ".    up   ."
    "left down right";
  touch-action: none;
}
.dir {
  width: 100%;
  height: 100%;
  border: 2px solid rgba(255, 255, 255, .75);
  border-radius: 22px;
  background: rgba(255, 255, 255, .45);
  color: rgba(110, 70, 40, .85);
  font-size: calc(var(--b) * .34);
  font-family: inherit;
  cursor: pointer;
  touch-action: none;
  box-shadow: 0 3px 0 rgba(120, 80, 40, .18);
  transition: transform .06s, background .06s;
  -webkit-appearance: none;
  appearance: none;
  outline: none;
}
.dir.up { grid-area: up; }
.dir.left { grid-area: left; }
.dir.down { grid-area: down; }
.dir.right { grid-area: right; }
.dir.pressed {
  background: rgba(255, 220, 120, .7);
  transform: translateY(2px) scale(.95);
  box-shadow: 0 1px 0 rgba(120, 80, 40, .18);
}
@media (hover: hover) and (pointer: fine) {
  #dpad { --b: min(64px, calc(var(--app-h, 100vh) * 0.08)); opacity: .85; }
}

/* ───────── 오버레이 공통 ───────── */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
}
.overlay.hidden { display: none; }


.panel {
  position: relative;
  background: rgba(255, 252, 240, .9);
  border: 3px solid #5a3a22;
  border-radius: 26px;
  padding: 20px 26px 22px;
  text-align: center;
  box-shadow: 0 6px 0 rgba(90, 58, 34, .35);
  min-width: 230px;
}

.rule { font-size: 16px; margin: 4px 0; font-weight: 700; }
.rule b { color: #e0567a; }

.btn {
  margin-top: 14px;
  font-family: inherit;
  font-size: 20px;
  font-weight: 900;
  color: #fff;
  background: #ff8aa5;
  border: 3px solid #5a3a22;
  border-radius: 999px;
  padding: 10px 30px;
  box-shadow: 0 4px 0 #5a3a22;
  cursor: pointer;
  letter-spacing: 1px;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #5a3a22; }
.btn:disabled { background: #ccb; cursor: default; }

.sound-btn {
  position: absolute;
  z-index: 2;
  right: 14px;
  top: calc(env(safe-area-inset-top, 0px) + 12px);
  padding: 6px 12px;
  border-radius: 999px;
  border: 2px solid #5a3a22;
  background: rgba(255, 255, 255, .9);
  color: #5a3a22;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
}
.sound-btn.off { color: #a08a7a; background: rgba(255, 255, 255, .7); }

#countdown span {
  font-size: 84px;
  font-weight: 900;
  color: #fff;
  -webkit-text-stroke: 4px #5a3a22;
  paint-order: stroke fill;
  text-shadow: 0 6px 0 rgba(90, 58, 34, .35);
  transform: translateY(-24vh);
}
#countdown span.tick { animation: tick .8s ease-out; }
#countdown span.go { font-size: 60px; color: #ff8aa5; }
@keyframes tick {
  0% { transform: translateY(-24vh) scale(1.8); opacity: 0; }
  25% { transform: translateY(-24vh) scale(1); opacity: 1; }
  100% { transform: translateY(-24vh) scale(.9); opacity: .9; }
}

#gameOver { background: rgba(60, 40, 20, .35); }
#gameOver .panel { animation: popIn .35s cubic-bezier(.2, 1.6, .5, 1); }
@keyframes popIn { from { transform: scale(.6); opacity: 0; } }
h2 { font-size: 32px; font-weight: 900; color: #5a3a22; margin-bottom: 10px; }
.go-label { font-size: 13px; font-weight: 800; letter-spacing: 2px; opacity: .6; margin-top: 6px; }
.go-score { font-size: 38px; font-weight: 900; color: #e0567a; font-variant-numeric: tabular-nums; }
.go-best { font-size: 24px; font-weight: 900; font-variant-numeric: tabular-nums; }
.new-best { margin-top: 4px; color: #ff9f1a; font-weight: 900; animation: bump .6s infinite; }
.new-best.hidden { display: none; }

/* 피격 화면 흔들림 */
#stage.shake { animation: shake .35s linear; }
@keyframes shake {
  0%, 100% { transform: translate(0, 0); }
  15% { transform: translate(-8px, 3px); }
  30% { transform: translate(7px, -4px); }
  45% { transform: translate(-6px, -2px); }
  60% { transform: translate(5px, 3px); }
  75% { transform: translate(-3px, 1px); }
  90% { transform: translate(2px, -1px); }
}

/* ───────── 닉네임 ───────── */
.nick-label {
  display: block;
  margin-top: 12px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 1px;
  opacity: .7;
}
.nick-input {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 9px 12px;
  font-family: inherit;
  font-size: 16px;            /* iOS 확대 방지 */
  font-weight: 700;
  text-align: center;
  color: #4a2f1c;
  background: #fff;
  border: 2.5px solid #5a3a22;
  border-radius: 14px;
  outline: none;
  -webkit-user-select: text;
  user-select: text;
}
.nick-input:focus { border-color: #ff8aa5; box-shadow: 0 0 0 3px rgba(255, 138, 165, .3); }
.nick-input.invalid { border-color: #e0567a; animation: nickShake .3s; }
@keyframes nickShake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.nick-error { margin-top: 4px; font-size: 12px; font-weight: 700; color: #e0567a; }


.btn-sub {
  margin-top: 8px !important;
  font-size: 16px;
  padding: 8px 20px;
  color: #5a3a22;
  background: #fff3c4;
  box-shadow: 0 3px 0 #5a3a22;
}

/* ───────── 게임방법 ───────── */
#howto { background: rgba(60, 40, 20, .45); z-index: 20; padding: calc(env(safe-area-inset-top, 0px) + 20px) 18px calc(env(safe-area-inset-bottom, 0px) + 16px); }
.howto-wrap {
  position: relative;
  width: min(370px, 100%);
  max-height: 100%;
  display: flex;
}
.howto-x {
  position: absolute;
  z-index: 2;
  top: -8px;
  right: -8px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 2.5px solid #5a3a22;
  background: #fff;
  box-shadow: 0 3px 0 #5a3a22;
  display: grid;
  place-items: center;
  cursor: pointer;
  touch-action: manipulation;
}
.howto-x svg { width: 16px; height: 16px; }
.howto-x path { stroke: #5a3a22; stroke-width: 3; stroke-linecap: round; fill: none; }
.howto-x:active { transform: translateY(2px); box-shadow: 0 1px 0 #5a3a22; }
.howto-x:focus-visible { outline: 3px solid #ff8aa5; outline-offset: 2px; }
.howto-panel {
  width: 100%;
  max-height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  text-align: left;
  padding: 16px 16px 18px;
  background: #fffaf0;
  border-radius: 28px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: popIn .25s cubic-bezier(.2, 1.6, .5, 1);
}
.howto-top { display: flex; align-items: center; gap: 6px; }
.howto-usagi { width: 74px; height: 74px; object-fit: contain; flex: none; margin: -6px -4px -6px -8px; }
.howto-panel h2 { font-size: 26px; margin: 0; color: #e0567a; }
.howto-lead { font-size: 13.5px; line-height: 1.45; color: #6b4a33; }

.rule-card {
  position: relative;
  border-radius: 20px;
  padding: 12px 12px 10px;
  border: 2.5px solid;
}
.rule-card.good { background: #eef8e6; border-color: #a8d48f; }
.rule-card.bad  { background: #fff0ea; border-color: #f3ad97; }
.rule-tag {
  display: inline-block;
  font-size: 13px;
  padding: 3px 10px 4px;
  border-radius: 999px;
  color: #fff;
  letter-spacing: .3px;
}
.good .rule-tag { background: #7cbf5e; }
.bad  .rule-tag { background: #ef8a6c; }
.rule-do { margin-top: 6px; font-size: 17px; color: #4a2f1c; }
.rule-do em { font-style: normal; color: #e0567a; background: linear-gradient(transparent 60%, #ffe28a 60%); padding: 0 2px; }
.howto-items {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
  margin: 8px 0;
  padding: 6px;
  background: rgba(255, 255, 255, .75);
  border-radius: 14px;
}
.howto-items img { width: 100%; aspect-ratio: 1; height: auto; object-fit: contain; max-width: 100%; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-size: 12.5px;
  padding: 4px 10px 5px;
  border-radius: 999px;
  background: #fff;
  border: 1.5px solid currentColor;
}
.chip-plus { color: #e0567a; }
.chip-minus { color: #5b7bd5; }
.chip-heart { color: #c2410c; }

.dir-demo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin: 2px 0 2px;
}
.dir-demo img { width: 44px; height: 44px; object-fit: contain; }
.dir-demo img:last-of-type { animation: demoFly 1.6s ease-in infinite; }
.dir-trail { width: 34px; border-top: 3px dotted #ef8a6c; }
.dir-eq { font-size: 18px; color: #b07a5a; margin: 0 4px; }
.dir-key {
  width: 38px; height: 38px;
  border-radius: 12px;
  display: grid; place-items: center;
  font-size: 15px;
  color: #5a3a22;
  background: #ffe28a;
  border: 2px solid #5a3a22;
  box-shadow: 0 3px 0 #5a3a22;
  animation: keyPress 1.6s ease-in-out infinite;
}
@keyframes demoFly { 0% { transform: translateX(14px); } 70% { transform: translateX(-10px); } 100% { transform: translateX(14px); } }
@keyframes keyPress { 0%, 60%, 100% { transform: none; box-shadow: 0 3px 0 #5a3a22; } 70% { transform: translateY(3px); box-shadow: 0 0 0 #5a3a22; } }
.dir-caption { text-align: center; font-size: 12.5px; color: #8a5a3a; margin-bottom: 8px; }

.howto-tips {
  list-style: none;
  display: grid;
  gap: 6px;
  font-size: 13.5px;
  color: #5a3a22;
  padding: 2px 4px;
}
.howto-tips li { display: flex; align-items: center; gap: 8px; }
.tip-ico {
  flex: none;
  width: 26px; height: 26px;
  display: grid; place-items: center;
  font-size: 13px;
  background: #fff;
  border: 1.5px solid #e8d6bb;
  border-radius: 50%;
}
.pc-only { display: none !important; }
@media (hover: hover) and (pointer: fine) { .pc-only { display: flex !important; } }
.howto-panel .btn { display: block; margin: 4px auto 0; }
@media (prefers-reduced-motion: reduce) { .dir-demo img, .dir-key { animation: none; } }

.go-nick { font-size: 16px; font-weight: 800; margin-top: -4px; margin-bottom: 4px; color: #8a5a3a; }
.go-nick:empty { display: none; }

/* ───────── 홈 화면 ───────── */
#stage[data-screen="home"] #hud,
#stage[data-screen="home"] #dpad,
#stage[data-screen="home"] #combo { display: none; }

#startScreen {
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: calc(env(safe-area-inset-top, 0px) + 10vh) 16px calc(env(safe-area-inset-bottom, 0px) + 4vh);
  background: linear-gradient(to bottom, rgba(255, 255, 255, .35), rgba(255, 255, 255, 0) 30%);
}
.home-title { text-align: center; animation: titleIn .6s cubic-bezier(.2, 1.4, .5, 1); }
.home-title h1 {
  font-size: clamp(40px, 12vw, 54px);
  line-height: 1.05;
  font-weight: 900;
  color: #ff7c98;
  -webkit-text-stroke: 7px #5a3a22;
  paint-order: stroke fill;
  text-shadow: 0 5px 0 rgba(90, 58, 34, .35);
  letter-spacing: 1px;
}
.home-sub {
  display: inline-block;
  margin-bottom: 10px;
  padding: 5px 14px;
  font-size: 13px;
  font-weight: 800;
  background: rgba(255, 255, 255, .8);
  border: 2px solid #5a3a22;
  border-radius: 999px;
}
@keyframes titleIn { from { transform: translateY(-20px) scale(.9); opacity: 0; } }

.home-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: min(320px, 100%);
  padding: 14px 20px 14px;
  background: rgba(255, 252, 240, .92);
}
.home-card .nick-label { margin-top: 0; }
.home-card .btn { margin-top: 12px; }
.home-best { margin-top: 10px; text-align: center; font-size: 13px; font-weight: 800; opacity: .7; }
.home-best:empty { display: none; }

/* ───────── 일시정지 ───────── */
.hud-right { display: flex; align-items: center; gap: 8px; }
.pause-btn {
  pointer-events: auto;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid rgba(90, 58, 34, .55);
  background: rgba(255, 255, 255, .7);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  touch-action: manipulation;
}
.pause-btn span { width: 4px; height: 13px; border-radius: 2px; background: #5a3a22; }
.pause-btn:active { transform: scale(.92); }
#stage[data-screen="over"] .pause-btn { visibility: hidden; }

#pauseScreen { background: rgba(60, 40, 20, .4); z-index: 15; }
.pause-panel { display: flex; flex-direction: column; align-items: stretch; width: min(280px, 84vw); animation: popIn .25s cubic-bezier(.2, 1.6, .5, 1); }
.pause-panel h2 { margin-bottom: 0; }
.pause-sub { font-size: 14px; font-weight: 800; opacity: .65; margin-bottom: 4px; }
.btn-row { display: flex; gap: 8px; margin-top: 10px; }
.btn-row .btn { flex: 1; margin-top: 0 !important; padding-left: 10px; padding-right: 10px; white-space: nowrap; }
#gameOver .btn-row { margin-top: 14px; }
#gameOver .btn-row .btn { font-size: 17px; }
.pause-panel .btn-row .btn { font-size: 16px; }

/* ───────── 핑크 하트 ───────── */
.heart svg, .heart-ico svg { width: 100%; height: 100%; display: block; overflow: visible; }
.h-body { fill: #ff8fb1; stroke: #5a3a22; stroke-width: 1.8; stroke-linejoin: round; }
.h-shine { fill: none; stroke: #fff; stroke-width: 1.8; stroke-linecap: round; opacity: .9; }
.h-dot { fill: #fff; opacity: .9; }
.heart.lost .h-body { fill: #efe4e7; stroke: #c9b7bc; }
.heart.lost .h-shine, .heart.lost .h-dot { opacity: 0; }
.heart-ico { display: inline-block; width: 1.1em; height: 1em; vertical-align: -0.15em; }
.tip-ico .heart-ico { width: 15px; height: 14px; vertical-align: 0; }
#lives { gap: 3px; padding: 5px 10px; }
button:focus:not(:focus-visible) { outline: none; }
.btn:focus-visible { outline: 3px solid #ff8aa5; outline-offset: 3px; }

/* ───────── 점수 공유 ───────── */
.btn-share {
  display: block;
  width: 100%;
  margin-top: 14px;
  font-size: 17px;
  background: linear-gradient(135deg, #ffb36b, #ff7c98 55%, #c86bff);
}
#gameOver .btn-share + .btn-row { margin-top: 10px; }

#shareScreen { background: rgba(60, 40, 20, .5); z-index: 25; padding: calc(env(safe-area-inset-top, 0px) + 20px) 18px calc(env(safe-area-inset-bottom, 0px) + 16px); }
.share-wrap { position: relative; width: min(340px, 100%); max-height: 100%; display: flex; }
.share-panel {
  width: 100%;
  max-height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  padding: 16px 18px 16px;
  background: #fffaf0;
  border-radius: 28px;
  animation: popIn .25s cubic-bezier(.2, 1.6, .5, 1);
}
.share-panel h2 { text-align: center; color: #e0567a; font-size: 24px; margin: 0; }
.share-sub { text-align: center; font-size: 13px; color: #8a5a3a; margin-top: -6px; }
.share-preview {
  position: relative;
  align-self: center;
  width: min(62%, 210px);
  aspect-ratio: 9 / 16;
  max-width: 100%;
  border-radius: 16px;
  overflow: hidden;
  border: 3px solid #5a3a22;
  box-shadow: 0 5px 0 rgba(90, 58, 34, .3);
  background: #f3e6cf;
}
.share-preview img { width: 100%; height: 100%; object-fit: cover; display: block; -webkit-touch-callout: default; -webkit-user-select: auto; user-select: auto; }
.share-preview img:not([src]) { visibility: hidden; }
.share-loading { position: absolute; inset: 0; display: grid; place-items: center; font-size: 14px; color: #8a5a3a; }
.share-loading[hidden] { display: none; }
.share-panel .btn { margin-top: 0; display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 17px; padding: 11px 16px; }
.share-panel .share-btn { font-size: 15px; padding: 10px 14px; color: #5a3a22; background: #fff; box-shadow: 0 3px 0 #5a3a22; letter-spacing: 0; }
.share-hint { font-size: 12.5px; line-height: 1.5; text-align: center; color: #8a5a3a; }
.share-hint b { color: #d62976; }

.toast {
  position: absolute;
  z-index: 40;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 28px);
  transform: translate(-50%, 20px);
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(60, 40, 20, .92);
  color: #fff;
  font-size: 14px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* 홈: 게임방법 | 개발자 인스타 */
.home-row { display: flex; gap: 8px; margin-top: 8px; }
.home-row .btn { flex: 1; margin-top: 0 !important; padding: 8px 6px; font-size: 15px; white-space: nowrap; text-decoration: none; display: flex; align-items: center; justify-content: center; gap: 5px; }
.btn-insta { background: #fff0f6; }

/* ───────── 랭킹 ───────── */
.home-row .btn { font-size: 14px; padding: 8px 4px; }
.btn-rank { background: #eef6ff; }
#gameOver .btn-row .btn { font-size: 15px; padding-left: 6px; padding-right: 6px; }
.go-rank { margin-top: 6px; font-size: 14px; color: #8a5a3a; min-height: 1.4em; }
.go-rank b { color: #e0567a; font-size: 17px; }

#rankScreen { background: rgba(60, 40, 20, .5); z-index: 25; padding: calc(env(safe-area-inset-top, 0px) + 20px) 18px calc(env(safe-area-inset-bottom, 0px) + 16px); }
.rank-panel {
  width: 100%;
  max-height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 16px 18px;
  background: #fffaf0;
  border-radius: 28px;
  animation: popIn .25s cubic-bezier(.2, 1.6, .5, 1);
}
.rank-panel h2 { text-align: center; color: #e0567a; font-size: 24px; margin: 0; }
.rank-list { list-style: none; display: grid; gap: 6px; }
.rank-list li {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 14px;
  background: #fff;
  border: 2px solid #f0e2c8;
  font-size: 15px;
}
.rank-list li.me { border-color: #ff8aa5; background: #fff4f7; }
.rank-no {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border-radius: 50%;
  font-size: 14px;
  color: #8a5a3a;
  background: #f6ecdc;
}
.rank-list li:nth-child(1) .rank-no { background: #ffd54a; color: #5a3a22; }
.rank-list li:nth-child(2) .rank-no { background: #dfe3ea; color: #5a3a22; }
.rank-list li:nth-child(3) .rank-no { background: #f0b98a; color: #5a3a22; }
.rank-nick { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #4a2f1c; }
.rank-score { font-variant-numeric: tabular-nums; color: #e0567a; }
.rank-empty, .rank-msg { text-align: center; font-size: 14px; color: #8a5a3a; padding: 18px 0; }
.rank-me { text-align: center; font-size: 13.5px; color: #8a5a3a; }
.rank-me:empty { display: none; }
.rank-me b { color: #e0567a; }
#gameOver .panel { width: min(310px, 86vw); }
.rank-list li { text-align: left; }
/* 안내 문구(빈 랭킹·불러오는 중)는 한 줄 전체 사용 */
.rank-list li.rank-empty, .rank-list li.rank-msg {
  display: block;
  text-align: center;
  line-height: 1.5;
  padding: 22px 16px;
  word-break: keep-all;
}

/* 내 주변 순위 */
.rank-list li { grid-template-columns: minmax(28px, auto) 1fr auto; }
.rank-no { width: auto; min-width: 28px; padding: 0 7px; border-radius: 14px; font-variant-numeric: tabular-nums; }
.rank-list li.rank-gap, .rank-list li.rank-label {
  display: block;
  padding: 0;
  border: 0;
  background: none;
  text-align: center;
  color: #b8a48f;
}
.rank-list li.rank-gap { font-size: 18px; line-height: 1; }
.rank-list li.rank-label { font-size: 12.5px; color: #8a5a3a; margin-top: 2px; }
/* 주변 순위의 1·2·3번째 줄은 금/은/동 색을 쓰지 않게 */
.rank-list li.rank-label ~ li .rank-no { background: #f6ecdc; color: #8a5a3a; }
.rank-list li.rank-label ~ li.me .rank-no { background: #ff8aa5; color: #fff; }
.rank-list li.me .rank-no { background: #ff8aa5; color: #fff; }
.rank-list { gap: 5px; }
.rank-list li { padding: 6px 12px; }

/* 랭킹 창: 세로를 줄이고 목록만 스크롤 */
.rank-panel { max-height: min(60vh, 500px); overflow: hidden; }
.rank-list { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 2px 2px 4px; scroll-padding: 8px; }
.rank-list li { grid-template-columns: minmax(28px, auto) 1fr auto; gap: 10px; }

/* GAME OVER 순위 글씨색 */
.go-rank b { font-size: 17px; }
.go-rank b.rank-top10 { color: #e0567a; }
.go-rank b.rank-out { color: #e8a200; -webkit-text-stroke: .4px #b07a00; }
