:root {
  --bg: #0b1a33;
  --panel: rgba(10, 22, 44, 0.88);
  --line: rgba(160, 200, 255, 0.22);
  --text: #eef4ff;
  --muted: #9fb3d1;
  --accent: #ffb020;
  --accent2: #38c8ff;
  --good: #3ee08a;
  --bad: #ff5468;
  --radius: 14px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text);
  font-family: 'M PLUS Rounded 1c', system-ui, sans-serif; user-select: none; -webkit-user-select: none; }
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }
button { font-family: inherit; }
kbd { display: inline-block; padding: 1px 7px; border-radius: 6px; background: #1d3358; border: 1px solid #3d5c8c;
  border-bottom-width: 3px; font-family: 'Russo One', sans-serif; font-size: 0.8em; color: #fff; }

/* ---------- screens ---------- */
.screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 20; }
.screen.dim { background: rgba(3, 8, 20, 0.55); }
.title-wrap { text-align: center; }
.logo { font-family: 'Russo One', sans-serif; line-height: 0.9; text-shadow: 0 6px 30px rgba(0,0,0,.45); }
.logo .l1 { display: block; font-size: clamp(40px, 9vw, 96px); letter-spacing: 2px; color: #fff; }
.logo .l2 { display: block; font-size: clamp(56px, 14vw, 150px); background: linear-gradient(180deg, #ffd56a, #ff8a1f);
  -webkit-background-clip: text; background-clip: text; color: transparent; transform: skewX(-8deg); }
.tagline { margin: 6px 0 26px; font-size: clamp(14px, 2.6vw, 20px); color: #e0ecff; text-shadow: 0 2px 8px rgba(0,0,0,.6); }
.menu { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.btn { min-width: 240px; padding: 12px 22px; border-radius: 999px; border: 1px solid var(--line); cursor: pointer;
  background: rgba(15, 32, 62, 0.85); color: var(--text); font-size: 17px; font-weight: 800; transition: transform .12s, background .12s; }
.btn:hover { transform: translateY(-2px); background: rgba(30, 56, 100, 0.95); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(180deg, #ffbe3d, #ff8a1f); color: #2a1300; border: none; box-shadow: 0 6px 20px rgba(255, 140, 30, .35); }
.btn.big { font-size: 20px; padding: 14px 30px; }
.btn.small { min-width: 0; font-size: 14px; padding: 8px 16px; }
.btn.danger { background: #4a1420; border-color: #ff5468; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.title-foot { margin-top: 22px; color: #dbe7ff; font-weight: 800; text-shadow: 0 2px 6px rgba(0,0,0,.6); display: flex; gap: 6px; align-items: center; justify-content: center; }
.title-foot .sep { opacity: .5; margin: 0 6px; }
.coin-ico { display: inline-block; width: 16px; height: 16px; border-radius: 50%; vertical-align: -2px;
  background: radial-gradient(circle at 35% 35%, #fff3b0, #ffc31f 45%, #c98400); box-shadow: 0 0 0 2px #8a5a00 inset; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 18px 20px; max-height: calc(100vh - 32px);
  overflow-y: auto; backdrop-filter: blur(10px); box-shadow: 0 20px 60px rgba(0,0,0,.45); width: 100%; }
.panel.wide { max-width: 980px; }
.panel.small-panel { max-width: 320px; text-align: center; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.panel-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.panel-head h2 { margin: 0; font-size: 22px; flex: 1; }
.back { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: #13284a; color: #fff; font-size: 20px; cursor: pointer; }
.muted { color: var(--muted); }

/* hill cards */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.hill-card { position: relative; border-radius: var(--radius); padding: 14px; cursor: pointer; border: 2px solid transparent; min-height: 150px;
  background-size: cover; overflow: hidden; transition: transform .12s; }
.hill-card:hover { transform: translateY(-2px); }
.hill-card.sel { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255,176,32,.3); }
.hill-card.locked { filter: grayscale(.8) brightness(.6); cursor: not-allowed; }
.hill-card .hn { font-size: 20px; font-weight: 800; }
.hill-card .he { font-family: 'Russo One'; font-size: 12px; opacity: .8; letter-spacing: 2px; }
.hill-card .hk { margin-top: 8px; font-size: 13px; }
.hill-card .hb { margin-top: 8px; font-size: 14px; font-weight: 800; color: #ffe08a; }
.hill-card .lock { margin-top: 8px; font-size: 12px; color: #ffd0d0; }
.hill-card.day { background: linear-gradient(160deg, #3d8ee8, #a9d4ff); }
.hill-card.sunset { background: linear-gradient(160deg, #3b3b7a, #ff9a62); }
.hill-card.night { background: linear-gradient(160deg, #050818, #1d3a6b 60%, #2bd4a0); }
.hill-card .hn, .hill-card .he, .hill-card .hk { text-shadow: 0 2px 6px rgba(0,0,0,.5); }
.gate-row { display: flex; gap: 16px; align-items: center; margin: 18px 0; flex-wrap: wrap; }
.gate-row > div { flex: 1; min-width: 220px; }
.gate-title { font-weight: 800; font-size: 17px; }
.gate-title b { color: var(--accent); font-size: 22px; }
.gate-desc { color: var(--muted); font-size: 13px; margin-top: 4px; }
#gateRange { flex: 1; min-width: 200px; accent-color: var(--accent); height: 30px; }
#btnStart { display: block; margin: 0 auto; }

/* shop */
.tabs { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.tab { padding: 8px 16px; border-radius: 999px; border: 1px solid var(--line); background: #10213f; color: var(--muted); cursor: pointer; font-weight: 800; }
.tab.active { background: var(--accent2); color: #001a2a; border-color: transparent; }
.shop-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.shop-item { background: rgba(255,255,255,0.05); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.shop-item h4 { margin: 0; font-size: 16px; }
.shop-item p { margin: 0; font-size: 12px; color: var(--muted); flex: 1; }
.lv { display: flex; gap: 4px; }
.lv i { flex: 1; height: 8px; border-radius: 4px; background: #253a5e; }
.lv i.on { background: linear-gradient(90deg, #38c8ff, #3ee08a); }
.swatch { height: 46px; border-radius: 10px; position: relative; overflow: hidden; }
.shop-item.equipped { border-color: var(--good); }

/* achievements */
.ach-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.ach { display: flex; gap: 10px; align-items: center; padding: 10px; border-radius: 12px; background: rgba(255,255,255,0.04); border: 1px solid var(--line); }
.ach .ico { font-size: 26px; width: 40px; text-align: center; filter: grayscale(1); opacity: .4; }
.ach.done .ico { filter: none; opacity: 1; }
.ach.done { border-color: rgba(255, 200, 60, .5); background: rgba(255, 190, 40, .08); }
.ach .t { font-weight: 800; font-size: 14px; }
.ach .d { font-size: 12px; color: var(--muted); }
.ach .r { font-size: 12px; color: #ffd560; }
.stats-box { margin-top: 16px; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.stats-box div { background: rgba(255,255,255,0.04); border-radius: 10px; padding: 8px 10px; font-size: 12px; color: var(--muted); }
.stats-box b { display: block; font-size: 18px; color: #fff; }

/* ranking */
.rank-list { min-height: 200px; }
.rank-row { display: grid; grid-template-columns: 50px 1fr 100px 90px; gap: 8px; padding: 9px 12px; border-radius: 10px; align-items: center; }
.rank-row:nth-child(odd) { background: rgba(255,255,255,0.04); }
.rank-row.head { color: var(--muted); font-size: 12px; background: none; }
.rank-row .pos { font-family: 'Russo One'; font-size: 18px; }
.rank-row .dist { font-family: 'Russo One'; color: var(--accent); text-align: right; }
.rank-row .sc { text-align: right; color: var(--muted); font-size: 13px; }
.rank-row.me { outline: 2px solid var(--accent2); }

/* help */
.help-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.help-card { background: rgba(255,255,255,0.05); border-radius: 12px; padding: 12px 14px; }
.help-card h3 { margin: 0 0 6px; font-size: 16px; color: var(--accent); }
.help-card p { margin: 0; font-size: 13px; line-height: 1.8; }
.g { color: var(--good); }
.set-title { margin: 18px 0 8px; }
.settings { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; }
.settings label { display: flex; gap: 6px; align-items: center; font-weight: 800; }
.settings input[type=text] { background: #0d1d38; border: 1px solid var(--line); border-radius: 8px; color: #fff; padding: 6px 10px; font-family: inherit; width: 140px; }
.small-note { font-size: 13px; margin-top: 14px; }

/* result */
.panel.result { max-width: 520px; text-align: center; }
.res-status { font-family: 'Russo One'; font-size: 22px; letter-spacing: 2px; }
.res-status.ok { color: var(--good); }
.res-status.ng { color: var(--bad); }
.res-dist { font-family: 'Russo One'; font-size: 84px; line-height: 1; margin: 6px 0; background: linear-gradient(180deg, #fff, #9fd6ff);
  -webkit-background-clip: text; background-clip: text; color: transparent; }
.res-dist small { font-size: 30px; margin-left: 4px; }
.res-badges { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; min-height: 6px; }
.badge { padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 800; background: #1d3358; }
.badge.gold { background: linear-gradient(90deg, #ffcf4a, #ff9a1f); color: #2a1300; animation: pop .5s; }
.badge.blue { background: #1f7ad6; }
.badge.green { background: #19995a; }
@keyframes pop { 0% { transform: scale(.2); } 70% { transform: scale(1.2); } 100% { transform: scale(1); } }
.res-lines { margin: 12px auto; max-width: 360px; text-align: left; font-size: 14px; }
.res-lines div { display: flex; justify-content: space-between; padding: 4px 2px; border-bottom: 1px dashed rgba(255,255,255,.1); }
.res-lines span:last-child { font-weight: 800; }
.res-score { font-size: 18px; } .res-score b { font-family: 'Russo One'; font-size: 26px; color: var(--accent); }
.res-coins { font-size: 18px; margin: 6px 0; display: flex; align-items: center; justify-content: center; gap: 4px; }
.res-ach { display: flex; flex-direction: column; gap: 4px; margin: 8px 0; }
.res-ach div { background: rgba(255, 190, 40, .15); border: 1px solid rgba(255, 200, 60, .5); border-radius: 10px; padding: 6px; font-size: 13px; font-weight: 800; }
.res-submit { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: 10px 0; }
.res-submit input { background: #0d1d38; border: 1px solid var(--line); border-radius: 999px; color: #fff; padding: 8px 14px; font-family: inherit; width: 160px; }
.res-submit #submitMsg { width: 100%; font-size: 12px; }
.res-buttons { display: flex; flex-direction: column; gap: 8px; align-items: center; margin-top: 12px; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; font-weight: 800; }
.chip { background: rgba(8, 18, 38, 0.65); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: 14px;
  display: inline-flex; gap: 6px; align-items: center; backdrop-filter: blur(4px); }
.hud-tl { position: absolute; top: 12px; left: 12px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.hud-tr { position: absolute; top: 12px; right: 12px; display: flex; gap: 6px; }
.btn-mini { pointer-events: auto; cursor: pointer; color: #fff; font-size: 16px; }
#hudWind.head { color: var(--good); } #hudWind.tail { color: #ff8c9a; }
#hudCenter { position: absolute; top: 30%; left: 0; right: 0; text-align: center; font-family: 'Russo One', sans-serif;
  font-size: clamp(30px, 7vw, 64px); text-shadow: 0 4px 20px rgba(0,0,0,.5); }
#hudCenter .sub { display: block; font-family: 'M PLUS Rounded 1c'; font-size: clamp(14px, 2.4vw, 20px); margin-top: 6px; }
.flash { animation: flash .6s ease-out; }
@keyframes flash { 0% { transform: scale(1.8); opacity: 0; } 40% { transform: scale(.95); opacity: 1; } 100% { transform: scale(1); } }
.c-perfect { color: #ffd640; } .c-great { color: #3ee08a; } .c-good { color: #38c8ff; } .c-bad { color: #ff5468; }
#hudTrick { position: absolute; top: 18%; left: 0; right: 0; text-align: center; font-size: clamp(18px, 3.5vw, 30px); color: #fff;
  text-shadow: 0 3px 12px rgba(0,0,0,.6); }
#hudTrick .pts { color: var(--accent); font-family: 'Russo One'; }
#hudHint { position: absolute; bottom: 110px; left: 0; right: 0; text-align: center; font-size: 15px; color: #e8f1ff; text-shadow: 0 2px 8px rgba(0,0,0,.8); }
.hud-bottom { position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); display: flex; gap: 10px; align-items: flex-end; }
.stat { background: rgba(8, 18, 38, 0.65); border: 1px solid var(--line); border-radius: 14px; padding: 6px 14px; text-align: center; min-width: 96px; backdrop-filter: blur(4px); }
.stat .lbl { display: block; font-size: 10px; letter-spacing: 2px; color: var(--muted); }
.stat span:nth-child(2) { font-family: 'Russo One'; font-size: 26px; }
.stat .unit { font-size: 11px; margin-left: 3px; color: var(--muted); }
.stat.big { min-width: 150px; } .stat.big span:nth-child(2) { font-size: 40px; color: var(--accent); }
#balance { position: absolute; right: 18px; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; }
.bal-label { font-size: 11px; color: var(--muted); }
.bal-track { position: relative; width: 26px; height: 220px; border-radius: 13px; background: rgba(8, 18, 38, 0.7); border: 1px solid var(--line); overflow: hidden; }
#balZone { position: absolute; left: 0; right: 0; background: linear-gradient(180deg, rgba(62,224,138,.15), rgba(62,224,138,.65), rgba(62,224,138,.15)); }
#balCursor { position: absolute; left: -2px; right: -2px; height: 6px; margin-top: -3px; background: #fff; border-radius: 3px; box-shadow: 0 0 8px #fff; }
#balEff { font-family: 'Russo One'; font-size: 12px; }
#landInd { font-size: 11px; padding: 3px 6px; border-radius: 8px; background: #19995a; white-space: nowrap; }
#landInd.ng { background: #b8283a; }
#minimap { position: absolute; left: 12px; bottom: 14px; width: 220px; height: 110px; border-radius: 12px; background: rgba(8, 18, 38, 0.55); border: 1px solid var(--line); }

#toast { position: fixed; top: 70px; left: 50%; transform: translateX(-50%); z-index: 40; display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
.toast { background: linear-gradient(90deg, rgba(255, 190, 40, .95), rgba(255, 140, 30, .95)); color: #2a1300; padding: 10px 18px; border-radius: 999px;
  font-weight: 800; box-shadow: 0 8px 24px rgba(0,0,0,.35); animation: toastIn .35s ease-out; white-space: nowrap; }
@keyframes toastIn { from { transform: translateY(-20px); opacity: 0; } to { transform: none; opacity: 1; } }
#loading { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: var(--bg); z-index: 100;
  font-family: 'Russo One'; letter-spacing: 4px; font-size: 22px; }

/* touch */
#touch { position: fixed; inset: auto 0 0 0; height: 0; z-index: 15; }
#touch .tcb { pointer-events: auto; width: 64px; height: 64px; border-radius: 50%; border: 2px solid rgba(255,255,255,.35); background: rgba(10, 25, 50, .5);
  color: #fff; font-size: 22px; font-weight: 800; touch-action: none; }
#touch .tcb.active { background: rgba(56, 200, 255, .55); }
#touch .tcb.small { font-size: 10px; width: 58px; height: 58px; line-height: 1.1; }
#touch .tcb.jump { width: 88px; height: 88px; background: rgba(255, 150, 30, .55); font-family: 'Russo One'; font-size: 16px; }
.tc-left { position: fixed; left: 14px; bottom: 140px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.tc-row { display: flex; gap: 60px; }
.tc-right { position: fixed; right: 14px; bottom: 140px; display: grid; grid-template-columns: 62px 62px; gap: 6px; align-items: center; justify-items: center; }
.tc-right .jump { grid-column: span 2; }

@media (max-width: 700px) {
  .stat { min-width: 70px; padding: 4px 8px; } .stat span:nth-child(2) { font-size: 18px; } .stat.big { min-width: 100px; } .stat.big span:nth-child(2) { font-size: 28px; }
  #minimap { display: none; }
  .bal-track { height: 150px; }
  .rank-row { grid-template-columns: 34px 1fr 76px 64px; font-size: 13px; }
  .btn { min-width: 200px; }
  .res-dist { font-size: 60px; }
  #hudHint { bottom: 80px; font-size: 13px; }
  #balance { right: 8px; top: 40%; }
}
