:root {
  --bg-top: #fff4be;
  --bg-bottom: #ffd6a4;
  --ink: #23324a;
  --card: #fffdf6;
  --lane: #e7f0ff;
  --lane-line: #a9c3e8;
  --danger: #2f64d8;
  --warning: #ffd47c;
  --warning-soft: #f8f4ea;
  --player: #ff6f3c;
  --good: #1d9e73;
  --bad: #dc3a44;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Hannotate SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at 15% 20%, #ffffff99 0 12%, transparent 40%),
    radial-gradient(circle at 85% 80%, #ffffff77 0 10%, transparent 42%),
    linear-gradient(155deg, var(--bg-top), var(--bg-bottom));
  color: var(--ink);
}

.app {
  width: min(430px, 100%);
  margin: 0 auto;
  padding: 16px 14px 24px;
}

.screen {
  display: none;
}

.screen.active {
  display: block;
}

.card {
  background: var(--card);
  border: 3px solid #ffffff;
  border-radius: 24px;
  box-shadow: 0 14px 30px #5a443614;
  padding: 16px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  line-height: 1.15;
  font-size: 1.9rem;
}

h2 {
  font-size: 1.5rem;
}

.eyebrow {
  color: #f28f00;
  font-weight: 700;
  margin-bottom: 8px;
}

.lead {
  margin: 10px 0 14px;
  line-height: 1.5;
}

.best-box {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.best-box p,
.result-grid p {
  background: #fff4e0;
  border-radius: 12px;
  padding: 10px;
  font-size: 0.94rem;
}

.tips {
  margin: 0 0 16px;
  padding-left: 1.2rem;
  line-height: 1.5;
  font-size: 0.94rem;
}

.btn {
  border: 0;
  border-radius: 14px;
  padding: 12px 16px;
  font-weight: 700;
  font-size: 1rem;
}

.btn:active {
  transform: translateY(1px);
}

.btn.primary {
  width: 100%;
  color: #fff;
  background: linear-gradient(135deg, #ff7a48, #ff4d57);
}

.btn.secondary {
  color: #1f3557;
  background: #d6ebff;
}

.btn.ghost {
  width: 100%;
  margin-top: 10px;
  color: #6a7688;
  background: #edf2fb;
}

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

.stat {
  background: #e9f4ff;
  border-radius: 10px;
  padding: 6px;
  text-align: center;
}

.stat span {
  display: block;
  font-size: 0.72rem;
  color: #5f7897;
}

.status-row {
  margin: 10px 0 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.meter-wrap {
  flex: 1;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 6px;
  align-items: center;
  font-size: 0.82rem;
}

.meter {
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: #eceff6;
}

.meter i {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #ffce47, #ff7945, #ff3f5d);
  transition: width 0.18s ease;
}

.badge {
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.78rem;
  background: #eaf8f1;
  color: #1e8865;
  white-space: nowrap;
}

.board {
  --row-count: 9;
  --lane-count: 4;
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--lane-count), 1fr);
  gap: 6px;
  padding: 10px;
  border-radius: 16px;
  background:
    linear-gradient(180deg, #f2f8ff, #edf4ff),
    repeating-linear-gradient(to bottom, #ffffff22 0 10px, #ffffff66 10px 20px);
  border: 2px solid #d8e6ff;
}

.cell {
  height: 34px;
  border-radius: 8px;
  background: var(--lane);
  border: 2px solid transparent;
  position: relative;
  transition: transform 0.14s ease, background 0.14s ease;
}

.cell.safe {
  background: #e8f1ff;
  border-color: var(--lane-line);
}

.cell.warning {
  background: var(--warning-soft);
  border-color: #e6dac1;
}

.cell.warning.revealed {
  background: var(--warning);
  border-color: #f3a315;
}

.cell.danger {
  background: var(--danger);
  border-color: #1544ab;
}

.cell.player {
  border-color: var(--player);
  box-shadow: inset 0 0 0 2px #fff, 0 0 0 3px #ff935466;
}

.cell.player::after {
  content: "我";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 700;
  font-size: 0.78rem;
}

.cell.danger.player::after {
  content: "危";
}

.cell.crowd::before {
  content: "!";
  position: absolute;
  right: 4px;
  top: 1px;
  font-weight: 800;
  font-size: 0.78rem;
  color: #ff4f5f;
}

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

.btn.ctrl {
  color: #1b3a5e;
  background: #d9ecff;
}

.btn.ctrl:disabled {
  opacity: 0.45;
}

.toast {
  margin-top: 8px;
  min-height: 1.4em;
  font-size: 0.86rem;
  color: #576980;
  text-align: center;
}

.result-grid {
  margin: 12px 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.reason {
  margin: 8px 0 10px;
  line-height: 1.5;
  color: #5a3553;
}

#shareText {
  width: 100%;
  min-height: 92px;
  resize: none;
  border: 2px solid #dce6f7;
  border-radius: 12px;
  padding: 10px;
  font: inherit;
  background: #f8fbff;
  color: #2b3951;
}

.action-row {
  margin-top: 10px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.modal {
  position: fixed;
  inset: 0;
  background: #0e1728aa;
  display: none;
  place-items: center;
  padding: 16px;
}

.modal.show {
  display: grid;
}

.modal-card {
  width: min(420px, 100%);
  background: #fffef8;
  border-radius: 20px;
  padding: 16px;
  border: 3px solid #fff;
}

.countdown {
  margin-top: 6px;
  color: #7c4a25;
}

.buff-options {
  margin-top: 12px;
  display: grid;
  gap: 8px;
}

.buff-item {
  text-align: left;
  border: 2px solid #d9e7fb;
  background: #eef5ff;
  border-radius: 14px;
  padding: 10px;
  color: #1f3556;
}

.buff-item strong {
  display: block;
  margin-bottom: 4px;
}

.shake {
  animation: shake 0.18s linear 2;
}

@keyframes shake {
  0% { transform: translateX(-2px); }
  50% { transform: translateX(3px); }
  100% { transform: translateX(0); }
}

@media (max-width: 380px) {
  .cell {
    height: 30px;
  }

  h1 {
    font-size: 1.58rem;
  }
}
