/* Gearworks Factory UI. Colours are variables: change them here to re-skin the whole interface. */
:root {
  --ink: #2b1e16;          /* outlines, dark panels */
  --panel: rgba(43, 30, 22, .9);
  --paper: #f6eedd;        /* text on dark */
  --muted: #cdbf9f;
  --btn: #e9d8b4;          /* light buttons */
  --accent: #f2c76b;       /* selected / primary */
  --good: #7bd66f;
  --bad: #ff7a66;
  --radius: 12px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #2f4a33; color: var(--paper);
  font: 14px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; }
#game { position: fixed; inset: 0; touch-action: none; }
#game canvas { display: block; touch-action: none; }
[hidden] { display: none !important; }
button { font: inherit; color: var(--ink); background: var(--btn); border: 0; border-radius: 9px; padding: 6px 12px; cursor: pointer; }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--accent); font-weight: 700; }
button.danger { background: var(--bad); color: #fff; font-weight: 700; }
button.link { background: none; color: var(--muted); text-decoration: underline; padding: 4px; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
svg .f { fill: currentColor; stroke: none; }
.icon { width: 40px; height: 40px; padding: 0; display: inline-grid; place-items: center; }
.icon.small { width: 28px; height: 28px; font-size: 18px; }
.icon.on, .tool.on { background: var(--accent); box-shadow: inset 0 0 0 2px var(--ink); }

/* loading */
#loading { position: fixed; inset: 0; display: grid; place-content: center; text-align: center; background: #2f4a33; z-index: 30; }
#loading h1 { margin: 0 0 14px; font-size: 28px; }
#loading .bar { width: min(320px, 70vw); height: 10px; background: rgba(0,0,0,.3); border-radius: 6px; overflow: hidden; margin: auto; }
#loading .bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }

/* level select */
#menu { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; z-index: 10; background: linear-gradient(180deg, rgba(20,14,10,.15), rgba(20,14,10,.55)); overflow-y: auto; }
.menu-card { width: min(880px, 100%); background: var(--panel); border-radius: 18px; padding: 18px 18px 12px; box-shadow: 0 12px 40px rgba(0,0,0,.35); }
.logo { font-weight: 900; font-size: 34px; line-height: 1; letter-spacing: .5px; text-shadow: 0 3px 0 var(--ink); }
.logo span { color: var(--accent); margin-right: 8px; }
.sub { color: var(--muted); margin: 6px 0 14px; }
#levels { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.lvl { text-align: left; padding: 10px; border-radius: var(--radius); background: #f3e6c8; display: grid; gap: 4px; min-height: 112px; align-content: start; }
.lvl.done { background: #e4f0cf; }
.lvl.locked { background: #8d7f68; color: #4a3f31; }
.lvl .num { font-weight: 900; font-size: 20px; }
.lvl .nm { font-weight: 700; }
.lvl .gl { display: flex; flex-wrap: wrap; gap: 6px; font-size: 12px; }
.lvl .gl span { display: inline-flex; align-items: center; gap: 2px; }
.lvl .gl img { width: 18px; height: 18px; }
.lvl .st i svg, .bigstars i svg { color: rgba(0,0,0,.18); }
.lvl .st i.on svg, .bigstars i.on svg { color: #f2a93b; }
.lvl .st svg { width: 16px; height: 16px; }
.menu-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; color: var(--muted); flex-wrap: wrap; gap: 8px; }

/* top bar */
#top { position: fixed; left: 8px; right: 8px; top: 8px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; pointer-events: none; z-index: 5; }
#top > * { pointer-events: auto; }
#lvl-name, #money, #clock { background: var(--panel); padding: 8px 12px; border-radius: var(--radius); font-weight: 700; white-space: nowrap; }
#money { color: var(--accent); }
#clock { font-variant-numeric: tabular-nums; min-width: 58px; text-align: center; }
.grow { flex: 1; pointer-events: none !important; }
#goals { display: flex; gap: 6px; }
.goal { background: var(--panel); border-radius: var(--radius); padding: 4px 10px 6px 6px; display: grid; grid-template-columns: 26px auto; align-items: center; column-gap: 6px; font-weight: 700; font-variant-numeric: tabular-nums; }
.goal img { width: 26px; height: 26px; grid-row: span 2; }
.goal i { display: block; height: 4px; background: rgba(255,255,255,.2); border-radius: 3px; overflow: hidden; }
.goal i b { display: block; height: 100%; width: 0; background: var(--accent); }
.goal.done i b { background: var(--good); }
#speed { display: flex; background: var(--panel); border-radius: var(--radius); padding: 4px; gap: 4px; }
#speed .sp { padding: 4px 8px; background: transparent; color: var(--paper); display: inline-flex; align-items: center; gap: 2px; }
#speed .sp svg { width: 16px; height: 16px; }
#speed .sp.on { background: var(--accent); color: var(--ink); }

/* toolbar */
#toolbar { position: fixed; left: 50%; bottom: calc(8px + var(--safe-b)); transform: translateX(-50%); display: flex; align-items: center; gap: 6px; background: var(--panel); padding: 6px; border-radius: 16px; max-width: calc(100vw - 16px); z-index: 5; }
#tools { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: thin; }
.tool { width: 58px; height: 62px; padding: 2px; display: grid; grid-template-rows: 1fr auto; place-items: center; flex: 0 0 auto; background: #f3e6c8; }
.tool img { max-width: 52px; max-height: 40px; object-fit: contain; pointer-events: none; }
.tool .ic svg { width: 26px; height: 26px; }
.tool small { font-weight: 700; font-size: 11px; }
.tool.poor small { color: #b5402c; }
.sep { width: 2px; align-self: stretch; background: rgba(255,255,255,.15); }
#hint { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(86px + var(--safe-b)); background: var(--panel); padding: 6px 12px; border-radius: 10px; max-width: calc(100vw - 32px); color: var(--muted); font-size: 13px; text-align: center; z-index: 4; pointer-events: none; }
#toast { position: fixed; left: 50%; top: 64px; transform: translateX(-50%); background: var(--bad); color: #fff; padding: 6px 14px; border-radius: 10px; font-weight: 700; z-index: 8; pointer-events: none; }

/* info panel */
#panel { position: fixed; right: 8px; top: 64px; width: 280px; max-width: calc(100vw - 16px); background: var(--panel); border-radius: 14px; padding: 10px 12px; z-index: 6; }
.ph { display: flex; justify-content: space-between; align-items: center; font-size: 16px; }
#panel-status { color: var(--muted); margin: 4px 0 6px; }
.bad { color: var(--bad); }
#panel-body p { margin: 4px 0; color: var(--muted); font-size: 13px; }
.row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 4px 0; }
.row label { width: 30px; color: var(--muted); font-size: 12px; }
.row em { color: var(--muted); font-size: 12px; }
.chip { display: inline-flex; align-items: center; gap: 2px; background: rgba(255,255,255,.1); border-radius: 8px; padding: 1px 6px 1px 2px; font-weight: 700; }
.chip img { width: 22px; height: 22px; }
.recipe { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 4px 0; }
.recipe small { color: var(--muted); }
.bar { height: 6px; background: rgba(255,255,255,.15); border-radius: 4px; overflow: hidden; margin: 6px 0; }
.bar b { display: block; height: 100%; background: var(--accent); }
.recipes { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.recipes button { font-size: 12px; padding: 4px 8px; display: inline-flex; align-items: center; gap: 4px; }
.recipes button img { width: 18px; height: 18px; }
.recipes button.on { background: var(--accent); box-shadow: inset 0 0 0 2px var(--ink); }
#panel-acts { display: flex; gap: 6px; margin-top: 8px; }
#panel-acts .act { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; }
#panel-acts svg { width: 16px; height: 16px; }

/* modal */
#modal { position: fixed; inset: 0; background: rgba(15,10,7,.55); display: grid; place-items: center; padding: 16px; z-index: 20; }
#modal .card { background: var(--panel); border-radius: 18px; padding: 18px 20px; width: min(440px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; box-shadow: 0 12px 40px rgba(0,0,0,.4); }
#modal h2 { margin: 0 0 6px; font-size: 24px; }
#modal h3 { margin: 12px 0 6px; font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
#modal p { color: var(--muted); margin: 6px 0; }
#modal .small { font-size: 12px; }
.kicker { color: var(--accent); font-weight: 700; text-transform: uppercase; letter-spacing: 1px; font-size: 12px; }
.goals-big { display: flex; flex-wrap: wrap; gap: 10px; }
.goals-big div { display: flex; align-items: center; gap: 6px; background: rgba(255,255,255,.08); border-radius: 10px; padding: 4px 10px 4px 4px; }
.goals-big img { width: 40px; height: 40px; }
.tips { margin: 10px 0 0; padding-left: 20px; color: var(--paper); }
.tips li { margin: 4px 0; }
details { margin-top: 10px; color: var(--muted); }
.btns { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.btns button { padding: 9px 16px; }
.bigstars { display: flex; gap: 6px; justify-content: center; margin: 10px 0; }
.bigstars svg { width: 54px; height: 54px; }

/* phones */
@media (max-width: 700px) {
  #lvl-name { display: none; }
  #top { gap: 5px; }
  .goal { padding: 3px 8px 4px 4px; grid-template-columns: 22px auto; font-size: 12px; }
  .goal img { width: 22px; height: 22px; }
  #money, #clock { padding: 6px 9px; }
  #speed .sp svg { display: none; }
  #speed .sp[data-s="0"] svg { display: inline; }
  #speed .sp { padding: 4px 7px; font-size: 13px; }
  .tool { width: 50px; height: 56px; }
  .tool img { max-width: 44px; max-height: 34px; }
  #toolbar { left: 8px; right: 8px; transform: none; max-width: none; }
  #tools { flex: 1; }
  #toolbar .icon { width: 36px; height: 36px; flex: 0 0 auto; }
  #hint { bottom: calc(80px + var(--safe-b)); font-size: 12px; }
  #panel { left: 8px; right: 8px; width: auto; top: auto; bottom: calc(80px + var(--safe-b)); }
  .logo { font-size: 28px; }
  #levels { grid-template-columns: repeat(2, 1fr); }
}
@media (max-height: 480px) and (orientation: landscape) {
  .tool { width: 46px; height: 48px; } .tool img { max-height: 28px; }
  #panel { top: 56px; bottom: auto; max-height: calc(100vh - 130px); overflow-y: auto; }
}
