:root {
  color-scheme: light;
  --bg: #f2f0ea;
  --paper: #fffefa;
  --ink: #262521;
  --muted: #767168;
  --line: #ddd8cd;
  --accent: #34556a;
  --accent-dark: #203847;
  --red: #bf0000;
}

* { box-sizing: border-box; }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: linear-gradient(180deg, #f7f5ef 0%, var(--bg) 100%);
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  overflow-x: hidden;
}

.static-layer {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 20;
  opacity: 0;
  background:
    repeating-linear-gradient(to bottom, transparent 0 5px, rgba(0, 0, 0, 0.08) 6px),
    repeating-radial-gradient(circle at 28% 35%, rgba(0, 0, 0, 0.26) 0 1px, transparent 1px 4px);
  mix-blend-mode: multiply;
}

body.polluted .static-layer { opacity: 0.06; }
body.bad .static-layer { opacity: 0.18; }

.wrap {
  width: min(760px, calc(100vw - 28px));
  margin: 6vh auto;
}

.panel {
  position: relative;
  padding: clamp(22px, 4vw, 38px);
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 254, 250, 0.96);
  box-shadow: 0 18px 54px rgba(35, 31, 24, 0.12);
}

.kicker,
.counter,
.small,
.subtext,
.system-line {
  color: var(--muted);
}

.kicker {
  margin-bottom: 12px;
  font-size: 12px;
  letter-spacing: 0.14em;
}

h1,
h2 {
  margin: 0;
  line-height: 1.35;
  font-weight: 620;
}

h1 { font-size: clamp(28px, 5vw, 42px); }
h2 { font-size: clamp(21px, 3.5vw, 30px); }

.lead {
  max-width: 620px;
  margin: 20px 0;
  color: #4c4941;
  font-size: 16px;
  line-height: 1.85;
}

.notice {
  margin: 24px 0;
  padding: 16px 18px;
  border-left: 3px solid var(--accent);
  background: #f5f2ea;
  line-height: 1.75;
}

.notice p { margin: 0; }

.consent {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 18px;
  line-height: 1.65;
  font-size: 15px;
}

button {
  min-height: 42px;
  padding: 11px 18px;
  border: 0;
  border-radius: 999px;
  font: inherit;
  cursor: pointer;
  transition: opacity 140ms ease, background 140ms ease, border-color 140ms ease;
}

button:disabled { cursor: not-allowed; opacity: 0.42; }
.primary { color: #fff; background: var(--accent); }
.primary:hover:not(:disabled) { background: var(--accent-dark); }
.secondary { color: var(--accent-dark); background: #dfe9ee; }
.ghost { color: var(--muted); background: transparent; }
.hidden { display: none !important; }

.topbar {
  display: flex;
  gap: 20px;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 18px;
}

.counter {
  min-width: max-content;
  font-size: 13px;
}

.subtext {
  min-height: 28px;
  margin: 0 0 20px;
  line-height: 1.75;
  font-size: 14px;
}

.options {
  display: grid;
  gap: 10px;
  margin: 20px 0;
}

.option {
  width: 100%;
  padding: 15px 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.option:hover,
.option.selected {
  border-color: var(--accent);
  background: #eef4f6;
}

.option.corrupted {
  color: var(--red);
  border-color: rgba(191, 0, 0, 0.45);
  background: #fff6f6;
}

.system-line {
  min-height: 24px;
  margin: 16px 0 4px;
  font-size: 13px;
}

.nav {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  z-index: 50;
  width: min(520px, calc(100vw - 28px));
  transform: translateX(-50%);
  padding: 13px 16px;
  border: 1px solid rgba(52, 85, 106, 0.28);
  border-radius: 12px;
  background: rgba(255, 254, 250, 0.97);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.14);
  line-height: 1.65;
  font-size: 14px;
}

.red-flash {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #b90000;
  color: #fff;
  font-size: clamp(34px, 9vw, 96px);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-align: center;
  text-shadow: 3px 3px 0 #000;
}

.platform-modal {
  position: fixed;
  inset: 0;
  z-index: 75;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(23, 27, 30, 0.36);
}

.platform-box {
  width: min(520px, 100%);
  padding: 22px;
  border: 1px solid #cfc8ba;
  border-radius: 12px;
  background: #fffefa;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
}

.platform-title {
  margin-bottom: 12px;
  color: var(--accent-dark);
  font-weight: 700;
}

.platform-box p {
  margin: 0 0 18px;
  line-height: 1.75;
}

.platform-actions {
  display: grid;
  gap: 10px;
}

.error-screen {
  position: fixed;
  inset: 0;
  z-index: 80;
  padding: clamp(20px, 5vw, 56px);
  background: #080000;
  color: #ff1616;
  overflow: hidden;
}

.error-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(to bottom, transparent 0 7px, rgba(255, 0, 0, 0.12) 8px);
  animation: scan 420ms linear infinite;
}

.error-screen pre {
  position: relative;
  margin: 0;
  max-width: 980px;
  white-space: pre-wrap;
  font: clamp(15px, 2.2vw, 24px)/1.6 ui-monospace, SFMono-Regular, Consolas, monospace;
  text-shadow: 2px 0 #fff, -2px 0 #770000;
}

.error-screen.diary {
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 48%, rgba(255, 255, 255, 0.12), transparent 28%),
    #050000;
}

.error-screen.diary pre {
  width: min(780px, 92vw);
  color: #ffdfdf;
  font-family: "Microsoft JhengHei", "Noto Sans TC", system-ui, sans-serif;
  font-size: clamp(20px, 4vw, 44px);
  line-height: 1.75;
  letter-spacing: 0.04em;
  text-shadow: 3px 0 #b60000, -2px 0 #000;
  animation: diaryPulse 95ms steps(2, end) infinite, diaryGrow 980ms linear forwards;
}

.report-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 24px 0;
}

.report-grid div {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.report-grid span,
.report-grid strong { display: block; }
.report-grid span { margin-bottom: 6px; color: var(--muted); font-size: 13px; }
.recommendations { padding-left: 22px; line-height: 1.9; }

.downloaded {
  margin-top: 20px;
  padding: 18px;
  border: 1px solid rgba(191, 0, 0, 0.45);
  border-radius: 12px;
  background: #120909;
  color: #ffecec;
  white-space: pre-wrap;
  font: 14px/1.8 ui-monospace, SFMono-Regular, Consolas, monospace;
}

.glitch-text {
  color: var(--red);
  text-shadow: 2px 0 #2d6b83, -2px 0 #ffb1b1;
  animation: textBreak 480ms steps(2, end) 1;
}

.noise-text {
  display: inline-block;
  color: var(--red);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  letter-spacing: 0.04em;
  animation: textBreak 520ms steps(2, end) 2;
}

.ambient-text {
  position: absolute;
  right: clamp(14px, 5vw, 46px);
  bottom: 92px;
  z-index: 3;
  max-width: min(360px, 70vw);
  color: rgba(191, 0, 0, 0.82);
  font-size: 14px;
  line-height: 1.7;
  pointer-events: none;
  transform: translate(0, 0);
  animation: driftText 2.4s ease-in-out forwards;
}

.ambient-text.breaking {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  text-shadow: 1px 0 #fff, -1px 0 #6e0000;
}

.option.corrupted {
  animation: optionCrawl 1.6s steps(3, end) infinite;
}

@keyframes textBreak {
  0% { filter: blur(0); transform: translate(0); }
  35% { filter: blur(0.6px); transform: translate(-1px, 0); }
  68% { transform: translate(1px, 0); }
  100% { filter: blur(0); transform: translate(0); }
}

@keyframes scan {
  from { transform: translateY(-8px); }
  to { transform: translateY(8px); }
}

@keyframes driftText {
  0% { opacity: 0; transform: translate(10px, 6px); }
  18% { opacity: 1; }
  42% { transform: translate(-8px, -4px); }
  70% { transform: translate(5px, -12px); }
  100% { opacity: 0; transform: translate(-18px, -20px); }
}

@keyframes optionCrawl {
  0% { transform: translateX(0); }
  50% { transform: translateX(2px); }
  100% { transform: translateX(0); }
}

@keyframes diaryPulse {
  from { transform: translate(-2px, 1px) skewX(-1deg); filter: contrast(1.1); }
  to { transform: translate(2px, -1px) skewX(1deg); filter: contrast(1.6); }
}

@keyframes diaryGrow {
  from { opacity: 0.65; scale: 0.94; }
  45% { opacity: 1; scale: 1.06; }
  to { opacity: 0.92; scale: 1.18; }
}

@media (max-width: 680px) {
  .wrap { width: min(100vw - 18px, 760px); margin: 18px auto; }
  .panel { padding: 22px 16px; }
  .topbar { display: block; }
  .counter { margin-top: 10px; }
  .report-grid { grid-template-columns: 1fr; }
  .nav { flex-direction: column-reverse; }
  .nav button { width: 100%; }
}
