:root {
  --bg: #0b0d17; --panel: #131729; --panel2: #1a1f36; --line: #272d4c; --text: #e8ecff; --muted: #8b93b8;
  --up: #2ee86b; --down: #ff4d6d; --accent: #ffd23f; --violet: #9b6bff; --cyan: #2ce8f5;
  --pixel: 'Silkscreen', monospace; --sans: 'Inter', system-ui, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.4 var(--sans); overflow: hidden; -webkit-tap-highlight-color: transparent; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.muted { color: var(--muted); }
.up { color: var(--up); } .down { color: var(--down); }
.row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }

.screen { display: none; height: 100%; }
body[data-screen="home"] #home, body[data-screen="lobby"] #lobby { display: grid; place-items: center; overflow: auto; padding: 16px; }
body[data-screen="game"] #game { display: flex; flex-direction: column; }

.btn { background: var(--panel2); border: 2px solid var(--line); border-radius: 10px; padding: 10px 16px; font-weight: 800; transition: transform .08s, filter .15s; }
.btn:hover { filter: brightness(1.2); } .btn:active { transform: translateY(2px); }
.btn.big { font-size: 18px; padding: 14px 22px; width: 100%; }
.btn.go { background: var(--up); border-color: #1fb851; color: #06210f; box-shadow: 0 4px 0 #128a3b; }
.btn.buy { background: var(--up); border-color: #1fb851; color: #06210f; box-shadow: 0 4px 0 #128a3b; }
.btn.sell { background: var(--down); border-color: #d73755; color: #2a0610; box-shadow: 0 4px 0 #9c1f38; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 6px 12px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.icon-btn { background: none; border: 0; font-size: 20px; }
.chip { background: var(--panel2); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.chip.on { background: var(--accent); color: #241a00; border-color: var(--accent); }
.pill { background: var(--panel2); border-radius: 6px; padding: 1px 6px; font-size: 11px; font-weight: 800; text-transform: uppercase; }
.logo { display: inline-block; width: 32px; height: 32px; background: url(/assets/logos.png) 0 0 / 320px 320px; image-rendering: pixelated; flex: none; }
.logo.xl { width: 64px; height: 64px; background-size: 640px 640px; }

/* HOME */
#home { position: relative; }
.marquee { position: fixed; inset: auto 0 0 0; height: 72px; overflow: hidden; opacity: .5; pointer-events: none; }
.marquee-track { display: flex; gap: 16px; width: max-content; animation: scroll 60s linear infinite; padding: 4px; }
.marquee-track .logo { width: 64px; height: 64px; background-size: 640px 640px; }
@keyframes scroll { to { transform: translateX(-50%); } }
.home-card, .lobby-card { width: min(460px, 100%); background: var(--panel); border: 2px solid var(--line); border-radius: 20px; padding: 24px; display: flex; flex-direction: column; gap: 14px; text-align: center; position: relative; z-index: 1; margin-bottom: 80px; }
.brand-big { width: 96px; height: 96px; image-rendering: pixelated; margin: 0 auto; animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-6px) rotate(-3deg); } }
h1 { font: 700 54px/0.95 var(--pixel); margin: 0; letter-spacing: 2px; color: var(--accent); text-shadow: 4px 4px 0 #8a5a00, 0 0 30px #ffd23f55; }
.tag { margin: 0; font-size: 18px; font-weight: 800; }
.field { display: flex; flex-direction: column; gap: 4px; text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; }
input, select { background: var(--bg); border: 2px solid var(--line); border-radius: 10px; padding: 10px 12px; min-width: 0; }
input:focus, select:focus { outline: none; border-color: var(--violet); }
.home-card .row > * { flex: 1; }
.join { display: flex; gap: 6px; }
.join input { width: 80px; flex: 1; text-transform: uppercase; font-weight: 800; letter-spacing: 2px; text-align: center; }
.how { text-align: left; padding-left: 20px; margin: 0; color: var(--muted); display: grid; gap: 6px; }
.how b { color: var(--text); }
.fine { font-size: 11px; color: var(--muted); margin: 0; }

/* LOBBY */
.code { font: 700 56px var(--pixel); letter-spacing: 6px; color: var(--accent); }
.lobby-card h3 { margin: 6px 0 0; }
.plist { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; text-align: left; }
.plist li { background: var(--panel2); border-radius: 10px; padding: 8px 12px; display: flex; justify-content: space-between; }
.settings { display: grid; gap: 8px; text-align: left; }
.settings label { display: flex; justify-content: space-between; align-items: center; font-weight: 600; }
.stepper { display: flex; gap: 10px; align-items: center; }
.stepper button { width: 32px; height: 32px; border-radius: 8px; border: 2px solid var(--line); background: var(--panel2); font-weight: 800; }

/* GAME TOP */
.top { display: flex; align-items: center; gap: 14px; padding: 8px 14px; background: var(--panel); border-bottom: 2px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; font: 700 16px var(--pixel); color: var(--accent); }
.brand img { width: 28px; height: 28px; image-rendering: pixelated; }
.clock { display: flex; flex-direction: column; align-items: center; line-height: 1.1; }
.clock span { font-size: 11px; color: var(--muted); }
.clock b { font: 700 22px var(--pixel); }
.clock.hurry b { color: var(--down); animation: pulse .5s infinite alternate; }
.stat { display: flex; flex-direction: column; line-height: 1.1; }
.stat span { font-size: 11px; color: var(--muted); }
.stat b { font-size: 18px; font-weight: 800; }
.stat i { font-style: normal; font-size: 12px; font-weight: 800; }
.heat { margin-left: auto; width: 150px; }
.heat span { font-size: 11px; color: var(--muted); }
.heat .bar { height: 10px; background: var(--bg); border-radius: 6px; overflow: hidden; border: 1px solid var(--line); }
.heat i { display: block; height: 100%; width: 0; background: var(--up); transition: width .3s, background .3s; }
.heat.hot .bar { animation: pulse .4s infinite alternate; }
@keyframes pulse { to { opacity: .55; } }
.ticker { height: 26px; overflow: hidden; background: #070912; border-bottom: 1px solid var(--line); white-space: nowrap; }
.ticker-track { display: inline-flex; gap: 22px; padding: 4px 0; animation: scroll 120s linear infinite; font-weight: 800; font-size: 12px; }

/* FLOOR */
.floor { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(300px, 380px) 1fr minmax(280px, 340px); }
.col { min-height: 0; display: flex; flex-direction: column; gap: 10px; padding: 10px; overflow: hidden; }
.market { border-right: 2px solid var(--line); }
.side { border-left: 2px solid var(--line); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.tiles { flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); gap: 5px; align-content: start; padding-right: 2px; }
.tile { position: relative; border: 2px solid transparent; border-radius: 10px; padding: 5px 2px 4px; display: flex; flex-direction: column; align-items: center; gap: 2px; background: var(--panel2); font-size: 11px; line-height: 1.1; }
.tile b { font-weight: 800; letter-spacing: .5px; }
.tile span { font-weight: 800; font-size: 10px; }
.tile.sel { border-color: var(--accent); }
.tile.held::after { content: attr(data-held); position: absolute; top: 2px; right: 3px; font-size: 9px; font-weight: 800; background: var(--accent); color: #000; border-radius: 4px; padding: 0 3px; }
.tile.moon .logo { animation: shake .3s infinite; }
.tile.halt { filter: saturate(.2) brightness(.8); }
@keyframes shake { 25% { transform: rotate(-6deg); } 75% { transform: rotate(6deg); } }
.sector-head { grid-column: 1 / -1; font-weight: 800; color: var(--muted); font-size: 12px; margin-top: 6px; }

.trade { padding: 12px 16px; }
.stock-head { display: flex; align-items: center; gap: 14px; }
.names { flex: 1; min-width: 0; }
.names h2 { margin: 0; font-size: 22px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.names p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.price { text-align: right; display: flex; flex-direction: column; }
.price b { font: 700 28px var(--pixel); }
.price span { font-weight: 800; font-size: 16px; }
.badge { font-size: 11px; font-weight: 800; padding: 1px 6px; border-radius: 6px; background: var(--violet); color: #fff; margin-left: 4px; }
.chart-wrap { flex: 1; min-height: 160px; position: relative; background: #0a0c16; border: 2px solid var(--line); border-radius: 14px; overflow: hidden; }
#chart { position: absolute; inset: 0; width: 100%; height: 100%; }
.halted { position: absolute; inset: 0; display: none; place-items: center; font: 700 40px var(--pixel); color: var(--cyan); background: #2ce8f522; }
.halted.on { display: grid; }
.position { background: var(--panel); border-radius: 10px; padding: 8px 12px; font-weight: 600; }
.order { position: relative; display: flex; flex-direction: column; gap: 8px; }
.amts { display: flex; gap: 6px; flex-wrap: wrap; }
.amts button { flex: 1; min-width: 56px; background: var(--panel2); border: 2px solid var(--line); border-radius: 8px; padding: 6px 4px; font-weight: 800; }
.amts button.on { border-color: var(--accent); color: var(--accent); }
.buttons { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; }
.buttons .buy, .buttons .sell { font-size: 20px; padding: 12px; }
.hint { margin: 0; color: var(--muted); font-size: 12px; min-height: 17px; }
.frozen-ov { position: absolute; inset: -4px; display: none; place-items: center; background: #ff4d6dcc; border-radius: 12px; font-weight: 800; font-size: 18px; text-align: center; }
.frozen-ov.on { display: grid; }
.hand { display: flex; gap: 8px; align-items: stretch; flex-wrap: wrap; }
.cards { display: flex; gap: 8px; flex: 1; min-width: 0; }
.card { flex: 1; min-width: 0; background: linear-gradient(160deg, #3b2a73, #1d1838); border: 2px solid var(--violet); border-radius: 12px; padding: 6px 8px; text-align: left; display: flex; gap: 8px; align-items: center; }
.card .em { font-size: 24px; }
.card b { display: block; font-size: 13px; }
.card small { display: block; color: #c9c2ff; font-size: 11px; line-height: 1.2; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.card.empty { border-style: dashed; border-color: var(--line); background: none; color: var(--muted); justify-content: center; font-size: 12px; }
.rumor-btn { background: #3a2a10; border-color: #8a5a00; color: var(--accent); }

/* SIDE */
.panel { background: var(--panel); border-radius: 12px; padding: 8px 10px; display: flex; flex-direction: column; min-height: 0; }
.panel h3 { margin: 0 0 6px; font: 700 13px var(--pixel); color: var(--muted); }
.lb { flex: none; max-height: 34%; }
#lb { list-style: none; margin: 0; padding: 0; overflow-y: auto; display: grid; gap: 3px; }
#lb li { display: grid; grid-template-columns: 22px 1fr auto; gap: 6px; align-items: center; padding: 3px 6px; border-radius: 8px; font-size: 13px; }
#lb li.me { background: #ffd23f22; outline: 1px solid #ffd23f66; }
#lb .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
#lb .rk { font-weight: 800; color: var(--muted); }
#lb .spy { grid-column: 2 / -1; font-size: 11px; color: var(--cyan); }
#lb .hb { grid-column: 2 / -1; height: 3px; border-radius: 2px; background: var(--down); opacity: .7; }
.feed { flex: 3; }
#feed { overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.fi { padding: 5px 8px; border-radius: 8px; background: var(--panel2); font-size: 12.5px; border-left: 3px solid var(--line); animation: pop .3s; cursor: default; }
.fi[data-s] { cursor: pointer; }
.fi.news.up { border-left-color: var(--up); } .fi.news.down { border-left-color: var(--down); }
.fi.whale { border-left-color: var(--cyan); color: #bdf6ff; }
.fi.sec, .fi.margin { border-left-color: var(--down); background: #3a1020; }
.fi.debunk { border-left-color: var(--accent); background: #2e2610; }
.fi.card { border-left-color: var(--violet); background: #221a3d; }
.fi.bell { text-align: center; font-weight: 800; color: var(--accent); }
.fi.sys { color: var(--muted); background: none; padding: 2px 8px; }
.fi .early { background: var(--violet); color: #fff; font-weight: 800; font-size: 10px; border-radius: 4px; padding: 0 4px; margin-right: 4px; }
.fi .lg { width: 16px; height: 16px; background-size: 160px 160px; vertical-align: -3px; margin-right: 4px; }
@keyframes pop { from { transform: scale(.96); opacity: 0; } }
.chat { flex: 2; }
#chatLog { flex: 1; overflow-y: auto; font-size: 13px; display: flex; flex-direction: column; gap: 2px; }
#chatLog b { color: var(--accent); }
#chatLog .bot b { color: var(--cyan); }
.emotes { display: flex; gap: 2px; justify-content: space-between; margin: 6px 0; }
.emotes button { background: none; border: 0; font-size: 20px; padding: 2px; border-radius: 8px; }
.emotes button:hover { background: var(--panel2); transform: scale(1.2); }
#chatForm input { width: 100%; padding: 8px 10px; }
.tabs { display: none; }

/* MODALS */
.modal { position: fixed; inset: 0; background: #05060cbb; display: none; place-items: center; z-index: 20; padding: 16px; }
.modal.on { display: grid; }
.sheet { background: var(--panel); border: 2px solid var(--line); border-radius: 20px; padding: 22px; width: min(560px, 100%); max-height: 100%; overflow: auto; display: flex; flex-direction: column; gap: 12px; text-align: center; animation: pop .25s; }
.sheet.wide { width: min(720px, 100%); }
.sheet h2 { margin: 0; font: 700 24px var(--pixel); color: var(--accent); }
.draft { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.draft button { background: linear-gradient(160deg, #3b2a73, #1d1838); border: 2px solid var(--violet); border-radius: 16px; padding: 16px 10px; display: flex; flex-direction: column; gap: 6px; align-items: center; transition: transform .1s; }
.draft button:hover { transform: translateY(-4px) rotate(-1deg); border-color: var(--accent); }
.draft .em { font-size: 44px; }
.draft b { font-size: 16px; }
.draft small { color: #c9c2ff; }
.ropts { display: grid; gap: 8px; }
.ropts button { background: var(--panel2); border: 2px solid var(--line); border-radius: 10px; padding: 10px; text-align: left; font-weight: 600; }
.ropts button:hover { border-color: var(--accent); }
.ranks { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; text-align: left; }
.ranks li { display: grid; grid-template-columns: 34px 1fr auto auto; gap: 10px; align-items: center; background: var(--panel2); border-radius: 10px; padding: 8px 12px; font-weight: 600; }
.ranks li.me { outline: 2px solid var(--accent); }
.ranks .rk { font-size: 20px; text-align: center; }
.podium li:first-child { background: linear-gradient(90deg, #5a4300, var(--panel2)); font-size: 18px; }
.awards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.award { background: var(--panel2); border-radius: 12px; padding: 10px; text-align: left; display: flex; gap: 10px; align-items: center; }
.award .em { font-size: 30px; }
.award b { display: block; } .award small { color: var(--muted); }

/* TUTORIAL + HELP */
.btn.learn { background: var(--violet); border-color: #7a4ee0; color: #fff; box-shadow: 0 4px 0 #4b2c9c; }
.home-card.veteran .btn.learn { order: 10; background: transparent; box-shadow: none; font-size: 14px; padding: 8px; border-color: var(--line); color: var(--muted); }
.help-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; text-align: left; }
.help-grid div { background: var(--panel2); border-radius: 10px; padding: 10px; font-size: 13px; color: #c3c9e8; }
.help-grid b { display: block; color: var(--text); font-size: 14px; margin-bottom: 2px; }
#tut { display: none; position: fixed; inset: 0; z-index: 50; pointer-events: none; }
#tut.on { display: block; }
.tut-spot { position: fixed; border: 3px solid var(--accent); border-radius: 14px; box-shadow: 0 0 0 9999px rgba(5, 6, 12, .62), 0 0 24px #ffd23f88; transition: all .35s ease; animation: glow 1s ease-in-out infinite alternate; }
.tut-spot.none { left: 50% !important; top: 40% !important; width: 0 !important; height: 0 !important; border: 0; }
@keyframes glow { to { box-shadow: 0 0 0 9999px rgba(5, 6, 12, .62), 0 0 40px #ffd23fcc; } }
.tut-box { position: fixed; width: min(340px, calc(100vw - 32px)); background: #1d1838; border: 2px solid var(--violet); border-radius: 16px; padding: 14px 16px; pointer-events: auto; box-shadow: 0 12px 40px #000a; transition: top .35s ease, left .35s ease; animation: pop .25s; }
.tut-box h3 { margin: 0 0 6px; font-size: 18px; }
.tut-text { margin: 0 0 12px; color: #d9d4ff; line-height: 1.45; }
.tut-step { margin: 0 0 4px; font: 700 11px var(--pixel); color: var(--violet); }
.tut-actions { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.tut-wait { font-weight: 800; color: var(--accent); animation: pulse .6s infinite alternate; }

/* FX */
#fx { position: fixed; inset: 0; pointer-events: none; z-index: 30; overflow: hidden; }
.float { position: absolute; bottom: 60px; display: flex; flex-direction: column; align-items: center; animation: rise 2.4s ease-out forwards; }
.float .e { font-size: 44px; }
.float small { font-weight: 800; background: #000a; border-radius: 6px; padding: 0 6px; }
@keyframes rise { 0% { transform: translateY(20px) scale(.5); opacity: 0; } 15% { transform: translateY(0) scale(1.1); opacity: 1; } 100% { transform: translateY(-60vh) scale(1); opacity: 0; } }
.money { position: absolute; font: 700 28px var(--pixel); animation: rise 1.6s ease-out forwards; text-shadow: 2px 2px 0 #000; }
#toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; z-index: 40; pointer-events: none; }
.toast { background: #000e; border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px; font-weight: 600; animation: pop .2s; max-width: 90vw; }
.toast.bad { border-color: var(--down); }
#flash { position: fixed; inset: 0; pointer-events: none; z-index: 35; }
#flash.red { animation: flash 1s; }
#flash.gold { animation: flashg .8s; }
@keyframes flash { 0%, 40% { box-shadow: inset 0 0 0 9999px #ff1f4b44; } 100% { box-shadow: none; } }
@keyframes flashg { 0% { box-shadow: inset 0 0 120px 30px #ffd23f88; } 100% { box-shadow: none; } }
.shake { animation: shake .25s 3; }

@media (max-width: 1250px) and (min-width: 901px) {
  .floor { grid-template-columns: 250px 1fr 260px; }
  .tiles { grid-template-columns: repeat(auto-fill, minmax(54px, 1fr)); }
  .top { gap: 10px; } .brand span, .hide-sm { display: none; }
  .card small { display: none; }
}

/* PHONES */
@media (max-width: 900px) {
  .top { gap: 10px; padding: 6px 10px; flex-wrap: nowrap; }
  .brand span, .hide-sm, .code-chip { display: none; }
  .heat { width: 80px; }
  .floor { display: block; position: relative; }
  .col { position: absolute; inset: 0; display: none; border: 0; }
  body[data-tab="market"] .market, body[data-tab="trade"] .trade { display: flex; }
  body[data-tab="feed"] .side, body[data-tab="chat"] .side { display: flex; }
  body[data-tab="feed"] .chat { display: none; }
  body[data-tab="chat"] .lb, body[data-tab="chat"] .feed { display: none; }
  .tabs { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--panel); border-top: 2px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
  .tabs button { background: none; border: 0; padding: 10px 0; font-weight: 800; font-size: 12px; color: var(--muted); }
  body[data-tab="market"] [data-tab="market"], body[data-tab="trade"] [data-tab="trade"], body[data-tab="feed"] [data-tab="feed"], body[data-tab="chat"] [data-tab="chat"] { color: var(--accent); }
  .price b { font-size: 20px; } .names h2 { font-size: 17px; } .logo.xl { width: 48px; height: 48px; background-size: 480px 480px; }
  .card small { display: none; }
  .hand { flex-direction: column; }
  .card { padding: 4px 8px; }
  .card.empty { font-size: 0; }
  .card.empty::after { content: '+'; font-size: 16px; }
  .draft { grid-template-columns: 1fr; }
  .draft button { flex-direction: row; text-align: left; }
  .draft .em { font-size: 32px; }
  h1 { font-size: 42px; }
  .code { font-size: 44px; }
}
