:root {
  --ink: #17202a;
  --muted: #667085;
  --line: #d8dee8;
  --paper: #fbfcfe;
  --soft: #eef3f8;
  --accent: #1f7a8c;
  --accent-2: #d96c4f;
  --ok: #2f8a5f;
  --warn: #b7791f;
  --bad: #bd3f3f;
  --shadow: 0 14px 34px rgba(29, 41, 57, 0.14);
  font-family:
    "Segoe UI",
    "Hiragino Kaku Gothic ProN",
    "Yu Gothic",
    Meiryo,
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(246, 248, 251, 0.96)),
    repeating-linear-gradient(90deg, rgba(31, 122, 140, 0.07) 0 1px, transparent 1px 72px),
    #f2f5f8;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
  touch-action: manipulation; /* ダブルタップズームと300ms遅延を防ぐ */
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  width: min(1180px, calc(100vw - 28px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 22px 0 34px;
}

.topbar,
.game-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 800;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: #fff;
  box-shadow: 5px 5px 0 #b7d7de;
}

.nav-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(420px, 1.1fr);
  gap: 28px;
  align-items: stretch;
  min-height: 560px;
  padding: 18px 0 26px;
}

.hero-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  max-width: 10ch;
  font-size: clamp(42px, 7vw, 76px);
  line-height: 0.98;
  letter-spacing: 0;
}

h2 {
  font-size: 30px;
  line-height: 1.18;
}

h3 {
  font-size: 18px;
}

.lead {
  max-width: 620px;
  color: #344054;
  font-size: 18px;
  line-height: 1.75;
}

.section {
  padding: 22px 0;
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

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

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

.card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 4px 14px rgba(16, 24, 40, 0.06);
}

.choice-card {
  display: flex;
  min-height: 174px;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
  padding: 18px;
  text-align: left;
  transition:
    transform 0.16s ease,
    border-color 0.16s ease,
    box-shadow 0.16s ease;
}

.choice-card:hover,
.choice-card.selected {
  border-color: var(--accent);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.choice-card.selected {
  outline: 3px solid rgba(31, 122, 140, 0.16);
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 13px;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 28px;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: #344054;
  font-size: 12px;
  font-weight: 700;
}

.btn {
  min-height: 40px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
}

.btn.primary {
  border-color: #174a55;
  background: #174a55;
  color: #fff;
}

.btn.secondary {
  border-color: #c6d1dd;
  background: #edf3f6;
}

.btn.danger {
  border-color: #f1c3c3;
  background: #fff4f4;
  color: #9f2a2a;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.office-scene {
  position: relative;
  min-height: 520px;
  overflow: hidden;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(211, 226, 234, 0.9) 0 45%, rgba(226, 214, 195, 0.9) 45% 100%),
    #e8edf1;
  box-shadow: var(--shadow);
  perspective: 820px;
}

.window {
  position: absolute;
  top: 38px;
  left: 36px;
  width: 178px;
  height: 122px;
  border: 5px solid #fff;
  background:
    linear-gradient(90deg, transparent 48%, #fff 48% 52%, transparent 52%),
    linear-gradient(180deg, transparent 48%, #fff 48% 52%, transparent 52%),
    linear-gradient(135deg, #9cc9d5, #e7f1f5);
  box-shadow: 0 8px 18px rgba(16, 24, 40, 0.12);
}

.wall-board {
  position: absolute;
  top: 42px;
  right: 34px;
  width: 240px;
  min-height: 150px;
  padding: 14px;
  border: 4px solid #795548;
  background: #fbfbf2;
  box-shadow: 0 8px 18px rgba(16, 24, 40, 0.12);
}

.board-line {
  height: 8px;
  margin: 10px 0;
  border-radius: 4px;
  background: #d8dee8;
}

.desk {
  position: absolute;
  right: 70px;
  bottom: 72px;
  width: 540px;
  height: 210px;
  transform: rotateX(58deg) rotateZ(-2deg);
  transform-origin: bottom;
  border: 4px solid #94623f;
  border-radius: 10px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.13), transparent 18%),
    repeating-linear-gradient(90deg, #b77b51 0 52px, #a96f49 52px 56px);
  box-shadow: 0 26px 26px rgba(60, 42, 31, 0.18);
}

.monitor {
  position: absolute;
  right: 230px;
  bottom: 258px;
  width: 160px;
  height: 100px;
  border: 7px solid #243447;
  border-radius: 8px;
  background:
    linear-gradient(90deg, #7ad1a3 0 35%, #f3d26f 35% 68%, #ee7d6f 68%),
    #d6eef3;
  box-shadow: 0 10px 18px rgba(16, 24, 40, 0.17);
}

.monitor::after {
  position: absolute;
  right: 55px;
  bottom: -40px;
  width: 36px;
  height: 38px;
  border-radius: 4px;
  background: #243447;
  content: "";
}

.paper-stack {
  position: absolute;
  left: 36px;
  bottom: 102px;
  width: 130px;
  height: 88px;
  transform: rotate(-6deg);
  border: 2px solid #cbd5e1;
  border-radius: 6px;
  background:
    repeating-linear-gradient(180deg, #fff 0 15px, #edf2f7 15px 17px),
    #fff;
  box-shadow:
    9px 9px 0 #e1e7ef,
    18px 18px 0 #cbd5e1;
}

.mail-bin {
  position: absolute;
  left: 206px;
  bottom: 94px;
  width: 108px;
  height: 70px;
  transform: skewX(-8deg);
  border: 3px solid #35606d;
  border-radius: 7px;
  background: #cde7ed;
}

.phone {
  position: absolute;
  right: 86px;
  bottom: 176px;
  width: 92px;
  height: 56px;
  border-radius: 16px 16px 10px 10px;
  background: #2b3948;
  box-shadow: inset 0 -12px 0 rgba(0, 0, 0, 0.16);
}

.phone::before {
  position: absolute;
  top: -26px;
  left: 14px;
  width: 64px;
  height: 28px;
  border-radius: 26px 26px 8px 8px;
  background: #33465a;
  content: "";
}

.alert-bubble {
  position: absolute;
  left: 34px;
  top: 192px;
  max-width: 310px;
  padding: 12px 14px;
  border: 2px solid #d96c4f;
  border-radius: 8px;
  background: #fffaf7;
  box-shadow: 6px 6px 0 rgba(217, 108, 79, 0.18);
  font-weight: 800;
}

.play-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 16px;
  align-items: start;
}

.hud-metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(86px, 1fr));
  gap: 8px;
  width: 100%;
}

.metric {
  min-height: 64px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.metric strong {
  display: block;
  font-size: 22px;
}

.task-panel,
.side-panel,
.result-panel,
.admin-panel {
  padding: 16px;
}

.task-panel {
  position: relative;
  min-height: 386px;
}

.task-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.task-title {
  font-size: 28px;
  line-height: 1.18;
}

.task-description {
  margin-top: 12px;
  color: #344054;
  font-size: 16px;
  line-height: 1.75;
}

.task-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 16px 0;
}

.stat-box {
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfd;
}

.hand {
  display: grid;
  grid-template-columns: repeat(5, minmax(128px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.ai-card {
  display: flex;
  min-height: 126px;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  padding: 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  text-align: left;
  transition:
    transform 0.12s ease,
    background 0.12s ease,
    border-color 0.12s ease;
}

.ai-card:hover,
.ai-card.selected {
  border-color: var(--accent);
  background: #eef8fa;
  transform: translateY(-2px);
}

.ai-card .icon {
  font-size: 24px;
}

.feedback {
  min-height: 92px;
  margin-top: 12px;
  padding: 12px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid var(--line);
}

.feedback.perfect {
  border-color: #87c6a6;
  background: #effaf4;
}

.feedback.good {
  border-color: #9bc4dc;
  background: #f0f8fc;
}

.feedback.risk {
  border-color: #edc878;
  background: #fff8e8;
}

.feedback.miss {
  border-color: #eda5a5;
  background: #fff1f1;
}

.queue-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.queue-item {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
}

.result-metric {
  min-height: 104px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.result-metric strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
}

.history-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.history-item {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.badge {
  display: inline-grid;
  min-height: 32px;
  place-items: center;
  padding: 4px 8px;
  border-radius: 7px;
  color: #fff;
  font-weight: 900;
  text-transform: uppercase;
}

.badge.perfect {
  background: var(--ok);
}

.badge.good {
  background: #2d7fa3;
}

.badge.risk {
  background: var(--warn);
}

.badge.miss {
  background: var(--bad);
}

.admin-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

textarea {
  width: 100%;
  min-height: 330px;
  resize: vertical;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  line-height: 1.55;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  z-index: 10;
}

/* ===== コアループ用の追加スタイル ===== */

.game-hud {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}

.goal-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.goal-strip strong {
  margin-right: 4px;
}

.goal-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f4f7fa;
  font-size: 12px;
  font-weight: 700;
}

.goal-chip.done {
  border-color: #87c6a6;
  background: #effaf4;
  color: #1d6a44;
}

.goal-chip.over {
  border-color: #eda5a5;
  background: #fff1f1;
  color: #9f2a2a;
}

.small-btn {
  min-height: 32px;
  margin-left: auto;
  padding: 4px 10px;
  font-size: 12px;
}

.hud-metrics {
  grid-template-columns: minmax(150px, 1.4fr) repeat(4, minmax(86px, 1fr));
}

.metric .unit {
  font-size: 13px;
  font-weight: 700;
}

.metric.time .time-bar {
  height: 7px;
  margin-top: 5px;
  overflow: hidden;
  border-radius: 4px;
  background: #e5ebf1;
}

.time-fill {
  height: 100%;
  border-radius: 4px;
  background: var(--accent);
}

.time-fill.danger {
  background: var(--bad);
  animation: pulse 0.8s infinite;
}

.metric.combo-hot {
  border-color: var(--accent-2);
  background: #fff6f2;
}

.metric.combo-hot strong {
  color: var(--accent-2);
}

.metric.stamp-low {
  border-color: #edc878;
  background: #fff8e8;
}

.desk-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 10px 0 14px;
}

.task-chip {
  display: flex;
  min-height: 118px;
  flex-direction: column;
  gap: 7px;
  padding: 12px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #fff;
  text-align: left;
  transition:
    transform 0.12s ease,
    border-color 0.12s ease,
    box-shadow 0.12s ease;
}

.task-chip:hover {
  transform: translateY(-2px);
}

.task-chip.selected {
  border-color: var(--accent);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.task-chip.interrupt {
  border-color: var(--accent-2);
  background: #fff8f4;
}

.chip-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 8px;
}

.chip-flag {
  flex-shrink: 0;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-2);
  color: #fff;
  font-size: 11px;
  font-weight: 900;
}

.pill.tiny {
  min-height: 22px;
  padding: 2px 7px;
  font-size: 11px;
}

.pill.risky {
  border-color: #edc878;
  background: #fff8e8;
  color: #8a5a10;
}

.pill.new-best {
  border-color: var(--accent-2);
  background: #fff6f2;
  color: var(--accent-2);
}

.deadline-track {
  height: 8px;
  overflow: hidden;
  border-radius: 4px;
  background: #e5ebf1;
}

.deadline-fill {
  height: 100%;
  border-radius: 4px;
}

.task-chip.calm .deadline-fill {
  background: #2d7fa3;
}

.task-chip.warn .deadline-fill {
  background: var(--warn);
}

.task-chip.danger .deadline-fill {
  background: var(--bad);
}

.task-chip.danger .deadline-text {
  color: var(--bad);
  font-weight: 800;
  animation: pulse 0.8s infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.45;
  }
}

.btn.big {
  min-height: 48px;
  padding: 10px 22px;
  font-size: 16px;
}

.ai-card.depleted {
  cursor: not-allowed;
  opacity: 0.4;
}

.goal-board {
  padding: 16px;
  border-left: 6px solid var(--accent);
}

/* 書類の山 */
.pile-box {
  padding: 6px 0 2px;
}

.pile {
  position: relative;
  display: flex;
  min-height: 96px;
  flex-direction: column-reverse;
  align-items: center;
  justify-content: start;
  gap: 2px;
  padding: 6px 0;
}

.pile-sheet {
  width: 74%;
  height: 8px;
  border: 1px solid #cbd5e1;
  border-radius: 2px;
  background: repeating-linear-gradient(180deg, #fff 0 3px, #edf2f7 3px 4px);
  box-shadow: 0 2px 3px rgba(16, 24, 40, 0.08);
}

.pile-clear {
  padding: 26px 0;
  font-weight: 900;
  color: var(--ok);
}

.mini-history {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.mini-history-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mini-history-item .badge {
  min-height: 22px;
  padding: 2px 7px;
  font-size: 10px;
}

.badge.expired {
  background: #5b6472;
}

/* 結果画面：目標達成表 */
.goal-results {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0 4px;
}

.goal-result {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-weight: 700;
}

.goal-result.ok {
  border-color: #87c6a6;
  background: #effaf4;
}

.goal-result.ok span:first-child {
  color: var(--ok);
}

.goal-result.ng {
  border-color: #eda5a5;
  background: #fff5f5;
}

.goal-result.ng span:first-child {
  color: var(--bad);
}

.improve-box {
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid #edc878;
  border-radius: 8px;
  background: #fff8e8;
}

/* ===== 3Dプレイ画面（スマホファースト） ===== */

body.playing {
  overflow: hidden;
}

#play-root {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  background:
    linear-gradient(180deg, #dcebf2 0%, #cfe3ec 42%, #e2d6c3 42%, #d9c9b2 100%);
  /* iOS: 連打時の文字選択・長押しメニューを防ぐ */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  padding-top: env(safe-area-inset-top);
}

.p-hud {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 10px 4px;
}

.p-time {
  position: relative;
  flex: 1;
  height: 24px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.85);
}

#p-time-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
  transition: width 0.9s linear;
}

#p-time-fill.danger {
  background: var(--bad);
  animation: pulse 0.8s infinite;
}

.p-time span {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #17202a;
  font-size: 13px;
  font-weight: 900;
  text-shadow: 0 0 4px rgba(255, 255, 255, 0.9);
}

.p-quit {
  min-height: 26px;
  padding: 3px 12px;
  border: 1px solid #f1c3c3;
  border-radius: 999px;
  background: #fff4f4;
  color: #9f2a2a;
  font-size: 12px;
  font-weight: 800;
}

.p-stats {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  padding: 4px 12px;
  font-size: 13px;
  font-weight: 800;
}

.p-stats .hot {
  color: var(--accent-2);
}

.p-stats .over {
  color: var(--bad);
}

.chip-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  padding: 2px 10px;
}

.p-chip {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px 8px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.92);
  text-align: left;
}

.p-chip .chip-line {
  display: flex;
  align-items: center;
  gap: 5px;
  overflow: hidden;
  font-size: 11px;
  white-space: nowrap;
}

.p-chip .em {
  font-size: 17px;
}

.p-chip.selected {
  border-color: var(--accent);
  background: #eef8fa;
}

.p-chip.interrupt {
  border-color: var(--accent-2);
  background: #fff8f4;
}

.p-chip .dl {
  display: block;
  height: 5px;
  overflow: hidden;
  border-radius: 3px;
  background: #e5ebf1;
}

.p-chip .dl i {
  display: block;
  height: 100%;
  border-radius: 3px;
}

.p-chip.calm .dl i {
  background: #2d7fa3;
}

.p-chip.warn .dl i {
  background: var(--warn);
}

.p-chip.danger .dl i {
  background: var(--bad);
}

.p-chip.danger {
  animation: pulse 0.9s infinite;
}

#stage {
  position: relative;
  flex: 1;
  min-height: 180px;
}

#stage canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100% !important;
  height: 100% !important;
}

.p-msg {
  min-height: 34px;
  padding: 5px 14px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
  text-align: center;
  color: #344054;
}

.p-msg.perfect {
  color: var(--ok);
}

.p-msg.good {
  color: #2d7fa3;
}

.p-msg.risk {
  color: var(--warn);
}

.p-msg.miss {
  color: var(--bad);
}

.stamp-tray {
  padding: 8px 10px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
}

.stamp-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.stamp-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 2px 4px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: #fff;
  transition: transform 0.1s ease, border-color 0.1s ease;
}

.stamp-btn .ic {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 2.5px solid #1f7a8c;
  border-radius: 50%;
  color: #1f7a8c;
  font-size: 18px;
  font-weight: 900;
}

.stamp-btn.human .ic {
  border-color: var(--bad);
  color: var(--bad);
}

.stamp-btn .nm {
  max-width: 100%;
  overflow: hidden;
  color: #344054;
  font-size: 9px;
  font-weight: 700;
  white-space: nowrap;
}

.stamp-btn.selected {
  border-color: var(--accent);
  background: #eef8fa;
  transform: translateY(-2px);
}

.stamp-btn.selected.human {
  border-color: var(--bad);
  background: #fff4f4;
}

.stamp-btn.depleted {
  cursor: not-allowed;
  opacity: 0.35;
}

.go-btn {
  width: 100%;
  min-height: 48px;
  margin-top: 8px;
  border: none;
  border-radius: 12px;
  background: #174a55;
  color: #fff;
  font-size: 16px;
  font-weight: 900;
}

.go-btn:disabled {
  opacity: 0.45;
}

@media (min-width: 700px) {
  #play-root {
    left: 50%;
    width: 560px;
    transform: translateX(-50%);
    border-left: 1px solid var(--line);
    border-right: 1px solid var(--line);
    box-shadow: var(--shadow);
  }
}

/* 演出：ポップアップとシェイク */
#fx-layer {
  position: fixed;
  inset: 0;
  z-index: 20;
  overflow: hidden;
  pointer-events: none;
}

.fx-pop {
  position: absolute;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 22px;
  font-weight: 900;
  white-space: nowrap;
  transform: translate(-50%, 0);
  animation: pop-float 1.5s ease-out forwards;
  box-shadow: var(--shadow);
}

.fx-pop.perfect {
  background: var(--ok);
  color: #fff;
}

.fx-pop.good {
  background: #2d7fa3;
  color: #fff;
}

.fx-pop.risk {
  background: var(--warn);
  color: #fff;
}

.fx-pop.miss,
.fx-pop.bad {
  background: var(--bad);
  color: #fff;
}

.fx-pop.combo {
  background: var(--accent-2);
  color: #fff;
  font-size: 26px;
}

.fx-pop.comboname {
  background: #fff;
  border: 2px solid var(--accent-2);
  color: var(--accent-2);
}

.fx-pop.alert {
  background: #17202a;
  color: #ffd45e;
  font-size: 24px;
}

.fx-pop.bonus {
  background: #fff;
  border: 2px solid var(--ok);
  color: var(--ok);
}

@keyframes pop-float {
  0% {
    opacity: 0;
    transform: translate(-50%, 16px) scale(0.85);
  }
  15% {
    opacity: 1;
    transform: translate(-50%, 0) scale(1.06);
  }
  30% {
    transform: translate(-50%, -4px) scale(1);
  }
  75% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -46px) scale(0.96);
  }
}

.shake {
  animation: shake 0.4s ease;
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-7px);
  }
  40% {
    transform: translateX(6px);
  }
  60% {
    transform: translateX(-4px);
  }
  80% {
    transform: translateX(3px);
  }
}

@media (max-width: 960px) {
  .hero,
  .play-layout,
  .admin-grid {
    grid-template-columns: 1fr;
  }

  .hero {
    min-height: auto;
  }

  .office-scene {
    min-height: 420px;
  }

  .hud-metrics,
  .hand,
  .result-grid,
  .grid.three {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .desk-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100vw - 18px, 1180px);
    padding-top: 10px;
  }

  .topbar,
  .game-hud,
  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  h1 {
    max-width: 9ch;
    font-size: 42px;
  }

  .grid,
  .grid.three,
  .hud-metrics,
  .hand,
  .task-stats,
  .result-grid,
  .goal-results {
    grid-template-columns: 1fr;
  }

  .choice-card {
    min-height: 150px;
  }

  .wall-board {
    right: 16px;
    width: 186px;
  }

  .desk {
    right: -120px;
    width: 480px;
  }
}

/* ===== Game feel refresh ===== */
:root {
  --ink: #121826;
  --muted: #6b7280;
  --line: #253247;
  --paper: #f8fbff;
  --soft: #eaf3f8;
  --accent: #00a9a5;
  --accent-2: #ff6b4a;
  --ok: #20a66a;
  --warn: #f6a623;
  --bad: #e5484d;
  --gold: #ffd166;
  --shadow: 0 18px 34px rgba(18, 24, 38, 0.18);
}

body {
  background:
    radial-gradient(circle at 14% 12%, rgba(255, 209, 102, 0.28), transparent 24%),
    radial-gradient(circle at 90% 8%, rgba(0, 169, 165, 0.24), transparent 28%),
    linear-gradient(180deg, #f7fbff 0%, #e9f0f7 52%, #f4f0e8 100%);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 4;
  padding: 10px 0;
  backdrop-filter: blur(14px);
}

.brand.btn {
  border-color: rgba(18, 24, 38, 0.16);
  background: rgba(255, 255, 255, 0.84);
  box-shadow: 0 8px 18px rgba(18, 24, 38, 0.08);
}

.brand-mark {
  border: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 5px 0 #101828;
}

.btn {
  border-color: rgba(18, 24, 38, 0.15);
  box-shadow: 0 3px 0 rgba(18, 24, 38, 0.16);
}

.btn.primary {
  border-color: #101828;
  background: linear-gradient(180deg, #ff7a55, #e14d32);
  box-shadow: 0 5px 0 #8c2f22;
}

.btn.secondary {
  background: #fff;
}

.eyebrow {
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 950;
  letter-spacing: 0.12em;
}

.game-hero {
  position: relative;
  grid-template-columns: minmax(320px, 0.86fr) minmax(420px, 1.14fr);
  min-height: min(720px, calc(100svh - 92px));
  overflow: hidden;
  padding: 28px;
  border: 2px solid #111827;
  border-radius: 12px;
  background:
    linear-gradient(90deg, rgba(9, 17, 32, 0.92) 0%, rgba(9, 17, 32, 0.78) 40%, rgba(9, 17, 32, 0.12) 70%),
    url("assets/rush-hero.png") center right / cover no-repeat,
    #101828;
  box-shadow: 0 18px 0 rgba(18, 24, 38, 0.18), var(--shadow);
  color: #fff;
}

.game-hero .hero-copy {
  position: relative;
  z-index: 1;
  justify-content: center;
  max-width: 620px;
}

.game-hero h1 {
  max-width: 7.5ch;
  color: #fff;
  font-size: clamp(48px, 7vw, 84px);
  text-shadow: 0 5px 0 #0b1020, 0 14px 26px rgba(0, 0, 0, 0.36);
}

.game-hero .lead {
  max-width: 560px;
  color: #eef7ff;
  font-size: 18px;
  font-weight: 750;
  line-height: 1.65;
}

.hero-art {
  min-height: 420px;
}

.how-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  max-width: 660px;
}

.how-strip span {
  display: flex;
  min-height: 56px;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 13px;
  font-weight: 850;
}

.how-strip b {
  display: grid;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 8px;
  background: var(--gold);
  color: #111827;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.game-hero .pill {
  border-color: rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.game-section {
  padding-top: 36px;
}

.stage-grid {
  align-items: stretch;
}

.stage-card {
  position: relative;
  min-height: 210px;
  overflow: hidden;
  border: 2px solid #111827;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.96), rgba(236, 250, 250, 0.96));
  box-shadow: 0 7px 0 rgba(18, 24, 38, 0.18);
}

.stage-card::after {
  position: absolute;
  right: -24px;
  bottom: -28px;
  width: 120px;
  height: 120px;
  border: 14px solid rgba(0, 169, 165, 0.16);
  border-radius: 50%;
  content: "";
}

.stage-card.selected {
  outline: 4px solid rgba(255, 107, 74, 0.22);
}

.stage-card-top {
  display: flex;
  align-items: center;
  gap: 12px;
}

.stage-icon {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border: 2px solid #111827;
  border-radius: 10px;
  background: #fff4d6;
  font-size: 28px;
  box-shadow: 0 5px 0 rgba(18, 24, 38, 0.18);
}

.stage-rule {
  color: #364152;
  font-size: 14px;
  font-weight: 800;
}

.briefing-screen {
  display: grid;
  gap: 16px;
}

.briefing-header,
.mission-board,
.compact-goals {
  border: 2px solid #111827;
  border-radius: 12px;
  box-shadow: 0 8px 0 rgba(18, 24, 38, 0.14);
}

.briefing-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 22px;
  background: linear-gradient(135deg, #101828, #1f3643);
  color: #fff;
}

.briefing-header .lead {
  color: #e6edf4;
}

.mission-board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 12px;
  background: #fff;
}

.mission-card {
  min-height: 170px;
  padding: 16px;
  border: 2px solid rgba(18, 24, 38, 0.14);
  border-radius: 10px;
  background: #f6fbff;
}

.mission-card.danger {
  background: #fff4ed;
}

.mission-num {
  display: inline-grid;
  min-width: 42px;
  min-height: 30px;
  place-items: center;
  margin-bottom: 10px;
  border-radius: 8px;
  background: #101828;
  color: var(--gold);
  font-weight: 950;
}

.mission-card p {
  margin-top: 8px;
  color: #4b5565;
  line-height: 1.55;
}

.compact-goals {
  padding: 16px;
  border-left-width: 2px;
  background: #fff;
}

#play-root {
  background:
    radial-gradient(circle at 24% 0%, rgba(255, 209, 102, 0.28), transparent 24%),
    linear-gradient(180deg, #c9f1f2 0%, #d7eef4 40%, #ead8bd 40%, #d7bd97 100%);
}

.p-hud {
  padding: 10px 10px 6px;
  background: rgba(16, 24, 40, 0.9);
}

.p-time {
  height: 28px;
  border: 2px solid #111827;
  background: #fff;
  box-shadow: inset 0 -3px 0 rgba(18, 24, 38, 0.12);
}

#p-time-fill {
  background: linear-gradient(90deg, #35d07f, #ffd166, #ff6b4a);
}

.p-time span {
  color: #111827;
}

.p-quit {
  min-width: 54px;
  min-height: 30px;
  border: 2px solid #111827;
  background: #fff;
  color: #111827;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.25);
}

.p-quit.sound {
  min-width: 76px;
}

.p-stats {
  padding: 7px 10px;
  background: #101828;
  color: #f8fbff;
  font-size: 12px;
}

.p-stats span {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  justify-content: center;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

.chip-row {
  gap: 8px;
  padding: 8px 10px 5px;
  background: rgba(16, 24, 40, 0.9);
}

.p-chip {
  min-height: 112px;
  padding: 8px;
  border: 2px solid #111827;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 5px 0 rgba(17, 24, 39, 0.16);
}

.p-chip.selected {
  border-color: var(--gold);
  background: #fff9df;
  transform: translateY(-2px);
}

.p-chip.interrupt {
  border-color: var(--accent-2);
  background: #fff2ec;
}

.chip-top,
.chip-meta,
.risk-row {
  display: flex;
  align-items: center;
  gap: 5px;
}

.chip-top {
  min-height: 32px;
  color: #111827;
  font-size: 11px;
  line-height: 1.2;
}

.chip-top strong {
  overflow-wrap: anywhere;
}

.p-chip .em {
  display: grid;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 8px;
  background: #ecfeff;
  font-size: 18px;
}

.chip-flag {
  min-width: 22px;
  padding: 2px 4px;
  border-radius: 6px;
  background: var(--accent-2);
  color: #fff;
  font-size: 10px;
  font-weight: 950;
}

.chip-meta {
  justify-content: space-between;
  color: #344054;
  font-size: 11px;
  font-weight: 900;
}

.chip-meta b {
  padding: 2px 6px;
  border-radius: 6px;
  background: #e9f8f6;
  color: #007d79;
}

.risk-row {
  min-height: 19px;
  flex-wrap: wrap;
}

.risk-badge {
  display: inline-flex;
  align-items: center;
  min-height: 18px;
  padding: 1px 5px;
  border-radius: 999px;
  background: #fff1dd;
  color: #9a5b00;
  font-size: 9px;
  font-weight: 950;
}

.risk-badge.safe {
  background: #eafaf2;
  color: #14734a;
}

.p-msg {
  min-height: 42px;
  padding: 7px 12px;
  background: rgba(255, 255, 255, 0.82);
  color: #111827;
  font-size: 12px;
  font-weight: 850;
}

.p-msg.hint-risk {
  color: #9a3412;
}

.stamp-tray {
  border-top: 2px solid #111827;
  background: #fbfcfe;
  box-shadow: 0 -8px 24px rgba(18, 24, 38, 0.14);
}

.tray-label {
  display: flex;
  justify-content: space-between;
  padding: 0 2px 6px;
  color: #6b7280;
  font-size: 11px;
  font-weight: 950;
  letter-spacing: 0.08em;
}

.stamp-btn {
  min-height: 68px;
  border: 2px solid #111827;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 4px 0 rgba(18, 24, 38, 0.14);
}

.stamp-btn .ic {
  width: 34px;
  height: 34px;
  border-width: 2px;
  border-radius: 10px;
  background: #f1fffe;
  font-size: 17px;
}

.stamp-btn .nm {
  font-size: 10px;
  font-weight: 950;
}

.stamp-btn.selected {
  border-color: var(--accent);
  background: #e8fffb;
  box-shadow: 0 4px 0 rgba(0, 125, 121, 0.24);
}

.stamp-btn.selected.human {
  border-color: var(--bad);
  background: #fff0f0;
}

.go-btn {
  border: 2px solid #111827;
  border-radius: 10px;
  background: linear-gradient(180deg, #ff7a55, #e14d32);
  box-shadow: 0 5px 0 #8c2f22;
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100vw - 18px, 1180px);
    padding-top: 10px;
  }

  .topbar {
    position: static;
    align-items: stretch;
  }

  .brand.btn {
    justify-content: flex-start;
  }

  .nav-actions .btn.danger,
  .nav-actions .btn.secondary:nth-of-type(3) {
    display: none;
  }

  .game-hero {
    grid-template-columns: 1fr;
    min-height: auto;
    padding: 20px;
    background:
      linear-gradient(180deg, rgba(9, 17, 32, 0.92) 0%, rgba(9, 17, 32, 0.7) 58%, rgba(9, 17, 32, 0.2) 100%),
      url("assets/rush-hero.png") center bottom / cover no-repeat,
      #101828;
  }

  .game-hero h1 {
    font-size: 48px;
  }

  .game-hero .lead {
    font-size: 15px;
  }

  .how-strip,
  .mission-board,
  .stage-grid {
    grid-template-columns: 1fr;
  }

  .hero-art {
    min-height: 210px;
  }

  .briefing-header {
    align-items: stretch;
    flex-direction: column;
  }

  .p-chip {
    min-height: 104px;
    padding: 7px;
  }

  .chip-top {
    font-size: 10px;
  }

  .risk-badge {
    font-size: 8px;
  }
}
