/* Gremlin Smash game styles */
.game-wrap { max-width: 860px; margin: 0 auto; padding: 1rem; }
.game-hud { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; justify-content: space-between; background: #111; color: #fff; padding: .6rem .9rem; border-radius: 8px 8px 0 0; font-family: 'Montserrat','Segoe UI',Arial,sans-serif; font-size: .85rem; }
.game-hud b { color: #ff8a33; }
.game-hud .bar { display: inline-block; width: 110px; height: 10px; background: #333; border-radius: 5px; vertical-align: middle; overflow: hidden; margin-left: .35rem; }
.game-hud .bar i { display: block; height: 100%; width: 0; background: #2aa7ff; transition: width .15s; }
.game-stage { position: relative; background: #0b0b0b; border-radius: 0 0 8px 8px; overflow: hidden; line-height: 0; }
#game { width: 100%; height: auto; display: block; touch-action: none; background: #222; }
.game-overlay { position: absolute; inset: 0; display: flex; align-items: flex-start; justify-content: center; background: rgba(8,8,8,.86); line-height: 1.5; padding: 1rem; text-align: center; color: #fff; overflow-y: auto; }
.game-overlay.hidden { display: none; }
.game-card { max-width: 560px; width: 100%; margin: auto; }
.game-card h2 { color: #ff8a33; margin: 0 0 .5rem; }
.game-card p { margin: .4rem 0; color: #e6e6e6; }
.game-card .small { font-size: .8rem; color: #bdbdbd; }
.game-card .btn { margin-top: .5rem; cursor: pointer; border: 0; }
.code-box { display: inline-block; line-height: 1.3; background: #fff; color: #111; font-family: 'Courier New', monospace; font-weight: 700; font-size: 1.5rem; letter-spacing: 2px; padding: .5rem 1rem; border-radius: 6px; border: 3px dashed #ff6b00; margin: .5rem 0; user-select: all; }
.claim-form { margin-top: .6rem; text-align: left; }
.claim-form input { width: 100%; padding: .45rem .6rem; margin: .2rem 0; border: 1px solid #ccc; border-radius: 4px; font-size: 1rem; font-family: 'Open Sans','Segoe UI',Arial,sans-serif; }
.claim-form button { width: 100%; }
.claim-msg { margin-top: .4rem; font-size: .9rem; }
.touch-controls { display: none; justify-content: space-between; align-items: center; padding: .8rem .2rem; user-select: none; -webkit-user-select: none; }
.dpad { display: grid; grid-template-columns: repeat(3, 54px); grid-template-rows: repeat(3, 54px); gap: 4px; }
.dpad button, .wrench-btn { background: #1a1a1a; color: #fff; border: 2px solid #ff6b00; border-radius: 10px; font-size: 1.3rem; touch-action: none; }
.dpad button:active, .wrench-btn:active, .dpad button.on { background: #ff6b00; }
.wrench-btn { width: 96px; height: 96px; border-radius: 50%; font-size: 1rem; font-weight: 700; }
.game-help { font-size: .9rem; color: #555; text-align: center; margin: .6rem 0; }
.game-terms { font-size: .8rem; color: #555; max-width: 860px; margin: 1rem auto; padding: 0 1rem; }
@media (hover: none) and (pointer: coarse) { .touch-controls { display: flex; } .key-help { display: none; } }
@media (max-width: 600px) { .game-hud { font-size: .75rem; } .game-hud .bar { width: 70px; } }
.activity-card { background: #fff; border-radius: 10px; border-top: 4px solid #ff6b00; box-shadow: 0 4px 15px rgba(0,0,0,.1); padding: 1.5rem; max-width: 520px; margin: 1rem auto; text-align: center; }
.activity-card .emoji { font-size: 3rem; }

@media (min-width: 701px) { .game-card h2 { font-size: 1.6rem; } .game-card p { margin: .25rem 0; } }

/* Phones: show start and end screens full-screen so the code and form are easy to read */
@media (max-width: 700px) {
  .game-overlay { position: fixed; inset: 0; z-index: 200; padding: 1.2rem 1rem 2rem; background: #080808; }
  .game-card h2 { font-size: 1.6rem; }
  .code-box { font-size: 1.2rem; letter-spacing: 1px; }
}

/* Pipe Flow */
#pipes { width: 100%; height: auto; display: block; background: #1b1f23; touch-action: manipulation; cursor: pointer; outline: none; }
#pipes:focus-visible { box-shadow: inset 0 0 0 3px #ff6b00; }
.hud-btn { padding: .25rem .7rem; font-size: .8rem; background: transparent; cursor: pointer; }
.game-card .btn + .btn { margin-left: .3rem; }

/* Breaker Box */
.breaker-stage { background: #1b1f23; line-height: 1.4; min-height: 480px; }
.breaker-board { display: flex; gap: 1rem; padding: 1rem; align-items: flex-start; color: #fff; }
.light-box { flex: 0 0 210px; text-align: center; background: #111; border-radius: 10px; padding: 1rem .8rem; }
.bulb { --lit: 1; width: 120px; height: 150px; margin: 0 auto; position: relative; transition: filter .3s; }
.bulb svg { width: 100%; height: 100%; display: block; overflow: visible; }
.bulb .glass { fill: rgb(calc(70 + 185 * var(--lit)), calc(70 + 160 * var(--lit)), calc(70 + 20 * var(--lit))); stroke: #666; stroke-width: 2; transition: fill .3s; }
.bulb .fil { fill: none; stroke: #222; stroke-width: 3; }
.bulb { filter: drop-shadow(0 0 calc(30px * var(--lit)) rgba(255, 214, 90, calc(0.95 * var(--lit)))); }
.bulb.flick { animation: flick .5s infinite alternate; }
.bulb.out { filter: none; }
@keyframes flick { from { opacity: .55; } to { opacity: 1; } }
.light-title { font-family: 'Montserrat','Segoe UI',Arial,sans-serif; font-weight: 700; margin: .4rem 0 .2rem; color: #ff8a33; }
.light-msg { font-size: .85rem; color: #ddd; margin: 0; min-height: 4.2em; }
.panel-wrap { flex: 1; background: #aeb4ba; border: 6px solid #7a828a; border-radius: 8px; padding: .6rem; }
.panel { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .5rem; }
.brk { position: relative; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: .1rem .4rem; text-align: left; background: #e9ecef; color: #111; border: 2px solid #555; border-radius: 6px; padding: .4rem .5rem; cursor: pointer; font-family: 'Open Sans','Segoe UI',Arial,sans-serif; min-height: 72px; }
.brk:hover { border-color: #ff6b00; }
.brk:focus-visible { outline: 3px solid #ff6b00; outline-offset: 2px; }
.brk-num { position: absolute; top: 2px; left: 6px; font-size: .65rem; color: #555; font-weight: 700; }
.brk-ico { font-size: 1.3rem; grid-column: 1; margin-top: .6rem; }
.brk-name { grid-column: 1; font-weight: 600; font-size: .85rem; }
.brk-tag { grid-column: 1; font-size: .65rem; background: #ff6b00; color: #fff; border-radius: 3px; padding: 0 .3rem; justify-self: start; font-weight: 700; }
.brk-sw { grid-column: 2; grid-row: 1 / span 3; width: 26px; height: 52px; background: #333; border-radius: 4px; position: relative; }
.brk-sw i { position: absolute; left: 3px; right: 3px; top: 3px; height: 22px; background: #2fc260; border-radius: 3px; transition: top .15s, background .15s; }
.brk.off .brk-sw i { top: 27px; background: #c0392b; }
.brk.off { background: #cfd3d7; }
.brk.off .brk-ico, .brk.off .brk-name { opacity: .45; }
.brk-state { position: absolute; right: 4px; top: 2px; font-size: .55rem; font-weight: 700; color: #555; display: none; }
@media (max-width: 700px) {
  .breaker-board { flex-direction: column; padding: .6rem; }
  .light-box { flex: none; width: 100%; box-sizing: border-box; }
  .bulb { width: 90px; height: 112px; }
  .panel { grid-template-columns: repeat(2, 1fr); }
  .breaker-stage { min-height: 0; }
}
.bulb svg { opacity: calc(.35 + .65 * var(--lit)); }
@media (max-width: 700px) {
  .light-box { display: flex; align-items: center; gap: .8rem; text-align: left; padding: .5rem .8rem; }
  .light-box .bulb { width: 56px; height: 70px; margin: 0; flex: none; }
  .light-box .light-title { margin: 0; font-size: .9rem; }
  .light-box .light-msg { min-height: 0; font-size: .8rem; }
}

/* Handyman Training */
#train { width: 100%; height: auto; display: block; background: #161b22; touch-action: none; }
.tool-bar { display: flex; gap: .4rem; background: #1a1a1a; padding: .4rem .6rem; flex-wrap: wrap; }
.tool-btn { flex: 1 1 90px; background: #111; color: #fff; border: 2px solid #444; border-radius: 6px; padding: .35rem .5rem; font-family: 'Montserrat','Segoe UI',Arial,sans-serif; font-size: .85rem; cursor: pointer; }
.tool-btn.active { border-color: #ff6b00; background: #2a1a0d; }
.tool-btn.locked { opacity: .45; cursor: not-allowed; }
.tool-btn small { color: #ff8a33; letter-spacing: 1px; }
.tc-actions { display: flex; flex-direction: column; align-items: flex-end; gap: .4rem; }
.tc-actions .wrench-btn { width: 84px; height: 84px; }
.tc-actions .small-btn { width: 64px; height: 44px; border-radius: 22px; font-size: .75rem; }
@media (hover: none) and (pointer: coarse) { .train-controls { display: flex; } }

/* No text selection, magnifier, or long-press menu on game controls (phones) */
.touch-controls, .touch-controls *, .tool-bar, .tool-bar *, .game-hud, .game-stage canvas, #game, #pipes, #train {
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
}
.touch-controls button, .tool-btn { touch-action: none; }

/* Full screen mode */
.fs-btn { margin-left: auto; }
html.fs-lock, html.fs-lock body { overflow: hidden; }
.game-wrap.is-fs { position: fixed; inset: 0; z-index: 500; max-width: none; width: 100%; height: 100%; margin: 0; padding: .4rem; background: #080808; overflow: auto; box-sizing: border-box; display: flex; flex-direction: column; align-items: center; }
.game-wrap.is-fs > * { width: 100%; max-width: 1100px; }
.game-wrap.is-fs .game-hud { border-radius: 8px; }
.game-wrap.is-fs .game-stage { display: flex; justify-content: center; background: #000; border-radius: 8px; }
.game-wrap.is-fs .game-stage canvas { width: auto; max-width: 100%; height: auto; max-height: calc(100vh - 150px); max-height: calc(100dvh - 150px); margin: 0 auto; }
.game-wrap.is-fs .game-help { color: #bbb; margin: .3rem 0; }
.game-wrap.is-fs .touch-controls { padding: .4rem .2rem; }
@media (hover: none) and (pointer: coarse) { .game-wrap.is-fs .game-stage canvas { max-height: calc(100vh - 290px); max-height: calc(100dvh - 290px); } }
@media (hover: none) and (pointer: coarse) and (orientation: landscape) {
  .game-wrap.is-fs .game-stage canvas { max-height: calc(100vh - 100px); max-height: calc(100dvh - 100px); }
  .game-wrap.is-fs .game-help { display: none; }
}
.game-wrap.is-fs .breaker-board { width: 100%; }
@media (max-width: 700px) {
  .game-wrap.is-fs { padding-top: 44px; }
  .game-wrap.is-fs .fs-btn { position: fixed; top: 6px; right: 6px; z-index: 700; background: #080808; padding: .3rem .7rem; margin: 0; }
}

/* Light Hang Rush */
#lights { width: 100%; height: auto; display: block; background: #0b1230; touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
.light-controls { justify-content: center; }
.light-controls .hang-btn { width: 100%; max-width: 360px; height: 84px; border-radius: 14px; font-size: 1.3rem; }
@media (hover: none) and (pointer: coarse) { .light-controls { display: flex; } }

/* Rake It Up */
#rake { width: 100%; height: auto; display: block; background: #f6c27a; touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
.rk-move { display: flex; gap: .6rem; }
.rake-controls .rk-arrow { width: 84px; height: 84px; border-radius: 14px; font-size: 1.6rem; }
.rake-controls .wrench-btn { touch-action: none; }
@media (hover: none) and (pointer: coarse) { .rake-controls { display: flex; } }
