:root {
  --ink: #1B1D21;
  --panel: #23262B;
  --panel-2: #1E2126;
  --line: #3A3F46;
  --cyan: #8FA0AE;
  --pink: #C08B4E;
  --violet: #9AA3AD;
  --green: #5FA88C;
  --amber: #D9973F;
  --red: #B5504B;
  --cream: #EFE9DE;
  --dim: #A8A296;
  --gold: #C08B4E;
  --slate: #2E3238;
  --steel: #7C8794;
  --mint: #5FA88C;
  --brick: #B5504B;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: #08060a;
  color: var(--cream);
  font-family: 'Nunito', 'Segoe UI', system-ui, sans-serif;
  font-weight: 600;
  letter-spacing: 0.1px;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}

#boot {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 40%, #2A1C12, #08060A 70%);
  transition: opacity 0.4s ease;
}
#boot.gone { opacity: 0; }
.boot-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 18px 26px;
  border: 1px solid #6B4F35;
  background: rgba(14, 12, 10, 0.9);
  color: var(--cream);
}
.boot-card b {
  font-size: 26px;
  letter-spacing: 1px;
  color: #E9C98A;
  text-shadow: 0 1px 5px rgba(0, 0, 0, 0.5);
}
.boot-card span { font-size: 11px; letter-spacing: 0.6px; color: var(--dim); }

#app {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

#world {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

#fx {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 5;
}

#tags {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 6;
}
.world-tag {
  position: absolute;
  transform: translate(-50%, -50%);
  padding: 1px 4px;
  background: rgba(4, 10, 17, 0.78);
  border: 1px solid currentColor;
  font-size: 7.5px;
  letter-spacing: 0.2px;
  line-height: 1.12;
  white-space: nowrap;
  color: var(--cyan);
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.6);
}
.world-tag.aisle {
  color: #23262B;
  background: #E8E2D6;
  border: 1px solid #C08B4E;
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.35px;
  padding: 2px 7px;
  text-shadow: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
}
@media (max-width: 520px) { .world-tag.aisle { font-size: 8px; padding: 1px 5px; letter-spacing: 0.2px; } }
.world-tag.brand { font-size: 11px; color: #E9C98A; text-shadow: 0 0 12px rgba(192, 139, 78, 0.55); padding: 2px 6px; }
.world-tag.portal-tag { font-size: 6.5px; }
.world-tag.shop {
  color: var(--gold);
  pointer-events: auto;
  cursor: pointer;
  font-size: 7.5px;
  text-align: center;
  background: rgba(10, 8, 4, 0.86);
  border-color: rgba(255, 210, 63, 0.7);
  text-shadow: 0 0 8px rgba(255, 210, 63, 0.45);
}
.world-tag.shop:hover { background: rgba(60, 44, 8, 0.95); }
.world-tag.shop b { display: block; font-size: 7.5px; color: #fff; }
.world-tag.portal-tag {
  font-size: 8px;
  letter-spacing: 0.2px;
  padding: 1px 4px;
  color: #EAF2F8;
  background: rgba(12, 18, 24, 0.92);
  border: 1px solid #6E93AB;
  font-weight: 700;
  transform: translate(-50%, -50%);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
}

/* ---------------- HUD base ---------------- */
#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}
#hud > * { pointer-events: auto; }

.panel, .hud-block {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: inset 0 0 0 1px rgba(255, 214, 110, 0.07), 0 8px 26px rgba(0, 0, 0, 0.6);
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 10px 100%, 0 calc(100% - 10px));
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px 6px;
  font-size: 11px;
  letter-spacing: 1.1px;
  color: #f2dfb4;
  background: linear-gradient(90deg, rgba(255, 214, 110, 0.13), rgba(255, 214, 110, 0.02) 60%, transparent);
  border-bottom: 1px solid var(--line);
  text-shadow: none;
}

.panel-x {
  pointer-events: auto;
  border: 1px solid var(--line);
  background: rgba(70, 223, 240, 0.1);
  color: var(--cyan);
  font-family: inherit;
  font-size: 9px;
  padding: 3px 6px;
  cursor: pointer;
}
.panel-x:hover { background: rgba(70, 223, 240, 0.22); }

.btn {
  font-family: inherit;
  font-size: 11px;
  letter-spacing: 0.5px;
  color: var(--ink);
  background: var(--cyan);
  border: 0;
  padding: 9px 12px;
  cursor: pointer;
  clip-path: polygon(0 0, calc(100% - 6px) 0, 100% 6px, 100% 100%, 6px 100%, 0 calc(100% - 6px));
  box-shadow: 0 0 12px rgba(70, 223, 240, 0.35);
}
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: translateY(1px); }
.btn.tiny { font-size: 9px; padding: 6px 8px; }
.btn.primary { background: var(--pink); color: #fff; box-shadow: 0 0 14px rgba(192, 139, 78, 0.4); }
.btn.danger { background: var(--red); color: #180407; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: 0.42; filter: grayscale(0.7); cursor: default; box-shadow: none; }

.btn.night-btn {
  background: linear-gradient(90deg, #8A4A2E, var(--pink));
  color: #fff;
  font-size: 12px;
  padding: 8px 12px;
  box-shadow: 0 0 16px rgba(192, 139, 78, 0.45);
}
@keyframes nightPulse {
  0%, 100% { box-shadow: 0 0 10px rgba(192, 139, 78, 0.3); }
  50% { box-shadow: 0 0 22px rgba(192, 139, 78, 0.6); }
}

.icon-btn {
  width: 26px;
  height: 26px;
  font-family: inherit;
  font-size: 13px;
  color: var(--cyan);
  background: rgba(70, 223, 240, 0.1);
  border: 1px solid var(--line);
  cursor: pointer;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 4px 100%, 0 calc(100% - 4px));
}
.icon-btn:hover { background: rgba(70, 223, 240, 0.24); }

/* ---------------- top left ---------------- */
#topLeft {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 8px 12px 10px;
  min-width: 232px;
  border-left: 3px solid var(--pink);
}
#gameTitle {
  margin: 0 0 8px;
  font-family: 'Nunito', 'Segoe UI', system-ui, sans-serif;
  font-size: clamp(10.8px, 2.9vw, 14.5px);
  line-height: 1.12;
  letter-spacing: 0.1px;
  color: #fff;
  text-shadow: 0 2px 0 #0a0f17, 0 4px 14px rgba(0, 0, 0, 0.55);
  font-weight: 900;
  white-space: nowrap;
}
.hud-line {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  line-height: 1.5;
  color: var(--cream);
  white-space: nowrap;
}
.hud-line .lbl { color: var(--dim); font-size: 10px; letter-spacing: 0.5px; }
.hud-line b { font-weight: 700; }
.hud-line .ico {
  width: 13px;
  height: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
.hud-line .ico canvas { width: 100%; height: 100%; image-rendering: pixelated; display: block; }

.health { margin-bottom: 1px; }
.health b { color: #ffd9d9; font-size: 12px; }
.health-bar {
  position: relative;
  flex: 1;
  min-width: 52px;
  height: 8px;
  margin-left: 2px;
  background: #2a0f16;
  border: 1px solid #5c1f2a;
  overflow: hidden;
}
.health-bar i {
  display: block;
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #ff3b52, #ff7b62);
  box-shadow: 0 0 10px rgba(255, 70, 90, 0.6);
  transition: width 0.25s ease;
}
.wave-line { gap: 10px; margin: 2px 0; }
.wave-line b { font-size: 13px; color: #fff; letter-spacing: 0.5px; }
.phase {
  font-size: 11px;
  letter-spacing: 1px;
  padding: 1px 5px;
  border: 1px solid currentColor;
}
.phase.day { color: var(--amber); text-shadow: 0 0 8px rgba(240, 164, 58, 0.6); }
.phase.night { color: var(--pink); text-shadow: 0 0 9px rgba(192, 139, 78, 0.6); }
.currency b { font-size: 13px; }
.currency:nth-of-type(3) b, #goldTxt { color: var(--gold); text-shadow: 0 0 8px rgba(255, 210, 63, 0.45); }
#gemsTxt { color: var(--cyan); text-shadow: 0 0 8px rgba(70, 223, 240, 0.5); }
.night-line { gap: 12px; margin-top: 3px; color: var(--dim); font-size: 10px; }
.night-line b { color: var(--red); font-size: 12px; }
.top-actions { display: flex; align-items: center; gap: 8px; margin-top: 7px; }
.top-actions .night-btn { flex: 1; }
.btn.repair-btn { background: var(--amber); color: #1b1204; font-size: 9px; }
.btn.noble-btn {
  margin-top: 6px;
  width: 100%;
  background: linear-gradient(90deg, #6E4A2A, #C08B4E);
  color: #fff;
  font-size: 9px;
  padding: 6px 8px;
  box-shadow: 0 0 14px rgba(192, 139, 78, 0.45);
}
@keyframes noblePulse {
  0%, 100% { box-shadow: 0 0 8px rgba(192, 139, 78, 0.35); }
  50% { box-shadow: 0 0 20px rgba(192, 139, 78, 0.65); }
}
body.card-open .hint { display: none !important; }
body.noble-wait #towerPanel { top: 228px; }
@media (max-width: 900px) { body.noble-wait #towerPanel { top: 200px; } }
@media (max-width: 720px) { body.noble-wait #towerPanel { top: 194px; } }
@media (max-width: 430px) { body.noble-wait #towerPanel { top: 188px; } }
body.coach-on .hint { display: none !important; }
.world-tag.shop b { color: #ffe9a8; }
#topLeft.overrun { border-left-color: var(--red); }

/* ---------------- tower selection ---------------- */
#towerPanel {
  position: absolute;
  left: 10px;
  top: 198px;
  width: 206px;
  padding-bottom: 6px;
}
.tower-list { padding: 6px; display: flex; flex-direction: column; gap: 5px; min-height: 0; }
#towerPanel .panel-foot { flex: 0 0 auto; }
.tower-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 5px 6px;
  font-family: inherit;
  text-align: left;
  color: var(--cream);
  background: rgba(38, 32, 25, 0.72);
  border: 1px solid #4c3d2c;
  cursor: grab;
  clip-path: polygon(0 0, calc(100% - 5px) 0, 100% 5px, 100% 100%, 5px 100%, 0 calc(100% - 5px));
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
  touch-action: none;
}
.tower-chip:hover { border-color: var(--gold); background: rgba(64, 51, 33, 0.92); }
.tower-chip.chosen { border-color: var(--gold); background: rgba(66, 54, 18, 0.8); box-shadow: 0 0 10px rgba(255, 210, 63, 0.3); }
.tower-chip.poor { opacity: 0.62; }
.tower-chip:active { transform: scale(0.98); }
.tower-chip .t-ico {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #17130f;
  border: 1px solid #55442f;
}
.tower-chip .t-ico canvas { width: 23px; height: 23px; image-rendering: pixelated; display: block; }
.tower-chip .t-body { min-width: 0; flex: 1; }
.tower-chip .t-name { display: block; font-size: 11px; font-weight: 700; line-height: 1.12; white-space: normal; overflow-wrap: anywhere; }
.tower-chip .t-cost { display: block; font-size: 9.5px; color: var(--gold); margin-top: 2px; }
.tower-chip .t-cost::before { content: '$'; }
.tower-chip .t-cost.poor { color: var(--red); }
.panel-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 5px 8px 0;
  border-top: 1px solid var(--line);
  font-size: 9px;
  color: var(--dim);
}

/* ---------------- bottom bar ---------------- */
#bottomBar {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  pointer-events: none;
}
#bottomBar > * { pointer-events: auto; }

#inventoryPanel { width: 300px; flex: 0 0 auto; }
.inv-slots { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; padding: 6px 7px 4px; }
.inv-slot {
  position: relative;
  min-width: 0;
  height: 70px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  overflow: hidden;
  background: #17130f;
  border: 1px solid #55442f;
  font-family: inherit;
  color: var(--cream);
  cursor: pointer;
}
.inv-slot:disabled { cursor: default; opacity: 0.5; }
.inv-slot.gear { cursor: default; background: #14110d; border-color: #6d5636; }
.inv-slot.gear .n { color: var(--gold); }
.inv-slot.gear .ct { color: #fff; }
.inv-slot.has { border-color: var(--cyan); box-shadow: inset 0 0 12px rgba(70, 223, 240, 0.12); }
.inv-slot canvas { width: 24px; height: 24px; image-rendering: pixelated; display: block; }
.inv-slot .n { font-size: 10px; line-height: 1.1; color: var(--cream); font-weight: 800; letter-spacing: 0.3px; }
.inv-slot .ct { font-size: 12px; line-height: 1.05; color: #fff; }
.inv-slot .p { font-size: 8px; line-height: 1.05; color: var(--gold); }
.inv-foot { display: flex; justify-content: flex-end; padding: 0 7px 6px; }

#heroPanel { width: 240px; flex: 0 0 auto; }
.hero-body { display: flex; align-items: center; gap: 8px; padding: 7px 9px 2px; }
#portrait {
  width: 56px;
  height: 56px;
  image-rendering: auto;
  border: 1px solid #5a4632;
  background: #100c0a;
  flex: 0 0 56px;
  border-radius: 3px;
}
.hero-text { min-width: 0; }
.hero-label { font-size: 9px; color: var(--dim); }
.hero-name { font-size: 15px; color: #fff; letter-spacing: 0.5px; text-shadow: 0 0 10px rgba(255, 255, 255, 0.2); }
.hero-gold { font-size: 14px; color: var(--gold); text-shadow: 0 0 8px rgba(255, 210, 63, 0.45); }
.hero-bonus { display: none; }

#rightBar { margin-left: auto; display: flex; align-items: flex-end; gap: 8px; }
#abilityPanel { width: 172px; }
.ability-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  padding: 6px;
}
.ability {
  position: relative;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #17130f;
  border: 1px solid #55442f;
  font-family: inherit;
  color: var(--cream);
  cursor: pointer;
  overflow: hidden;
}
.ability canvas { width: 18px; height: 18px; image-rendering: pixelated; display: block; }
.ability .cost {
  position: absolute;
  right: 2px;
  bottom: 1px;
  font-size: 8px;
  color: var(--cyan);
}
.ability .cd {
  position: absolute;
  inset: 0;
  background: rgba(5, 8, 15, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--cyan);
}
.ability.ready { border-color: var(--violet); box-shadow: inset 0 0 12px rgba(179, 107, 255, 0.16); }
.ability:disabled { cursor: default; }
.ability:not(:disabled):hover { border-color: var(--violet); }
.ability .label {
  position: absolute;
  left: 3px;
  top: 1px;
  font-size: 7px;
  letter-spacing: 0.5px;
  color: var(--dim);
}
#radarPanel { width: 120px; }
#radar {
  display: block;
  width: 100%;
  height: auto;
  padding: 4px;
}

/* ---------------- hint ---------------- */
.hint {
  position: absolute;
  left: 50%;
  bottom: 128px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: min(640px, calc(100vw - 40px));
  padding: 6px 10px;
  background: rgba(6, 12, 20, 0.86);
  border: 1px solid #1d3346;
  font-size: 10px;
  color: #a9c4da;
  pointer-events: auto;
  clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 8px 100%, 0 calc(100% - 8px));
  z-index: 9;
}
.hint b { color: var(--cyan); }
.hint-x {
  border: 0;
  background: transparent;
  color: #54718a;
  font-size: 13px;
  cursor: pointer;
  padding: 0 2px;
  font-family: inherit;
}
#hint.gone { display: none; }

/* ---------------- cards ---------------- */
.card {
  position: absolute;
  width: 330px;
  z-index: 20;
}
.pad-card {
  right: 12px;
  top: 12px;
  width: 300px;
}
.block-card { right: 12px; top: 12px; width: 280px; }
.visitor-card { left: 50%; top: 50%; transform: translate(-50%, -50%); width: 380px; border-color: #4c2a62; }
.visitor-card .panel-head { color: var(--violet); border-bottom-color: #40244f; background: linear-gradient(90deg, rgba(179, 107, 255, 0.2), transparent); }
.card-body { padding: 8px 10px 10px; }
.card-text { margin: 0 0 8px; font-size: 10px; line-height: 1.5; color: #a9c4da; }
.card-actions { display: flex; gap: 6px; justify-content: flex-end; margin-top: 8px; }
.build-list { display: flex; flex-direction: column; gap: 5px; }
.build-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px;
  background: #0b1925;
  border: 1px solid #20404f;
  cursor: pointer;
  font-family: inherit;
  color: var(--cream);
  text-align: left;
}
.build-row:hover { border-color: var(--cyan); }
.build-row .b-ico { width: 24px; height: 24px; flex: 0 0 24px; display: flex; align-items: center; justify-content: center; }
.build-row .b-ico canvas { width: 20px; height: 20px; image-rendering: pixelated; }
.build-row .b-name { flex: 1; font-size: 9px; }
.build-row .b-cost { font-size: 9px; color: var(--gold); }
.build-row.poor { opacity: 0.6; }
.built-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.built-head span { font-size: 12px; color: #fff; }
.built-head b { font-size: 10px; color: var(--cyan); }
.built-stats { margin-bottom: 6px; }
.built-stats div {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  color: var(--dim);
  padding: 2px 0;
}
.built-stats b { color: #fff; }
.built-ups { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.up-row {
  display: flex;
  align-items: center;
  gap: 7px;
  background: #0b1925;
  border: 1px solid #20404f;
  padding: 4px 6px;
  font-family: inherit;
  color: var(--cream);
  cursor: pointer;
  text-align: left;
}
.up-row:hover { border-color: var(--cyan); }
.up-row .u-name { flex: 0 0 46px; font-size: 9px; color: var(--dim); }
.up-row .u-val { flex: 1; font-size: 9px; }
.up-row .u-cost { font-size: 9px; color: var(--gold); }
.up-row.maxed { opacity: 0.66; cursor: default; }
.up-row.poor { opacity: 0.6; }
.barricade-row { display: flex; justify-content: space-between; font-size: 10px; color: var(--dim); margin-bottom: 6px; }
.barricade-row b { color: #fff; }
.v-name { font-size: 15px; color: var(--violet); margin-bottom: 5px; letter-spacing: 0.5px; text-shadow: 0 0 12px rgba(179, 107, 255, 0.5); }
.v-trade { display: flex; align-items: center; gap: 8px; padding: 7px; background: #0c1226; border: 1px solid #2c2a4c; }
.v-col { flex: 1; font-size: 9px; color: var(--dim); display: flex; flex-direction: column; gap: 3px; }
.v-col span { color: #6d86a0; font-size: 8px; letter-spacing: 0.6px; }
.v-offer-list { list-style: none; margin: 0; padding: 0; }
.v-offer-list li { font-size: 10px; color: var(--gold); }
.v-arrow { color: var(--violet); font-size: 14px; }
.v-ask { font-size: 10px; color: #fff; }
.v-col small { font-size: 8px; color: #54718a; }

/* ---------------- fx / toasts ---------------- */
.fx-float {
  position: absolute;
  transform: translate(-50%, -50%);
  font-size: 12px;
  color: #fff;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.7), 0 0 8px rgba(255, 255, 255, 0.4);
  pointer-events: none;
  white-space: nowrap;
  animation: fxRise 1s ease-out forwards;
}
.fx-float.gold { color: var(--gold); }
.fx-float.ware { color: var(--cyan); }
.fx-float.dmg { color: #ffd9d9; font-size: 10px; }
.fx-float.bad { color: var(--red); }
@keyframes fxRise {
  0% { opacity: 0; transform: translate(-50%, -40%) scale(0.8); }
  20% { opacity: 1; transform: translate(-50%, -70%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -160%) scale(1); }
}
.fx-spark {
  position: absolute;
  width: 6px;
  height: 6px;
  transform: translate(-50%, -50%);
  background: #fff;
  box-shadow: 0 0 10px #46dff0;
  animation: fxSpark 0.42s ease-out forwards;
  pointer-events: none;
}
@keyframes fxSpark { to { opacity: 0; transform: translate(-50%, -50%) scale(0.2); } }

#toasts {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  z-index: 30;
  pointer-events: none;
  width: min(360px, calc(100vw - 420px));
  min-width: 220px;
}

@media (max-width: 900px) {
  #toasts {
    top: 168px;
    left: auto;
    right: 6px;
    width: min(47vw, 200px);
    min-width: 132px;
    align-items: stretch;
  }
}
.toast {
  background: rgba(8, 16, 26, 0.95);
  border: 1px solid #26445a;
  border-left: 3px solid var(--cyan);
  padding: 7px 10px;
  font-size: 10px;
  line-height: 1.4;
  color: var(--cream);
  width: 100%;
  animation: toastIn 0.18s ease-out;
  clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 8px 100%, 0 calc(100% - 8px));
}
.toast b { display: block; font-size: 11px; letter-spacing: 0.4px; margin-bottom: 2px; }
.toast.good { border-left-color: var(--green); }
.toast.good b { color: var(--green); }
.toast.gold { border-left-color: var(--gold); }
.toast.gold b { color: var(--gold); }
.toast.warn { border-left-color: var(--amber); }
.toast.warn b { color: var(--amber); }
.toast.bad { border-left-color: var(--red); }
.toast.bad b { color: var(--red); }
.toast.out { opacity: 0; transition: opacity 0.3s ease; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-6px); } }

/* ---------------- phase transition ---------------- */
.phase-fx {
  position: absolute;
  inset: 0;
  z-index: 40;
  pointer-events: none;
  overflow: hidden;
}
.pf-veil {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 45%, rgba(192, 139, 78, 0.45), rgba(5, 8, 15, 0.96) 62%);
  animation: pfVeil 1.6s ease-in-out forwards;
}
.pf-scan {
  position: absolute;
  inset: -10%;
  background: repeating-linear-gradient(0deg, rgba(70, 223, 240, 0.14) 0 2px, transparent 2px 7px);
  animation: pfScan 1.6s linear forwards;
}
.pf-word {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  animation: pfWord 1.6s ease-in-out forwards;
}
.pf-word b {
  font-size: clamp(28px, 7vw, 64px);
  letter-spacing: 4px;
  color: #fff;
  text-shadow: 0 0 24px rgba(192, 139, 78, 0.75), 0 0 60px rgba(192, 139, 78, 0.5);
}
.pf-word span { font-size: 12px; letter-spacing: 3px; color: var(--cyan); text-transform: uppercase; }
.phase-fx.dawn .pf-veil { background: radial-gradient(circle at 50% 45%, rgba(240, 164, 58, 0.4), rgba(5, 8, 15, 0.9) 62%); }
.phase-fx.dawn .pf-word b { text-shadow: 0 0 24px rgba(240, 164, 58, 0.85); }
@keyframes pfVeil { 0% { opacity: 0; } 22% { opacity: 1; } 70% { opacity: 1; } 100% { opacity: 0; } }
@keyframes pfScan { 0% { transform: translateY(-8%); opacity: 0; } 30% { opacity: 0.8; } 100% { transform: translateY(8%); opacity: 0; } }
@keyframes pfWord {
  0% { opacity: 0; transform: scale(0.94); }
  25% { opacity: 1; transform: scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: scale(1.04); }
}

/* ---------------- coach ---------------- */
.coach {
  position: absolute;
  left: 10px;
  bottom: 160px;
  width: min(340px, calc(100vw - 20px));
  background: var(--panel-2);
  border: 1px solid #2c4a62;
  border-left: 3px solid var(--gold);
  padding: 5px 8px 6px;
  z-index: 32;
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 10px 100%, 0 calc(100% - 10px));
}
.coach-head { display: flex; justify-content: space-between; font-size: 8px; color: var(--dim); margin-bottom: 2px; }
.coach-skip { border: 0; background: transparent; color: #54718a; font-family: inherit; font-size: 9px; cursor: pointer; }
.coach p { margin: 2px 0 5px; font-size: 10px; line-height: 1.4; color: var(--cream); }
.coach-foot { display: flex; justify-content: flex-end; }

/* ---------------- modal ---------------- */
.modal-wrap {
  position: absolute;
  inset: 0;
  z-index: 50;
  background: rgba(3, 6, 11, 0.74);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal { width: min(620px, 100%); max-height: min(86vh, 720px); overflow: auto; }
.modal-body { padding: 10px 14px 14px; }
.lead { margin: 0 0 10px; font-size: 11px; line-height: 1.6; color: #c2d8ea; }
.help-list { margin: 0 0 10px; padding-left: 16px; }
.help-list li { font-size: 10px; line-height: 1.6; color: #a9c4da; margin-bottom: 6px; }
.help-list b { color: var(--cyan); }
.foot { font-size: 9px; color: #54718a; margin: 8px 0 10px; }

/* ---------------- drag ghost ---------------- */
.drag-ghost {
  position: fixed;
  width: 54px;
  height: 54px;
  z-index: 60;
  pointer-events: none;
  background: rgba(9, 22, 32, 0.92);
  border: 1px solid var(--gold);
  box-shadow: 0 0 16px rgba(255, 210, 63, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translate(-50%, -50%);
}
.drag-ghost canvas { width: 34px; height: 34px; image-rendering: pixelated; }

/* ---------------- responsive ---------------- */
@media (max-width: 1180px) {
  #inventoryPanel { width: 252px; }
  #heroPanel { width: 208px; }
  #abilityPanel { width: 156px; }
  #radarPanel { width: 106px; }
  #towerPanel { width: 184px; }
}

@media (max-width: 900px) {
  #topLeft { padding: 6px 9px 8px; min-width: 0; max-width: 60vw; }
  .hud-line { font-size: 10px; }
  .hud-line b { font-size: 11px; }
  .health-bar { min-width: 40px; }
  #towerPanel { top: 168px; width: 158px; }
  .tower-chip .t-name { font-size: 9px; }
  #bottomBar { gap: 6px; left: 6px; right: 6px; bottom: 6px; }
  #inventoryPanel { width: 206px; }
  .inv-slot { height: 62px; }
  .inv-slots { gap: 4px; padding: 5px 5px 3px; }
  .inv-slot canvas { width: 20px; height: 20px; }
  .inv-slot .n { font-size: 8px; letter-spacing: 0; }
  .inv-slot .p { font-size: 7px; }
  #heroPanel { width: 172px; }
  #portrait { width: 52px; height: 52px; flex-basis: 52px; }
  .hero-name { font-size: 13px; }
  .hero-bonus { display: none; }
  #abilityPanel { width: 142px; }
  .ability { height: 30px; }
  #radarPanel { width: 94px; }
  .hint { bottom: 122px; font-size: 9px; }
  .pad-card, .block-card { top: auto; bottom: 128px; right: 6px; width: min(300px, calc(100vw - 12px)); }
  .toasts { top: 8px; }
}

@media (max-width: 720px) {
  #topLeft { max-width: 58vw; }
  #towerPanel {
    top: 162px;
    width: 102px;
    padding-bottom: 4px;
  }
  #towerPanel .panel-head { font-size: 8px; padding: 5px 6px; letter-spacing: 0.4px; }
  .tower-list { gap: 4px; padding: 4px; }
  .tower-chip { gap: 5px; padding: 4px; }
  .tower-chip .t-ico { width: 24px; height: 24px; flex-basis: 24px; }
  .tower-chip .t-ico canvas { width: 19px; height: 19px; }
  .tower-chip .t-name { font-size: 8px; letter-spacing: 0; white-space: normal; }
  .tower-chip .t-cost { font-size: 8px; margin-top: 0; }
  .panel-foot { flex-direction: column; align-items: flex-start; gap: 4px; padding: 4px 5px 0; font-size: 8px; }
  .panel-foot .btn.tiny { font-size: 8px; padding: 4px 5px; }

  #bottomBar { flex-wrap: wrap; align-items: stretch; }
  #inventoryPanel { width: calc(56% - 3px); order: 1; }
  #heroPanel { width: calc(44% - 3px); order: 2; }
  #rightBar { width: 100%; order: 3; margin-left: 0; align-items: stretch; }
  #abilityPanel { flex: 1; width: auto; }
  #radarPanel { width: 86px; flex: 0 0 86px; }
  #abilityPanel .panel-head, #radarPanel .panel-head { font-size: 8px; padding: 5px 6px; }
  .ability-grid { gap: 4px; padding: 4px; }
  .ability { height: 27px; }
  .ability .label { display: none; }
  .inv-slots { padding: 4px; gap: 4px; }
  .inv-slot { height: 52px; }
  .inv-slot canvas { width: 19px; height: 19px; }
  .inv-slot .n { display: none; }
  .inv-slot .ct { font-size: 10px; }
  .inv-slot .p { font-size: 7px; }
  .hero-body { padding: 5px 6px 2px; gap: 6px; }
  #portrait { width: 48px; height: 48px; flex-basis: 48px; }
  .hero-name { font-size: 12px; }
  .hero-gold { font-size: 11px; }
  .hero-label { font-size: 8px; }
  #radar { padding: 2px; }
  .hint { bottom: 242px; padding: 4px 8px; }
  .coach { bottom: 232px; }
  .pad-card, .block-card { bottom: 232px; }
  .toast { font-size: 9px; padding: 5px 8px; }
  .toast b { font-size: 10px; }
}

@media (max-width: 430px) {
  #topLeft { padding: 5px 7px 6px; }
  .hud-line { font-size: 9px; gap: 4px; }
  .hud-line .lbl { font-size: 8px; }
  .hud-line b { font-size: 10px; }
  .wave-line b { font-size: 11px; }
  .phase { font-size: 9px; padding: 0 4px; }
  .top-actions { gap: 5px; }
  .btn.night-btn { font-size: 9px; padding: 6px 7px; }
  .icon-btn { width: 22px; height: 22px; font-size: 11px; }
  #towerPanel { top: 156px; width: 98px; }
  .tower-chip .t-name { font-size: 7.5px; }
  #inventoryPanel { width: calc(54% - 3px); }
  #heroPanel { width: calc(46% - 3px); }
  #radarPanel { width: 74px; flex-basis: 74px; }
  .hint { bottom: 232px; max-width: calc(100vw - 16px); }
  .pad-card, .block-card { bottom: 164px; }
  .visitor-card { width: calc(100vw - 16px); }
}

@media (max-height: 520px) and (orientation: landscape) {
  #towerPanel {
    top: 108px; left: 6px; right: auto; width: 140px;
    max-height: calc(100vh - 212px);
    display: flex; flex-direction: column;
  }
  #towerPanel .panel-head { font-size: 8px; flex: 0 0 auto; }
  #towerList { overflow-y: auto; min-height: 0; scrollbar-width: thin; }
  #towerPanel .panel-foot { flex: 0 0 auto; }
  #bottomBar { bottom: 6px; }
  #topLeft { top: 6px; left: 6px; }
  .hint { display: none; }
  #heroPanel { width: 170px; }
  #inventoryPanel { width: 220px; }
  .inv-slot { height: 52px; }
  #radarPanel { width: 84px; }
  #abilityPanel { width: 132px; }
  .ability { height: 26px; }
  .pad-card, .block-card { top: 8px; bottom: auto; right: 8px; }
  /* the tutorial tip sits over the bottom strip, not the aisles */
  .coach {
    top: 6px; bottom: auto; left: 252px; right: auto; transform: none;
    width: min(420px, calc(100vw - 402px)); padding: 4px 8px 5px;
    display: grid; grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: 'head head' 'text btn';
    align-items: end; column-gap: 8px;
  }
  .coach-head { grid-area: head; margin-bottom: 2px; }
  .coach p { grid-area: text; font-size: 10px; line-height: 1.3; margin: 0; }
  .coach-foot { grid-area: btn; }
  .coach-foot .btn { font-size: 9px; padding: 4px 9px; }
}

@media (orientation: landscape) and (min-width: 721px) {
  /* the tutorial tip parks on the top strip, never across the shop floor */
  .coach {
    top: 8px; bottom: auto; left: auto; right: 10px; transform: none;
    width: min(420px, calc(100vw - 460px)); padding: 4px 8px 5px;
    display: grid; grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: 'head head' 'text btn';
    align-items: end; column-gap: 8px;
  }
  .coach-head { grid-area: head; margin-bottom: 2px; }
  .coach p { grid-area: text; font-size: 10px; line-height: 1.3; margin: 0; }
  .coach-foot { grid-area: btn; }
  .coach-foot .btn { font-size: 9px; padding: 4px 9px; }
}

@media (orientation: landscape), (min-width: 721px) {
  /* Bottom bar: INVENTORY hard left, HERO PORTRAIT truly centred in the
     viewport, ABILITIES + RADAR hard right, exactly as the layout asks. */
  #bottomBar {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: end;
  }
  #inventoryPanel { grid-column: 1; justify-self: start; }
  #heroPanel { grid-column: 2; justify-self: center; }
  #rightBar { grid-column: 3; justify-self: end; margin-left: 0; }
}

@media (max-height: 520px) and (orientation: landscape) {
  /* the tower rail stays on the left; the tip parks top-right, clear of it */
  .coach {
    left: auto; right: 10px; top: 8px; bottom: auto;
    width: min(430px, calc(100vw - 420px)); padding: 4px 8px 5px;
  }
}

/* money pulse */
#goldTxt.pulse { animation: goldPulse 0.5s ease-out; }
@keyframes goldPulse {
  0% { transform: scale(1); }
  40% { transform: scale(1.18); color: #fff; }
  100% { transform: scale(1); }
}

/* ---------------- portrait: a tall phone shows the mall, not the panels -------- */
.hud-row { display: block; }

@media (orientation: portrait) and (max-width: 820px) {
  /* top-left: same information, a third of the height, readable title */
  #topLeft { top: 6px; left: 6px; right: auto; width: auto; padding: 7px 9px 8px; min-width: 0; max-width: calc(100vw - 12px); }
  #gameTitle { font-size: clamp(10.8px, 2.9vw, 14.5px); letter-spacing: 0.1px; margin-bottom: 6px; }
  .hud-row { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; flex-wrap: nowrap; }
  .hud-row.currency-row { flex-direction: row; align-items: center; gap: 12px; }
  .hud-row + .hud-row { margin-top: 2px; }
  .hud-line { font-size: 10px; line-height: 1.35; gap: 5px; }
  .hud-line b { font-size: 11px; }
  .hud-line .lbl { font-size: 8.5px; }
  .health b { font-size: 11px; }
  .health-bar { min-width: 54px; height: 7px; }
  .wave-line { margin: 0; gap: 7px; }
  .wave-line b { font-size: 12px; }
  .phase { font-size: 9px; padding: 0 4px; }
  .currency b { font-size: 12px; }
  .top-actions { margin-top: 6px; gap: 6px; }
  .btn.night-btn { font-size: 12px; padding: 8px 10px; }
  .icon-btn { width: 28px; height: 28px; font-size: 13px; }
  #nightLine { margin-top: 3px; font-size: 9px; gap: 10px; }
  #nightLine b { font-size: 11px; }
  .btn.noble-btn { margin-top: 5px; }

  /* tower selection: the spec's vertical left sidebar. It sits below the
     top-left stats, stays narrow, and starts under the storefront sign so
     the GIGA-MART fascia and both portals stay in view. */
  #towerPanel {
    left: 6px; right: auto; top: 164px; bottom: auto;
    width: 96px; padding-bottom: 0; max-height: 306px;
    display: flex; flex-direction: column; align-items: stretch;
    background: rgba(14, 12, 10, 0.88);
  }
  body.noble-wait #towerPanel { top: 196px; max-height: 300px; }
  #towerPanel .panel-head {
    flex: 0 0 auto; padding: 4px 6px 3px;
    font-size: 8px; letter-spacing: 0.4px;
    border-right: none;
  }
  #towerList {
    display: flex; flex-direction: column; gap: 2px;
    padding: 4px; overflow-y: auto; overflow-x: hidden;
    min-height: 0; flex: 1 1 auto;
    scrollbar-width: thin;
  }
  .tower-chip {
    flex: 0 0 auto; width: 100%; min-width: 0; min-height: 0; padding: 2px 3px;
    gap: 4px; flex-direction: row; align-items: center; justify-content: flex-start;
  }
  .tower-chip .t-ico { width: 19px; height: 19px; flex-basis: 19px; }
  .tower-chip .t-ico canvas { width: 16px; height: 16px; }
  .tower-chip .t-body { flex: 1 1 auto; width: auto; }
  .tower-chip .t-name { font-size: 7.5px; line-height: 1.04; white-space: normal; overflow-wrap: anywhere; text-align: left; }
  .tower-chip .t-cost { font-size: 7.5px; margin-top: 0; text-align: left; }
  .panel-foot {
    flex: 0 0 auto; flex-direction: column; align-items: stretch; justify-content: center;
    gap: 2px; padding: 3px 5px 5px; font-size: 8px;
  }
  .panel-foot .btn.tiny { font-size: 8px; padding: 4px 4px; width: 100%; }

  /* bottom bar: one row. Inventory left, Elara centre, abilities and radar right. */
  #bottomBar { left: 6px; right: 6px; bottom: 6px; gap: 4px; flex-wrap: nowrap; align-items: stretch; }
  #inventoryPanel { width: 34%; order: 1; }
  #heroPanel { width: 30%; order: 2; }
  #rightBar { width: 36%; order: 3; margin-left: 0; flex-direction: row; align-items: stretch; gap: 4px; }
  #abilityPanel { flex: 1; width: auto; }
  #radarPanel { width: 46px; flex: 0 0 46px; }
  #radar { width: 100%; height: auto; padding: 2px; display: block; }
  #abilityPanel .panel-head, #radarPanel .panel-head, #inventoryPanel .panel-head, #heroPanel .panel-head {
    font-size: 8px; padding: 4px 6px; letter-spacing: 0.4px;
  }
  #heroPanel .panel-head { font-size: 9px; }
  .ability-grid { grid-template-columns: 1fr 1fr; gap: 3px; padding: 4px; }
  .ability { height: 24px; }
  .ability .label { display: none; }
  .ability .cost { font-size: 8px; }
  .inv-slots { gap: 3px; padding: 4px 4px 2px; }
  .inv-slot { height: 40px; }
  .inv-slot canvas { width: 16px; height: 16px; }
  .inv-slot .n { display: none; }
  .inv-slot .ct { font-size: 10px; }
  .inv-slot .p { font-size: 7px; }
  .inv-foot { padding: 1px 4px 4px; }
  .inv-foot .btn.tiny { font-size: 8px; padding: 4px 6px; width: 100%; }
  .hero-body { padding: 4px 5px 3px; gap: 5px; align-items: center; }
  #portrait { width: 46px; height: 46px; flex-basis: 46px; }
  .hero-label { font-size: 7px; }
  .hero-name { font-size: 13px; }
  .hero-gold { font-size: 12px; }

  /* cards dock over the build strip, never the middle of the mall */
  .pad-card, .block-card {
        left: 6px; right: 6px; top: auto; bottom: 100px;
    width: auto; max-height: 44vh; overflow: auto;
  }
  .pad-card .card-body, .block-card .card-body { padding: 6px 8px 8px; }
  .build-list { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
  .build-row { padding: 4px 5px; gap: 5px; }
  .build-row .b-ico { width: 20px; height: 20px; flex-basis: 20px; }
  .build-row .b-ico canvas { width: 17px; height: 17px; }
  .build-row .b-name { font-size: 8px; }
  .card-text { font-size: 10px; margin-bottom: 6px; }
  .visitor-card { width: calc(100vw - 16px); max-height: 76vh; overflow: auto; }

  /* the tutorial tip parks on the promenade below the shop, never over the aisles */
  .coach {
    top: auto; bottom: 100px; left: 6px; right: 6px; width: auto; transform: none;
    padding: 5px 8px 6px;
    display: grid; grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: 'head head' 'text btn';
    align-items: end; column-gap: 8px;
  }
  .coach-head { grid-area: head; font-size: 7.5px; margin-bottom: 2px; }
  .coach-skip { font-size: 8px; }
  .coach p { grid-area: text; font-size: 10px; line-height: 1.3; margin: 0; }
  .coach-foot { grid-area: btn; }
  .coach-foot .btn { font-size: 9px; padding: 5px 9px; }
    .hint { left: 6px; right: 6px; bottom: 100px; transform: none; max-width: none; font-size: 9.5px; padding: 5px 8px; }

  /* labels over the floor read at phone size */
  .world-tag { font-size: 9px; padding: 1px 4px; }
  .world-tag.aisle { font-size: 9px; white-space: normal; max-width: 92px; text-align: center; line-height: 1.15; }
  .world-tag.shop { font-size: 8.5px; }
  .world-tag.shop b { font-size: 9px; }
  .world-tag.portal-tag { font-size: 10px; }
}

@media (orientation: portrait) and (max-height: 620px) {
  .hint { display: none; }
}

@media (orientation: portrait) and (max-width: 430px) {
  .world-tag.portal-tag { font-size: 9.5px; padding: 1px 5px; letter-spacing: 0; }
}

@media (orientation: portrait) and (max-width: 370px) {
  #topLeft { padding: 6px 7px 7px; }
  #radarPanel { width: 38px; flex-basis: 38px; }
  #portrait { width: 36px; height: 36px; flex-basis: 36px; }
  .hero-name { font-size: 11px; }
  .hero-gold { font-size: 10px; }
  .tower-chip .t-name { font-size: 7px; }
  .ability { height: 22px; }
  .world-tag.portal-tag { font-size: 9px; padding: 1px 4px; }
}

/* ==================================================================
   REFINED RETAIL THEME
   Graphite console, ivory type, one brass accent. The world is lit
   3D; the interface is matte back-office software, not an arcade.
   ================================================================== */
html, body {
  background: #14161A;
  color: var(--cream);
  font-variant-numeric: tabular-nums;
}
#world { image-rendering: auto; }

.panel, .hud-block {
  background: #23262B;
  border: 1px solid var(--line);
  border-radius: 3px;
  clip-path: none !important;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.42);
}
.panel-head {
  background: #1E2126;
  color: var(--cream);
  border-bottom: 1px solid var(--line);
  font-size: 9.5px;
  letter-spacing: 1.8px;
  padding: 8px 10px 7px;
  font-weight: 700;
}
.panel-x, .icon-btn {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 2px;
  color: var(--dim);
  clip-path: none;
}
.panel-x:hover, .icon-btn:hover { background: #2E3238; color: var(--cream); }

.btn {
  background: #2E3238;
  color: var(--cream);
  border: 1px solid #4A5058;
  border-radius: 2px;
  clip-path: none;
  box-shadow: none;
  letter-spacing: 0.7px;
  font-weight: 700;
}
.btn:hover { background: #373C43; filter: none; }
.btn:active { transform: translateY(1px); }
.btn.tiny { font-size: 9px; padding: 6px 9px; }
.btn.primary, .btn.night-btn {
  background: var(--brass, #C08B4E);
  color: #1B1D21;
  border-color: #C08B4E;
  box-shadow: none;
  text-shadow: none;
  animation: none;
}
.btn.primary:hover, .btn.night-btn:hover { background: #CE9A5C; }
.btn.repair-btn {
  background: transparent;
  border-color: #7A5C36;
  color: var(--amber);
  font-size: 9px;
}
.btn.danger { background: #4A2C2B; border-color: #6E3B39; color: #E7B9B6; }
.btn.noble-btn {
  background: #2E3238;
  border: 1px solid var(--brass, #C08B4E);
  color: var(--cream);
  box-shadow: none;
  animation: none;
}

#topLeft {
  border-left: 1px solid var(--line);
  border-top: 2px solid var(--brass, #C08B4E);
  padding: 10px 12px 11px;
}
#topLeft.overrun { border-top-color: var(--brick); border-left-color: var(--line); }
#gameTitle {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin: 0 0 9px;
  color: var(--cream);
  text-shadow: none;
  font-weight: 900;
  white-space: normal;
}
#gameTitle .t-main {
  font-size: clamp(15px, 3.6vw, 20px);
  line-height: 0.98;
  letter-spacing: -0.35px;
}
#gameTitle .t-sub {
  font-size: clamp(7.5px, 1.65vw, 9.5px);
  line-height: 1.1;
  letter-spacing: 2.2px;
  color: var(--brass, #C08B4E);
  font-weight: 700;
}
.hud-line { color: var(--cream); font-variant-numeric: tabular-nums; }
.hud-line .lbl { color: var(--dim); letter-spacing: 0.9px; }
.health b { color: var(--cream); }
.health-bar {
  background: #2A2D33;
  border: 1px solid #3A3F46;
  height: 6px;
  border-radius: 1px;
}
.health-bar i {
  background: var(--brick);
  box-shadow: none;
  transition: width 0.25s ease;
}
.wave-line b { color: var(--cream); }
.phase { border-radius: 1px; letter-spacing: 1.4px; padding: 1px 5px; }
.phase.day { color: var(--amber); text-shadow: none; }
.phase.night { color: #AFC3D6; text-shadow: none; }
#goldTxt { color: var(--brass, #C08B4E); text-shadow: none; }
#gemsTxt { color: #9FB4C4; text-shadow: none; }
.night-line b { color: var(--brick); }
.top-actions .night-btn { flex: 1; }
.icon-btn { color: var(--dim); }

/* left column */
#towerPanel { border-radius: 3px; }
.tower-chip {
  background: #1E2126;
  border: 1px solid var(--line);
  border-left: 2px solid transparent;
  border-radius: 2px;
  clip-path: none;
  box-shadow: none;
}
.tower-chip:hover { background: #2A2D33; border-color: #4A5058; border-left-color: var(--brass, #C08B4E); }
.tower-chip.chosen {
  background: #2A2D33;
  border-color: #4A5058;
  border-left-color: var(--brass, #C08B4E);
  box-shadow: none;
}
.tower-chip .t-ico {
  background: #191B1F;
  border: 1px solid #33383F;
  border-radius: 2px;
}
.tower-chip .t-name { font-weight: 700; letter-spacing: 0.1px; }
.tower-chip .t-cost { color: var(--brass, #C08B4E); }
.tower-chip .t-cost.poor { color: var(--brick); }
.panel-foot { color: var(--dim); border-top-color: var(--line); }

/* inventory, hero, abilities, radar */
.inv-slot {
  background: #191B1F;
  border: 1px solid #33383F;
  border-radius: 2px;
}
.inv-slot.has { border-color: #4A5058; border-top: 2px solid var(--brass, #C08B4E); box-shadow: none; }
.inv-slot .ct { color: var(--cream); }
.inv-slot .p { color: var(--brass, #C08B4E); }
.inv-slot .n { color: var(--dim); }
#portrait { border: 1px solid #4A5058; border-radius: 2px; background: #191B1F; }
.hero-name { color: var(--cream); text-shadow: none; letter-spacing: 0.2px; font-weight: 700; }
.hero-gold { color: var(--brass, #C08B4E); text-shadow: none; }
.hero-label { color: var(--dim); }
.ability {
  background: #191B1F;
  border: 1px solid #33383F;
  border-radius: 2px;
}
.ability.ready { border-color: #4A5058; border-top: 1px solid var(--brass, #C08B4E); box-shadow: none; }
.ability:not(:disabled):hover { border-color: var(--brass, #C08B4E); }
.ability .cost { color: var(--dim); }
.ability .cd { background: rgba(25, 27, 31, 0.8); color: var(--cream); }
.ability .label { color: var(--dim); }
#radarPanel #radar { background: transparent; border-radius: 50%; }

/* world labels: engraved retail plates, not neon */
.world-tag, .world-tag.aisle, .world-tag.shop, .world-tag.portal-tag, .world-tag.brand {
  background: rgba(30, 33, 38, 0.94);
  border: 1px solid #4A5058;
  border-radius: 1px;
  color: var(--cream);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  text-shadow: none;
  font-weight: 700;
  letter-spacing: 0.6px;
}
.world-tag.aisle { color: var(--cream); border-left: 2px solid var(--brass, #C08B4E); }
.world-tag.brand { color: var(--cream); border-left: 2px solid var(--brass, #C08B4E); }
.world-tag.portal-tag { color: var(--cream); border-left: 2px solid #6E5A76; }
.world-tag.shop {
  color: var(--brass, #C08B4E);
  border-color: #4A5058;
  border-left: 2px solid var(--brass, #C08B4E);
}
.world-tag.shop:hover { background: #2A2D33; }
.world-tag.shop b { color: var(--cream); }

/* transient feedback */
.fx-float { text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55); }
.fx-float.gold { color: var(--brass, #C08B4E); }
.fx-float.ware { color: var(--mint); }
.fx-float.bad { color: #D98A85; }
.fx-spark { background: var(--brass, #C08B4E); box-shadow: none; }
#toasts { width: min(340px, calc(100vw - 420px)); }
.toast {
  background: #23262B;
  border: 1px solid var(--line);
  border-left: 2px solid var(--brass, #C08B4E);
  border-radius: 2px;
  clip-path: none;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.38);
  color: var(--cream);
}
.toast b { color: var(--cream); }
.toast.good { border-left-color: var(--mint); }
.toast.good b { color: var(--mint); }
.toast.gold { border-left-color: var(--brass, #C08B4E); }
.toast.gold b { color: var(--brass, #C08B4E); }
.toast.warn { border-left-color: var(--amber); }
.toast.warn b { color: var(--amber); }
.toast.bad { border-left-color: var(--brick); }
.toast.bad b { color: var(--brick); }

/* hint, cards, coach, modal */
.hint {
  background: #1E2126;
  border: 1px solid var(--line);
  border-left: 2px solid var(--brass, #C08B4E);
  border-radius: 2px;
  clip-path: none;
  color: var(--cream);
}
.hint b { color: var(--brass, #C08B4E); }
.hint-x { color: var(--dim); }
.card { border-radius: 3px; }
.visitor-card { border-color: var(--line); }
.visitor-card .panel-head { color: var(--cream); background: #1E2126; border-bottom-color: var(--line); }
.card-text { color: #C9C2B6; }
.build-row, .up-row {
  background: #191B1F;
  border: 1px solid #33383F;
  border-radius: 2px;
}
.build-row:hover, .up-row:hover { border-color: var(--brass, #C08B4E); }
.build-row .b-cost, .up-row .u-cost { color: var(--brass, #C08B4E); }
.built-head span { color: var(--cream); }
.built-head b { color: var(--brass, #C08B4E); }
.v-name { color: var(--cream); text-shadow: none; font-weight: 700; }
.v-trade { background: #191B1F; border-color: var(--line); }
.v-arrow { color: var(--brass, #C08B4E); }
.v-offer-list li { color: var(--brass, #C08B4E); }
.v-col span { color: var(--dim); }
.coach {
  background: #23262B;
  border: 1px solid var(--line);
  border-left: 2px solid var(--brass, #C08B4E);
  border-radius: 2px;
  clip-path: none;
}
.coach-skip { color: var(--dim); }
.modal-wrap { background: rgba(12, 14, 17, 0.78); }
.lead, .help-list li { color: #C9C2B6; }
.help-list b { color: var(--brass, #C08B4E); }
.foot { color: var(--dim); }
.drag-ghost {
  background: #23262B;
  border: 1px solid var(--brass, #C08B4E);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.4);
  border-radius: 2px;
}
.pf-veil { background: radial-gradient(circle at 50% 45%, rgba(24, 26, 30, 0.9), rgba(12, 14, 17, 0.97) 62%); }
.pf-scan { background: none; }
.pf-word b { text-shadow: none; letter-spacing: 6px; font-weight: 800; }
.pf-word span { color: var(--brass, #C08B4E); }
.phase-fx.dawn .pf-veil { background: radial-gradient(circle at 50% 45%, rgba(40, 36, 28, 0.9), rgba(12, 14, 17, 0.97) 62%); }
.phase-fx.dawn .pf-word b { text-shadow: none; }

/* icons are drawn small; let the browser smooth them into place */
.ico canvas, .t-ico canvas, .inv-slot canvas, .ability canvas,
.build-row .b-ico canvas, .drag-ghost canvas, #portrait {
  image-rendering: auto;
}

/* residual refinement: boot card, quiet secondary type */
#boot { background: #14161A; }
.boot-card {
  background: #23262B;
  border: 1px solid var(--line);
  border-radius: 3px;
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.45);
}
.boot-card b { color: var(--cream); text-shadow: none; letter-spacing: 2px; }
.boot-card span { color: var(--dim); }
.v-col small, .foot, .coach-skip, .hint-x { color: var(--dim); }
canvas { image-rendering: auto !important; }

/* Short landscape: keep the console compact and the stats clear of the
   tower rail, so TOWER SELECTION stays on the left without covering
   health, gold or START NIGHT. */
@media (max-height: 520px) and (orientation: landscape) {
  #topLeft { padding: 5px 8px 6px; }
  #gameTitle { flex-direction: row; flex-wrap: wrap; align-items: baseline; gap: 4px; margin-bottom: 3px; }
  #gameTitle .t-main { font-size: 13px; letter-spacing: -0.2px; }
  #gameTitle .t-sub { font-size: 6.5px; letter-spacing: 1.1px; }
  .hud-line { font-size: 9px; line-height: 1.35; gap: 5px; }
  .wave-line { margin: 1px 0; }
  .phase { font-size: 9px; padding: 0 4px; }
  .night-line { font-size: 8px; margin-top: 1px; }
  .top-actions { margin-top: 3px; gap: 5px; }
  .top-actions .night-btn { padding: 5px 8px; font-size: 10px; }
  .icon-btn { width: 20px; height: 20px; font-size: 10px; }
  #towerPanel {
    top: 108px; left: 6px; right: auto; width: 136px;
    max-height: calc(100vh - 154px);
    display: flex; flex-direction: column;
  }
  #towerPanel .panel-head { font-size: 8px; padding: 3px 5px 2px; flex: 0 0 auto; }
  #towerList { overflow: visible; min-height: 0; gap: 2px; padding: 3px; }
  #towerPanel .tower-chip { padding: 1px 3px; gap: 4px; min-height: 0; }
  #towerPanel .t-ico { width: 18px; height: 18px; flex-basis: 18px; }
  #towerPanel .t-ico canvas { width: 15px; height: 15px; }
  #towerPanel .t-name { font-size: 8px; line-height: 1.05; }
  #towerPanel .t-cost { font-size: 7px; margin-top: 0; }
  #towerPanel .panel-foot {
    flex: 0 0 auto; flex-direction: row; align-items: center; justify-content: space-between;
    padding: 2px 4px 3px; gap: 4px; font-size: 7.5px;
  }
  #towerPanel .panel-foot .btn.tiny { width: auto; font-size: 7.5px; padding: 3px 4px; }
  .inv-slot { height: 60px; }
  .inv-slot canvas { width: 18px; height: 18px; }
  .inv-slot .n { display: block; font-size: 10px; line-height: 1.05; letter-spacing: 0.2px; white-space: nowrap; }
  .inv-slot .ct { font-size: 9.5px; }
  .inv-slot .p { font-size: 7px; }
  #toasts {
    top: 104px; left: 146px; right: auto; align-items: flex-start;
    width: min(240px, calc(100vw - 400px));
  }
}
@media (max-width: 430px) {
  #towerPanel .panel-head { letter-spacing: 0.6px; font-size: 8.5px; }
}

/* ------------------------------------------------------------------
   First-person opening, title screen, and the hand-over to the store
   ------------------------------------------------------------------ */

#cinema {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: transparent;
  overflow: hidden;
  transition: opacity 0.9s ease;
  touch-action: none;
}
#cinema.done { opacity: 0; pointer-events: none; }
#cinemaVeil {
  position: absolute;
  inset: 0;
  background: #050608;
  opacity: 1;
  transition: opacity 2.1s ease;
}
#cinema.awake #cinemaVeil { opacity: 0.08; }
#cinema.blackout #cinemaVeil { opacity: 1; transition: opacity 0.9s ease; }
#cinemaVignette {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 50% 46%, rgba(0, 0, 0, 0) 38%, rgba(0, 0, 0, 0.55) 78%, rgba(0, 0, 0, 0.82) 100%);
  opacity: 0;
  transition: opacity 1.8s ease;
}
#cinema.lit #cinemaVignette { opacity: 1; }
#cinemaHint {
  position: absolute;
  left: 50%;
  bottom: clamp(52px, 12vh, 110px);
  transform: translateX(-50%);
  margin: 0;
  font-size: 10px;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: rgba(239, 233, 222, 0.45);
  opacity: 0;
  transition: opacity 1.2s ease;
  white-space: nowrap;
}
#cinema.lit #cinemaHint { opacity: 1; }
#cinemaShout {
  position: absolute;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%) scale(1.06);
  margin: 0;
  font-family: 'Nunito', 'Segoe UI', system-ui, sans-serif;
  font-weight: 300;
  font-style: italic;
  font-size: clamp(42px, 9vw, 96px);
  letter-spacing: 0.02em;
  color: #F3EDE2;
  text-shadow: 0 0 26px rgba(155, 77, 255, 0.55), 0 2px 10px rgba(0, 0, 0, 0.8);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.5s cubic-bezier(0.2, 0.9, 0.25, 1);
}
#cinemaShout.on {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}
#cinemaSkip {
  position: absolute;
  right: clamp(14px, 3vw, 28px);
  bottom: clamp(14px, 3vw, 26px);
  padding: 8px 13px;
  font-family: inherit;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.24em;
  color: rgba(239, 233, 222, 0.62);
  background: rgba(20, 22, 26, 0.5);
  border: 1px solid rgba(239, 233, 222, 0.2);
  border-radius: 2px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.8s ease, color 0.2s ease, border-color 0.2s ease;
}
#cinema.lit #cinemaSkip,
#cinema.awake #cinemaSkip { opacity: 1; }
#cinemaSkip:hover { color: #EFE9DE; border-color: rgba(192, 139, 78, 0.75); }

#world { transition: filter 0.9s ease, transform 0.9s ease; }
#world.title-blur {
  filter: blur(9px) brightness(0.62) saturate(0.9);
  transform: scale(1.035);
}

body.pre-game #hud,
body.pre-game #tags,
body.pre-game #tags *,
body.pre-game #fx,
body.pre-game #fx *,
body.pre-game #toasts,
body.pre-game #modal,
body.pre-game .modal-wrap,
body.pre-game #coach,
body.pre-game #hint,
body.pre-game #phaseFx {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

#titleScreen {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 1s ease;
  touch-action: none;
  background: #0b0d10 url("../img/title-backdrop.jpg") center / cover no-repeat;
}
#titleScreen.show { opacity: 1; }
#titleScreen.out { opacity: 0; pointer-events: none; }
#titleScreen .title-wash {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 50% 48%, rgba(14, 16, 19, 0.08) 22%, rgba(10, 12, 15, 0.58) 70%, rgba(6, 7, 9, 0.86) 100%);
}
.title-card {
  position: relative;
  text-align: center;
  width: min(92vw, 780px);
  padding: clamp(18px, 4vw, 36px) clamp(14px, 4vw, 34px);
  transform: translateY(10px);
  transition: transform 1.1s cubic-bezier(0.2, 0.8, 0.2, 1);
}
#titleScreen.show .title-card { transform: translateY(0); }
.title-kicker {
  margin: 0 0 14px;
  font-size: clamp(9px, 1.4vw, 11px);
  font-weight: 800;
  letter-spacing: 0.58em;
  text-indent: 0.58em;
  color: #C08B4E;
  text-transform: uppercase;
}
.title-name {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  color: #EFE9DE;
  font-weight: 900;
  line-height: 0.94;
}
.title-name .tn-main {
  font-size: clamp(34px, 8.2vw, 86px);
  letter-spacing: -0.045em;
  text-shadow: 0 2px 22px rgba(0, 0, 0, 0.55);
}
.title-name .tn-sub {
  font-size: clamp(10px, 1.75vw, 15px);
  font-weight: 700;
  letter-spacing: clamp(2.2px, 0.62vw, 6px);
  text-indent: clamp(2.2px, 0.62vw, 6px);
  color: #C08B4E;
}
.title-line {
  margin: clamp(18px, 3.4vw, 30px) auto 0;
  max-width: 44ch;
  font-size: clamp(11px, 1.6vw, 13px);
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.5;
  color: rgba(239, 233, 222, 0.72);
}
#openDoorsBtn {
  margin-top: clamp(22px, 4vw, 36px);
  padding: clamp(13px, 2.2vw, 17px) clamp(26px, 5vw, 48px);
  font-family: inherit;
  font-size: clamp(11px, 1.5vw, 13px);
  font-weight: 800;
  letter-spacing: 0.2em;
  text-indent: 0.2em;
  color: #17191D;
  background: #C08B4E;
  border: 1px solid #D8A66A;
  border-radius: 2px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.42);
  cursor: pointer;
  transition: background 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}
#openDoorsBtn:hover { background: #D29A58; box-shadow: 0 12px 34px rgba(0, 0, 0, 0.5); }
#openDoorsBtn:active { transform: translateY(1px); }
#openDoorsBtn:focus-visible { outline: 2px solid #EFE9DE; outline-offset: 3px; }
.title-foot {
  margin: clamp(20px, 3.6vw, 32px) 0 0;
  font-size: clamp(8px, 1.1vw, 10px);
  font-weight: 700;
  letter-spacing: 0.26em;
  color: rgba(239, 233, 222, 0.42);
}
@media (max-height: 520px) {
  .title-card { padding: 6px 16px; }
  .title-kicker { margin-bottom: 6px; }
  .title-name .tn-main { font-size: clamp(30px, 7vw, 54px); }
  .title-line { margin-top: 10px; }
  #openDoorsBtn { margin-top: 14px; padding: 10px 26px; }
  .title-foot { display: none; }
}

/* ------------------------------------------------------------------
   Embossed, larger action controls: placing a tower, opening the night,
   and applying a shelf upgrade. Raised surfaces with a hard top light,
   a deep bottom edge and a real drop shadow; pressing them sinks them.
   ------------------------------------------------------------------ */

.tower-chip {
  min-height: 52px;
  padding: 8px 9px;
  gap: 9px;
  border: 1px solid #4C525A;
  border-left: 3px solid transparent;
  border-radius: 3px;
  background: linear-gradient(180deg, #353A42 0%, #272B31 46%, #1C1F24 100%);
  box-shadow:
    inset 0 1px 0 rgba(239, 233, 222, 0.17),
    inset 0 -2px 0 rgba(0, 0, 0, 0.55),
    0 3px 0 #101215,
    0 7px 14px rgba(0, 0, 0, 0.38);
  transform: translateY(-1px);
  transition: transform 0.1s ease, box-shadow 0.1s ease, background 0.15s ease, border-color 0.15s ease;
}
.tower-chip:hover {
  border-color: #626A74;
  border-left-color: #C08B4E;
  background: linear-gradient(180deg, #3D434C 0%, #2D3239 46%, #20242A 100%);
  box-shadow:
    inset 0 1px 0 rgba(239, 233, 222, 0.22),
    inset 0 -2px 0 rgba(0, 0, 0, 0.55),
    0 4px 0 #101215,
    0 9px 18px rgba(0, 0, 0, 0.42);
  transform: translateY(-2px);
}
.tower-chip.chosen {
  border-color: #C08B4E;
  border-left-color: #C08B4E;
  background: linear-gradient(180deg, #3B3428 0%, #2C2720 55%, #211D18 100%);
  box-shadow:
    inset 0 2px 5px rgba(0, 0, 0, 0.62),
    inset 0 0 0 1px rgba(192, 139, 78, 0.4),
    0 1px 0 #101215;
  transform: translateY(1px);
}
.tower-chip:active {
  transform: translateY(2px);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.65), 0 1px 0 #101215;
}
.tower-chip .t-ico {
  width: 32px;
  height: 32px;
  flex-basis: 32px;
  border-radius: 3px;
  background: linear-gradient(180deg, #23262B, #14161A);
  box-shadow: inset 0 1px 0 rgba(239, 233, 222, 0.1), 0 1px 2px rgba(0, 0, 0, 0.5);
}
.tower-chip .t-ico canvas { width: 26px; height: 26px; }
.tower-chip .t-name { font-size: 12px; font-weight: 800; letter-spacing: 0.1px; }
.tower-chip .t-cost { font-size: 10.5px; font-weight: 800; margin-top: 2px; }

/* START NIGHT: the biggest brass key on the console */
.btn.night-btn,
#startNightBtn {
  min-height: 42px;
  padding: 11px 17px;
  font-size: clamp(11.5px, 1.35vw, 14px);
  font-weight: 900;
  letter-spacing: 0.12em;
  color: #1A1712;
  background: linear-gradient(180deg, #DCA765 0%, #C08B4E 52%, #92602C 100%);
  border: 1px solid #E2B57C;
  border-radius: 3px;
  clip-path: none;
  text-shadow: 0 1px 0 rgba(255, 240, 210, 0.4);
  box-shadow:
    inset 0 1px 0 rgba(255, 247, 228, 0.65),
    inset 0 -3px 0 rgba(82, 47, 14, 0.5),
    0 3px 0 #4B2E12,
    0 7px 16px rgba(0, 0, 0, 0.45);
  transform: translateY(-1px);
  transition: transform 0.1s ease, box-shadow 0.1s ease, filter 0.15s ease;
}
.btn.night-btn:hover,
#startNightBtn:hover { filter: brightness(1.07); transform: translateY(-2px); }
.btn.night-btn:active,
#startNightBtn:active {
  transform: translateY(2px);
  box-shadow: inset 0 3px 7px rgba(60, 32, 8, 0.55), 0 1px 0 #4B2E12;
}
#startNightBtn:disabled {
  filter: grayscale(0.55) brightness(0.8);
  opacity: 0.62;
  transform: none;
  box-shadow: inset 0 1px 0 rgba(255, 247, 228, 0.3), 0 1px 0 #3A2A1C;
}

/* Build rows in a plot card: the same raised treatment, one per shelf */
.build-row {
  min-height: 50px;
  padding: 8px 10px;
  gap: 10px;
  border: 1px solid #4C525A;
  border-radius: 3px;
  background: linear-gradient(180deg, #353A42 0%, #272B31 46%, #1C1F24 100%);
  box-shadow:
    inset 0 1px 0 rgba(239, 233, 222, 0.17),
    inset 0 -2px 0 rgba(0, 0, 0, 0.55),
    0 3px 0 #101215,
    0 6px 12px rgba(0, 0, 0, 0.34);
  transform: translateY(-1px);
  transition: transform 0.1s ease, box-shadow 0.1s ease, border-color 0.15s ease;
  clip-path: none;
}
.build-row:hover {
  border-color: #C08B4E;
  transform: translateY(-2px);
  box-shadow:
    inset 0 1px 0 rgba(239, 233, 222, 0.22),
    inset 0 -2px 0 rgba(0, 0, 0, 0.55),
    0 4px 0 #101215,
    0 8px 15px rgba(0, 0, 0, 0.4);
}
.build-row:active { transform: translateY(2px); box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.65); }
.build-row .b-ico { width: 32px; height: 32px; flex-basis: 32px; }
.build-row .b-ico canvas { width: 26px; height: 26px; }
.build-row .b-name { font-size: 11.5px; font-weight: 800; }
.build-row .b-cost { font-size: 12px; font-weight: 900; }
.build-row.poor { opacity: 0.72; }

/* Upgrade rows: unmistakably buttons, with the brass price on the right */
.up-row {
  min-height: 48px;
  padding: 8px 10px;
  gap: 8px;
  border: 1px solid #4C525A;
  border-radius: 3px;
  background: linear-gradient(180deg, #353A42 0%, #272B31 46%, #1C1F24 100%);
  box-shadow:
    inset 0 1px 0 rgba(239, 233, 222, 0.17),
    inset 0 -2px 0 rgba(0, 0, 0, 0.55),
    0 3px 0 #101215,
    0 6px 12px rgba(0, 0, 0, 0.34);
  transform: translateY(-1px);
  transition: transform 0.1s ease, box-shadow 0.1s ease, border-color 0.15s ease;
}
.up-row:hover {
  border-color: #C08B4E;
  transform: translateY(-2px);
  box-shadow:
    inset 0 1px 0 rgba(239, 233, 222, 0.22),
    inset 0 -2px 0 rgba(0, 0, 0, 0.55),
    0 4px 0 #101215,
    0 8px 15px rgba(0, 0, 0, 0.4);
}
.up-row:active { transform: translateY(2px); box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.65); }
.up-row .u-name { flex: 0 0 54px; font-size: 10.5px; font-weight: 800; letter-spacing: 0.4px; color: #C9C2B6; }
.up-row .u-val { font-size: 10.5px; font-weight: 700; }
.up-row .u-cost { font-size: 12px; font-weight: 900; color: #C08B4E; }
.up-row.maxed { opacity: 0.6; transform: none; box-shadow: inset 0 1px 0 rgba(239, 233, 222, 0.08), 0 1px 0 #101215; }
.up-row.poor { opacity: 0.74; }
.pad-card .card-body { max-height: min(58vh, 460px); overflow-y: auto; scrollbar-width: thin; }

@media (max-width: 430px) {
  .tower-chip { min-height: 40px; padding: 4px 4px; gap: 4px; }
  .tower-chip .t-ico { width: 24px; height: 24px; flex-basis: 24px; }
  .tower-chip .t-ico canvas { width: 20px; height: 20px; }
  .tower-chip .t-name { font-size: 9.5px; line-height: 1.05; }
  .tower-chip .t-cost { font-size: 8.5px; }
  .btn.night-btn, #startNightBtn { min-height: 36px; padding: 8px 10px; font-size: 11px; letter-spacing: 0.06em; }
  .build-row { min-height: 44px; padding: 6px 7px; }
  .build-row .b-name, .build-row .b-cost { font-size: 10.5px; }
  .up-row { min-height: 42px; padding: 6px 7px; }
  .up-row .u-name { flex-basis: 46px; font-size: 9.5px; }
  .up-row .u-val { font-size: 9.5px; }
  .up-row .u-cost { font-size: 11px; }
}

@media (max-height: 520px) and (orientation: landscape) {
  .tower-chip { min-height: 36px; padding: 3px 5px; gap: 5px; }
  .tower-chip .t-ico { width: 22px; height: 22px; flex-basis: 22px; }
  .tower-chip .t-ico canvas { width: 18px; height: 18px; }
  .tower-chip .t-name { font-size: 9px; }
  .tower-chip .t-cost { font-size: 8px; }
  .btn.night-btn, #startNightBtn { min-height: 34px; padding: 7px 10px; font-size: 10.5px; letter-spacing: 0.06em; }
  .build-row { min-height: 40px; padding: 5px 7px; }
  .up-row { min-height: 38px; padding: 5px 7px; }
}

/* The earlier compact-phone rules scope their chip sizes to #towerPanel,
   so the raised sizes need the same reach to win on every screen. */
#towerPanel .tower-chip {
  min-height: 52px;
  padding: 8px 9px;
  gap: 9px;
  border-radius: 3px;
  border: 1px solid #4C525A;
  border-left: 3px solid transparent;
  background: linear-gradient(180deg, #353A42 0%, #272B31 46%, #1C1F24 100%);
  box-shadow:
    inset 0 1px 0 rgba(239, 233, 222, 0.17),
    inset 0 -2px 0 rgba(0, 0, 0, 0.55),
    0 3px 0 #101215,
    0 7px 14px rgba(0, 0, 0, 0.38);
  transform: translateY(-1px);
}
#towerPanel .tower-chip:hover {
  border-color: #626A74;
  border-left-color: #C08B4E;
  transform: translateY(-2px);
}
#towerPanel .tower-chip.chosen {
  border-color: #C08B4E;
  border-left-color: #C08B4E;
  background: linear-gradient(180deg, #3B3428 0%, #2C2720 55%, #211D18 100%);
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.62), inset 0 0 0 1px rgba(192, 139, 78, 0.4), 0 1px 0 #101215;
  transform: translateY(1px);
}
#towerPanel .tower-chip:active { transform: translateY(2px); }
#towerPanel .tower-chip .t-ico { width: 32px; height: 32px; flex-basis: 32px; }
#towerPanel .tower-chip .t-ico canvas { width: 26px; height: 26px; }
#towerPanel .tower-chip .t-name { font-size: 12px; font-weight: 800; line-height: 1.1; }
#towerPanel .tower-chip .t-cost { font-size: 10.5px; font-weight: 800; margin-top: 2px; }
#towerPanel .tower-chip.poor { opacity: 0.72; }

@media (max-width: 430px) {
  #towerPanel .tower-chip { min-height: 40px; padding: 4px 4px; gap: 4px; }
  #towerPanel .tower-chip .t-ico { width: 24px; height: 24px; flex-basis: 24px; }
  #towerPanel .tower-chip .t-ico canvas { width: 20px; height: 20px; }
  #towerPanel .tower-chip .t-name { font-size: 9.5px; line-height: 1.05; }
  #towerPanel .tower-chip .t-cost { font-size: 8.5px; }
}

@media (max-height: 520px) and (orientation: landscape) {
  #towerList { overflow-y: auto; }
  #towerPanel .tower-chip { min-height: 32px; padding: 2px 5px; gap: 5px; }
  #towerPanel .tower-chip .t-ico { width: 21px; height: 21px; flex-basis: 21px; }
  #towerPanel .tower-chip .t-ico canvas { width: 17px; height: 17px; }
  #towerPanel .tower-chip .t-name { font-size: 9px; }
  #towerPanel .tower-chip .t-cost { font-size: 8px; }
}

/* Short landscape: a 119 px gap sits between the stats block and the bottom
   console. A vertical rail with six raised keys does not fit there, so the
   tower rail runs horizontally in that gap, above the inventory. The keys
   stay large enough to hit with a thumb and never cover the bottom panels. */
@media (max-height: 520px) and (orientation: landscape) {
  #towerPanel {
    top: auto;
    bottom: 138px;
    left: 6px;
    right: 6px;
    width: auto;
    height: 74px;
    max-height: none;
    padding-bottom: 0;
    display: flex;
    flex-direction: column;
  }
  #towerPanel .panel-head { display: none; }
  #towerList {
    display: flex;
    flex-direction: row;
    gap: 4px;
    padding: 4px;
    height: 54px;
    min-height: 0;
    overflow-x: auto;
    overflow-y: hidden;
    align-items: stretch;
  }
  #towerPanel .tower-chip {
    flex: 1 1 0;
    width: auto;
    min-width: 84px;
    min-height: 46px;
    padding: 3px 4px;
    gap: 4px;
    border-left-width: 1px;
    border-top: 2px solid transparent;
  }
  #towerPanel .tower-chip.chosen { border-top-color: #C08B4E; border-left-color: #C08B4E; }
  #towerPanel .tower-chip .t-ico { width: 22px; height: 22px; flex-basis: 22px; }
  #towerPanel .tower-chip .t-ico canvas { width: 18px; height: 18px; }
  #towerPanel .tower-chip .t-name { font-size: 8.5px; line-height: 1.05; }
  #towerPanel .tower-chip .t-cost { font-size: 7.5px; margin-top: 0; }
  #towerPanel .panel-foot {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 1px 5px 2px;
    gap: 4px;
    font-size: 8px;
    height: 20px;
    border-top: none;
  }
  #towerPanel .panel-foot .btn.tiny { width: auto; font-size: 8px; padding: 2px 6px; }
}

@media (orientation: portrait) and (max-width: 820px) {
  #towerPanel { max-height: calc(100vh - 280px); }
  #towerList { overflow-y: auto; }
}

/* Lit product shots in the tower console, so a card is an object on a plate,
   not a flat glyph on a rectangle. */
.tower-thumb, .b-ico .tower-thumb, .drag-ghost .tower-thumb {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  pointer-events: none;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.45));
}
#towerPanel .tower-chip .t-ico,
.build-row .b-ico {
  position: relative;
  overflow: hidden;
}
#towerPanel .tower-chip .t-ico::after,
.build-row .b-ico::after {
  content: "";
  position: absolute;
  inset: 0;
  box-shadow: inset 0 1px 0 rgba(239, 233, 222, 0.13), inset 0 -2px 4px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}
#towerPanel .tower-chip {
  background: linear-gradient(180deg, #333840 0%, #292D33 47%, #202329 100%);
  border-color: #505761;
  box-shadow:
    inset 0 1px 0 rgba(239, 233, 222, 0.22),
    inset 0 -2px 0 rgba(0, 0, 0, 0.62),
    0 3px 0 #0D0F12,
    0 7px 15px rgba(0, 0, 0, 0.42);
}
#towerPanel .tower-chip .t-ico {
  background: radial-gradient(circle at 50% 40%, #1E2228, #101215 78%);
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.65), inset 0 0 0 1px rgba(192, 139, 78, 0.18);
  border-color: #424952;
}

/* Short landscape keeps the spec's left tower sidebar and moves the bottom
   console to its right, so the two never cover each other. */
@media (max-height: 520px) and (orientation: landscape) {
  #towerPanel {
    top: 150px;
    bottom: 6px;
    left: 6px;
    right: auto;
    width: 142px;
    height: auto;
    max-height: none;
    padding-bottom: 0;
    display: flex;
    flex-direction: column;
  }
  #towerPanel .panel-head {
    display: flex;
    flex: 0 0 auto;
    padding: 4px 6px 3px;
    font-size: 8px;
    letter-spacing: 0.4px;
  }
  #towerList {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    height: auto;
    min-height: 0;
    gap: 2px;
    padding: 3px;
    overflow-x: hidden;
    overflow-y: auto;
    align-items: stretch;
  }
  #towerPanel .tower-chip {
    flex: 0 0 auto;
    width: 100%;
    min-width: 0;
    min-height: 28px;
    padding: 2px 4px;
    gap: 4px;
    border-left-width: 2px;
    border-top-width: 1px;
  }
  #towerPanel .tower-chip.chosen { border-left-color: #C08B4E; border-top-color: transparent; }
  #towerPanel .tower-chip .t-ico { width: 20px; height: 20px; flex-basis: 20px; }
  #towerPanel .tower-chip .t-ico canvas,
  #towerPanel .tower-chip .t-ico img { width: 17px; height: 17px; }
  #towerPanel .tower-chip .t-name { font-size: 8px; line-height: 1.03; }
  #towerPanel .tower-chip .t-cost { font-size: 7.5px; margin-top: 0; }
  #towerPanel .panel-foot {
    display: flex;
    flex-direction: row;
    flex: 0 0 auto;
    height: auto;
    padding: 2px 4px 3px;
    gap: 4px;
    font-size: 7.5px;
    border-top: 1px solid var(--line);
  }
  #towerPanel .panel-foot .btn.tiny { width: auto; font-size: 7.5px; padding: 2px 4px; }
  #bottomBar {
    left: 152px;
    right: 6px;
  }
}

/* Cashier crystal charge and the night boss status, inside the stats console */
.crystal-line { margin-top: 2px; }
.crystal-line b { color: #7FD8B5; }
.crystal-bar {
  width: 62px;
  height: 6px;
  min-width: 40px;
  background: #222B2B;
  border: 1px solid #3A4746;
  border-radius: 1px;
  overflow: hidden;
}
.crystal-bar i {
  display: block;
  height: 100%;
  width: 100%;
  background: #5FA88C;
  transition: width 0.3s ease, background 0.3s ease;
}
.crystal-line.low b { color: #D9973F; }
.crystal-line.critical b { color: #B5504B; }
.crystal-line.critical .crystal-bar i { background: #B5504B; }
.night-line { flex-wrap: wrap; }
#bossLine { color: #E08A84; }
#bossLine b { color: #FFB0A8; }

/* The raid has emptied the till crystals. */
#lost {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(7, 8, 10, 0.78);
}
#lost.hidden { display: none; }
.lost-card {
  width: min(90vw, 440px);
  padding: clamp(20px, 4vw, 34px);
  text-align: center;
  background: #23262B;
  border: 1px solid #4A5058;
  border-top: 2px solid #B5504B;
  border-radius: 3px;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.6);
}
.lost-kicker {
  margin: 0 0 10px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.28em;
  color: #B5504B;
}
.lost-card h2 {
  margin: 0 0 12px;
  font-size: clamp(22px, 5vw, 34px);
  line-height: 1.02;
  letter-spacing: -0.02em;
  color: #EFE9DE;
}
.lost-card p {
  margin: 0 auto;
  max-width: 38ch;
  font-size: 12px;
  line-height: 1.5;
  color: #C9C2B6;
}
#restartBtn {
  margin-top: 24px;
  padding: 13px 28px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.18em;
  color: #17191D;
  background: #C08B4E;
  border: 1px solid #D8A66A;
  border-radius: 2px;
  box-shadow: 0 4px 0 #4B2E12, 0 10px 24px rgba(0, 0, 0, 0.45);
  cursor: pointer;
}
#restartBtn:hover { background: #D29A58; }
body.pre-game #lost { display: none !important; }

/* Portrait: the extra stats row moves the tower rail down a touch */
@media (orientation: portrait) and (max-width: 820px) {
  #towerPanel { top: 180px; }
  body.night #towerPanel { top: 196px; }
  #towerPanel { max-height: calc(100vh - 296px); }
  body.night #towerPanel { max-height: calc(100vh - 312px); }
}
/* Short landscape: keep the left rail under the night stats block */
@media (max-height: 520px) and (orientation: landscape) {
  #towerPanel { top: 158px; }
  body.night #towerPanel { top: 158px; }
}

/* The night transition stays translucent so the aisles can be seen folding
   into the maze behind the title, rather than hiding the move. */
.phase-fx.shift .pf-veil {
  background: radial-gradient(circle at 50% 46%, rgba(13, 18, 24, 0.3), rgba(7, 10, 14, 0.58) 72%);
}
.phase-fx.shift .pf-word b { color: #EFE9DE; }

/* Portrait: a compact console. The same information, but the top block and
   tower rail give the store back most of the screen, and the tip sits in one
   line above the inventory instead of over the aisles. */
@media (orientation: portrait) and (max-width: 820px) {
  #topLeft { padding: 5px 7px 6px; width: 204px; max-width: 58vw; }
  #gameTitle { gap: 1px; margin-bottom: 4px; }
  #gameTitle .t-main { font-size: 12px; letter-spacing: -0.2px; }
  #gameTitle .t-sub { font-size: 6px; letter-spacing: 1.1px; }
  .hud-row { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 2px 8px; }
  .hud-row.currency-row { gap: 8px; }
  .hud-line { font-size: 9px; line-height: 1.25; gap: 4px; }
  .hud-line .lbl { font-size: 7.5px; }
  .health .lbl { display: none; }
  .hud-line b { font-size: 10px; }
  .health-bar { min-width: 32px; height: 6px; }
  .wave-line { margin: 0; gap: 5px; }
  .wave-line b { font-size: 11px; }
  .phase { font-size: 8px; padding: 0 3px; }
  .currency b { font-size: 10.5px; }
  .crystal-line { margin-top: 1px; }
  .crystal-bar { height: 5px; }
  .top-actions { margin-top: 3px; gap: 4px; align-items: center; }
  .top-actions .night-btn,
  #startNightBtn { font-size: 10.5px; padding: 5px 7px; min-height: 30px; letter-spacing: 0.04em; }
  .top-actions .btn.tiny { font-size: 8px; padding: 4px 5px; }
  .icon-btn { width: 22px; height: 22px; font-size: 10px; }
  #towerPanel .tower-chip { min-height: 32px; padding: 2px 3px; }
  #towerPanel .tower-chip .t-ico { width: 17px; height: 17px; flex-basis: 17px; }
  #towerPanel .tower-chip .t-ico canvas { width: 14px; height: 14px; }
  #towerPanel { top: 140px; max-height: 284px; }
  .top-actions { margin-bottom: 0; }
  .hint { font-size: 8.5px; padding: 4px 6px; bottom: 100px; line-height: 1.28; }
  .hint-x { width: 14px; height: 14px; font-size: 10px; }
  .coach { bottom: 100px; padding: 4px 6px 5px; }
  .coach p { font-size: 9px; line-height: 1.25; }
  .coach-head { font-size: 7px; }
  .coach-foot .btn { font-size: 8px; padding: 4px 8px; }
}
@media (orientation: portrait) and (max-width: 820px) and (max-height: 700px) {
  #topLeft { width: 190px; }
  #towerPanel { top: 140px; max-height: 270px; }
  #gameTitle .t-main { font-size: 11px; }
  #gameTitle .t-sub { display: none; }
  .top-actions .night-btn { font-size: 10px; padding: 5px 7px; }
  #startNightBtn { min-height: 28px; }
}
@media (orientation: portrait) and (max-width: 370px) {
  #gameTitle .t-sub { display: none; }
  .hud-line .lbl { display: none; }
  #topLeft { width: 178px; padding: 4px 6px 5px; }
  #towerPanel { top: 142px; max-height: 228px; }
  #towerPanel .tower-chip { min-height: 30px; }
  .top-actions .night-btn, #startNightBtn { min-height: 28px; padding: 4px 6px; }
}

/* ------------------------------------------------------------------
   In-game zoom: pinch on a phone, wheel on a desktop, and two buttons
   that work everywhere. Hidden until the store doors open.
   ------------------------------------------------------------------ */
#zoomCtl {
  position: fixed;
  right: max(8px, env(safe-area-inset-right));
  top: 44%;
  z-index: 26;
  display: flex;
  flex-direction: column;
  gap: 7px;
  touch-action: manipulation;
}
#zoomCtl .zoom-btn {
  width: 42px;
  height: 42px;
  padding: 0;
  font-family: inherit;
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
  color: #EFE9DE;
  background: linear-gradient(180deg, #3A3E44 0%, #24272C 100%);
  border: 1px solid #545A62;
  border-radius: 3px;
  box-shadow: 0 4px 0 #14161A, 0 7px 14px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.14);
  cursor: pointer;
}
#zoomCtl .zoom-btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #14161A, 0 2px 5px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}
#zoomCtl .zoom-btn:hover { color: #FFFFFF; border-color: #C08B4E; }
body.pre-game #zoomCtl,
body.lost #zoomCtl {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
}
@media (max-height: 520px) {
  #zoomCtl { top: 34%; }
  #zoomCtl .zoom-btn { width: 36px; height: 36px; font-size: 19px; }
}
@media (max-width: 430px) {
  #zoomCtl .zoom-btn { width: 38px; height: 38px; font-size: 20px; }
}

/* ------------------------------------------------------------------
   Boss night: a clear, high-contrast health bar for the Rift Warden.
   ------------------------------------------------------------------ */
#bossBar {
  position: fixed;
  left: 50%;
  top: 10px;
  transform: translateX(-50%);
  width: min(460px, 46vw);
  z-index: 24;
  pointer-events: none;
}
#bossBar .bb-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 4px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.22em;
  color: #FFD9C8;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
}
#bossBar .bb-head span:last-child {
  font-size: 9px;
  letter-spacing: 0.18em;
  color: #E8B85A;
}
#bossBar .bb-track {
  height: 13px;
  padding: 2px;
  background: #17141A;
  border: 1px solid #7A3A3A;
  border-radius: 2px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
#bossBar .bb-track i {
  display: block;
  height: 100%;
  width: 100%;
  background: linear-gradient(180deg, #FF6A4A 0%, #B52E24 100%);
  box-shadow: 0 0 12px rgba(255, 74, 58, 0.6);
  transition: width 0.18s linear;
}
#bossBar.low .bb-track i {
  background: linear-gradient(180deg, #FFC24A 0%, #C9771F 100%);
}
body.pre-game #bossBar,
body.lost #bossBar {
  opacity: 0 !important;
  visibility: hidden !important;
}
@media (max-width: 700px) and (orientation: portrait) {
  /* Clear of the TOWER SELECTION rail on the left and the toast stack on
     the right, and below both, over the floor. */
  #bossBar {
    top: 360px;
    left: 102px;
    right: 8px;
    width: auto;
    transform: none;
  }
  #bossBar .bb-head { font-size: 10px; }
}

/* In landscape the top strip already carries the stats and the guide, so
   the boss bar sits above the bottom console where the floor is clear. */
@media (orientation: landscape) {
  #bossBar {
    top: auto;
    bottom: 122px;
    width: min(420px, 44vw);
  }
}


/* The boss health bar travels with the monster. */
#bossTag {
  position: fixed;
  transform: translate(-50%, -100%);
  z-index: 30;
  width: 128px;
  pointer-events: none;
  text-align: center;
}
#bossTag span {
  display: block;
  margin-bottom: 2px;
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: #FFD9C8;
  text-shadow: 0 1px 5px rgba(0, 0, 0, 0.95);
  white-space: nowrap;
}
#bossTag .bt-track {
  height: 8px;
  padding: 1px;
  background: rgba(10, 8, 10, 0.86);
  border: 1px solid rgba(255, 110, 82, 0.75);
  border-radius: 1px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}
#bossTag .bt-track i {
  display: block;
  height: 100%;
  width: 100%;
  background: linear-gradient(180deg, #FF7A58 0%, #C42E22 100%);
}
body.pre-game #bossTag,
body.lost #bossTag {
  display: none !important;
}

/* ------------------------------------------------------------------
   Short landscape: one compact stats console above the left tower rail.
   The console used to stack six rows and ran down over TOWER SELECTION;
   now title, health, night, money, crystal and the horde line wrap into
   four short rows, so the rail starts clean underneath it.
   ------------------------------------------------------------------ */
@media (max-height: 520px) and (orientation: landscape) {
  #topLeft {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    column-gap: 12px;
    row-gap: 2px;
    width: 300px;
    min-width: 0;
    padding: 5px 9px 6px;
  }
  #topLeft #gameTitle {
    flex: 0 0 100%;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: baseline;
    gap: 5px;
    margin: 0 0 1px;
    white-space: nowrap;
    overflow: hidden;
  }
  #topLeft #gameTitle .t-main { font-size: 13px; letter-spacing: -0.2px; }
  #topLeft #gameTitle .t-sub { display: none; }
  #topLeft .hud-row {
    display: flex;
    flex: 0 0 auto;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 8px;
    margin: 0;
  }
  #topLeft .hud-line {
    font-size: 9px;
    line-height: 1.35;
    gap: 4px;
    white-space: nowrap;
  }
  #topLeft .health { flex: 0 0 auto; }
  #topLeft .health .health-bar { min-width: 34px; width: 44px; flex: 0 0 auto; }
  #topLeft .wave-line { margin: 0; gap: 6px; }
  #topLeft .wave-line b { font-size: 12px; letter-spacing: 0.3px; }
  #topLeft .phase { font-size: 8px; padding: 1px 4px; }
  #topLeft .crystal-line { margin: 0; gap: 5px; }
  #topLeft .crystal-bar { width: 42px; min-width: 34px; flex: 0 0 auto; }
  #topLeft #nightLine {
    margin: 0;
    gap: 9px;
    font-size: 9px;
    flex-wrap: nowrap;
  }
  #topLeft #nightLine b { font-size: 10px; }
  #topLeft .top-actions {
    width: 100%;
    gap: 6px;
    margin-top: 2px;
  }
}

@media (max-width: 620px) and (orientation: landscape) {
  #topLeft { width: 270px; }
}

@media (max-height: 520px) and (orientation: landscape) {
  #towerPanel { top: 132px; }
}

/* Short landscape: the help sheet is two columns of short tips, so the
   whole page fits without scrolling inside a 390px-tall window. */
@media (max-height: 520px) and (orientation: landscape) {
  #modal .modal { width: min(780px, calc(100vw - 20px)); max-height: calc(100vh - 16px); }
  #modal .modal-body { padding: 6px 14px 10px; }
  #modal .lead { font-size: 10px; line-height: 1.45; margin-bottom: 6px; }
  #modal .help-list {
    columns: 2;
    column-gap: 20px;
    margin-bottom: 4px;
    padding-left: 15px;
  }
  #modal .help-list li {
    font-size: 9px;
    line-height: 1.42;
    margin-bottom: 4px;
    break-inside: avoid;
    -webkit-column-break-inside: avoid;
  }
  #modal .foot { margin: 2px 0 6px; font-size: 8px; }
  #modal .modal-body > .btn.wide { padding: 7px 14px; font-size: 10px; }
}

/* Portrait tower rail: the names carry the choice, so give them a little
   more size than the old 7.5px without widening the 96px rail. */
@media (orientation: portrait) and (max-width: 820px) {
  .tower-chip .t-name { font-size: 8.5px; }
  .tower-chip .t-cost { font-size: 8px; }
  .panel-foot { font-size: 8.5px; }
  .panel-foot .btn.tiny { font-size: 8.5px; }
}

/* Short landscape with a rift noble waiting: the rail starts below the
   noble button instead of running off the bottom of the screen. */
@media (max-height: 520px) and (orientation: landscape) {
  body.noble-wait #towerPanel {
    top: 164px;
    max-height: calc(100vh - 170px);
  }
}

/* Narrow landscape: keep the three bottom consoles in their own columns.
   At 720px and below the centre column was thinner than HERO PORTRAIT, so
   the portrait slid over the inventory's last slot. */
@media (max-width: 820px) and (orientation: landscape) {
  #bottomBar { left: 148px; right: 6px; gap: 5px; }
  #inventoryPanel { width: 190px; }
  #heroPanel { width: 100%; min-width: 0; }
  #rightBar { gap: 5px; }
  #abilityPanel { width: 118px; }
  #radarPanel { width: 70px; flex: 0 0 70px; }
  .hero-body { padding: 5px 6px; gap: 5px; }
  #portrait { width: 46px; height: 46px; flex-basis: 46px; }
  .hero-name { font-size: 12px; }
  .hero-gold { font-size: 11px; }
  .inv-slots { gap: 4px; padding: 5px 5px 3px; }
  .inv-slot { height: 54px; }
  .inv-slot .n { font-size: 8px; }
}

/* Landscape wider than a phone: the same compact stats console, with the
   larger title kept. The tower rail starts under it, so the two no longer
   touch, and the rail stops above the inventory bar. */
@media (orientation: landscape) and (min-width: 821px) and (min-height: 521px) {
  #topLeft {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    column-gap: 14px;
    row-gap: 2px;
    width: min(380px, 34vw);
    padding: 8px 12px 9px;
  }
  #topLeft #gameTitle {
    flex: 0 0 100%;
    margin: 0 0 5px;
  }
  #topLeft .hud-row {
    display: flex;
    flex: 0 0 auto;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 10px;
    margin: 0;
  }
  #topLeft .hud-line { white-space: nowrap; }
  #topLeft .top-actions { width: 100%; margin-top: 5px; }
  #towerPanel {
    top: 190px;
    max-height: calc(100vh - 360px);
  }
  body.noble-wait #towerPanel {
    top: 226px;
    max-height: calc(100vh - 396px);
  }
}

/* ------------------------------------------------------------------
   COMPACT LANDSCAPE CONSOLE (final override)
   A 390 px-tall phone in landscape has to keep the store visible. The
   stats strip, the tower rail and the bottom console shrink to a common
   console height, so the aisle, the horde and the turrets fill the middle
   band instead of the panels covering most of the screen.
   ------------------------------------------------------------------ */
@media (max-height: 640px) and (orientation: landscape) {
  #topLeft {
    width: 286px;
    max-width: calc(100vw - 300px);
    padding: 4px 8px 5px;
    column-gap: 8px;
    row-gap: 0;
  }
  #topLeft #gameTitle { flex: 0 0 100%; margin: 0 0 1px; }
  #topLeft #gameTitle .t-main { font-size: 12px; }
  #topLeft #gameTitle .t-sub { font-size: 5.5px; letter-spacing: 0.8px; }
  #topLeft .hud-row { column-gap: 7px; }
  #topLeft .hud-line { font-size: 8.5px; line-height: 1.2; gap: 3px; }
  #topLeft .hud-line b { font-size: 9.5px; }
  #topLeft .health-bar { width: 32px; min-width: 26px; height: 5px; }
  #topLeft .wave-line b { font-size: 10.5px; }
  #topLeft .crystal-bar { width: 36px; min-width: 28px; height: 5px; }
  #topLeft .top-actions { margin-top: 1px; gap: 4px; }
  #topLeft .top-actions .night-btn,
  #topLeft #startNightBtn { min-height: 22px; padding: 3px 7px; font-size: 9.5px; }
  #topLeft .icon-btn { width: 20px; height: 20px; font-size: 10px; }

  #towerPanel,
  body.night #towerPanel {
    top: 118px;
    bottom: auto;
    left: 6px;
    right: auto;
    width: 112px;
    height: auto;
    max-height: calc(100vh - 124px);
    padding-bottom: 0;
    display: flex;
    flex-direction: column;
  }
  body.noble-wait #towerPanel { top: 140px; max-height: calc(100vh - 146px); }
  #towerPanel .panel-head {
    display: flex;
    flex: 0 0 auto;
    padding: 2px 5px;
    font-size: 7.5px;
    letter-spacing: 0.3px;
  }
  #towerList {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    height: auto;
    min-height: 0;
    gap: 2px;
    padding: 3px;
    overflow-x: hidden;
    overflow-y: auto;
    align-items: stretch;
  }
  #towerPanel .tower-chip {
    flex: 0 0 auto;
    width: 100%;
    min-width: 0;
    min-height: 26px;
    padding: 2px 4px;
    gap: 4px;
    border-left-width: 2px;
    border-top-width: 1px;
  }
  #towerPanel .tower-chip .t-ico { width: 19px; height: 19px; flex-basis: 19px; }
  #towerPanel .tower-chip .t-ico canvas,
  #towerPanel .tower-chip .t-ico img { width: 16px; height: 16px; }
  #towerPanel .tower-chip .t-name { font-size: 7.8px; line-height: 1.02; }
  #towerPanel .tower-chip .t-cost { font-size: 7.2px; margin-top: 0; }
  #towerPanel .panel-foot {
    display: flex;
    flex-direction: row;
    flex: 0 0 auto;
    height: auto;
    padding: 1px 4px 2px;
    gap: 3px;
    font-size: 7.2px;
    border-top: 1px solid var(--line);
  }
  #towerPanel .panel-foot .btn.tiny { width: auto; font-size: 7.2px; padding: 2px 4px; }

  #bottomBar {
    left: 124px;
    right: 4px;
    bottom: 4px;
    height: 76px;
    display: flex;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 4px;
  }
  #inventoryPanel { width: 194px; flex: 0 0 194px; order: 1; }
  #heroPanel { width: auto; flex: 1 1 auto; min-width: 118px; order: 2; }
  #rightBar { width: auto; flex: 0 0 auto; order: 3; margin-left: 0; display: flex; flex-direction: row; align-items: stretch; gap: 4px; }
  #abilityPanel { width: 104px; flex: 0 0 104px; }
  #radarPanel { width: 54px; flex: 0 0 54px; }

  #bottomBar .panel-head,
  #abilityPanel .panel-head,
  #radarPanel .panel-head,
  #inventoryPanel .panel-head,
  #heroPanel .panel-head { font-size: 7.5px; padding: 2px 5px; letter-spacing: 0.3px; }
  .inv-slots { gap: 3px; padding: 3px; }
  .inv-slot { height: 34px; }
  .inv-slot canvas { width: 14px; height: 14px; }
  .inv-slot .n { display: none; }
  .inv-slot .ct { font-size: 9px; }
  .inv-slot .p { font-size: 6.5px; }
  .inv-foot { padding: 0 3px 2px; }
  .inv-foot .btn.tiny { font-size: 7.5px; padding: 2px 5px; width: 100%; }
  .hero-body { padding: 3px 5px 2px; gap: 5px; align-items: center; }
  #portrait { width: 32px; height: 32px; flex-basis: 32px; }
  .hero-label { font-size: 6.5px; }
  .hero-name { font-size: 11px; }
  .hero-gold { font-size: 10px; }
  .ability-grid { grid-template-columns: 1fr 1fr; gap: 2px; padding: 3px; }
  .ability { height: 21px; }
  .ability .label { display: none; }
  .ability .cost { font-size: 7px; }
  #radar { width: 100%; height: auto; padding: 1px; display: block; }

  .coach {
    top: 4px;
    bottom: auto;
    left: auto;
    right: 8px;
    width: min(360px, calc(100vw - 310px));
    padding: 3px 7px 4px;
  }
  .coach p { font-size: 9px; line-height: 1.24; }
  .coach-head { font-size: 7px; }
  .coach-foot .btn { font-size: 8px; padding: 3px 8px; }

  #toasts { top: 74px; left: auto; right: 6px; width: min(230px, calc(100vw - 380px)); }
  .toast { font-size: 8.5px; padding: 4px 6px; }
  .toast b { font-size: 9px; }

  #zoomCtl { top: 38%; }
  #zoomCtl .zoom-btn { width: 34px; height: 34px; font-size: 17px; }
}
@media (max-width: 620px) and (max-height: 640px) and (orientation: landscape) {
  #topLeft { width: 260px; }
  #towerPanel { width: 104px; }
  #bottomBar { left: 112px; }
  #inventoryPanel { width: 178px; flex-basis: 178px; }
  #abilityPanel { width: 96px; flex-basis: 96px; }
  #radarPanel { width: 48px; flex-basis: 48px; }
}

/* Portrait: the jewel stall's tag sits just above its counter, clear of the
   AISLE 5 sign the TOWER SELECTION rail was moved off. */
@media (orientation: portrait) and (max-width: 820px) {
  .world-tag.shop[data-ware="jewel"] { margin-top: -28px; }
}

/* ---- readable guide callout (2026-11-18) ------------------------------- */
.coach {
  width: min(430px, calc(100vw - 20px));
  padding: 10px 13px 11px;
  background: linear-gradient(180deg, #2b2f35 0%, #1e2125 100%);
  border: 1px solid #6d5736;
  border-left: 4px solid #d9a55c;
  box-shadow: 0 9px 28px rgba(0, 0, 0, 0.52);
  z-index: 36;
}
.coach-head {
  font-size: 11px;
  letter-spacing: 0.1em;
  color: #e0bd86;
  font-weight: 800;
  margin-bottom: 5px;
}
.coach-skip {
  font-size: 11px;
  color: #b6a17e;
  letter-spacing: 0.06em;
}
.coach p {
  font-size: 13px;
  line-height: 1.44;
  color: #f4eee2;
  margin: 0 0 9px;
}
.coach-foot .btn {
  font-size: 12px;
  padding: 7px 17px;
  min-height: 32px;
}
#hint {
  font-size: 12px;
  line-height: 1.35;
}
#hintText b { color: #f0cb8c; }
@media (max-width: 700px) and (orientation: portrait) {
  .coach {
    left: 10px;
    right: 10px;
    width: auto;
    bottom: 188px;
  }
  .coach p { font-size: 12.5px; }
}
@media (max-width: 740px) and (orientation: landscape) {
  .coach {
    top: 6px;
    bottom: auto;
    left: auto;
    right: 8px;
    width: min(430px, calc(100vw - 300px));
    padding: 7px 10px 8px;
  }
  .coach-head { font-size: 9.5px; margin-bottom: 3px; }
  .coach p { font-size: 11px; line-height: 1.3; margin-bottom: 5px; }
  .coach-foot .btn { font-size: 10.5px; padding: 5px 12px; min-height: 26px; }
}

/* The day guide's last tip points at the button it names. */
.btn.night-btn.guide-pulse {
  animation: guidePulse 1.35s ease-in-out infinite;
  box-shadow: 0 0 0 2px rgba(255, 214, 148, 0.55), 0 6px 20px rgba(255, 180, 80, 0.35);
}
@keyframes guidePulse {
  0%, 100% { transform: translateY(0); box-shadow: 0 0 0 2px rgba(255, 214, 148, 0.45), 0 6px 18px rgba(255, 180, 80, 0.28); }
  50% { transform: translateY(-1px); box-shadow: 0 0 0 4px rgba(255, 226, 176, 0.22), 0 9px 24px rgba(255, 180, 80, 0.5); }
}

/* ------------------------------------------------------------------
   Portrait phone console, final pass: the store is the screen. The
   stats, tower rail, tutorial and bottom console keep every control
   and readout, but each is compact enough to leave the aisles and the
   horde clear between them. This block comes last so it wins over the
   earlier phone rules without changing the laptop layout.
   ------------------------------------------------------------------ */
@media (orientation: portrait) and (max-width: 820px) {
  #topLeft {
    top: 5px; left: 5px; padding: 5px 7px 6px;
    max-width: calc(100vw - 10px);
  }
  #gameTitle { font-size: 10px; line-height: 1.08; margin-bottom: 4px; letter-spacing: 0; }
  #gameTitle .t-sub { font-size: 6.6px; letter-spacing: 0.03em; }
  .hud-row { gap: 1px; }
  .hud-row + .hud-row { margin-top: 1px; }
  .hud-row.currency-row { gap: 9px; }
  .hud-line { font-size: 9px; line-height: 1.25; gap: 4px; }
  .hud-line b { font-size: 10px; }
  .hud-line .lbl { font-size: 7.5px; }
  .health b { font-size: 10px; }
  .health-bar { min-width: 44px; height: 6px; }
  .wave-line b { font-size: 11px; }
  .phase { font-size: 8px; padding: 0 3px; }
  .currency b { font-size: 11px; }
  .top-actions { margin-top: 3px; gap: 5px; }
  .btn.night-btn { min-height: 34px; font-size: 10.5px; padding: 6px 10px; letter-spacing: 0.05em; }
  .icon-btn { width: 26px; height: 26px; font-size: 12px; }
  #nightLine { margin-top: 2px; font-size: 8.5px; gap: 8px; }
  #nightLine b { font-size: 10px; }
  .btn.noble-btn { margin-top: 4px; font-size: 9px; padding: 5px 8px; }

  #towerPanel {
    left: 5px; top: 150px; bottom: auto;
    width: 88px; max-height: 272px;
  }
  body.night #towerPanel { top: 150px; max-height: 272px; }
  body.noble-wait #towerPanel { top: 178px; max-height: 262px; }
  #towerPanel .panel-head { font-size: 7px; padding: 3px 5px 2px; letter-spacing: 0.3px; }
  #towerList { gap: 2px; padding: 3px; }
  #towerPanel .tower-chip {
    min-height: 34px; padding: 2px 3px; gap: 3px;
    box-shadow: inset 0 1px 0 rgba(239,233,222,0.14), 0 2px 0 #101215, 0 4px 8px rgba(0,0,0,0.32);
  }
  #towerPanel .tower-chip .t-ico { width: 20px; height: 20px; flex-basis: 20px; }
  #towerPanel .tower-chip .t-ico canvas { width: 16px; height: 16px; }
  #towerPanel .tower-chip .t-name { font-size: 7.4px; line-height: 1.02; font-weight: 700; }
  #towerPanel .tower-chip .t-cost { font-size: 7px; margin-top: 0; }
  #towerPanel .panel-foot { padding: 2px 4px 4px; gap: 1px; font-size: 7px; }
  #towerPanel .panel-foot .btn.tiny { font-size: 7px; padding: 3px 3px; min-height: 20px; }

  #bottomBar {
    left: 4px; right: 4px; bottom: 4px;
    gap: 3px; align-items: stretch;
  }
  #bottomBar .panel .panel-head {
    font-size: 6.8px; padding: 2px 5px; letter-spacing: 0.3px;
    line-height: 1.2;
  }
  #inventoryPanel { width: 33%; }
  #heroPanel { width: 27%; }
  #rightBar { width: 40%; gap: 3px; }
  #portrait { width: 32px; height: 32px; flex-basis: 32px; }
  .hero-body { padding: 3px 4px 2px; gap: 4px; }
  .hero-label { font-size: 6.5px; }
  .hero-name { font-size: 11px; }
  .hero-gold { font-size: 10px; }
  .inv-slots { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 2px; padding: 3px 3px 1px; }
  .inv-slot { height: 30px; }
  .inv-slot canvas { width: 12px; height: 12px; }
  .inv-slot .ct { font-size: 9px; }
  .inv-slot .p { font-size: 6px; }
  .inv-foot { padding: 0 3px 3px; }
  .inv-foot .btn.tiny { font-size: 7px; padding: 3px 4px; min-height: 18px; }
  #abilityPanel { flex: 1; }
  .ability-grid { grid-template-columns: 1fr 1fr; gap: 2px; padding: 3px; }
  .ability { height: 21px; }
  .ability .cost { font-size: 7px; }
  #radarPanel { width: 34px; flex: 0 0 34px; }
  #radar { width: 100%; height: auto; padding: 1px; }

  /* The guide parks as a slim banner over the near floor, never over the
     aisles, the cashier or the horde. */
  .coach {
    left: 4px; right: 4px; bottom: 74px; width: auto;
    padding: 3px 7px 5px;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: 'head head' 'text btn';
    column-gap: 6px;
  }
  .coach-head { font-size: 7px; margin-bottom: 1px; }
  .coach-skip { font-size: 8px; }
  .coach p { font-size: 9.5px; line-height: 1.25; margin: 0; }
  .coach-foot .btn { font-size: 9px; padding: 5px 10px; min-height: 30px; }
  #hint { left: 4px; right: 4px; bottom: 74px; font-size: 9px; padding: 4px 7px; }
  .pad-card, .block-card { left: 4px; right: 4px; bottom: 76px; }
  .visitor-card { max-height: 72vh; }

  #zoomCtl { right: 4px; top: auto; bottom: 156px; }
}

@media (orientation: portrait) and (max-width: 370px) {
  #towerPanel { width: 82px; top: 150px; max-height: 258px; }
  #towerPanel .tower-chip .t-name { font-size: 7px; }
  #bottomBar .panel .panel-head { font-size: 6.4px; }
  .hero-name { font-size: 10px; }
  #radarPanel { width: 30px; flex-basis: 30px; }
}

/* ------------------------------------------------------------------
   Final phone pass: the panels let the store show through, and the
   first-night guide sits on the console instead of on the shop floor.
   ------------------------------------------------------------------ */
@media (orientation: portrait) and (max-width: 820px) {
  #topLeft,
  #towerPanel {
    background: rgba(18, 20, 24, 0.82);
    box-shadow: inset 0 0 0 1px rgba(255, 214, 110, 0.06), 0 6px 18px rgba(0, 0, 0, 0.5);
  }
  #gameTitle { font-size: 9.6px; }
  #gameTitle .t-sub { font-size: 6.2px; }
  .hud-line .lbl { color: #B6AE9E; }
  #towerPanel {
    width: 82px;
    top: 146px;
    max-height: 258px;
  }
  body.night #towerPanel { top: 146px; max-height: 258px; }
  #towerPanel .tower-chip { min-height: 31px; padding: 1px 3px; }
  #towerPanel .tower-chip .t-ico { width: 18px; height: 18px; flex-basis: 18px; }
  #towerPanel .tower-chip .t-ico canvas { width: 14px; height: 14px; }

  /* The first-night guide docks over the bottom console (which is HUD,
     not shop floor) so the shelves, the cashier and the horde stay clear. */
  .coach {
    bottom: 4px;
    left: 4px;
    right: 4px;
    width: auto;
    padding: 4px 8px 5px;
    background: rgba(26, 29, 34, 0.96);
  }
  .coach p { font-size: 10px; line-height: 1.28; }
}

/* The tower rail stays a rail: names on one line, no wasted height. */
@media (orientation: portrait) and (max-width: 820px) {
  #topLeft,
  #towerPanel { background: rgba(16, 18, 22, 0.74); }
  #towerPanel {
    width: 88px;
    top: 146px;
    max-height: 186px;
    padding-bottom: 0;
  }
  body.night #towerPanel { top: 146px; max-height: 186px; }
  #towerPanel .panel-head { font-size: 6.4px; padding: 2px 4px 1px; letter-spacing: 0.2px; }
  #towerList { gap: 1px; padding: 2px; }
  #towerPanel .tower-chip {
    min-height: 22px;
    padding: 1px 3px;
    gap: 3px;
    align-items: center;
  }
  #towerPanel .tower-chip .t-ico { width: 17px; height: 17px; flex-basis: 17px; }
  #towerPanel .tower-chip .t-ico canvas { width: 13px; height: 13px; }
  #towerPanel .tower-chip .t-name {
    font-size: 6.8px;
    line-height: 1.05;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  #towerPanel .tower-chip .t-cost { font-size: 6.2px; margin-top: 0; }
  #towerPanel .panel-foot { padding: 2px 3px 3px; gap: 0; }
  #towerPanel .panel-foot #slotsTxt { font-size: 6.2px; }
  #towerPanel .panel-foot .btn.tiny { font-size: 6.4px; padding: 3px 2px; min-height: 17px; }
}

/* Phone build rail: icon and price only. The full tower cards, with their
   names and stats, open on the plot the player taps. */
@media (orientation: portrait) and (max-width: 820px) {
  #towerPanel {
    width: 52px;
    top: 146px;
    max-height: 182px;
    background: rgba(16, 18, 22, 0.72);
  }
  body.night #towerPanel { top: 146px; max-height: 182px; }
  #towerPanel .panel-head {
    font-size: 5.0px;
    padding: 2px 2px 1px;
    letter-spacing: 0;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
  }
  #towerList { padding: 2px; gap: 1px; }
  #towerPanel .tower-chip {
    min-height: 21px;
    padding: 0;
    gap: 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
  }
  #towerPanel .tower-chip .t-ico { width: 16px; height: 16px; flex-basis: 16px; }
  #towerPanel .tower-chip .t-ico canvas { width: 13px; height: 13px; }
  #towerPanel .tower-chip .t-name { display: none; }
  #towerPanel .tower-chip .t-cost { font-size: 5.2px; margin-top: 0; text-align: center; line-height: 1; }
  #towerPanel .panel-foot { padding: 2px 2px 3px; gap: 0; }
  #towerPanel .panel-foot #slotsTxt { font-size: 5.6px; text-align: center; }
  #towerPanel .panel-foot .btn.tiny { font-size: 5.6px; padding: 2px 1px; min-height: 15px; }
}

@media (orientation: portrait) and (max-width: 820px) {
  #towerPanel .panel-foot {
    padding: 1px 2px 2px;
    gap: 0;
  }
  #towerPanel .panel-foot #slotsTxt { font-size: 5.2px; line-height: 1; }
  #towerPanel .panel-foot .btn.tiny {
    font-size: 5.2px;
    line-height: 1.05;
    padding: 1px 1px;
    min-height: 0;
  }
}

@media (orientation: portrait) and (max-width: 820px) {
  #towerPanel {
    width: 58px;
    top: 146px;
    max-height: 198px;
  }
  body.night #towerPanel { top: 146px; max-height: 198px; }
  #towerPanel .panel-head { font-size: 5.6px; }
  #towerPanel .tower-chip { min-height: 26px; }
  #towerPanel .tower-chip .t-ico { width: 18px; height: 18px; flex-basis: 18px; }
  #towerPanel .tower-chip .t-ico canvas { width: 15px; height: 15px; }
  #towerPanel .tower-chip .t-cost { font-size: 5.4px; }
}

/* ------------------------------------------------------------------
   Tower rail: the spec asks for icons AND names. On an upright phone the
   rail keeps every tower's name visible above its price; the newest rule
   wins over the earlier icon-only phone rail.
   ------------------------------------------------------------------ */
@media (orientation: portrait) and (max-width: 820px) {
  #towerPanel {
    width: 104px;
    top: 146px;
    max-height: 276px;
    padding-bottom: 0;
  }
  body.night #towerPanel { top: 146px; max-height: 276px; }
  #towerPanel .panel-head {
    font-size: 7.2px;
    padding: 3px 5px 2px;
    letter-spacing: 0.35px;
    text-align: left;
  }
  #towerList {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 3px;
    overflow-y: auto;
    min-height: 0;
  }
  #towerPanel .tower-chip {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 4px;
    width: 100%;
    min-height: 34px;
    padding: 2px 4px;
  }
  #towerPanel .tower-chip .t-ico { width: 19px; height: 19px; flex: 0 0 19px; }
  #towerPanel .tower-chip .t-ico canvas { width: 15px; height: 15px; }
  #towerPanel .tower-chip .t-body {
    display: block;
    min-width: 0;
    flex: 1 1 auto;
    text-align: left;
  }
  #towerPanel .tower-chip .t-name {
    display: block;
    font-size: 8px;
    line-height: 1.08;
    font-weight: 700;
    letter-spacing: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: left;
  }
  #towerPanel .tower-chip .t-cost {
    display: block;
    font-size: 7.4px;
    margin-top: 1px;
    text-align: left;
  }
  #towerPanel .panel-foot { padding: 3px 4px 4px; gap: 1px; }
  #towerPanel .panel-foot #slotsTxt { font-size: 7px; }
  #towerPanel .panel-foot .btn.tiny {
    font-size: 7px;
    padding: 3px 3px;
    min-height: 19px;
  }
}

@media (orientation: portrait) and (max-width: 370px) {
  #towerPanel { width: 98px; max-height: 294px; }
  #towerPanel .tower-chip { min-height: 37px; }
  #towerPanel .tower-chip .t-name {
    font-size: 7.6px;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    line-height: 1.04;
  }
}

/* Narrow phones: keep the rail and guide from swallowing the dark play area. */
@media (orientation: portrait) and (max-width: 430px) {
  #towerPanel {
    width: 82px;
    max-height: 248px;
    background: rgba(14, 12, 10, 0.62);
  }
  #towerPanel .panel-head { font-size: 7px; padding: 3px 5px; }
  .tower-chip { padding: 2px 2px; gap: 3px; }
  .tower-chip .t-ico { width: 16px; height: 16px; flex-basis: 16px; }
  .tower-chip .t-ico canvas { width: 14px; height: 14px; }
  .tower-chip .t-name { font-size: 7px; }
  .tower-chip .t-cost { font-size: 7px; }
  #coach { width: min(290px, calc(100vw - 24px)); }
}
