:root {
  --bg: #fff6e5; --ink: #2b2140; --red: #ff4d5e; --yellow: #ffd23f;
  --sky: #4cc9f0; --mint: #7be0c3; --pink: #ff8fc7; --purple: #a66cff;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: #bfe8ff;
  font-family: 'Jua', system-ui, sans-serif; color: var(--ink);
  user-select: none; -webkit-user-select: none; touch-action: none;
}
#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
[hidden] { display: none !important; }
h2, h3 { font-weight: normal; }

#loading {
  position: fixed; inset: 0; display: grid; place-items: center;
  font-family: 'Press Start 2P', monospace; font-size: 16px; color: var(--red);
}

.btn {
  font: inherit; font-size: 18px; color: var(--ink); background: var(--yellow);
  border: 3px solid var(--ink); border-radius: 14px; padding: 10px 16px;
  box-shadow: 0 4px 0 var(--ink); cursor: pointer; touch-action: none;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn:disabled { opacity: .45; }
.btn.big { font-size: 20px; padding: 12px 22px; }
.btn.wide { display: block; width: 100%; margin-top: 14px; }
.btn small { font-size: 14px; opacity: .8; }

.pill {
  background: #fff; border: 3px solid var(--ink); border-radius: 999px;
  padding: 6px 14px; font-size: 17px; box-shadow: 0 3px 0 var(--ink);
}
.coin { display: flex; align-items: center; gap: 6px; }
.coin-ico { width: 18px; height: 18px; border-radius: 50%; background: var(--yellow); border: 3px solid #e09a00; box-shadow: inset -2px -2px 0 #f0b400; }
.coin .coins, .timer span { font-family: 'Press Start 2P', monospace; font-size: 13px; }

.topbar {
  position: fixed; top: calc(12px + env(safe-area-inset-top)); left: 16px; right: 16px;
  display: flex; gap: 8px; align-items: center; pointer-events: none;
}
.side {
  position: fixed; right: 16px; top: calc(70px + env(safe-area-inset-top));
  display: flex; flex-direction: column; gap: 10px;
}
.btn.icon { display: flex; flex-direction: column; align-items: center; font-size: 24px; padding: 6px 10px; line-height: 1.1; }
.btn.icon span { font-size: 13px; }

#joy {
  position: fixed; left: 24px; bottom: calc(24px + env(safe-area-inset-bottom));
  width: 120px; height: 120px; border-radius: 50%;
  background: rgba(255, 255, 255, .55); border: 3px solid var(--ink); touch-action: none;
}
#knob {
  position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px;
  border-radius: 50%; background: var(--red); border: 3px solid var(--ink); pointer-events: none;
}
#prompt {
  position: fixed; left: 0; right: 0; margin: 0 auto; width: max-content;
  bottom: calc(170px + env(safe-area-inset-bottom)); animation: bounce 1s ease-in-out infinite;
}
@media (pointer: fine) { #joy { display: none; } #prompt { bottom: 60px; } }
@media (pointer: coarse) { .pc-only { display: none; } }
.hint {
  position: fixed; left: 16px; bottom: 16px; margin: 0; padding: 6px 10px;
  background: rgba(255, 255, 255, .85); border-radius: 8px; font-size: 14px;
}
#claw-ui .hint { bottom: auto; top: calc(64px + env(safe-area-inset-top)); }

#claw-ui .controls {
  position: fixed; left: 16px; right: 16px; bottom: calc(20px + env(safe-area-inset-bottom));
  display: flex; justify-content: space-between; align-items: center;
  max-width: 520px; margin: 0 auto;
}
.dpad { display: grid; grid-template-columns: repeat(3, 56px); grid-template-rows: repeat(3, 56px); gap: 4px; }
.dpad .btn { padding: 0; font-size: 20px; background: #fff; }
.dpad [data-dir=up] { grid-area: 1 / 2; }
.dpad [data-dir=left] { grid-area: 2 / 1; }
.dpad [data-dir=right] { grid-area: 2 / 3; }
.dpad [data-dir=down] { grid-area: 3 / 2; }
.btn.drop { width: 112px; height: 112px; border-radius: 50%; background: var(--red); color: #fff; font-size: 22px; }

.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 560px; max-height: 58vh; overflow: auto;
  background: var(--bg); border: 4px solid var(--ink); border-bottom: 0; border-radius: 24px 24px 0 0;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); touch-action: pan-y;
}
@media (min-width: 900px) and (min-aspect-ratio: 1/1) {
  .sheet { left: auto; right: 32px; top: 32px; bottom: 32px; width: 380px; max-height: none; border-bottom: 4px solid var(--ink); border-radius: 24px; }
}
.title {
  font-family: 'Press Start 2P', monospace; font-size: 22px; line-height: 1.4; text-align: center;
  color: var(--red); text-shadow: 3px 3px 0 var(--yellow); margin: 0 0 8px;
}
.sheet-title { margin: 0 0 6px; text-align: center; }
.row { margin: 10px 0; }
.row h3 { margin: 0 0 6px; font-size: 16px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { font: inherit; font-size: 15px; background: #fff; border: 3px solid var(--ink); border-radius: 12px; padding: 6px 12px; cursor: pointer; }
.chip.on { background: var(--sky); color: #fff; }
.chip.swatch { width: 38px; height: 38px; border-radius: 50%; padding: 0; }
.chip.swatch.on { outline: 3px solid var(--red); outline-offset: 2px; }
#nick-input {
  font: inherit; font-size: 18px; width: 100%; padding: 10px 12px;
  border: 3px solid var(--ink); border-radius: 12px; background: #fff; user-select: text;
}

.modal { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; background: rgba(43, 33, 64, .45); z-index: 10; }
.card {
  background: var(--bg); border: 4px solid var(--ink); border-radius: 20px; box-shadow: 0 6px 0 var(--ink);
  padding: 20px; width: min(360px, 100%); text-align: center; animation: pop .35s cubic-bezier(.3, 1.6, .5, 1);
}
.card h2 { margin: 0 0 8px; }
.card.wide { width: min(560px, 100%); max-height: 84vh; overflow: auto; touch-action: pan-y; }
.big-num { font-family: 'Press Start 2P', monospace; font-size: 28px; color: var(--red); }
.bar { height: 14px; border: 3px solid var(--ink); border-radius: 999px; background: #fff; overflow: hidden; margin-bottom: 14px; }
.bar i { display: block; height: 100%; background: var(--mint); }
.dex-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (min-width: 520px) { .dex-grid { grid-template-columns: repeat(4, 1fr); } }
.dex-item { position: relative; background: #fff; border: 3px solid var(--ink); border-radius: 14px; padding: 6px; font-size: 14px; }
.dex-item img { width: 100%; aspect-ratio: 1; display: block; }
.dex-item.locked img { filter: brightness(0); opacity: .2; }
.count { position: absolute; top: 4px; right: 8px; font-size: 12px; }
.badge { display: inline-block; font-size: 12px; color: #fff; border-radius: 6px; padding: 1px 7px; }

.result-name { font-size: 22px; margin: 4px 0; }
.res-item { display: grid; justify-items: center; gap: 4px; margin-bottom: 6px; }
.res-item img { width: 170px; height: 170px; }
.res-item b { font-size: 22px; font-weight: normal; }
.result-items.multi { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; max-height: 50vh; overflow: auto; }
.result-items.multi .res-item { background: #fff; border: 3px solid var(--ink); border-radius: 14px; padding: 6px; }
.result-items.multi img { width: 80px; height: 80px; }
.result-items.multi b { font-size: 16px; }
.new { font-family: 'Press Start 2P', monospace; font-size: 11px; color: var(--red); }
.btns { display: flex; gap: 10px; margin-top: 12px; }
.btns .btn { flex: 1; }
#again, #go-major { background: var(--red); color: #fff; }
.pill:empty { display: none; }
#g-exit { position: fixed; right: 16px; top: calc(12px + env(safe-area-inset-top)); }
.rar-legend .card { animation: pop .35s, legend 1.2s linear infinite; }
.rar-epic .card { box-shadow: 0 6px 0 var(--ink), 0 0 30px var(--purple); }

.note { font-size: 14px; opacity: .7; margin: 6px 0; }
.tabs { justify-content: center; margin-bottom: 6px; }
.chip.thumb { width: 52px; height: 52px; padding: 2px; }
.chip.thumb img { width: 100%; height: 100%; display: block; }
.chip.thumb.on { background: #dff4ff; outline: 3px solid var(--red); outline-offset: 2px; }

#market-list, #locker-list { margin-top: 12px; display: grid; gap: 8px; }
.silhouette { filter: brightness(0); opacity: .35; }
.lock-dot { display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--ink); margin-right: 6px; vertical-align: -2px; }
.market-row { display: flex; align-items: center; gap: 10px; background: #fff; border: 3px solid var(--ink); border-radius: 14px; padding: 6px 10px; text-align: left; }
.market-row img { width: 52px; height: 52px; }
.market-row .info { flex: 1; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.market-row small { width: 100%; font-size: 13px; opacity: .7; }
.btn.sell { display: flex; align-items: center; gap: 6px; font-size: 16px; padding: 8px 12px; background: var(--mint); }
.btn.sell .coin-ico { width: 14px; height: 14px; border-width: 2px; }

#gacha-drag { position: fixed; inset: 0; touch-action: none; }
.turn-ring {
  position: fixed; width: 120px; height: 120px; margin: -60px 0 0 -60px; pointer-events: none;
  display: grid; place-items: center; font-size: 64px; color: var(--red); text-shadow: 0 3px 0 #fff;
  border: 4px dashed rgba(255, 77, 94, .7); border-radius: 50%; animation: spin 2s linear infinite;
}
.gacha-hint {
  position: fixed; left: 0; right: 0; top: calc(70px + env(safe-area-inset-top)); margin: 0 auto; width: max-content;
  font-size: 22px; background: #fff; border: 3px solid var(--ink); border-radius: 14px; padding: 8px 16px; pointer-events: none;
}
.gacha-hint:empty { display: none; }
#gacha-btn { position: fixed; left: 0; right: 0; margin: 0 auto; width: max-content; bottom: calc(28px + env(safe-area-inset-bottom)); }
#touch { position: fixed; inset: 0; touch-action: none; }
#gauge {
  position: fixed; left: 16px; right: 150px; bottom: calc(64px + env(safe-area-inset-bottom)); max-width: 420px; height: 26px;
  border: 3px solid var(--ink); border-radius: 999px; background: #fff; overflow: hidden; pointer-events: none;
}
#gauge i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #ffd23f, #ff8c42, #ff4d5e); }
#fire { position: fixed; right: 20px; bottom: calc(24px + env(safe-area-inset-bottom)); }
.pill.score { font-family: 'Press Start 2P', monospace; font-size: 12px; }
#crosshair {
  position: fixed; width: 44px; height: 44px; margin: -22px 0 0 -22px; pointer-events: none;
  border: 3px solid var(--red); border-radius: 50%; box-shadow: 0 0 0 2px #fff;
}
#crosshair::before, #crosshair::after { content: ''; position: absolute; background: var(--red); }
#crosshair::before { left: 50%; top: -10px; bottom: -10px; width: 3px; margin-left: -1.5px; }
#crosshair::after { top: 50%; left: -10px; right: -10px; height: 3px; margin-top: -1.5px; }
#touch { cursor: pointer; }
@media (pointer: fine) { #touch.aim { cursor: none; } } /* 사격만 조준선이 커서 대신 */
.pop {
  position: fixed; transform: translate(-50%, -50%); pointer-events: none; z-index: 15; white-space: nowrap;
  font-family: 'Press Start 2P', monospace; font-size: 18px; text-shadow: 0 3px 0 #2b2140, 0 0 8px #fff;
  animation: rise .9s ease-out forwards;
}
@keyframes rise { 0% { opacity: 0; margin-top: 10px; scale: .6; } 20% { opacity: 1; scale: 1.2; } 100% { opacity: 0; margin-top: -60px; scale: 1; } }
.reward { display: flex; justify-content: center; align-items: center; gap: 6px; font-size: 20px; margin: 4px 0; }
#countdown {
  position: fixed; inset: 0; display: grid; place-items: center; pointer-events: none; z-index: 25;
  font-family: 'Press Start 2P', monospace; font-size: 120px; color: #fff; text-shadow: 0 8px 0 var(--ink), 0 0 30px var(--pink);
}
#countdown.tick { animation: pop .4s cubic-bezier(.3, 1.6, .5, 1); }
#flash { position: fixed; inset: 0; background: #fff; z-index: 26; pointer-events: none; opacity: 0; }
#flash.go { animation: flash .6s ease-out; }
@keyframes flash { 0% { opacity: 1; } 100% { opacity: 0; } }
.photo-img { display: block; width: auto; max-width: 100%; max-height: 58vh; margin: 0 auto 4px; border-radius: 8px; box-shadow: 0 4px 0 var(--ink); }
a.btn { text-decoration: none; text-align: center; }
@keyframes spin { to { transform: rotate(360deg); } }

#toast {
  position: fixed; top: calc(80px + env(safe-area-inset-top)); left: 0; right: 0; margin: 0 auto; width: max-content; max-width: calc(100% - 32px);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; z-index: 30;
}
.confetti { position: fixed; top: -16px; width: 10px; height: 14px; z-index: 20; animation: fall linear forwards; pointer-events: none; }

@keyframes bounce { 50% { transform: translateY(-6px); } }
@keyframes pop { from { transform: scale(.6); opacity: 0; } }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }
@keyframes legend {
  0%, 100% { box-shadow: 0 6px 0 var(--ink), 0 0 36px #ffd23f; }
  50% { box-shadow: 0 6px 0 var(--ink), 0 0 36px #ff8fc7; }
}
.shake { animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
