/* Starlight Tycoon — mobile-first game shell */
@font-face {
  font-family: 'Fredoka';
  src: url('/fonts/fredoka.woff2') format('woff2-variations'), url('/fonts/fredoka.woff2') format('woff2');
  font-weight: 300 700; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --ink: #fff;
  --ink-2: #cdbcff;
  --night: #0d0726;
  --violet: #6b3cf5;
  --violet-2: #9a6bff;
  --panel: rgba(44, 22, 112, .72);
  --panel-edge: rgba(176, 140, 255, .55);
  --gold-1: #ffe76e; --gold-2: #ffb21c; --gold-3: #c46f00;
  --blue-1: #5fc4ff; --blue-2: #2a6cf0; --blue-3: #1a3f9e;
  --purple-1: #b884ff; --purple-2: #7a3bf0; --purple-3: #4a1d9e;
  --red-1: #ff7a86; --red-2: #e8304a; --red-3: #93152a;
  --radius: 22px;
  --font: 'Fredoka', 'PingFang TC', 'Noto Sans TC', 'Microsoft JhengHei', system-ui, sans-serif;
}
:lang(zh-Hans) { --font: 'Fredoka', 'PingFang SC', 'Noto Sans SC', 'Microsoft YaHei', system-ui, sans-serif; }

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font); color: var(--ink);
  background: var(--night) url('/img/bg.webp') center / cover fixed;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
img, svg { display: block; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--gold-1); outline-offset: 3px; }

/* ---------- phone on phones, phone frame everywhere else ---------- */
.stage { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; gap: 64px; }
.phone { position: relative; width: 100%; height: 100vh; height: 100dvh; }
.app {
  position: relative; height: 100%; overflow-x: hidden; overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: #150b3d url('/img/bg.webp') center top / cover;
}
.pc-side { display: none; }

@media (min-width: 561px) {
  body { background-attachment: fixed; }
  .phone {
    flex: none; width: 430px; height: min(932px, calc(100vh - 48px)); height: min(932px, calc(100dvh - 48px));
    position: relative; padding: 10px; border-radius: 52px;
    background: linear-gradient(160deg, #4b36a8, #1c1150 45%, #2d1d73);
    box-shadow: 0 0 0 2px rgba(190, 160, 255, .45), 0 30px 80px rgba(0, 0, 0, .6), 0 0 120px rgba(120, 70, 255, .35);
  }
  .app { border-radius: 42px; scrollbar-width: none; }
  .app::-webkit-scrollbar { display: none; }
}
@media (min-width: 960px) {
  .pc-side { display: flex; flex-direction: column; align-items: center; width: 340px; text-align: center; }
}
.pc-logo { width: 340px; height: auto; filter: drop-shadow(0 8px 24px rgba(120, 70, 255, .6)); }
.pc-title { font-size: 34px; font-weight: 700; margin: 8px 0 22px; color: var(--gold-1); text-shadow: 0 3px 0 rgba(0,0,0,.35), 0 0 18px rgba(255, 200, 60, .5); }
.qr-card {
  padding: 22px 22px 18px; border-radius: 28px; background: var(--panel); border: 2px solid var(--panel-edge);
  box-shadow: 0 0 40px rgba(140, 90, 255, .45), inset 0 0 30px rgba(140, 90, 255, .25);
}
.qr-card img { width: 220px; height: 220px; border-radius: 14px; margin: 0 auto; }
.qr-card p { margin: 14px 0 8px; font-size: 18px; font-weight: 600; }
.qr-url { display: inline-block; padding: 6px 16px; border-radius: 999px; background: rgba(0,0,0,.3); color: var(--ink-2); font-size: 15px; }

/* sideways phone */
.rotate { display: none; }
@media (orientation: landscape) and (max-height: 500px) and (pointer: coarse) {
  .rotate {
    display: flex; position: fixed; inset: 0; z-index: 100; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
    background: rgba(13, 7, 38, .96); text-align: center; padding: 24px;
  }
  .rotate svg { width: 72px; height: 72px; fill: none; stroke: var(--gold-1); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; animation: tilt 1.8s ease-in-out infinite; }
  .rotate p { margin: 0; font-size: 22px; font-weight: 600; }
}
@keyframes tilt { 0%, 30% { transform: rotate(90deg); } 60%, 100% { transform: rotate(0); } }

/* ---------- shared pieces ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 16px 0 12px; border-radius: 999px;
  border: 2px solid var(--panel-edge); background: rgba(40, 20, 100, .75); font-weight: 600; font-size: 16px;
  box-shadow: 0 0 14px rgba(140, 90, 255, .45);
}
.pill svg, .chip-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; }

.btn {
  display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; text-decoration: none;
  border-radius: 26px; font-weight: 700; letter-spacing: .3px; border: 0; transition: transform .08s, box-shadow .08s;
}
.btn:active { transform: translateY(4px); }
.btn-gold {
  color: #3d1a00; background: linear-gradient(180deg, var(--gold-1), var(--gold-2));
  box-shadow: 0 6px 0 var(--gold-3), 0 0 28px rgba(255, 196, 50, .65), inset 0 2px 0 rgba(255,255,255,.7);
  text-transform: uppercase;
}
.btn-gold:active { box-shadow: 0 2px 0 var(--gold-3), 0 0 18px rgba(255, 196, 50, .5), inset 0 2px 0 rgba(255,255,255,.7); }
.btn-big { height: 78px; font-size: 32px; margin-top: 18px; }
.btn-big svg { width: 34px; height: 34px; fill: #3d1a00; }
.btn-ghost {
  height: 52px; margin-top: 16px; font-size: 18px; font-weight: 600; color: var(--ink);
  background: rgba(40, 20, 100, .78); border: 2px solid var(--panel-edge); box-shadow: 0 0 18px rgba(140, 90, 255, .5);
}
.btn-ghost img { width: 30px; height: 30px; border-radius: 9px; }
.btn-small { height: 44px; width: auto; padding: 0 22px; font-size: 16px; display: inline-flex; }

.f1 { fill: #fff; }
.f2 { fill: rgba(255, 255, 255, .32); }
.win { fill: #3b2a9a; stroke: #bfe6ff; stroke-width: 2; }
.flame { fill: #ffd23f; }
.hilt { fill: none; stroke: #fff; stroke-width: 5; stroke-linecap: round; }
.step-red .f1, .tile-red .f1, .tab-red .f1 { fill: #ffe9ec; }
.coin { fill: #ffc229; stroke: #fff2a8; stroke-width: 3; }
.coin-star { fill: #fff6c2; }

/* ---------- landing ---------- */
.landing {
  min-height: 100%; display: flex; flex-direction: column; align-items: center;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 16px calc(env(safe-area-inset-bottom, 0px) + 18px);
}
.topbar { width: 100%; display: flex; justify-content: space-between; }
.logo { width: 84%; max-width: 360px; height: auto; margin-top: 6px; filter: drop-shadow(0 6px 18px rgba(110, 60, 255, .7)); position: relative; z-index: 2; }
.hero-wrap { width: 112%; margin: -14% 0 -10%; position: relative; z-index: 1; pointer-events: none; }
.hero {
  width: 100%; height: auto;
  -webkit-mask-image: radial-gradient(closest-side, #000 72%, transparent 100%);
          mask-image: radial-gradient(closest-side, #000 72%, transparent 100%);
}
.tagline {
  position: relative; z-index: 2; margin: 0; padding: 12px 20px; width: 100%; text-align: center;
  font-size: 19px; font-weight: 600; line-height: 1.35; color: #fff1c4; font-style: italic; text-wrap: balance; word-break: keep-all; overflow-wrap: anywhere;
  border-radius: 18px; background: linear-gradient(90deg, rgba(60, 25, 140, .85), rgba(95, 40, 190, .9), rgba(60, 25, 140, .85));
  border: 2px solid rgba(255, 210, 110, .55); box-shadow: 0 0 22px rgba(150, 90, 255, .55);
}
:lang(zh-Hant) .tagline, :lang(zh-Hans) .tagline { font-style: normal; letter-spacing: .5px; }

.steps { list-style: none; margin: 22px 0 0; padding: 0; width: 100%; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.step {
  position: relative; display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 26px 6px 12px; border-radius: 20px; border: 2px solid rgba(255,255,255,.35);
}
.step-blue { background: linear-gradient(180deg, var(--blue-1), var(--blue-2)); box-shadow: 0 5px 0 var(--blue-3), 0 0 18px rgba(80, 170, 255, .5); }
.step-purple { background: linear-gradient(180deg, var(--purple-1), var(--purple-2)); box-shadow: 0 5px 0 var(--purple-3), 0 0 18px rgba(170, 110, 255, .5); }
.step-red { background: linear-gradient(180deg, var(--red-1), var(--red-2)); box-shadow: 0 5px 0 var(--red-3), 0 0 18px rgba(255, 90, 110, .5); }
.step-n {
  position: absolute; top: -12px; left: 50%; transform: translateX(-50%); width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; font-size: 16px; color: #2a1270; background: #fff; box-shadow: 0 2px 0 rgba(0,0,0,.25);
}
.step-ic { width: 46px; height: 46px; filter: drop-shadow(0 3px 0 rgba(0,0,0,.2)); }
.step b { margin-top: 6px; font-size: 18px; text-transform: uppercase; text-shadow: 0 2px 0 rgba(0,0,0,.25); }
.step small { margin-top: 4px; font-size: 12px; line-height: 1.3; color: rgba(255,255,255,.9); }

.banner {
  margin-top: 20px; width: 100%; display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 20px;
  background: var(--panel); border: 2px solid rgba(255, 210, 110, .55); box-shadow: 0 0 20px rgba(255, 190, 60, .3);
}
.banner svg { width: 44px; height: 44px; flex: none; }
.banner p { word-break: keep-all; overflow-wrap: anywhere; margin: 0; font-size: 16px; font-weight: 600; line-height: 1.35; color: #fff1c4; }
.rate { margin: 10px 0 0; font-size: 14px; color: var(--ink-2); }
.foot { margin-top: auto; padding-top: 22px; font-size: 12px; color: rgba(205, 188, 255, .75); text-align: center; }
.foot a { color: inherit; }

/* ---------- game shell ---------- */
.game { min-height: 100%; display: flex; flex-direction: column; }
.hud {
  position: sticky; top: 0; z-index: 5; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 6px;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 10px 8px;
  background: linear-gradient(180deg, rgba(13, 7, 38, .9), rgba(13, 7, 38, 0));
}
.hud-logo { width: 116px; height: auto; filter: drop-shadow(0 3px 10px rgba(110, 60, 255, .7)); }
.hud-right { display: flex; justify-content: flex-end; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 10px 0 6px; border-radius: 999px;
  background: rgba(30, 14, 80, .85); border: 2px solid var(--panel-edge); font-size: 14px; white-space: nowrap;
}
.chip > svg { width: 24px; height: 24px; }
.chip-fuel svg { fill: #4fc3ff; } .chip-fuel .drop { fill: #e9f7ff; }
.chip .bar { width: 44px; height: 8px; border-radius: 8px; background: rgba(255,255,255,.15); overflow: hidden; }
.chip .bar i { display: block; height: 100%; background: linear-gradient(90deg, #3fd0ff, #57f0c8); }
.chip-btn { width: 36px; padding: 0; justify-content: center; }

.ribbon {
  margin: 4px 14px 0; padding: 8px 12px; border-radius: 14px; text-align: center; font-size: 14px; font-weight: 600;
  color: #3d1a00; background: linear-gradient(180deg, var(--gold-1), var(--gold-2)); box-shadow: 0 3px 0 var(--gold-3);
}
.panes { flex: 1; padding: 18px 16px 24px; display: flex; flex-direction: column; align-items: center; text-align: center; }
.pane { width: 100%; }
.pane h2 { margin: 8px 0 16px; font-size: 34px; text-transform: uppercase; text-shadow: 0 3px 0 rgba(0,0,0,.35), 0 0 18px rgba(150, 100, 255, .8); }
.card {
  display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 26px 20px; border-radius: 26px;
  background: var(--panel); border: 2px solid var(--panel-edge); box-shadow: 0 0 30px rgba(140, 90, 255, .45), inset 0 0 26px rgba(140, 90, 255, .2);
}
.card p { word-break: keep-all; overflow-wrap: anywhere; margin: 0; font-size: 18px; line-height: 1.45; }
.tile { width: 96px; height: 96px; border-radius: 26px; display: grid; place-items: center; border: 2px solid rgba(255,255,255,.4); }
.tile svg { width: 60px; height: 60px; }
.tile-blue { background: linear-gradient(180deg, var(--blue-1), var(--blue-2)); box-shadow: 0 6px 0 var(--blue-3); }
.tile-purple { background: linear-gradient(180deg, var(--purple-1), var(--purple-2)); box-shadow: 0 6px 0 var(--purple-3); }
.tile-gold { background: linear-gradient(180deg, var(--gold-1), var(--gold-2)); box-shadow: 0 6px 0 var(--gold-3); }
.tile-red { background: linear-gradient(180deg, var(--red-1), var(--red-2)); box-shadow: 0 6px 0 var(--red-3); }
.soon { margin: 18px 0 0; font-size: 15px; color: var(--ink-2); }

.tabbar {
  position: sticky; bottom: 0; z-index: 5; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
  padding: 10px 10px calc(env(safe-area-inset-bottom, 0px) + 10px);
  background: linear-gradient(0deg, rgba(13, 7, 38, .95), rgba(13, 7, 38, .6));
}
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 6px; border-radius: 20px; text-decoration: none;
  font-weight: 700; font-size: 15px; text-transform: uppercase; border: 2px solid rgba(255,255,255,.3);
  text-shadow: 0 2px 0 rgba(0,0,0,.3); opacity: .82; transition: transform .1s, opacity .1s;
}
.tab svg { width: 34px; height: 34px; filter: drop-shadow(0 2px 0 rgba(0,0,0,.25)); }
.tab.on { opacity: 1; transform: translateY(-4px); border-color: #fff; }
.tab-blue { background: linear-gradient(180deg, var(--blue-1), var(--blue-2)); box-shadow: 0 5px 0 var(--blue-3); }
.tab-purple { background: linear-gradient(180deg, var(--purple-1), var(--purple-2)); box-shadow: 0 5px 0 var(--purple-3); }
.tab-gold { background: linear-gradient(180deg, var(--gold-1), var(--gold-2)); box-shadow: 0 5px 0 var(--gold-3); color: #3d1a00; text-shadow: none; }
.tab-gold .f1 { fill: #3d1a00; }
.tab-red { background: linear-gradient(180deg, var(--red-1), var(--red-2)); box-shadow: 0 5px 0 var(--red-3); }
.tab-blue.on { box-shadow: 0 5px 0 var(--blue-3), 0 0 22px rgba(80, 170, 255, .9); }
.tab-purple.on { box-shadow: 0 5px 0 var(--purple-3), 0 0 22px rgba(170, 110, 255, .9); }
.tab-gold.on { box-shadow: 0 5px 0 var(--gold-3), 0 0 22px rgba(255, 200, 60, .9); }
.tab-red.on { box-shadow: 0 5px 0 var(--red-3), 0 0 22px rgba(255, 90, 110, .9); }

/* ---------- language sheet and toast ---------- */
.sheet-bg { position: absolute; inset: 0; z-index: 20; border-radius: inherit; overflow: hidden; display: flex; align-items: flex-end; background: rgba(5, 2, 20, .6); }
.sheet {
  width: 100%; padding: 20px 18px calc(env(safe-area-inset-bottom, 0px) + 20px); border-radius: 28px 28px 0 0;
  background: #24125f; border-top: 2px solid var(--panel-edge); display: flex; flex-direction: column; align-items: stretch; gap: 10px;
}
.sheet h3 { margin: 0 0 6px; text-align: center; font-size: 20px; }
.lang-opt { height: 54px; border-radius: 18px; border: 2px solid var(--panel-edge); background: rgba(255,255,255,.06); font-size: 18px; font-weight: 600; }
.lang-opt[aria-pressed="true"] { background: linear-gradient(180deg, var(--purple-1), var(--purple-2)); border-color: #fff; }
.sheet .btn-ghost { width: 100%; margin-top: 4px; }

.toast {
  position: absolute; left: 50%; bottom: 110px; z-index: 30; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  max-width: 86%; padding: 12px 18px; border-radius: 16px; background: rgba(10, 5, 30, .92); border: 2px solid var(--panel-edge);
  font-size: 15px; text-align: center; transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.noscript { position: fixed; inset: auto 0 0; margin: 0; padding: 14px; text-align: center; background: #000; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
@media (min-width: 561px) { .sheet-bg { inset: 10px; border-radius: 42px; } }
@media (max-height: 760px) {
  .logo { width: 74%; }
  .hero-wrap { width: 88%; margin: -11% 0 -8%; }
  .btn-big { height: 68px; font-size: 28px; margin-top: 14px; }
}
