/* Brick Mars Colony Builder - layout. Tokens (--kit-*) come from kit/kit_ui.css */
:root { --bg: #1c1620; --text: #f4f1ea; --soft: #cfc3b8; }
* { 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); }
#brand, #res, #ctl, #pal, #dash, #banner, #fpsB, #hint, #warpMsg { 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: flex-start; justify-content: flex-end; pointer-events: none; z-index: 5; }
#top > * { pointer-events: auto; }
#brand { padding: 9px 13px; font-size: 14px; white-space: nowrap; margin-right: auto; }
#res { display: flex; flex-wrap: wrap; gap: 4px 12px; padding: 7px 12px; font: 600 12.5px 'JetBrains Mono', ui-monospace, monospace; max-width: calc(100% - 190px); }
.chip { display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; } .chip .i { opacity: .8; font-size: 12px; min-width: 14px; text-align: center; }
.chip[data-s=warn] { color: #ffc94a; } .chip[data-s=bad] { color: #ff6a5c; }
#banner { position: absolute; left: 50%; top: 66px; transform: translateX(-50%); padding: 6px 14px; font-size: 12.5px; display: none; max-width: min(760px, calc(100% - 24px)); z-index: 4; border-color: #ffc94a; }
#banner.on { display: block; }
#fpsB { position: absolute; left: 12px; bottom: 64px; padding: 3px 8px; font: 500 11px 'JetBrains Mono', monospace; z-index: 4; } #fpsB:empty { display: none; }
#pal { position: absolute; left: 12px; top: 56px; bottom: 76px; width: 206px; padding: 8px; z-index: 6; display: flex; flex-direction: column; gap: 6px; overflow: auto; }
#tabs { display: flex; gap: 4px; } #tabs button { flex: 1; min-height: 34px; border-radius: 999px; border: 1px solid var(--kit-line); background: var(--kit-panel2); color: var(--soft); font: 600 12px var(--kit-font); cursor: pointer; }
#tabs button[aria-selected=true] { color: #fff; border-color: var(--kit-accent); box-shadow: 0 0 0 2px rgba(70,166,255,.3) inset; }
#slots { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.slot { position: relative; min-height: 82px; border-radius: 10px; border: 1px solid var(--kit-line); background: var(--kit-panel2); color: var(--text); cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; padding: 4px 2px; font: 600 11px var(--kit-font); }
.slot img { display: block; border-radius: 8px; } .slot.on { border-color: var(--kit-accent); box-shadow: 0 0 0 2px var(--kit-accent) inset; background: rgba(70,166,255,.18); }
.slot .cost { position: absolute; right: 4px; top: 3px; font: 600 10px 'JetBrains Mono', monospace; background: rgba(0,0,0,.5); padding: 0 4px; border-radius: 6px; color: #ffd9a0; }
.slot:focus-visible, button:focus-visible, input:focus-visible { outline: 3px solid var(--kit-warn); outline-offset: 2px; }
#brickPanel { display: flex; flex-direction: column; gap: 6px; } #brickPanel[hidden] { display: none; } #brickTools { display: flex; flex-wrap: wrap; gap: 4px; } #brickTools .kit-btn { min-height: 36px; padding: 4px 8px; font-size: 12px; }
#brickPanel .kit-palette { width: 100%; padding: 6px; border: 0; background: transparent; backdrop-filter: none; max-height: none; } #brickPanel .kit-slots { grid-template-columns: repeat(3, 1fr); } #brickPanel .kit-slot { min-height: 46px; }
#ctl { position: absolute; right: 12px; top: 62px; width: 330px; padding: 8px 10px; z-index: 6; font-size: 13px; }
#ctl .row { display: flex; align-items: center; gap: 8px; margin: 4px 0; flex-wrap: wrap; } #ctl .lbl { color: var(--soft); font-weight: 600; font-size: 12px; } #ctl input[type=range] { flex: 1; min-width: 70px; min-height: 30px; accent-color: #46a6ff; }
.seg { display: inline-flex; gap: 4px; } .seg button { min-width: 42px; min-height: 40px; border-radius: 10px; border: 1px solid var(--kit-line); background: var(--kit-panel2); color: var(--text); font: 600 13px var(--kit-font); cursor: pointer; }
.seg button[aria-pressed=true], .kit-btn[aria-pressed=true] { border-color: var(--kit-accent); background: rgba(70,166,255,.25); }
#saver { min-height: 40px; padding: 4px 10px; font-size: 12px; }
#dash { position: absolute; right: 12px; top: 180px; width: 300px; max-height: calc(100% - 270px); overflow: auto; padding: 10px 12px; z-index: 6; font-size: 12px; } #dash[hidden] { display: none; }
#dash h2 { margin: 0 0 6px; font-size: 14px; } #dash .x { position: absolute; right: 6px; top: 4px; background: none; border: 0; color: var(--soft); font-size: 22px; min-width: 40px; min-height: 40px; cursor: pointer; }
#dash .sp { margin: 6px 0; } #dash .sp span { display: block; color: var(--soft); margin-bottom: 2px; } #dash canvas { display: block; width: 100%; height: 46px; background: rgba(0,0,0,.25); border-radius: 6px; margin-bottom: 3px; }
#dash pre { font: 11px/1.5 'JetBrains Mono', monospace; white-space: pre-wrap; margin: 6px 0 0; color: var(--text); }
#bar { position: absolute; left: 12px; right: 12px; bottom: 12px; z-index: 7; }
#bar .kit-btn { padding: 6px 10px; } #bar [data-id=saverT], #bar [data-id=ctlT] { display: none; }
#bar [data-id=undo] .lb, #bar [data-id=redo] .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); }
#hint { position: absolute; left: 50%; bottom: 76px; transform: translateX(-50%); padding: 6px 14px; font-size: 13px; display: none; border-color: var(--kit-bad); z-index: 8; max-width: calc(100% - 24px); } #hint.on { display: block; }
#warpMsg { position: absolute; left: 50%; top: 120px; transform: translateX(-50%); padding: 10px 16px; z-index: 12; } #warpMsg[hidden] { display: none; }
#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: #ee8a2a; 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(700px, 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 .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 { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 12.5px; background: rgba(255,255,255,.07); padding: 1px 5px; border-radius: 5px; }
#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 .note { color: var(--soft); font-size: 12.5px; }
#dlg .btns, .tour .btns { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; } #dlg canvas { width: 100%; max-width: 520px; height: auto; border-radius: 10px; display: block; }
.mono { font: 12px/1.5 'JetBrains Mono', monospace; white-space: pre-wrap; } .stars { font-size: 26px; letter-spacing: 3px; color: #ffc94a; } .stars .off { color: #555a66; }
.tour { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); width: min(430px, calc(100% - 24px)); background: #1b1e27; border: 2px solid var(--kit-accent); border-radius: 14px; padding: 12px 14px; z-index: 70; font-size: 14px; }
@media (max-width: 900px) { #ctl { width: min(330px, calc(100% - 238px)); } #res { max-width: calc(100% - 24px); } #brand { display: none; } #top { justify-content: center; } }
@media (max-width: 640px) {
  #res { font-size: 11px; gap: 2px 8px; padding: 5px 8px; } #banner { top: 78px; font-size: 11.5px; }
  #pal { left: 0; right: 0; top: auto; bottom: 0; width: 100%; height: auto; max-height: 36dvh; border-radius: 14px 14px 0 0; }
  #slots { grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); } .slot { min-height: 76px; }
  #bar { left: 6px; right: 6px; bottom: calc(36dvh + 6px); } #ctl { right: 6px; left: 6px; width: auto; top: 98px; padding: 4px 6px; } #ctl .row { margin: 2px 0; } #ctl .lbl { display: none; }
  #bar [data-id=saverT], #bar [data-id=ctlT] { display: inline-flex; } #saver { display: none; } #ctl .row + .row { display: none; } body.show-ctl #ctl .row + .row { display: flex; }
  #dash { left: 6px; right: 6px; width: auto; top: 140px; max-height: 40dvh; }
  .kit-toolbar { flex-wrap: nowrap; overflow-x: auto; } #hint { bottom: calc(36dvh + 64px); } .tour { bottom: calc(36dvh + 70px); }
}
@media (prefers-reduced-motion: reduce) { .spin { animation: none; } }
