:root {
  --paper: #f7f1e4;
  --paper-deep: #eadfc9;
  --ink: #191714;
  --muted: #665d50;
  --brick: #9b3424;
  --brick-dark: #64291f;
  --moss: #4d6b57;
  --ochre: #b48131;
  --blueprint: #21394a;
  --line: rgba(25, 23, 20, 0.18);
  --shadow: 0 24px 70px rgba(57, 38, 18, 0.18);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(rgba(25, 23, 20, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(25, 23, 20, 0.035) 1px, transparent 1px),
    radial-gradient(circle at 16% 20%, rgba(155, 52, 36, 0.14), transparent 28%),
    var(--paper);
  background-size: 28px 28px, 28px 28px, 100% 100%, auto;
  font-family: "Noto Serif TC", "Songti TC", "PMingLiU", serif;
  letter-spacing: 0;
}

button {
  font: inherit;
}

.page-shell {
  min-height: 100vh;
  padding: 22px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  max-width: 1180px;
  margin: 0 auto 18px;
  border-bottom: 2px solid var(--ink);
  padding-bottom: 16px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  display: grid;
  width: 54px;
  aspect-ratio: 1;
  place-items: center;
  color: var(--paper);
  background: var(--brick);
  border: 2px solid var(--ink);
  box-shadow: 5px 5px 0 var(--ink);
  font-size: 1.55rem;
  font-weight: 900;
}

.eyebrow,
.screen-kicker {
  margin: 0;
  color: var(--brick-dark);
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.8rem, 4vw, 3.1rem);
  line-height: 0.95;
}

.status-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.status-strip span {
  border: 1px solid var(--line);
  background: rgba(255, 252, 245, 0.66);
  padding: 7px 10px;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 0.76rem;
  font-weight: 800;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 18px;
  max-width: 1180px;
  margin: 0 auto;
}

.workbench {
  min-height: 680px;
  display: grid;
  grid-template-rows: minmax(310px, 42vh) auto;
  border: 2px solid var(--ink);
  background: rgba(255, 252, 245, 0.72);
  box-shadow: var(--shadow);
}

.case-visual {
  position: relative;
  overflow: hidden;
  display: grid;
  place-items: end center;
  min-height: 310px;
  padding: 34px 20px 0;
  background:
    linear-gradient(135deg, transparent 0 52%, rgba(33, 57, 74, 0.1) 52% 53%, transparent 53%),
    linear-gradient(180deg, rgba(77, 107, 87, 0.2), rgba(234, 223, 201, 0.35));
}

.case-visual::before {
  content: "";
  position: absolute;
  inset: 24px;
  border: 1px dashed rgba(25, 23, 20, 0.28);
}

.facade {
  position: relative;
  width: min(430px, 72vw);
  height: 245px;
  border: 3px solid var(--ink);
  background: #bc6a4c;
  box-shadow: 12px 12px 0 rgba(25, 23, 20, 0.22);
}

.roof {
  position: absolute;
  left: -22px;
  right: -22px;
  top: -42px;
  height: 44px;
  clip-path: polygon(5% 100%, 50% 0, 95% 100%);
  border: 3px solid var(--ink);
  background: var(--blueprint);
}

.wall-grid {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(3, 1fr);
  opacity: 0.58;
}

.wall-grid span {
  border-right: 1px solid rgba(25, 23, 20, 0.24);
  border-bottom: 1px solid rgba(25, 23, 20, 0.24);
}

.window-row {
  position: absolute;
  inset: 54px 48px auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 28px;
}

.window-row i {
  height: 62px;
  border: 3px solid var(--ink);
  background: rgba(247, 241, 228, 0.84);
}

.door {
  position: absolute;
  left: 50%;
  bottom: -3px;
  width: 74px;
  height: 88px;
  transform: translateX(-50%);
  border: 3px solid var(--ink);
  border-bottom: 0;
  background: var(--brick-dark);
}

.scaffold {
  position: absolute;
  bottom: 0;
  width: 94px;
  height: 245px;
  border-left: 3px solid var(--ink);
  border-right: 3px solid var(--ink);
  background:
    linear-gradient(35deg, transparent 48%, var(--ink) 49% 51%, transparent 52%),
    linear-gradient(-35deg, transparent 48%, var(--ink) 49% 51%, transparent 52%);
  background-size: 72px 72px;
  opacity: 0.7;
}

.scaffold-left {
  left: 8%;
}

.scaffold-right {
  right: 8%;
}

.site-tag {
  position: absolute;
  right: 28px;
  bottom: 22px;
  max-width: min(280px, 58vw);
  border: 2px solid var(--ink);
  background: var(--paper);
  padding: 10px 12px;
  font-weight: 900;
  box-shadow: 5px 5px 0 var(--ink);
}

.screen-panel {
  padding: clamp(22px, 4vw, 42px);
}

h2 {
  margin-bottom: 12px;
  max-width: 820px;
  font-size: clamp(1.85rem, 4.2vw, 4.4rem);
  line-height: 0.98;
}

.screen-copy {
  max-width: 760px;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.8;
}

.action-area {
  display: grid;
  gap: 12px;
  margin-top: 24px;
}

.choice-button,
.primary-button,
.secondary-button {
  min-height: 58px;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  color: var(--ink);
  background: #fffaf0;
  padding: 14px 16px;
  text-align: left;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.choice-button:hover,
.primary-button:hover,
.secondary-button:hover {
  transform: translate(-2px, -2px);
  box-shadow: 5px 5px 0 var(--ink);
}

.choice-button strong,
.primary-button strong {
  display: block;
  margin-bottom: 4px;
  font-size: 1.02rem;
}

.choice-button span,
.primary-button span,
.secondary-button span {
  color: var(--muted);
  line-height: 1.5;
}

.primary-button {
  background: var(--brick);
  color: var(--paper);
}

.primary-button span {
  color: rgba(247, 241, 228, 0.82);
}

.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  min-height: 48px;
  background: transparent;
  font-weight: 900;
}

.case-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.case-card {
  display: grid;
  gap: 8px;
  min-height: 178px;
  align-content: start;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: #fffaf0;
  padding: 16px;
  text-align: left;
  cursor: pointer;
}

.case-card[data-cleared="true"] {
  background: rgba(77, 107, 87, 0.14);
}

.case-card:hover {
  box-shadow: 5px 5px 0 var(--ink);
}

.case-card b {
  font-size: 1.18rem;
}

.case-card small {
  color: var(--brick-dark);
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-weight: 900;
}

.case-card span {
  color: var(--muted);
  line-height: 1.55;
}

.ledger {
  border: 2px solid var(--ink);
  background: rgba(255, 252, 245, 0.82);
  box-shadow: var(--shadow);
  padding: 18px;
  align-self: start;
  position: sticky;
  top: 18px;
}

.metric-block {
  margin-bottom: 16px;
}

.metric-heading,
.logbook-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-weight: 900;
}

.metric-heading strong {
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 2rem;
}

.meter {
  height: 14px;
  border: 2px solid var(--ink);
  background: var(--paper-deep);
}

.meter span {
  display: block;
  width: 60%;
  height: 100%;
  background: linear-gradient(90deg, var(--brick), var(--moss));
  transition: width 260ms ease;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.metric-grid div {
  border: 1px solid var(--line);
  background: rgba(247, 241, 228, 0.72);
  padding: 12px;
}

.metric-grid span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.86rem;
}

.metric-grid strong {
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 1.45rem;
}

.icon-button {
  display: grid;
  width: 38px;
  aspect-ratio: 1;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: transparent;
  cursor: pointer;
}

.icon-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.logbook {
  border-top: 2px solid var(--ink);
  padding-top: 14px;
}

.logbook ol {
  display: grid;
  gap: 10px;
  max-height: 345px;
  margin: 14px 0 0;
  padding-left: 20px;
  overflow: auto;
}

.logbook li {
  color: var(--muted);
  line-height: 1.5;
}

.result-sheet {
  display: grid;
  gap: 14px;
  max-width: 760px;
}

.result-grade {
  width: fit-content;
  border: 3px solid var(--ink);
  background: var(--ochre);
  padding: 8px 13px;
  color: var(--paper);
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 2rem;
  font-weight: 900;
  box-shadow: 6px 6px 0 var(--ink);
}

@media (max-width: 920px) {
  .topbar,
  .game-layout {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .status-strip {
    justify-content: flex-start;
  }

  .game-layout {
    display: grid;
  }

  .ledger {
    position: static;
    order: -1;
  }

  .case-list {
    grid-template-columns: 1fr;
  }

  .scaffold-left {
    left: -18px;
  }

  .scaffold-right {
    right: -18px;
  }
}

@media (max-width: 560px) {
  .page-shell {
    padding: 12px;
  }

  .brand-mark {
    width: 46px;
  }

  .workbench {
    min-height: auto;
    grid-template-rows: 260px auto;
  }

  .facade {
    width: 74vw;
    height: 192px;
  }

  .window-row {
    inset: 44px 28px auto;
    gap: 16px;
  }

  .window-row i {
    height: 48px;
  }

  .door {
    width: 58px;
    height: 72px;
  }

  .scaffold {
    width: 64px;
    height: 202px;
  }

  .site-tag {
    right: 16px;
    bottom: 14px;
  }
}
