:root {
  color-scheme: dark;
  --bg: #060c18;
  --panel: #0e48ff;
  --text: #f8fafc;
  --muted: rgba(255, 255, 255, 0.76);
  --red: #ff4d4f;
  --green: #73ff86;
  --yellow: #ffd84d;
  --line: #e43d3d;
  --btn-blue: #2447ff;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: linear-gradient(180deg, #08111f, #02050a);
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
}

button, input { font: inherit; }
button { cursor: pointer; }

.phone-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 12px;
}

.screen {
  width: min(100%, 430px);
  background: #111;
  border-radius: 22px;
  padding: 18px 14px 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.topline {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 12px;
  text-align: center;
}

.panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.value-card {
  background: var(--panel);
  border-radius: 8px;
  padding: 12px 10px;
  min-height: 104px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.value-card span {
  color: rgba(255, 255, 255, 0.92);
  font-size: 15px;
}

.value-card strong {
  font-size: 46px;
  line-height: 1;
  font-weight: 700;
  letter-spacing: 1px;
}

#profit-display.negative { color: var(--red); }
#profit-display.positive { color: var(--green); }
#bet-display { color: #fff; }

.midline {
  margin: 12px 0 14px;
  text-align: center;
  color: var(--line);
  font-size: 34px;
  font-weight: 700;
  position: relative;
}

.midline::before,
.midline::after {
  content: "";
  position: absolute;
  top: 50%;
  width: calc(50% - 32px);
  height: 2px;
  background: var(--line);
}

.midline::before { left: 0; }
.midline::after { right: 0; }

.actions {
  display: grid;
  gap: 10px;
  margin-bottom: 10px;
}

.primary-actions { grid-template-columns: 1fr 1fr; }
.secondary-actions { grid-template-columns: 1fr 1fr; }

.btn {
  border: 0;
  border-radius: 999px;
  padding: 15px 12px;
  font-size: 30px;
  font-weight: 700;
}

.btn-loss {
  background: #39a043;
  color: #fff;
}

.btn-win {
  background: var(--yellow);
  color: #1f1f1f;
}

.btn-secondary {
  background: var(--btn-blue);
  color: #fff;
  font-size: 22px;
}

.config-box,
.sequence-box,
.status-box,
.history-box {
  margin-top: 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.config-box { padding: 10px 12px; }
.config-box summary {
  cursor: pointer;
  color: var(--muted);
}

.config-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.config-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.config-grid input,
.sequence-box input {
  width: 100%;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #fff;
  border-radius: 8px;
  padding: 9px 10px;
}

.config-actions,
.sequence-box {
  display: grid;
  gap: 10px;
}

.config-actions {
  grid-template-columns: 1fr 1fr;
  margin-top: 12px;
}

.sequence-box {
  padding: 10px;
}

.sequence-box .btn-secondary {
  font-size: 18px;
  padding: 10px 12px;
}

.status-box {
  padding: 10px 12px;
  display: grid;
  gap: 6px;
  color: var(--muted);
}

.status-box strong { color: #fff; }

.history-box {
  padding: 10px 12px;
}

.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  color: var(--muted);
}

.clear-link {
  background: transparent;
  border: 0;
  color: #9cc2ff;
  padding: 0;
}

#history-output {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 13px;
  line-height: 1.55;
  color: #dbe7ff;
  min-height: 120px;
  max-height: 240px;
  overflow: auto;
}

@media (max-width: 420px) {
  .value-card strong { font-size: 40px; }
  .btn { font-size: 26px; }
  .btn-secondary { font-size: 18px; }
  .config-grid { grid-template-columns: 1fr; }
}
