@font-face { font-family: 'Jersey 20'; font-weight: 100 900; size-adjust: 118%; src: url(../fonts/Jersey20-Regular.ttf) format('truetype'); }

:root {
  --ink: #2a1f17;
  --ink-soft: #5a4636;
  --parch: #f4e4c1;
  --parch-2: #ead5a8;
  --parch-3: #dcc293;
  --bar: #2e4a5a;
  --bar-2: #1f3440;
  --green: #86a83a;
  --gold: #f2c14e;
  --red: #c0523a;
  --night: #1b1622;
  --panel-w: 420px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: var(--night); overscroll-behavior: none;
  font-family: 'Jersey 20', monospace; color: var(--ink);
  user-select: none; -webkit-user-select: none;
}
img { image-rendering: pixelated; }
button { font-family: inherit; cursor: pointer; }

#app { position: relative; height: 100%; width: 100%; overflow: hidden; background: #14301a; }
#game { position: absolute; inset: 0; }
#game canvas { image-rendering: pixelated; display: block; touch-action: none; }

/* ---------- HUD ---------- */
#hud {
  position: absolute; top: 0; left: 0; right: 0; z-index: 35;
  display: flex; justify-content: space-between; align-items: flex-start; gap: 8px;
  padding: 8px 10px 14px; pointer-events: none;
  background: linear-gradient(#1b1622dd, #1b162266 70%, transparent);
}
#hud button, #hud .pill { pointer-events: auto; }
.res-row, .hud-right { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.pill {
  display: flex; align-items: center; gap: 5px; min-width: 96px;
  background: #0e0b13d0; border: 2px solid #000; border-radius: 6px;
  padding: 3px 8px 3px 4px; color: #fff; font-size: 16px; font-weight: 600;
}
.pill img { width: 22px; height: 22px; flex: none; }
.pill small { font-size: 12px; color: #9ed04a; font-weight: 400; margin-left: auto; }
.pill.neg small { color: #ff8a70; }
#hud.hungry .pill[data-res=food] { border-color: #d8402e; animation: hungry 1s infinite; }
@keyframes hungry { 50% { background: #5a1a14d0; } }
#popPill, #buildPill { min-width: 0; }
.prot {
  display: flex; align-items: center; gap: 5px;
  background: linear-gradient(#3e5fae, #2c4687); color: #fff;
  border: 2px solid #000; border-radius: 6px; padding: 3px 10px 3px 5px; font-size: 14px;
  box-shadow: inset 0 -2px 0 #1d2f5c;
}
.prot img { width: 22px; height: 22px; }
.prot b { color: var(--gold); font-size: 18px; }
.icon-btn { width: 36px; height: 32px; border: 2px solid #000; border-radius: 6px; background: #0e0b13d0; color: #fff; font-size: 18px; }

#quest {
  position: absolute; left: 10px; top: calc(var(--hud-h, 60px) - 4px); z-index: 34; width: 310px;
  max-height: calc(100% - var(--hud-h, 60px) - 84px); overflow-y: auto; scrollbar-width: none;
  display: flex; flex-direction: column; gap: 5px;
}
.arena {
  background: #2a2140f0; color: #fff; border: 2px solid #000; border-left: 4px solid var(--gold);
  border-radius: 4px; padding: 6px 8px; display: flex; flex-direction: column; gap: 3px;
}
.arena.ready { background: #3a3214f0; }
.ahead { display: flex; justify-content: space-between; align-items: baseline; }
.ahead b { color: var(--gold); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.ahead small { color: #bbb; font-size: 12px; }
.aname { font-size: 16px; font-weight: 700; }
.agoal { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.agoal i { flex: none; width: 13px; height: 13px; border: 2px solid #8a84a0; border-radius: 2px; font-style: normal; font-size: 10px; line-height: 9px; text-align: center; color: #1e1626; }
.agoal.done i { background: #9ed04a; border-color: #9ed04a; }
.agoal.done span { color: #b8e08a; }
.agoal span { flex: 1; }
.agoal em { font-style: normal; color: #bbb; font-size: 12px; font-variant-numeric: tabular-nums; }
.afoot { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 3px; }
.afoot .c.poor { color: #ff9a88; }
.arena .btn.go { animation: pulseBtn 1s ease-in-out infinite; }
.mrow small { color: var(--ink-soft); font-size: 13px; }
.mrow.soon { border-style: dashed; border-color: #b08a3a; background: #f8ecc8; }
.tag { flex: none; background: #3b2e46; color: var(--gold); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; border-radius: 3px; padding: 3px 7px; }
.arena.soon .agoal i { color: var(--gold); border-color: var(--gold); }
.arena.soon .agoal em { color: var(--gold); }
.qhead {
  align-self: flex-start; background: #1b1622e8; color: var(--gold); border: 2px solid #000; border-radius: 4px;
  padding: 2px 10px; font-size: 15px; font-weight: 700;
}
.qhead small { color: #bbb; font-weight: 400; font-size: 12px; margin-left: 4px; }
.qrow {
  display: flex; align-items: center; gap: 7px;
  background: #1b1622e0; color: #fff; border: 2px solid #000; border-left: 4px solid #6a6480;
  border-radius: 4px; padding: 5px 7px;
}
.qrow.ready { border-left-color: #9ed04a; background: #24361ee8; }
.qpor { flex: none; width: 36px; height: 36px; background: #24324a; border: 2px solid #000; display: flex; align-items: center; justify-content: center; }
.qpor img { width: 30px; height: 28px; }
.qbody { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.qbody b { font-size: 14px; color: var(--gold); }
.qbody span { font-size: 13px; line-height: 1.2; }
.qbar { position: relative; height: 12px; background: #0b141a; border: 1px solid #000; border-radius: 2px; overflow: hidden; }
.qbar i { position: absolute; left: 0; top: 0; bottom: 0; background: linear-gradient(#9ed04a, #5f9a2a); }
.qbar em { position: relative; display: block; text-align: center; font-size: 10px; line-height: 11px; font-style: normal; text-shadow: 1px 1px 0 #000; }
.qrew { display: flex; gap: 6px; font-size: 12px; }
.qrew img { width: 14px; height: 14px; }
.qrow .btn { animation: pulseBtn 1s ease-in-out infinite; }

/* ---------- build button / drawer ---------- */
#buildBtn {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 33;
  display: flex; align-items: center; gap: 8px;
  padding: 8px 22px 8px 14px; font-size: 22px; font-weight: 700; color: #fff; text-shadow: 2px 2px 0 #000;
  background: linear-gradient(#f8d060, #c88a20); border: 3px solid #000; border-radius: 8px;
  box-shadow: inset 0 -4px 0 #0004, 0 4px 0 #0006;
}
#buildBtn img { width: 32px; height: 32px; }
#buildBtn kbd { font-family: inherit; font-size: 12px; background: #0005; border-radius: 3px; padding: 1px 5px; }
#buildBtn:active { transform: translate(-50%, 2px); }

#drawer {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 36;
  background: var(--parch-2); border-top: 3px solid #000; box-shadow: 0 -6px 0 #0003;
  animation: up .18s ease-out;
}
@keyframes up { from { transform: translateY(40px); } }
.dr-head { display: flex; align-items: center; background: #1b1622; padding: 6px 8px 0; }
.dr-tabs { display: flex; gap: 4px; flex: 1; }
.dr-tabs button {
  background: #4a4560; color: #ddd; border: 2px solid #000; border-bottom: 0; border-radius: 6px 6px 0 0;
  padding: 6px 16px; font-size: 16px;
}
.dr-tabs button.on { background: var(--parch-2); color: var(--ink); font-weight: 700; }
.dr-close { background: none; border: 0; color: #fff; font-size: 20px; padding: 4px 10px; }
.dr-cards { display: flex; gap: 10px; overflow-x: auto; padding: 12px; }
.bcard {
  position: relative; flex: 0 0 150px; display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: var(--parch); border: 3px solid var(--parch-3); border-radius: 8px; padding: 8px 6px; text-align: center; color: var(--ink);
}
.bcard:hover { border-color: var(--gold); transform: translateY(-2px); }
.bcard.poorc { opacity: .75; }
.bcard.locked { filter: grayscale(1); opacity: .6; }
.bimg { height: 64px; display: flex; align-items: flex-end; justify-content: center; }
.bimg img { max-width: none; }
.bname { font-size: 16px; font-weight: 700; }
.binfo { font-size: 12px; color: var(--ink-soft); display: flex; align-items: center; gap: 2px; flex-wrap: wrap; justify-content: center; }
.binfo img { width: 14px; height: 14px; }
.bmeta { font-size: 11px; color: #8a7460; }
.bcard .costs { font-size: 13px; }
.lock {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 4px;
  background: #1b1622a0; color: #fff; font-size: 15px; font-weight: 700; border-radius: 5px; text-shadow: 1px 1px 0 #000;
}
.lock img { width: 18px; height: 18px; }

#modeHint {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 37;
  display: flex; align-items: center; gap: 10px; max-width: calc(100% - 20px);
  background: #1b1622ee; color: #fff; border: 2px solid var(--gold); border-radius: 8px; padding: 6px 8px 6px 10px; font-size: 14px;
}
#modeHint img { height: 36px; max-width: 48px; object-fit: contain; }
#modeHint span b { display: block; color: var(--gold); font-size: 15px; }

/* ---------- cutscene layers ---------- */
#spot {
  position: absolute; inset: 0; z-index: 20; pointer-events: none; opacity: 0;
  background: radial-gradient(circle at 50% 50%, rgba(160, 255, 120, .18) 0, rgba(10, 16, 40, .2) 60px, rgba(8, 12, 32, .97) 170px);
  transition: opacity 1.4s ease;
}
#spot.on { opacity: 1; transition: none; }
#flash { position: absolute; inset: 0; z-index: 21; pointer-events: none; background: #fffbe0; opacity: 0; }
#flash.go { animation: flash 1.1s ease-out; }
@keyframes flash { 0% { opacity: .95; } 100% { opacity: 0; } }
body.cutscene #buildBtn, body.cutscene #quest { display: none; }

#banner {
  position: absolute; left: 50%; top: 24%; z-index: 40; pointer-events: none;
  transform: translate(-50%, 0); opacity: 0; white-space: nowrap;
  display: flex; align-items: center; gap: 8px;
  padding: 6px 34px; color: #fff; font-size: 22px; font-weight: 700; text-shadow: 2px 2px 0 #000;
  background: linear-gradient(90deg, transparent, #5a3a14 15%, #8a5a20 50%, #5a3a14 85%, transparent);
  border-top: 2px solid var(--gold); border-bottom: 2px solid var(--gold);
}
#banner img { width: 28px; height: 28px; }
#banner b { color: var(--gold); }
#banner.show { animation: banner 2.4s ease-out forwards; }
@keyframes banner {
  0% { opacity: 0; transform: translate(-50%, 12px) scale(.9); }
  12% { opacity: 1; transform: translate(-50%, 0) scale(1.05); }
  20% { transform: translate(-50%, 0) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -16px); }
}

#toast {
  position: absolute; left: 50%; top: var(--hud-h, 58px); z-index: 60; pointer-events: none;
  transform: translate(-50%, -20px); opacity: 0; transition: .25s;
  width: max-content; max-width: calc(100% - 32px); text-align: center;
  background: #1b1622ee; color: #fff; font-size: 15px; padding: 8px 16px;
  border: 2px solid var(--gold); border-radius: 6px;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- dialogue ---------- */
#dialog { position: absolute; inset: 0; z-index: 50; cursor: pointer; }
.dlg-box {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 20px; width: min(760px, calc(100% - 20px));
  min-height: 118px; padding: 28px 110px 16px 18px;
  background: var(--parch); border: 3px solid var(--ink); border-radius: 6px;
  box-shadow: 0 0 0 2px #c79a4a, 0 6px 0 #0006;
}
.dlg-name {
  position: absolute; top: -16px; left: 14px;
  background: #3b2e46; color: #fff; padding: 3px 16px; font-size: 17px; font-weight: 600;
  border: 2px solid #d8b060; border-radius: 4px;
}
.dlg-text { font-size: 18px; line-height: 1.35; color: var(--ink-soft); min-height: 66px; }
.dlg-portrait {
  position: absolute; right: 10px; bottom: 10px; width: 88px; height: 88px;
  background: #24324a; border: 3px solid var(--ink); box-shadow: 0 0 0 2px #d8b060;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.dlg-portrait img { width: 78px; height: 72px; }
.dlg-next { position: absolute; right: 114px; bottom: 8px; font-size: 12px; color: var(--ink-soft); opacity: 0; }
.done .dlg-next { opacity: 1; animation: bob .8s infinite; }
@keyframes bob { 50% { transform: translateY(3px); } }

#skip {
  position: absolute; top: 60px; right: 12px; z-index: 70;
  background: #0e0b13cc; color: #fff; border: 2px solid #fff6; border-radius: 16px; padding: 5px 14px; font-size: 15px;
}

/* ---------- story card ---------- */
#card { position: absolute; inset: 0; z-index: 55; background: #000a; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.card-frame {
  height: min(78vh, 560px); aspect-ratio: 5 / 8; padding: 6px;
  background: linear-gradient(135deg, #e8f4ff, #9fb8d8 40%, #e8f4ff 60%, #9fb8d8);
  box-shadow: 0 0 40px #7fff9a88; animation: cardIn .6s ease-out;
}
@keyframes cardIn { from { transform: scale(.7) rotate(-4deg); } }
.card-scene { position: relative; width: 100%; height: 100%; overflow: hidden; background: linear-gradient(#3a4252 0, #59647a 35%, #3b5a33 62%, #2b4a26 100%); }
.card-scene::before { content: ''; position: absolute; left: 0; right: 0; top: 52%; height: 10%; background: repeating-linear-gradient(90deg, #1f3a26 0 6px, #2a4a30 6px 12px); }
.bolt { position: absolute; width: 3px; background: #e8f0ff; box-shadow: 0 0 8px #fff; opacity: 0; transform-origin: top; }
.b1 { left: 20%; top: 4%; height: 22%; transform: rotate(14deg); animation: bolt 3s infinite .4s; }
.b2 { left: 72%; top: 8%; height: 18%; transform: rotate(-18deg); animation: bolt 3.4s infinite 1.6s; }
@keyframes bolt { 0%, 90%, 100% { opacity: 0; } 92%, 96% { opacity: 1; } 94% { opacity: .2; } }
.card-glow { position: absolute; left: 50%; top: 52%; width: 140px; height: 140px; transform: translate(-50%, -50%); background: radial-gradient(circle, #d8ffd0 0, #6bff7a99 25%, transparent 65%); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { transform: translate(-50%, -50%) scale(1.25); opacity: .7; } }
.card-scene img { position: absolute; }
.c-statue { width: 46%; left: 40%; top: 18%; filter: drop-shadow(0 0 10px #4c7a4c); }
.c-hero { width: 34%; left: 8%; top: 44%; }
.c-dog { width: 28%; left: 62%; top: 60%; }
.card-text { position: absolute; left: 0; right: 0; bottom: 0; padding: 30px 12px 12px; color: #fff; font-size: 16px; line-height: 1.3; text-shadow: 1px 1px 0 #000; background: linear-gradient(transparent, #000c 40%); }

/* ---------- side panel ---------- */
#panel {
  position: absolute; top: calc(var(--hud-h, 60px) - 8px); right: 0; bottom: 0; width: var(--panel-w); max-width: 100%; z-index: 38;
  border-left: 3px solid #000; border-top: 3px solid #000; box-shadow: -6px 0 0 #0003; animation: slide .18s ease-out;
}
@keyframes slide { from { transform: translateX(30px); } }
.sheet { position: absolute; inset: 0; display: flex; flex-direction: column; background: var(--parch-2); }
.sheet-art {
  position: relative; flex: 0 0 170px; overflow: hidden;
  background: radial-gradient(circle at 50% 75%, #8fd06099 0, transparent 60%), repeating-linear-gradient(45deg, #5fae3c 0 6px, #58a536 6px 12px);
  display: flex; align-items: flex-end; justify-content: center; padding: 14px 0 16px;
}
.art-img { height: 100%; max-width: 70%; object-fit: contain; filter: drop-shadow(0 4px 0 #0004); }
.back { position: absolute; right: 8px; top: 8px; width: 34px; height: 34px; background: #3b3550; color: #fff; border: 2px solid #000; border-radius: 6px; font-size: 16px; }
.sheet-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: linear-gradient(var(--bar), var(--bar-2)); color: #fff; border-top: 3px solid #000; border-bottom: 3px solid #000; padding: 8px 12px; }
.sheet-bar .title { font-size: 21px; font-weight: 700; text-shadow: 2px 2px 0 #000; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sheet-bar small { font-size: 17px; color: #cfe4f0; }
.pct { position: relative; flex: 0 0 120px; height: 24px; background: #0b141a; border: 2px solid #000; border-radius: 3px; overflow: hidden; }
.pct i { position: absolute; left: 0; top: 0; bottom: 0; background: linear-gradient(#9ed04a, #5f9a2a); }
.pct b { position: relative; display: block; text-align: center; font-size: 14px; line-height: 20px; text-shadow: 1px 1px 0 #000; }
.sheet-body { flex: 1; overflow-y: auto; padding: 10px 10px 16px; }
.sheet-tabs { display: flex; gap: 8px; padding: 8px 10px 0; background: #1b1622; }
.sheet-tabs button { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; background: #4a4560; color: #ddd; border: 2px solid #000; border-radius: 6px 6px 2px 2px; padding: 7px; font-size: 15px; }
.sheet-tabs button img { width: 20px; height: 20px; }
.sheet-tabs button.on { background: linear-gradient(#e8b84a, #b88424); color: #fff; text-shadow: 1px 1px 0 #000; }
.sheet-foot { display: flex; gap: 8px; padding: 8px 10px; background: #1b1622; }
.sheet-foot .btn { flex: 1; flex-direction: row; justify-content: center; }

.box { background: var(--parch); border: 2px solid var(--parch-3); border-radius: 6px; padding: 10px; margin-bottom: 10px; font-size: 15px; }
.box p { margin: 0 0 8px; }
.box p.big { font-size: 18px; font-weight: 700; }
.stat { display: flex; align-items: center; gap: 4px; font-size: 17px; font-weight: 600; margin: 6px 0 8px; }
.stat img { width: 20px; height: 20px; }
.costs { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.c { display: inline-flex; align-items: center; gap: 2px; font-weight: 600; }
.c img { width: 16px; height: 16px; }
.c.poor { color: #d8402e; }
.c.free { color: #4a7a1a; }

.upgrade-box { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.upgrade-box small { color: var(--ink-soft); font-size: 13px; }
.upgrade-box.ready { border-color: var(--gold); }
.prod-line { display: flex; align-items: center; gap: 4px; font-size: 16px; margin: 0 2px 10px; flex-wrap: wrap; }
.prod-line img { width: 20px; height: 20px; }
.prod-line small { color: var(--ink-soft); }
.prod-line .warn { color: #d8402e; }

.frow { display: flex; align-items: center; gap: 10px; background: var(--parch); border: 2px solid var(--parch-3); border-radius: 6px; padding: 8px; margin-bottom: 8px; }
.frow.empty { opacity: .6; }
.ficon { flex: none; width: 52px; height: 52px; display: flex; align-items: center; justify-content: center; background: #fff8e6; border: 3px solid #d8c070; border-radius: 4px; font-size: 22px; color: var(--ink-soft); }
.ficon img { width: 40px; height: 40px; }
.finfo { flex: 1; min-width: 0; }
.fname { font-size: 16px; font-weight: 700; }
.flv { font-size: 12px; font-weight: 400; background: #3b2e46; color: #fff; border-radius: 3px; padding: 0 5px; margin-left: 2px; }
.fdesc { font-size: 13px; color: var(--ink-soft); margin: 2px 0; }
.fprod { font-size: 14px; display: flex; align-items: center; gap: 3px; }
.fprod img { width: 14px; height: 14px; }
.fprod b, .arr { color: #4a7a1a; }
.hint { font-size: 14px; color: var(--ink-soft); margin: 0 2px 10px; }
h4 { margin: 14px 2px 8px; font-size: 16px; display: flex; align-items: center; justify-content: space-between; }

.btn {
  flex: none; display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-width: 84px; padding: 5px 10px; font-size: 15px; font-weight: 700; color: #fff;
  text-shadow: 1px 1px 0 #0008; border: 2px solid #000; border-radius: 5px;
  background: linear-gradient(#8a86a0, #625e78); box-shadow: inset 0 -3px 0 #0004;
}
.btn.sm { min-width: 0; padding: 3px 10px; font-size: 13px; }
.btn .costs { gap: 6px; font-size: 13px; }
.btn .c { color: #fff; }
.btn .c.poor { color: #ffb0a0; }
.btn.green { background: linear-gradient(#9cc048, var(--green)); }
.btn.gold { background: linear-gradient(#f8d060, #d8a030); }
.btn.red { background: linear-gradient(#d8684a, var(--red)); }
.btn.dim { filter: grayscale(.85) brightness(.85); }
.btn:active { transform: translateY(2px); box-shadow: none; }
.pulse { animation: pulseBtn 1s ease-in-out infinite; }
@keyframes pulseBtn { 50% { box-shadow: 0 0 0 4px #ffe14a, 0 0 18px #ffe14a; } }
#buildBtn.pulse { animation: pulseBuild 1s ease-in-out infinite; }
@keyframes pulseBuild { 50% { box-shadow: 0 0 0 4px #ffe14a, 0 0 22px #ffe14a; } }

.mrow { display: flex; align-items: center; gap: 10px; padding: 7px 10px; margin-bottom: 6px; background: var(--parch); border: 2px solid var(--parch-3); border-radius: 6px; font-size: 15px; }
.mrow .req { display: flex; align-items: center; gap: 2px; font-weight: 700; color: #2c4687; min-width: 44px; }
.mrow .req img { width: 18px; height: 18px; }
.mrow .mtext { flex: 1; }
.mrow.done { opacity: .55; }
.mrow.done .mark { color: #4a7a1a; font-weight: 700; }

/* ---------- menu ---------- */
#menu { position: absolute; inset: 0; z-index: 80; background: #000a; display: flex; align-items: center; justify-content: center; }
.menu-box { width: min(90%, 380px); background: var(--parch); border: 3px solid var(--ink); border-radius: 6px; padding: 18px; display: flex; flex-direction: column; gap: 10px; box-shadow: 0 0 0 2px #c79a4a; }
.menu-box h3 { margin: 0; font-size: 24px; }
.muted { margin: 0; font-size: 14px; color: var(--ink-soft); }
.keys { line-height: 1.5; }
.menu-box .btn { width: 100%; font-size: 17px; padding: 9px; }
.menu-box .x-btn { text-decoration: none; text-align: center; background: linear-gradient(#2a2a34, #14141a); font-size: 15px; }

@media (max-width: 760px) {
  #hud { flex-direction: column; }
  .pill { min-width: 0; font-size: 14px; }
  .pill small { display: none; }
  #quest { width: min(300px, calc(100% - 70px)); }
  #panel { width: 100%; }
}

/* ---------- day/night clock, zoom, repair ---------- */
#clockPill { min-width: 0; position: relative; padding-bottom: 7px; }
#clockPill em { position: absolute; left: 4px; right: 4px; bottom: 2px; height: 3px; background: #2a2640; border-radius: 2px; overflow: hidden; }
#clockPill em i { display: block; height: 100%; width: 0; background: #ffd23f; }
#clockPill.night { border-color: #6a58c8; background: #1a1438e0; }
#clockPill.night em i { background: #b8a8ff; }

#zoom { position: absolute; right: 10px; bottom: 16px; z-index: 33; display: flex; flex-direction: column; gap: 6px; }
#zoom button {
  width: 42px; height: 42px; font-size: 24px; line-height: 1; font-weight: 700; color: #fff;
  background: #1b1622e0; border: 2px solid #000; border-radius: 8px; box-shadow: inset 0 -3px 0 #0005;
}
#zoom button:active { transform: translateY(2px); box-shadow: none; }
body.cutscene #zoom { display: none; }

.repair-box { display: flex; align-items: center; justify-content: space-between; gap: 10px; border-color: #d8402e; background: #ffe2d6; }
.repair-box small { color: var(--ink-soft); font-size: 13px; }

.qtoggle {
  align-self: flex-start; display: flex; align-items: center; gap: 8px;
  background: #1b1622f0; color: var(--gold); border: 2px solid #000; border-radius: 6px;
  padding: 5px 10px; font-size: 15px; font-weight: 700;
}
.qtoggle b { background: #9ed04a; color: #14240a; border-radius: 3px; padding: 0 6px; font-size: 12px; }
.qtoggle i { font-style: normal; font-size: 10px; color: #bbb; }
.qtoggle.has { animation: pulseBtn 1.4s ease-in-out infinite; }
#modeHint .btn { min-width: 0; }
#modeHint .btn.green { font-size: 17px; padding: 8px 18px; }

/* ---------- phones ---------- */
@media (max-width: 760px) {
  #hud { padding: calc(env(safe-area-inset-top, 0px) + 5px) 6px 10px; gap: 5px; }
  .res-row, .hud-right { gap: 4px; }
  .pill { padding: 2px 6px 2px 3px; font-size: 13px; }
  .pill img { width: 18px; height: 18px; }
  .prot { padding: 2px 7px 2px 4px; font-size: 12px; }
  .prot span { display: none; }
  .prot img { width: 18px; height: 18px; }
  .prot b { font-size: 15px; }
  .icon-btn { width: 32px; height: 28px; font-size: 16px; }
  #quest { left: 6px; }
  #buildBtn { bottom: calc(env(safe-area-inset-bottom, 0px) + 12px); font-size: 20px; padding: 9px 20px 9px 12px; }
  #buildBtn kbd { display: none; }
  #zoom { right: 6px; bottom: calc(env(safe-area-inset-bottom, 0px) + 12px); }
  #modeHint { left: 6px; right: 6px; transform: none; bottom: calc(env(safe-area-inset-bottom, 0px) + 10px); font-size: 13px; }
  #modeHint span { flex: 1; min-width: 0; }
  body:has(#modeHint:not([hidden])) #zoom { bottom: calc(env(safe-area-inset-bottom, 0px) + 78px); }
  .bcard { flex-basis: 132px; }
  .dr-tabs { overflow-x: auto; }
  .dr-tabs button { padding: 7px 12px; font-size: 15px; white-space: nowrap; }
  .dr-cards { padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 12px); }
  .dlg-box { bottom: calc(env(safe-area-inset-bottom, 0px) + 12px); padding: 24px 92px 12px 12px; }
  .dlg-text { font-size: 16px; }
  .dlg-portrait { width: 74px; height: 74px; }
  .dlg-portrait img { width: 64px; height: 60px; }
  .dlg-next { right: 96px; }
  .sheet-art { flex-basis: 120px; }
  .btn { min-width: 76px; }
  #skip { top: calc(var(--hud-h, 60px) + 6px); }
}

[hidden] { display: none !important; }
