:root {
  --ink: #17212b;
  --muted: #61707d;
  --line: #d9e1e6;
  --paper: #fffefb;
  --soft: #f2f6f4;
  --green: #236b52;
  --green-soft: #dcece5;
  --orange: #ce6539;
  --a: #24705a;
  --b: #315ea8;
  --c: #b56e16;
  --shadow: 0 16px 44px rgba(37, 53, 61, .12);
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body {
  background: linear-gradient(145deg, #eef5f1 0%, #f8f3eb 100%);
  color: var(--ink);
  font-family: "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  line-height: 1.5;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
#app { width: 100%; height: 100%; overflow: hidden; }

.screen {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  padding: clamp(14px, 3vw, 34px);
}
.card {
  width: min(720px, 94vw);
  max-height: 94vh;
  overflow: hidden;
  background: rgba(255, 254, 251, .97);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: clamp(22px, 4vh, 40px);
}
.card.wide { width: min(920px, 96vw); }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(1.7rem, 3vw, 2.45rem); margin-bottom: 10px; }
h2 { font-size: clamp(1.35rem, 2.3vw, 1.85rem); }
.lead { color: var(--muted); font-size: 1.04rem; }
.eyebrow { color: var(--green); font-weight: 750; letter-spacing: .12em; }
.form-grid { display: grid; gap: 14px; margin: 20px 0; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
label { display: grid; gap: 6px; font-weight: 650; }
input, select, textarea {
  min-width: 0;
  border: 1px solid #bbc8cf;
  border-radius: 10px;
  padding: 10px 12px;
  background: white;
  color: var(--ink);
}
textarea { resize: none; height: 72px; }
.actions { display: flex; justify-content: flex-end; align-items: center; gap: 12px; margin-top: 20px; }
.actions.between { justify-content: space-between; }
.primary, .secondary {
  border-radius: 12px;
  padding: 10px 20px;
  border: 1px solid transparent;
  font-weight: 750;
}
.primary { background: var(--green); color: white; }
.primary:hover { background: #174f3c; }
.secondary { background: white; color: var(--green); border-color: #9bb7ab; }
.error { color: #a22d2d; min-height: 1.5em; }
.fine { color: var(--muted); font-size: .87rem; }
.participant-id {
  display: inline-block;
  padding: 8px 13px;
  border-radius: 10px;
  background: var(--green-soft);
  color: var(--green);
  font: 700 1.05rem ui-monospace, monospace;
}

.instruction-copy { max-width: 760px; font-size: clamp(1.08rem, 1.8vw, 1.28rem); line-height: 1.85; }
.instruction-copy strong { color: var(--ink); font-weight: 850; }
.steps { display: flex; justify-content: center; gap: 7px; margin-top: 12px; }
.step-dot { width: 9px; height: 9px; border-radius: 50%; background: #c9d2d7; }
.step-dot.active { background: var(--green); }
.quiz-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.quiz-item { padding: 12px; border: 1px solid var(--line); border-radius: 12px; }

.task-shell {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: minmax(190px, 230px) minmax(0, 1fr);
  gap: clamp(8px, 1.4vh, 14px);
  padding: clamp(8px, 1.4vw, 18px);
  overflow: hidden;
}
.task-sidebar {
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto 1fr;
  align-content: start;
  gap: clamp(14px, 2.5vh, 26px);
  background: rgba(255,255,255,.95);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: clamp(16px, 2vw, 24px);
  box-shadow: 0 8px 24px rgba(37,53,61,.08);
}
.phase-info, .turn-status { display: grid; gap: 5px; }
.phase-info span, .turn-status span, .progress-cue span {
  color: var(--muted);
  font-size: .82rem;
  font-weight: 750;
  letter-spacing: .06em;
}
.task-title { color: var(--ink); font-size: clamp(1.3rem, 2vw, 1.75rem); font-weight: 850; }
.progress-stack { display: grid; gap: 12px; }
.progress-cue {
  display: grid;
  gap: 2px;
  padding: 13px 14px;
  border: 1px solid #cbdad3;
  border-radius: 14px;
  background: var(--green-soft);
}
.progress-cue strong { color: var(--green); font-size: clamp(2rem, 3.5vw, 3rem); line-height: 1; }
.progress-cue small { margin-left: 7px; color: #5d756b; font-size: .48em; font-weight: 750; }
.turn-status {
  align-self: end;
  padding: 14px;
  border-top: 1px solid var(--line);
}
.turn-message, .round-finished > strong { color: var(--green); font-size: clamp(1.3rem, 2.1vw, 1.75rem); font-weight: 850; }
.round-finished { gap: 14px; }
.round-finished .primary { width: 100%; padding: 10px 12px; cursor: pointer; }
.task-stage {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.22fr) minmax(310px, .9fr);
  gap: clamp(9px, 1.4vw, 18px);
}
.task-stage.solo { grid-template-columns: minmax(420px, 780px); justify-content: center; }
.map-card {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 7px;
  background: rgba(255,255,255,.96);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: clamp(8px, 1.3vh, 14px);
  overflow: hidden;
}
.map-head { display: flex; justify-content: space-between; align-items: center; font-weight: 800; }
.score { color: var(--muted); font-weight: 650; }
.score b { color: var(--ink); font-size: 1.14rem; }
.canvas-wrap { min-height: 0; display: grid; place-items: center; }
canvas.map {
  display: block;
  width: min(100%, calc(100vh - 54px));
  height: min(100%, calc(100vh - 54px));
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 1;
  background: #f8faf9;
  border: 1px solid #9daeb5;
  touch-action: none;
}
canvas.clickable { cursor: crosshair; box-shadow: 0 0 0 3px rgba(35,107,82,.2); }
canvas.pending { cursor: wait; }
.bot-grid { min-height: 0; display: grid; grid-template-rows: repeat(3, minmax(0, 1fr)); gap: 8px; }
.bot-card { grid-template-columns: minmax(112px, .36fr) minmax(0, 1fr); grid-template-rows: 1fr; align-items: center; }
.bot-card .map-head { display: grid; align-content: center; justify-items: start; gap: 8px; }
.bot-card canvas.map { width: min(100%, calc((100vh - 54px) / 3)); height: min(100%, calc((100vh - 54px) / 3)); }
.bot-identity { display: grid; grid-template-columns: 56px minmax(0, 1fr); align-items: center; gap: 8px; }
.bot-avatar { display: block; width: 56px; height: 56px; object-fit: contain; }
.bot-name { display: grid; justify-items: start; gap: 5px; white-space: nowrap; }
.bot-label { width: 38px; height: 38px; border-radius: 50%; color: white; display: grid; place-items: center; font-size: 1.2rem; }
.bot-label.A { background: var(--a); }.bot-label.B { background: var(--b); }.bot-label.C { background: var(--c); }
.active-card { border-color: var(--green); box-shadow: inset 0 0 0 2px rgba(35,107,82,.16); }
.compat-overlay {
  position: fixed; inset: 0; z-index: 20; display: grid; place-items: center;
  background: rgba(15, 28, 34, .62); color: white; text-align: center;
}
.compat-overlay[hidden] { display: none; }
.overlay-box { background: rgba(22, 38, 45, .95); border-radius: 18px; padding: 24px 36px; max-width: 620px; }
#toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  display: none; z-index: 50; background: #8d2828; color: white; padding: 10px 16px; border-radius: 9px;
}

@media (max-height: 720px) {
  .task-shell { padding: 7px; gap: 7px; }
  .task-sidebar { padding: 12px; gap: 10px; }
  .progress-stack { gap: 8px; }
  .progress-cue { padding: 9px 11px; }
  .turn-status { padding: 10px; }
  .map-card { padding: 7px; }
  .bot-identity { grid-template-columns: 46px minmax(0, 1fr); gap: 6px; }
  .bot-avatar { width: 46px; height: 46px; }
  .bot-label { width: 32px; height: 32px; font-size: 1rem; }
  .card { padding: 20px 26px; }
}
@media (max-width: 1100px) {
  .task-shell { grid-template-columns: 180px minmax(0, 1fr); }
  .task-stage { grid-template-columns: minmax(0, 1fr) minmax(290px, .86fr); }
}
