:root {
  --bg: #0b0e16;
  --panel: #1a1f2c;
  --panel2: #252c3d;
  --text: #f1f3f8;
  --muted: #98a1b4;
  --good: #5fe08f;
  --bad: #ff6464;
  --glow: 255, 205, 90;   /* r, g, b of the light; set per skin */
  --sky: #2a2312;         /* tint at the top of the page; set per skin */
  --dark: #222a3c;        /* an unlit cell */
  --cell: 40px;
  --gap: 3px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; color: var(--text); overflow: hidden;
  font: 14px/1.3 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(120% 80% at 50% 0%, var(--sky) 0%, #10131d 55%, var(--bg) 100%) fixed var(--bg); }
.sky { position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: .4;
  background: url("img/night.webp") center / cover no-repeat; mix-blend-mode: screen; }
#app { position: relative; z-index: 1; height: 100vh; height: 100dvh; max-width: 620px; margin: 0 auto; display: flex;
  flex-direction: column; gap: 6px; padding: 10px 12px; }

/* ---------- header ---------- */
.top { display: flex; align-items: center; gap: 10px; min-height: 38px; }
.logo { width: 36px; height: 36px; flex: none; border-radius: 11px; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 45%, rgba(var(--glow), .35), #232a3c 70%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 0 14px rgba(var(--glow), .25); color: rgb(var(--glow)); }
.logo svg { width: 24px; height: 24px; filter: drop-shadow(0 0 4px rgba(var(--glow), .8)); }
.heading { flex: 1; min-width: 0; }
.title { font-weight: 800; font-size: 17px; letter-spacing: .2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.teaser { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.status { display: flex; gap: 6px; align-items: center; }
.pill { background: var(--panel); border: 1px solid #2b3245; border-radius: 99px; padding: 4px 11px; font-size: 13px;
  font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; display: flex; align-items: center; gap: 5px; height: 28px; }
.pill.dim { color: var(--muted); font-weight: 600; }
.pill.lamps svg { width: 16px; height: 16px; color: rgb(var(--glow)); filter: drop-shadow(0 0 3px rgba(var(--glow), .7)); }
.pill.lamps.full { border-color: rgba(var(--glow), .55); }
.pill.lamps small { color: var(--muted); font-weight: 600; font-size: 12px; }
.meter { flex: 1; min-width: 60px; height: 28px; position: relative; border-radius: 99px; overflow: hidden;
  background: var(--panel); border: 1px solid #2b3245; }
.meter .fill { position: absolute; inset: 0 auto 0 0; width: 0; transition: width .45s ease;
  background: linear-gradient(90deg, rgba(var(--glow), .25), rgba(var(--glow), .7)); box-shadow: 0 0 12px rgba(var(--glow), .5); }
.meter span { position: relative; display: block; text-align: center; line-height: 26px; font-size: 12.5px; font-weight: 700;
  font-variant-numeric: tabular-nums; text-shadow: 0 1px 2px rgba(0,0,0,.6); }

/* ---------- board ---------- */
.stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; }
.board { display: grid; gap: var(--gap); padding: 7px; border-radius: 14px; background: #070910;
  box-shadow: 0 10px 30px rgba(0,0,0,.5), inset 0 0 0 1px rgba(255,255,255,.05); transition: box-shadow .8s;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: manipulation; }
.cell { width: var(--cell); height: var(--cell); border-radius: calc(var(--cell) * .16); display: flex; align-items: center;
  justify-content: center; position: relative; }

/* white cells: dark until a light reaches them */
.cell.w { cursor: pointer; background-color: var(--dark); box-shadow: inset 0 0 0 1px rgba(255,255,255,.035);
  transition: background-color .32s ease-out, box-shadow .32s ease-out; }
@media (hover: hover) { .cell.w:not(.l1):not(.l2):not(.l3):hover { background-color: #2c354b; } }
.cell.w:active { transform: scale(.95); }
.cell.w.l1 { background-color: rgba(var(--glow), .45); background-color: color-mix(in srgb, rgb(var(--glow)) 44%, var(--dark));
  box-shadow: inset 0 0 calc(var(--cell) * .35) rgba(var(--glow), .35); }
.cell.w.l2 { background-color: rgba(var(--glow), .55); background-color: color-mix(in srgb, rgb(var(--glow)) 56%, var(--dark));
  box-shadow: inset 0 0 calc(var(--cell) * .35) rgba(var(--glow), .45); }
.cell.w.l3 { background-color: rgba(var(--glow), .65); background-color: color-mix(in srgb, rgb(var(--glow)) 66%, var(--dark));
  box-shadow: inset 0 0 calc(var(--cell) * .35) rgba(var(--glow), .5); }

.cell.lamp { background-image: radial-gradient(circle, rgba(255,255,255,.7) 0%, rgba(255,255,255,0) 62%); z-index: 1; }
.cell.lamp svg { width: 76%; height: 76%; pointer-events: none; color: #fffaf0;
  color: color-mix(in srgb, rgb(var(--glow)) 45%, #fff);
  filter: drop-shadow(0 1px 1px rgba(0,0,0,.55)) drop-shadow(0 0 5px rgba(var(--glow), .95)); animation: pop .28s ease-out; }
.cell.lamp.bad { background-color: #7a2a33 !important; background-image: none; box-shadow: inset 0 0 0 2px var(--bad); }
.cell.lamp.bad svg { color: #ff9a9a; filter: drop-shadow(0 1px 1px rgba(0,0,0,.6)); animation: pop .28s ease-out, wobble .4s .1s; }
.cell.mark::after { content: ""; width: 20%; height: 20%; border-radius: 50%; background: #7d879c; }
.cell.mark.l1::after, .cell.mark.l2::after, .cell.mark.l3::after { background: rgba(20, 16, 8, .55); }

/* walls */
.cell.wall { background: linear-gradient(160deg, #11151f 0%, #090b11 100%); color: #eef1f8; cursor: default;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08), inset 0 0 0 1px rgba(255,255,255,.03);
  font-weight: 800; font-size: calc(var(--cell) * .48); font-variant-numeric: tabular-nums; transition: color .25s, background .25s; }
.cell.wall.ok { color: var(--good); text-shadow: 0 0 8px rgba(95,224,143,.5); }
.cell.wall.over { color: #ffd6d6; background: linear-gradient(160deg, #5a222a 0%, #34141a 100%); }

/* hints */
.board .cell.hl-from { box-shadow: inset 0 0 0 2px #ffd65a, 0 0 12px rgba(255,214,90,.5); animation: pulse 1.1s ease-in-out infinite; z-index: 2; }
.board .cell.hl-lamp { box-shadow: inset 0 0 0 3px var(--good), 0 0 14px rgba(95,224,143,.6); animation: pulse 1.1s ease-in-out infinite; z-index: 2; }
.board .cell.hl-dark { box-shadow: inset 0 0 0 3px var(--bad), 0 0 14px rgba(255,100,100,.55); animation: pulse 1.1s ease-in-out infinite; z-index: 2; }

/* solved / revealed */
.board.won { box-shadow: 0 10px 30px rgba(0,0,0,.5), 0 0 46px rgba(var(--glow), .35), inset 0 0 0 1px rgba(var(--glow), .3); }
.board.won .cell.w { animation: bloom 1s ease-out both; }
.board.won .cell.wall.ok { color: rgb(var(--glow)); text-shadow: 0 0 8px rgba(var(--glow), .6); }
.board .cell.w.given svg { opacity: .8; }
.board .cell.w.given { box-shadow: inset 0 0 0 2px rgba(255,255,255,.6); }
.cell.wrong::before { content: ""; position: absolute; inset: 20%; z-index: 2;
  background: linear-gradient(45deg, transparent 44%, var(--bad) 44% 56%, transparent 56%),
              linear-gradient(-45deg, transparent 44%, var(--bad) 44% 56%, transparent 56%); }

/* ---------- message + bar ---------- */
.msg { min-height: 38px; display: flex; align-items: center; justify-content: center; text-align: center; font-size: 13.5px;
  color: var(--muted); padding: 0 4px; line-height: 1.3; }
.msg.good { color: var(--good); font-weight: 700; }
.msg.bad { color: var(--bad); font-weight: 600; }
.msg.hint { color: #f1dc8f; }
.msg .g { color: var(--good); font-weight: 700; }
.msg .r { color: var(--bad); font-weight: 700; }
.msg .y { color: #ffd65a; font-weight: 700; }
.msg.result { color: var(--text); font-weight: 600; gap: 10px; animation: rise .5s ease-out both; }
.msg.result .emo { width: 32px; height: 32px; flex: none; color: rgb(var(--glow)); }
.msg.result .emo svg { width: 100%; height: 100%; filter: drop-shadow(0 0 6px rgba(var(--glow), .8)); }
.msg.result small { display: block; color: var(--muted); font-weight: 400; font-size: 12.5px; margin-top: 2px; }

.bar { display: flex; gap: 6px; }
.bar > button, .seg button { height: 40px; border: 0; border-radius: 10px; background: var(--panel); color: var(--text);
  font: 600 13.5px system-ui, sans-serif; cursor: pointer; padding: 0 10px; white-space: nowrap; touch-action: manipulation; }
.bar > button { flex: 1; }
.bar > button.icon { flex: none; width: 44px; padding: 0; font-size: 19px; }
.bar > button:disabled, .seg button:disabled { opacity: .4; cursor: default; }
.bar > button.confirm { background: #5a2630; color: #ffd6d6; }
#hint b { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 3px; border-radius: 99px; background: #3a3220;
  color: #ffc94d; font-size: 12px; line-height: 18px; }
.seg { display: flex; background: var(--panel); border-radius: 10px; padding: 3px; gap: 3px; flex: 1.7; min-width: 0; }
.seg button { flex: 1; min-width: 0; height: 34px; border-radius: 8px; background: transparent; color: var(--muted); padding: 0 6px;
  display: flex; align-items: center; justify-content: center; gap: 5px; }
.seg button.on { background: var(--panel2); color: var(--text); box-shadow: inset 0 1px 0 rgba(255,255,255,.08); }
.seg .lbl { overflow: hidden; text-overflow: ellipsis; }
.seg .ico { width: 18px; height: 18px; flex: none; display: flex; align-items: center; justify-content: center; }
.seg .ico svg { width: 18px; height: 18px; }
#modeLamp.on .ico { color: rgb(var(--glow)); filter: drop-shadow(0 0 3px rgba(var(--glow), .7)); }
.seg .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

@media (max-width: 400px) {
  .bar > button, .seg button { font-size: 12.5px; padding: 0 6px; }
  .bar > button.icon { width: 38px; }
  .title { font-size: 16px; }
  .meter span { font-size: 11.5px; }
}
@media (max-width: 340px) { .seg .lbl { display: none; } }

@keyframes pop { 0% { transform: scale(.3); opacity: 0; } 70% { transform: scale(1.12); } 100% { transform: none; opacity: 1; } }
@keyframes wobble { 25% { transform: rotate(-12deg); } 75% { transform: rotate(12deg); } }
@keyframes bloom { 0% { filter: brightness(1); } 35% { filter: brightness(1.7) saturate(1.2); } 100% { filter: brightness(1.12); } }
@keyframes pulse { 50% { filter: brightness(1.35); } }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
@keyframes rise { 0% { transform: translateY(8px); opacity: 0; } 100% { transform: none; opacity: 1; } }
.board.shake { animation: shake .4s; }
