/* CHAIN REACTION: inventions group (gates, lasers, semaphore, piano, breaker, keycode). Built on css/kit.css */

/* shared */
.inv-in { font-size: 30px; min-width: 78px; text-align: center; padding: 6px 10px; }
.inv-nudge { animation: inv-nudge 320ms ease; }
@keyframes inv-nudge { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

/* ---------- logic gates ---------- */
.gt-mod { position: absolute; inset: 0; }
.gt-head { position: absolute; top: 6px; left: 0; right: 0; text-align: center; }
.gt-head .k-plate { font-size: 14px; padding: 5px 14px; }
.gt-board { position: absolute; left: 0; top: 42px; width: 400px; height: 260px; overflow: hidden;
  background: radial-gradient(circle at 1px 1px, rgba(255,255,255,.07) 1px, transparent 1.5px) 0 0 / 14px 14px, linear-gradient(180deg, #17402a, #0f2e1d); }
.gt-svg { position: absolute; left: 0; top: 0; }
.gt-wires path { fill: none; stroke: #d29a4a; stroke-width: 3.5; stroke-linejoin: round; stroke-linecap: round; }
.gt-gate path, .gt-gate circle { fill: #e9ecef; stroke: #111418; stroke-width: 2.5; stroke-linejoin: round; }
.gt-gate path.gt-xor { fill: none; stroke-width: 3; }
.gt-lamp-base { fill: #8a9198; stroke: #2a2e33; stroke-width: 1.5; }
.gt-lamp-glass { fill: #3b3a30; stroke: #9aa1a8; stroke-width: 2.5; transition: fill 200ms; }
.gt-lamp-wire { fill: none; stroke: #77705a; stroke-width: 2; }
.gt-lamp.lit .gt-lamp-glass { fill: #ffe066; filter: drop-shadow(0 0 10px #ffd23f) drop-shadow(0 0 20px #ffb800); }
.gt-lamp.lit .gt-lamp-wire { stroke: #fff6cf; }
.gt-lamp.fail .gt-lamp-glass { animation: gt-fail 600ms; }
@keyframes gt-fail { 30% { fill: #7a2a22; } }
.gt-sw { position: absolute; left: 8px; width: 84px; height: 46px; padding: 0 6px 0 4px; border: none; border-radius: 8px; cursor: pointer; display: flex; align-items: center; gap: 6px;
  background: linear-gradient(180deg, #3a3f45, #23272c); box-shadow: 0 3px 0 #0e1012, 0 4px 8px rgba(0,0,0,.6), inset 0 1px 0 rgba(255,255,255,.15); }
.gt-sw b { width: 26px; height: 30px; display: grid; place-items: center; border-radius: 4px; font: 900 20px var(--mono); color: #1b1d20; background: linear-gradient(180deg, #f2f3f4, #b9bfc6); }
.gt-rocker { flex: 1; height: 38px; display: flex; flex-direction: column; border-radius: 5px; overflow: hidden; box-shadow: inset 0 0 0 2px #0b0c0e; }
.gt-rocker i { flex: 1; display: grid; place-items: center; font: 800 11px var(--mono); font-style: normal; letter-spacing: 1px; color: #6b7178; background: #15171a; }
.gt-sw:not(.on) .gt-rocker i:last-child { background: linear-gradient(180deg, #5d6268, #3f444a); color: #f2f3f4; }
.gt-sw.on .gt-rocker i:first-child { background: linear-gradient(180deg, #4ade80, #16a34a); color: #052e14; }
.gt-sw.locked { cursor: not-allowed; background: var(--grain), linear-gradient(180deg, #c9a136, #8a6a1c); box-shadow: 0 3px 0 #4a3608, 0 4px 8px rgba(0,0,0,.6), inset 0 1px 0 rgba(255,255,255,.4); }
.gt-lock { flex: 1; display: grid; place-items: center; }
.gt-lock rect { fill: #2a2e33; }
.gt-lock .gt-shackle { fill: none; stroke: #2a2e33; stroke-width: 3; }
.gt-test { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); width: 170px; height: 54px; font-size: 24px; }
.gt-test:active { transform: translateX(-50%) translateY(5px); }

/* ---------- laser mirrors ---------- */
.las-mod { position: absolute; inset: 0; }
.las-svg { position: absolute; left: 0; top: 0; }
.las-frame { fill: #121417; stroke: #4b525a; stroke-width: 2; }
.las-cell { fill: #1d2126; stroke: #262b31; stroke-width: 1; }
.las-block rect { fill: #6b7178; stroke: #2a2e33; stroke-width: 2; }
.las-block .las-rivet { fill: #c9ced4; }
.las-beam { fill: none; stroke: #ff2d55; stroke-width: 9; stroke-opacity: .35; stroke-linejoin: round; stroke-linecap: round; filter: blur(2px); }
.las-beam-core { fill: none; stroke: #ffd6df; stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.las-em-body { fill: #2a2e33; stroke: #8a9198; stroke-width: 2; }
.las-em-nozzle { fill: #b9c0c7; stroke: #2a2e33; stroke-width: 1.5; }
.las-rec-ring { stroke: #111; stroke-width: 3; }
.las-rec-lens { fill: #0b0d10; stroke: rgba(255,255,255,.35); stroke-width: 1.5; transition: fill 150ms; }
.las-rec.hit .las-rec-lens { fill: #fff; }
.las-rec.hit { filter: drop-shadow(0 0 8px #ff2d55); }
.las-mount { fill: #2b3036; stroke: #4b525a; stroke-width: 1.5; }
.las-blade { transform-box: fill-box; transform-origin: center; transition: transform 180ms ease; }
.las-blade.back { transform: rotate(90deg); }
.las-mirror { stroke: #9fc4e6; stroke-width: 7; stroke-linecap: round; }
.las-mirror-shine { stroke: #fff; stroke-width: 1.5; stroke-linecap: round; }
.las-pivot { fill: #5d6268; stroke: #1b1d20; stroke-width: 1; }
.las-hit { fill: transparent; cursor: pointer; }
.las-mir:hover .las-mount { stroke: #f5c518; }
.las-foot { position: absolute; left: 24px; right: 24px; bottom: 10px; height: 52px; display: flex; align-items: center; justify-content: space-between; }
.las-lcd { width: 150px; white-space: nowrap; box-sizing: border-box; font-size: 18px; letter-spacing: 2px; text-align: center; }
.las-fire { width: 150px; height: 50px; font-size: 22px; }

/* ---------- flag semaphore ---------- */
.sem-mod { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 16px; }
.sem-left { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.sem-win { width: 186px; height: 196px; display: grid; place-items: center; background: linear-gradient(180deg, #dce6eb, #b9c8d0); box-shadow: inset 0 0 0 4px #1b1e22, inset 0 4px 12px rgba(0,0,0,.6); }
.sem-fig .sem-limb, .sem-fig .sem-body { stroke: #1b1d20; stroke-width: 7; stroke-linecap: round; fill: none; }
.sem-fig .sem-body { stroke-width: 10; }
.sem-fig .sem-pole { stroke: #5b4630; stroke-width: 3; stroke-linecap: round; }
.sem-fig .sem-flag { stroke: #1b1d20; stroke-width: 1.5; stroke-linejoin: round; }
.sem-fig .sem-hand { fill: #1b1d20; }
.sem-fig .sem-head { fill: #1b1d20; }
.sem-nav { display: flex; align-items: center; gap: 8px; }
.sem-nav .k-btn { width: 52px; height: 46px; font-size: 18px; }
.sem-page { width: 64px; font-size: 20px; letter-spacing: 1px; text-align: center; padding: 8px 4px; }
.sem-right { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.sem-screen { width: 150px; font-size: 34px; letter-spacing: 10px; text-align: center; white-space: nowrap; padding: 8px 4px 8px 14px; }
.sem-pad { display: grid; grid-template-columns: repeat(3, 54px); gap: 9px; }
.sem-key { height: 44px; font-size: 20px; padding: 0; }
.sem-key.dark, .sem-key.amber { font-size: 13px; letter-spacing: 0; }

/* ---------- piano ---------- */
.pi-mod { position: absolute; inset: 0; }
.pi-top { position: absolute; top: 14px; left: 18px; right: 22px; height: 124px; display: flex; align-items: center; gap: 18px; }
.pi-symwin { width: 112px; height: 112px; display: grid; place-items: center; color: #1b1d20; background: linear-gradient(180deg, #f6f1e4, #ddd3bd); box-shadow: inset 0 0 0 4px #1b1e22, inset 0 3px 10px rgba(0,0,0,.45); }
.pi-sym .st { fill: none; stroke: currentColor; stroke-width: 3.5; stroke-linecap: round; stroke-linejoin: round; }
.pi-sym .st.thick { stroke-width: 6; }
.pi-sym .fi { fill: currentColor; }
.pi-info { display: flex; flex-direction: column; gap: 16px; }
.pi-row { display: flex; align-items: center; gap: 10px; }
.pi-leds { display: flex; gap: 12px; padding: 8px 10px; border-radius: 8px; background: #1b1e22; box-shadow: inset 0 2px 6px #000; }
.pi-leds .k-led { width: 16px; height: 16px; }
.pi-case { position: absolute; left: 8px; width: 384px; bottom: 10px; height: 230px; border-radius: 12px;
  background: linear-gradient(180deg, #2a2a2e, #0f0f12); box-shadow: inset 0 2px 0 rgba(255,255,255,.18), 0 6px 14px rgba(0,0,0,.6); }
.pi-case::before { content: ''; position: absolute; left: 10px; right: 10px; top: 20px; height: 6px; background: #7a1a1a; border-radius: 2px; }
.pi-kb { position: absolute; left: 10px; top: 26px; width: 364px; height: 194px; }
.pi-key { position: absolute; top: 0; padding: 0; border: none; cursor: pointer; }
.pi-white { width: 52px; height: 194px; border-radius: 0 0 7px 7px; background: linear-gradient(180deg, #e9e6dc 0%, #fbfaf5 20%, #f3f0e6 100%);
  box-shadow: inset -1px 0 0 #9b968a, inset 0 -6px 0 #d6d1c3, 0 2px 3px rgba(0,0,0,.5); display: flex; align-items: flex-end; justify-content: center; padding-bottom: 14px; }
.pi-white span { font: 800 15px var(--mono); color: #6b665a; }
.pi-black { width: 38px; height: 118px; z-index: 2; border-radius: 0 0 5px 5px; background: linear-gradient(180deg, #111 0%, #2b2b2e 85%, #3a3a3e 100%);
  box-shadow: inset 0 -8px 0 #1a1a1c, inset 1px 0 0 rgba(255,255,255,.12), 0 3px 4px rgba(0,0,0,.7); }
.pi-white.hit { animation: pi-white 200ms; }
.pi-black.hit { animation: pi-black 200ms; }
@keyframes pi-white { 30% { background: linear-gradient(180deg, #d6d2c6, #e6e2d6); box-shadow: inset -1px 0 0 #9b968a, inset 0 -2px 0 #d6d1c3; } }
@keyframes pi-black { 30% { background: linear-gradient(180deg, #000, #1c1c1e); box-shadow: inset 0 -3px 0 #1a1a1c; } }

/* ---------- breaker panel ---------- */
.br-mod { position: absolute; inset: 0; }
.br-top { position: absolute; top: 10px; left: 16px; right: 26px; height: 66px; display: flex; align-items: center; justify-content: space-between; }
.br-meter { display: flex; align-items: center; gap: 10px; }
.br-lamps { display: flex; gap: 16px; padding: 8px 14px; border-radius: 8px; background: #1b1e22; box-shadow: inset 0 2px 6px #000; }
.br-lamp { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.br-lamp .k-led { width: 22px; height: 22px; }
.br-lamp small { font: 800 10px var(--mono); letter-spacing: 1px; color: #cfd4d9; }
.br-row { position: absolute; top: 90px; left: 12px; right: 12px; bottom: 10px; display: flex; gap: 10px; }
.br-grid { display: grid; grid-template-columns: repeat(3, 84px); grid-template-rows: repeat(2, 1fr); gap: 8px 6px; }
.br-sw { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 0; border: none; background: none; cursor: pointer; }
.br-body { width: 60px; height: 104px; border-radius: 6px; display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: 4px 0;
  background: linear-gradient(180deg, #2e3237, #1b1e22); box-shadow: inset 0 0 0 2px #0e1012, 0 3px 6px rgba(0,0,0,.6), inset 0 1px 0 rgba(255,255,255,.12); }
.br-body small { font: 800 10px var(--mono); color: #6b7178; letter-spacing: 1px; }
.br-sw.on .br-on { color: #4ade80; }
.br-sw:not(.on) .br-off { color: #f87171; }
.br-slot { position: relative; width: 26px; height: 60px; border-radius: 4px; background: #0b0c0e; box-shadow: inset 0 2px 5px #000; }
.br-handle { position: absolute; left: 2px; right: 2px; height: 28px; bottom: 2px; border-radius: 3px; background: linear-gradient(180deg, #f2f3f4, #a9aeb4); box-shadow: 0 2px 3px rgba(0,0,0,.7); transition: bottom 120ms; }
.br-sw.on .br-handle { bottom: 30px; }
.br-label { font-size: 13px; padding: 3px 8px; }
.br-main { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 0; border: none; background: none; cursor: pointer; }
.br-main-slot { position: relative; width: 40px; height: 218px; border-radius: 8px; background: #0b0c0e; box-shadow: inset 0 3px 8px #000, 0 0 0 4px #3a3f45, 0 0 0 6px #1b1d20; }
.br-main-arm { position: absolute; left: 50%; top: 6px; width: 14px; height: 70px; margin-left: -7px; border-radius: 4px; background: linear-gradient(90deg, #8a9198, #d9dde2, #8a9198); transition: top 260ms cubic-bezier(.5,0,.3,1.3); }
.br-main-grip { position: absolute; left: -24px; right: -24px; top: -10px; height: 32px; border-radius: 8px; background: linear-gradient(180deg, #ff6b5e, #d6342a 55%, #a52119); box-shadow: 0 4px 6px rgba(0,0,0,.6), inset 0 2px 1px rgba(255,255,255,.4); }
.br-main.pulled .br-main-arm { top: 142px; }
.br-main .k-plate { font-size: 14px; }

/* ---------- keycode ---------- */
.kc-mod { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px; }
.kc-top { display: flex; align-items: center; gap: 16px; }
.kc-screen { width: 170px; font-size: 42px; letter-spacing: 9px; text-align: center; white-space: nowrap; padding: 8px 4px 8px 16px; box-sizing: border-box; }
.kc-screen.ok { color: #b7ffcf; }
.kc-light { padding: 8px; border-radius: 50%; background: #1b1e22; box-shadow: inset 0 2px 6px #000; }
.kc-seed { display: flex; flex-direction: column; align-items: center; gap: 4px; color: #cfd4d9; font: 800 11px var(--mono); letter-spacing: 2px; }
.kc-seed .inv-in { font-size: 24px; min-width: 64px; }
.kc-pad { display: grid; grid-template-columns: repeat(3, 76px); gap: 11px 14px; }
.kc-key { height: 50px; font-size: 22px; padding: 0; }
.kc-key.dark, .kc-key.red { font-size: 15px; }

/* ---------- expert pages ---------- */
.inv-gates { display: grid; gap: 10px; max-width: 1000px; }
.inv-gate { display: grid; grid-template-columns: 150px 1fr 220px; gap: 18px; align-items: center; background: #1a1d22; border-radius: 10px; padding: 10px 16px; }
.inv-gate-pic { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.inv-gate-pic b { font: 900 22px var(--mono); color: var(--hazard); }
.inv-gate-txt p { margin: 4px 0; font-size: 19px; }
.inv-gate .gt-icon .gt-gate path, .inv-gate .gt-icon .gt-gate circle { fill: #e9ecef; stroke: #000; }
.gt-icon-wire { stroke: #d29a4a; stroke-width: 3.5; fill: none; }
.inv-tt { border-collapse: collapse; font: 15px var(--mono); }
.inv-tt th { color: var(--dim); font-weight: 600; padding: 1px 8px; }
.inv-tt td { padding: 1px 8px; text-align: center; color: #c9ced4; }
.inv-tt td.on { color: var(--green); font-weight: 800; }
.inv-chip { display: inline-block; width: 18px; height: 18px; border-radius: 4px; vertical-align: -3px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.4); }
.inv-lz td { font-size: 19px; }
.inv-list { white-space: nowrap; }
.sem-chart { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; max-width: 1000px; margin-top: 16px; }
.sem-cell { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 6px 10px; border-radius: 10px; background: linear-gradient(180deg, #dce6eb, #b9c8d0); color: #111; text-align: center; }
.sem-cell b { font: 900 34px var(--mono); line-height: 1; }
.sem-cell small { font-size: 13px; line-height: 1.25; color: #333; }
.inv-kb { position: relative; width: 308px; height: 120px; margin: 10px 0 18px; }
.inv-kb .w, .inv-kb .b { position: absolute; top: 0; display: flex; align-items: flex-end; justify-content: center; font: 800 14px var(--mono); border-radius: 0 0 5px 5px; }
.inv-kb .w { width: 44px; height: 120px; background: #f3f0e6; color: #222; box-shadow: inset -1px 0 0 #999; padding-bottom: 6px; box-sizing: border-box; }
.inv-kb .b { width: 30px; height: 72px; background: #111; color: #fff; z-index: 2; font-size: 11px; padding-bottom: 4px; box-sizing: border-box; box-shadow: 0 0 0 1px #555; }
.inv-pi td { font-size: 19px; }
.inv-sym { display: flex; align-items: center; gap: 12px; color: var(--ink); }
.inv-sym span { font-size: 16px; font-weight: 700; white-space: normal; max-width: 120px; }
.inv-mel { font: 700 21px var(--mono); letter-spacing: 1px; color: #fff; }
.inv-lbl { font: 900 22px var(--mono); color: var(--hazard); width: 90px; }
.inv-kc td { font-size: 18px; }
body.print .sem-cell { break-inside: avoid; }
body.print .inv-gate { background: #eee; color: #111; }
body.print .inv-sym, body.print .inv-mel { color: #111; }
table.rules.inv-pi, table.rules.inv-lz, table.rules.inv-kc { max-width: 1100px; }
.inv-mel { white-space: nowrap; font-size: 20px; }
.inv-lz td:first-child, .inv-kc td:first-child, .inv-pi td:first-child { white-space: nowrap; }
