/*
  Planet Colony (星球殖民物语): the planet fills the window under the site bar. Supplies run
  along the top, the current goal sits top left, the panel for whatever you clicked opens on
  the right, tools along the bottom. Warm lamplight on dark glass.
*/

html,
body {
  height: 100%;
}

body.pc-body {
  margin: 0;
  overflow: hidden;
  color: var(--gh-ink);
  background:
    radial-gradient(ellipse 60% 55% at 50% 46%, rgba(120, 104, 70, 0.22), transparent 70%),
    radial-gradient(ellipse at 50% 50%, #161d2a 0%, #0c121d 52%, #060a12 100%);
  font-family: var(--gh-font-body);
  overscroll-behavior: none;
}

.pc-stage {
  --pc-gold: #ffcf5a;
  --pc-amber: #ff9f2e;
  --pc-me: #3d8bff;
  --pc-ok: #7dd87a;
  --pc-warn: #ffb547;
  --pc-bad: #ff6b57;
  --pc-glass: rgba(16, 15, 13, 0.8);
  --pc-line: rgba(255, 220, 160, 0.14);
  --pc-text: #f4efe4;
  --pc-dim: #b9b0a0;
  position: fixed;
  inset: 56px 0 0;
}

.pc-stage *,
.pc-stage *::before,
.pc-stage *::after {
  box-sizing: border-box;
}

#pcCanvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: pointer;
  touch-action: none;
  opacity: 0;
  transition: opacity 900ms ease;
}

.pc-stage.is-ready #pcCanvas {
  opacity: 1;
}

.pc-stage[data-mode="road"] #pcCanvas {
  cursor: crosshair;
}

.pc-stage.is-paused #pcCanvas {
  filter: saturate(0.5) brightness(0.78);
}

/* ---------- Glass ---------- */

.pc-res,
.pc-time,
.pc-goal,
.pc-panel,
.pc-dock,
.pc-mode,
.pc-toast,
.pc-tip,
.pc-sheet,
.pc-card {
  border: 1px solid var(--pc-line);
  background: var(--pc-glass);
  box-shadow: 0 18px 40px -18px rgba(0, 0, 0, 0.85), inset 0 1px 0 rgba(255, 230, 190, 0.07);
  -webkit-backdrop-filter: blur(10px) saturate(1.2);
  backdrop-filter: blur(10px) saturate(1.2);
  color: var(--pc-text);
}

.pc-stage button {
  font: inherit;
  color: inherit;
}

.pc-stage :focus-visible {
  outline: 2px solid var(--pc-gold);
  outline-offset: 2px;
}

/* ---------- Top: supplies and clock ---------- */

.pc-top {
  position: absolute;
  top: 10px;
  left: 14px;
  right: 14px;
  display: flex;
  justify-content: center;
  gap: 8px;
  pointer-events: none;
}

.pc-res,
.pc-time {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  border-radius: 12px;
  pointer-events: auto;
}

.pc-res span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-radius: 8px;
  white-space: nowrap;
}

.pc-res i {
  width: 9px;
  height: 9px;
  border-radius: 3px;
  background: var(--c);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.25);
}

.pc-res em {
  color: var(--pc-dim);
  font-size: 0.74rem;
  font-style: normal;
}

.pc-res b {
  font-family: var(--gh-font-display);
  font-size: 1.05rem;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}

.pc-time {
  position: absolute;
  right: 0;
  top: 0;
}

.pc-time time {
  padding: 0 8px 0 6px;
  color: var(--pc-dim);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}

.pc-time button {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
}

.pc-time button:hover {
  background: rgba(255, 230, 190, 0.08);
}

.pc-time svg {
  width: 19px;
  height: 19px;
}

.pc-time [data-act="speed"] span {
  font-size: 0.82rem;
  font-weight: 700;
}

.pc-i-play,
.pc-time [data-act="pause"][aria-pressed="true"] .pc-i-pause {
  display: none;
}

.pc-time [data-act="pause"][aria-pressed="true"] .pc-i-play {
  display: inline;
}

.pc-time [data-act="pause"][aria-pressed="true"] {
  color: var(--pc-gold);
}

.pc-time [data-act="sound"][aria-pressed="false"] .pc-wave {
  display: none;
}

/* ---------- Goal (top left) ---------- */

.pc-goal {
  position: absolute;
  top: 62px;
  left: 14px;
  display: grid;
  gap: 6px;
  width: min(300px, calc(100% - 28px));
  padding: 12px 14px 14px;
  border-radius: 14px;
}

.pc-goal header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.pc-goal small {
  color: var(--pc-gold);
  font-size: 0.74rem;
  font-weight: 700;
}

.pc-goal header button {
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--pc-dim);
  cursor: pointer;
}

.pc-goal header svg {
  width: 18px;
  height: 18px;
  transition: transform 200ms ease;
}

.pc-goal h2 {
  margin: 0;
  font-family: var(--gh-font-display);
  font-size: 1.35rem;
  font-weight: 400;
  line-height: 1.15;
}

.pc-goal p {
  margin: 0;
  color: var(--pc-dim);
  font-size: 0.84rem;
  line-height: 1.55;
}

.pc-look {
  justify-self: start;
  margin-top: 2px;
  padding: 7px 12px;
  border: 1px solid rgba(255, 207, 90, 0.5);
  border-radius: 8px;
  background: rgba(255, 207, 90, 0.12);
  color: var(--pc-gold) !important;
  font-size: 0.82rem !important;
  font-weight: 700 !important;
  cursor: pointer;
}

.pc-look:hover {
  background: rgba(255, 207, 90, 0.22);
}

.pc-goal.is-folded p,
.pc-goal.is-folded .pc-look,
.pc-goal.is-auto-folded p,
.pc-goal.is-auto-folded .pc-look {
  display: none;
}

.pc-goal.is-folded header svg,
.pc-goal.is-auto-folded header svg {
  transform: rotate(-90deg);
}

/* ---------- Panel (right) ---------- */

.pc-panel {
  position: absolute;
  top: 62px;
  right: 14px;
  max-height: calc(100% - 150px);
  width: min(350px, calc(100% - 28px));
  padding: 16px 16px 18px;
  overflow-y: auto;
  border-radius: 16px;
  visibility: hidden;
  opacity: 0;
  transform: translateX(12px);
  transition: opacity 180ms ease, transform 180ms ease, visibility 180ms;
  scrollbar-width: thin;
}

.pc-panel.is-open {
  visibility: visible;
  opacity: 1;
  transform: none;
}

.pc-close {
  position: absolute;
  top: 10px;
  right: 10px;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--pc-dim);
  cursor: pointer;
}

.pc-close:hover {
  background: rgba(255, 230, 190, 0.08);
  color: var(--pc-text);
}

.pc-close svg {
  width: 18px;
  height: 18px;
}

.pc-panel h2,
.pc-sheet h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 30px 6px 0;
  font-family: var(--gh-font-display);
  font-size: 1.45rem;
  font-weight: 400;
  line-height: 1.15;
}

.pc-panel h2 small {
  color: var(--pc-dim);
  font-family: var(--gh-font-body);
  font-size: 0.74rem;
  font-weight: 600;
}

.pc-panel h3,
.pc-sheet h3 {
  margin: 14px 0 6px;
  color: var(--pc-gold);
  font-size: 0.8rem;
  font-weight: 700;
}

.pc-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--c);
  box-shadow: 0 0 10px var(--c);
}

.pc-sub,
.pc-desc,
.pc-note {
  margin: 4px 0 8px;
  font-size: 0.84rem;
  line-height: 1.55;
}

.pc-desc,
.pc-note {
  color: var(--pc-dim);
}

.pc-note {
  padding: 7px 10px;
  border-radius: 8px;
  background: rgba(255, 230, 190, 0.05);
}

.pc-status {
  position: relative;
  margin: 6px 0 8px;
  padding: 8px 10px 8px 26px;
  border-radius: 9px;
  font-size: 0.86rem;
  font-weight: 600;
  line-height: 1.45;
}

.pc-status::before {
  content: "";
  position: absolute;
  top: 13px;
  left: 11px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.pc-status.is-ok {
  color: var(--pc-ok);
  background: rgba(125, 216, 122, 0.1);
}

.pc-status.is-wait {
  color: var(--pc-warn);
  background: rgba(255, 181, 71, 0.1);
}

.pc-status.is-bad {
  color: var(--pc-bad);
  background: rgba(255, 107, 87, 0.11);
}

.pc-row {
  display: grid;
  grid-template-columns: 5.2em 1fr auto;
  align-items: center;
  gap: 8px;
  margin: 6px 0;
  font-size: 0.84rem;
}

.pc-row > span:first-child {
  color: var(--pc-dim);
}

.pc-row b {
  font-variant-numeric: tabular-nums;
}

.pc-row small {
  grid-column: 2 / -1;
  margin-top: -4px;
  color: var(--pc-dim);
  font-size: 0.74rem;
}

.pc-bar {
  display: block;
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 230, 190, 0.1);
}

.pc-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #c98a00, var(--pc-gold));
}

.pc-check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
  font-size: 0.84rem;
  cursor: pointer;
}

.pc-check input {
  width: 16px;
  height: 16px;
  accent-color: var(--pc-gold);
}

.pc-builds {
  display: grid;
  gap: 6px;
}

.pc-build {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 2px 8px;
  padding: 9px 11px;
  border: 1px solid var(--pc-line);
  border-radius: 10px;
  background: rgba(255, 230, 190, 0.04);
  text-align: left;
  cursor: pointer;
  transition: background-color 140ms ease, border-color 140ms ease;
}

.pc-build:hover:not(:disabled) {
  border-color: rgba(255, 207, 90, 0.55);
  background: rgba(255, 207, 90, 0.1);
}

.pc-build b {
  font-size: 0.95rem;
}

.pc-build small {
  grid-column: 1;
  color: var(--pc-gold);
  font-size: 0.74rem;
}

.pc-build em {
  grid-column: 1 / -1;
  color: var(--pc-dim);
  font-size: 0.78rem;
  font-style: normal;
  line-height: 1.45;
}

.pc-build:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.pc-size {
  grid-row: 1;
  grid-column: 2;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
}

.pc-size.is-small {
  color: #1d1600;
  background: #ffd23f;
}

.pc-size.is-medium {
  color: #241200;
  background: #ff9f2e;
}

.pc-size.is-large {
  color: #fff;
  background: #e2483a;
}

.pc-size.is-mine {
  color: #1d1a16;
  background: #c9c1b2;
}

.pc-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.pc-actions button {
  flex: 1 1 auto;
  padding: 9px 12px;
  border: 1px solid var(--pc-line);
  border-radius: 9px;
  background: rgba(255, 230, 190, 0.06);
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
}

.pc-actions button:hover {
  background: rgba(255, 230, 190, 0.12);
}

.pc-actions .is-main {
  border-color: transparent;
  background: var(--pc-gold);
  color: #1d1600;
}

.pc-actions .is-main:hover {
  background: #ffdc7f;
}

.pc-actions .is-danger {
  color: #ffb3a8;
}

.pc-actions .is-attack {
  border-color: transparent;
  background: var(--pc-bad);
  color: #fff;
}

.pc-wares {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  font-size: 0.8rem;
}

.pc-wares.is-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
}

.pc-ware {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 7px;
  background: rgba(255, 230, 190, 0.06);
}

.pc-ware i {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--c);
}

.pc-ware b {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}

.pc-ranks {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin: 6px 0;
  font-size: 0.8rem;
}

.pc-rank {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  color: #1d1a16;
  font-size: 0.72rem;
  font-weight: 800;
}

.pc-rank.r0 { background: #9a9a9a; }
.pc-rank.r1 { background: #c08a4a; }
.pc-rank.r2 { background: #dfe6ee; }
.pc-rank.r3 { background: #ffcf3f; }
.pc-rank.r4 { background: #ff6b57; color: #fff; }

.pc-range {
  display: grid;
  gap: 6px;
  margin: 10px 0 4px;
  font-size: 0.86rem;
}

.pc-range input {
  width: 100%;
  accent-color: var(--pc-bad);
}

.pc-chain {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 8px 0;
  font-size: 0.82rem;
}

.pc-chain span {
  padding: 5px 9px;
  border-radius: 8px;
  background: rgba(255, 230, 190, 0.07);
}

.pc-chain i {
  color: var(--pc-gold);
  font-style: normal;
}

.pc-tools {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 5px;
}

.pc-tool {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 4px 4px 9px;
  border-radius: 8px;
  background: rgba(255, 230, 190, 0.06);
  font-size: 0.8rem;
}

.pc-tool b {
  margin-left: auto;
}

.pc-tool button {
  padding: 3px 8px;
  border: 0;
  border-radius: 6px;
  background: rgba(255, 207, 90, 0.18);
  color: var(--pc-gold);
  font-size: 0.74rem;
  font-weight: 800;
  cursor: pointer;
}

.pc-help {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 18px;
  font-size: 0.86rem;
  line-height: 1.55;
}

/* ---------- Dock, mode line, toasts, tip ---------- */

.pc-dock {
  position: absolute;
  left: 50%;
  bottom: calc(14px + env(safe-area-inset-bottom));
  display: flex;
  gap: 2px;
  max-width: calc(100% - 20px);
  padding: 5px;
  overflow-x: auto;
  border-radius: 16px;
  transform: translateX(-50%);
  scrollbar-width: none;
}

.pc-dock::-webkit-scrollbar {
  display: none;
}

.pc-dock button {
  display: inline-flex;
  flex: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 58px;
  height: 56px;
  padding: 4px 8px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  color: var(--pc-dim);
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
}

.pc-dock svg {
  width: 24px;
  height: 24px;
}

.pc-dock button:hover {
  color: var(--pc-text);
  background: rgba(255, 230, 190, 0.07);
}

.pc-dock [aria-pressed="true"] {
  border-color: var(--pc-gold);
  color: var(--pc-text);
  background: rgba(255, 207, 90, 0.13);
}

.pc-mode {
  position: absolute;
  left: 50%;
  bottom: calc(84px + env(safe-area-inset-bottom));
  max-width: min(560px, calc(100% - 28px));
  margin: 0;
  padding: 9px 16px;
  border-color: rgba(255, 207, 90, 0.4);
  border-radius: 999px;
  font-size: 0.86rem;
  text-align: center;
  transform: translateX(-50%);
}

.pc-mode[hidden] {
  display: none;
}

.pc-toasts {
  position: absolute;
  top: 62px;
  left: 50%;
  display: grid;
  justify-items: center;
  gap: 6px;
  width: min(420px, calc(100% - 700px));
  min-width: 260px;
  margin: 0;
  padding: 0;
  list-style: none;
  transform: translateX(-50%);
  pointer-events: none;
}

.pc-toast {
  padding: 7px 14px;
  border-left: 3px solid var(--pc-dim);
  border-radius: 10px;
  font-size: 0.84rem;
  line-height: 1.4;
  pointer-events: auto;
  animation: pc-in 240ms ease both;
  transition: opacity 700ms ease;
}

.pc-toast button {
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
}

.pc-toast button:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.pc-toast.is-good {
  border-left-color: var(--pc-ok);
}

.pc-toast.is-warn {
  border-left-color: var(--pc-warn);
}

.pc-toast.is-bad {
  border-left-color: var(--pc-bad);
}

.pc-toast.is-old {
  opacity: 0;
}

@keyframes pc-in {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
}

.pc-tip {
  position: absolute;
  top: 0;
  left: 0;
  padding: 4px 9px;
  border-radius: 7px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
}

.pc-tip[hidden] {
  display: none;
}

/* ---------- Sheet (stock, economy, military, help) ---------- */

.pc-sheet {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(640px, calc(100% - 28px));
  max-height: calc(100% - 140px);
  padding: 18px 20px 20px;
  overflow-y: auto;
  border-radius: 18px;
  transform: translate(-50%, -50%);
}

.pc-sheet[hidden] {
  display: none;
}

.pc-sheet header .pc-close {
  top: 14px;
  right: 14px;
}

/* ---------- Start and end cards ---------- */

.pc-card {
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  gap: 14px;
  width: min(560px, calc(100% - 28px));
  max-height: calc(100% - 28px);
  padding: 26px 28px 22px;
  overflow-y: auto;
  border-radius: 20px;
  background: rgba(14, 13, 11, 0.86);
  transform: translate(-50%, -50%);
  animation: pc-card-in 420ms ease both;
}

.pc-card[hidden] {
  display: none;
}

@keyframes pc-card-in {
  from {
    opacity: 0;
    transform: translate(-50%, calc(-50% + 12px));
  }
}

.pc-card h1,
.pc-card h2 {
  justify-self: start;
  margin: 0;
  font-family: var(--gh-font-display);
  font-size: clamp(2.3rem, 7vw, 3.3rem);
  font-weight: 400;
  line-height: 1.02;
  background: linear-gradient(100deg, #fff1c9 0%, var(--pc-gold) 40%, #f0a64a 75%, #b7743a 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.pc-end:not(.is-won) h2 {
  background: linear-gradient(100deg, #ffd2c9, var(--pc-bad) 60%, #8a2a22);
  -webkit-background-clip: text;
  background-clip: text;
}

.pc-lede {
  margin: 0;
  font-size: 0.97rem;
  line-height: 1.65;
}

.pc-steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.pc-steps li {
  display: grid;
  align-content: start;
  gap: 3px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 230, 190, 0.05);
  counter-increment: step;
}

.pc-steps b {
  color: var(--pc-gold);
  font-family: var(--gh-font-display);
  font-size: 1.1rem;
  font-weight: 400;
}

.pc-steps b::before {
  content: counter(step) " ";
  color: var(--pc-dim);
  font-family: var(--gh-font-body);
  font-size: 0.8rem;
  font-weight: 700;
}

.pc-steps span {
  color: var(--pc-dim);
  font-size: 0.8rem;
  line-height: 1.45;
}

.pc-modes {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.pc-mode-b {
  display: grid;
  gap: 2px;
  padding: 11px 13px;
  border: 1px solid var(--pc-line);
  border-radius: 12px;
  background: rgba(255, 230, 190, 0.05);
  text-align: left;
  cursor: pointer;
  transition: border-color 140ms ease, background-color 140ms ease, transform 140ms ease;
}

.pc-mode-b:hover {
  border-color: rgba(255, 207, 90, 0.6);
  background: rgba(255, 207, 90, 0.1);
  transform: translateY(-1px);
}

.pc-mode-b b {
  font-size: 0.98rem;
}

.pc-mode-b span {
  color: var(--pc-dim);
  font-size: 0.78rem;
}

.pc-mode-b.is-peace {
  border-color: rgba(255, 207, 90, 0.5);
  background: rgba(255, 207, 90, 0.1);
}

.pc-go {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pc-go:not(:has(button:not([hidden]))) {
  display: none;
}

.pc-card.is-ingame .pc-steps {
  display: none;
}

/* A new game while one is in progress asks for a second click. */
.pc-stage [data-start].is-armed {
  border-color: rgba(255, 150, 90, 0.75);
  box-shadow: 0 0 0 1px rgba(255, 150, 90, 0.4);
}

.pc-stage [data-start].is-armed::after {
  content: attr(data-armed);
  display: block;
  margin-top: 4px;
  color: #ffb27a;
  font-size: 0.76rem;
  font-weight: 700;
}

.pc-primary,
.pc-secondary {
  flex: 1 1 180px;
  min-height: 46px;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: 12px;
  font-weight: 800 !important;
  cursor: pointer;
}

.pc-primary {
  background: var(--pc-gold);
  color: #1d1600 !important;
  box-shadow: 0 10px 26px -12px rgba(255, 207, 90, 0.9);
}

.pc-secondary {
  border-color: var(--pc-line);
  background: rgba(255, 230, 190, 0.06);
}

.pc-primary[hidden],
.pc-secondary[hidden] {
  display: none;
}

.pc-aside {
  margin: 0;
  color: var(--pc-dim);
  font-size: 0.8rem;
  text-align: center;
}

.pc-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 0;
}

.pc-stats div {
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 230, 190, 0.05);
}

.pc-stats dt {
  color: var(--pc-dim);
  font-size: 0.74rem;
}

.pc-stats dd {
  margin: 2px 0 0;
  font-family: var(--gh-font-display);
  font-size: 1.4rem;
}

/* While the menu is up, the interface steps back. */
.pc-stage.has-card .pc-top,
.pc-stage.has-card .pc-goal,
.pc-stage.has-card .pc-panel,
.pc-stage.has-card .pc-dock,
.pc-stage.has-card .pc-toasts,
.pc-stage.has-card .pc-mode,
.pc-stage.has-card .pc-tip {
  visibility: hidden;
  opacity: 0;
}

.pc-stage.is-peace [data-act="military"] {
  display: none;
}

/* ---------- Fallback ---------- */

.pc-fallback {
  position: absolute;
  inset: 50% auto auto 50%;
  display: grid;
  gap: 10px;
  width: min(420px, calc(100% - 40px));
  padding: 24px;
  border: 1px solid var(--pc-line);
  border-radius: 14px;
  background: rgba(14, 13, 11, 0.9);
  text-align: center;
  transform: translate(-50%, -50%);
}

.pc-fallback[hidden] {
  display: none;
}

.pc-fallback strong {
  font-family: var(--gh-font-display);
  font-size: 1.5rem;
  font-weight: 400;
}

/* ---------- Narrow screens ---------- */

@media (max-width: 1100px) {
  .pc-res em {
    display: none;
  }

  /* The supplies sit at the left so they never run under the clock on the right. */
  .pc-top {
    justify-content: flex-start;
  }

  .pc-res {
    max-width: calc(100% - 250px);
    overflow-x: auto;
    scrollbar-width: none;
  }

  .pc-toasts {
    top: auto;
    bottom: calc(84px + env(safe-area-inset-bottom));
    width: calc(100% - 28px);
  }
}

@media (max-width: 760px) {
  .pc-top {
    top: 8px;
    left: 8px;
    right: 8px;
    justify-content: flex-start;
  }

  .pc-res {
    max-width: calc(100% - 156px);
    overflow-x: auto;
    scrollbar-width: none;
  }

  .pc-res span {
    padding: 3px 6px;
  }

  .pc-res b {
    font-size: 0.92rem;
  }

  .pc-time time {
    display: none;
  }

  .pc-time button {
    width: 32px;
    height: 32px;
  }

  .pc-goal {
    top: 56px;
    left: 8px;
    width: calc(100% - 16px);
    padding: 9px 12px 10px;
  }

  .pc-goal h2 {
    font-size: 1.1rem;
  }

  .pc-panel {
    top: auto;
    left: 8px;
    right: 8px;
    bottom: calc(76px + env(safe-area-inset-bottom));
    width: auto;
    max-height: 52%;
    transform: translateY(12px);
  }

  .pc-dock {
    left: 8px;
    right: 8px;
    max-width: none;
    transform: none;
    bottom: calc(8px + env(safe-area-inset-bottom));
  }

  .pc-dock button {
    min-width: 52px;
    height: 52px;
  }

  .pc-mode {
    bottom: calc(70px + env(safe-area-inset-bottom));
  }

  .pc-card {
    padding: 20px 18px 18px;
  }

  .pc-steps,
  .pc-modes {
    grid-template-columns: 1fr;
  }

  .pc-stats {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  .pc-panel,
  .pc-toast,
  .pc-card,
  #pcCanvas {
    animation: none;
    transition: none;
  }
}

.pc-seg {
  display: flex;
  gap: 4px;
  padding: 3px;
  border-radius: 10px;
  background: rgba(255, 230, 190, 0.05);
}

.pc-seg button {
  flex: 1;
  padding: 7px 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

.pc-seg button[aria-pressed="true"] {
  border-color: var(--pc-gold);
  background: rgba(255, 207, 90, 0.14);
}

.pc-reach {
  grid-column: 1 / -1;
  display: block;
  margin-top: 2px;
  font-size: 0.76rem;
  font-weight: 700;
}

p.pc-reach {
  margin: 6px 0;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(255, 230, 190, 0.05);
}

.pc-reach.is-good {
  color: var(--pc-ok);
}

.pc-reach.is-poor {
  color: var(--pc-warn);
}

.pc-dock button {
  position: relative;
}

.pc-count {
  position: absolute;
  top: 4px;
  right: 6px;
  min-width: 18px;
  padding: 1px 5px;
  border-radius: 999px;
  background: var(--pc-bad);
  color: #fff;
  font-size: 0.66rem;
  font-weight: 800;
  line-height: 1.4;
}

.pc-count[hidden] {
  display: none;
}

.pc-log {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.pc-log li {
  display: grid;
  grid-template-columns: 3.6em 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-left: 3px solid var(--pc-dim);
  border-radius: 8px;
  background: rgba(255, 230, 190, 0.04);
  font-size: 0.84rem;
}

.pc-log li.is-good { border-left-color: var(--pc-ok); }
.pc-log li.is-warn { border-left-color: var(--pc-warn); }
.pc-log li.is-bad { border-left-color: var(--pc-bad); }

.pc-log time {
  color: var(--pc-dim);
  font-size: 0.74rem;
  font-variant-numeric: tabular-nums;
}

.pc-log button {
  padding: 4px 9px;
  border: 0;
  border-radius: 6px;
  background: rgba(255, 207, 90, 0.16);
  color: var(--pc-gold);
  font-size: 0.74rem;
  font-weight: 800;
  cursor: pointer;
}

.pc-chart {
  margin: 10px 0 0;
}

.pc-chart figcaption {
  margin-bottom: 4px;
  font-size: 0.82rem;
  font-weight: 700;
}

.pc-chart figcaption small {
  margin-left: 6px;
  color: var(--pc-dim);
  font-weight: 600;
}

.pc-chart svg {
  display: block;
  width: 100%;
  height: 90px;
  border-radius: 8px;
  background: rgba(255, 230, 190, 0.04);
}

.pc-legend {
  display: flex;
  gap: 14px;
  margin: 0 0 4px;
  font-size: 0.82rem;
}

.pc-legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 5px;
  border-radius: 3px;
  background: var(--c);
}

.pc-bars {
  display: grid;
  gap: 4px;
}

.pc-bars div {
  display: grid;
  grid-template-columns: 5.5em 1fr 2.5em;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
}

.pc-bars i {
  display: block;
  height: 9px;
  border-radius: 4px;
  background: var(--c);
}

.pc-bars b {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.pc-dist {
  display: grid;
  gap: 4px;
  margin: 8px 0;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255, 230, 190, 0.04);
}

.pc-dist b {
  font-size: 0.82rem;
}

.pc-dist label {
  display: grid;
  grid-template-columns: 6.5em 1fr 1.6em;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
}

.pc-dist input {
  width: 100%;
  accent-color: var(--pc-gold);
}

.pc-dist output {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ---------- New game setup ---------- */

.pc-custom {
  border: 1px solid var(--pc-line);
  border-radius: 12px;
  background: rgba(255, 230, 190, 0.03);
}

.pc-custom summary {
  padding: 11px 14px;
  font-weight: 800;
  cursor: pointer;
}

.pc-custom[open] summary {
  border-bottom: 1px solid var(--pc-line);
}

.pc-form {
  display: grid;
  gap: 10px;
  padding: 12px 14px 14px;
}

.pc-field {
  display: grid;
  gap: 5px;
}

.pc-field > span {
  color: var(--pc-dim);
  font-size: 0.78rem;
  font-weight: 700;
}

.pc-form .pc-seg {
  flex-wrap: wrap;
}

.pc-form .pc-seg button {
  flex: 1 0 auto;
}

.pc-seedrow {
  display: flex;
  gap: 6px;
}

.pc-range {
  grid-template-columns: 6.5em 1fr;
  align-items: center;
}

.pc-range input {
  width: 100%;
  accent-color: var(--pc-gold);
}

.pc-seedrow input {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--pc-line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.3);
  color: var(--pc-text);
  font: inherit;
  font-variant-numeric: tabular-nums;
}

.pc-seedrow button {
  padding: 8px 12px;
  border: 1px solid var(--pc-line);
  border-radius: 8px;
  background: rgba(255, 230, 190, 0.06);
  font-weight: 700;
  cursor: pointer;
}

.pc-hint {
  margin: 0;
  color: var(--pc-dim);
  font-size: 0.8rem;
  line-height: 1.5;
}

.pc-victory {
  margin: 4px 0 0;
  padding-top: 8px;
  border-top: 1px solid var(--pc-line);
  color: var(--pc-gold);
  font-size: 0.78rem;
  font-weight: 700;
}

/* ---------- Minimap and buildings overview ---------- */

.pc-mini {
  position: absolute;
  left: 14px;
  bottom: calc(14px + env(safe-area-inset-bottom));
  width: 240px;
  height: 120px;
  border: 1px solid var(--pc-line);
  border-radius: 12px;
  box-shadow: 0 18px 40px -18px rgba(0, 0, 0, 0.85);
  cursor: pointer;
  image-rendering: pixelated;
}

.pc-stage.has-card .pc-mini {
  visibility: hidden;
}

@media (max-width: 1180px) {
  .pc-mini {
    width: 180px;
    height: 90px;
    bottom: calc(82px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 760px) {
  .pc-mini {
    display: none;
  }
}

.pc-blist {
  display: grid;
  gap: 4px;
}

.pc-brow {
  display: grid;
  grid-template-columns: 7em 6.5em 5.5em 1fr;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(255, 230, 190, 0.04);
  font-size: 0.82rem;
}

.pc-brow span {
  color: var(--pc-dim);
  font-variant-numeric: tabular-nums;
}

.pc-bchips {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}

.pc-bchip {
  width: 14px;
  height: 14px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  cursor: pointer;
}

.pc-bchip.is-ok { background: var(--pc-ok); }
.pc-bchip.is-wait { background: var(--pc-warn); }
.pc-bchip.is-bad { background: var(--pc-bad); }

@media (max-width: 760px) {
  .pc-brow {
    grid-template-columns: 1fr auto;
  }

  .pc-bchips {
    grid-column: 1 / -1;
  }
}

/* ---------- Challenges ---------- */

.pc-custom summary small {
  margin-left: 6px;
  color: var(--pc-dim);
  font-weight: 600;
  font-size: 0.8rem;
}

.pc-chals {
  display: grid;
  gap: 6px;
  max-height: 330px;
  padding: 10px;
  overflow-y: auto;
}

.pc-chal {
  display: grid;
  gap: 3px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: rgba(255, 230, 190, 0.05);
  color: var(--pc-text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.pc-chal:hover,
.pc-chal:focus-visible {
  border-color: rgba(255, 207, 90, 0.45);
  background: rgba(255, 207, 90, 0.08);
}

.pc-chal.is-daily {
  border-color: rgba(255, 207, 90, 0.32);
  background: linear-gradient(100deg, rgba(255, 159, 46, 0.16), rgba(255, 230, 190, 0.04));
}

.pc-chal-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.pc-chal-meta {
  color: var(--pc-dim);
  font-size: 0.78rem;
}

.pc-chal-meta em {
  margin-left: 4px;
  color: var(--pc-gold);
  font-style: normal;
}

.pc-chal-desc {
  font-size: 0.82rem;
  line-height: 1.5;
}

.pc-stars {
  color: var(--pc-gold);
  letter-spacing: 1px;
  white-space: nowrap;
}

.pc-medal {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 207, 90, 0.08);
  font-size: 0.88rem;
  line-height: 1.55;
}

.pc-medal[hidden] {
  display: none;
}

.pc-medal .pc-stars {
  font-size: 1.1rem;
}

.pc-end-chart:empty {
  display: none;
}

.pc-end-chart .pc-legend {
  margin: 0;
}

/* ---------- Attack odds ---------- */

.pc-odds {
  margin: 0;
  font-size: 0.84rem;
  line-height: 1.5;
}

.pc-odds b.is-ok { color: var(--pc-ok); }
.pc-odds b.is-wait { color: var(--pc-warn); }
.pc-odds b.is-bad { color: var(--pc-bad); }

.pc-odds span {
  color: var(--pc-dim);
}

/* ---------- Transport priority and warehouse policy ---------- */

.pc-prio {
  display: grid;
  gap: 4px;
  margin: 0 0 6px;
  padding: 0;
  list-style: none;
}

.pc-prio li {
  display: grid;
  grid-template-columns: 1.6em 1fr auto auto;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-radius: 8px;
  background: rgba(255, 230, 190, 0.05);
  font-size: 0.84rem;
}

.pc-prio li > b {
  color: var(--pc-gold);
  font-variant-numeric: tabular-nums;
}

.pc-prio-name {
  display: flex;
  align-items: center;
  gap: 3px;
}

.pc-prio-name i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--c);
}

.pc-prio-name i:last-of-type {
  margin-right: 5px;
}

.pc-prio button {
  width: 30px;
  height: 26px;
  padding: 0;
  border: 1px solid var(--pc-line);
  border-radius: 6px;
  background: rgba(255, 230, 190, 0.06);
  color: var(--pc-text);
  font: inherit;
  cursor: pointer;
}

.pc-prio button:disabled {
  opacity: 0.3;
  cursor: default;
}

.pc-policy {
  display: grid;
  gap: 5px;
}

.pc-policy-row {
  display: grid;
  gap: 3px;
  font-size: 0.8rem;
}

.pc-policy-row > span {
  color: var(--pc-dim);
}

.pc-policy .pc-seg button {
  padding: 4px 6px;
  font-size: 0.74rem;
}

.pc-endtable {
  width: 100%;
  margin-top: 10px;
  border-collapse: collapse;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

.pc-endtable th,
.pc-endtable td {
  padding: 4px 6px;
  text-align: right;
  border-bottom: 1px solid var(--pc-line);
}

.pc-endtable thead th {
  color: var(--pc-dim);
  font-weight: 600;
}

.pc-endtable tbody th {
  text-align: left;
  font-weight: 700;
  white-space: nowrap;
}

.pc-endtable tbody th i {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 5px;
  border-radius: 50%;
  background: var(--c);
}

/* ---------- Random events ---------- */

.pc-weather {
  position: absolute;
  left: 50%;
  top: 46px;
  z-index: 6;
  transform: translateX(-50%);
  white-space: nowrap;
  margin: 0;
  padding: 5px 10px;
  border: 1px solid rgba(255, 207, 90, 0.35);
  border-radius: 10px;
  background: var(--pc-glass);
  color: var(--pc-text);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  pointer-events: auto;
}

.pc-weather[hidden] {
  display: none;
}

.pc-weather b {
  color: var(--pc-gold);
}

@media (min-width: 1101px) {
  .pc-stage.has-weather .pc-toasts {
    top: 92px;
  }
}

@media (max-width: 760px) {
  .pc-weather {
    top: 40px;
    padding: 3px 9px;
  }

  .pc-stage.has-weather .pc-goal {
    top: 84px;
  }
}

/* ---------- Guided tour ---------- */

.pc-tour-spot {
  position: absolute;
  z-index: 20;
  border: 2px solid var(--pc-gold);
  border-radius: 12px;
  box-shadow: 0 0 0 200vmax rgba(8, 7, 5, 0.5), 0 0 24px rgba(255, 207, 90, 0.55);
  pointer-events: none;
  transition: left 160ms ease, top 160ms ease, width 160ms ease, height 160ms ease;
}

.pc-tour-spot[hidden] {
  display: none;
}

.pc-tour-spot.is-round {
  border-radius: 50%;
  animation: pc-tour-pulse 1.4s ease-in-out infinite;
}

@keyframes pc-tour-pulse {
  50% { box-shadow: 0 0 0 200vmax rgba(8, 7, 5, 0.5), 0 0 36px rgba(255, 207, 90, 0.9); }
}

.pc-tour-bubble {
  position: absolute;
  z-index: 21;
  display: grid;
  gap: 8px;
  width: min(340px, calc(100% - 24px));
  padding: 14px 16px 12px;
  border: 1px solid rgba(255, 207, 90, 0.45);
  border-radius: 14px;
  background: rgba(20, 18, 14, 0.94);
  box-shadow: 0 18px 40px -16px rgba(0, 0, 0, 0.9);
  color: var(--pc-text);
}

.pc-tour-count {
  margin: 0;
  color: var(--pc-gold);
  font-size: 0.74rem;
  font-weight: 700;
}

.pc-tour-text {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.6;
}

.pc-tour-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pc-tour-actions button {
  padding: 7px 14px;
  border: 1px solid var(--pc-line);
  border-radius: 9px;
  background: rgba(255, 230, 190, 0.06);
  color: var(--pc-text);
  font: inherit;
  font-size: 0.84rem;
  cursor: pointer;
}

.pc-tour-actions .pc-tour-next {
  border-color: transparent;
  background: var(--pc-gold);
  color: #2a1d05;
  font-weight: 700;
}

.pc-tour-actions .pc-tour-quit {
  margin-left: auto;
  color: var(--pc-dim);
}

.pc-stage.has-card .pc-tour-spot,
.pc-stage.has-card .pc-tour-bubble {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .pc-tour-spot,
  .pc-tour-spot.is-round {
    transition: none;
    animation: none;
  }
}

/* ---------- Opening story ---------- */

.pc-story {
  position: absolute;
  inset: 0;
  z-index: 30;
  overflow: hidden;
}

.pc-stage.is-story > :not(.pc-story):not(canvas) {
  visibility: hidden;
}

.pc-story-pic {
  position: absolute;
  inset: 0;
  background: #07090c center / cover no-repeat;
  opacity: 0;
  transition: opacity 700ms ease;
}

.pc-story.has-pic .pc-story-pic {
  opacity: 1;
}

.pc-story-pic.is-moving {
  animation: pc-story-push 7s ease-out both;
}

@keyframes pc-story-push {
  from { transform: scale(1.06); }
  to { transform: scale(1); }
}

.pc-story-bar {
  position: absolute;
  left: 0;
  right: 0;
  height: 11vh;
  background: #000;
}

.pc-story-bar.is-top { top: 0; }
.pc-story-bar.is-bottom { bottom: 0; height: 24vh; background: linear-gradient(to top, #000 55%, rgba(0, 0, 0, 0)); }

.pc-story-caption {
  position: absolute;
  left: 50%;
  bottom: 9vh;
  width: min(760px, calc(100% - 40px));
  margin: 0;
  color: #f6efe0;
  font-size: clamp(1rem, 2.1vw, 1.35rem);
  line-height: 1.75;
  text-align: center;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.9);
  transform: translateX(-50%);
}

.pc-story-caption.is-in {
  animation: pc-story-caption 900ms ease both;
}

@keyframes pc-story-caption {
  from { opacity: 0; transform: translate(-50%, 8px); }
}

.pc-story-controls {
  position: absolute;
  right: 18px;
  bottom: 16px;
  left: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.pc-story-dots {
  display: flex;
  gap: 6px;
  margin-right: auto;
}

.pc-story-dots i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.28);
}

.pc-story-dots i.is-on {
  background: var(--pc-gold);
}

.pc-story-controls button {
  padding: 7px 16px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 9px;
  background: rgba(0, 0, 0, 0.35);
  color: #f6efe0;
  font: inherit;
  font-size: 0.86rem;
  cursor: pointer;
}

.pc-story-controls .pc-story-next {
  border-color: transparent;
  background: var(--pc-gold);
  color: #2a1d05;
  font-weight: 700;
}

@media (prefers-reduced-motion: reduce) {
  .pc-story-pic.is-moving,
  .pc-story-caption.is-in {
    animation: none;
  }
}

@media (max-aspect-ratio: 1/1) {
  .pc-story-pic {
    background-size: contain;
    background-position: center 38%;
  }
}

.pc-time [data-act="music"] .pc-mute-line {
  display: none;
}

.pc-time [data-act="music"][aria-pressed="false"] .pc-mute-line {
  display: inline;
}

.pc-time [data-act="music"][aria-pressed="false"] {
  opacity: 0.6;
}
