@font-face {
  font-family: 'Jua';
  src: url('../fonts/Jua.woff2') format('woff2');
  font-weight: 400; font-display: swap;
}
@font-face {
  font-family: 'Pretendard';
  src: url('../fonts/Pretendard-Regular.woff2') format('woff2');
  font-weight: 400; font-display: swap;
}
@font-face {
  font-family: 'Pretendard';
  src: url('../fonts/Pretendard-Bold.woff2') format('woff2');
  font-weight: 700; font-display: swap;
}

:root {
  --paper: #fffdf5;
  --paper-2: #f8f0dc;
  --paper-3: #f1e6cd;
  --ink: #4a4133;
  --ink-soft: #857963;
  --blue: #5b8fd6;
  --blue-dark: #3f6ea8;
  --green: #7fa86a;
  --green-dark: #5d8550;
  --yellow: #f2cf6b;
  --line: rgba(160, 148, 116, .32);
  --shadow: 0 4px 0 rgba(168, 150, 110, .22);
  --ui: 'Pretendard', -apple-system, 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  --hand: 'Jua', 'Pretendard', sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overscroll-behavior: none; }
body {
  font-family: var(--ui);
  color: var(--ink);
  background:
    radial-gradient(120% 90% at 50% 0%, #fdf8ea 0%, #f4ebd6 60%, #eee1c6 100%);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

/* 모눈 종이 배경 */
#app {
  position: relative;
  width: 100%;
  height: 100dvh;
  max-width: 520px;
  margin: 0 auto;
  overflow: hidden;
  background-color: #f8f1df;
  background-image:
    linear-gradient(rgba(150, 170, 196, .16) 1px, transparent 1px),
    linear-gradient(90deg, rgba(150, 170, 196, .16) 1px, transparent 1px);
  background-size: 24px 24px, 24px 24px;
  box-shadow: 0 0 40px rgba(120, 100, 60, .18);
  isolation: isolate;
}
#app::after {
  content: '';
  position: absolute; inset: 0;
  pointer-events: none;
  z-index: 60;
  opacity: .5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='.10'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
}

.screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  opacity: 0; pointer-events: none;
  transform: translateY(8px);
  transition: opacity .28s ease, transform .28s ease;
  z-index: 2;
}
.screen.active { opacity: 1; pointer-events: auto; transform: none; z-index: 5; }

/* ---------- 공통 종이 카드 ---------- */
.card {
  position: relative;
  background: var(--paper);
  border-radius: 18px;
  border: 1.5px solid var(--line);
  box-shadow: var(--shadow);
  padding: 14px 14px 15px;
}
.card.tape::before, .card.tape::after {
  content: '';
  position: absolute; top: -11px;
  width: 64px; height: 22px;
  background: linear-gradient(180deg, rgba(240, 224, 178, .96), rgba(226, 205, 154, .9));
  border-left: 1px dashed rgba(180, 155, 105, .45);
  border-right: 1px dashed rgba(180, 155, 105, .45);
  box-shadow: 0 1px 2px rgba(150, 130, 90, .18);
  opacity: .95;
}
.card.tape::before { left: 12px; transform: rotate(-5deg); }
.card.tape::after { right: 12px; transform: rotate(4deg); }

.sheet-label {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--hand); font-weight: 700;
  font-size: 17px; color: #6b5a3c;
  background: linear-gradient(180deg, #f6e7bd, #efdbaa);
  padding: 3px 12px 4px;
  border-radius: 8px;
  box-shadow: 0 2px 0 rgba(170, 145, 95, .28);
  transform: rotate(-.6deg);
}
.sheet-label svg { width: 16px; height: 16px; }

h1, h2, h3 { font-family: var(--hand); margin: 0; letter-spacing: -.2px; }

/* ---------- 홈(설계) ---------- */
.topbar {
  position: relative;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 14px 6px;
  gap: 8px;
  z-index: 6;
}
.icon-btn {
  width: 42px; height: 42px; flex: 0 0 42px;
  display: grid; place-items: center;
  border-radius: 14px;
  background: var(--paper);
  border: 1.5px solid var(--line);
  box-shadow: 0 3px 0 rgba(168, 150, 110, .2);
  color: #6b5f48;
  cursor: pointer;
  transition: transform .1s;
}
.icon-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(168, 150, 110, .2); }
.icon-btn svg { width: 21px; height: 21px; }

.title-tape {
  position: relative;
  font-family: var(--hand); font-weight: 700;
  font-size: 27px; color: #4d4231;
  padding: 6px 20px 7px;
  background: linear-gradient(180deg, #fbf1cf, #f3e2b4);
  border-radius: 6px;
  box-shadow: 0 2px 0 rgba(170, 145, 95, .25);
  transform: rotate(-1deg);
}
.title-tape::before {
  content: ''; position: absolute; inset: -6px -10px auto;
  height: 100%;
  background:
    linear-gradient(90deg, rgba(255,255,255,.4), transparent 20%, transparent 80%, rgba(255,255,255,.35));
  border-radius: 8px;
  z-index: -1;
}

.coin-chip {
  display: flex; align-items: center; gap: 6px;
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: 999px;
  padding: 5px 12px 5px 6px;
  box-shadow: 0 3px 0 rgba(168, 150, 110, .2);
  font-family: var(--ui); font-weight: 700; font-size: 15px;
  color: #7a6327;
}
.coin-ico {
  width: 24px; height: 24px; border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, #ffeaa6, #f0c04e 60%, #d9a334);
  border: 1.5px solid #c99a34;
  display: grid; place-items: center;
  font-family: var(--hand); font-weight: 700; font-size: 13px; color: #8a6a1c;
  box-shadow: inset 0 -2px 0 rgba(150, 110, 30, .25);
}

.home-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 6px 14px 150px;
  scrollbar-width: none;
}
.home-scroll::-webkit-scrollbar { display: none; }

.preview-wrap {
  position: relative;
  margin: 4px 2px 0;
  height: 208px;
  border-radius: 20px;
  background:
    radial-gradient(85% 70% at 50% 30%, #fffdf4 0%, #fbf4e2 58%, #f3e7cd 100%);
  border: 1.5px solid var(--line);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .8), var(--shadow);
  overflow: hidden;
}
.preview-wrap canvas { width: 100%; height: 100%; display: block; touch-action: none; }
.preview-hint {
  position: absolute; left: 0; right: 0; bottom: 9px;
  display: flex; align-items: center; justify-content: center; gap: 5px;
  font-family: var(--hand); font-size: 15px; color: #8b7b5f;
  pointer-events: none;
}
.preview-hint svg { width: 16px; height: 16px; opacity: .75; }
.preview-dash {
  position: absolute; left: 50%; bottom: 26px; width: 150px; height: 46px;
  transform: translateX(-50%);
  border-bottom: 2px dashed rgba(150, 135, 100, .35);
  border-radius: 0 0 80px 80px;
  pointer-events: none;
}

.section { margin-top: 16px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.section-head .hint { font-family: var(--hand); font-size: 15px; color: #9a8a6c; }

/* 기체 6종 */
.shape-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.shape-card {
  position: relative;
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 8px 6px 6px;
  text-align: center;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(168, 150, 110, .14);
  transition: transform .12s, border-color .12s;
}
.shape-card:active { transform: scale(.97); }
.shape-card.sel { border-color: var(--blue); background: #f4f8ff; box-shadow: 0 3px 0 rgba(91, 143, 214, .3); }
.shape-card.sel::after {
  content: '✓';
  position: absolute; top: -7px; right: -6px;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--blue); color: #fff;
  font-size: 13px; font-weight: 700;
  display: grid; place-items: center;
  border: 2px solid #fff;
  box-shadow: 0 2px 4px rgba(60, 90, 140, .3);
}
.shape-card svg { width: 100%; height: 40px; display: block; }
.shape-card b { display: block; font-family: var(--hand); font-size: 15px; font-weight: 700; color: #5a4e3a; margin-top: 2px; }
.shape-card small { display: block; font-size: 9.5px; line-height: 1.3; color: #a2957c; height: 25px; overflow: hidden; }
.shape-card b { font-size: 16px; }

/* 색상 칩 */
.chip-row { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 4px; scrollbar-width: none; }
.chip-row::-webkit-scrollbar { display: none; }
.color-chip {
  position: relative; flex: 0 0 40px; height: 40px; border-radius: 12px;
  border: 1.5px solid rgba(140, 128, 100, .35);
  box-shadow: inset 0 -2px 6px rgba(0, 0, 0, .08), 0 2px 0 rgba(168, 150, 110, .16);
  cursor: pointer;
}
.color-chip.sel { outline: 2.5px solid var(--blue); outline-offset: 2px; }
.pat-chip {
  flex: 0 0 auto; height: 40px; padding: 0 12px; border-radius: 12px;
  background: var(--paper); border: 1.5px solid var(--line);
  font-family: var(--hand); font-size: 15px; font-weight: 700; color: #6b5c42;
  display: flex; align-items: center; gap: 6px; cursor: pointer;
  box-shadow: 0 2px 0 rgba(168, 150, 110, .16);
}
.pat-chip.sel { border-color: var(--blue); background: #f4f8ff; color: #3f6ea8; }
.lock-badge { font-size: 10px; color: #a2957c; }

/* 아이템 리스트 (재질·부품·궤적) */
.item-row { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 6px; scrollbar-width: none; }
.item-row::-webkit-scrollbar { display: none; }
.item-card {
  position: relative;
  flex: 0 0 128px;
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 9px 9px 8px;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(168, 150, 110, .14);
}
.item-card.sel { border-color: var(--green); background: #f6fbf1; box-shadow: 0 3px 0 rgba(127, 168, 106, .3); }
.item-card .nm { font-family: var(--hand); font-weight: 700; font-size: 15px; color: #5a4e3a; }
.item-card .ds { font-size: 10.5px; line-height: 1.35; color: #96896f; margin-top: 3px; min-height: 28px; }
.item-card .pr {
  margin-top: 6px; display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 700; color: #8a6a1c;
}
.item-card .pr.locked { color: #b3a58a; }
.item-card .swatch { width: 100%; height: 26px; border-radius: 8px; margin-top: 6px; }
.item-card .tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 5px; }
.tag { font-size: 9.5px; padding: 1.5px 5px; border-radius: 6px; background: #f0e8d5; color: #8a7b5f; }
.tag.up { background: #e4f2e0; color: #4f7a45; }
.tag.down { background: #fbe6e2; color: #a4574a; }

/* 슬라이더 */
.sliders { display: flex; flex-direction: column; gap: 9px; }
.slider-row { display: flex; align-items: center; gap: 8px; }
.slider-row .lb { display: flex; align-items: center; gap: 5px; width: 82px; flex: 0 0 82px; font-family: var(--hand); font-size: 15px; font-weight: 700; color: #5f533d; }
.slider-row .lb svg { width: 16px; height: 16px; opacity: .7; }
.slider-row input[type=range] {
  -webkit-appearance: none; appearance: none;
  flex: 1; height: 18px; background: transparent; margin: 0 6px;
}
.slider-row input[type=range]::-webkit-slider-runnable-track {
  height: 7px; border-radius: 5px;
  background: linear-gradient(180deg, #e7dcc3, #d9cbb0);
  border: 1px solid rgba(150, 135, 100, .3);
  box-shadow: inset 0 1px 1px rgba(120, 100, 70, .18);
}
.slider-row input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 20px; height: 20px; margin-top: -7px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffffff, #f3ead7 70%);
  border: 2px solid #b9a77f;
  box-shadow: 0 2px 3px rgba(120, 100, 70, .3);
  cursor: grab;
}
.slider-row input[type=range]::-moz-range-track { height: 7px; border-radius: 5px; background: #dfd3ba; }
.slider-row input[type=range]::-moz-range-thumb { width: 20px; height: 20px; border-radius: 50%; background: #fff; border: 2px solid #b9a77f; }
.slider-row .val { width: 46px; flex: 0 0 46px; text-align: right; font-size: 12px; font-weight: 700; color: #7d6f56; }
.slider-row input[type=range]::-webkit-slider-thumb:active { cursor: grabbing; }

.stat-line { display: flex; gap: 6px; margin-top: 10px; }
.stat-pill { flex: 1; background: #f5eeda; border: 1px solid rgba(160, 148, 116, .25); border-radius: 10px; padding: 5px 6px; text-align: center; }
.stat-pill span { display: block; font-size: 9.5px; color: #9a8c72; }
.stat-pill b { font-family: var(--hand); font-size: 15px; color: #5c4f3a; }

/* 스테이지 */
.stage-row { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.stage-row::-webkit-scrollbar { display: none; }
.stage-chip {
  position: relative; flex: 0 0 auto; min-width: 88px;
  background: var(--paper); border: 1.5px solid var(--line); border-radius: 12px;
  padding: 7px 10px; cursor: pointer; box-shadow: 0 2px 0 rgba(168, 150, 110, .14);
}
.stage-chip.sel { border-color: var(--blue); background: #f4f8ff; }
.stage-chip.locked { opacity: .62; }
.stage-chip b { display: block; font-family: var(--hand); font-size: 15px; color: #574c38; }
.stage-chip small { font-size: 10px; color: #9a8c72; }

/* 하단 발사 버튼 */
.bottom-dock {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 10px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(248, 241, 223, 0) 0%, rgba(248, 241, 223, .92) 34%, #f6eeda 100%);
  z-index: 8;
}
.btn {
  position: relative;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; height: 58px;
  border: none; border-radius: 18px;
  font-family: var(--hand); font-weight: 700; font-size: 27px; letter-spacing: .5px;
  color: #fffef7;
  cursor: pointer;
  transition: transform .1s, box-shadow .1s;
  text-shadow: 0 1px 2px rgba(60, 50, 20, .25);
}
.btn svg { width: 26px; height: 26px; }
.btn-primary {
  background: linear-gradient(180deg, #78a6e0, var(--blue) 55%, #4f80c4);
  box-shadow: 0 5px 0 var(--blue-dark), 0 8px 14px rgba(70, 105, 160, .28);
}
.btn-green {
  background: linear-gradient(180deg, #97bf82, var(--green) 55%, #6f9659);
  box-shadow: 0 5px 0 var(--green-dark), 0 8px 14px rgba(90, 130, 70, .25);
}
.btn-ghost {
  background: var(--paper); color: #6b5d43;
  border: 1.5px solid var(--line);
  box-shadow: 0 4px 0 rgba(168, 150, 110, .22);
  font-size: 20px; height: 48px;
  text-shadow: none;
}
.btn:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(80, 110, 150, .4); }
.btn-ghost:active { box-shadow: 0 1px 0 rgba(168, 150, 110, .22); }

/* ---------- 비행 화면 ---------- */
#flight { background: #cfe7f2; }
#gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hud { position: absolute; inset: 0; pointer-events: none; z-index: 6; }
.hud-card {
  position: absolute;
  background: rgba(255, 252, 243, .94);
  border: 1.5px solid rgba(160, 148, 116, .38);
  border-radius: 14px;
  box-shadow: 0 3px 0 rgba(150, 130, 90, .18), 0 6px 14px rgba(60, 70, 60, .12);
  backdrop-filter: blur(2px);
}
.hud-dist { left: 12px; top: 12px; padding: 8px 14px 9px; transform: rotate(-1.2deg); }
.hud-dist .k { font-family: var(--hand); font-size: 14px; color: #8a7c61; }
.hud-dist .v { font-family: var(--hand); font-weight: 700; font-size: 34px; line-height: .95; color: #3d3527; }
.hud-dist .v small { font-size: 17px; margin-left: 1px; }
.hud-alt { left: 12px; top: 86px; padding: 5px 10px; display: flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700; color: #6f6350; }
.hud-alt svg { width: 14px; height: 14px; opacity: .7; }

.hud-btns { position: absolute; right: 12px; top: 12px; display: flex; gap: 8px; pointer-events: auto; }
.hud-btns .icon-btn { width: 40px; height: 40px; flex-basis: 40px; border-radius: 50%; background: rgba(255, 252, 243, .95); }

.pitch-gauge {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  width: 54px; padding: 10px 0 8px;
  border-radius: 16px;
  background: rgba(255, 252, 243, .95);
  border: 1.5px solid rgba(160, 148, 116, .4);
  box-shadow: 0 3px 0 rgba(150, 130, 90, .16);
  text-align: center;
}
.pitch-gauge .lab { font-family: var(--hand); font-size: 13px; color: #7d7159; }
.pitch-gauge .lab.up { color: #c4644f; }
.pitch-gauge .lab.down { color: #4f7fb0; }
.pitch-track {
  position: relative; width: 10px; height: 132px; margin: 6px auto;
  border-radius: 6px;
  background: linear-gradient(180deg, #f6e2d5 0%, #f4eddc 50%, #dfeaf5 100%);
  border: 1px solid rgba(150, 135, 100, .3);
}
.pitch-track::after { content: ''; position: absolute; left: -4px; right: -4px; top: 50%; height: 2px; background: rgba(140, 125, 95, .45); }
.pitch-mark {
  position: absolute; left: 50%; top: 50%; width: 22px; height: 8px;
  margin: -4px 0 0 -11px; border-radius: 4px;
  background: var(--blue); border: 1.5px solid #fff;
  box-shadow: 0 1px 3px rgba(40, 60, 90, .35);
  transition: top .08s linear;
}
.pitch-gauge .deg { font-size: 11px; font-weight: 700; color: #6d6250; }

.wind-card {
  position: absolute; left: 12px; bottom: calc(18px + env(safe-area-inset-bottom));
  padding: 8px 12px 9px; display: flex; align-items: center; gap: 9px;
  transform: rotate(.8deg);
}
.wind-card .k { font-family: var(--hand); font-size: 14px; color: #8a7c61; }
.wind-card .v { font-size: 13px; font-weight: 700; color: #4d5a6b; }
.wind-arrow { width: 28px; height: 28px; display: grid; place-items: center; }
.wind-arrow svg { width: 26px; height: 26px; transition: transform .3s; }

.thermal-toast {
  position: absolute; left: 50%; top: 24%; transform: translate(-50%, 0) scale(.9);
  padding: 8px 16px; border-radius: 999px;
  background: rgba(255, 233, 168, .95);
  border: 1.5px solid rgba(225, 185, 90, .8);
  font-family: var(--hand); font-weight: 700; font-size: 18px; color: #8a6413;
  opacity: 0; transition: opacity .2s, transform .2s;
  box-shadow: 0 4px 12px rgba(200, 160, 60, .25);
}
.thermal-toast.show { opacity: 1; transform: translate(-50%, -8px) scale(1); }

.fly-hint {
  position: absolute; left: 50%; bottom: 30%; transform: translateX(-50%);
  font-family: var(--hand); font-size: 17px; color: #4c4436;
  background: rgba(255, 252, 243, .88);
  padding: 5px 14px; border-radius: 999px; white-space: nowrap;
  opacity: 0; transition: opacity .3s;
  border: 1.5px dashed rgba(150, 135, 100, .4);
}
.fly-hint.show { opacity: 1; }

/* 발사 조준 */
.aim-layer { position: absolute; inset: 0; z-index: 7; pointer-events: none; }
.aim-band {
  position: absolute; left: 50%; bottom: 0; width: 3px; height: 0;
  transform: translateX(-50%);
  background: repeating-linear-gradient(180deg, rgba(91, 143, 214, .7) 0 6px, transparent 6px 12px);
  transition: height .07s;
}
.aim-power {
  position: absolute; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: 210px; padding: 9px 12px 10px;
  border-radius: 16px;
  background: rgba(255, 252, 243, .95);
  border: 1.5px solid rgba(160, 148, 116, .4);
  box-shadow: 0 4px 0 rgba(150, 130, 90, .18);
  opacity: 0; transition: opacity .18s;
}
.aim-power.show { opacity: 1; }
.aim-power .bar { height: 12px; border-radius: 8px; background: #ece1c9; overflow: hidden; border: 1px solid rgba(150, 135, 100, .3); }
.aim-power .fill { height: 100%; width: 0%; border-radius: 8px; background: linear-gradient(90deg, #9fd3b8, #f2cf6b 55%, #f29b8e); transition: width .06s; }
.aim-power .row { display: flex; justify-content: space-between; font-size: 11px; color: #7d7159; margin-top: 5px; font-weight: 700; }
.aim-tip {
  position: absolute; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  font-family: var(--hand); font-size: 18px; color: #4d4433;
  white-space: nowrap; text-shadow: 0 1px 0 rgba(255, 255, 255, .8);
}

/* ---------- 결과 ---------- */
#result { background: rgba(246, 238, 218, .96); overflow-y: auto; }
.result-scroll { padding: 26px 18px calc(24px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 14px; min-height: 100%; justify-content: center; }
.result-card { text-align: center; padding: 22px 16px 20px; transform: rotate(-.5deg); }
.result-card .k { font-family: var(--hand); font-size: 19px; color: #8a7c61; }
.result-big { font-family: var(--hand); font-weight: 700; font-size: 68px; line-height: 1.02; color: #3d5c86; margin: 2px 0 4px; letter-spacing: -1px; white-space: nowrap; }
.result-big small { font-size: 30px; margin-left: 2px; }
.result-sub { font-family: var(--hand); font-size: 16px; color: #9a8c72; }
.result-badge {
  display: inline-flex; align-items: center; gap: 5px;
  margin-top: 8px; padding: 4px 12px; border-radius: 999px;
  font-size: 12px; font-weight: 700;
  background: #eef5e8; color: #4f7a45;
}
.result-badge.new { background: #fdf0cf; color: #96701a; }

.hint-card { display: flex; gap: 10px; align-items: flex-start; padding: 13px 14px; background: #eef6fb; border-color: rgba(130, 165, 195, .4); }
.hint-card .bulb { flex: 0 0 34px; width: 34px; height: 34px; border-radius: 50%; background: #fdf3d8; display: grid; place-items: center; }
.hint-card .bulb svg { width: 20px; height: 20px; }
.hint-card p { margin: 0; font-size: 13px; line-height: 1.5; color: #3f5566; word-break: keep-all; }

.meta-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.meta-card { padding: 12px 12px 13px; text-align: center; }
.meta-card .k { font-family: var(--hand); font-size: 14px; color: #8a7c61; }
.meta-card .v { font-family: var(--hand); font-weight: 700; font-size: 25px; color: #4c4436; white-space: nowrap; }
.meta-card .v.coin { color: #b8892a; }
.meta-card > small { display: block; font-size: 10.5px; color: #9a8c72; margin-top: 2px; }
.meta-card .v small { display: inline; font-size: 14px; margin-left: 1px; }

.rank-card { padding: 14px; text-align: center; }
.rank-card .region { font-family: var(--hand); font-size: 16px; color: #7a6c52; }
.rank-card .rank { font-family: var(--hand); font-weight: 700; font-size: 34px; color: var(--green-dark); }
.rank-card .rank small { font-size: 17px; }
.rank-card .note { font-size: 11px; color: #9a8c72; }

.result-actions { display: flex; flex-direction: column; gap: 9px; margin-top: 2px; }
.result-actions .row { display: flex; gap: 9px; }
.result-actions .row .btn { flex: 1; }

/* ---------- 상점 ---------- */
#shop, #rank { background: rgba(247, 240, 222, .98); }
.page-head { display: flex; align-items: center; gap: 10px; padding: 14px 14px 8px; }
.page-head h2 { font-size: 24px; color: #4d4231; }
.page-head .spacer { flex: 1; }
.page-body { flex: 1; overflow-y: auto; padding: 4px 14px calc(24px + env(safe-area-inset-bottom)); scrollbar-width: none; }
.page-body::-webkit-scrollbar { display: none; }

.tabs { display: flex; gap: 6px; padding: 4px 14px 10px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto; padding: 7px 14px; border-radius: 999px;
  background: var(--paper); border: 1.5px solid var(--line);
  font-family: var(--hand); font-size: 16px; font-weight: 700; color: #786a52;
  cursor: pointer; box-shadow: 0 2px 0 rgba(168, 150, 110, .16);
}
.tab.sel { background: #eaf2ff; border-color: var(--blue); color: #35629b; }

.shop-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.shop-item { padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.shop-item .nm { font-family: var(--hand); font-weight: 700; font-size: 17px; color: #544935; }
.shop-item .ds { font-size: 11px; line-height: 1.4; color: #96896f; min-height: 30px; }
.shop-item .row { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: auto; }
.shop-item .price { display: flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; color: #8a6a1c; }
.shop-item .price .coin-ico { width: 18px; height: 18px; font-size: 10px; }
.shop-item .mini-btn {
  padding: 6px 12px; border-radius: 10px; border: none;
  font-family: var(--hand); font-weight: 700; font-size: 15px;
  background: var(--blue); color: #fff; box-shadow: 0 3px 0 var(--blue-dark);
  cursor: pointer;
}
.shop-item .mini-btn.eq { background: #e8efe0; color: #4f7a45; box-shadow: 0 3px 0 rgba(127, 168, 106, .5); }
.shop-item .mini-btn.off { background: #efe7d3; color: #8a7c61; box-shadow: 0 3px 0 rgba(168, 150, 110, .35); }
.shop-item .swatch { height: 30px; border-radius: 10px; border: 1px solid rgba(150, 135, 100, .25); }
.shop-item .tags { display: flex; gap: 4px; flex-wrap: wrap; }

/* ---------- 랭킹 ---------- */
.profile-bar { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.profile-name {
  flex: 1; display: flex; align-items: center; gap: 8px;
  background: var(--paper); border: 1.5px solid var(--line); border-radius: 12px;
  padding: 9px 12px; font-family: var(--hand); font-size: 17px; font-weight: 700; color: #544935;
  cursor: pointer;
}
.profile-name .region-pill { margin-left: auto; font-size: 12px; color: #7a6c52; background: #f0e7d2; padding: 2px 8px; border-radius: 999px; font-family: var(--ui); font-weight: 700; }
.rank-list { display: flex; flex-direction: column; gap: 6px; }
.rank-row {
  display: flex; align-items: center; gap: 9px;
  padding: 10px 12px; border-radius: 12px;
  background: var(--paper); border: 1.5px solid var(--line);
  box-shadow: 0 2px 0 rgba(168, 150, 110, .12);
}
.rank-row.me { background: #eef5e8; border-color: rgba(127, 168, 106, .6); }
.rank-no { width: 30px; font-family: var(--hand); font-weight: 700; font-size: 19px; color: #8a7c61; text-align: center; }
.rank-no.top { color: #b8892a; }
.rank-nick { flex: 1; font-size: 13.5px; font-weight: 700; color: #4a4133; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-nick small { display: block; font-size: 10px; font-weight: 400; color: #9a8c72; }
.rank-dist { font-family: var(--hand); font-weight: 700; font-size: 19px; color: #3d5c86; }
.rank-dist small { font-size: 12px; }
.empty-note { text-align: center; padding: 28px 16px; font-family: var(--hand); font-size: 16px; color: #9a8c72; line-height: 1.5; }

/* ---------- 모달 ---------- */
.modal-back {
  position: absolute; inset: 0; z-index: 40;
  background: rgba(60, 52, 38, .35);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.modal-back.show { opacity: 1; pointer-events: auto; }
.modal {
  width: 100%; max-width: 360px; max-height: 84%;
  overflow-y: auto;
  padding: 18px 16px 16px;
  transform: translateY(10px) scale(.98); transition: transform .2s;
}
.modal-back.show .modal { transform: none; }
.modal h3 { font-size: 21px; color: #4d4231; margin-bottom: 10px; }
.modal .field { margin-bottom: 10px; }
.modal .field label { display: block; font-family: var(--hand); font-size: 15px; color: #7a6c52; margin-bottom: 4px; }
.modal input[type=text] {
  width: 100%; height: 42px; border-radius: 12px; border: 1.5px solid var(--line);
  background: #fffdf6; padding: 0 12px; font-family: var(--ui); font-size: 14px; color: var(--ink);
}
.region-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.region-grid button {
  padding: 7px 0; border-radius: 9px; border: 1.5px solid var(--line);
  background: #fffdf6; font-family: var(--hand); font-size: 14px; color: #6b5c42; cursor: pointer;
}
.region-grid button.sel { background: #eaf2ff; border-color: var(--blue); color: #35629b; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 8px 2px; font-size: 14px; }
.switch { width: 46px; height: 26px; border-radius: 999px; background: #ded3bb; position: relative; cursor: pointer; transition: background .18s; border: 1px solid rgba(150, 135, 100, .3); }
.switch.on { background: var(--green); }
.switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .18s; }
.switch.on::after { transform: translateX(20px); }

/* 튜토리얼 */
.tutorial {
  position: absolute; left: 14px; right: 14px;
  bottom: calc(84px + env(safe-area-inset-bottom));
  display: none; padding: 14px 16px 12px; z-index: 9;
}
.tutorial.show { display: block; }
.tutorial .step { font-size: 11px; color: #9a8c72; font-weight: 700; letter-spacing: .4px; }
.tutorial h4 { font-family: var(--hand); font-size: 19px; margin: 3px 0 5px; color: #4d4231; }
.tutorial p { margin: 0 0 10px; font-size: 12.5px; line-height: 1.5; color: #6b6150; }
.tutorial .tut-actions { display: flex; gap: 8px; justify-content: flex-end; }
.tutorial .mini-btn { padding: 7px 14px; border-radius: 10px; border: none; background: var(--blue); color: #fff; font-family: var(--hand); font-size: 16px; font-weight: 700; box-shadow: 0 3px 0 var(--blue-dark); cursor: pointer; }
.tutorial .mini-btn.ghost { background: transparent; color: #857963; box-shadow: none; }

.toast {
  position: absolute; left: 50%; top: 76px; transform: translate(-50%, -6px);
  background: rgba(70, 60, 42, .9); color: #fff;
  padding: 8px 16px; border-radius: 999px; font-size: 12.5px;
  opacity: 0; transition: opacity .2s, transform .2s; z-index: 50; pointer-events: none;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2.5px solid rgba(120, 110, 85, .25); border-top-color: #7a6a4d;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.fade-in { animation: fade .3s ease both; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

@media (max-height: 700px) {
  .preview-wrap { height: 170px; }
  .result-big { font-size: 56px; }
}
