:root {
  color-scheme: light;
  --ink: #111827;
  --night: #17202b;
  --panel: #fbf3df;
  --paper: #fffaf0;
  --paper-deep: #ead8b5;
  --line: #6b5a46;
  --muted: #6f6253;
  --red: #b6422f;
  --red-dark: #7d271f;
  --teal: #167a78;
  --teal-dark: #0f5556;
  --gold: #d9a441;
  --green: #2f7d52;
  --shadow: 0 18px 45px rgba(16, 24, 39, 0.22);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: "Hiragino Sans", "Yu Gothic", system-ui, sans-serif;
  background:
    radial-gradient(circle at 12% 8%, rgba(217, 164, 65, 0.28), transparent 28%),
    radial-gradient(circle at 88% 12%, rgba(22, 122, 120, 0.28), transparent 26%),
    linear-gradient(145deg, #17202b 0%, #26313c 44%, #5b3f32 100%);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.topbar {
  width: min(1200px, calc(100% - 28px));
  margin: 0 auto;
  padding: 28px 0 18px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: end;
  color: #fffaf0;
}

.eyebrow,
.label {
  margin: 0 0 8px;
  color: var(--red);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.topbar .eyebrow {
  color: #f5c76a;
}

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

h1 {
  margin-bottom: 8px;
  font-size: clamp(34px, 7vw, 72px);
  line-height: 0.95;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 12px;
  font-size: 21px;
  line-height: 1.25;
}

.lead {
  max-width: 680px;
  margin-bottom: 0;
  color: #efe3ca;
  line-height: 1.75;
}

.score-strip {
  display: grid;
  grid-template-columns: repeat(3, 98px);
  gap: 8px;
}

.score-strip div {
  min-height: 78px;
  padding: 12px 10px;
  border: 1px solid rgba(255, 250, 240, 0.22);
  border-radius: 8px;
  background: rgba(12, 18, 26, 0.42);
  text-align: center;
  backdrop-filter: blur(8px);
}

.score-strip span {
  display: block;
  color: #f5c76a;
  font-size: 26px;
  font-weight: 900;
}

.score-strip small {
  color: #e9dbc0;
  font-size: 11px;
  font-weight: 700;
}

.game-shell {
  width: min(1200px, calc(100% - 28px));
  margin: 0 auto 48px;
  display: grid;
  grid-template-columns: minmax(230px, 0.85fr) minmax(320px, 1.45fr) minmax(260px, 0.9fr);
  grid-template-areas:
    "job press controls"
    "chronicle press impact";
  gap: 14px;
  align-items: stretch;
}

.panel,
.press-area {
  border: 1px solid rgba(65, 48, 34, 0.32);
  border-radius: 8px;
  background: rgba(251, 243, 223, 0.96);
  box-shadow: var(--shadow);
}

.panel {
  padding: 20px;
}

.job-panel {
  grid-area: job;
}

.controls-panel {
  grid-area: controls;
}

.chronicle-panel {
  grid-area: chronicle;
}

.impact-panel {
  grid-area: impact;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.year-badge {
  flex: 0 0 auto;
  padding: 6px 9px;
  border-radius: 999px;
  color: #fff8e8;
  background: var(--teal-dark);
  font-size: 11px;
  font-weight: 900;
}

.job-text {
  color: var(--muted);
  line-height: 1.75;
}

.target-card {
  display: grid;
  gap: 4px;
  margin: 18px 0;
  padding: 16px;
  border-radius: 8px;
  color: #fffaf0;
  background:
    linear-gradient(135deg, rgba(17, 24, 39, 0.96), rgba(84, 52, 34, 0.96)),
    repeating-linear-gradient(90deg, transparent 0 18px, rgba(255, 255, 255, 0.04) 18px 20px);
}

.target-card span,
.target-card small {
  color: #d5c4a7;
  font-size: 12px;
  font-weight: 700;
}

.target-card strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(32px, 7vw, 58px);
  letter-spacing: 0.08em;
}

.step-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 20px;
  color: var(--line);
  line-height: 1.55;
}

.step-list li.done {
  color: var(--green);
  font-weight: 800;
}

.press-area {
  grid-area: press;
  position: relative;
  min-height: 680px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 250, 240, 0.94), rgba(232, 215, 179, 0.94)),
    repeating-linear-gradient(90deg, rgba(74, 57, 39, 0.04) 0 2px, transparent 2px 18px);
}

.work-light {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 48% 15%, rgba(255, 234, 171, 0.8), transparent 32%);
  pointer-events: none;
}

.press-scene {
  position: relative;
  min-height: 610px;
  padding: 38px 28px 22px;
}

.press-frame {
  position: relative;
  height: 420px;
  max-width: 520px;
  margin: 0 auto;
}

.press-frame::before,
.press-frame::after {
  content: "";
  position: absolute;
  top: 72px;
  bottom: 24px;
  width: 34px;
  border-radius: 8px;
  background: linear-gradient(90deg, #4d3327, #7a4f38 45%, #322017);
  box-shadow: inset 8px 0 12px rgba(255, 255, 255, 0.09), inset -9px 0 10px rgba(0, 0, 0, 0.22);
}

.press-frame::before {
  left: 48px;
}

.press-frame::after {
  right: 48px;
}

.crossbar {
  position: absolute;
  top: 74px;
  left: 38px;
  right: 38px;
  height: 42px;
  border-radius: 8px;
  background: linear-gradient(180deg, #7e563f, #3e281d);
  box-shadow: inset 0 8px 10px rgba(255, 255, 255, 0.08);
}

.screw {
  position: absolute;
  z-index: 3;
  top: 10px;
  left: 50%;
  width: 56px;
  height: 170px;
  transform: translateX(-50%);
  border-radius: 999px;
  background:
    repeating-linear-gradient(165deg, #31231e 0 8px, #6a4937 8px 14px),
    linear-gradient(90deg, #31231e, #8a6248, #31231e);
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.24);
}

.screw span {
  position: absolute;
  left: 50%;
  width: 122px;
  height: 12px;
  border-radius: 999px;
  transform: translateX(-50%);
  background: #37231a;
}

.screw span:nth-child(1) { top: 4px; }
.screw span:nth-child(2) { top: 30px; width: 92px; }
.screw span:nth-child(3) { top: 58px; width: 112px; }

.platen {
  position: absolute;
  z-index: 2;
  top: 178px;
  left: 50%;
  width: min(58%, 280px);
  height: 44px;
  transform: translateX(-50%);
  border-radius: 8px;
  background: linear-gradient(180deg, #3c2a21, #1c1513);
  box-shadow: 0 14px 18px rgba(0, 0, 0, 0.22);
  transition: transform 0.18s ease;
}

.platen.press {
  transform: translate(-50%, 52px);
}

.bed {
  position: absolute;
  left: 78px;
  right: 78px;
  bottom: 88px;
  min-height: 95px;
  padding: 18px;
  border-radius: 8px;
  background:
    linear-gradient(180deg, #24201c, #141210),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.06) 0 8px, transparent 8px 16px);
  box-shadow: 0 16px 26px rgba(0, 0, 0, 0.28);
}

.type-line {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.type-slot,
.type-block {
  width: 40px;
  height: 48px;
  display: inline-grid;
  place-items: center;
  border-radius: 5px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 24px;
  font-weight: 900;
  line-height: 1;
}

.type-slot {
  border: 2px dashed rgba(235, 220, 190, 0.36);
  color: rgba(235, 220, 190, 0.65);
}

.type-block {
  color: #1b1714;
  background: linear-gradient(180deg, #d4c5a8, #8f7d61);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.4), inset 0 -4px 0 rgba(0, 0, 0, 0.16);
}

.lever {
  position: absolute;
  z-index: 1;
  right: 18px;
  top: 124px;
  width: 150px;
  height: 16px;
  border-radius: 999px;
  transform-origin: 18px 50%;
  transform: rotate(-24deg);
  background: linear-gradient(90deg, #2d1d16, #9a6a45);
  transition: transform 0.18s ease;
}

.lever.pull {
  transform: rotate(26deg);
}

.paper-stack {
  max-width: 320px;
  margin: 10px auto 0;
  transform: rotate(-1deg);
}

.printed-sheet {
  position: relative;
  min-height: 196px;
  padding: 18px;
  border: 1px solid #d0b98e;
  border-radius: 4px;
  background:
    linear-gradient(180deg, rgba(255, 252, 241, 0.96), rgba(246, 233, 203, 0.96)),
    repeating-linear-gradient(0deg, transparent 0 25px, rgba(78, 58, 34, 0.08) 25px 26px);
  box-shadow: 0 18px 34px rgba(0, 0, 0, 0.2);
}

.printed-sheet::before,
.printed-sheet::after {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px solid rgba(130, 91, 50, 0.24);
  pointer-events: none;
}

.sheet-title {
  color: var(--red-dark);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 18px;
  font-weight: 900;
}

.sheet-word {
  margin: 22px 0 14px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 34px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-align: center;
}

.sheet-word.faint {
  color: rgba(17, 24, 39, 0.42);
}

.sheet-word.blotted {
  text-shadow: 1px 0 rgba(17, 24, 39, 0.38), -1px 1px rgba(17, 24, 39, 0.28);
}

.sheet-lines {
  display: grid;
  gap: 9px;
}

.sheet-lines span {
  display: block;
  height: 7px;
  border-radius: 999px;
  background: rgba(57, 42, 26, 0.24);
}

.sheet-lines span:nth-child(2) { width: 76%; }
.sheet-lines span:nth-child(3) { width: 92%; }
.sheet-lines span:nth-child(4) { width: 64%; }
.sheet-lines span:nth-child(5) { width: 82%; }

.fact-ribbon {
  position: relative;
  z-index: 2;
  margin: 0 24px 24px;
  padding: 14px 16px;
  border-left: 4px solid var(--teal);
  border-radius: 7px;
  color: #f9edcf;
  background: rgba(23, 32, 43, 0.92);
  line-height: 1.65;
}

.control-mount {
  display: grid;
  gap: 14px;
}

.tray {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(44px, 1fr));
  gap: 8px;
}

.letter-btn {
  min-height: 46px;
  border: 1px solid rgba(84, 58, 34, 0.32);
  border-radius: 7px;
  color: #1b1714;
  background: linear-gradient(180deg, #e7d8bd, #b8a17b);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 22px;
  font-weight: 900;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.42);
}

.letter-btn:disabled {
  opacity: 0.42;
  cursor: default;
}

.slots {
  min-height: 62px;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
}

.hint {
  color: var(--muted);
  line-height: 1.65;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.primary-btn,
.soft-btn,
.danger-btn,
.text-btn {
  min-height: 42px;
  border-radius: 8px;
  font-weight: 900;
}

.primary-btn {
  border: 1px solid var(--teal-dark);
  color: #fff;
  background: linear-gradient(180deg, var(--teal), var(--teal-dark));
  box-shadow: 0 10px 22px rgba(15, 85, 86, 0.24);
}

.soft-btn {
  border: 1px solid rgba(84, 58, 34, 0.28);
  color: #3e2d22;
  background: #f4e5c7;
}

.danger-btn {
  border: 1px solid var(--red-dark);
  color: #fff;
  background: linear-gradient(180deg, var(--red), var(--red-dark));
}

.text-btn {
  border: 0;
  color: var(--teal-dark);
  background: transparent;
}

.primary-btn,
.soft-btn,
.danger-btn {
  padding: 0 14px;
}

.setting {
  display: grid;
  gap: 7px;
}

.setting label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--line);
  font-size: 13px;
  font-weight: 800;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--teal);
}

.meter {
  position: relative;
  height: 16px;
  border-radius: 999px;
  background: #ddcaa4;
  overflow: hidden;
}

.meter span {
  position: absolute;
  top: 0;
  bottom: 0;
  border-radius: 999px;
  background: rgba(47, 125, 82, 0.42);
}

.timing-track {
  position: relative;
  height: 42px;
  border-radius: 999px;
  background: linear-gradient(90deg, #c95b4b, #e6cf8b 25%, #45a16f 50%, #e6cf8b 75%, #c95b4b);
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}

.timing-marker {
  position: absolute;
  top: 5px;
  width: 10px;
  height: 32px;
  border-radius: 999px;
  background: #111827;
  box-shadow: 0 0 0 3px rgba(255, 250, 240, 0.7);
}

.proof-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(44px, 1fr));
  gap: 8px;
}

.proof-letter {
  min-height: 56px;
  border: 1px solid rgba(84, 58, 34, 0.32);
  border-radius: 7px;
  color: #111827;
  background: #fffaf0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 24px;
  font-weight: 900;
}

.proof-letter.found {
  color: #fff;
  background: var(--green);
}

.chronicle {
  display: grid;
  gap: 10px;
}

.chronicle-item {
  padding: 10px 12px;
  border-left: 3px solid var(--gold);
  border-radius: 6px;
  background: rgba(255, 250, 240, 0.64);
  color: var(--line);
  line-height: 1.55;
}

.chronicle-item strong {
  color: var(--red-dark);
}

.impact-grid {
  display: grid;
  gap: 10px;
}

.impact-grid div {
  padding: 12px;
  border-radius: 7px;
  background: rgba(255, 250, 240, 0.66);
}

.impact-grid strong,
.impact-grid span {
  display: block;
}

.impact-grid strong {
  margin-bottom: 4px;
  color: var(--teal-dark);
}

.impact-grid span {
  color: var(--muted);
  line-height: 1.55;
}

.result-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  border-radius: 8px;
  color: #fffaf0;
  background: linear-gradient(135deg, #111827, #1e4b4b);
}

.result-card strong {
  color: #f5c76a;
  font-size: 36px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 10;
  max-width: min(420px, calc(100% - 28px));
  padding: 12px 16px;
  border-radius: 999px;
  color: #fff;
  background: rgba(17, 24, 39, 0.94);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translate(-50%, 20px);
  transition: opacity 0.18s, transform 0.18s;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 980px) {
  .topbar {
    grid-template-columns: 1fr;
  }

  .score-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .game-shell {
    grid-template-columns: 1fr;
    grid-template-areas:
      "press"
      "job"
      "controls"
      "chronicle"
      "impact";
  }

  .press-area {
    min-height: auto;
  }

  .press-scene {
    min-height: 560px;
  }
}

@media (max-width: 540px) {
  .topbar,
  .game-shell {
    width: min(100% - 18px, 1200px);
  }

  .topbar {
    padding-top: 18px;
  }

  .score-strip div {
    min-height: 68px;
    padding: 10px 6px;
  }

  .score-strip span {
    font-size: 22px;
  }

  .panel {
    padding: 16px;
  }

  .press-scene {
    min-height: 490px;
    padding: 24px 8px 12px;
  }

  .press-frame {
    height: 360px;
  }

  .press-frame::before { left: 26px; }
  .press-frame::after { right: 26px; }
  .crossbar { left: 18px; right: 18px; }
  .bed { left: 46px; right: 46px; }
  .lever { right: 0; width: 112px; }
  .type-slot,
  .type-block {
    width: 31px;
    height: 42px;
    font-size: 20px;
  }

  .fact-ribbon {
    margin: 0 12px 14px;
  }
}
