:root {
  --ink: #e9dfc6;
  --dim: #a99d84;
  --brass: #c9a35c;
  --brass-hi: #e6c47e;
  --panel: rgba(13, 12, 19, 0.86);
  --edge: rgba(201, 163, 92, 0.35);
  --gas: #ffcf7a;
  --aether: #8fe9d9;
  --dread: #c4473b;
  --good: #9fd6a6;
  --bb: 124px;
  --serif: "IM Fell English", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --caps: "IM Fell English SC", "IM Fell English", Georgia, serif;
  color-scheme: dark;
}
[hidden] { display: none !important; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0b0c14; color: var(--ink); font: 16px/1.35 var(--serif); }
body { -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; touch-action: none; }
canvas#view { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; cursor: default; }
canvas#view.building { cursor: crosshair; }
canvas#view.panning { cursor: grabbing; }
button { font: inherit; color: inherit; cursor: pointer; }

.panel, #hud, #info, #build, #objective, #gazette { background: var(--panel); border: 1px solid var(--edge); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }

/* top bar */
#hud {
  position: fixed; left: 0; right: 0; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 4px 14px; flex-wrap: wrap;
  padding: calc(6px + env(safe-area-inset-top, 0px)) 16px 6px;
  border-width: 0 0 1px;
}
.res { display: flex; flex-direction: column; min-width: 54px; }
.res .lbl, .lbl { font: 11px/1 var(--caps); letter-spacing: 0.08em; color: var(--dim); }
.res .val { font-size: 18px; font-variant-numeric: tabular-nums; }
.res.gas .val { color: var(--gas); }
.res.aether .val { color: var(--aether); }
.bar { display: block; width: 54px; height: 4px; background: rgba(255,255,255,0.1); margin-top: 3px; border-radius: 2px; overflow: hidden; }
.bar.wide { width: 90px; height: 7px; margin-top: 6px; }
.bar i { display: block; height: 100%; width: 0; background: var(--gas); transition: width .3s; }
.dread .bar i { background: linear-gradient(90deg, #7a3a3a, var(--dread)); }
.dread.high .lbl { color: var(--dread); animation: pulse 1s infinite alternate; }
@keyframes pulse { to { opacity: .45; } }
.spacer { flex: 1; }
.clock { display: flex; flex-direction: column; align-items: flex-end; font: 15px/1.1 var(--caps); letter-spacing: .05em; }
.clock .phase { color: var(--dim); font-size: 12px; }
.clock .phase.night { color: #9fb4ff; }
.speed { display: flex; border: 1px solid var(--edge); border-radius: 4px; overflow: hidden; }
.speed button { background: none; border: 0; padding: 6px 9px; font-size: 11px; letter-spacing: -2px; color: var(--dim); }
.speed button.on { background: rgba(201,163,92,.22); color: var(--brass-hi); }
.icon-btn { background: none; border: 1px solid var(--edge); border-radius: 4px; width: 34px; height: 30px; color: var(--brass-hi); }
.icon-btn.off { color: var(--dim); text-decoration: line-through; }

/* charge (objective) and gazette */
#objective { position: fixed; left: 16px; top: 74px; z-index: 4; padding: 8px 12px; border-radius: 4px; max-width: 300px; display: flex; flex-direction: column; gap: 4px; }
#objective #obj-text { font-style: italic; }
#objective.done { border-color: var(--brass-hi); box-shadow: 0 0 18px rgba(230,196,126,.25); }
#gazette { position: fixed; right: 16px; top: 74px; z-index: 4; width: min(320px, calc(100vw - 32px)); padding: 8px 12px 6px; border-radius: 4px; }
#gazette .mast { font: 13px/1 var(--caps); letter-spacing: .14em; text-align: center; color: var(--brass); border-bottom: 1px double var(--edge); padding-bottom: 6px; margin-bottom: 4px; }
#news { list-style: none; margin: 0; padding: 0; font-size: 14px; }
#news li { padding: 4px 0; border-bottom: 1px dotted rgba(201,163,92,.18); opacity: .7; }
#news li:first-child { opacity: 1; }
#news li:last-child { border: 0; }
#news li.bad { color: #e8a59a; }
#news li.good { color: var(--good); }
#news li.night { color: #b8c6ff; }
#news li.fresh { animation: fresh 1.2s ease-out; }
@keyframes fresh { from { background: rgba(201,163,92,.25); } }

/* build bar */
#build {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  padding: 6px 16px calc(6px + env(safe-area-inset-bottom, 0px)); border-width: 1px 0 0;
}
#build-list { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: thin; padding-bottom: 2px; }
.bbtn {
  flex: 0 0 auto; width: 84px; display: flex; flex-direction: column; align-items: center; gap: 1px;
  background: rgba(255,255,255,.03); border: 1px solid rgba(201,163,92,.2); border-radius: 4px; padding: 4px 2px 5px;
}
.bbtn canvas { width: 56px; height: 56px; }
.bbtn .nm { font-size: 13px; line-height: 1.05; text-align: center; }
.bbtn .cost { font-size: 11px; color: var(--dim); font-variant-numeric: tabular-nums; }
.bbtn.on { border-color: var(--brass-hi); background: rgba(201,163,92,.18); box-shadow: inset 0 0 12px rgba(230,196,126,.2); }
.bbtn.cant { opacity: .45; }
.bbtn.tool { width: 64px; justify-content: center; }
.bbtn.tool .glyph { font-size: 26px; height: 56px; line-height: 56px; color: #e08a7a; }

/* info */
#info { position: fixed; right: 16px; bottom: calc(var(--bb) + 10px); z-index: 6; width: min(300px, calc(100vw - 32px)); padding: 12px 14px; border-radius: 4px; }
#info h2 { margin: 0 0 4px; font: 20px/1.1 var(--caps); color: var(--brass-hi); letter-spacing: .03em; }
#info p { margin: 0 0 8px; font-size: 14px; color: var(--ink); }
#info dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin: 0 0 8px; font-size: 14px; }
#info dt { color: var(--dim); }
#info dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
#info .close { position: absolute; right: 6px; top: 4px; background: none; border: 0; font-size: 22px; color: var(--dim); }
#info .why { color: #e8a59a; }
button.danger { background: rgba(196,71,59,.18); border: 1px solid rgba(196,71,59,.6); border-radius: 4px; padding: 5px 12px; color: #f0b3a8; }

#tip { position: fixed; z-index: 9; pointer-events: none; background: var(--panel); border: 1px solid var(--edge); border-radius: 4px; padding: 8px 10px; max-width: 260px; font-size: 14px; }
#tip b { display: block; font: 16px var(--caps); color: var(--brass-hi); }
#tip .c { color: var(--dim); font-size: 13px; margin-top: 4px; }
#toast { position: fixed; left: 50%; top: 40%; transform: translate(-50%, -50%); z-index: 8; pointer-events: none; text-align: center;
  font: 26px/1.2 var(--caps); letter-spacing: .06em; color: var(--brass-hi); text-shadow: 0 0 20px rgba(0,0,0,.9), 0 0 40px rgba(230,196,126,.35);
  animation: toast 2.6s ease-out forwards; }
#toast small { display: block; font: italic 16px var(--serif); color: var(--ink); letter-spacing: 0; }
@keyframes toast { 0% { opacity: 0; transform: translate(-50%, -40%); } 12% { opacity: 1; transform: translate(-50%, -50%); } 75% { opacity: 1; } 100% { opacity: 0; } }

/* overlays */
.overlay { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(ellipse at 50% 40%, rgba(20,18,30,.55), rgba(4,4,10,.92)); overflow-y: auto; }
.card { max-width: 560px; width: 100%; text-align: center; background: rgba(12,11,18,.9); border: 1px solid var(--edge);
  padding: 34px 30px 26px; border-radius: 6px; box-shadow: 0 0 60px rgba(0,0,0,.6), inset 0 0 40px rgba(201,163,92,.05); }
.card.small { max-width: 420px; }
.card h1 { font: 64px/1 var(--caps); margin: 6px 0 14px; color: var(--brass-hi); letter-spacing: .04em;
  text-shadow: 0 0 24px rgba(255,200,110,.35); }
.card h2 { font: 32px/1.1 var(--caps); margin: 4px 0 10px; color: var(--brass-hi); }
.eyebrow { font: italic 15px var(--serif); color: var(--dim); margin: 0; }
.lede { font-size: 17px; line-height: 1.5; margin: 0 0 22px; }
.actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-bottom: 14px; }
.actions.col { flex-direction: column; }
.actions button, .confirm button { background: rgba(255,255,255,.04); border: 1px solid var(--edge); border-radius: 4px; padding: 9px 20px; font-size: 17px; }
.actions button.primary { background: linear-gradient(rgba(201,163,92,.32), rgba(201,163,92,.16)); border-color: var(--brass); color: #fff4dc; }
.actions button:hover { border-color: var(--brass-hi); }
.keys { list-style: none; padding: 12px 0 0; margin: 0; border-top: 1px solid rgba(201,163,92,.2); font-size: 14px; color: var(--dim);
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; text-align: left; }
.keys b { font: 13px var(--caps); color: var(--brass); letter-spacing: .05em; margin-right: 4px; }
.stats { display: grid; grid-template-columns: 1fr auto; gap: 4px 18px; max-width: 260px; margin: 0 auto 18px; text-align: left; }
.stats dt { color: var(--dim); } .stats dd { margin: 0; text-align: right; }
.confirm { font-size: 15px; }

@media (max-width: 760px) {
  #hud { gap: 2px 10px; padding-left: 16px; padding-right: 16px; }
  .res { min-width: 44px; }
  .res .val { font-size: 15px; }
  .bar.wide { width: 60px; }
  #objective { top: auto; bottom: calc(var(--bb) + 8px); left: 16px; right: auto; max-width: calc(100vw - 32px); padding: 6px 10px; }
  #gazette { top: auto; bottom: calc(var(--bb) + 62px); right: 16px; left: 16px; width: auto; }
  #gazette #news li:not(:first-child) { display: none; }
  #info { bottom: calc(var(--bb) + 8px); left: 16px; right: 16px; width: auto; }
  .bbtn { width: 70px; padding-top: 2px; } .bbtn canvas { width: 42px; height: 42px; } .bbtn .cost { font-size: 10px; }
  .bbtn.tool .glyph { height: 42px; line-height: 42px; }
  .card { padding: 26px 18px 20px; }
  .card h1 { font-size: 46px; }
  .keys { grid-template-columns: 1fr; }
}
@media (max-width: 760px) and (max-height: 700px) { #gazette { display: none; } }
#title { background: radial-gradient(ellipse at 50% 45%, rgba(10,10,20,.1), rgba(4,4,10,.8)); }
#title .card { background: rgba(12,11,18,.74); }
