:root {
  --ink: #140f16;
  --ink: #14160f;
  --panel: #23281d;
  --panel-2: #2c3224;
  --khaki: #b6b09a;
  --bone: #c9c3ac;
  --orange: #c2551f;
  --orange-hot: #d96a2a;
  --blood: #8a2b22;
  --grey: #7c8380;
  --moss: #4a5f55;
  --line: rgba(201, 195, 172, 0.26);
  --display: 'Big Shoulders Stencil', Impact, 'Arial Narrow', sans-serif;
  --cond: 'Barlow Semi Condensed', 'Arial Narrow', Arial, sans-serif;
  --mono: 'IBM Plex Mono', 'Courier New', monospace;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: #0d0f09;
  color: var(--bone);
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--cond);
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  margin: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

#app {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background: #14160f;
}

.display {
  font-family: var(--display);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.cond {
  font-family: var(--cond);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.mono {
  font-family: var(--mono);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

.hidden { display: none !important; }

.plate {
  position: relative;
  background-color: #545845;
  background-image: url(../img/command_plate.webp);
  background-size: 320px 100%;
  background-position: center;
  background-blend-mode: multiply;
  border: 1px solid var(--line);
  box-shadow: inset 0 0 0 1px rgba(13, 15, 9, 0.55);
}

.plate::before,
.plate::after {
  content: "";
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #bdb7a2;
  box-shadow: inset 0 0 0 1px #585b49, 0 0 0 1px rgba(13, 15, 9, 0.85);
  pointer-events: none;
}

.plate::before { top: 4px; left: 4px; }
.plate::after { bottom: 4px; right: 4px; }

#topbar {
  position: relative;
  z-index: 30;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 74px;
  padding: 0 12px;
  background: #1c2117;
  border-bottom: 2px solid #0b0d08;
  box-shadow: inset 0 -2px 0 rgba(201, 195, 172, 0.14);
}

#topbar::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url(../img/command_plate.webp);
  background-repeat: repeat-x;
  background-size: auto 100%;
  opacity: 0.72;
  pointer-events: none;
}

#topbar::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(16, 18, 11, 0.34);
  pointer-events: none;
}

#topbar .hud-left,
#topbar .hud-right { position: relative; z-index: 2; }

.hud-left { flex: 0 0 auto; }

.sector-plate {
  width: 366px;
  height: 64px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  padding: 4px 12px 4px 14px;
}

.sector-main {
  display: flex;
  align-items: center;
  gap: 10px;
  line-height: 1;
}

#sectorNo {
  font-size: 27px;
  line-height: 0.9;
  color: var(--bone);
  letter-spacing: 0.06em;
}

#cityName {
  margin-left: auto;
  font-size: 11px;
  letter-spacing: 0.2em;
  color: var(--orange);
  white-space: nowrap;
}

.sector-sub {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 9px;
  line-height: 1;
  white-space: nowrap;
}

#coords { color: rgba(201, 195, 172, 0.58); letter-spacing: 0.04em; margin-left: auto; }

.reward-tag {
  flex: 0 0 auto;
  font-size: 9px;
  letter-spacing: 0.06em;
  color: var(--orange);
  text-shadow: 1px 1px 0 rgba(13, 15, 9, 0.8);
  white-space: nowrap;
}

.hostiles {
  display: flex;
  align-items: center;
  gap: 4px;
}

.hostiles img { width: 13px; height: 13px; object-fit: contain; opacity: 0.9; }
.hostiles b { font-size: 13px; color: var(--bone); }
.hostiles .cond { font-size: 7px; letter-spacing: 0.16em; color: rgba(201, 195, 172, 0.62); }

.plan {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 2px;
  width: 104px;
  flex: 0 0 auto;
}

.plan-cell {
  position: relative;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 3px;
  min-width: 0;
  height: 15px;
  padding: 1px 3px 0;
  border: 1px solid rgba(201, 195, 172, 0.28);
  background: rgba(20, 22, 15, 0.24);
  line-height: 1;
}

.plan-cell b { font-size: 8px; color: var(--bone); }
.plan-cell em { font-style: normal; font-size: 9px; color: var(--orange); }
.plan-cell.active { border-color: var(--orange); box-shadow: inset 0 0 0 1px rgba(194, 85, 31, 0.35); }
.plan-cell.done { border-color: rgba(201, 195, 172, 0.2); opacity: 0.55; }
.plan-cell.done em { display: none; }
.plan-cell.done::after {
  content: "";
  position: absolute;
  left: 4px;
  right: 4px;
  top: 50%;
  height: 2px;
  background: var(--orange);
  transform: rotate(-24deg);
  opacity: 0.9;
}

.hud-brand {
  position: absolute;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
  width: clamp(100px, 28vw, 540px);
  z-index: 6;
  pointer-events: none;
}

.hud-brand img {
  display: block;
  width: 100%;
  height: auto;
}

.hud-right {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.stat-plate {
  height: 48px;
  min-width: 86px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 11px;
  border-radius: 0;
}

.stat-plate img { width: 24px; height: 24px; object-fit: contain; opacity: 0.94; }
.stat-plate span { font-size: 20px; line-height: 1; white-space: nowrap; }

.money {
  color: var(--bone);
  text-shadow: 1px 1px 0 var(--orange), 2px 2px 0 rgba(194, 85, 31, 0.28);
}

.stat-button {
  width: 54px;
  min-width: 54px;
  justify-content: center;
  padding: 0;
}

.stat-button:active { background-color: #3a412e; }

#field {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  background: #14160f;
}

#game {
  position: absolute;
  inset: 0;
}

#game canvas {
  display: block;
  touch-action: none;
  cursor: crosshair;
}

#stamp {
  position: absolute;
  inset: 0;
  z-index: 56;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  padding: 16px;
}

.stamp-inner {
  position: relative;
  width: min(92%, 880px);
  padding: 18px 26px 20px;
  text-align: center;
  transform: rotate(-6deg) scale(1.16);
  opacity: 0;
  border: 5px solid var(--orange);
  background: rgba(20, 22, 15, 0.62);
  box-shadow: 0 0 0 2px rgba(20, 22, 15, 0.7);
  transition: transform 140ms steps(3, end), opacity 140ms steps(3, end);
}

#stamp.show .stamp-inner {
  opacity: 1;
  transform: rotate(-6deg) scale(1);
}

.stamp-kicker {
  font-size: clamp(8px, 1.1vw, 12px);
  letter-spacing: 0.4em;
  color: var(--bone);
  opacity: 0.8;
}

.stamp-word {
  margin: 2px 0 6px;
  font-size: clamp(38px, 9.2vw, 128px);
  line-height: 0.84;
  color: var(--orange);
  text-shadow: 3px 3px 0 rgba(20, 22, 15, 0.85);
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.stamp-loot {
  font-size: clamp(10px, 1.5vw, 17px);
  color: var(--bone);
  letter-spacing: 0.14em;
  text-shadow: 1px 1px 0 var(--orange);
}

#deployTag {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  z-index: 22;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 9px 7px 13px;
  background: #2f3527;
  border: 1px solid var(--orange);
  box-shadow: 0 0 0 1px rgba(13, 15, 9, 0.6);
  pointer-events: none;
  white-space: nowrap;
}

#deployTag .cond { font-size: 9px; letter-spacing: 0.14em; color: var(--bone); }

#deployTag button {
  pointer-events: auto;
  font-size: 8px;
  letter-spacing: 0.08em;
  padding: 4px 7px;
  border: 1px solid var(--line);
  color: var(--orange);
}

#toast {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  z-index: 70;
  padding: 8px 14px;
  background: #2b3123;
  border: 1px solid var(--bone);
  box-shadow: 2px 2px 0 rgba(13, 15, 9, 0.9);
  font-family: var(--cond);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.13em;
  font-size: 11px;
  color: var(--bone);
  white-space: nowrap;
  pointer-events: none;
}

#toast.warn { border-color: var(--orange); color: var(--orange); }

#deck {
  position: relative;
  z-index: 20;
  flex: 0 0 auto;
  background: #1d2217;
  border-top: 2px solid #0b0d08;
  box-shadow: inset 0 2px 0 rgba(201, 195, 172, 0.18);
  padding: 5px 8px 7px;
}

#deck::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url(../img/command_plate.webp);
  background-repeat: repeat-x;
  background-size: auto 100%;
  opacity: 0.55;
  pointer-events: none;
}

#deck::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(16, 18, 11, 0.38);
  pointer-events: none;
}

#deck > * { position: relative; z-index: 1; }

#hintRow {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 20px;
  padding: 0 2px;
}

.hint {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 8.5px;
  letter-spacing: 0.13em;
  color: rgba(201, 195, 172, 0.64);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.text-button {
  flex: 0 0 auto;
  font-size: 8px;
  letter-spacing: 0.12em;
  padding: 3px 7px;
  color: var(--bone);
  border: 1px solid rgba(201, 195, 172, 0.24);
  background: rgba(20, 22, 15, 0.22);
}

.text-button:hover { border-color: var(--bone); }
.text-button:active { background: rgba(201, 195, 172, 0.12); }

#deckBody {
  display: flex;
  align-items: stretch;
  gap: 8px;
  margin-top: 4px;
}

#deployRow {
  flex: 0 0 auto;
  display: flex;
  align-items: stretch;
  gap: 6px;
  min-width: 0;
}

.ucard {
  position: relative;
  width: 104px;
  height: 148px;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 5px 4px 4px;
  overflow: hidden;
  color: var(--bone);
  background-color: #4d513f;
  background-image: url(../img/command_plate.webp);
  background-size: 190px 100%;
  background-position: center;
  background-blend-mode: multiply;
  border: 1px solid rgba(201, 195, 172, 0.34);
  box-shadow: inset 0 0 0 1px rgba(13, 15, 9, 0.6), 0 2px 0 rgba(13, 15, 9, 0.7);
}

.ucard::before {
  content: "";
  position: absolute;
  inset: 3px;
  border: 1px solid rgba(201, 195, 172, 0.16);
  pointer-events: none;
}

.ucard-name {
  font-size: 9.5px;
  letter-spacing: 0.12em;
  line-height: 1;
  color: var(--bone);
  text-shadow: 1px 1px 0 rgba(13, 15, 9, 0.9);
  z-index: 1;
}

.ucard-figure {
  position: relative;
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  overflow: hidden;
  padding-top: 2px;
}

.ucard-figure img {
  display: block;
  max-width: 96%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(2px 2px 0 rgba(13, 15, 9, 0.55));
}

.ucard-tier {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 8px;
  margin: 1px 0 2px;
}

.ucard-tier i {
  width: 7px;
  height: 7px;
  border-top: 2px solid var(--orange);
  border-right: 2px solid var(--orange);
  transform: rotate(-45deg);
  opacity: 0.92;
}

.ucard-cost {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  line-height: 1;
  color: var(--orange);
  text-shadow: 1px 1px 0 rgba(13, 15, 9, 0.9);
  z-index: 1;
}

.ucard-cost img { width: 13px; height: 13px; object-fit: contain; opacity: 0.9; }
.ucard-cost b { font-weight: 500; }

.ucard:hover { border-color: rgba(201, 195, 172, 0.62); }
.ucard:active { transform: translateY(1px); }

.ucard.poor { opacity: 0.56; }
.ucard.poor .ucard-cost { color: #a07d54; }

.ucard.armed {
  border-color: var(--orange);
  box-shadow: inset 0 0 0 2px var(--orange), inset 0 0 0 4px rgba(20, 22, 15, 0.85), 0 2px 0 rgba(13, 15, 9, 0.7);
}

.ucard.armed::after {
  content: "ARMED";
  position: absolute;
  left: 50%;
  top: 26px;
  transform: translateX(-50%) rotate(-5deg);
  font-family: var(--display);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.1em;
  color: var(--orange);
  text-shadow: 1px 1px 0 rgba(13, 15, 9, 0.95);
  z-index: 3;
  pointer-events: none;
}

#upgradeRow {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  min-width: 0;
}

#upgradeRow.locked {
  display: grid;
}

#upgradeRow.locked .ucell {
  opacity: 0.52;
}

#upgradeRow.locked .ucell .up-cost {
  color: #9b7b52;
}

.upgrade-lock {
  display: none !important;
}

.deck-filler {
  display: none;
}

.ucell {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  min-width: 0;
  padding: 4px 4px 5px;
  background-color: #4d513f;
  background-image: url(../img/command_plate.webp);
  background-size: 190px 100%;
  background-position: center;
  background-blend-mode: multiply;
  border: 1px solid rgba(201, 195, 172, 0.3);
  box-shadow: inset 0 0 0 1px rgba(13, 15, 9, 0.6);
  color: var(--bone);
}

.ucell:hover { border-color: rgba(201, 195, 172, 0.62); }
.ucell.poor { opacity: 0.58; }
.ucell.max { opacity: 1; }

.uchever {
  width: 38px;
  height: 34px;
  object-fit: contain;
  margin-bottom: -1px;
  filter: drop-shadow(1px 1px 0 rgba(13, 15, 9, 0.7));
}

.up-name {
  font-size: 8px;
  line-height: 1;
  letter-spacing: 0.12em;
  white-space: nowrap;
}

.up-pips {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 7px;
  margin: 2px 0 1px;
}

.up-pips i {
  width: 5px;
  height: 5px;
  border: 1px solid rgba(201, 195, 172, 0.42);
  transform: rotate(45deg);
}

.up-pips i.on { background: var(--orange); border-color: var(--orange); }

.up-cost {
  font-size: 11px;
  line-height: 1;
  color: var(--orange);
  text-shadow: 1px 1px 0 rgba(13, 15, 9, 0.85);
  white-space: nowrap;
}

.ucell.max .up-cost { color: var(--bone); }

.sheet {
  position: absolute;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(11, 13, 8, 0.78);
}

.sheet-plate {
  width: min(560px, 96vw);
  max-height: 90vh;
  max-height: 90dvh;
  overflow: auto;
  padding: 18px 20px 16px;
  border: 1px solid rgba(201, 195, 172, 0.45);
  box-shadow: 0 0 0 2px rgba(11, 13, 8, 0.85), 6px 6px 0 rgba(11, 13, 8, 0.55);
}

.sheet-head {
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
  margin-bottom: 8px;
}

.sheet-head img { width: 30px; height: 30px; object-fit: contain; }

.sheet-head h2 {
  margin: 0;
  font-size: clamp(26px, 5vw, 42px);
  line-height: 0.9;
  color: var(--bone);
  letter-spacing: 0.05em;
}

.sheet-body { display: flex; flex-direction: column; gap: 7px; }

.order {
  display: grid;
  grid-template-columns: 74px 1fr;
  gap: 9px;
  align-items: baseline;
  margin: 0;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(201, 195, 172, 0.12);
}

.order b {
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--orange);
}

.order span {
  font-size: 11px;
  line-height: 1.35;
  letter-spacing: 0.06em;
  color: rgba(201, 195, 172, 0.82);
}

.sheet-foot {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 12px;
}

.sheet-button {
  padding: 9px 16px;
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--bone);
  border: 1px solid var(--line);
  background: rgba(20, 22, 15, 0.4);
}

.sheet-button:hover { border-color: var(--bone); }
.sheet-button.danger { color: var(--orange); border-color: var(--orange); }
.sheet-button.danger:hover { background: rgba(194, 85, 31, 0.16); }

.fail-plate {
  width: min(480px, 94vw);
  text-align: center;
  border-color: var(--orange);
}

.fail-word {
  margin: 4px 0 10px;
  font-size: clamp(48px, 11vw, 88px);
  line-height: 0.82;
  color: var(--orange);
  text-shadow: 3px 3px 0 rgba(13, 15, 9, 0.9);
}

.fail-copy {
  margin: 0 auto 14px;
  max-width: 330px;
  font-size: 11px;
  line-height: 1.4;
  letter-spacing: 0.08em;
  color: rgba(201, 195, 172, 0.82);
}

.fail-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
}

.fail-stats > div {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 8px 4px;
  border-right: 1px solid rgba(201, 195, 172, 0.12);
}

.fail-stats > div:last-child { border-right: 0; }

.fail-stats span { font-size: 7px; letter-spacing: 0.12em; color: rgba(201, 195, 172, 0.6); }
.fail-stats b { font-size: 20px; color: var(--bone); }

#wipe {
  position: absolute;
  inset: -6% -10%;
  z-index: 90;
  background: var(--bone);
  transform: translateX(-118%);
  pointer-events: none;
  transition: transform 280ms cubic-bezier(0.5, 0, 0.7, 1);
}

#wipe::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
  width: 18px;
  background: var(--orange);
}

#wipe.cover { transform: translateX(0); }
#wipe.out { transform: translateX(118%); transition-timing-function: cubic-bezier(0.3, 0, 0.5, 1); }


.load-plate {
  width: min(360px, 90vw);
  text-align: center;
}

.load-word {
  margin: 4px 0 12px;
  font-size: clamp(40px, 9vw, 64px);
  line-height: 0.85;
  color: var(--bone);
}

.load-rule {
  position: relative;
  height: 6px;
  background: rgba(20, 22, 15, 0.7);
  border: 1px solid rgba(201, 195, 172, 0.35);
  overflow: hidden;
}

.load-rule i {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 34%;
  background: var(--orange);
  animation: loadSweep 900ms steps(6, end) infinite;
}

@keyframes loadSweep {
  0% { transform: translateX(-110%); }
  100% { transform: translateX(330%); }
}

.load-copy {
  margin: 8px 0 0;
  font-size: 8px;
  letter-spacing: 0.28em;
  color: rgba(201, 195, 172, 0.6);
}

#fundsNo.flash {
  animation: fundsStamp 260ms steps(2, end);
}

@keyframes fundsStamp {
  0% { transform: scale(1.28); }
  50% { transform: scale(0.94); }
  100% { transform: scale(1); }
}

@media (min-width: 981px) and (max-width: 1100px) {
  .hud-brand { width: 250px; }
}

@media (max-width: 980px) {
  #topbar {
    height: 122px;
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: 58px 58px;
    grid-template-areas:
      "brand brand"
      "sector stats";
    gap: 2px 8px;
    padding: 2px 8px 4px;
  }

  .hud-brand {
    position: static;
    grid-area: brand;
    transform: none;
    justify-self: center;
    align-self: center;
    width: 122px;
    margin-top: 2px;
  }

  .hud-left { grid-area: sector; min-width: 0; }
  .hud-right { grid-area: stats; margin-left: 0; gap: 4px; }

  .sector-plate {
    width: 100%;
    height: 56px;
    gap: 2px;
    padding: 3px 8px;
  }

  .sector-main { gap: 6px; }
  #sectorNo { font-size: 19px; }
  #cityName { display: none; }

  .sector-sub { gap: 4px; }
  #coords { display: none; }
  .reward-tag { margin-left: auto; font-size: 8px; }
  .hostiles img { width: 11px; height: 11px; }
  .hostiles b { font-size: 12px; }
  .hostiles .cond { display: none; }

  .plan { width: 96px; gap: 2px; }
  .plan-cell { height: 14px; padding: 1px 1px 0; }
  .plan-cell b { font-size: 8px; }
  .plan-cell em { display: none; }

  .stat-plate {
    height: 40px;
    min-width: 0;
    padding: 0 6px;
    gap: 3px;
  }
  .stat-plate img { width: 15px; height: 15px; }
  .stat-plate span { font-size: 12px; }
  .stat-button { width: 34px; min-width: 34px; }

  #deckBody { flex-direction: column; }

  .ucard {
    width: clamp(78px, 9vw, 96px);
    height: 130px;
  }

  #upgradeRow { width: 100%; }
  #upgradeRow.locked { display: none; }

  .sheet { padding: 10px; }
}

@media (max-width: 700px) {
  #deck { padding: 4px 6px 6px; }

  #deployRow {
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    padding-bottom: 2px;
  }
  #deployRow::-webkit-scrollbar { display: none; }

  .ucard {
    width: 86px;
    height: 118px;
    scroll-snap-align: start;
    padding: 4px 3px 3px;
  }

  .ucard-name { font-size: 8px; letter-spacing: 0.1em; }
  .ucard-cost { font-size: 10px; }
  .ucard-cost img { width: 11px; height: 11px; }
  .ucard.armed::after { top: 20px; font-size: 12px; }

  #upgradeRow { gap: 4px; }
  .ucell { padding: 3px 2px 4px; }
  .uchever { width: 26px; height: 24px; }
  .up-name { font-size: 6.5px; letter-spacing: 0.08em; }
  .up-pips { gap: 2px; height: 6px; }
  .up-pips i { width: 4px; height: 4px; }
  .up-cost { font-size: 9px; }

  #hintRow { height: 24px; }
  .hint { font-size: 7.5px; letter-spacing: 0.1em; }
  .text-button { font-size: 8px; padding: 4px 8px; min-height: 22px; }

  #toast { font-size: 9px; padding: 6px 10px; bottom: 10px; }
  #deployTag { bottom: 8px; padding: 5px 6px 5px 9px; }
  #deployTag .cond { font-size: 7.5px; }

  .order { grid-template-columns: 62px 1fr; }
  .sheet-plate { padding: 14px 14px 12px; }
}

@media (max-height: 560px) and (orientation: landscape) {
  #topbar {
    height: 56px;
    display: flex;
    grid-template-columns: none;
    grid-template-rows: none;
    gap: 8px;
    padding: 0 10px;
  }

  .hud-brand { position: absolute; left: 50%; top: 0; transform: translateX(-50%); width: 112px; }
  .hud-left { flex: 0 0 auto; }
  .hud-right { margin-left: auto; }
  .sector-plate { height: 48px; width: 250px; }
  #sectorNo { font-size: 20px; }
  .plan { width: 96px; }
  .plan-cell { height: 12px; padding: 0 1px; }
  .plan-cell em { display: none; }
  .plan-cell b { font-size: 7.5px; }
  .stat-plate { height: 40px; min-width: 62px; }
  .stat-plate span { font-size: 16px; }
  .stat-plate img { width: 18px; height: 18px; }
  .stat-button { min-width: 44px; width: 44px; }

  #hintRow { height: 16px; }
  #hintText { display: none; }
  #hintRow { justify-content: flex-end; }

  #deck { padding: 3px 8px 5px; }
  #deckBody { display: flex; flex-direction: row; }
  #upgradeRow { flex: 1 1 auto; width: auto; min-width: 0; }
  .ucard { height: 96px; width: 82px; }
  .ucard-name { font-size: 8px; }
  .ucard-tier { display: none; }
  .ucard-cost { font-size: 10px; }
  .ucard-figure img { max-height: 100%; }

  #upgradeRow { height: auto; }
  .uchever { width: 24px; height: 22px; }
  .up-name { font-size: 7px; }
  .up-cost { font-size: 9px; }

  .sheet { padding: 8px; }
  .sheet-plate { max-height: 94vh; }
}

@media (max-height: 560px) and (orientation: landscape) and (max-width: 980px) {
  #topbar { height: 56px; display: flex; }
  .hud-brand { position: absolute; left: 50%; top: 0; transform: translateX(-50%); width: 112px; }
  .hud-left { flex: 0 0 auto; }
  .hud-right { margin-left: auto; }
  .sector-plate { width: 250px; height: 44px; }
  #cityName { display: none; }
  #coords { display: none; }
}

@media (max-height: 560px) and (min-width: 981px) {
  #deckBody { flex-direction: row; }
  #hintText { display: block; }
  #hintRow { justify-content: flex-start; }
}

@media (max-width: 380px) {
  .hud-brand { width: 108px; }
  .stat-plate { padding: 0 4px; }
  .stat-plate img { width: 13px; height: 13px; }
  .stat-plate span { font-size: 11px; }
  .ucard { width: 80px; height: 112px; }
  .sector-plate { padding: 2px 6px; }
  #sectorNo { font-size: 17px; }
}

@media (min-width: 1460px) and (min-height: 600px) {
  .hint { font-size: 10px; }
  .text-button { font-size: 9px; padding: 4px 8px; }

  .ucard { width: 138px; height: 172px; }
  .ucard-name { font-size: 12px; }
  .ucard-cost { font-size: 15px; }
  .ucard-cost img { width: 15px; height: 15px; }
  .ucard-tier i { width: 8px; height: 8px; }

  #deckBody { gap: 10px; }
  #deployRow { gap: 6px; }

  #upgradeRow {
    flex: 0 0 auto;
    grid-template-columns: repeat(5, 120px);
    gap: 6px;
    border-left: 1px solid rgba(201, 195, 172, 0.14);
    padding-left: 10px;
  }

  .ucell { padding: 6px 4px 7px; }
  .uchever { width: 42px; height: 38px; }
  .up-name { font-size: 9px; }
  .up-pips i { width: 6px; height: 6px; }
  .up-cost { font-size: 13px; }

  .deck-filler {
    display: block;
    flex: 1 1 auto;
    min-width: 0;
    border: 1px solid rgba(201, 195, 172, 0.18);
    box-shadow: inset 0 0 0 1px rgba(13, 15, 9, 0.6);
  }
}

@media (min-width: 1300px) and (min-height: 600px) {
  .stamp-inner {
    width: min(86%, 1200px);
  }
  .stamp-word {
    font-size: clamp(80px, 8.5vw, 150px);
  }
}
