/* Toy-Brick Castle & Kingdom Builder - layout. Tokens (--kit-*) come from kit/kit_ui.css */
:root { --bg: #20232b; --text: #f4f1ea; --soft: #c9c4b8; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: Inter, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; overflow: hidden; }
body.embed-mode, body.embed-mode #app { height: 100vh; height: 100dvh; }
#app { position: relative; width: 100%; height: 100vh; height: 100dvh; }
#c { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
#c:focus-visible { box-shadow: inset 0 0 0 3px var(--kit-warn); }
#env, #sim, #hud, #brand { background: var(--kit-panel); border: 1px solid var(--kit-line); border-radius: 14px; backdrop-filter: blur(8px); }
#top { position: absolute; left: 12px; right: 12px; top: 10px; display: flex; gap: 8px; align-items: center; justify-content: space-between; pointer-events: none; z-index: 5; }
#top > * { pointer-events: auto; }
#brand { padding: 10px 14px; font-size: 14px; white-space: nowrap; }
#hud { position: absolute; left: 12px; top: 62px; padding: 7px 10px; font: 500 12px 'JetBrains Mono', ui-monospace, monospace; white-space: pre; z-index: 4; pointer-events: none; }
#pal-wrap { position: absolute; left: 12px; top: 130px; bottom: 76px; z-index: 6; width: 214px; pointer-events: none; }
#pal-wrap > div { pointer-events: auto; max-height: 100%; }
#palD { display: none; } body.m-decorate #palB { display: none; } body.m-decorate #palD { display: block; } body.m-simulate #pal-wrap { display: none; }
#bar { position: absolute; left: 12px; right: 12px; bottom: 12px; z-index: 7; }
#env { position: absolute; right: 12px; bottom: 76px; width: 300px; padding: 10px 12px; font-size: 13px; z-index: 6; }
#env .row { display: flex; align-items: center; gap: 8px; margin: 6px 0; min-height: 34px; }
#env .lbl, #env label { min-width: 84px; color: var(--soft); font-weight: 600; }
#env input[type=range] { flex: 1; min-height: 30px; accent-color: #46a6ff; min-width: 0; }
#env output { font: 600 12px 'JetBrains Mono', monospace; min-width: 42px; text-align: right; }
.seg { display: inline-flex; gap: 4px; } .seg button { min-width: 44px; min-height: 40px; border-radius: 10px; border: 1px solid var(--kit-line); background: var(--kit-panel2); color: var(--text); font-size: 18px; cursor: pointer; }
.seg button[aria-pressed=true] { border-color: var(--kit-accent); background: rgba(70, 166, 255, .25); }
.seg button:focus-visible, select:focus-visible, input:focus-visible, button:focus-visible { outline: 3px solid var(--kit-warn); outline-offset: 2px; }
.chip { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--kit-line); background: var(--kit-panel2); font-weight: 600; }
#sim { position: absolute; right: 12px; top: 62px; width: 318px; max-height: calc(100% - 350px); overflow: auto; padding: 12px; font-size: 13px; display: none; z-index: 6; }
body.m-simulate #sim { display: block; }
#sim h2 { margin: 0 0 8px; font-size: 15px; } #sim h2 small { color: var(--soft); font-weight: 500; }
.rw { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 7px 0; min-height: 30px; }
.rw input[type=range] { width: 140px; min-height: 30px; accent-color: #46a6ff; } .rw select { background: #11131a; color: var(--text); border: 1px solid var(--kit-line); border-radius: 8px; min-height: 34px; padding: 2px 6px; }
.rw input[type=checkbox] { width: 22px; height: 22px; accent-color: #46a6ff; }
.btns { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
#legend { display: none; height: 10px; border-radius: 5px; background: linear-gradient(90deg, #2159d9, #26bfbf, #f2d933, #f2731a, #d91a1a); margin: 6px 0 2px; } #legend.on { display: block; }
#res { font: 12px/1.5 'JetBrains Mono', ui-monospace, monospace; white-space: pre-wrap; } #res .ok { color: #5fd17a; } #res .bad { color: #ff6a5c; } #res .dim { color: var(--soft); }
#live { position: absolute; left: -9999px; }
#load { position: absolute; inset: 0; display: grid; place-items: center; background: var(--bg); font-size: 15px; z-index: 30; text-align: center; }
.spin { width: 34px; height: 34px; border: 4px solid rgba(255,255,255,.2); border-top-color: #46a6ff; border-radius: 50%; margin: 0 auto 12px; animation: sp 1s linear infinite; } @keyframes sp { to { transform: rotate(360deg); } }
#dlg { position: fixed; inset: 0; background: rgba(8, 10, 16, .66); z-index: 80; display: grid; place-items: center; padding: 14px; }
#dlg[hidden] { display: none; }
#dlg .card { position: relative; width: min(680px, 100%); max-height: calc(100dvh - 28px); overflow: auto; background: #1b1e27; border: 1px solid var(--kit-line); border-radius: 16px; padding: 18px 20px; font-size: 14px; line-height: 1.5; }
#dlg h2 { margin: 0 0 10px; font-size: 18px; } #dlg h3 { margin: 12px 0 4px; font-size: 14px; } #dlg .x { position: absolute; right: 10px; top: 8px; width: 44px; height: 44px; background: none; border: 0; color: var(--soft); font-size: 26px; cursor: pointer; }
#dlg details { border: 1px solid var(--kit-line); border-radius: 10px; margin: 6px 0; padding: 6px 10px; } #dlg summary { cursor: pointer; font-weight: 700; min-height: 30px; display: flex; align-items: center; }
#dlg code, #dlg .eq { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 12.5px; background: rgba(255,255,255,.07); padding: 1px 5px; border-radius: 5px; } #dlg .eq { display: block; padding: 6px 10px; margin: 6px 0; overflow-x: auto; }
#dlg table { border-collapse: collapse; width: 100%; font-size: 12.5px; } #dlg td, #dlg th { border-bottom: 1px solid var(--kit-line); padding: 4px 6px; text-align: left; } #dlg .pass { color: #5fd17a; } #dlg .fail { color: #ff6a5c; }
#dlg .slot { display: flex; align-items: center; gap: 8px; margin: 6px 0; flex-wrap: wrap; } #dlg textarea, #dlg input[type=text] { width: 100%; background: #11131a; color: var(--text); border: 1px solid var(--kit-line); border-radius: 8px; padding: 8px; font: 12px 'JetBrains Mono', monospace; }
#dlg .note { color: var(--soft); font-size: 12.5px; }
.stars { font-size: 20px; letter-spacing: 2px; color: #ffc94a; } .stars .off { color: #555a66; }
.ch { border: 1px solid var(--kit-line); border-radius: 12px; padding: 10px 12px; margin: 8px 0; display: flex; gap: 10px; justify-content: space-between; align-items: center; }
.tour { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); width: min(420px, calc(100% - 24px)); background: #1b1e27; border: 2px solid var(--kit-accent); border-radius: 14px; padding: 12px 14px; z-index: 70; font-size: 14px; }
.tour .btns { margin-bottom: 0; }
@media (max-width: 640px) {
  #brand { display: none; } #top { justify-content: center; }
  #hud { top: 60px; left: 8px; font-size: 10.5px; padding: 5px 8px; }
  #pal-wrap { left: 0; right: 0; top: auto; bottom: 0; width: 100%; }
  #palB, #palD { width: 100%; } #palB .kit-palette, #palD .kit-palette { border-radius: 14px 14px 0 0; max-height: 34dvh; }
  #bar { left: 6px; right: 6px; bottom: calc(34dvh + 6px); } body.m-simulate #bar { bottom: 6px; }
  #env { display: none; left: 8px; right: 8px; width: auto; bottom: calc(34dvh + 64px); } body.show-env #env { display: block; } body.m-simulate #env { bottom: 66px; }
  #sim { left: 8px; right: 8px; width: auto; top: 96px; max-height: 38dvh; padding: 10px; }
  body.m-simulate.show-env #sim { display: none; }
  .kit-mode span:not(.ic) { font-size: 12px; } .kit-mode { padding: 6px 10px; }
}
@media (prefers-reduced-motion: reduce) { .spin { animation: none; } }

#bar .kit-btn { padding: 6px 10px; }
#bar [data-id=undo] .lb, #bar [data-id=redo] .lb, #bar [data-id=lvlU] .lb, #bar [data-id=lvlD] .lb, #bar [data-id=help] .lb, #bar [data-id=set] .lb { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
#bar [data-id=sky] { display: none; }
@media (max-width: 640px) { #bar [data-id=sky] { display: inline-flex; } #bar .kit-btn { padding: 6px 9px; } }
@media (max-width: 640px) { #sim { top: auto; bottom: 62px; max-height: 34dvh; } body.m-simulate #bar { bottom: 6px; } }

@media (max-width: 640px) { #palB.kit-palette, #palD.kit-palette { max-height: 34dvh; } }
@media (max-width: 640px) { #palB .kit-colours, #palD .kit-colours { order: 1; } #palB .kit-slots, #palD .kit-slots { order: 2; } #palB .kit-slot, #palD .kit-slot { min-height: 46px; } #palB .kit-cat, #palD .kit-cat { min-height: 32px; } }
