/* 童年怀旧街机风：红黄蓝、高饱和、粗描边、塑料按钮、灯箱、扁平 2D */

:root {
  --red: #d62839;
  --red-dark: #7d1220;
  --yellow: #ffd23f;
  --yellow-dark: #b8860b;
  --blue: #1d4ed8;
  --blue-mid: #24479e;
  --blue-dark: #0b1f52;
  --cream: #f6e7a8;
  --ink: #0b1f52;
  --white: #fffbe8;
  --ok: #7dffb0;
  --bad: #ffb3b3;

  --edge: 3px;
  --radius: 12px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tabbar-h: 58px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--blue-dark);
  color: var(--cream);
  font-family: system-ui, -apple-system, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}

/* 街机背景：深蓝 + 细网点 */
body {
  background-image: radial-gradient(rgba(255, 210, 63, 0.07) 1px, transparent 1px);
  background-size: 14px 14px;
}

#app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  max-width: 560px;
  margin: 0 auto;
  padding-top: var(--safe-top);
  background: linear-gradient(180deg, #173a8a 0%, #102a66 100%);
}

/* ---------------------------------------------------------------- 顶栏 */

.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px 6px;
  min-height: 44px;
}

.title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 900;
  font-size: 18px;
  letter-spacing: 1px;
  color: var(--yellow);
  text-shadow: 0 2px 0 var(--red-dark);
  white-space: nowrap;
}

.title-mark {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff 0 18%, var(--yellow) 19% 55%, var(--red) 56%);
  border: 2px solid var(--blue-dark);
}

.top-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.conn {
  font-size: 12px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  border: 2px solid var(--blue-dark);
  background: rgba(0, 0, 0, 0.25);
}

.conn[data-state='ok'] {
  color: var(--ok);
}

.conn[data-state='bad'] {
  color: var(--bad);
}

.chip {
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  padding: 5px 9px;
  color: var(--ink);
  background: var(--cream);
  border: 2px solid var(--blue-dark);
  border-radius: 8px;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.22);
  white-space: nowrap;
}

.chip[data-open='1'] {
  background: var(--yellow);
}

.chip:disabled {
  opacity: 0.45;
}

/* ---------------------------------------------------------------- 内容与视图 */

.content {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.view {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0 10px;
  overflow: hidden;
}

.view[hidden] {
  display: none;
}

/* ---------------------------------------------------------------- 卡片与面板 */

.card {
  margin-bottom: 10px;
  padding: 12px;
  border: var(--edge) solid var(--blue-dark);
  border-radius: var(--radius);
  background: var(--blue-mid);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.28);
}

.card h2 {
  margin: 0 0 4px;
  font-size: 16px;
  color: var(--yellow);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.panel {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  margin-bottom: 10px;
  padding: 12px;
  border: var(--edge) solid var(--blue-dark);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.18);
}

.panel h2 {
  margin: 0 0 8px;
  font-size: 16px;
  color: var(--yellow);
}

.panel h3 {
  margin: 14px 0 6px;
  font-size: 14px;
  color: var(--cream);
}

.muted {
  margin: 4px 0;
  font-size: 13px;
  opacity: 0.92;
}

.badge {
  font-size: 11px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
  border: 2px solid var(--blue-dark);
  background: var(--cream);
  color: var(--ink);
}

/* ---------------------------------------------------------------- 余额 */

.card-balance {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  background: var(--blue);
}

.balance-item {
  display: flex;
  flex-direction: column;
  padding: 8px 10px;
  border-radius: 10px;
  border: 2px solid var(--blue-dark);
  background: rgba(0, 0, 0, 0.22);
}

.balance-item .label {
  font-size: 11px;
  opacity: 0.9;
}

.balance-item .value {
  font-size: 24px;
  font-weight: 900;
  color: var(--yellow);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 0 var(--red-dark);
}

/* ---------------------------------------------------------------- 机台入口卡片 */

.card-machine {
  text-align: center;
  background: linear-gradient(180deg, var(--red) 0%, #b3172a 100%);
  border-color: var(--red-dark);
}

.card-machine h2 {
  color: var(--white);
  font-size: 20px;
  text-shadow: 0 2px 0 var(--red-dark);
}

.card-machine .muted {
  color: var(--white);
  opacity: 0.95;
}

.machine-art {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 6px;
}

.bulb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--red-dark);
  background: var(--yellow);
  box-shadow: 0 0 8px rgba(255, 210, 63, 0.8);
}

.bulb:nth-child(2) {
  background: var(--white);
}
.bulb:nth-child(3) {
  background: var(--yellow);
}
.bulb:nth-child(4) {
  background: var(--white);
}

/* ---------------------------------------------------------------- 按钮（塑料质感） */

.btn {
  font: inherit;
  font-weight: 900;
  font-size: 16px;
  color: var(--white);
  background: var(--blue-mid);
  border: var(--edge) solid var(--blue-dark);
  border-radius: var(--radius);
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.28), inset 0 2px 0 rgba(255, 255, 255, 0.18);
  padding: 10px 14px;
  min-height: 46px;
  transition: transform 60ms ease;
}

.btn:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.28);
}

.btn:disabled {
  opacity: 0.5;
  filter: grayscale(0.35);
}

.btn-primary {
  background: var(--red);
  border-color: var(--red-dark);
}

.btn-yellow {
  background: var(--yellow);
  border-color: var(--yellow-dark);
  color: var(--red-dark);
}

.btn-ghost {
  background: rgba(0, 0, 0, 0.2);
  color: var(--cream);
  font-size: 14px;
  min-height: 40px;
}

.btn-block {
  display: block;
  width: 100%;
  margin-top: 8px;
}

.btn-step {
  width: 46px;
  min-height: 46px;
  padding: 0;
  font-size: 22px;
  background: var(--cream);
  color: var(--ink);
}

.btn-start {
  flex: 1 1 auto;
  font-size: 18px;
  letter-spacing: 2px;
}

:focus-visible {
  outline: 3px solid var(--white);
  outline-offset: 2px;
}

/* ---------------------------------------------------------------- 签到阶梯 */

.ladder {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin: 8px 0;
}

.ladder-day {
  padding: 6px 2px;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  border-radius: 8px;
  border: 2px solid var(--blue-dark);
  background: var(--blue-mid);
  color: var(--cream);
}

.ladder-day strong {
  display: block;
  font-size: 15px;
  color: var(--yellow);
}

.ladder-day[data-state='done'] {
  background: #1d7a4d;
  border-color: #0f5132;
  color: var(--white);
}

.ladder-day[data-state='done'] strong {
  color: var(--white);
}

.ladder-day[data-state='next'] {
  background: var(--yellow);
  border-color: var(--red);
  color: var(--red-dark);
}

.ladder-day[data-state='next'] strong {
  color: var(--red-dark);
}

.card-recent .list {
  margin-top: 4px;
}

.card-links {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 0;
}

/* ---------------------------------------------------------------- 机台页：整体面板 */

.view[data-view='machine'] {
  padding: 0 6px 6px;
}

.cabinet {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 6px;
  border: var(--edge) solid var(--blue-dark);
  border-radius: 14px;
  background: linear-gradient(180deg, #2a52b8 0%, #1c3f96 100%);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.3), inset 0 2px 0 rgba(255, 255, 255, 0.12);
}

.cabinet-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 5px;
}

.bal {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  padding: 2px 7px;
  border-radius: 8px;
  border: 2px solid var(--blue-dark);
  background: rgba(0, 0, 0, 0.25);
}

.bal-label {
  font-size: 10px;
  opacity: 0.9;
  white-space: nowrap;
}

.bal-value {
  font-size: 14px;
  font-weight: 900;
  color: var(--yellow);
  font-variant-numeric: tabular-nums;
}

.cabinet-head .chip {
  margin-left: auto;
  padding: 4px 7px;
}

.cabinet-head .chip + .chip {
  margin-left: 0;
}

.mults {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
  margin: 5px 0;
}

.mult {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 3px 4px 4px;
  border-radius: 10px;
  border: var(--edge) solid var(--blue-dark);
  background: var(--blue-mid);
  color: var(--cream);
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.25), inset 0 2px 0 rgba(255, 255, 255, 0.14);
}

.mult b {
  font-size: 18px;
  font-weight: 900;
  line-height: 1.1;
}

.mult small {
  font-size: 10px;
  font-weight: 700;
  opacity: 0.9;
}

.mult-mark {
  position: absolute;
  top: 0;
  left: 5px;
  font-size: 12px;
  font-weight: 900;
  color: var(--red);
}

/* 灯亮不只靠颜色：加 ✓ 标记、粗边框与外发光 */
.mult[data-on='1'] {
  background: var(--yellow);
  color: var(--red-dark);
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(255, 210, 63, 0.35), inset 0 -4px 0 rgba(0, 0, 0, 0.2);
}

.cabinet-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  gap: 6px;
}

.stage {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
}

#machine {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* 侧置蓄力槽：竖向，从下往上填充 */
.power {
  flex: 0 0 auto;
  width: 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 4px;
  border-radius: 10px;
  border: var(--edge) solid var(--blue-dark);
  background: var(--blue-mid);
  touch-action: none;
}

.power-track {
  flex: 1 1 auto;
  width: 14px;
  position: relative;
  border-radius: 7px;
  background: rgba(0, 0, 0, 0.4);
  overflow: hidden;
}

.power-fill {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 0%;
  background: linear-gradient(0deg, var(--yellow) 0%, #ff9f1c 55%, var(--red) 100%);
}

.power-label {
  font-size: 10px;
  font-weight: 800;
  color: var(--cream);
}

.cabinet-foot {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 6px;
}

.stake {
  display: flex;
  align-items: center;
  gap: 5px;
}

.btn-step {
  width: 44px;
  min-height: 46px;
  padding: 0;
  font-size: 22px;
  background: var(--cream);
  color: var(--ink);
}

/* 七段数码管：投入数 */
.seg-display {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 46px;
  padding: 0 9px;
  border-radius: 10px;
  border: var(--edge) solid var(--blue-dark);
  background: #16060a;
  box-shadow: inset 0 3px 6px rgba(0, 0, 0, 0.7);
}

.seg-digit {
  position: relative;
  width: 20px;
  height: 34px;
  --on: #ff3b30;
  --off: rgba(255, 59, 48, 0.13);
}

.seg-digit i {
  position: absolute;
  background: var(--off);
  border-radius: 2px;
}

.seg-digit i:nth-child(1) { left: 3px; top: 0; width: 14px; height: 4px; }
.seg-digit i:nth-child(2) { right: 0; top: 3px; width: 4px; height: 13px; }
.seg-digit i:nth-child(3) { right: 0; bottom: 3px; width: 4px; height: 13px; }
.seg-digit i:nth-child(4) { left: 3px; bottom: 0; width: 14px; height: 4px; }
.seg-digit i:nth-child(5) { left: 0; bottom: 3px; width: 4px; height: 13px; }
.seg-digit i:nth-child(6) { left: 0; top: 3px; width: 4px; height: 13px; }
.seg-digit i:nth-child(7) { left: 3px; top: 15px; width: 14px; height: 4px; }

.seg-digit i.on {
  background: var(--on);
  box-shadow: 0 0 6px rgba(255, 59, 48, 0.9);
}

.seg-unit {
  font-size: 11px;
  font-weight: 800;
  color: var(--cream);
  writing-mode: vertical-rl;
  letter-spacing: 1px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.btn-start {
  flex: 1 1 auto;
  font-size: 19px;
  letter-spacing: 3px;
}

.info {
  flex: 0 0 auto;
  padding-top: 4px;
  min-height: 34px;
  text-align: center;
}

.status {
  font-size: 13px;
  font-weight: 800;
  color: var(--cream);
}

.result {
  font-size: 12px;
  min-height: 16px;
  color: #cfd8ee;
}

.result[data-hit='1'] {
  color: var(--yellow);
  font-weight: 900;
}

/* 左手模式：仅镜像侧置蓄力槽与底部控件，机台画布与物理不变 */
#app[data-hand='left'] .cabinet-body,
#app[data-hand='left'] .cabinet-foot,
#app[data-hand='left'] .stake {
  flex-direction: row-reverse;
}

/* ---------------------------------------------------------------- 记录 */

.segmented {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding-bottom: 8px;
}

.seg {
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  min-height: 38px;
  color: var(--cream);
  background: rgba(0, 0, 0, 0.22);
  border: 2px solid var(--blue-dark);
  border-radius: 10px;
}

.seg[data-on='1'] {
  background: var(--yellow);
  color: var(--red-dark);
  border-color: var(--red);
}

.list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12.5px;
}

.list-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  padding: 7px 9px;
  border-radius: 8px;
  border: 2px solid rgba(0, 0, 0, 0.25);
  background: rgba(0, 0, 0, 0.2);
}

.list-row .pos {
  color: var(--ok);
  font-weight: 800;
  white-space: nowrap;
}

.list-row .neg {
  color: var(--bad);
  font-weight: 800;
  white-space: nowrap;
}

.list-row .meta {
  display: block;
  font-size: 11px;
  opacity: 0.8;
}

.more {
  margin-top: 8px;
}

/* ---------------------------------------------------------------- 个人中心 */

.profile {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border-radius: 10px;
  border: 2px solid var(--blue-dark);
  background: rgba(0, 0, 0, 0.2);
}

.avatar {
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  font-size: 22px;
  font-weight: 900;
  color: var(--red-dark);
  background: var(--yellow);
  border: var(--edge) solid var(--red);
  border-radius: 50%;
}

.account-name {
  font-size: 16px;
  font-weight: 900;
  color: var(--yellow);
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 4px;
  border-radius: 10px;
  border: 2px solid var(--blue-dark);
  background: rgba(0, 0, 0, 0.2);
}

.stat span {
  font-size: 11px;
  opacity: 0.9;
}

.stat strong {
  font-size: 18px;
  color: var(--yellow);
  font-variant-numeric: tabular-nums;
}

.settings .row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  padding: 0 4px;
  border-bottom: 2px solid rgba(0, 0, 0, 0.18);
  font-size: 14px;
  font-weight: 700;
}

.settings input[type='checkbox'] {
  width: 22px;
  height: 22px;
  accent-color: var(--yellow);
}

.settings input[type='range'] {
  width: 150px;
  accent-color: var(--yellow);
}

.input {
  display: block;
  width: 100%;
  height: 44px;
  margin: 6px 0;
  padding: 0 12px;
  font: inherit;
  font-size: 15px;
  color: var(--ink);
  background: var(--cream);
  border: var(--edge) solid var(--blue-dark);
  border-radius: 10px;
}

/* ---------------------------------------------------------------- 底部导航 */

.tabbar {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 6px 8px calc(6px + var(--safe-bottom));
  background: var(--blue-dark);
  border-top: var(--edge) solid #061539;
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  min-height: 46px;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  color: var(--cream);
  background: transparent;
  border: 0;
  border-radius: 10px;
  opacity: 0.75;
}

.tab-ico {
  font-size: 16px;
  line-height: 1;
}

.tab[data-on='1'] {
  opacity: 1;
  color: var(--red-dark);
  background: var(--yellow);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.2);
}

/* ---------------------------------------------------------------- 调试面板 */

.debug {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 8px);
  max-height: 46%;
  overflow: auto;
  padding: 8px 10px;
  border-radius: 10px;
  border: 2px solid var(--yellow);
  background: rgba(11, 31, 82, 0.96);
  font-size: 11px;
  line-height: 1.45;
  z-index: 10;
}

.debug pre {
  margin: 4px 0;
  white-space: pre-wrap;
  word-break: break-all;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.dbg-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.dbg-title {
  margin-top: 6px;
  color: var(--yellow);
  font-weight: 800;
}

/* ---------------------------------------------------------------- 简洁动画 */

#app[data-motion='reduced'] .btn,
#app[data-motion='reduced'] .bulb {
  transition: none;
  box-shadow: none;
}

#app[data-motion='reduced'] .bulb {
  background: var(--yellow);
}

@media (prefers-reduced-motion: reduce) {
  .btn {
    transition: none;
  }
}

/* ---------------------------------------------------------------- 短屏降级 */

@media (max-height: 700px) {
  .mult b {
    font-size: 16px;
  }
  .mult {
    padding: 2px 4px 3px;
  }
  .mult small {
    display: none;
  }
  .power {
    width: 28px;
    padding: 4px 3px;
  }
  .seg-display {
    height: 42px;
  }
  .seg-digit {
    width: 18px;
    height: 30px;
  }
  .btn-step {
    min-height: 42px;
    width: 42px;
  }
  .btn {
    min-height: 42px;
    padding: 8px 12px;
  }
  .btn-step {
    min-height: 42px;
  }
  .stake-value {
    height: 42px;
  }
  .info {
    min-height: 34px;
  }
  .bal-value {
    font-size: 13px;
  }
  .force {
    padding: 4px 8px;
  }
  .force-hint {
    display: none;
  }
}

@media (max-height: 560px) {
  .topbar {
    min-height: 36px;
    padding: 4px 12px;
  }
  .title {
    font-size: 15px;
  }
  .mult small {
    display: none;
  }
  .tabbar {
    padding-top: 3px;
    padding-bottom: calc(3px + var(--safe-bottom));
  }
  .tab {
    min-height: 38px;
  }
}
