:root {
  --bg-top: #0c111d;
  --bg-bottom: #06090f;
  --card: #0f1522;
  --card-edge: #1c2638;
  --text: #e8edf6;
  --muted: #8a94a8;
  --dim: #566074;
  --orange: #f7931a;
  --green: #22d07f;
  --red: #ff4d61;
  --amber: #f5b83d;
  --gap: 14px;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg-bottom);
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(var(--bg-top), var(--bg-bottom)) fixed;
  color: var(--text);
  font: 500 14px/1.4 Inter, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  padding: 0 20px 20px;
}

a {
  color: inherit;
}

/* --- Header --- */

.top {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 16px 0 10px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.coin {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--orange);
  color: #fff;
  font-weight: 800;
  font-size: 24px;
  transform: rotate(14deg);
}

.name {
  font-weight: 700;
  font-size: 24px;
  letter-spacing: -0.01em;
}

.tag {
  color: var(--muted);
  font-size: 15px;
}

.note a {
  color: var(--muted);
}

.note {
  color: var(--dim);
  font-size: 13px;
  padding-left: 18px;
  border-left: 1px solid #1a2333;
}

.live {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 16px;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--amber);
  background: rgba(245, 184, 61, 0.14);
}

.status i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.status[data-state='live'] {
  color: var(--red);
  background: rgba(255, 77, 97, 0.14);
}

.status[data-state='live'] i {
  animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    opacity: 0.25;
  }
}

.clock {
  font-weight: 600;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  min-width: 5.5em;
  text-align: right;
}

/* --- Controls --- */

.controls {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0 12px;
}

.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 3px;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--card-edge);
}

.segmented button {
  font: inherit;
  font-weight: 600;
  font-size: 13px;
  color: var(--muted);
  background: none;
  border: 0;
  border-radius: 9px;
  padding: 7px 13px;
  cursor: pointer;
}

.segmented button:hover {
  color: var(--text);
}

.segmented button[aria-pressed='true'] {
  color: #111;
  background: var(--orange);
}

.segmented button:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 1px;
}

/* --- Advert (bottom right, under the trades) --- */

.ad {
  display: flex;
  justify-content: center;
  min-height: 60px;
}

.ad[hidden] {
  display: none;
}

/* A fixed box, as on the main page: without one AdSense may resize the unit to fill the space. */
.ad-unit {
  width: 468px;
  height: 60px;
  overflow: hidden;
}

/* The phone advert (responsive): only in the one-column layout, below. A block box, not flex, so
   the unit sees the full width it may fill. */
.board .ad-mobile {
  display: none;
}

/* Where the advert goes, in builds without it (local and pre-deploy), so the layout matches. */
.ad-placeholder {
  display: grid;
  place-items: center;
  border: 1px dashed var(--card-edge);
  border-radius: 8px;
  color: var(--dim);
  font-size: 12px;
}

/* --- The board --- */

/* Desktop: two columns, each with its own rows, so the two charts (left) can be the same height
   whatever the price card, book and trades (right) need. Narrower layouts dissolve the columns
   (display: contents) and place the five cards in the board's own grid. */
.board {
  display: grid;
  gap: var(--gap);
  grid-template-columns: minmax(0, 1fr) minmax(360px, 468px);
}

.board .left,
.board .right {
  display: grid;
  gap: var(--gap);
  min-height: 0;
}

.board .left {
  grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
}

.board .right {
  grid-template-rows: 230px 420px 300px;
  grid-auto-rows: auto;
}

.ad-side {
  min-height: 60px;
  flex: none;
}

.card {
  position: relative;
  min-width: 0;
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-radius: 16px;
  overflow: hidden;
}

/* The depth chart's Live / Slow switch, over its canvas beside the title. */
.depth-mode {
  position: absolute;
  top: 12px;
  z-index: 1;
  display: flex;
  gap: 2px;
  padding: 2px;
  border-radius: 8px;
  background: var(--bg-bottom);
  border: 1px solid var(--card-edge);
}

.depth-mode button {
  min-width: 24px;
  font: inherit;
  font-weight: 600;
  font-size: 11px;
  line-height: 1;
  color: var(--muted);
  background: none;
  border: 0;
  border-radius: 6px;
  padding: 4px 9px;
  cursor: pointer;
}

.depth-mode button:hover:not(:disabled) {
  color: var(--text);
}

.depth-mode button:disabled {
  opacity: 0.35;
  cursor: default;
}

.depth-mode select {
  font: inherit;
  font-weight: 600;
  font-size: 11px;
  color: var(--muted);
  background: var(--card);
  border: 0;
  border-radius: 6px;
  padding: 2px 4px;
  margin-left: 2px;
  cursor: pointer;
}

.depth-mode select[hidden] {
  display: none;
}

.depth-mode select:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 1px;
}

.depth-mode .divider {
  width: 1px;
  margin: 3px 2px;
  background: var(--card-edge);
}

.depth-mode button[aria-pressed='true'] {
  color: #111;
  background: var(--orange);
}

.depth-mode button:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 1px;
}

.card canvas {
  position: absolute;
  inset: 0;
  display: block;
}



/* Desktop: the page is the window's height, and the panels share it. */
@media (min-width: 1101px) and (min-height: 600px) {
  body {
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    padding-bottom: 8px;
  }
  .top {
    padding-top: 12px;
  }
  .board {
    flex: 1;
    min-height: 0;
  }
  .board .right {
    grid-template-rows: minmax(150px, 0.6fr) minmax(200px, 1.6fr) minmax(140px, 0.9fr);
  }
  .board .left {
    grid-template-rows: minmax(260px, 1fr) minmax(260px, 1fr);
  }
}

/* Tablets: the chart across the top, then pairs. */
@media (max-width: 1100px) {
  .board .left,
  .board .right {
    display: contents;
  }
  .chart {
    grid-area: chart;
  }
  .price {
    grid-area: price;
  }
  .book {
    grid-area: book;
  }
  .depth {
    grid-area: depth;
  }
  .trades {
    grid-area: trades;
  }
  .ad-side {
    grid-area: ad2;
  }
  .board {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: 240px 440px 380px 340px auto;
    grid-template-areas:
      'price price'
      'chart chart'
      'book trades'
      'depth depth'
      'ad2 ad2';
  }
}

/* Phones: one column. */
@media (max-width: 700px) {
  body {
    padding: 0 12px 16px;
  }
  .note {
    border-left: 0;
    padding-left: 0;
    flex-basis: 100%;
    order: 3;
  }
  .tag {
    display: none;
  }
  .board {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 196px 360px auto 340px 300px 320px;
    grid-template-areas: 'price' 'chart' 'admobile' 'book' 'trades' 'depth';
  }
  /* The 468x60 slot isn't part of this layout (left out by main.ts; never given a column here). */
  .board .ad-side {
    display: none;
  }
  .board .ad-mobile:not([hidden]) {
    display: block;
    grid-area: admobile;
    min-height: 50px;
  }
  /* Google had no advert for it: no empty gap (Google's own advice for unfilled units). */
  .board .ad-mobile:has(ins[data-ad-status='unfilled']) {
    display: none;
  }
  .ad-placeholder-mobile {
    width: 100%;
    height: 100px;
  }
  .segmented {
    width: 100%;
    justify-content: space-between;
  }
  .segmented button {
    flex: 1;
    padding: 7px 4px;
  }
  .depth-mode button {
    padding: 4px 6px;
    min-width: 20px;
  }
  .depth-mode select {
    padding: 2px 1px;
  }
}
