* { box-sizing: border-box; }
:root { --cy: #29e7ff; --mg: #ff3fb4; --gold: #ffd36b; --ink: #07060f; --glass: rgba(10, 10, 26, .86); }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--ink); color: #fff;
  /* Latin web font first, then system fonts covering Cyrillic / Thai / CJK */
  font-family: 'Baloo 2', 'Nunito', system-ui, -apple-system, 'Segoe UI', 'Noto Sans', 'Noto Sans Thai', 'Leelawadee UI',
    'Hiragino Sans', 'Noto Sans JP', 'Apple SD Gothic Neo', 'Malgun Gothic', 'Noto Sans KR', 'PingFang SC', 'Microsoft YaHei', 'Noto Sans SC', sans-serif;
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent;
}
#viewport { position: fixed; inset: 0; }
#stage { position: absolute; left: 0; top: 0; width: 1280px; height: 720px; transform-origin: 0 0; overflow: hidden; }
#game { position: absolute; inset: 0; width: 1280px; height: 720px; touch-action: none; display: block; }

.overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  background: radial-gradient(ellipse at center, rgba(8, 6, 22, .55), rgba(3, 3, 10, .9));
  animation: fade .25s ease;
}
.overlay.hidden, .hidden { display: none !important; }
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes pop { from { transform: scale(.9); opacity: 0 } to { transform: scale(1); opacity: 1 } }
@keyframes flicker { 0%, 100% { opacity: 1 } 92% { opacity: 1 } 93% { opacity: .55 } 94% { opacity: 1 } 97% { opacity: .8 } }
@keyframes glow { 50% { filter: brightness(1.2); } }

.loader { text-align: center; font-size: 22px; color: #c7cbe0; }
.spin8 {
  width: 64px; height: 64px; margin: 0 auto 12px; border-radius: 50%; display: grid; place-items: center;
  background: radial-gradient(circle at 35% 30%, #555 0, #111 45%, #000 100%); color: #111; font-weight: 800; font-size: 22px;
  box-shadow: 0 0 24px var(--mg), 0 0 6px var(--cy); animation: rot 1.2s linear infinite; position: relative;
}
.spin8::before { content: ''; position: absolute; width: 30px; height: 30px; border-radius: 50%; background: #f4f1e8; }
.spin8 { z-index: 0; }
@keyframes rot { to { transform: rotate(360deg) } }

/* ---------------------------------------------------------------- menu */
.menu { justify-content: flex-start; padding-top: 30px; gap: 22px;
  background: linear-gradient(180deg, rgba(5, 4, 14, .72), rgba(5, 4, 14, .42) 45%, rgba(5, 4, 14, .9)); }
.menu-head { width: 1180px; display: flex; justify-content: space-between; align-items: center; }
.logo { display: flex; flex-direction: column; line-height: .82; animation: flicker 6s infinite; }
.logo .l1 { font-size: 64px; font-weight: 800; letter-spacing: 14px; color: #fff; text-shadow: 0 0 6px #fff, 0 0 18px var(--mg), 0 0 42px var(--mg), 0 0 70px var(--mg); }
.logo .l2 { font-size: 50px; font-weight: 800; letter-spacing: 8px; color: #e8fdff; text-shadow: 0 0 6px #fff, 0 0 16px var(--cy), 0 0 40px var(--cy); }
.profile { display: flex; align-items: center; gap: 14px; background: var(--glass); border: 1.5px solid rgba(41, 231, 255, .35);
  padding: 10px 16px; border-radius: 22px; box-shadow: 0 0 24px rgba(41, 231, 255, .15); }
.profile .av { width: 60px; height: 60px; border-radius: 50%; border: 2px solid var(--cy); box-shadow: 0 0 12px var(--cy); object-fit: cover; }
.pinfo { width: 220px; }
.pname { font-size: 20px; }
.rank { font-size: 14px; font-weight: 700; }
.xpbar { position: relative; height: 18px; border-radius: 9px; background: #1c1f3a; overflow: hidden; margin-top: 4px; }
.xpbar i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, var(--cy), var(--mg)); border-radius: 9px; }
.xpbar span { position: relative; font-size: 13px; font-weight: 800; padding-left: 8px; line-height: 18px; }
.wallet { font-size: 24px; background: rgba(20, 14, 40, .9); border: 1.5px solid rgba(255, 211, 107, .45); padding: 4px 16px; border-radius: 26px; white-space: nowrap; }
.wallet b { color: var(--gold); }
.wallet.small { font-size: 19px; padding: 2px 14px; }
.streak { font-size: 20px; background: rgba(60, 20, 8, .9); border: 1.5px solid rgba(255, 140, 60, .5); padding: 4px 12px; border-radius: 26px; }
.streak b { color: #ffb36b; }

.continue { background: linear-gradient(#34d399, #0e8a5f); font-size: 20px; animation: glow 1.6s ease-in-out infinite; }
.continue small { display: block; font-size: 14px; font-weight: 700; opacity: .9; }

.modes { display: grid; grid-template-columns: 1.5fr 1fr 1fr 1fr 1fr; gap: 16px; width: 1180px; margin-top: 8px; }
.mode {
  font: inherit; color: #fff; cursor: pointer; text-align: left; position: relative; overflow: hidden;
  min-height: 320px; padding: 18px; border-radius: 22px; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px;
  background-color: #090d1e;
  background-image: linear-gradient(180deg, rgba(5, 8, 22, .03) 5%, rgba(5, 8, 22, .15) 42%, rgba(5, 8, 22, .92) 83%, #050816 100%), var(--mode-art);
  background-size: cover; background-position: center;
  border: 2px solid var(--c, var(--cy));
  box-shadow: 0 0 22px color-mix(in srgb, var(--c, var(--cy)) 35%, transparent), inset 0 0 30px rgba(0, 0, 0, .5);
  transition: transform .15s, box-shadow .15s; animation: pop .35s ease both;
}
.mode:hover { transform: translateY(-5px); box-shadow: 0 0 36px color-mix(in srgb, var(--c, var(--cy)) 60%, transparent); }
.mode .mi { display: none; }
.mode b { font-size: 26px; line-height: 1.05; text-shadow: 0 2px 8px #050816, 0 0 12px var(--c, var(--cy)); overflow-wrap: anywhere; hyphens: auto; }
.mode small { font-size: 15px; color: #e0e5f3; line-height: 1.25; text-shadow: 0 2px 5px #050816; }
.mode.tour { --c: var(--mg); --mode-art: url('assets/mode-tour.webp'); }
.mode.nine { --c: var(--gold); --mode-art: url('assets/mode-nine.webp'); }
.mode.trick { --c: #7dff9a; --mode-art: url('assets/mode-trick.webp'); }
.mode.duo { --c: var(--cy); --mode-art: url('assets/mode-duo.webp'); }
.mode.practice { --c: #a45bff; --mode-art: url('assets/mode-practice.webp'); }
.mode.locked { filter: saturate(.7) brightness(.78); }

.menu-row { display: flex; gap: 12px; margin-top: 4px; }
.menu-row.small { justify-content: center; margin-top: 14px; }

.btn {
  font: inherit; font-weight: 800; font-size: 19px; color: #fff; border: 0; cursor: pointer;
  padding: 9px 24px 11px; border-radius: 14px; position: relative;
  box-shadow: 0 4px 0 rgba(0, 0, 0, .45), inset 0 1px 0 rgba(255, 255, 255, .25); transition: transform .08s, filter .15s;
}
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0, 0, 0, .45); }
.btn:disabled { filter: grayscale(1) brightness(.55); cursor: not-allowed; }
.btn.green { background: linear-gradient(#34d399, #0e8a5f); }
.btn.blue { background: linear-gradient(#3b9cff, #1c4fb8); }
.btn.purple { background: linear-gradient(#c05bff, #6a1fb0); }
.btn.dark { background: linear-gradient(#3a3f5c, #1a1d33); }
.btn.gold { background: linear-gradient(#ffd36b, #c28a12); color: #2b1a00; }
.btn.red { background: linear-gradient(#ff4d6d, #a3122f); }
.btn.icon { padding: 9px 15px 11px; }
.btn.off { opacity: .45; }
.btn .badge {
  position: absolute; top: -8px; right: -8px; min-width: 24px; height: 24px; padding: 0 6px; border-radius: 12px;
  background: #ef4444; color: #fff; font-size: 15px; line-height: 24px; box-shadow: 0 0 10px #ef4444;
}
.link { font: inherit; background: none; border: 0; color: #aab4de; text-decoration: underline; cursor: pointer; font-size: 14px; }

/* ---------------------------------------------------------------- panels & modals */
.panel { width: 1200px; max-height: 690px; background: var(--glass); border: 1.5px solid rgba(255, 63, 180, .35); border-radius: 26px;
  padding: 18px 24px; box-shadow: 0 0 40px rgba(255, 63, 180, .15), 0 30px 80px rgba(0, 0, 0, .6); animation: pop .25s ease both; }
.panel-head { display: flex; align-items: center; gap: 16px; }
.panel-head h2 { margin: 0; font-size: 36px; flex: 1; text-shadow: 0 0 14px var(--mg); }
.sub { margin: 4px 0 10px; color: #aab4de; font-size: 16px; }
.modal {
  background: linear-gradient(180deg, rgba(24, 18, 52, .97), rgba(10, 8, 26, .97)); border: 1.5px solid rgba(41, 231, 255, .35);
  border-radius: 24px; padding: 24px 34px; min-width: 440px; max-width: 900px; text-align: center;
  box-shadow: 0 0 40px rgba(41, 231, 255, .15), 0 30px 80px rgba(0, 0, 0, .6); animation: pop .25s ease both;
}
.modal.wide { width: 860px; }
.modal h2 { margin: 0 0 6px; font-size: 38px; line-height: 1.1; }
.stack { display: flex; flex-direction: column; gap: 12px; margin-top: 10px; }
.actions { display: flex; gap: 12px; justify-content: center; margin-top: 16px; }
.save-note { font-size: 14px; max-width: 340px; margin: 12px auto 0; }

.venues { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.venue {
  font: inherit; color: #fff; text-align: left; cursor: pointer; position: relative; height: 262px; border-radius: 18px; overflow: hidden;
  border: 2px solid var(--a); background: #0b0a18 center/cover; padding: 0; display: flex; flex-direction: column; justify-content: flex-end;
  box-shadow: 0 0 18px color-mix(in srgb, var(--a) 40%, transparent); transition: transform .15s; animation: pop .3s ease both;
}
.venue:hover:not(.locked) { transform: translateY(-4px); }
.venue .shade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0, 0, 0, .1), rgba(4, 3, 12, .92) 70%); }
.venue .in { position: relative; padding: 10px 14px 12px; }
.venue .num { position: absolute; top: 10px; left: 12px; font-size: 13px; font-weight: 800; background: rgba(0, 0, 0, .6); padding: 1px 10px; border-radius: 10px; }
.venue .opp { position: absolute; top: 10px; right: 10px; width: 64px; height: 64px; border-radius: 50%; border: 2px solid var(--b); box-shadow: 0 0 12px var(--b); object-fit: cover; }
.venue .city { font-size: 24px; font-weight: 800; line-height: 1.05; text-shadow: 0 0 10px var(--a); overflow-wrap: anywhere; }
.venue .vn { font-size: 14px; color: #c7cbe0; }
.venue .tag { font-size: 12.5px; font-style: italic; color: #ffe7a8; line-height: 1.2; margin-top: 2px; opacity: .9;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.venue .money { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0 8px; margin-top: 4px; font-size: 15px; font-weight: 700; }
.venue .money b { color: var(--gold); }
.venue .ai { font-size: 13px; color: #aab4de; }
.venue .rec { font-size: 13px; color: #7dff9a; }
.venue.locked { cursor: not-allowed; filter: grayscale(.55) brightness(.78); }
.venue.locked::after { content: '🔒'; position: absolute; top: 22px; left: 0; right: 0; text-align: center; font-size: 40px; }
.venue.poor .money b.fee { color: #ff6b81; }

.tricks { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; }
.trickc { font: inherit; color: #fff; cursor: pointer; border-radius: 16px; padding: 10px; text-align: center; min-height: 150px;
  background: rgba(20, 16, 44, .8); border: 1.5px solid rgba(125, 255, 154, .35); transition: transform .12s; animation: pop .3s ease both; }
.trickc:hover:not(.locked) { transform: translateY(-3px); border-color: #7dff9a; }
.trickc canvas { width: 100%; height: auto; aspect-ratio: 200 / 110; border-radius: 8px; display: block; }
.trickc .tn { font-size: 16px; font-weight: 800; margin-top: 4px; }
.trickc .ts { color: var(--gold); letter-spacing: 2px; }
.trickc .ts .off { color: #3a3f5c; }
.trickc .tr { font-size: 12px; color: #aab4de; }
.trickc.locked { cursor: not-allowed; filter: grayscale(.85) brightness(.5); }

.tabs { display: flex; gap: 10px; margin: 10px 0 4px; }
.tab { font: inherit; font-weight: 800; font-size: 17px; color: #c7cbe0; cursor: pointer; background: rgba(20, 16, 44, .85);
  border: 1.5px solid rgba(255, 255, 255, .14); border-radius: 12px; padding: 4px 18px; }
.tab.on { color: #fff; border-color: var(--cy); box-shadow: inset 0 -3px 0 var(--cy), 0 0 12px rgba(41, 231, 255, .3); }
.shop-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; max-height: 520px; overflow: auto; padding-right: 4px; }
.item { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; background: rgba(255, 255, 255, .05);
  border: 1.5px solid rgba(255, 255, 255, .08); border-radius: 14px; padding: 8px 14px; }
.item.eq { border-color: var(--cy); box-shadow: 0 0 12px rgba(41, 231, 255, .25); }
.item canvas { display: block; width: 100%; height: 26px; }
.item .nm { font-size: 19px; font-weight: 800; }
.item .nm small { font-size: 13px; color: #aab4de; font-weight: 700; margin-left: 6px; }
.stat { display: grid; grid-template-columns: 92px 1fr; gap: 6px; align-items: center; font-size: 13px; color: #aab4de; }
.stat .pips { display: flex; gap: 3px; }
.stat .pips i { width: 20px; height: 7px; border-radius: 3px; background: #2a2d4a; }
.stat .pips i.on { background: linear-gradient(90deg, var(--cy), var(--mg)); }
.swatch { width: 100%; height: 34px; border-radius: 8px; border: 1px solid rgba(255, 255, 255, .15); }
.item .btn { font-size: 16px; padding: 6px 14px 8px; min-width: 118px; }

.list { display: grid; gap: 10px; margin-top: 12px; text-align: left; }
.row { display: grid; grid-template-columns: 44px 1fr auto; gap: 14px; align-items: center; background: rgba(255, 255, 255, .05); border-radius: 14px; padding: 8px 14px; }
.row .ic { font-size: 28px; text-align: center; }
.row .nm { font-size: 19px; font-weight: 800; }
.row .ds { color: #aab4de; font-size: 14px; }
.prog { height: 8px; border-radius: 4px; background: #2a2d4a; overflow: hidden; margin-top: 4px; }
.prog i { display: block; height: 100%; background: linear-gradient(90deg, var(--cy), var(--mg)); }
.row .btn { font-size: 16px; padding: 6px 14px 8px; min-width: 120px; }

.howto { text-align: left; font-size: 20px; line-height: 1.35; margin: 8px 0; padding-left: 24px; }
.howto li { margin: 4px 0; }
.keys { color: #aab4de; font-size: 17px; }
kbd { background: #2a2d4a; border-radius: 6px; padding: 0 7px; margin: 0 2px; font-family: inherit; font-weight: 800; color: #fff; }

.spinpad { position: relative; width: 240px; height: 240px; margin: 10px auto; border-radius: 50%; cursor: crosshair; touch-action: none;
  background: radial-gradient(circle at 36% 30%, #fff 0, #ecebe4 40%, #a9a8a0 100%); box-shadow: 0 0 30px rgba(41, 231, 255, .5), inset -10px -14px 30px rgba(0, 0, 0, .25); }
.spinpad::before, .spinpad::after { content: ''; position: absolute; background: rgba(0, 0, 0, .12); }
.spinpad::before { left: 0; right: 0; top: 50%; height: 1px; }
.spinpad::after { top: 0; bottom: 0; left: 50%; width: 1px; }
.spinpad .ring { position: absolute; border: 2px dashed rgba(255, 63, 180, .7); border-radius: 50%; }
.spinpad .dot { position: absolute; width: 26px; height: 26px; margin: -13px 0 0 -13px; border-radius: 50%; background: #e0233c; box-shadow: 0 0 10px #e0233c; pointer-events: none; }
.spin-labels { display: flex; justify-content: center; gap: 16px; color: #aab4de; font-size: 14px; }

.stars { font-size: 56px; letter-spacing: 8px; line-height: 1; margin: 4px 0 6px; }
.stars span { display: inline-block; color: var(--gold); text-shadow: 0 0 16px var(--gold); animation: pop .4s ease both; }
.stars span.off { color: #2a2d4a; text-shadow: none; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 10px 0; }
.stats div { background: rgba(255, 255, 255, .06); border-radius: 12px; padding: 6px 10px; }
.stats b { display: block; font-size: 26px; color: #e8fdff; }
.stats small { color: #aab4de; font-size: 13px; }
.reward { font-size: 26px; font-weight: 800; display: flex; gap: 18px; justify-content: center; }
.reward .c { color: var(--gold); }
.reward .x { color: var(--cy); }
.reward .n { color: #ff6b81; }
.result-extra { font-size: 16px; color: #d6dcf7; display: grid; gap: 4px; margin-top: 6px; }
.result-extra .q { color: #7dff9a; }
.result-extra .goal { color: var(--gold); }
.result-extra .lv { color: var(--mg); font-weight: 800; font-size: 20px; }
.win h2 { color: var(--gold); text-shadow: 0 0 20px var(--gold); }
.lose h2 { color: #ff6b81; text-shadow: 0 0 20px #ff3f6b; }

.toast {
  position: absolute; top: 112px; left: 0; right: 0; margin: 0 auto; width: max-content; max-width: 1100px; z-index: 20; text-align: center;
  background: rgba(10, 8, 26, .95); border: 1.5px solid var(--gold); color: #fff; font-weight: 800; font-size: 19px;
  padding: 9px 22px; border-radius: 16px; box-shadow: 0 0 20px rgba(255, 211, 107, .35); animation: pop .3s ease both; pointer-events: none;
}
.tip { position: absolute; left: 330px; top: 116px; z-index: 15; width: 620px; text-align: center;
  background: rgba(10, 8, 26, .94); border: 2px solid var(--cy); border-radius: 18px; padding: 10px 18px 6px;
  box-shadow: 0 0 26px rgba(41, 231, 255, .4); animation: pop .3s ease both; }
.tip p { margin: 0; font-size: 18px; font-weight: 700; line-height: 1.35; }

/* language picker */
#lang { z-index: 30; }
.langs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 12px; }
.btn.lang { display: flex; flex-direction: column; align-items: center; gap: 0; padding: 8px 10px 10px; font-size: 18px; line-height: 1.2; }
.btn.lang small { font-size: 12px; opacity: .7; }
.btn.lang.on { background: linear-gradient(#34d399, #0e8a5f); box-shadow: 0 0 16px rgba(52, 211, 153, .6), 0 4px 0 rgba(0, 0, 0, .45); }
.lang-btn .lang-code { font-size: 14px; font-weight: 800; vertical-align: middle; }
.menu-row .btn, .stack .btn, .actions .btn { max-width: 520px; }

#rotate { display: none; }
@media (orientation: portrait) and (max-width: 700px) and (pointer: coarse) {
  #rotate { display: block; position: fixed; left: 0; right: 0; bottom: 0; padding: 10px; text-align: center; z-index: 10;
    background: rgba(255, 63, 180, .95); color: #fff; font-weight: 800; }
}
@media (prefers-reduced-motion: reduce) {
  .continue, .overlay, .modal, .panel, .mode, .venue, .trickc, .toast, .tip, .logo { animation: none !important; }
}

/* phones: invisible hit-area padding around buttons (the 1280×720 stage is scaled down on small screens) */
@media (pointer: coarse) {
  .btn::after { content: ''; position: absolute; inset: -7px -5px; }
}
