:root {
  color-scheme: dark;
  --bg: #080c12;
  --panel: #101720;
  --panel-2: #151e2a;
  --line: #253143;
  --text: #f2f6fb;
  --muted: #8794a7;
  --accent: #58a9ff;
  --buy: #22c98b;
  --sell: #ff5c6a;
  --warning: #ffb44c;
  --radius: 16px;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: radial-gradient(circle at 50% -20%, #17263b 0, var(--bg) 38%);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, select { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.gateway {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: var(--bg);
}
.gateway-card { width: min(100%, 330px); }
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 20px;
  font-weight: 850;
  letter-spacing: -.03em;
}
.logo span {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--accent);
  color: #06101d;
  font-size: 19px;
  font-weight: 900;
}
.gateway-status { display: flex; align-items: center; gap: 8px; margin: 24px 0; color: var(--muted); font-size: 13px; }
.gateway-status i, .server-indicator i { width: 8px; height: 8px; border-radius: 50%; background: var(--warning); }
.gateway-status.online i, .server-indicator.online i { background: var(--buy); box-shadow: 0 0 10px rgba(34, 201, 139, .55); }
.gateway-status.offline i, .server-indicator.offline i { background: var(--sell); }
.gateway form { display: grid; gap: 10px; }
.gateway label, .field > span, .settings-card > label { color: var(--muted); font-size: 12px; }
input, select {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 11px;
  outline: none;
  background: #0c121b;
  color: var(--text);
  padding: 0 14px;
}
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(88, 169, 255, .12); }
.primary-button { min-height: 50px; border: 0; border-radius: 11px; background: var(--accent); color: #07111d; font-weight: 850; }
.text-button { padding: 0; border: 0; background: none; color: var(--accent); }
.gateway-error { min-height: 20px; margin-top: 12px; color: var(--sell); font-size: 12px; line-height: 1.45; }
.gateway-retry-button { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; margin-top: 8px; padding: 0 16px; }
.gateway-retry-button small { min-width: 28px; color: rgba(7, 17, 29, .68); font-size: 11px; }

.app-shell { min-height: 100vh; padding-bottom: 76px; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 66px;
  padding: 10px max(16px, calc((100vw - 1080px) / 2));
  border-bottom: 1px solid rgba(37, 49, 67, .8);
  background: rgba(8, 12, 18, .9);
  backdrop-filter: blur(18px);
}
.logo-button { border: 0; background: none; }
.top-account { display: flex; align-items: center; gap: 12px; text-align: right; }
.top-account strong, .top-account small { display: inline; }
.top-account small { margin-left: 4px; color: var(--muted); font-size: 10px; }
.server-connection { display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.server-indicator { display: grid; place-items: center; }
.top-account .server-ping { min-width: 31px; margin: 0; text-align: left; font-variant-numeric: tabular-nums; }
.server-ping.good { color: var(--buy); }
.server-ping.warning { color: var(--warning); }
.server-ping.slow { color: var(--sell); }
.avatar { display: grid; place-items: center; width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 50%; background: var(--panel-2); font-weight: 800; }

.content { width: min(100% - 28px, 1080px); margin: 0 auto; }
.view { display: none; padding: 28px 0; }
.view.active { display: block; }
.view-heading, .trade-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.view h1, .trade-heading h1 { margin: 4px 0 0; font-size: clamp(24px, 4vw, 34px); letter-spacing: -.04em; }
.eyebrow { color: var(--accent); font-size: 10px; font-weight: 850; letter-spacing: .14em; text-transform: uppercase; }
.search { width: 190px; min-height: 42px; }

.category-tabs, .segmented, .timeframes {
  display: flex;
  gap: 5px;
  padding: 4px;
  border-radius: 12px;
  background: #0c121b;
}
.category-tabs { margin-bottom: 14px; }
.category-tabs button, .segmented button, .timeframes button {
  min-height: 40px;
  padding: 0 20px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-weight: 750;
}
.category-tabs button.active, .segmented button.active, .timeframes button.active { background: var(--panel-2); color: var(--text); box-shadow: 0 2px 8px rgba(0,0,0,.25); }
.pair-header { display: grid; grid-template-columns: 1fr 1fr; padding: 11px 15px; color: var(--muted); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
.pair-header span:last-child { text-align: right; }
.pairs-list { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(16, 23, 32, .94); }
.pair-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  width: 100%;
  min-height: 67px;
  padding: 10px 15px;
  border: 0;
  border-bottom: 1px solid rgba(37,49,67,.65);
  background: transparent;
  color: var(--text);
  text-align: left;
}
.pair-row:last-child { border-bottom: 0; }
.pair-row:hover { background: var(--panel-2); }
.pair-row strong, .pair-row small { display: block; }
.pair-row small { margin-top: 4px; color: var(--muted); }
.pair-row .right { text-align: right; }
.positive { color: var(--buy) !important; }
.negative { color: var(--sell) !important; }
.empty-state { padding: 34px 16px; color: var(--muted); text-align: center; }

.trade-heading { display: grid; grid-template-columns: 44px 1fr auto; }
.back-button { width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 11px; background: var(--panel); color: var(--text); font-size: 20px; }
.market-badge { color: var(--accent); font-size: 10px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.instrument-price { text-align: right; }
.instrument-price strong, .instrument-price span { display: block; }
.instrument-price span { margin-top: 4px; font-size: 12px; }
.notifications-button { position: relative; width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 11px; background: var(--panel); color: var(--muted); cursor: pointer; }
.notifications-button span { font-size: 12px; }
.notifications-button b { position: absolute; top: -5px; right: -5px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 999px; background: var(--sell); color: #fff; font-size: 9px; line-height: 17px; }
.notifications-panel { position: fixed; z-index: 30; top: 66px; right: max(14px, calc((100vw - 1120px) / 2)); width: min(390px, calc(100vw - 28px)); max-height: min(560px, calc(100vh - 90px)); overflow: auto; padding: 13px; border: 1px solid var(--line); border-radius: 15px; background: rgba(11, 17, 25, .98); box-shadow: 0 18px 50px rgba(0,0,0,.42); }
.notifications-heading { display: flex; align-items: center; justify-content: space-between; padding: 2px 3px 10px; }
.notifications-heading button { border: 0; background: transparent; color: var(--muted); font-size: 22px; cursor: pointer; }
.notifications-list { display: grid; gap: 7px; }
.notification-item { padding: 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); cursor: pointer; }
.notification-item.unread { border-color: rgba(82, 167, 255, .34); background: rgba(82, 167, 255, .07); }
.notification-item span, .notification-item small { display: block; }
.notification-item span { font-size: 12px; line-height: 1.4; }
.notification-item small { margin-top: 5px; color: var(--muted); font-size: 9px; }
.chart-panel, .order-panel, .pair-position, .settings-card, .account-cards, .social-card, .tournament-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(16, 23, 32, .94);
}
.chart-panel { overflow: hidden; }
.chart-toolbar { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 64px; padding: 12px; }
.timeframes { width: max-content; margin: 0; }
.timeframes button { min-height: 32px; padding: 0 13px; font-size: 11px; }
.chart-toolbar-actions { display: flex; align-items: center; gap: 12px; }
.chart-position-pnl { min-width: 84px; text-align: right; font-size: 13px; }
.chart-settings { position: relative; }
.chart-settings-button { display: grid; place-items: center; width: 34px; height: 34px; padding: 0; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); color: var(--muted); font-size: 16px; }
.chart-settings-button:hover, .chart-settings-button[aria-expanded="true"] { border-color: var(--accent); background: rgba(88, 169, 255, .12); color: var(--accent); }
.chart-settings-menu { position: absolute; z-index: 6; top: 42px; right: 0; width: 190px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: #0c121b; box-shadow: 0 14px 34px rgba(0, 0, 0, .35); }
.chart-settings-menu > strong { display: block; margin-bottom: 14px; font-size: 12px; }
.chart-setting-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; color: var(--muted); font-size: 12px; cursor: pointer; }
.chart-setting-row input { position: relative; width: 36px; min-height: 20px; height: 20px; padding: 0; border-radius: 10px; appearance: none; background: var(--panel-2); cursor: pointer; }
.chart-setting-row input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 12px; height: 12px; border-radius: 50%; background: var(--muted); transition: transform .15s ease, background .15s ease; }
.chart-setting-row input:checked { border-color: var(--buy); background: rgba(34, 201, 139, .2); }
.chart-setting-row input:checked::after { transform: translateX(16px); background: var(--buy); }
.chart-wrap { position: relative; height: clamp(260px, 42vh, 430px); border-top: 1px solid var(--line); }
#candles-chart { display: block; width: 100%; height: 100%; user-select: none; }
.chart-message { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 12px; pointer-events: none; }
.order-panel { margin-top: 14px; padding: 16px; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; }
#order-type { grid-template-columns: repeat(3, 1fr); }
.order-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: block; margin-top: 14px; }
.field > span { display: flex; justify-content: space-between; margin-bottom: 8px; }
.field b { color: var(--text); }
.amount-control-row {
  display: grid;
  grid-template-columns: minmax(180px, 280px) repeat(3, minmax(76px, 108px));
  gap: 8px;
  align-items: stretch;
}
.amount-presets { display: contents; }
.amount-presets button {
  min-width: 0;
  min-height: 48px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}
.amount-presets button:hover, .amount-presets button:focus-visible { border-color: var(--accent); color: var(--text); outline: none; }
.trigger-label-mode { grid-template-columns: repeat(3, 1fr); min-height: 48px; }
.trigger-label-mode button { min-height: 40px; padding: 0 10px; }
input[type="range"] { min-height: 30px; padding: 0; accent-color: var(--accent); }
.trade-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }
.trade-button { min-height: 58px; border: 0; border-radius: 12px; color: #07100d; font-size: 16px; font-weight: 900; }
.trade-button.buy { background: var(--buy); }
.trade-button.sell { background: var(--sell); color: #19070a; }
.trade-button:disabled { cursor: not-allowed; filter: grayscale(.8); opacity: .45; }
.protection-button { width: 100%; min-height: 58px; margin-top: 18px; border: 0; border-radius: 12px; background: var(--accent); color: #07111d; font-size: 16px; font-weight: 900; }
.protection-button.stop-loss { background: var(--sell); color: #19070a; }
.protection-button:disabled { cursor: not-allowed; filter: grayscale(.8); opacity: .45; }
.trade-message { min-height: 20px; margin-top: 10px; color: var(--buy); font-size: 12px; }
.trade-message.error { color: var(--sell); }
.pair-position { margin-top: 14px; padding: 16px; }

.account-cards { display: grid; grid-template-columns: repeat(3, 1fr); margin-bottom: 28px; overflow: hidden; }
.account-cards > div { padding: 18px; }
.account-cards > div + div { border-left: 1px solid var(--line); }
.account-cards small, .account-cards strong { display: block; }
.account-cards small { color: var(--muted); font-size: 11px; }
.account-cards strong { margin-top: 7px; font-size: 18px; }
#portfolio-view h2 { margin: 24px 0 10px; color: var(--muted); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; }
.section-label { margin: 26px 0 10px; color: var(--muted); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; }
.item-list { display: grid; gap: 8px; }
.item-card { padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.item-card.market-link { cursor: pointer; }
.item-card.market-link:hover, .item-card.market-link:focus-visible { border-color: var(--accent); background: var(--panel-2); outline: none; }
.item-top, .item-detail { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.item-detail { margin-top: 8px; color: var(--muted); font-size: 11px; }
.order-result { display: grid; justify-items: end; gap: 5px; }
.order-pnl { padding: 4px 8px; border-radius: 7px; font-size: 10px; font-weight: 800; white-space: nowrap; }
.order-pnl.profit { background: rgba(34, 201, 139, .14); color: #7ce3bc; }
.order-pnl.loss { background: rgba(255, 91, 112, .14); color: #ff9baa; }
.order-pnl.flat { background: rgba(137, 153, 175, .12); color: var(--muted); }
.position-metrics { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; color: var(--muted); font-size: 11px; }
.position-metrics b { color: var(--text); font-weight: 700; }
.position-metrics .order-fee, .position-metrics .order-fee b { color: #ff9baa; }
.mini-button { min-height: 32px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); color: var(--text); }
.mini-button:disabled { cursor: not-allowed; opacity: .4; }
.orders-pagination { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 14px; }
.orders-pagination span { min-width: 88px; color: var(--muted); font-size: 11px; text-align: center; }

#settings-view { max-width: 620px; }
.settings-card { margin-bottom: 12px; padding: 18px; }
.settings-card select { margin-top: 10px; }
.settings-toggle { margin-top: 10px; }
.auto-protection-settings { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.auto-protection-settings > label > span:first-child { display: block; margin-bottom: 8px; color: var(--muted); font-size: 11px; }
.percent-input { position: relative; display: block; }
.percent-input input { padding-right: 38px; }
.percent-input b { position: absolute; top: 50%; right: 14px; color: var(--muted); font-size: 12px; transform: translateY(-50%); pointer-events: none; }
.setting-status { min-height: 16px; margin: 6px 0 -4px; color: var(--buy); font-size: 11px; }
.setting-status.error { color: var(--sell); }
.amount-preset-settings { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.amount-preset-settings input { min-width: 0; }
.setting-note { margin: 10px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.account-info span, .account-info strong, .account-info small { display: block; }
.account-info span, .account-info small, .account-info p { color: var(--muted); }
.account-info strong { margin-top: 8px; font-size: 20px; }
.account-info small { margin-top: 4px; word-break: break-all; }
.account-info p { margin: 18px 0 0; font-size: 12px; line-height: 1.55; }

.social-view, .competition-view { max-width: 820px; }
.social-grid { display: grid; grid-template-columns: minmax(210px, .72fr) 1.4fr; gap: 12px; }
.social-card { padding: 16px; }
.friend-code-card { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 5px 12px; }
.friend-code-card small { grid-column: 1 / -1; color: var(--muted); font-size: 11px; }
.friend-code-card strong { color: var(--accent); font-size: 22px; letter-spacing: .12em; }
.compact-form > label { display: block; margin-bottom: 8px; color: var(--muted); font-size: 11px; }
.inline-form { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.inline-form .primary-button { min-width: 112px; padding: 0 16px; }
.form-message { min-height: 17px; margin-top: 7px; color: var(--buy); font-size: 11px; }
.form-message.error { color: var(--sell); }
.friend-stats { display: flex; flex-wrap: wrap; gap: 7px 15px; margin-top: 9px; color: var(--muted); font-size: 11px; }
.friend-stats b { color: var(--text); }

.tournament-code-form { margin-bottom: 12px; }
.tournament-create { margin-bottom: 18px; }
.tournament-create > summary { cursor: pointer; color: var(--text); font-size: 14px; font-weight: 800; }
.tournament-create[open] > summary { margin-bottom: 4px; }
.tournament-name-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 10px; }
.compact-switch { display: flex; align-items: center; gap: 9px; min-height: 48px; margin-top: 14px; padding: 0 11px 0 13px; border: 1px solid var(--line); border-radius: 11px; background: #0c121b; color: var(--muted); cursor: pointer; }
.compact-switch span { font-size: 11px; font-weight: 750; white-space: nowrap; }
.compact-switch i { position: relative; width: 38px; height: 22px; border-radius: 999px; background: #263244; transition: background .18s ease; }
.compact-switch i::after { position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #91a0b3; content: ""; transition: transform .18s ease, background .18s ease; }
.compact-switch[aria-checked="true"] { border-color: rgba(82, 167, 255, .38); color: var(--text); }
.compact-switch[aria-checked="true"] i { background: rgba(82, 167, 255, .55); }
.compact-switch[aria-checked="true"] i::after { background: #fff; transform: translateX(16px); }
.competition-fields { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.tournament-pairs-field small { margin-top: 4px; color: var(--muted); font-size: 10px; line-height: 1.4; }
.tournament-pairs-field { margin-top: 12px; }
.tournament-pairs-field small { display: block; }
.time-settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.time-settings-grid fieldset { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0; padding: 12px; border: 1px solid var(--line); border-radius: 11px; }
.time-settings-grid legend { padding: 0 5px; color: var(--muted); font-size: 11px; }
.time-settings-grid label span { display: block; margin-bottom: 6px; color: var(--muted); font-size: 10px; }
.create-tournament-button { width: 100%; margin-top: 12px; }
.tournament-list-heading { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin: 26px 0 10px; }
.tournament-list-heading .section-label { margin: 0; }
.tournaments-list { display: grid; gap: 10px; }
.tournament-card { padding: 16px; }
.tournament-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.tournament-card-header h3 { margin: 0; font-size: 17px; }
.tournament-card-header small { display: block; margin-top: 5px; color: var(--muted); }
.status-badge { flex: 0 0 auto; padding: 5px 8px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 9px; font-weight: 850; letter-spacing: .08em; }
.status-badge.active { border-color: rgba(34,201,139,.45); color: var(--buy); }
.status-badge.finished { color: var(--accent); }
.status-badge.cancelled { border-color: rgba(255, 91, 112, .25); color: var(--sell); }
.tournament-metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 13px; }
.tournament-metrics > div { min-width: 0; padding: 9px; border-radius: 9px; background: #0c121b; }
.tournament-metrics small, .tournament-metrics strong { display: block; }
.tournament-metrics small { color: var(--muted); font-size: 9px; }
.tournament-metrics strong { margin-top: 4px; overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.tournament-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; }
.tournament-actions .primary-button { min-height: 38px; padding: 0 16px; }
.tournament-code { color: var(--accent); font-size: 11px; letter-spacing: .1em; }
.copy-tournament-code { min-height: 34px; padding: 0 10px; border: 1px solid rgba(82, 167, 255, .22); border-radius: 8px; background: rgba(82, 167, 255, .07); cursor: pointer; }
.copy-tournament-code:hover, .copy-tournament-code:focus-visible { border-color: var(--accent); outline: none; }
.copy-tournament-code span { margin-left: 4px; font-size: 13px; }
.tournament-rules { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tournament-rules span { padding: 5px 8px; border-radius: 7px; background: rgba(137, 153, 175, .08); color: var(--muted); font-size: 10px; }
.invite-controls { display: grid; grid-template-columns: minmax(140px, 1fr) auto; gap: 7px; width: min(100%, 360px); }
.invite-controls select { min-height: 38px; }
.standings { margin-top: 12px; border-top: 1px solid var(--line); }
.standings summary { padding-top: 12px; color: var(--muted); cursor: pointer; font-size: 11px; }
.standing-row { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid rgba(37,49,67,.5); }
.standing-row:last-child { border-bottom: 0; }
.standing-rank { color: var(--muted); font-weight: 800; text-align: center; }
.standing-row small { display: block; margin-top: 3px; color: var(--muted); font-size: 9px; }
.standing-score { text-align: right; }
.standing-score strong, .standing-score small { display: block; }
.archive-winners { margin-top: 12px; padding: 11px; border-radius: 10px; background: #0c121b; }
.archive-winners > small { display: block; margin-bottom: 7px; color: var(--muted); font-size: 9px; letter-spacing: .08em; text-transform: uppercase; }
.archive-winner { display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 8px; min-height: 32px; border-top: 1px solid rgba(37,49,67,.45); font-size: 11px; }
.archive-winner:first-of-type { border-top: 0; }
.archive-winner b:first-child { color: var(--accent); }
.archive-winner span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.archive-refund { color: var(--muted); font-size: 11px; }
.archive-tabs { margin-bottom: 14px; }
.live-tournament { margin: 0 0 14px; padding: 16px; border: 1px solid rgba(34,201,139,.35); border-radius: var(--radius); background: linear-gradient(145deg, rgba(34,201,139,.11), rgba(16,23,32,.96) 55%); }
.live-tournament-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.live-tournament-top h2 { margin: 3px 0 0; font-size: 20px; }
.live-tournament-top small { color: var(--buy); font-size: 10px; font-weight: 800; letter-spacing: .08em; }
.live-tournament-score { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0; }
.live-tournament-score div { padding: 10px; border-radius: 9px; background: rgba(8,14,21,.7); }
.live-tournament-score small, .live-tournament-score strong { display: block; }
.live-tournament-score small { color: var(--muted); font-size: 9px; }
.live-tournament-score strong { margin-top: 4px; font-size: 14px; }
.danger-button { min-height: 38px; padding: 0 15px; border: 1px solid rgba(255,91,112,.35); border-radius: 9px; background: rgba(255,91,112,.08); color: var(--sell); font-weight: 800; cursor: pointer; }
.tournament-mode-badge { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 8px; padding: 5px 8px; border-radius: 7px; background: rgba(34,201,139,.1); color: var(--buy); font-size: 10px; font-weight: 800; }
.toast-stack { position: fixed; z-index: 40; right: 14px; bottom: 88px; display: grid; gap: 8px; width: min(360px, calc(100vw - 28px)); pointer-events: none; }
.competition-toast { padding: 13px 14px; border: 1px solid rgba(82,167,255,.35); border-radius: 12px; background: rgba(13,20,30,.96); color: var(--text); box-shadow: 0 12px 34px rgba(0,0,0,.35); animation: toast-in .2s ease; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.bottom-nav {
  position: fixed;
  z-index: 12;
  left: 50%;
  bottom: max(12px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  width: min(calc(100% - 24px), 600px);
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(16, 23, 32, .94);
  box-shadow: 0 12px 40px rgba(0,0,0,.4);
  backdrop-filter: blur(16px);
  transform: translateX(-50%);
}
.bottom-nav button { min-height: 49px; border: 0; border-radius: 11px; background: transparent; color: var(--muted); }
.bottom-nav button.active { background: var(--panel-2); color: var(--text); }
.bottom-nav span, .bottom-nav b { display: block; }
.bottom-nav b { margin-top: 2px; font-size: 10px; }

@media (max-width: 720px) {
  .amount-control-row { grid-template-columns: 1fr; }
  .amount-presets { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
  .amount-presets button { padding: 0 6px; }
}

@media (max-width: 640px) {
  .topbar { min-height: 58px; padding: 8px 12px; }
  .top-account { gap: 8px; }
  .server-connection { flex-direction: column; gap: 2px; }
  .top-account .server-ping { min-width: 0; font-size: 8px; line-height: 1; text-align: center; }
  .logo { font-size: 17px; }
  .logo span { width: 30px; height: 30px; font-size: 17px; }
  .content { width: min(100% - 16px, 1080px); }
  .view { padding: 20px 0; }
  .view-heading { align-items: end; margin-bottom: 16px; }
  .search { width: 132px; min-height: 40px; }
  .category-tabs button { flex: 1; padding: 0 8px; }
  .trade-heading { grid-template-columns: 40px 1fr auto; gap: 9px; }
  .trade-heading h1 { font-size: 22px; }
  .instrument-price strong { font-size: 14px; }
  .chart-toolbar { gap: 8px; padding: 10px; }
  .timeframes button { padding: 0 10px; }
  .chart-toolbar-actions { gap: 8px; }
  .chart-position-pnl { min-width: 0; font-size: 11px; }
  .chart-wrap { height: 290px; }
  .order-fields { grid-template-columns: 1fr; gap: 0; }
  .amount-preset-settings { grid-template-columns: 1fr; }
  .account-cards { grid-template-columns: 1fr; }
  .account-cards > div + div { border-top: 1px solid var(--line); border-left: 0; }
  .social-grid, .competition-fields, .time-settings-grid { grid-template-columns: 1fr; }
  .inline-form { grid-template-columns: 1fr; }
  .inline-form .primary-button { width: 100%; }
  .tournament-metrics { grid-template-columns: 1fr 1fr; }
  .live-tournament-score { grid-template-columns: 1fr 1fr 1fr; }
  .compact-switch span { display: none; }
  .compact-switch { padding: 0 9px; }
  .item-top { align-items: flex-start; }
  .order-result { flex: 0 0 auto; }
  .bottom-nav { bottom: max(8px, env(safe-area-inset-bottom)); width: calc(100% - 16px); }
  .bottom-nav button { min-width: 0; padding: 0 2px; }
  .bottom-nav b { font-size: 8px; }
}
