/* 点灯笼 — 灯会夜主题 */
:root {
  --bg: #12142b;
  --bg2: #1b1e3d;
  --panel: #23264d;
  --panel2: #2c2f5c;
  --text: #f5eeda;
  --muted: #a9a8c7;
  --gold: #f5b942;
  --gold2: #ffcf6e;
  --red: #e23b3b;
  --lantern: #ff5a3c;
  --cell: #2a2d55;
  --cell-lit: #6b4d16;
  --cell-lit2: #8a651d;
  --wall: #171830;
  --accent: #ff8c42;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { min-height: 100%; }
body {
  background: radial-gradient(1200px 600px at 50% -10%, #2a2350 0%, var(--bg) 55%);
  color: var(--text);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  display: flex; flex-direction: column; align-items: center;
  padding: 0 12px 40px;
}
a { color: var(--gold); }

/* ---------- header ---------- */
header { text-align: center; padding: 22px 0 6px; }
header h1 { font-size: 30px; letter-spacing: 4px; }
header h1 span { color: var(--gold); }
header p { color: var(--muted); font-size: 13px; margin-top: 6px; letter-spacing: 1px; }
.brand { font-size: 12px; color: var(--muted); margin-top: 4px; }
.brand b { color: var(--gold); letter-spacing: 2px; }

/* ---------- screens ---------- */
.screen { width: 100%; max-width: 460px; display: none; }
.screen.active { display: block; }

/* ---------- menu ---------- */
.daily-card {
  background: linear-gradient(135deg, #7a2d12, #a83c14);
  border: 1px solid #ff8c42;
  border-radius: 16px; padding: 16px 18px; margin: 14px 0;
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  cursor: pointer;
}
.daily-card .t { font-size: 18px; font-weight: bold; }
.daily-card .s { font-size: 12px; color: #ffd9b0; margin-top: 4px; }
.daily-card .streak { font-size: 13px; background: rgba(0,0,0,.25); border-radius: 999px; padding: 6px 12px; white-space: nowrap; }
.daily-card.done { opacity: .65; }
.chapter { margin-top: 18px; }
.chapter h2 { font-size: 15px; color: var(--gold); letter-spacing: 2px; margin-bottom: 10px; }
.chapter h2 small { color: var(--muted); font-weight: normal; letter-spacing: 0; margin-left: 6px; }
.level-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.level-btn {
  aspect-ratio: 1; border-radius: 12px; border: 1px solid #3a3e78;
  background: var(--panel); color: var(--text);
  font-size: 18px; font-weight: bold; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
.level-btn .stars { font-size: 10px; color: var(--gold); letter-spacing: 1px; }
.level-btn.locked { opacity: .35; cursor: not-allowed; }
.level-btn.done { border-color: var(--gold); }
.menu-foot { text-align: center; color: var(--muted); font-size: 12px; margin-top: 22px; line-height: 1.9; }
.menu-foot button {
  background: none; border: 1px solid #3a3e78; color: var(--gold);
  border-radius: 999px; padding: 6px 16px; font-size: 13px; cursor: pointer; margin-top: 6px;
}

/* ---------- game HUD ---------- */
.hud { display: flex; justify-content: space-between; align-items: center; margin: 12px 0 10px; gap: 8px; }
.hud .back {
  background: var(--panel); border: 1px solid #3a3e78; color: var(--text);
  border-radius: 999px; padding: 7px 14px; font-size: 14px; cursor: pointer;
}
.hud .title { font-size: 16px; font-weight: bold; text-align: center; }
.hud .title small { display: block; font-size: 11px; color: var(--muted); font-weight: normal; margin-top: 2px; }
.hud .timer { font-size: 15px; color: var(--gold); font-variant-numeric: tabular-nums; min-width: 52px; text-align: right; }
.progress { height: 6px; background: var(--panel); border-radius: 999px; overflow: hidden; margin-bottom: 12px; }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), var(--accent)); width: 0%; transition: width .3s; }

/* ---------- board ---------- */
.board-wrap { display: flex; justify-content: center; }
.board {
  display: grid; gap: 4px; width: min(92vw, 420px);
  background: var(--bg2); border: 1px solid #34386e; border-radius: 16px; padding: 8px;
  touch-action: manipulation; user-select: none;
}
.cell {
  aspect-ratio: 1; border-radius: 7px; background: var(--cell);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: bold; cursor: pointer; position: relative;
  transition: background .15s;
}
.cell.lit { background: linear-gradient(135deg, var(--cell-lit), var(--cell-lit2)); }
.cell.wall { background: var(--wall); cursor: default; box-shadow: inset 0 0 0 1px #262850; }
.cell.wall.num { color: var(--gold2); font-size: 22px; }
.cell.wall.bad { color: #ff7a7a; box-shadow: inset 0 0 0 2px #ff5a5a; }
.cell .beam-h, .cell .beam-v { position: absolute; inset: 0; border-radius: 7px; pointer-events: none; }
.cell .beam-h { background: linear-gradient(90deg, rgba(245,185,66,.28), rgba(245,185,66,.05) 45%, rgba(245,185,66,.05) 55%, rgba(245,185,66,.28)); }
.cell .beam-v { background: linear-gradient(180deg, rgba(245,185,66,.28), rgba(245,185,66,.05) 45%, rgba(245,185,66,.05) 55%, rgba(245,185,66,.28)); }
.cell .lan { position: relative; z-index: 1; font-size: 24px; line-height: 1; filter: drop-shadow(0 0 6px rgba(255,120,60,.9)); }
.cell .lan.v { transform: rotate(90deg); }
.cell.conflict { box-shadow: inset 0 0 0 2px #ff4d4d; animation: pulse .7s infinite alternate; }
.cell .mk { position: absolute; right: 2px; top: 0px; font-size: 13px; color: #8d8cb5; z-index: 1; }
@keyframes pulse { from { box-shadow: inset 0 0 0 2px rgba(255,77,77,.55); } to { box-shadow: inset 0 0 0 2px rgba(255,77,77,1); } }

/* ---------- toolbar ---------- */
.toolbar { display: flex; gap: 10px; margin-top: 14px; }
.tool {
  flex: 1; padding: 11px 0; border-radius: 12px; border: 1px solid #3a3e78;
  background: var(--panel); color: var(--text); font-size: 15px; cursor: pointer;
}
.tool.on { border-color: var(--gold); background: #3a2f16; color: var(--gold2); }
.tool:disabled { opacity: .45; cursor: not-allowed; }
.rule-line { text-align: center; color: var(--muted); font-size: 12px; margin-top: 12px; line-height: 1.8; }

/* ---------- modal ---------- */
.modal-bg {
  position: fixed; inset: 0; background: rgba(8,9,20,.72);
  display: none; align-items: center; justify-content: center; padding: 20px; z-index: 10;
}
.modal-bg.show { display: flex; }
.modal {
  background: var(--panel); border: 1px solid #3a3e78; border-radius: 20px;
  padding: 26px 22px; max-width: 380px; width: 100%; text-align: center;
}
.modal h2 { font-size: 22px; margin-bottom: 8px; }
.modal .stars-big { font-size: 26px; color: var(--gold); letter-spacing: 4px; margin: 6px 0; }
.modal p { color: var(--muted); font-size: 14px; line-height: 1.9; }
.modal .btns { display: flex; gap: 10px; margin-top: 18px; }
.modal .btns button {
  flex: 1; padding: 12px 0; border-radius: 12px; border: none; font-size: 15px; cursor: pointer;
}
.btn-primary { background: var(--gold); color: #231a05; font-weight: bold; }
.btn-ghost { background: var(--panel2); color: var(--text); border: 1px solid #3a3e78 !important; }
.modal .howto { text-align: left; font-size: 14px; line-height: 2; color: var(--text); margin: 10px 0; }
.modal .howto b { color: var(--gold2); }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(20px);
  background: #33365f; border: 1px solid #4a4e85; color: var(--text);
  padding: 10px 18px; border-radius: 999px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: all .25s; z-index: 20; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

footer { text-align: center; color: var(--muted); font-size: 12px; margin-top: 26px; line-height: 1.8; }
