*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: #03070d;
  color: #f1f7ff;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  overflow: hidden;
}

body.widget-mode {
  background: transparent;
}

.orientation-notice {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 30;
  align-items: center;
  justify-items: center;
  padding: 28px;
  background: linear-gradient(180deg, #0b1c2d, #040910 75%);
  text-align: center;
}

.orientation-content { max-width: 320px; }
.orientation-icon {
  width: 88px;
  height: 88px;
  margin-bottom: 18px;
  fill: none;
  stroke: #86cbff;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.orientation-content h1 { margin: 0 0 14px; font-size: 25px; line-height: 1.25; color: #eaf5ff; }
.orientation-content p { margin: 0; color: #a7c5e3; font-size: 15px; line-height: 1.6; }

@media (max-width: 900px) and (orientation: portrait) {
  .orientation-notice { display: grid; }
  .screen, .settings-backdrop { visibility: hidden; }
}

.screen {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(180deg, rgba(0, 181, 255, 0.12), transparent 18%),
    linear-gradient(180deg, #08111d, #040910 70%);
}

body.widget-mode .screen {
  background: transparent;
}

.board {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: 0;
  min-height: 0;
  min-width: 0;
}

.board-shell {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  display: grid;
  border: 0;
  background:
    linear-gradient(180deg, rgba(53, 110, 171, 0.1), transparent 16%),
    #050a11;
  box-shadow: none;
  overflow: hidden;
}

.board-shell-ticker-top {
  grid-template-areas:
    "tape"
    "header"
    "grid";
  grid-template-rows: auto 30px minmax(0, 1fr);
}

.board-shell-ticker-bottom {
  grid-template-areas:
    "header"
    "grid"
    "tape";
  grid-template-rows: 30px minmax(0, 1fr) auto;
}

.board-shell-ticker-hide {
  grid-template-areas:
    "header"
    "grid";
  grid-template-rows: 30px minmax(0, 1fr);
}

.ticker-tape-shell {
  grid-area: tape;
  display: block;
  width: 100%;
  min-width: 0;
  background: linear-gradient(180deg, #0d1c2a, #07111b);
}

.ticker-tape-shell.hidden {
  display: none;
}

.ticker-tape-top {
  border-bottom: 1px solid rgba(77, 140, 197, 0.42);
}

.ticker-tape-bottom {
  border-top: 1px solid rgba(77, 140, 197, 0.42);
}

.ticker-tape {
  overflow: hidden;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.ticker-tape-track {
  display: flex;
  align-items: center;
  gap: 28px;
  width: max-content;
  padding: 7px 16px;
  white-space: nowrap;
  animation: ticker-tape-scroll 34s linear infinite;
}

.ticker-tape-item {
  display: inline-flex;
  align-items: baseline;
  gap: 9px;
  font-size: 0.84rem;
  text-transform: uppercase;
}

.ticker-tape-symbol {
  color: #a1cefb;
  font-weight: 800;
}

.ticker-tape-price {
  color: #eef8ff;
  font-weight: 700;
}

.ticker-tape-change {
  color: #d4e4f7;
}

.ticker-tape-item-positive .ticker-tape-change {
  color: #7cf28d;
}

.ticker-tape-item-negative .ticker-tape-change {
  color: #ff7b90;
}

.ticker-tape-item-flat .ticker-tape-change {
  color: #d4e4f7;
}

.ticker-tape-item-unavailable .ticker-tape-price,
.ticker-tape-item-unavailable .ticker-tape-change {
  color: #879bad;
}

@keyframes ticker-tape-scroll {
  from {
    transform: translateX(0);
  }

  to {
    transform: translateX(-33.3333%);
  }
}

.ticker-bar {
  grid-area: header;
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 0 10px;
  background: linear-gradient(180deg, #10253a, #091523);
  border-bottom: 1px solid rgba(89, 157, 219, 0.55);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  font-size: 0.72rem;
}

body.widget-mode .ticker-bar {
  -webkit-app-region: drag;
  user-select: none;
}

.title {
  color: #86cbff;
  white-space: nowrap;
}

.index-strip {
  display: flex;
  align-items: baseline;
  justify-content: flex-start;
  gap: 10px;
  min-width: 0;
  color: #eef7ff;
  white-space: nowrap;
}

.index-price {
  font-size: 1rem;
  letter-spacing: 0.02em;
}

.index-change {
  font-size: 0.72rem;
}

.index-change.positive {
  color: #71ef84;
}

.index-change.negative {
  color: #ff7387;
}

.index-change.flat {
  color: #c9d7e6;
}

.meta {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  color: #d8e9ff;
  font-size: 0.66rem;
  white-space: nowrap;
  overflow: hidden;
}

.bar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.widget-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.widget-controls.hidden {
  display: none;
}

.bar-button {
  min-height: 24px;
  padding: 0 9px;
  border: 1px solid rgba(101, 155, 204, 0.36);
  background: linear-gradient(180deg, #132536, #0d1724);
  color: #eaf5ff;
  font: inherit;
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}

body.widget-mode .bar-button,
body.widget-mode .tape-settings-button,
body.widget-mode .widget-controls {
  -webkit-app-region: no-drag;
}

.tape-settings-button {
  border-color: rgba(90, 180, 255, 0.48);
  background: linear-gradient(180deg, #15528a, #103657);
}

.tape-settings-save {
  border-color: rgba(90, 180, 255, 0.52);
  background: linear-gradient(180deg, #15528a, #103657);
}

.board-grid {
  grid-area: grid;
  --symbol-size: clamp(0.72rem, 0.86vw, 0.9rem);
  --change-size: clamp(0.58rem, 0.66vw, 0.72rem);
  --tile-padding-block: 6px;
  --tile-padding-inline: 6px;
  --tile-gap: 4px;
  display: grid;
  gap: 1px;
  padding: 1px;
  min-height: 0;
  width: 100%;
  cursor: pointer;
}

.board-row {
  display: grid;
  gap: 1px;
  min-height: 0;
}

.tile,
.tile-stack {
  display: flex;
  min-width: 0;
  min-height: 0;
}

.tile {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--tile-gap);
  padding: var(--tile-padding-block) var(--tile-padding-inline);
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
  overflow: hidden;
}

.board-row-split {
  grid-template-columns: repeat(20, minmax(0, 1fr));
}

.tile-stack {
  display: grid;
  gap: 1px;
}

.tile-split {
  padding: 4px 6px;
  gap: 2px;
}

.diagonal-pair {
  position: relative;
  display: block;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
  background: #101723;
}

.diagonal-pair::after {
  content: "";
  position: absolute;
  inset: -1px;
  background: linear-gradient(
    to bottom right,
    transparent calc(50% - 1px),
    rgba(250, 252, 255, 0.82) calc(50% - 1px),
    rgba(250, 252, 255, 0.82) calc(50% + 1px),
    transparent calc(50% + 1px)
  );
  pointer-events: none;
}

.tile-split-diagonal {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  padding: 4px 6px;
  overflow: hidden;
}

.tile-split-top-left {
  clip-path: polygon(0 0, 0 100%, 100% 0);
  align-items: flex-start;
  justify-content: flex-start;
}

.tile-split-bottom-right {
  clip-path: polygon(100% 0, 100% 100%, 0 100%);
  align-items: flex-end;
  justify-content: flex-end;
}

.tile-split-diagonal .symbol,
.tile-split-diagonal .change {
  width: auto;
  max-width: 100%;
  text-align: inherit;
}

.symbol,
.change {
  display: block;
  width: 100%;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1;
}

.symbol {
  font-size: var(--symbol-size);
  font-weight: 800;
  letter-spacing: 0.02em;
}

.change {
  font-size: var(--change-size);
  opacity: 0.95;
}

.settings-backdrop {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(2, 8, 15, 0.78);
  backdrop-filter: blur(8px);
  z-index: 20;
}

.settings-backdrop.hidden {
  display: none;
}

.settings-panel {
  width: min(520px, 96vw);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: linear-gradient(180deg, #0e1824, #09111b);
  border: 2px solid rgba(73, 140, 203, 0.72);
  box-shadow:
    0 18px 50px rgba(0, 0, 0, 0.45),
    inset 0 0 0 1px rgba(109, 172, 232, 0.08);
  overflow: hidden;
}

.settings-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid rgba(120, 169, 214, 0.24);
}

.settings-header h2 {
  margin: 0;
}

.settings-header p {
  margin: 6px 0 0;
  color: #a7c5e3;
  font-size: 0.88rem;
}

.settings-content {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.settings-field {
  display: grid;
  gap: 6px;
}

.settings-label {
  color: #9dc3e6;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.settings-field input,
.settings-field select {
  height: 42px;
  padding: 0 12px;
  border: 1px solid rgba(96, 154, 209, 0.34);
  background: #07111b;
  color: #f4fbff;
  font: inherit;
}

.ticker-tape-editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.ticker-tape-symbols {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ticker-tape-symbol-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid rgba(89, 149, 201, 0.3);
  background: #0a1420;
  color: #f1f8ff;
}

.ticker-tape-chip-remove {
  color: #ff91a3;
  font-weight: 700;
}

.settings-empty {
  color: #a8c3dd;
  font-size: 0.82rem;
  padding: 8px 0;
}

.settings-actions {
  display: flex;
  justify-content: flex-start;
}

.settings-message {
  min-height: 20px;
  color: #dcecff;
}

.settings-message-success {
  color: #87f39a;
}

.settings-message-error {
  color: #ff90a1;
}

/* Original wall dimensions, expressed as classes for the Pages CSP. */
.board-grid[data-market="nasdaq100"] { grid-template-rows: repeat(5, minmax(0, 1fr)); }
.board-grid[data-market="nasdaq100"] .board-row { grid-template-columns: repeat(20, minmax(0, 1fr)); }
.board-grid[data-market="dow30"] {
  grid-template-rows: repeat(3, minmax(0, 1fr));
  --symbol-size: clamp(0.94rem, 1.12vw, 1.28rem);
  --change-size: clamp(0.72rem, 0.82vw, 0.94rem);
  --tile-padding-block: 8px;
  --tile-padding-inline: 8px;
  --tile-gap: 5px;
}
.board-grid[data-market="dow30"] .board-row { grid-template-columns: repeat(10, minmax(0, 1fr)); }
.board-grid[data-market="sp500"] {
  grid-template-rows: repeat(10, minmax(0, 1fr));
  --symbol-size: 0.36rem;
  --change-size: 0.28rem;
  --tile-padding-block: 1px;
  --tile-padding-inline: 1px;
  --tile-gap: 1px;
}
.board-grid[data-market="sp500"] .board-row { grid-template-columns: repeat(50, minmax(0, 1fr)); }
.tile-gain { background: #25a746; }
.tile-loss { background: #c32642; }
.tile-flat { background: #343d49; }
.tile-stale { box-shadow: inset 0 0 0 1px #e5b56b; }
.board-grid:focus-visible, .bar-button:focus-visible, .ticker-tape-symbol-chip:focus-visible {
  outline: 2px solid #86cbff;
  outline-offset: 2px;
}
.settings-panel { max-height: calc(100dvh - 36px); overflow-y: auto; }
@media (prefers-reduced-motion: reduce) {
  .ticker-tape-track { animation: none; }
  .ticker-tape { overflow-x: auto; }
}

@media (max-width: 900px) {
  .ticker-tape-track {
    gap: 18px;
    padding: 6px 12px;
  }

  .ticker-bar {
    grid-template-columns: 1fr;
    min-height: 30px;
    padding: 4px 8px;
    justify-items: center;
    gap: 4px;
  }

  .title,
  .meta,
  .bar-actions {
    justify-self: center;
  }

  .meta {
    gap: 10px;
    font-size: 0.6rem;
    justify-content: center;
  }

  .bar-actions {
    flex-wrap: wrap;
    justify-content: center;
  }

  .board-shell-ticker-top {
    grid-template-rows: auto auto minmax(0, 1fr);
  }

  .board-shell-ticker-bottom {
    grid-template-rows: auto minmax(0, 1fr) auto;
  }

  .board-shell-ticker-hide {
    grid-template-rows: auto minmax(0, 1fr);
  }

  .settings-backdrop {
    padding: 8px;
  }

  .settings-header,
  .settings-content {
    padding: 12px;
  }

  .ticker-tape-editor {
    grid-template-columns: 1fr;
  }

  .tile {
    padding: max(3px, var(--tile-padding-block)) max(3px, var(--tile-padding-inline));
    gap: max(2px, var(--tile-gap));
  }

  .tile-split {
    padding: 3px 6px;
  }

  .symbol {
    font-size: min(0.62rem, var(--symbol-size));
  }

  .change {
    font-size: min(0.5rem, var(--change-size));
  }
}
