:root {
  --bg: #0d1117;
  --panel: #161d26;
  --ink: #e8eef5;
  --muted: #8fa3b8;
  --board-edge: rgba(56, 189, 248, 0.16);
  --cellbg: #1e2733;
  --accent: #38bdf8;
  --merc: #fb7185;
  --tube: #2c3b4c;
  --good: #4ade80;
  --bad: #f87171;
  --hintc: #fbbf24;
  --cell: 52px;
  --cluew: 30px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(1100px 640px at 50% -8%, #16273a 0%, var(--bg) 60%);
  color: var(--ink);
  font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 20px 48px;
  text-align: center;
}

h1 {
  margin: 0;
  font-size: 34px;
  letter-spacing: 0.5px;
}
h1 span {
  color: var(--merc);
  text-shadow: 0 0 18px rgba(251, 113, 133, 0.45);
}
.sub {
  margin: 6px auto 20px;
  max-width: 600px;
  color: var(--muted);
}
.sub strong,
.note strong {
  color: var(--ink);
}

#wrap {
  display: flex;
  justify-content: center;
}

#board {
  display: grid;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--board-edge);
  border-radius: 14px;
  position: relative;
  gap: 0;
}

.badge {
  position: absolute;
  top: -9px;
  right: 14px;
  font-size: 11px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--bg);
  padding: 0 8px;
  border-radius: 6px;
}

.corner {
  width: var(--cluew);
  height: var(--cluew);
}

.clue {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-weight: 700;
  font-size: 15px;
}
.clue.col {
  width: var(--cell);
  height: var(--cluew);
}
.clue.row {
  width: var(--cluew);
  height: var(--cell);
}
.clue.done {
  color: var(--good);
  opacity: 0.75;
}
.clue.bad {
  color: var(--bad);
}

.cell {
  width: var(--cell);
  height: var(--cell);
  border: 1px solid rgba(143, 163, 184, 0.16);
  border-radius: 0;
  background: var(--cellbg);
  cursor: pointer;
  padding: 0;
  position: relative;
  transition: box-shadow 0.12s;
  overflow: hidden;
}
.cell:hover {
  box-shadow: inset 0 0 0 2px rgba(56, 189, 248, 0.35);
  z-index: 1;
}

/* glass tube */
.tube {
  position: absolute;
  background: var(--tube);
  pointer-events: none;
}
.tube.core {
  left: 28%;
  top: 28%;
  width: 44%;
  height: 44%;
  border-radius: 50%;
}
.tube.core.bulb {
  left: 12%;
  top: 12%;
  width: 76%;
  height: 76%;
  box-shadow: inset 0 0 0 2px rgba(143, 163, 184, 0.25);
}
.tube.arm-up {
  left: 28%;
  top: 0;
  width: 44%;
  height: 50%;
}
.tube.arm-down {
  left: 28%;
  top: 50%;
  width: 44%;
  height: 50%;
}
.tube.arm-left {
  left: 0;
  top: 28%;
  width: 50%;
  height: 44%;
}
.tube.arm-right {
  left: 50%;
  top: 28%;
  width: 50%;
  height: 44%;
}

/* mercury */
.merc {
  position: absolute;
  background: var(--merc);
  pointer-events: none;
  display: none;
  box-shadow: 0 0 10px rgba(251, 113, 133, 0.35);
}
.cell.filled .merc.on {
  display: block;
}
.merc.core {
  left: 37%;
  top: 37%;
  width: 26%;
  height: 26%;
  border-radius: 50%;
}
.merc.core.bulb {
  left: 24%;
  top: 24%;
  width: 52%;
  height: 52%;
}
.merc.arm-up {
  left: 37%;
  top: 0;
  width: 26%;
  height: 52%;
}
.merc.arm-down {
  left: 37%;
  top: 48%;
  width: 26%;
  height: 52%;
}
.merc.arm-left {
  left: 0;
  top: 37%;
  width: 52%;
  height: 26%;
}
.merc.arm-right {
  left: 48%;
  top: 37%;
  width: 52%;
  height: 26%;
}

/* cross mark */
.cell.crossed::after {
  content: '×';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 20px;
  font-weight: 600;
  z-index: 2;
}

.cell.conflict {
  box-shadow: inset 0 0 0 2px rgba(248, 113, 113, 0.65);
  z-index: 1;
}
.cell.conflict .merc {
  background: var(--bad);
}
.cell.conflict::after {
  color: var(--bad);
}
.cell.hinted {
  box-shadow: inset 0 0 0 3px var(--hintc);
  z-index: 1;
}

#board.won .cell {
  cursor: default;
}
#board.won .merc {
  background: var(--good);
  box-shadow: 0 0 10px rgba(74, 222, 128, 0.4);
}

.hud {
  min-height: 26px;
  margin: 14px 0 4px;
}
#status {
  color: var(--muted);
}
#status.good {
  color: var(--good);
}
#status.bad {
  color: var(--bad);
}
#status.hint {
  color: var(--hintc);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  align-items: center;
  margin-top: 10px;
}
.controls label {
  color: var(--muted);
  font-size: 14px;
  display: flex;
  gap: 6px;
  align-items: center;
}
select,
button {
  background: var(--panel);
  color: var(--ink);
  border: 1px solid rgba(143, 163, 184, 0.35);
  border-radius: 9px;
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
  transition: border-color 0.12s, box-shadow 0.12s;
}
select:hover,
button:hover {
  border-color: var(--accent);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.25);
}

.note {
  margin: 34px auto 0;
  max-width: 640px;
  text-align: left;
  color: var(--muted);
  font-size: 14px;
  border-top: 1px solid rgba(143, 163, 184, 0.18);
  padding-top: 18px;
}

@media (max-width: 560px) {
  :root {
    --cell: 38px;
    --cluew: 24px;
  }
}
:root{--bg:#101e1b;--panel:#203e36;--ink:#fff5de;--muted:#d3d6bb;--tube:#81a39a;--merc:#f25937;--cellbg:#19342f;--accent:#f0b875;--board-edge:#8d7858;--cell:min(54px,calc((100vw - 76px)/8));--cluew:24px}
html,body{background:#101e1b;color:var(--ink)}body{min-height:100vh;background:linear-gradient(90deg,#091812d9,#14282355),url('./glasshouse.webp') center/cover fixed}
main{min-height:100vh;max-width:1120px;display:grid;grid-template-columns:1fr auto;align-items:center;gap:3vw;text-align:left;padding:4vw}
header{max-width:530px}h1{font:normal clamp(56px,7.6vw,105px)/.9 Georgia,serif;letter-spacing:-.055em;text-shadow:0 2px 15px #101b14}h1 i{font-weight:normal;color:#f4b588}header p{font:19px/1.55 Georgia,serif;max-width:32ch;color:#f7ebd7}
section{background:#142a25f5;border:1px solid #a58c66;border-radius:14px;box-shadow:0 20px 60px #07100ba8;padding:22px;min-width:min(450px,90vw);text-align:center}
#board{background:#203930;box-shadow:0 3px 8px #0005;padding:10px}.badge{display:none}.cell{background:linear-gradient(150deg,#29463d,#122c25)}.tube.core.bulb{background:radial-gradient(circle at 32% 25%,#d4eee4,#8ea69b 40%,#54796d 72%)}.filled .merc.core.bulb{background:radial-gradient(circle at 35% 30%,#ffe1bf,#fa6441 46%,#a73924)}.hud{max-width:400px;margin:16px auto;min-height:45px}.top{margin:0 0 18px;justify-content:space-between}button,select{font-size:15px}#new,#check{background:#f0c39b;color:#2a261e}.cell:focus-visible{outline:3px solid #ffd194;outline-offset:-3px;z-index:2}
@media(max-width:800px){main{grid-template-columns:1fr;align-content:center;padding:20px 12px;gap:12px}header,section{width:min(100%,530px);margin:auto}h1{font-size:48px}h1 br{display:none}h1 i:before{content:' '}header p{font-size:16px;max-width:50ch;margin:10px 0}section{padding:12px;min-width:0}}
