:root {
  --frame: #1d232f;
  --frame-inner: #2f3947;
  --grid-line: rgba(152, 171, 200, 0.45);
  --cell-bg: #f5f9ff;
  --cell-bg-soft: #ffffff;
  --cell-alt-bg: #d5e3fb;
  --cell-alt-bg-soft: #e1ebff;
  --head-bg: #21252f;
  --head-text: #d9e1f1;
  --brand-text: #d7d7df;
  --red-band: #6f1f27;
  --red-band-dark: #4f1820;
  --green-fill: #179060;
  --green-fill-deep: #1c7e5c;
  --green-text: #c8f2dd;
  --green-text-soft: #2f875f;
  --red-text: #b63e3c;
  --name-text: #1d2440;
  --table-head-size: clamp(24px, 4.2vh, 38px);
  --module-gap: 2px;
  --line-gap: 1px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", sans-serif;
  background:
    radial-gradient(circle at 50% 0, rgba(255, 255, 255, 0.1), transparent 20%),
    linear-gradient(to bottom, #232a34, #151b23 38%, #11161d 100%);
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.board-wrap {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(187, 201, 223, 0.2);
  box-shadow:
    inset 0 0 0 1px rgba(228, 236, 248, 0.1),
    0 0 30px rgba(0, 0, 0, 0.45);
  background:
    linear-gradient(to bottom, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0) 20%),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0.05) 48%, rgba(255, 255, 255, 0.02)),
    linear-gradient(to bottom, #323a46, #1e242d 100%);
}

.board-wrap::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 18% 6%, rgba(255, 255, 255, 0.85) 0 1.1%, transparent 2.4%),
    radial-gradient(circle at 46% 6%, rgba(255, 255, 255, 0.82) 0 1.2%, transparent 2.6%),
    radial-gradient(circle at 82% 6%, rgba(255, 255, 255, 0.82) 0 1.1%, transparent 2.4%);
  opacity: 0.9;
  pointer-events: none;
}

.board {
  position: absolute;
  inset: 0;
  padding: 0.65% 0.6%;
  display: flex;
  flex-direction: column;
  background:
    linear-gradient(90deg, rgba(39, 18, 23, 0.45), rgba(97, 24, 31, 0.3) 50%, rgba(40, 16, 22, 0.45)),
    linear-gradient(to bottom, #2c3139 0, #181d25 100%);
}

.top-bar {
  height: 7.6%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5% 0 1.2%;
  background:
    linear-gradient(90deg, rgba(103, 28, 37, 0.78), rgba(111, 32, 41, 0.62) 50%, rgba(105, 31, 39, 0.76)),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.08), transparent 40%);
  border: 1px solid rgba(197, 168, 172, 0.2);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0;
}

.brand-text .title {
  color: var(--brand-text);
  font-size: clamp(14px, 1.75vw, 24px);
  font-weight: 900;
  line-height: 1;
}

.clock {
  color: #dde4f5;
  font-size: clamp(12px, 1.65vw, 24px);
  font-weight: 700;
  letter-spacing: 0;
  white-space: nowrap;
}

.content {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 49.5% 4.6% 45.9%;
  gap: 0;
}

.market {
  min-width: 0;
  min-height: 0;
}

.stacked-market {
  height: 100%;
  display: grid;
  grid-template-rows:
    minmax(0, calc((100% - var(--module-gap) + var(--table-head-size)) / 2))
    minmax(0, calc((100% - var(--module-gap) - var(--table-head-size)) / 2));
  row-gap: var(--module-gap);
  min-height: 0;
  background: rgba(255, 255, 255, 0.9);
}

.table-panel {
  min-height: 0;
  display: grid;
  grid-template-rows: var(--table-head-size) 1fr;
  border-top: var(--line-gap) solid rgba(255, 255, 255, 0.68);
}

.table-panel:first-child {
  border-top: 0;
}

.table-panel.no-head {
  grid-template-rows: 1fr;
  border-top: 0;
}

.table-panel.no-head .table-head {
  display: none;
}

.left-market {
  display: grid;
  grid-template-columns: 7.8% 92.2%;
  position: relative;
}

.right-market {
  display: block;
}

.side-labels {
  display: grid;
  grid-template-rows:
    var(--table-head-size)
    minmax(0, calc((100% - var(--table-head-size) - var(--module-gap)) / 2))
    minmax(0, calc((100% - var(--table-head-size) - var(--module-gap)) / 2));
  row-gap: var(--module-gap);
  background: rgba(255, 255, 255, 0.9);
  margin-top: 0;
  height: 100%;
  overflow: hidden;
}

.side-labels::before {
  content: "";
  display: block;
  background: var(--head-bg);
  grid-row: 1;
}

.side-label {
  writing-mode: vertical-rl;
  text-orientation: upright;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(to bottom, #2f2d36, #34222a 100%);
  color: #f2f5fb;
  font-size: clamp(12px, 1.45vw, 20px);
  font-weight: 700;
  letter-spacing: 0.16em;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
}

.side-label.top {
  grid-row: 2;
}

.side-label.bottom {
  grid-row: 3;
}

.center-divider {
  display: grid;
  grid-template-rows:
    var(--table-head-size)
    minmax(0, calc((100% - var(--table-head-size) - var(--module-gap)) / 2))
    minmax(0, calc((100% - var(--table-head-size) - var(--module-gap)) / 2));
  row-gap: var(--module-gap);
  align-items: stretch;
  justify-items: stretch;
  background: rgba(255, 255, 255, 0.9);
  margin-top: 0;
  height: calc(100% + 1px);
}

.center-divider::before {
  content: "";
  grid-row: 1;
  grid-column: 1;
  background: var(--head-bg);
}

.center-divider span {
  writing-mode: vertical-rl;
  text-orientation: upright;
  color: #edf2ff;
  font-size: clamp(13px, 1.55vw, 21px);
  font-weight: 700;
  letter-spacing: 0.2em;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(
      to bottom,
      rgba(133, 37, 46, 0.95) 0,
      rgba(108, 30, 39, 0.96) 55%,
      rgba(84, 24, 32, 0.98) 100%
    ),
    linear-gradient(90deg, rgba(255, 255, 255, 0.05), transparent 50%, rgba(255, 255, 255, 0.05));
}

.center-divider span:first-child {
  grid-row: 2;
}

.center-divider span:last-child {
  grid-row: 3;
}

.table-area {
  height: 100%;
  display: grid;
  grid-template-rows: var(--table-head-size) 1fr;
  min-width: 0;
  min-height: 0;
}

.table-head,
.row {
  display: grid;
  grid-template-columns: 1.18fr 1.16fr 1.16fr 0.84fr;
}

.table-head {
  min-height: 0;
  background: var(--head-bg);
}

.table-head > div {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--head-text);
  font-size: clamp(11px, 1.38vw, 20px);
  font-weight: 700;
  border-right: 0;
}

.table-head > div:last-child {
  border-right: 0;
}

.rows {
  display: grid;
  grid-template-rows: repeat(4, minmax(0, 1fr));
  min-height: 0;
  overflow: hidden;
}

.row {
  min-height: 0;
}

.row-empty .name,
.row-empty .val,
.row-empty .highlow {
  color: transparent;
  text-shadow: none;
}

.row > div {
  border-right: 0;
  border-bottom: 0;
}

.row > div:last-child {
  border-right: 0;
}

.name,
.val,
.highlow {
  background: linear-gradient(to bottom, var(--cell-bg-soft), var(--cell-bg));
}

.row:nth-child(odd) .name,
.row:nth-child(odd) .val:not(.val-green):not(.is-up):not(.is-down),
.row:nth-child(odd) .highlow {
  background: linear-gradient(to bottom, var(--cell-alt-bg-soft), var(--cell-alt-bg));
}

.name {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--name-text);
  font-size: clamp(12px, 1.7vw, 24px);
  font-weight: 800;
  white-space: nowrap;
  min-height: 0;
}

.val {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(14px, 2vw, 28px);
  font-weight: 900;
  white-space: nowrap;
  min-height: 0;
}

.val.is-up {
  color: #c8f2dd;
  background:
    linear-gradient(to bottom, rgba(255, 255, 255, 0.08), transparent 34%),
    linear-gradient(to bottom, var(--green-fill), var(--green-fill-deep));
}

.val.is-down {
  color: #ffd7d7;
  background:
    linear-gradient(to bottom, rgba(255, 255, 255, 0.08), transparent 34%),
    linear-gradient(to bottom, #7d2c32, #5f1d22);
}

.val.is-flat {
  color: #d85e5b;
}

.val-green {
  background:
    linear-gradient(to bottom, rgba(255, 255, 255, 0.08), transparent 34%),
    linear-gradient(to bottom, var(--green-fill), var(--green-fill-deep));
  color: var(--green-text);
}

.val-green-text {
  color: var(--green-text-soft);
}

.val-red-text {
  color: var(--red-text);
}

.highlow {
  display: grid;
  grid-template-rows: 1fr 1fr;
  align-items: center;
  justify-items: center;
  padding: 2% 0;
  font-size: clamp(10px, 1.25vw, 18px);
  font-weight: 500;
  line-height: 1;
  min-height: 0;
}

.highlow .hi {
  color: #a15356;
}

.highlow .lo {
  color: #4f8667;
}

.notice-bar {
  height: 4.8%;
  min-height: 24px;
  margin-top: 0;
  background: linear-gradient(to bottom, #0a0d12, #121721);
  border-top: 1px solid rgba(170, 186, 212, 0.22);
  border-bottom: 1px solid rgba(170, 186, 212, 0.08);
  display: flex;
  align-items: center;
  overflow: hidden;
}

.notice-track {
  width: 100%;
  overflow: hidden;
  white-space: nowrap;
}

.notice-text {
  display: inline-block;
  padding-left: 100%;
  color: #dce5f8;
  font-size: clamp(11px, 1.3vw, 18px);
  letter-spacing: 0.02em;
  animation: ticker 20s linear infinite;
}

@keyframes ticker {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(-100%);
  }
}

@media (max-width: 720px) and (orientation: portrait) {
  html,
  body {
    height: auto;
    min-height: 100%;
  }

  body {
    display: block;
    overflow-y: auto;
  }

  .board-wrap {
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
    overflow: visible;
  }

  .board {
    position: relative;
    inset: auto;
    min-height: 100vh;
    min-height: 100dvh;
  }

  .top-bar {
    height: auto;
    min-height: 48px;
    padding: 0 2.2% 0 1.8%;
  }

  .brand {
    gap: 1.2vw;
  }

  .brand-text .title {
    font-size: clamp(12px, 4vw, 18px);
  }

  .brand-text .subtitle {
    font-size: clamp(5px, 1.7vw, 8px);
  }

  .clock {
    font-size: clamp(10px, 3.4vw, 16px);
  }

  .content {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: auto;
    flex: none;
  }

  .table-panel {
    position: relative;
    min-height: auto;
    grid-template-rows: 28px var(--table-head-size) auto;
  }

  .table-panel::before {
    content: attr(data-mobile-title);
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(to bottom, #631d27, #4f1820);
    color: #f3f5fb;
    font-size: clamp(11px, 3vw, 14px);
    font-weight: 700;
    letter-spacing: 0.12em;
  }

  .table-panel.no-head {
    grid-template-rows: 28px auto;
  }

  .center-divider {
    display: none;
  }

  .side-labels {
    display: none;
  }

  .market,
  .left-market,
  .right-market {
    display: block;
    height: auto;
    min-height: 0;
  }

  .left-market {
    grid-template-columns: none;
  }

  .stacked-market {
    display: flex;
    flex-direction: column;
    gap: 8px;
    height: auto;
    background: none;
  }

  .stacked-market::after {
    display: none;
  }

  .rows {
    grid-template-rows: repeat(4, minmax(42px, auto));
    overflow: visible;
  }

  .row {
    min-height: 42px;
  }

  .side-label {
    font-size: clamp(10px, 2.9vw, 16px);
  }

  .table-head > div {
    font-size: clamp(10px, 2.9vw, 14px);
  }

  .name {
    font-size: clamp(11px, 3.1vw, 16px);
  }

  .val {
    font-size: clamp(12px, 3.5vw, 18px);
  }

  .highlow {
    font-size: clamp(9px, 2.5vw, 12px);
  }

  .notice-bar {
    height: auto;
    min-height: 26px;
    flex: none;
  }

  .notice-text {
    font-size: clamp(10px, 3vw, 14px);
    animation-duration: 14s;
  }
}

@media (max-width: 420px) and (orientation: portrait) {
  .table-head,
  .row {
    grid-template-columns: 1.05fr 1.1fr 1.1fr 0.85fr;
  }
}

html.force-desktop-layout,
html.force-desktop-layout body {
  height: 100%;
}

html.force-desktop-layout body {
  display: flex;
  overflow: hidden;
}

html.force-desktop-layout .board-wrap {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

html.force-desktop-layout .board {
  position: absolute;
  inset: 0;
  min-height: 0;
}

html.force-desktop-layout .top-bar {
  height: 7.6%;
  min-height: 0;
}

html.force-desktop-layout .content {
  display: grid;
  grid-template-columns: 49.5% 4.6% 45.9%;
  grid-template-rows: none;
  gap: 0;
  flex: 1;
  min-height: 0;
}

html.force-desktop-layout .market {
  min-height: 0;
}

html.force-desktop-layout .left-market {
  display: grid;
  grid-template-columns: 7.8% 92.2%;
}

html.force-desktop-layout .right-market {
  display: block;
  height: auto;
}

html.force-desktop-layout .side-labels {
  display: grid;
}

html.force-desktop-layout .center-divider {
  display: grid;
  height: calc(100% + 1px);
}

html.force-desktop-layout .stacked-market {
  display: grid;
  grid-template-rows:
    minmax(0, calc((100% - var(--module-gap) + var(--table-head-size)) / 2))
    minmax(0, calc((100% - var(--module-gap) - var(--table-head-size)) / 2));
  row-gap: var(--module-gap);
  height: 100%;
  background: rgba(255, 255, 255, 0.9);
}

html.force-desktop-layout .stacked-market::after {
  display: block;
}

html.force-desktop-layout .table-panel {
  min-height: 0;
  grid-template-rows: var(--table-head-size) 1fr;
}

html.force-desktop-layout .table-panel::before {
  display: none;
  content: none;
}

html.force-desktop-layout .table-panel.no-head {
  grid-template-rows: 1fr;
}

html.force-desktop-layout .rows {
  grid-template-rows: repeat(4, minmax(0, 1fr));
  overflow: hidden;
}

html.force-desktop-layout .row {
  min-height: 0;
}

html.force-desktop-layout .notice-bar {
  height: 4.8%;
  min-height: 24px;
}
