/* 윤영이의 응원 자판기 — 밤 골목, 혼자 불 켜진 자판기 */

:root {
  --night-0: #080a12;
  --night-1: #10131d;
  --floor: #0a0b0f;
  --amber: #ffb000;
  --cream: #fff8e7;
  --ink: #2a2118;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --font: system-ui, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "Noto Sans CJK KR", "Malgun Gothic", "Segoe UI", sans-serif;
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .42 0 0 0 0 .32 0 0 0 0 .18 0 0 0 .07 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  background: var(--night-0);
  color-scheme: dark;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  overscroll-behavior: none;
  overflow-x: hidden;
  font-family: var(--font);
  color: #e9edf6;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

body.modal-open {
  overflow: hidden;
}

button {
  font: inherit;
  color: inherit;
  -webkit-user-select: none;
  user-select: none;
}

:focus-visible {
  outline: 3px solid var(--amber);
  outline-offset: 3px;
}

:focus:not(:focus-visible) {
  outline: none;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.svg-defs {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

/* ───────── 밤 장면 ───────── */

.wall {
  position: fixed;
  inset: 0 0 14vh 0;
  background: linear-gradient(180deg, var(--night-0), var(--night-1));
}

.wall::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(180deg, transparent 0 63px, rgba(255, 255, 255, 0.04) 63px 64px),
    repeating-linear-gradient(90deg, transparent 0 127px, rgba(255, 255, 255, 0.04) 127px 128px);
  -webkit-mask-image: radial-gradient(ellipse 60% 75% at 50% 60%, #000 25%, transparent 85%);
  mask-image: radial-gradient(ellipse 60% 75% at 50% 60%, #000 25%, transparent 85%);
}

.floor {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 14vh;
  background: var(--floor);
  box-shadow: 0 -1px 0 rgba(255, 255, 255, 0.035);
}

.stage {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: calc(8px + var(--safe-t)) calc(8px + var(--safe-r)) calc(8px + var(--safe-b)) calc(8px + var(--safe-l));
  overflow: clip;
}

/* ───────── 자판기 (내부 치수는 전부 cqw) ───────── */

.machine {
  --W: min(calc(100vw - 16px), calc((100vh - 16px - var(--safe-t) - var(--safe-b)) / 2), 520px);
  position: relative;
  width: max(288px, var(--W));
  aspect-ratio: 1 / 2;
  container-type: inline-size;
}

@supports (height: 100dvh) {
  .machine {
    --W: min(calc(100vw - 16px), calc((100dvh - 16px - var(--safe-t) - var(--safe-b)) / 2), 520px);
  }
}

.halo {
  position: absolute;
  inset: -2% -16% -1%;
  border-radius: 8cqw;
  background: rgba(196, 226, 255, 0.18);
  filter: blur(80px);
  pointer-events: none;
}

/* 바닥 빛 웅덩이: 자판기 래퍼 기준, 좌우 바닥 띠로 번집니다. */
.spill {
  position: absolute;
  left: -60%;
  width: 220%;
  bottom: -10cqw;
  height: 40cqw;
  background: radial-gradient(rgba(210, 235, 255, 0.24), transparent 70%);
  pointer-events: none;
}

.ground {
  position: absolute;
  left: 5%;
  width: 90%;
  bottom: -1.5cqw;
  height: 3cqw;
  background: radial-gradient(closest-side, rgba(0, 0, 0, 0.55), transparent);
  pointer-events: none;
}

.cabinet {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: 13cqw auto 7.2cqw 11cqw 1fr;
  row-gap: 1.6cqw;
  padding: 2.6cqw 3.2cqw 6.4cqw;
  border-radius: 3.4cqw 3.4cqw 1.4cqw 1.4cqw;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.07), transparent 10%),
    linear-gradient(90deg, #0a0f1d 0%, #19223e 4%, #222c50 16%, #27335b 50%, #222c50 84%, #19223e 96%, #0a0f1d 100%);
  box-shadow:
    inset 0 0 0 0.35cqw rgba(160, 190, 255, 0.07),
    inset 0 -1cqw 2cqw rgba(0, 0, 0, 0.45),
    0 0 0 0.3cqw #070a13;
}

/* 간판 */
.sign {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2cqw;
  overflow: hidden;
  border-radius: 1.8cqw;
  background: radial-gradient(130% 150% at 50% 0%, #fffef9 0%, #fff4dd 55%, #ffe1b4 100%);
  box-shadow:
    inset 0 0 0 0.5cqw #0c1120,
    inset 0 0 2.6cqw rgba(255, 180, 100, 0.45),
    0 0 6cqw rgba(255, 226, 180, 0.3);
}

.sign::before {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(90deg, transparent 0 11cqw, rgba(255, 255, 255, 0.35) 11cqw 12.5cqw, transparent 12.5cqw 23cqw);
  mix-blend-mode: soft-light;
  pointer-events: none;
}

.sign-title {
  position: relative;
  margin: 0;
  font-size: 6.1cqw;
  font-weight: 900;
  letter-spacing: -0.04em;
  line-height: 1;
  white-space: nowrap;
  color: #d92d47;
  text-shadow: 0 0.25cqw 0 rgba(255, 255, 255, 0.8), 0 0 1.6cqw rgba(255, 110, 110, 0.25);
}

.sign-tag {
  position: relative;
  flex: none;
  padding: 0.8cqw 1.6cqw;
  border-radius: 99px;
  font-size: 2.5cqw;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
  color: #fff;
  background: #d92d47;
  transform: rotate(-5deg);
  box-shadow: 0 0.3cqw 0 rgba(120, 20, 30, 0.3);
}

/* 진열창 */
.window {
  position: relative;
  display: grid;
  row-gap: 1.1cqw;
  padding: 1.6cqw 1.8cqw 1.8cqw;
  border-radius: 1.8cqw;
  background: linear-gradient(180deg, #f6fbff 0%, #e6eff8 50%, #d5e3f1 100%);
  box-shadow:
    inset 0 0 0 0.55cqw #0c1120,
    inset 0 0 0 0.9cqw rgba(255, 255, 255, 0.6),
    inset 0 0 4cqw rgba(60, 110, 170, 0.25),
    0 0 7cqw rgba(196, 226, 255, 0.4);
}

.row {
  display: grid;
}

.shelf {
  position: relative;
  height: 22.4cqw;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  column-gap: 1.2cqw;
  align-items: end;
  padding: 0 0.3cqw;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(220, 234, 248, 0.25));
  border-bottom: 0.7cqw solid #a7b6c7;
  box-shadow: 0 0.4cqw 0.6cqw rgba(30, 50, 80, 0.22);
}

/* 유리 반사광: 가장 밝은 띠는 1·2열 사이, 두 번째 띠는 3·4열 사이 틈에 옵니다. */
.shelf::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(112deg, transparent 0 25.7%, rgba(255, 255, 255, 0.1) 25.7% 28.7%, transparent 28.7% 72.1%, rgba(255, 255, 255, 0.04) 72.1% 73.6%, transparent 73.6%);
  pointer-events: none;
}

.dummy {
  justify-self: center;
  width: 10.4cqw;
  aspect-ratio: 100 / 206;
  margin-bottom: 0.2cqw;
  filter: drop-shadow(0 0.5cqw 0.5cqw rgba(20, 40, 70, 0.35));
}

.can-svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.rail {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  column-gap: 1.2cqw;
  padding-top: 0.8cqw;
}

.slot {
  display: flex;
  flex-direction: column;
  gap: 0.5cqw;
  min-width: 0;
}

.price {
  align-self: center;
  min-width: 9cqw;
  height: 2.8cqw;
  display: grid;
  place-items: center;
  padding: 0 1cqw;
  border-radius: 0.5cqw;
  font-size: 2.1cqw;
  font-weight: 700;
  line-height: 1;
  color: #fff;
  background: #11151f;
  font-variant-numeric: tabular-nums;
}

.temp {
  height: 4cqw;
  display: grid;
  place-items: center;
  border-radius: 0.5cqw;
  font-size: max(10px, 2.9cqw);
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.04em;
  color: #fff;
}

.temp.hot {
  background: linear-gradient(#ef3d3d, #c91f26);
}

.temp.cold {
  background: linear-gradient(#2f86ff, #1a5ed0);
}

.mood {
  position: relative;
  appearance: none;
  height: 10.6cqw;
  margin: 0 0 0.5cqw;
  padding: 0 0.4cqw 1.3cqw;
  border: 0;
  border-radius: 1.2cqw;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  font-size: max(11px, 3.7cqw);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.03em;
  white-space: nowrap;
  color: #161a24;
  background: linear-gradient(180deg, #ffffff, #e7ebf1);
  box-shadow:
    0 0.5cqw 0 #8b98a9,
    0 0.8cqw 1.2cqw rgba(20, 30, 50, 0.32),
    inset 0 0 0 0.25cqw rgba(0, 0, 0, 0.07);
  cursor: pointer;
  touch-action: manipulation;
}

.mood:active {
  transform: translateY(0.4cqw);
  box-shadow: 0 0.1cqw 0 #8b98a9, 0 0.3cqw 0.6cqw rgba(20, 30, 50, 0.3), inset 0 0 0 0.25cqw rgba(0, 0, 0, 0.07);
}

.led {
  position: absolute;
  top: 1.3cqw;
  left: 22%;
  right: 22%;
  height: 1.1cqw;
  border-radius: 99px;
  background: #27302a;
  box-shadow: inset 0 0 0 0.15cqw rgba(0, 0, 0, 0.3);
  transition: background-color 120ms, box-shadow 120ms;
}

.cabinet[data-phase="idle"] .led {
  background: #5dff86;
  box-shadow: 0 0 1.3cqw #37ff6c, 0 0 0.4cqw #c6ffd5;
}

.led.flash {
  animation: ledFlash 240ms steps(1, end) 2;
}

@keyframes ledFlash {
  0% {
    background: #f0fff4;
    box-shadow: 0 0 2.2cqw #5dff86, 0 0 0.6cqw #fff;
  }
  50% {
    background: #27302a;
    box-shadow: none;
  }
}

/* LED 티커 */
.ticker {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 0 3cqw;
  border-radius: 1.2cqw;
  background: #130b02;
  box-shadow:
    inset 0 0 0 0.5cqw #05070c,
    inset 0 0 2cqw rgba(0, 0, 0, 0.8),
    0 0 0 0.3cqw rgba(255, 255, 255, 0.04),
    0 0 3cqw rgba(255, 160, 0, 0.12);
}

.ticker::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, transparent 0 48%, rgba(12, 7, 1, 0.42) 56%) 0 0 / 0.8cqw 0.8cqw;
  pointer-events: none;
}

.ticker.is-long {
  justify-content: flex-start;
}

.ticker-text {
  flex: none;
  font-size: calc(4.3cqw * var(--fit, 1));
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.02em;
  white-space: nowrap;
  color: var(--amber);
  text-shadow: 0 0 1cqw rgba(255, 176, 0, 0.75), 0 0 0.3cqw rgba(255, 214, 130, 0.8);
}

.ticker.is-long .ticker-text {
  animation: tickerScroll var(--dur, 6s) linear infinite;
}

@keyframes tickerScroll {
  0%,
  16% {
    transform: translateX(0);
  }
  84%,
  100% {
    transform: translateX(calc(-1 * var(--shift, 0px)));
  }
}

/* 컨트롤 줄 */
.controls {
  display: flex;
  align-items: stretch;
  gap: 2cqw;
}

.lottery {
  position: relative;
  flex: none;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0 1.8cqw;
  border-radius: 1.2cqw;
  background: #07090f;
  box-shadow: inset 0 0 0 0.4cqw #1c2236, inset 0 0 1.6cqw rgba(0, 0, 0, 0.9);
}

/* 본체에 인쇄된 라벨: 박스 밖 아래, '꺼내는 곳'과 같은 줄 */
.lottery-cap {
  position: absolute;
  top: calc(100% + 1.6cqw);
  left: 0;
  right: 0;
  font-size: max(10px, 2.6cqw);
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.25em;
  text-align: center;
  white-space: nowrap;
  color: #c9cfdb;
}

.lottery-digits {
  display: flex;
  gap: 0.8cqw;
}

.seg-digit {
  display: block;
  width: 4.7cqw;
  height: 7.4cqw;
  overflow: visible;
  filter: drop-shadow(0 0 0.45cqw rgba(255, 60, 40, 0.8));
}

.seg {
  fill: rgba(255, 59, 48, 0.07);
}

.seg.on {
  fill: #ff4b3a;
}

.lottery.blink .seg.on {
  animation: segBlink 300ms steps(1, end) 3;
}

@keyframes segBlink {
  50% {
    fill: rgba(255, 59, 48, 0.07);
  }
}

.coin {
  position: relative;
  flex: 0 0 13cqw;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.9cqw;
  padding: 0;
  border: 0;
  border-radius: 1.2cqw;
  background: linear-gradient(180deg, #cbd3dc, #8f99a5 55%, #b4bdc7);
  box-shadow: inset 0 0.2cqw 0 rgba(255, 255, 255, 0.7), inset 0 -0.3cqw 0 rgba(0, 0, 0, 0.25), 0 0.4cqw 0.8cqw rgba(0, 0, 0, 0.4);
  cursor: pointer;
  touch-action: manipulation;
}

.coin-slot {
  position: relative;
  width: 1.5cqw;
  height: 5.4cqw;
  border-radius: 99px;
  background: #0b0d12;
  box-shadow: 0 0 0 0.55cqw #ffb347, 0 0 1.6cqw rgba(255, 170, 60, 0.7), inset 0 0 0.4cqw #000;
}

.coin-disc {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 4.4cqw;
  height: 4.4cqw;
  margin: -2.2cqw 0 0 -2.2cqw;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff4c9, #d9b24a 55%, #9c7a1f);
  opacity: 0;
  pointer-events: none;
}

.coin.inserting .coin-disc {
  animation: coinIn 360ms ease-in forwards;
}

@keyframes coinIn {
  0% {
    opacity: 1;
    transform: translateX(-5cqw) scale(1);
  }
  70% {
    opacity: 1;
    transform: translateX(0) scaleX(0.25);
  }
  100% {
    opacity: 0;
    transform: translateX(0) scaleX(0.1);
  }
}

.coin-cap {
  font-size: max(10px, 2.6cqw);
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.15em;
  color: #262c36;
}

.mute {
  flex: 0 0 11cqw;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 1.2cqw;
  color: #dfe6f3;
  background: #0d111c;
  box-shadow: inset 0 0 0 0.3cqw #232b42, 0 0.4cqw 0.8cqw rgba(0, 0, 0, 0.4);
  cursor: pointer;
  touch-action: manipulation;
}

.mute svg {
  width: 6cqw;
  height: 6cqw;
}

.mute .cross,
.mute[aria-pressed="true"] .wave {
  display: none;
}

.mute[aria-pressed="true"] .cross {
  display: inline;
}

.dex-btn {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1cqw;
  margin-bottom: 0.5cqw;
  padding: 0;
  border: 0;
  border-radius: 1.2cqw;
  font-size: max(12px, 3.8cqw);
  font-weight: 900;
  letter-spacing: 0.04em;
  color: #ffc24d;
  text-shadow: 0 0 1cqw rgba(255, 176, 0, 0.55);
  background: linear-gradient(180deg, #1c2338, #10141f);
  box-shadow: inset 0 0 0 0.3cqw #3b4668, inset 0 0.3cqw 0 rgba(255, 255, 255, 0.08), 0 0.5cqw 0 #060810, 0 0.8cqw 1.2cqw rgba(0, 0, 0, 0.4);
  cursor: pointer;
  touch-action: manipulation;
}

.dex-btn:active {
  transform: translateY(0.4cqw);
  box-shadow: inset 0 0 0 0.3cqw #3b4668, 0 0.1cqw 0 #060810;
}

.dex-btn svg {
  width: 5cqw;
  height: 5cqw;
  filter: drop-shadow(0 0 0.8cqw rgba(255, 176, 0, 0.5));
}

/* 꺼내는 곳 */
.bin-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 0.9cqw;
}

.bin-label {
  font-size: max(10px, 2.6cqw);
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.3em;
  color: #c9cfdb;
}

.bin {
  position: relative;
  width: 72cqw;
  height: 17cqw;
  padding: 0;
  border: 0;
  border-radius: 1.6cqw;
  background: #05070b;
  box-shadow:
    inset 0 0 0 0.6cqw #2b3452,
    inset 0 1.2cqw 2cqw rgba(0, 0, 0, 0.9),
    0 0.3cqw 0 rgba(255, 255, 255, 0.05);
  cursor: pointer;
  touch-action: manipulation;
  transition: box-shadow 200ms;
}

.bin.has-can {
  box-shadow:
    inset 0 0 0 0.6cqw #3a4670,
    inset 0 1.2cqw 2cqw rgba(0, 0, 0, 0.9),
    0 0 2.6cqw rgba(196, 226, 255, 0.28);
}

.bin.has-can.rare {
  box-shadow:
    inset 0 0 0 0.6cqw #8a6a1c,
    inset 0 1.2cqw 2cqw rgba(0, 0, 0, 0.9),
    0 0 3cqw rgba(255, 210, 90, 0.45);
}

.bin-well {
  position: absolute;
  inset: 0.9cqw;
  overflow: hidden;
  border-radius: 1cqw;
  background: radial-gradient(120% 95% at 50% 100%, #1d2436 0%, #080a10 70%);
}

.bin-can {
  position: absolute;
  left: 50%;
  bottom: 0.7cqw;
  width: 27cqw;
  height: 13cqw;
  margin-left: -13.5cqw;
}

.bin-can .can-svg {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 13cqw;
  height: 26.8cqw;
  transform: translate(-50%, -50%) rotate(-90deg);
}

.flap {
  position: absolute;
  inset: 0.9cqw;
  overflow: hidden;
  border-radius: 1cqw;
  transform-origin: 50% 0;
  background: linear-gradient(180deg, rgba(62, 68, 86, 0.5) 0%, rgba(28, 32, 42, 0.58) 60%, rgba(14, 16, 22, 0.66) 100%);
  box-shadow: inset 0 0.4cqw 0 rgba(255, 255, 255, 0.12), inset 0 -0.25cqw 0 rgba(0, 0, 0, 0.5);
}

.flap::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 1.1cqw;
  background: linear-gradient(180deg, rgba(210, 222, 245, 0.28), rgba(210, 222, 245, 0));
}

.flap::after {
  content: "PUSH";
  position: absolute;
  right: 3cqw;
  bottom: 1.5cqw;
  font-size: 1.8cqw;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.3em;
  color: rgba(214, 226, 255, 0.34);
}

.flap-shine {
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 18%, rgba(255, 255, 255, 0.16) 34%, transparent 50%), linear-gradient(180deg, rgba(255, 255, 255, 0.1), transparent 30%);
  opacity: 0.45;
}

.bin.has-can .flap-shine {
  animation: flapPulse 1.8s ease-in-out infinite;
}

.bin.has-can.rare .flap-shine {
  background: linear-gradient(100deg, transparent 18%, rgba(255, 220, 120, 0.26) 34%, transparent 50%), linear-gradient(180deg, rgba(255, 220, 120, 0.14), transparent 30%);
}

@keyframes flapPulse {
  0%,
  100% {
    opacity: 0.35;
  }
  50% {
    opacity: 1;
  }
}

.kick {
  position: absolute;
  left: 3.2cqw;
  right: 3.2cqw;
  bottom: 1.2cqw;
  height: 3.6cqw;
  border-radius: 0.8cqw;
  background: repeating-linear-gradient(90deg, #0a0d16 0 1.4cqw, #151b2c 1.4cqw 2cqw);
}

/* 7777 당첨: 불빛 맥동 */
.cabinet.celebrate .sign,
.cabinet.celebrate .window,
.cabinet.celebrate .ticker,
.cabinet.celebrate .coin-slot {
  animation: lightPulse 300ms ease-in-out 3;
}

.machine.celebrate .halo {
  animation: haloPulse 300ms ease-in-out 3;
}

@keyframes lightPulse {
  50% {
    filter: brightness(1.35) saturate(1.25);
  }
}

@keyframes haloPulse {
  50% {
    background: rgba(255, 236, 190, 0.34);
  }
}

/* ───────── 손에 든 캔 · 메시지 카드 오버레이 ───────── */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
}

.overlay-scrim {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 55%, rgba(16, 20, 34, 0.88), rgba(3, 4, 8, 0.95));
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.overlay-inner {
  position: relative;
  height: 100%;
  max-width: 420px;
  margin: 0 auto;
  padding: calc(14px + var(--safe-t)) calc(16px + var(--safe-r)) calc(16px + var(--safe-b)) calc(16px + var(--safe-l));
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.ticker-mirror {
  flex: none;
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border-radius: 10px;
  box-shadow: inset 0 0 0 3px #05070c, inset 0 0 12px rgba(0, 0, 0, 0.8), 0 0 18px rgba(255, 160, 0, 0.12);
}

.ticker-mirror::after {
  background-size: 3.4px 3.4px;
}

.ticker-mirror .ticker-text {
  font-size: calc(17px * var(--fit, 1));
  text-shadow: 0 0 6px rgba(255, 176, 0, 0.75), 0 0 2px rgba(255, 214, 130, 0.8);
}

.ov-content {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
}

.held-stage {
  position: relative;
  z-index: 2;
  display: grid;
  place-items: center;
  padding-top: 8%;
}

.held-can {
  --cw: min(44vw, 190px, 27vh);
  position: relative;
  width: var(--cw);
  aspect-ratio: 100 / 206;
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: none;
  cursor: pointer;
  touch-action: manipulation;
  filter: drop-shadow(0 22px 28px rgba(0, 0, 0, 0.55)) drop-shadow(0 0 30px rgba(196, 226, 255, 0.12));
}

@supports (height: 100dvh) {
  .held-can {
    --cw: min(44vw, 190px, 27dvh);
  }
}

/* 15vh: 세 줄 응원도 360×640에서 스크롤 없이 */
.overlay.opened .held-can {
  --cw: min(30vw, 124px, 15vh);
  cursor: default;
}

.held-art {
  display: block;
  width: 100%;
  height: 100%;
}

.held-can .can-hole {
  opacity: 0;
}

.overlay.tab-open .held-can .can-hole {
  opacity: 1;
}

.pulltab {
  --lift: 0;
  position: absolute;
  left: 50%;
  top: 9.2%;
  width: 30%;
  aspect-ratio: 30 / 22;
  transform-origin: 50% 77%;
  transform: translate(-50%, -77%) perspective(240px) rotateX(calc(58deg - var(--lift) * 58deg));
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.35));
  pointer-events: none;
}

.pulltab svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.overlay.tab-open .pulltab {
  --lift: 1;
}

.tab-grip {
  position: absolute;
  left: 10%;
  right: 10%;
  top: -8%;
  height: 24%;
  touch-action: none;
  cursor: grab;
}

.tab-grip:active {
  cursor: grabbing;
}

.overlay.tab-open .tab-grip,
.overlay.tab-open .tab-hint {
  display: none;
}

.tab-hint {
  position: absolute;
  left: 50%;
  top: -13%;
  width: 22%;
  color: var(--amber);
  filter: drop-shadow(0 0 6px rgba(255, 176, 0, 0.6));
  transform: translateX(-50%);
  animation: hintBob 1.3s ease-in-out infinite;
}

.tab-hint svg {
  display: block;
  width: 100%;
}

@keyframes hintBob {
  0%,
  100% {
    transform: translate(-50%, 0);
    opacity: 0.55;
  }
  50% {
    transform: translate(-50%, -30%);
    opacity: 1;
  }
}

.fx {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 90%;
  height: 90%;
  pointer-events: none;
}

.bubble {
  position: absolute;
  bottom: 0;
  left: var(--x);
  width: var(--s);
  height: var(--s);
  margin-left: calc(var(--s) / -2);
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.85);
  background: radial-gradient(circle at 32% 30%, rgba(255, 255, 255, 0.95) 0 18%, rgba(200, 230, 255, 0.2) 40%, transparent 70%);
  opacity: 0;
  animation: bubbleUp var(--t) cubic-bezier(0.25, 0.6, 0.4, 1) var(--d) forwards;
}

.bubble.gold {
  border-color: rgba(255, 226, 140, 0.95);
  background: radial-gradient(circle at 32% 30%, #fffbe6 0 18%, rgba(255, 210, 90, 0.3) 40%, transparent 70%);
}

@keyframes bubbleUp {
  0% {
    opacity: 0;
    transform: translate(0, 0) scale(0.4);
  }
  15% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(var(--dx), calc(-1 * var(--rise))) scale(1.05);
  }
}

.steam {
  position: absolute;
  bottom: -6%;
  left: var(--x);
  width: 34%;
  height: 100%;
  margin-left: -17%;
  overflow: visible;
  filter: blur(4px);
  opacity: 0;
  animation: steamUp 1000ms ease-out var(--d) forwards;
}

.steam path {
  fill: none;
  stroke: rgba(255, 255, 255, 0.85);
  stroke-width: 7;
  stroke-linecap: round;
}

@keyframes steamUp {
  0% {
    opacity: 0;
    transform: translateY(20%) scaleY(0.6);
  }
  30% {
    opacity: 0.85;
  }
  100% {
    opacity: 0;
    transform: translateY(-45%) scaleY(1.2);
  }
}

/* 크림색 종이 카드 */
.card,
.paper {
  color: var(--ink);
  background-color: var(--cream);
  background-image: var(--grain), linear-gradient(180deg, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0) 45%, rgba(150, 110, 50, 0.05));
}

.card {
  position: relative;
  transform-origin: 50% 100%;
  z-index: 1;
  width: 100%;
  padding: 22px 20px 18px;
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55), inset 0 2px 0 rgba(255, 255, 255, 0.6);
}

.card::before {
  content: "";
  position: absolute;
  top: -10px;
  left: 50%;
  width: 84px;
  height: 22px;
  margin-left: -42px;
  background: rgba(255, 196, 110, 0.72);
  transform: rotate(-3deg);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

.card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  padding-right: 52px;
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.3;
  color: var(--chip-ink, var(--ink));
  background: var(--chip-bg, #f1e6cc);
  box-shadow: inset 0 0 0 1px rgba(42, 33, 24, 0.16);
}

.card-name {
  font-size: 14px;
  font-weight: 800;
  line-height: 1.4;
}

/* 본문 아래 28px: 줄 간격 반쪽(0.3em)을 빼서 글자 끝에서 버튼까지 28px */
.card-msg {
  margin: 14px 0 calc(28px - 0.3em);
  font-size: clamp(19px, 5.4vw, 22px);
  font-weight: 500;
  line-height: 1.6;
  letter-spacing: -0.01em;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.card-new {
  position: absolute;
  top: -14px;
  right: 10px;
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.05em;
  color: #fff;
  background: radial-gradient(circle at 35% 30%, #ff8aa0, #df2447);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.3), inset 0 0 0 3px rgba(255, 255, 255, 0.35);
  transform: rotate(14deg);
}

.btn {
  appearance: none;
  border: 0;
  border-radius: 14px;
  cursor: pointer;
  touch-action: manipulation;
}

.btn-primary {
  width: 100%;
  min-height: 52px;
  font-size: 18px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(180deg, #df3f59, #c02841);
  box-shadow: 0 4px 0 #8c1b2e, 0 8px 18px rgba(192, 40, 65, 0.3);
}

.btn-primary:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #8c1b2e;
}

.card-sub {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.btn-ghost {
  min-height: 46px;
  padding: 0 8px;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  background: rgba(42, 33, 24, 0.06);
  box-shadow: inset 0 0 0 1.5px rgba(42, 33, 24, 0.24);
}

.btn-ghost:active {
  background: rgba(42, 33, 24, 0.12);
}

/* 종이 위에서는 호박색 테두리 안쪽에 진한 띠를 둘러 잘 보이게 */
.card :focus-visible,
.paper :focus-visible {
  box-shadow: 0 0 0 3px var(--ink);
}

/* ───────── 도감 ───────── */

.dex {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.dex-scrim {
  position: absolute;
  inset: 0;
  background: rgba(3, 4, 8, 0.72);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}

.dex-panel {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l);
  color: #e9edf6;
  background: linear-gradient(180deg, #161b2c, #0e121d);
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
}

@media (min-width: 600px) and (min-height: 560px) {
  .dex {
    align-items: center;
  }

  .dex-panel {
    width: 600px;
    height: min(88vh, 840px);
    border-radius: 24px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6), inset 0 0 0 1px rgba(255, 255, 255, 0.06);
  }
}

.dex-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 18px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.dex-title {
  margin: 0;
  font-size: 21px;
  font-weight: 900;
  line-height: 1.3;
}

.dex-progress {
  margin: 4px 0 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--amber);
  font-variant-numeric: tabular-nums;
}

.dex-close {
  flex: none;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 12px;
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
}

.dex-close svg {
  width: 22px;
  height: 22px;
}

.dex-body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 14px 16px 18px;
}

.dex-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

@media (max-width: 359.98px) {
  .dex-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.dex-item {
  width: 100%;
  height: 100%;
  min-height: 132px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 4px 10px;
  border: 0;
  border-radius: 14px;
  text-align: center;
  background: rgba(255, 255, 255, 0.035);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

button.dex-item {
  cursor: pointer;
  background: radial-gradient(90% 70% at 50% 30%, rgba(196, 226, 255, 0.16), rgba(255, 255, 255, 0.04));
  box-shadow: inset 0 0 0 1px rgba(196, 226, 255, 0.18);
}

button.dex-item:active {
  transform: scale(0.97);
}

.dex-can {
  display: block;
  width: 38px;
  aspect-ratio: 100 / 206;
  flex: none;
}

.dex-name {
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
  word-break: keep-all;
}

.dex-item.locked .dex-name {
  color: #8f99b3;
}

.dex-seen {
  margin-top: auto;
  font-size: 12px;
  font-weight: 700;
  color: #ffc83d;
  font-variant-numeric: tabular-nums;
}

.dex-sub {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 22px 2px 10px;
  font-size: 15px;
  font-weight: 800;
}

.dex-sub span {
  font-size: 12px;
  font-weight: 600;
  color: #8f99b3;
}

.dex-foot {
  display: flex;
  justify-content: center;
  padding: 6px 16px 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.dex-reset {
  min-height: 40px;
  padding: 8px 12px;
  border: 0;
  font-size: 13px;
  color: #9aa3bb;
  background: none;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.dex-back {
  min-height: 40px;
  padding: 0 14px 0 10px;
  border: 0;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  color: #e9edf6;
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
}

.dex-hero {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 16px 2px 18px;
}

.dex-hero .dex-can {
  width: 62px;
}

.dex-hero-title {
  margin: 0 0 8px;
  font-size: 19px;
  font-weight: 900;
  line-height: 1.35;
}

.dex-meta .chip {
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.28);
}

.dex-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 13px;
  color: #c0c8da;
}

.dex-msgs {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.paper {
  padding: 14px 14px 12px;
  border-radius: 14px;
}

.paper p {
  margin: 0 0 10px;
  font-size: 16px;
  line-height: 1.7;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.btn-replay {
  min-height: 40px;
  padding: 0 14px;
  border: 0;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 800;
  color: #fff;
  background: #3a2c1f;
  cursor: pointer;
}

.msg-locked {
  padding: 14px;
  border: 1.5px dashed rgba(255, 255, 255, 0.16);
  border-radius: 14px;
  font-size: 14px;
  color: #8f99b3;
}

/* ───────── 뷰포트 높이 <560 (가로로 든 폰) ───────── */

@media (max-height: 559.98px) {
  .machine {
    --W: min(calc(100vw - 24px), 400px);
  }

  /* 세로 스크롤은 페이지가 맡고, 옆으로 번지는 빛은 여기서 자릅니다.
     body/html의 clip은 뷰포트로 전파되며 hidden이 되어 scrollTo를 못 막습니다. */
  .stage {
    min-height: 0;
    padding-block: calc(12px + var(--safe-t)) calc(12px + var(--safe-b));
    overflow: clip visible;
  }
}

@media (max-height: 559.98px) and (min-width: 640px) {
  .overlay-inner {
    max-width: 860px;
  }

  .overlay.opened .ov-content {
    flex-direction: row-reverse;
    gap: 28px;
  }

  .overlay.opened .held-stage {
    flex: 0 0 40%;
  }

  .overlay.opened .card {
    flex: 1 1 60%;
  }

  .overlay.opened .held-can {
    --cw: min(16vw, 110px, 30vh);
  }
}

/* ───────── 모션 감소 ───────── */

@media (prefers-reduced-motion: reduce) {
  .led,
  .bin {
    transition: none;
  }

  .led.flash,
  .lottery.blink .seg.on,
  .cabinet.celebrate .sign,
  .cabinet.celebrate .window,
  .cabinet.celebrate .ticker,
  .cabinet.celebrate .coin-slot,
  .machine.celebrate .halo,
  .bin.has-can .flap-shine,
  .coin.inserting .coin-disc,
  .tab-hint,
  .ticker.is-long .ticker-text {
    animation: none;
  }

  .tab-hint {
    opacity: 0.9;
  }

  .bin.has-can .flap-shine {
    opacity: 0.8;
  }

  .mood:active,
  .dex-btn:active,
  .btn-primary:active,
  button.dex-item:active {
    transform: none;
  }
}
