:root { --night:#14213A; --deep:#0C1526; --gold:#E7C27A; --ink:#F4EEDF; --soft:#B9C2D3; --line:#2E3E5C; --card:#1C2B48; --pine:#142C29; }
* { box-sizing: border-box; }
/* Elements styled with display (the guess box, the previous/next row) must still hide when marked hidden. */
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: radial-gradient(120% 80% at 50% 0%, #1E2F4F 0%, var(--deep) 70%); color: var(--ink); font: 16px/1.6 "PingFang TC", "Microsoft JhengHei", "Noto Sans CJK TC", "Noto Sans TC", system-ui, sans-serif; min-height: 100vh; }
.skip-link { position: absolute; left: -999px; }
.skip-link:focus { left: 8px; top: 8px; background: var(--gold); color: var(--deep); padding: 6px 10px; z-index: 5; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.site-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.brand { font-weight: 800; letter-spacing: .06em; font-size: 13px; }
.toy-label { font-size: 13px; color: var(--gold); border: 1px solid var(--gold); border-radius: 999px; padding: 2px 10px; }
.language { margin-left: auto; display: flex; gap: 4px; }
.language button { background: none; color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: 4px 10px; cursor: pointer; font: inherit; font-size: 14px; }
.language button[aria-pressed="true"] { background: var(--gold); color: var(--deep); }
main { max-width: 1100px; margin: 0 auto; padding: 16px; display: grid; gap: 16px; }
@media (min-width: 900px) { main { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); align-items: start; } .stage { position: sticky; top: 16px; } }

/* Stage: a bright, neutral room (daylight) that the page dims when the lamps are switched on.
   The scene box keeps the picture's own proportions, so every position below is a percentage of the picture itself.
   On phones the stage is a 3:4 window onto the tall picture (slid up a little); on wide screens the stage is the picture. */
.stage { position: relative; overflow: hidden; border: 1px solid var(--line); border-radius: 16px; aspect-ratio: 16 / 10; background: #E9E3D6; }
.scene { position: absolute; inset: 0; --ar: 1.6; background: #E9E3D6 center / 100% 100% no-repeat; }
/* Trial room: Codex painted both lamps into the picture (sample in the case, trial lamp on the table), so no code lamps are drawn here. */
.stage[data-screen="0"] .scene, .stage[data-screen="1"] .scene { background-image: url("assets/scene-trial-lamps-desktop.webp"); }
.stage[data-screen="0"] .sample, .stage[data-screen="1"] .sample, .stage[data-screen="0"] .lamp-btn.trial, .stage[data-screen="1"] .lamp-btn.trial { display: none; }
.stage[data-screen="2"] .scene, .stage[data-screen="3"] .scene, .stage[data-screen="4"] .scene { background-image: url("assets/scene-row-desktop.webp"); }
@media (max-width: 639px) {
  .stage { aspect-ratio: 3 / 4; }
  .scene { inset: auto; left: 0; top: 0; width: 100%; aspect-ratio: 780 / 1400; transform: translateY(-8%); --ar: .5571; }
  .stage[data-screen="2"] .scene, .stage[data-screen="3"] .scene, .stage[data-screen="4"] .scene { transform: translateY(-18%); }
  .stage[data-screen="0"] .scene, .stage[data-screen="1"] .scene { background-image: url("assets/scene-trial-lamps-mobile.webp"); }
  .stage[data-screen="2"] .scene, .stage[data-screen="3"] .scene, .stage[data-screen="4"] .scene { background-image: url("assets/scene-row-mobile.webp"); }
}
/* A lamp is a square picture whose base line sits 88% of the way down; (--x, --y) is where that base line stands, --w is its width as a percent of the picture. */
.sample, .lamp-btn { position: absolute; left: calc(var(--x) - var(--w) * .5%); top: calc(var(--y) - var(--w) * var(--ar) * .884%); width: calc(var(--w) * 1%); aspect-ratio: 1; padding: 0; margin: 0; border: 0; background: none; transition: opacity .25s, left .3s, top .3s, width .3s; }
.lamp-btn { cursor: pointer; --w: 15; }
.lamps { position: absolute; inset: 0; z-index: 4; pointer-events: none; }
.lamp-btn { pointer-events: auto; }
/* bulk row: five wall shelves */
/* Measured on the pictures: wall-shelf tops at y 55.8%, shelf centres at x 18.75 / 34.65 / 50.6 / 66.4 / 82.4%. */
.lamp-btn[data-i="0"] { --x: 18.75%; --y: 55.8%; } .lamp-btn[data-i="1"] { --x: 34.65%; --y: 55.8%; } .lamp-btn[data-i="2"] { --x: 50.6%; --y: 55.8%; } .lamp-btn[data-i="3"] { --x: 66.4%; --y: 55.8%; } .lamp-btn[data-i="4"] { --x: 82.4%; --y: 55.8%; }
/* approved sample: inside the display case on the trial table; on a sealed stand on the counter in the buyer's space */
/* In the trial room the sample stands on the floor of the glass case (centre x 18.2%, floor y 55.8%). */
.sample { --w: 16; --x: 18.2%; --y: 55.8%; z-index: 4; }
/* In the row room it sits in a sealed dome on the counter top (clear of the plants; counter top y about 82%). --w is the dome's width here. */
.stage[data-screen="2"] .sample, .stage[data-screen="3"] .sample, .stage[data-screen="4"] .sample { --w: 14; --x: 23%; --y: 82%; }
.sample .stand, .sample .tagcard { position: absolute; display: none; pointer-events: none; }
/* The dome picture: feet at 94.8% of its height, inner floor at 69.8%. Its feet go on the same base line (88.4%) as a lamp's, so the --y rule is shared. */
.stage[data-screen="2"] .sample .stand, .stage[data-screen="3"] .sample .stand, .stage[data-screen="4"] .sample .stand { display: block; left: 0; top: -6.4%; width: 100%; height: auto; }
/* The tag beside the dome is a button: turned over, it shows a small handwritten note (a quiet echo, not explained). */
.tagbtn { display: none; position: absolute; z-index: 5; padding: 0; border: 0; background: none; cursor: pointer; width: calc(var(--w) * .36%); left: calc(var(--x) - var(--w) * .5% + var(--w) * .74%); top: calc(var(--y) - var(--w) * var(--ar) * .884% + var(--w) * var(--ar) * .52%); transform: rotate(8deg); }
.tagbtn img { display: block; width: 100%; height: auto; }
.stage[data-screen="2"] .tagbtn, .stage[data-screen="3"] .tagbtn, .stage[data-screen="4"] .tagbtn { display: block; --w: 14; --x: 23%; --y: 82%; }
.stage[data-mode="single"] .tagbtn { display: none; }
.tagnote { position: absolute; z-index: 6; left: 4%; top: 6%; max-width: min(78%, 340px); margin: 0; padding: 12px 14px; background: #FBF6EA; color: #3A2E1E; border-radius: 6px; box-shadow: 0 6px 18px rgba(0,0,0,.25); transform: rotate(-1.5deg); font-family: "Kaiti TC", "BiauKai", "STKaiti", "KaiTi", "Segoe Print", cursive; font-size: 16px; line-height: 1.6; }
/* Inside the dome the lamp is half the dome's width and its base stands on the dome's inner floor (63.4% of this box). */
.stage[data-screen="2"] .sample .lamp, .stage[data-screen="3"] .sample .lamp, .stage[data-screen="4"] .sample .lamp { inset: auto; left: 25%; top: 19.2%; width: 50%; height: 50%; }
/* trial table: one trial lamp on the big table */
/* The trial lamp stands in the middle of the big table top (front edge is at y 72%). */
.lamp-btn.trial { display: none; --x: 62%; --y: 65.5%; --w: 17; }
.stage[data-screen="0"] .lamp-btn[data-id], .stage[data-screen="1"] .lamp-btn[data-id] { display: none; }
@media (max-width: 639px) {
  .lamp-btn { --w: 28; }
  /* Measured: upper shelves top y 32.6% at x 25.8 / 51.5 / 77.7%; lower shelves top y 51.1% at x 37.9 / 65.5%. */
  .lamp-btn[data-i="0"] { --x: 25.8%; --y: 32.6%; } .lamp-btn[data-i="1"] { --x: 51.5%; --y: 32.6%; } .lamp-btn[data-i="2"] { --x: 77.7%; --y: 32.6%; }
  .lamp-btn[data-i="3"] { --x: 37.9%; --y: 51.1%; } .lamp-btn[data-i="4"] { --x: 65.5%; --y: 51.1%; }
  .sample { --w: 24; --x: 50%; --y: 31.4%; }
  .stage[data-screen="2"] .sample, .stage[data-screen="3"] .sample, .stage[data-screen="4"] .sample { --w: 30; --x: 30%; --y: 78.2%; }
  .lamp-btn.trial { --x: 60%; --y: 64%; --w: 34; }
}
/* one by one: the lamp stands large, in the middle */
.stage[data-mode="single"] .lamp-btn { opacity: 0; pointer-events: none; }
/* One by one: the lamp is taken down and stood on the counter top. */
.stage[data-mode="single"] .lamp-btn.current { opacity: 1; pointer-events: auto; --x: 52%; --y: 81.5%; --w: 34; }
.stage[data-mode="single"] .sample { opacity: 0; }
@media (max-width: 639px) { .stage[data-mode="single"] .lamp-btn.current { --x: 50%; --y: 77.5%; --w: 50; } }
/* On a wall shelf the cord would hang in the air past the shelf end, so it is not drawn there. */
.stage[data-mode="side"][data-screen="2"] .lamp-btn .cord, .stage[data-screen="3"] .lamp-btn .cord, .stage[data-screen="4"] .lamp-btn .cord { display: none; }
/* A soft contact shadow under every base. */
/* The windows are behind the lamps, so the shadow falls a little towards the viewer. */
.contact { position: absolute; left: 20%; width: 60%; top: 85.5%; height: 8%; border-radius: 50%; background: radial-gradient(60% 55% at 50% 35%, rgba(60, 34, 12, .5), rgba(60, 34, 12, 0)); filter: blur(1px); }
.lamp { position: absolute; inset: 0; }
.layer { position: absolute; inset: 0; width: 100%; height: 100%; }
.tint { background: var(--tint); mix-blend-mode: multiply; -webkit-mask: var(--shade-mask) center / 100% 100% no-repeat; mask: var(--shade-mask) center / 100% 100% no-repeat; }
.glow { opacity: 0; transition: opacity .3s; mix-blend-mode: screen; }
.lamp::before { content: ""; position: absolute; inset: -18%; background: radial-gradient(closest-side, var(--glowc, rgba(255,206,120,.7)), transparent 72%); opacity: 0; transition: opacity .3s; pointer-events: none; }
.stage.lit .lamp::before { opacity: 1; }
.stage.lit .glow { opacity: 1; }
.stage.lit .shade, .stage.lit .tint { filter: brightness(1.18); }
/* Lit shade: the light shows through the shade itself, in each lamp's own light colour. */
.litglow { background: radial-gradient(70% 80% at 50% 60%, var(--glowc, rgba(255,206,120,.8)) 0%, rgba(255,255,255,0) 100%); -webkit-mask: var(--shade-mask) center / 100% 100% no-repeat; mask: var(--shade-mask) center / 100% 100% no-repeat; mix-blend-mode: screen; opacity: 0; transition: opacity .3s; }
.stage.lit .litglow { opacity: 1; }
/* Room light: the lamp parts come from a flat-shaded set, the rooms are warm sunlit paintings.
   A warm grade and a soft light over the shade (bright on top, shaded underneath) let the lamps sit in the same light.
   The same grade goes on every lamp, so the differences between them stay exactly as they are. */
.scene .lamp { filter: sepia(.22) saturate(1.12) brightness(1.02) contrast(.95) blur(.25px); }
.sun { background: linear-gradient(to bottom, rgba(255, 226, 168, .55) 0%, rgba(255, 214, 150, .18) 45%, rgba(96, 60, 28, .32) 100%); mix-blend-mode: soft-light; -webkit-mask: var(--shade-mask) center / 100% 100% no-repeat; mask: var(--shade-mask) center / 100% 100% no-repeat; }
.stage.lit .sun { opacity: 0; }
.dim { position: absolute; inset: 0; z-index: 3; pointer-events: none; background: rgba(8, 14, 28, 0); transition: background .35s; }
.stage.lit .dim { background: rgba(8, 14, 28, .62); }
/* The letter sits just under the base line (on the shelf front), so it never hides the base colour. */
.lamp-btn .letter { position: absolute; left: 50%; top: 90%; transform: translateX(-50%); min-width: 26px; padding: 0 8px; text-align: center; font-size: 14px; font-weight: 800; color: var(--deep); background: #F4EEDF; border: 2px solid #A59676; border-radius: 999px; line-height: 22px; }
.lamp-btn[aria-pressed="true"] .lamp::after { content: ""; position: absolute; inset: 4%; border: 3px solid #E0874A; border-radius: 14px; }
.lamp-btn[aria-pressed="true"] .letter { background: #E0874A; border-color: #E0874A; color: #fff; }
.stage[data-screen="1"] .lamp-btn, .stage[data-screen="3"] .lamp-btn { cursor: default; }

.panel { display: grid; gap: 12px; align-content: start; min-width: 0; }
.screen { display: grid; gap: 12px; align-content: start; min-width: 0; }
.screen[hidden] { display: none; }
h1 { margin: 0; font-size: clamp(2rem, 6vw, 3rem); line-height: 1.15; } h2 { margin: 0; font-size: 1.5rem; line-height: 1.3; }
p { margin: 0; overflow-wrap: anywhere; }
.tagline { font-size: 1.1rem; color: var(--gold); }
.soft { font-size: 14px; color: var(--soft); }
.note-card { padding: 10px 14px; border-radius: 12px; background: #F4EEDF; color: #2A2418; transform: rotate(-.6deg); }
.ask { font-weight: 700; }
.choices { display: grid; gap: 10px; }
.choices button { text-align: left; padding: 10px 14px; border: 2px solid var(--line); border-radius: 12px; background: var(--card); color: var(--ink); cursor: pointer; font: inherit; min-height: 56px; }
.choices button strong { display: block; }
.choices button span { display: block; font-size: 14px; color: var(--soft); }
.choices button[aria-checked="true"] { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold) inset; }
.say { padding: 10px 14px; border-left: 4px solid var(--gold); background: var(--card); border-radius: 0 12px 12px 0; }
.say b { display: block; color: var(--gold); font-size: 14px; }
.modes { display: flex; flex-wrap: wrap; gap: 8px; }
.modes button, .single-nav button, #again { min-height: 44px; padding: 6px 14px; border: 2px solid var(--gold); border-radius: 999px; background: transparent; color: var(--gold); font: inherit; font-weight: 700; cursor: pointer; }
.modes button[aria-pressed="true"] { background: var(--gold); color: var(--deep); }
.single-nav { display: flex; gap: 8px; }
.guess { padding: 12px 14px; border: 2px solid var(--gold); border-radius: 14px; background: var(--card); display: grid; gap: 10px; }
.guess-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.guess-btns button { min-width: 48px; min-height: 44px; padding: 6px 12px; border: 2px solid var(--line); border-radius: 999px; background: transparent; color: var(--ink); font: inherit; font-weight: 800; cursor: pointer; }
.made { border-top: 1px solid var(--line); padding-top: 10px; }
.made summary { cursor: pointer; font-weight: 700; color: var(--gold); }
.made dl { margin: 10px 0 0; display: grid; gap: 8px; }
.made dt { font-size: 14px; font-weight: 700; color: var(--soft); }
.made dd { margin: 2px 0 0; }
.gate { font-size: 14px; color: #F2B58C; min-height: 1.4em; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
.primary { min-height: 48px; padding: 8px 22px; border-radius: 999px; border: 2px solid var(--gold); background: var(--gold); color: var(--deep); font: inherit; font-weight: 800; cursor: pointer; }
.primary:disabled { opacity: .45; cursor: default; }
.link { color: var(--gold); font-weight: 700; }
.sort { display: grid; gap: 14px; }
.sort-item { padding: 12px 14px; border: 2px solid var(--line); border-radius: 14px; background: var(--card); display: grid; gap: 8px; }
.sort-item h3 { margin: 0; font-size: 1.05rem; color: var(--gold); }
.baskets { display: flex; flex-wrap: wrap; gap: 8px; }
.baskets button { min-height: 44px; padding: 6px 12px; border: 2px solid var(--line); border-radius: 12px; background: transparent; color: var(--ink); font: inherit; cursor: pointer; }
.baskets button[aria-pressed="true"] { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold) inset; }
.card-lines { margin: 0; padding: 12px 14px 12px 34px; border-radius: 12px; background: #F4EEDF; color: #2A2418; display: grid; gap: 6px; }
.missed { display: grid; gap: 6px; }
.missed p { padding: 8px 12px; border-left: 4px solid #E0874A; background: var(--card); border-radius: 0 10px 10px 0; font-size: 15px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
