:root { color-scheme: dark; --bg: #1c2128; --panel: rgba(24, 28, 35, .92); --line: rgba(255, 255, 255, .1); --fg: #eef1f5; --muted: #9aa4b2; --accent: #f5a53a; --good: #3ddc84; font-family: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", sans-serif; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--fg); }
button, input { font: inherit; color: inherit; }
button { background: #2a313c; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; cursor: pointer; }
button:hover:not(:disabled) { background: #343d4a; }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #1c1407; font-weight: 800; }
button.big { width: 100%; padding: 12px; font-size: 1.05rem; }
input { background: #12161b; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%; min-width: 0; }
kbd { background: #2a313c; border-radius: 5px; padding: 1px 6px; font: 12px ui-monospace, monospace; }
a { color: var(--accent); }

.landing { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; background: radial-gradient(circle at 30% 20%, #2f3a2a, #151a20 70%); }
.landing-card { width: min(480px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 22px; padding: 26px; display: grid; gap: 10px; box-shadow: 0 30px 80px rgba(0, 0, 0, .5); }
.landing h1 { margin: 6px 0 0; font-size: clamp(2rem, 8vw, 2.8rem); letter-spacing: -.02em; }
.lede { color: var(--muted); margin: 0 0 8px; }
.home { color: var(--muted); text-decoration: none; font-size: .9rem; }
.landing label { font-size: .85rem; color: var(--muted); }
.join { display: flex; gap: 8px; }
.hint { color: var(--muted); font-size: .82rem; margin: 6px 0 0; }

#game { position: fixed; inset: 0; }
#canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; }
#canvas.building { cursor: copy; }
.loading { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 700; color: var(--muted); background: var(--bg); }

.topbar { position: absolute; top: calc(10px + env(safe-area-inset-top, 0px)); left: 10px; display: flex; align-items: center; gap: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 6px 8px 6px 12px; max-width: calc(100vw - 220px); flex-wrap: wrap; }
.brand { font-weight: 900; color: var(--fg); text-decoration: none; }
.room { color: var(--muted); font-size: .85rem; }
.conn { color: var(--good); font-size: .75rem; }
.conn.bad { color: #ff9f43; }
.icon { padding: 6px 9px; line-height: 1; }
.players { display: flex; gap: 6px; flex-wrap: wrap; }
.pl { display: inline-flex; align-items: center; gap: 4px; font-size: .78rem; background: rgba(255, 255, 255, .06); border-radius: 999px; padding: 2px 8px; }
.pl i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

.research-bar { position: absolute; top: calc(10px + env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 8px; background: var(--panel); border-radius: 14px; font-size: .88rem; white-space: nowrap; }
.research-bar.idle { border-color: rgba(245, 165, 58, .6); animation: pulse 2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 4px rgba(245, 165, 58, .25); } }
.rb { width: 90px; height: 8px; background: rgba(255, 255, 255, .1); border-radius: 4px; overflow: hidden; display: inline-block; }
.rb i { display: block; height: 100%; background: var(--good); }
.minimap { position: absolute; top: calc(10px + env(safe-area-inset-top, 0px)); right: 10px; width: 180px; height: 180px; border-radius: 14px; border: 2px solid var(--line); background: #000; image-rendering: pixelated; }

.bottom { position: absolute; left: 50%; bottom: calc(10px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); display: grid; justify-items: center; gap: 6px; }
.hotbar { display: flex; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 5px; }
.tools { position: absolute; right: -150px; bottom: 5px; display: flex; gap: 6px; }
.queue { display: flex; gap: 3px; min-height: 0; }
.slot { position: relative; width: 44px; height: 44px; padding: 4px; border-radius: 9px; background: #232a33; display: grid; place-items: center; }
.slot canvas { width: 30px; height: 30px; pointer-events: none; }
.slot .count { position: absolute; right: 3px; bottom: 1px; font-size: .72rem; font-weight: 800; text-shadow: 0 1px 2px #000; }
.slot .key { position: absolute; left: 4px; top: 1px; font-size: .62rem; color: var(--muted); }
.slot.sel { outline: 2px solid var(--accent); background: #3a3222; }
.slot.empty canvas, .slot.no canvas { opacity: .35; }
.slot .prog { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--good); border-radius: 2px; }
div.slot.empty { opacity: .5; }

.panel { position: absolute; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 14px; box-shadow: 0 20px 60px rgba(0, 0, 0, .45); max-height: calc(100dvh - 180px); overflow: auto; }
.panel h3 { margin: 0 0 8px; font-size: .95rem; }
.panel .close, .card .close { position: absolute; top: 8px; right: 8px; padding: 2px 8px; }
.panel.inv { left: 50%; top: 70px; transform: translateX(-50%); width: min(760px, calc(100vw - 20px)); }
.panel.inv .cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.panel-open .panel.entity { left: 50%; top: auto; bottom: 90px; transform: translateX(-50%); width: min(520px, calc(100vw - 20px)); }
.panel.entity { left: 50%; bottom: 90px; transform: translateX(-50%); width: min(520px, calc(100vw - 20px)); }
.panel-open .panel.inv:has(~ .panel.entity:not([hidden])) { top: 60px; }
.grid { display: flex; flex-wrap: wrap; gap: 4px; }
.grid.recipes .slot { width: 40px; height: 40px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; margin: 8px 0; }
.eslot { display: grid; gap: 3px; justify-items: center; font-size: .72rem; color: var(--muted); }
.status { margin: 0 0 6px; font-weight: 700; }
.pbar { position: relative; height: 12px; background: rgba(255, 255, 255, .08); border-radius: 6px; overflow: hidden; margin: 6px 0 10px; }
.pbar i { position: absolute; inset: 0 auto 0 0; background: var(--good); }
.pbar span { position: absolute; inset: 0; font-size: .66rem; display: grid; place-items: center; }
.lbl { color: var(--muted); }
.btn { margin-top: 4px; }
.panel.research { left: 50%; top: 60px; transform: translateX(-50%); width: min(900px, calc(100vw - 20px)); }
.techs { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.tech { border: 1px solid var(--line); border-radius: 14px; padding: 10px; background: rgba(255, 255, 255, .03); font-size: .84rem; }
.tech p { margin: 4px 0; color: var(--muted); }
.tech .th { font-size: .95rem; }
.tech.done { border-color: rgba(61, 220, 132, .5); }
.tech.done .th::after { content: " ✓"; color: var(--good); }
.tech.locked { opacity: .55; }
.tech.current { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.tech .unl { color: #cfe3ff; }

.chat { position: absolute; left: 10px; bottom: calc(10px + env(safe-area-inset-bottom, 0px)); width: min(340px, 40vw); }
.chat-log { display: grid; gap: 2px; margin-bottom: 4px; font-size: .84rem; }
.chat-line { background: rgba(0, 0, 0, .45); border-radius: 8px; padding: 3px 8px; transition: opacity 2s; }
.chat-line.old { opacity: 0; }
.chat input { background: rgba(0, 0, 0, .45); font-size: .84rem; padding: 6px 10px; }
.toasts { position: absolute; left: 50%; top: 64px; transform: translateX(-50%); display: grid; gap: 6px; justify-items: center; pointer-events: none; }
.toast { background: rgba(20, 24, 30, .92); border: 1px solid var(--line); border-radius: 12px; padding: 8px 14px; font-size: .9rem; transition: opacity .4s, transform .4s; }
.toast.out { opacity: 0; transform: translateY(-8px); }
.overlay { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0, 0, 0, .55); padding: 16px; z-index: 5; }
.card { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 22px; width: min(620px, 100%); max-height: 90dvh; overflow: auto; }
.card ol { padding-left: 20px; line-height: 1.5; }
.card.win { text-align: center; }
.keys { color: var(--muted); font-size: .85rem; line-height: 1.8; }

.stick, .touch-tools { display: none; }
@media (pointer: coarse), (max-width: 860px) {
  .stick { display: block; position: absolute; left: 18px; bottom: calc(100px + env(safe-area-inset-bottom, 0px)); width: 120px; height: 120px; border-radius: 50%; background: rgba(255, 255, 255, .08); border: 2px solid rgba(255, 255, 255, .18); touch-action: none; }
  .knob { position: absolute; left: 35px; top: 35px; width: 50px; height: 50px; border-radius: 50%; background: rgba(255, 255, 255, .35); }
  .touch-tools { display: grid; gap: 8px; position: absolute; right: 12px; bottom: calc(110px + env(safe-area-inset-bottom, 0px)); }
  .touch-tools .icon { font-size: 1.3rem; padding: 10px 12px; }
  .touch-tools .on { background: var(--accent); }
  .minimap { width: 110px; height: 110px; }
  .topbar { max-width: calc(100vw - 140px); }
  .research-bar { top: auto; bottom: calc(76px + env(safe-area-inset-bottom, 0px)); font-size: .78rem; }
  .tools { position: static; }
  .bottom { width: calc(100vw - 16px); }
  .hotbar { overflow-x: auto; max-width: 100%; }
  .slot { width: 40px; height: 40px; }
  .chat { display: none; }
  .panel.inv .cols { grid-template-columns: 1fr; }
  .panel.inv, .panel.research { top: 56px; max-height: calc(100dvh - 190px); }
}

.goals { position: absolute; top: calc(200px + env(safe-area-inset-top, 0px)); right: 10px; width: 220px; text-align: left; background: var(--panel); border-radius: 14px; font-size: .84rem; padding: 10px 12px; }
.goals .gh { color: var(--accent); font-weight: 800; margin-bottom: 3px; }
.goals .gh small { color: var(--muted); font-weight: 400; }
@media (pointer: coarse), (max-width: 860px) { .goals { top: calc(128px + env(safe-area-inset-top, 0px)); width: 160px; font-size: .74rem; padding: 7px 9px; } }
@media (max-width: 1300px) and (min-width: 861px) { .research-bar { top: calc(62px + env(safe-area-inset-top, 0px)); left: 10px; transform: none; } }
@media (pointer: coarse), (max-width: 860px) {
  .research-bar { top: calc(118px + env(safe-area-inset-top, 0px)); bottom: auto; left: 8px; transform: none; max-width: calc(100vw - 140px); overflow: hidden; }
  .goals { top: calc(128px + env(safe-area-inset-top, 0px)); }
  .research-bar ~ .goals { top: calc(170px + env(safe-area-inset-top, 0px)); }
}

.news { background: rgba(255, 255, 255, .04); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; font-size: .85rem; }
.news summary { cursor: pointer; font-weight: 700; }
.news ul { margin: 6px 0 0; padding-left: 18px; color: var(--muted); line-height: 1.6; }

.tip { position: absolute; left: 0; top: 0; z-index: 4; pointer-events: none; max-width: 280px; background: rgba(18, 22, 28, .94); border: 1px solid var(--line); border-radius: 10px; padding: 7px 10px; font-size: .84rem; box-shadow: 0 8px 24px rgba(0, 0, 0, .4); }
.tip .st { margin-top: 2px; }
.tip .st.ok { color: var(--good); }
.tip .st.idle { color: #f2c94c; }
.tip .st.bad { color: #ff7a7a; }
.tip small { display: block; margin-top: 3px; color: var(--muted); }
.hintbar { font-size: .78rem; color: var(--muted); background: rgba(18, 22, 28, .7); border-radius: 999px; padding: 3px 12px; text-align: center; }
.hintbar b { color: var(--fg); }
.hintbar kbd { font-size: 10px; padding: 0 4px; }
@media (pointer: coarse), (max-width: 860px) { .hintbar, .tip { display: none !important; } }
