:root {
  --paper: #f2eee4;
  --paper-2: #fffdf7;
  --ink: #172025;
  --muted: #667078;
  --rule: #c9c6bb;
  --coral: #ff5a4f;
  --blue: #2878ff;
  --lime: #c7ef3d;
  --yellow: #ffd447;
  --dark: #162126;
  --shadow: 7px 7px 0 #172025;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: "Yu Gothic UI", "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
  overscroll-behavior: none;
}

body {
  min-height: 100svh;
  background-image:
    linear-gradient(#1720250a 1px, transparent 1px),
    linear-gradient(90deg, #1720250a 1px, transparent 1px);
  background-size: 28px 28px;
}

button, a { font: inherit; }
button { touch-action: manipulation; }
.hidden { display: none !important; }

.app-shell {
  width: min(1280px, 100%);
  margin: 0 auto;
  padding: 0 clamp(12px, 3vw, 40px) 36px;
}

.masthead {
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 3px solid var(--ink);
}

.wordmark {
  color: var(--ink);
  text-decoration: none;
  display: flex;
  align-items: baseline;
  gap: 7px;
  font-weight: 1000;
  letter-spacing: -.07em;
  font-size: clamp(1.25rem, 3vw, 1.8rem);
}

.wordmark b { color: var(--coral); }
.wordmark small { letter-spacing: .18em; font-size: .55rem; margin-left: 5px; }

.sound-btn {
  border: 2px solid var(--ink);
  background: var(--paper-2);
  color: var(--ink);
  padding: 8px 12px;
  font-size: .68rem;
  letter-spacing: .08em;
  font-weight: 900;
  cursor: pointer;
}

.screen { min-height: calc(100svh - 76px); }

.start-screen {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(30px, 6vw, 86px);
  align-items: center;
  padding: 54px 0 70px;
}

.kicker {
  margin: 0 0 13px;
  color: var(--blue);
  font-size: .72rem;
  font-weight: 1000;
  letter-spacing: .18em;
}

.start-copy h1,
.result-top h1 {
  margin: 0;
  font-size: clamp(3rem, 7.6vw, 6.4rem);
  line-height: .94;
  letter-spacing: -.095em;
  font-weight: 1000;
}

.start-copy h1 em { color: var(--coral); font-style: normal; }

.lead {
  max-width: 640px;
  margin: 25px 0;
  font-weight: 700;
  line-height: 1.85;
  color: #465158;
}

.three-rules {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 2px solid var(--ink);
  background: var(--paper-2);
  margin: 0 0 24px;
}

.three-rules div {
  display: flex;
  gap: 9px;
  padding: 12px 10px;
  border-right: 1px solid var(--ink);
}

.three-rules div:last-child { border-right: 0; }
.three-rules b { color: var(--coral); font-size: 1.3rem; line-height: 1; }
.three-rules span { font-size: .68rem; color: var(--muted); line-height: 1.4; }
.three-rules strong { display: block; color: var(--ink); font-size: .82rem; }

.primary {
  width: 100%;
  border: 2px solid var(--ink);
  background: var(--yellow);
  color: var(--ink);
  padding: 16px 18px;
  box-shadow: 5px 5px 0 var(--ink);
  font-weight: 1000;
  cursor: pointer;
  text-align: left;
  transition: transform .12s, box-shadow .12s;
}

.primary span { float: right; }
.primary:hover { transform: translate(-2px, -2px); box-shadow: 7px 7px 0 var(--ink); }
.primary:active { transform: translate(4px, 4px); box-shadow: 1px 1px 0 var(--ink); }
.best { min-height: 1.2em; margin: 16px 0 0; text-align: center; color: var(--muted); font-size: .72rem; font-weight: 800; }

.start-visual {
  position: relative;
  padding: 34px 28px 30px;
  border: 3px solid var(--ink);
  background: var(--paper-2);
  box-shadow: 12px 12px 0 var(--blue);
  transform: rotate(1deg);
}

.route-label { font-size: .68rem; font-weight: 1000; letter-spacing: .2em; border-bottom: 1px solid var(--rule); padding-bottom: 12px; }
.route { display: grid; grid-template-columns: 1fr auto 1fr auto 1fr; align-items: center; gap: 8px; margin: 40px 0 55px; }
.route > i { font-style: normal; font-size: 1.8rem; font-weight: 1000; }
.route-node { min-height: 142px; border: 2px solid var(--ink); padding: 13px 10px; display: flex; flex-direction: column; justify-content: space-between; }
.route-node span { font-size: .66rem; font-weight: 1000; }
.route-node b { font-size: clamp(.95rem, 2vw, 1.35rem); }
.route-node small { font-size: .63rem; font-weight: 800; }
.route-node.coral { background: #ffb4ad; }
.route-node.blue { background: #9ec0ff; }
.route-node.lime { background: var(--lime); }
.sample-ticket { position: absolute; right: 4%; bottom: 57px; width: 43%; padding: 13px; border: 2px solid var(--ink); background: var(--dark); color: white; transform: rotate(-5deg); box-shadow: 5px 5px 0 var(--coral); }
.sample-ticket span, .sample-ticket small { display: block; font-size: .63rem; }
.sample-ticket span { color: var(--yellow); font-weight: 900; }
.sample-ticket b { display: block; margin: 5px 0 8px; font-size: 1.05rem; }
.start-visual > p { margin: 0; font-size: .75rem; font-weight: 800; color: var(--muted); }

.game-screen { padding-top: 18px; }
.scoreboard { display: grid; grid-template-columns: 110px repeat(3, 1fr) auto; align-items: stretch; border: 2px solid var(--ink); background: var(--paper-2); }
.scoreboard > div { padding: 9px 14px; border-right: 1px solid var(--ink); }
.scoreboard small { display: block; font-size: .58rem; font-weight: 1000; color: var(--muted); letter-spacing: .1em; }
.scoreboard strong { font-size: 1.65rem; line-height: 1.1; }
.scoreboard span:not(#day) { margin-left: 3px; font-size: .65rem; font-weight: 900; }
.scoreboard .day-card { background: var(--ink); color: white; }
.scoreboard .day-card small { color: var(--lime); }
.scoreboard .day-card strong { font-size: 2rem; }
.scoreboard .day-card i { font-size: .7rem; font-style: normal; color: #aeb7bb; margin-left: 3px; }
.scoreboard > p { align-self: center; padding: 0 16px; font-size: .68rem; white-space: nowrap; }

.mission-strip { display: flex; gap: 15px; align-items: center; margin: 12px 0; padding: 9px 12px; background: var(--yellow); border: 2px solid var(--ink); font-size: .72rem; }
.mission-strip span { padding: 4px 8px; background: var(--ink); color: white; font-size: .61rem; font-weight: 1000; white-space: nowrap; }
.mission-strip b { letter-spacing: .02em; }

.director-layout { display: grid; grid-template-columns: minmax(0, 1fr) 238px; gap: 14px; }
.work-area { min-width: 0; display: grid; gap: 12px; }
.crew-panel, .policy-panel, .line-panel, .intel-panel section { border: 2px solid var(--ink); background: var(--paper-2); }
.crew-panel, .policy-panel, .line-panel { padding: 13px; }
.section-head { display: flex; justify-content: space-between; align-items: end; margin-bottom: 11px; }
.section-head p, .intel-panel section > p:first-child { margin: 0 0 3px; color: var(--blue); font-size: .57rem; font-weight: 1000; letter-spacing: .16em; }
.section-head h2, .intel-panel h2 { margin: 0; font-size: .96rem; }
.section-head > small { color: var(--muted); font-size: .62rem; font-weight: 800; text-align: right; }
.section-head.compact { margin-bottom: 8px; }

.crew-list { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.crew-card { position: relative; min-width: 0; border: 1px solid var(--ink); background: #f6f2e9; padding: 9px; cursor: pointer; text-align: left; color: var(--ink); }
.crew-card.selected { background: var(--ink); color: white; box-shadow: 3px 3px 0 var(--coral); }
.crew-card .avatar { display: inline-grid; place-items: center; width: 29px; height: 29px; margin-right: 6px; border-radius: 50%; background: var(--worker-color); color: var(--ink); font-size: .7rem; font-weight: 1000; vertical-align: middle; }
.crew-card b { font-size: .82rem; }
.crew-card > small { display: block; margin: 6px 0 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .59rem; opacity: .7; }
.skill-line { display: flex; gap: 3px; }
.skill-line i { flex: 1; height: 5px; background: var(--rule); }
.skill-line i.on { background: var(--worker-color); }
.crew-card.selected .skill-line i:not(.on) { background: #ffffff35; }
.crew-place { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; font-size: .59rem; font-weight: 1000; }
.combo { color: #49700a; }
.crew-card.selected .combo { color: var(--lime); }
.fatigue { color: #b52f27; }
.crew-card.selected .fatigue { color: #ff9d94; }

.mode-buttons { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.mode-button { border: 1px solid var(--ink); background: #f8f5ed; padding: 8px 10px; text-align: left; cursor: pointer; color: var(--ink); }
.mode-button b, .mode-button small { display: block; }
.mode-button b { font-size: .74rem; }
.mode-button small { margin-top: 3px; color: var(--muted); font-size: .56rem; line-height: 1.35; }
.mode-button.selected { background: var(--blue); color: white; box-shadow: 3px 3px 0 var(--ink); }
.mode-button.selected small { color: #e5edff; }

.pipeline { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.stage { position: relative; min-width: 0; border: 2px solid var(--ink); background: #f8f5ed; }
.stage:not(:last-child)::after { content: "→"; position: absolute; z-index: 4; right: -19px; top: 46%; width: 18px; height: 24px; display: grid; place-items: center; color: var(--ink); font-size: 1.2rem; font-weight: 1000; }
.stage-head { padding: 9px 10px; background: var(--stage-color); border-bottom: 2px solid var(--ink); }
.stage-title { display: flex; align-items: center; justify-content: space-between; gap: 5px; }
.stage-title span { font-size: .58rem; font-weight: 1000; }
.stage-title b { font-size: .88rem; }
.stage-cap { display: flex; justify-content: space-between; align-items: end; margin-top: 7px; }
.stage-cap strong { font-size: 1.7rem; line-height: .9; }
.stage-cap small { font-size: .55rem; font-weight: 900; }
.place-button { width: 100%; margin-top: 8px; border: 1px solid var(--ink); background: var(--paper-2); padding: 5px 7px; cursor: pointer; font-size: .62rem; font-weight: 1000; }
.stage-staff { min-height: 20px; margin-top: 7px; display: flex; flex-wrap: wrap; gap: 4px; }
.staff-pill { display: inline-flex; align-items: center; gap: 3px; padding: 3px 6px; border: 1px solid var(--ink); background: var(--paper-2); font-size: .55rem; font-weight: 900; }
.staff-pill i { width: 6px; height: 6px; border-radius: 50%; background: var(--worker-color); }
.load-meter { height: 5px; margin-top: 7px; border: 1px solid var(--ink); background: white; }
.load-meter i { display: block; height: 100%; max-width: 100%; background: var(--blue); }
.load-meter.over i { background: var(--coral); }

.job-stack { min-height: 170px; padding: 7px; display: grid; align-content: start; gap: 6px; }
.job-card { width: 100%; position: relative; border: 1px solid var(--ink); background: white; padding: 8px; text-align: left; color: var(--ink); cursor: pointer; overflow: hidden; }
.job-card.priority { box-shadow: inset 4px 0 0 var(--coral); background: #fff6dc; }
.job-card.priority::after { content: "最優先"; position: absolute; right: 0; top: 0; padding: 2px 5px; background: var(--coral); color: white; font-size: .47rem; font-weight: 1000; }
.job-name { display: block; max-width: 72%; font-size: .7rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.job-meta { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0; }
.job-meta span { padding: 2px 4px; background: #e9e6de; font-size: .48rem; font-weight: 900; }
.job-meta .due.urgent { background: var(--yellow); }
.job-meta .due.late { background: var(--coral); color: white; }
.work-left { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.work-left small { font-size: .49rem; color: var(--muted); font-weight: 900; white-space: nowrap; }
.work-pips { flex: 1; display: flex; justify-content: flex-end; gap: 2px; }
.work-pips i { width: 8px; height: 8px; border: 1px solid var(--ink); background: var(--stage-color); }
.empty-stage { min-height: 130px; display: grid; place-items: center; color: #989b98; text-align: center; font-size: .65rem; font-weight: 800; }

.intel-panel { display: grid; align-content: start; gap: 12px; }
.intel-panel section { padding: 13px; }
.intel-panel h2 { margin-bottom: 9px; }
.today-card { background: var(--ink) !important; color: white; }
.today-card > p:first-child { color: var(--lime) !important; }
.today-card h2 { display: flex; align-items: center; gap: 7px; }
.today-card > p:last-child, .tomorrow-event, .report-card div { margin: 0; color: #b9c2c5; font-size: .66rem; line-height: 1.6; font-weight: 700; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--coral); box-shadow: 0 0 0 4px #ff5a4f33; animation: pulse 1.5s infinite; }
.upcoming-job { padding: 9px; background: var(--yellow); border: 1px solid var(--ink); }
.upcoming-job b, .upcoming-job span, .upcoming-job small { display: block; }
.upcoming-job span { font-size: .53rem; font-weight: 1000; }
.upcoming-job b { margin: 3px 0; font-size: .8rem; }
.upcoming-job small { font-size: .54rem; }
.upcoming-job > div + div { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--ink); }
.tomorrow-event { margin-top: 9px !important; padding-top: 8px; border-top: 1px dashed var(--rule); color: var(--muted); }
.report-card div { color: var(--muted); }
.report-card b { color: var(--ink); }

.command-bar { position: sticky; z-index: 10; bottom: 8px; display: grid; grid-template-columns: 1fr minmax(270px, 430px); gap: 12px; align-items: center; margin-top: 12px; padding: 8px 8px 8px 13px; border: 2px solid var(--ink); background: #fffdf7ee; backdrop-filter: blur(9px); box-shadow: 5px 5px 0 var(--ink); }
.command-bar > div span, .command-bar > div strong { display: block; }
.command-bar > div span { font-size: .54rem; color: var(--muted); font-weight: 1000; }
.command-bar > div strong { font-size: .72rem; }
.run { padding: 12px 14px; box-shadow: none; }
.run:hover { box-shadow: none; transform: none; }
.status-message { min-height: 1.25em; margin: 10px 0 0; text-align: center; color: #a02b24; font-size: .67rem; font-weight: 900; }
.keyboard { margin: 3px 0 0; text-align: center; color: var(--muted); font-size: .55rem; }

.result-screen { padding: clamp(42px, 8vw, 90px) 4vw 60px; }
.result-top { display: grid; grid-template-columns: 1fr auto; gap: 25px; align-items: end; border-bottom: 3px solid var(--ink); padding-bottom: 28px; }
.result-top h1 { font-size: clamp(3rem, 9vw, 7rem); }
.result-top p { max-width: 700px; margin: 16px 0 0; color: var(--muted); font-weight: 700; line-height: 1.7; }
.grade { width: clamp(110px, 17vw, 170px); aspect-ratio: 1; display: grid; place-items: center; border: 3px solid var(--ink); background: var(--lime); box-shadow: 8px 8px 0 var(--ink); font-size: clamp(4rem, 9vw, 7rem); font-weight: 1000; line-height: 1; transform: rotate(3deg); }
.result-grid { display: grid; grid-template-columns: repeat(4, 1fr); margin: 18px 0; border: 2px solid var(--ink); background: var(--paper-2); }
.result-grid div { padding: 15px; border-right: 1px solid var(--ink); }
.result-grid div:last-child { border-right: 0; }
.result-grid small { display: block; color: var(--muted); font-size: .62rem; font-weight: 900; }
.result-grid strong { font-size: 2rem; }
.result-grid span { font-size: .66rem; font-weight: 900; }
.result-lesson { margin: 18px 0 24px; padding: 19px; border-left: 9px solid var(--blue); background: var(--paper-2); font-weight: 700; line-height: 1.75; }
.result-lesson b { display: block; margin-bottom: 4px; color: var(--blue); font-size: .65rem; letter-spacing: .12em; }
.retry { max-width: 480px; }

@keyframes pulse { 50% { opacity: .45; } }

@media (max-width: 920px) {
  .start-screen { grid-template-columns: 1fr; padding-top: 42px; }
  .start-visual { width: min(690px, 95%); margin: 0 auto; }
  .director-layout { grid-template-columns: 1fr; }
  .intel-panel { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 690px) {
  .app-shell { padding-inline: 10px; }
  .masthead { height: 60px; }
  .wordmark small { display: none; }
  .screen { min-height: calc(100svh - 60px); }
  .start-screen { padding: 30px 2px 50px; gap: 38px; }
  .start-copy h1 { font-size: clamp(2.7rem, 15vw, 4.5rem); }
  .lead { font-size: .88rem; line-height: 1.75; }
  .three-rules { grid-template-columns: 1fr; }
  .three-rules div { border-right: 0; border-bottom: 1px solid var(--ink); padding: 9px 10px; }
  .three-rules div:last-child { border-bottom: 0; }
  .start-visual { width: calc(100% - 10px); padding: 23px 15px; box-shadow: 7px 7px 0 var(--blue); }
  .route { gap: 4px; margin: 25px 0 48px; }
  .route > i { font-size: .95rem; }
  .route-node { min-height: 110px; padding: 8px 6px; }
  .route-node b { font-size: .82rem; }
  .route-node small { font-size: .51rem; }
  .sample-ticket { bottom: 49px; width: 47%; padding: 9px; }
  .sample-ticket b { font-size: .78rem; }
  .scoreboard { grid-template-columns: 78px repeat(3, 1fr); }
  .scoreboard > div { padding: 7px 6px; }
  .scoreboard > p { grid-column: 1/-1; margin: 0; padding: 5px; text-align: center; border-top: 1px solid var(--ink); }
  .scoreboard strong { font-size: 1.15rem; }
  .scoreboard .day-card strong { font-size: 1.4rem; }
  .mission-strip { align-items: flex-start; font-size: .62rem; line-height: 1.5; }
  .crew-list { grid-template-columns: repeat(2, 1fr); }
  .mode-buttons { grid-template-columns: 1fr; }
  .mode-button { display: grid; grid-template-columns: 90px 1fr; align-items: center; }
  .mode-button small { margin: 0; }
  .section-head { align-items: start; }
  .pipeline { grid-template-columns: 1fr; gap: 20px; }
  .stage:not(:last-child)::after { content: "↓"; right: 50%; top: auto; bottom: -21px; height: 19px; }
  .stage-head { display: grid; grid-template-columns: 1fr auto; gap: 6px; }
  .place-button { grid-column: 2; grid-row: 1 / span 2; width: 95px; margin: 0; }
  .stage-staff { margin-top: 4px; }
  .job-stack { min-height: 70px; }
  .intel-panel { grid-template-columns: 1fr; }
  .command-bar { grid-template-columns: 1fr; bottom: 5px; padding: 8px; }
  .command-bar > div { display: none; }
  .run { font-size: .8rem; }
  .keyboard { display: none; }
  .result-screen { padding: 35px 2px 50px; }
  .result-top { grid-template-columns: 1fr auto; align-items: center; }
  .result-top h1 { font-size: clamp(2.35rem, 13vw, 4rem); }
  .grade { width: 84px; font-size: 3.7rem; box-shadow: 5px 5px 0 var(--ink); }
  .result-grid { grid-template-columns: repeat(2, 1fr); }
  .result-grid div:nth-child(2) { border-right: 0; }
  .result-grid div:nth-child(-n+2) { border-bottom: 1px solid var(--ink); }
}

@media (max-width: 350px) {
  .wordmark { font-size: 1.1rem; }
  .sound-btn { padding: 7px 8px; }
  .mission-strip span { display: none; }
  .crew-card { padding: 7px; }
  .section-head > small { max-width: 130px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
