:root {
    --bg: #0a1526;
    --ink: #16324f;
    --muted: #5f7590;
    --accent: #2f6fe0;
    --accent-2: #ffd21f;
    --gold: #ffc21f;
    --card: #ffffff;
    --line: rgba(43, 35, 80, 0.16);
    --emoji: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
    height: 100%;
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
    overflow: hidden;
    overscroll-behavior: none;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

#stage {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
    cursor: pointer;
}

/* ---------- HUD ---------- */
.hud {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 5;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 8px;
    padding: calc(10px + env(safe-area-inset-top)) calc(12px + env(safe-area-inset-right)) 0 calc(12px + env(safe-area-inset-left));
    pointer-events: none;
}
.hud-left { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.hud-right { display: flex; justify-content: flex-end; gap: 8px; }

.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    font-size: 16px;
    font-weight: 900;
    color: var(--ink);
    background: rgba(255, 255, 255, 0.86);
    border-radius: 999px;
    box-shadow: 0 3px 0 rgba(43, 35, 80, 0.14);
    font-variant-numeric: tabular-nums;
}
.pill.big { font-size: 22px; padding: 4px 14px 4px 10px; }
.pill .star { font-family: var(--emoji); font-size: 20px; line-height: 1; }
.pill.big.bump { animation: bump 0.45s ease-out; }
@keyframes bump {
    30% { transform: scale(1.35) rotate(-6deg); }
    60% { transform: scale(0.95); }
}

.tool {
    pointer-events: auto;
    position: relative;
    width: 42px; height: 42px;
    display: grid; place-items: center;
    padding: 0;
    color: var(--ink);
    background: rgba(255, 255, 255, 0.86);
    border: 0;
    border-radius: 50%;
    box-shadow: 0 3px 0 rgba(43, 35, 80, 0.14);
    cursor: pointer;
    touch-action: none;
}
.tool svg { width: 22px; height: 22px; fill: currentColor; overflow: visible; }
.tool .cross { display: none; }
.tool.muted .wave { display: none; }
.tool.muted .cross { display: inline; }
.tool:active { transform: scale(0.94); }

/* ---------- transient messages ---------- */
.banner {
    position: fixed;
    top: calc(84px + env(safe-area-inset-top));
    left: 0; right: 0;
    z-index: 4;
    text-align: center;
    font-family: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, sans-serif, var(--emoji);
    font-size: clamp(30px, 9vw, 56px);
    font-weight: 900;
    color: #fff;
    text-shadow: 0 3px 0 rgba(10, 10, 40, 0.5), 0 0 24px rgba(180, 140, 255, 0.95);
    opacity: 0;
    pointer-events: none;
}
.banner.show { animation: banner 1.9s ease-out; }
@keyframes banner {
    0% { opacity: 0; transform: scale(0.5) rotate(-6deg); }
    14% { opacity: 1; transform: scale(1.18) rotate(3deg); }
    26% { transform: scale(1) rotate(0); }
    78% { opacity: 1; transform: scale(1); }
    100% { opacity: 0; transform: scale(1.08); }
}

/* ---------- screens ---------- */
.screen {
    position: fixed;
    inset: 0;
    z-index: 10;
    display: flex;
    padding: 16px;
    background: rgba(3, 4, 18, 0.55);
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
    overflow-y: auto;
}
.card {
    width: min(420px, 100%);
    margin: auto;
    padding: 22px 22px 18px;
    text-align: center;
    background: var(--card);
    border-radius: 28px;
    box-shadow: 0 10px 0 rgba(43, 35, 80, 0.16), 0 24px 60px rgba(43, 35, 80, 0.3);
}

h1, h2 { margin: 0; font-weight: 900; letter-spacing: 0.01em; }
h1 {
    font-size: clamp(27px, 8.2vw, 38px);
    line-height: 1.05;
    background: linear-gradient(90deg, #12a150, #2f80ed 55%, #6a4fd6);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
h2 { font-size: 28px; margin-bottom: 10px; }

.tagline { margin: 6px 0 14px; color: var(--muted); font-size: 16px; font-weight: 700; }

.logo { display: block; width: 200px; height: 104px; margin: 0 auto 6px; border-radius: 18px; }

.howto {
    list-style: none;
    margin: 0 0 6px;
    padding: 0;
    text-align: left;
    font-size: 14px;
    line-height: 1.4;
    color: #4a4570;
}
.howto li { display: flex; gap: 10px; align-items: flex-start; padding: 4px 0; }
.howto strong { color: var(--ink); }
.dot { flex: none; width: 14px; height: 14px; margin-top: 3px; border-radius: 50%; }

.keys { margin: 12px 0 0; font-size: 12px; font-weight: 700; letter-spacing: 0.06em; color: var(--muted); }

.btn {
    display: block;
    width: 100%;
    margin-top: 10px;
    padding: 14px 16px;
    font: inherit;
    font-size: 18px;
    font-weight: 900;
    color: var(--ink);
    background: #f1f0f8;
    border: 0;
    border-radius: 18px;
    box-shadow: 0 4px 0 #d8d5ea;
    cursor: pointer;
    transition: transform 0.08s, filter 0.15s;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #d8d5ea; }
.btn:hover { filter: brightness(1.04); }
.btn:focus-visible, .tool:focus-visible, input:focus-visible { outline: 3px solid #2f9cf0; outline-offset: 2px; }
.btn.primary {
    padding: 16px;
    font-size: 22px;
    color: #fff;
    background: linear-gradient(180deg, #4fd384, #23a35a);
    box-shadow: 0 5px 0 #17703d;
    text-shadow: 0 2px 0 rgba(30, 10, 90, 0.4);
}
.btn.primary:active { box-shadow: 0 2px 0 #17703d; }
.btn.small { width: auto; margin: 0; padding: 0 16px; font-size: 14px; white-space: nowrap; background: #ffe7a3; box-shadow: 0 3px 0 #f0c64a; }
.btn:disabled { opacity: 0.5; cursor: default; }

/* ---------- finish screen ---------- */
.newbest {
    display: inline-block;
    margin-bottom: 6px;
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #4a3200;
    background: var(--gold);
    border-radius: 999px;
}
.final {
    font-size: clamp(54px, 17vw, 76px);
    font-weight: 900;
    line-height: 1;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
    text-shadow: 0 4px 0 rgba(47, 111, 224, 0.2);
}
.unit { margin: 2px 0 0; font-size: 14px; font-weight: 800; color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0; }
.stats div { padding: 10px 4px; background: #f6f5fb; border-radius: 16px; }
.stats b { display: block; font-size: 20px; }
.stats span { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }

.save { display: flex; gap: 8px; }
.save input {
    flex: 1;
    min-width: 0;
    height: 46px;
    padding: 0 14px;
    font: inherit;
    font-size: 16px;
    font-weight: 700;
    color: var(--ink);
    background: #fff;
    border: 2px solid #d8d5ea;
    border-radius: 14px;
    -webkit-user-select: text;
    user-select: text;
}
.save .btn { height: 43px; }

.note { min-height: 18px; margin: 10px 0 6px; font-size: 13px; font-weight: 600; color: var(--muted); }

.board { list-style: none; margin: 0 0 6px; padding: 0; text-align: left; font-size: 14px; font-weight: 700; }
.board li {
    display: grid;
    grid-template-columns: 30px 1fr auto;
    gap: 8px;
    align-items: center;
    padding: 7px 10px;
    border-radius: 12px;
    font-variant-numeric: tabular-nums;
}
.board li:nth-child(odd) { background: #f6f5fb; }
.board li.me { background: #fff0c2; outline: 2px solid var(--gold); }
.board .rank { font-weight: 900; color: var(--muted); }
.board li:nth-child(1) .rank { color: #e08a00; }
.board .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board .pts { font-weight: 900; }
.board li.empty { display: block; text-align: center; color: var(--muted); background: none; }

@media (max-height: 620px) {
    .card { padding: 14px 18px; }
    .logo { display: none; }
    .howto { font-size: 13px; margin-bottom: 8px; }
    .howto li { padding: 2px 0; }
    .btn { padding: 10px 14px; margin-top: 8px; }
    .btn.primary { padding: 12px; font-size: 20px; }
    .stats { margin: 10px 0; }
}

@media (prefers-reduced-motion: reduce) {
    .pill.big.bump { animation: none; }
}


/* ---------- Market Rush extras ---------- */
body { background: #0a1526; }
#stage { pointer-events: none; cursor: default; }
.card { color: var(--ink); }
.howto .dot { width: auto; height: auto; margin: 0; border-radius: 0; font-family: var(--emoji); font-size: 18px; line-height: 1.2; }
.logo { display: flex; justify-content: center; gap: 8px; width: auto; height: auto; margin-bottom: 4px; font-family: var(--emoji); font-size: 44px; line-height: 1.2; }
.logo span { animation: bob 2.4s ease-in-out infinite; }
.logo span:nth-child(2) { animation-delay: 0.3s; }
.logo span:nth-child(3) { animation-delay: 0.6s; }
@keyframes bob { 50% { transform: translateY(-6px) rotate(-6deg); } }
.btn small { display: block; margin-top: 2px; font-size: 12px; font-weight: 700; opacity: 0.85; text-shadow: none; }
.btn.ghost { background: transparent; box-shadow: none; color: var(--muted); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.card.wide { width: min(600px, 100%); }
.card h3 { margin: 14px 0 6px; font-size: 13px; font-weight: 900; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); text-align: left; }
.micon { font-family: var(--emoji); font-size: 50px; line-height: 1.1; margin-bottom: 4px; }
.bigstars { margin: 2px 0 6px; font-family: var(--emoji); font-size: 38px; letter-spacing: 4px; }
.keys.fake { margin-top: 6px; font-weight: 600; letter-spacing: 0; }
.tool.sound { position: fixed; top: calc(8px + env(safe-area-inset-top)); right: calc(10px + env(safe-area-inset-right)); z-index: 30; width: 38px; height: 38px; }
.tool.sound svg { width: 20px; height: 20px; }
.eqchart { display: block; width: 100%; height: auto; background: #f3f6fd; border-radius: 14px; }
.final.neg { color: #c43a31; }
.ledger { margin: 8px 0; }
.lrow { display: flex; justify-content: space-between; padding: 5px 10px; font-size: 14px; font-weight: 700; border-radius: 8px; }
.lrow:nth-child(odd) { background: #f3f6fd; }
.lrow .pos { color: #12824a; }
.lrow .neg { color: #c43a31; }

/* desk */
.desk { position: fixed; inset: 0; z-index: 4; display: flex; flex-direction: column; gap: 7px; width: min(820px, 100%); margin: 0 auto; padding: calc(8px + env(safe-area-inset-top)) calc(10px + env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) calc(10px + env(safe-area-inset-left)); color: #fff; }
.top { display: flex; align-items: center; gap: 7px; padding-right: 46px; }
.top .tool { flex: none; width: 38px; height: 38px; }
.top .tool svg { width: 20px; height: 20px; }
.top .title { flex: 1; min-width: 0; line-height: 1.2; }
.top .title b, .top .title span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: ui-rounded, system-ui, var(--emoji); }
.top .title b { font-size: 15px; font-weight: 900; }
.top .title span { font-size: 12px; font-weight: 700; color: #a9c4e6; }
.top .pill { flex: none; padding: 3px 9px; font-size: 14px; font-weight: 900; color: #0a1526; background: rgba(255, 255, 255, 0.9); white-space: nowrap; font-variant-numeric: tabular-nums; font-family: ui-rounded, system-ui, var(--emoji); }
.pill.eq.up { background: #3ddc84; }
.pill.eq.down { background: #ff8a8a; }
.top .pill.low { color: #fff; background: #e5484d; }
.goalbar { position: relative; height: 8px; background: rgba(255, 255, 255, 0.14); border-radius: 4px; overflow: hidden; }
.goalbar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #ffd23f, #3ddc84); transition: width 0.2s; }
.goalbar u { position: absolute; top: 0; bottom: 0; left: 43.5%; width: 2px; background: rgba(255, 255, 255, 0.7); }
.goalbar u + u { left: 69.5%; }

.news { display: grid; gap: 5px; min-height: 96px; align-content: start; }
.story { position: relative; display: flex; align-items: center; gap: 9px; padding: 7px 10px 9px; background: #f4f7ff; border-left: 6px solid #8b93a7; border-radius: 12px; color: #14233b; overflow: hidden; }
.story.empty { justify-content: center; background: rgba(255, 255, 255, 0.1); border: 0; color: #c9d8ee; font-weight: 700; }
.story.s-times { border-left-color: #2f80ed; }
.story.s-tv { border-left-color: #f2a51a; }
.story.s-talk { border-left-color: #b06bff; background: #f6efff; }
.story.s-gov { border-left-color: #12a150; }
.story.shock { background: #fff3c9; }
.story.old { opacity: 0.62; padding-top: 4px; padding-bottom: 6px; }
.story.old b { font-size: 12.5px; }
.story.true { box-shadow: inset 0 0 0 2px #12a150; }
.story.false { box-shadow: inset 0 0 0 2px #e5484d; }
.sicon { flex: none; font-family: var(--emoji); font-size: 24px; }
.stext { flex: 1; min-width: 0; line-height: 1.2; }
.stext b { display: block; font-size: 14.5px; font-weight: 900; }
.stext small { font-size: 11.5px; font-weight: 700; color: #5b6b85; font-family: ui-rounded, system-ui, var(--emoji); }
.chk { flex: none; width: 40px; height: 36px; padding: 0; font-size: 18px; font-family: var(--emoji); background: #dfe7f7; border: 0; border-radius: 10px; cursor: pointer; }
.chk:disabled { opacity: 0.3; }
.life { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(0, 0, 0, 0.06); }
.life i { display: block; height: 100%; background: #8fb4ee; }

.chartbox { position: relative; flex: 1; min-height: 90px; display: flex; flex-direction: column; background: rgba(8, 18, 34, 0.72); border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 16px; overflow: hidden; }
.sel { display: flex; justify-content: space-between; gap: 8px; padding: 6px 10px 2px; font-size: 14px; }
.sel b { font-weight: 900; white-space: nowrap; font-family: ui-rounded, system-ui, var(--emoji); font-variant-numeric: tabular-nums; }
.sel span { min-width: 0; font-size: 12.5px; font-weight: 700; color: #a9c4e6; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chart { flex: 1; display: block; width: 100%; min-height: 0; height: 100%; }
.floats { position: absolute; left: 0; right: 0; bottom: 20px; height: 0; text-align: center; pointer-events: none; }
.float { position: absolute; left: 0; right: 0; bottom: 0; font-size: 26px; font-weight: 900; text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8); animation: rise 1.2s ease-out forwards; }
.float.up { color: #3ddc84; }
.float.down { color: #ff7a7a; }
@keyframes rise { to { transform: translateY(-70px); opacity: 0; } }

.list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.list.n3, .list.n5, .list.n6 { grid-template-columns: repeat(3, 1fr); }
.co { position: relative; display: grid; grid-template-columns: auto 1fr; grid-template-areas: "i n" "p p" "h h"; align-items: center; gap: 0 5px; min-width: 0; min-height: 64px; padding: 5px 8px; font: inherit; text-align: left; color: #fff; background: rgba(255, 255, 255, 0.09); border: 2px solid transparent; border-radius: 13px; cursor: pointer; touch-action: manipulation; }
.co.on { border-color: #ffd23f; background: rgba(255, 255, 255, 0.16); }
.co.long { box-shadow: inset 0 -4px 0 #3ddc84; }
.co.short { box-shadow: inset 0 -4px 0 #ff8a5c; }
.ci { grid-area: i; font-family: var(--emoji); font-size: 18px; }
.cn { grid-area: n; font-size: 12px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.price { grid-area: p; justify-self: start; font-size: 15px; font-weight: 900; font-variant-numeric: tabular-nums; }
.chg { grid-area: p; justify-self: end; font-size: 11.5px; font-weight: 800; color: #a9c4e6; font-variant-numeric: tabular-nums; }
.hold { grid-area: h; min-height: 13px; font-size: 11px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.co .up { color: #3ddc84; }
.co .down { color: #ff8a8a; }
.co kbd { display: none; }

.deal { display: grid; gap: 6px; }
.tools { display: flex; gap: 6px; }
.tl { flex: 1; height: 36px; padding: 0 6px; font: inherit; font-size: 14px; font-weight: 900; color: #fff; background: rgba(255, 255, 255, 0.12); border: 0; border-radius: 11px; cursor: pointer; white-space: nowrap; font-family: ui-rounded, system-ui, var(--emoji); touch-action: manipulation; }
.tl.on { color: #0a1526; background: #ffd23f; }
.tl.stop.on { background: #7fd4ff; }
.tl.info { display: grid; place-items: center; flex: 0 0 auto; padding: 0 12px; background: transparent; cursor: default; }
.btns { display: grid; grid-template-columns: 1.3fr 1.3fr 0.8fr; gap: 7px; }
.dbtn { height: 58px; font: inherit; font-size: 20px; font-weight: 900; color: #fff; border: 0; border-radius: 16px; cursor: pointer; touch-action: manipulation; }
.dbtn.buy { background: #18a957; box-shadow: 0 4px 0 #0d6b36; }
.dbtn.sell { background: #e0434f; box-shadow: 0 4px 0 #8f1f29; }
.dbtn.close { font-size: 15px; background: #4a5d7a; box-shadow: 0 4px 0 #2c3a50; }
.dbtn:active:not(:disabled) { transform: translateY(3px); box-shadow: none; }
.dbtn:disabled { opacity: 0.35; cursor: default; }

.msg { position: fixed; top: calc(62px + env(safe-area-inset-top)); left: 50%; z-index: 8; width: max-content; max-width: min(520px, calc(100% - 24px)); padding: 8px 14px; font-size: 14px; font-weight: 800; color: #0a1526; text-align: center; background: #ffe9a8; border-radius: 14px; transform: translateX(-50%); opacity: 0; transition: opacity 0.25s; pointer-events: none; font-family: ui-rounded, system-ui, var(--emoji); }
.msg.show { opacity: 1; }
.banner { top: 40%; z-index: 9; font-size: clamp(28px, 8vw, 54px); color: #fff; text-shadow: 0 3px 0 rgba(0, 0, 0, 0.6), 0 0 24px rgba(61, 220, 132, 0.95); }

/* career */
.zone { margin: 0 0 12px; text-align: left; }
.zone h3 { margin: 6px 2px; }
.lvls { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.lvl { display: grid; place-items: center; padding: 8px 2px 6px; font: inherit; color: #fff; background: linear-gradient(180deg, #2fbf71, #178a4c); border: 0; border-radius: 14px; box-shadow: 0 3px 0 #0e5e33; cursor: pointer; }
.lvl.z1 { background: linear-gradient(180deg, #3b8de0, #2563b0); box-shadow: 0 3px 0 #173f73; }
.lvl.z2 { background: linear-gradient(180deg, #6a4fd6, #4329a0); box-shadow: 0 3px 0 #29186a; }
.lvl b { font-size: 18px; font-weight: 900; }
.lvl small { font-family: var(--emoji); font-size: 10px; letter-spacing: -1px; line-height: 1.2; min-height: 12px; }
.lvl.locked { color: #9aa3c4; background: #e7e9f3; box-shadow: none; cursor: default; }

@media (max-width: 420px) { .top .pill { font-size: 12.5px; padding: 2px 7px; } .top .title b { font-size: 13.5px; } .top .title span { font-size: 11px; } }
@media (max-height: 520px) {
    .logo { display: none; }
    .desk { width: 100%; display: grid; grid-template-columns: 1.1fr 1fr; grid-template-rows: auto auto 1fr auto; gap: 5px 9px; }
    .top, .goalbar { grid-column: 1 / -1; }
    .news { grid-column: 1; grid-row: 3; min-height: 0; overflow: hidden; align-self: start; }
    .story.old { display: none; }
    .chartbox { grid-column: 1; grid-row: 3 / 5; margin-top: 66px; }
    .list { grid-column: 2; grid-row: 3; align-content: start; }
    .co { min-height: 46px; padding: 3px 7px; }
    .deal { grid-column: 2; grid-row: 4; }
    .dbtn { height: 46px; font-size: 17px; }
    .tl { height: 30px; }
}
@media (prefers-reduced-motion: reduce) { .logo span { animation: none; } }
