:root {
  --ink: #15243d;
  --ink-soft: #526176;
  --paper: #f6f2e9;
  --white: #fffdf8;
  --line: rgba(21, 36, 61, 0.14);
  --crisis: #e56a4d;
  --crisis-deep: #a64132;
  --strategy: #287b72;
  --strategy-deep: #175b55;
  --danger: #b62f3b;
  --gold: #d6a94a;
  --shadow: 0 22px 60px rgba(30, 42, 63, 0.15);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--ink);
  background:
    linear-gradient(rgba(255,255,255,.45) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.45) 1px, transparent 1px),
    var(--paper);
  background-size: 32px 32px;
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif;
}

button, input { font: inherit; }
button { cursor: pointer; }

.ambient {
  position: fixed;
  z-index: -1;
  width: 36rem;
  height: 36rem;
  border-radius: 50%;
  filter: blur(2px);
  opacity: .5;
  pointer-events: none;
}

.ambient-one { right: -18rem; top: 14rem; background: radial-gradient(circle, rgba(229,106,77,.24), transparent 66%); }
.ambient-two { left: -18rem; bottom: -14rem; background: radial-gradient(circle, rgba(40,123,114,.22), transparent 66%); }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1440px;
  margin: auto;
  padding: 26px 46px 18px;
}

.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 15px;
  color: var(--white);
  background: var(--ink);
  font-size: 22px;
  font-weight: 800;
  box-shadow: 5px 5px 0 var(--gold);
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .17em;
  text-transform: uppercase;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 24px; letter-spacing: .03em; }
h2 { margin-bottom: 0; font-size: clamp(26px, 3vw, 40px); letter-spacing: -.03em; }

.top-actions, .section-actions, .dialog-actions, .print-toolbar { display: flex; gap: 10px; align-items: center; }
.text-button, .icon-button, .subtle-button, .dialog-close {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: rgba(255,253,248,.72);
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 700;
}
.text-button:hover, .icon-button:hover, .subtle-button:hover, .dialog-close:hover { background: var(--white); border-color: rgba(21,36,61,.34); }

main { max-width: 1440px; margin: auto; padding: 0 46px 52px; }

.safety-strip {
  border: 1px solid rgba(182,47,59,.2);
  border-left: 5px solid var(--danger);
  border-radius: 9px;
  padding: 12px 18px;
  color: #65222a;
  background: rgba(255,247,244,.88);
  font-size: 13px;
  line-height: 1.7;
}

.control-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin: 20px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255,253,248,.78);
  box-shadow: 0 8px 24px rgba(30,42,63,.05);
  backdrop-filter: blur(12px);
}

.mode-group { display: flex; gap: 8px; }
.mode-button {
  display: grid;
  gap: 3px;
  min-width: 165px;
  border: 1px solid transparent;
  border-radius: 14px;
  padding: 10px 15px;
  text-align: left;
  color: var(--ink);
  background: transparent;
}
.mode-button span { font-weight: 800; }
.mode-button small { color: var(--ink-soft); font-size: 11px; }
.mode-button.active { color: var(--white); background: var(--ink); box-shadow: 0 9px 18px rgba(21,36,61,.16); }
.mode-button.active small { color: rgba(255,255,255,.68); }
.panel-tools { display: flex; align-items: center; gap: 12px; }

.toggle { display: flex; gap: 9px; align-items: center; color: var(--ink-soft); font-size: 13px; font-weight: 700; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-track { position: relative; width: 38px; height: 22px; border-radius: 999px; background: #c7ccd1; transition: .2s ease; }
.toggle-track::after { content: ""; position: absolute; width: 16px; height: 16px; top: 3px; left: 3px; border-radius: 50%; background: white; transition: .2s ease; }
.toggle input:checked + .toggle-track { background: var(--strategy); }
.toggle input:checked + .toggle-track::after { transform: translateX(16px); }

.draw-stage {
  position: relative;
  overflow: hidden;
  min-height: 695px;
  border-radius: 32px;
  padding: 34px 42px 40px;
  color: var(--white);
  background:
    radial-gradient(circle at 76% 20%, rgba(214,169,74,.18), transparent 30%),
    linear-gradient(135deg, #132038, #1c3150 68%, #173c49);
  box-shadow: var(--shadow);
}
.draw-stage::after {
  content: "";
  position: absolute;
  right: -150px;
  bottom: -220px;
  width: 520px;
  height: 520px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 50%;
  box-shadow: 0 0 0 65px rgba(255,255,255,.025), 0 0 0 130px rgba(255,255,255,.018);
}
.stage-heading { position: relative; z-index: 2; display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.stage-heading .eyebrow { color: #d6a94a; }
.deck-status {
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 999px;
  padding: 9px 14px;
  color: rgba(255,255,255,.75);
  background: rgba(255,255,255,.06);
  font-size: 12px;
  font-weight: 700;
  transition: .2s ease;
}
.status-pulse { color: var(--white); background: rgba(214,169,74,.3); transform: scale(1.04); }

.card-area {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(320px, 470px) minmax(240px, 1fr);
  align-items: center;
  gap: clamp(50px, 8vw, 130px);
  max-width: 1030px;
  margin: 38px auto 0;
  perspective: 1400px;
}

.draw-card {
  position: relative;
  width: min(100%, 455px);
  aspect-ratio: 3 / 4;
  transform-style: preserve-3d;
  transition: transform .72s cubic-bezier(.2,.75,.2,1), filter .3s ease;
  cursor: pointer;
}
.draw-card:hover { filter: brightness(1.025); }
.draw-card.card-back { transform: rotateY(180deg); }
.draw-card.dealing { animation: deal .42s ease; }

@keyframes deal {
  0% { transform: translateY(-30px) rotateZ(-4deg) scale(.96) rotateY(180deg); opacity: .25; }
  100% { transform: rotateY(180deg); opacity: 1; }
}

.card-face {
  position: absolute;
  inset: 0;
  overflow: hidden;
  backface-visibility: hidden;
  border-radius: 27px;
  padding: 27px;
  box-shadow: 0 26px 60px rgba(0,0,0,.28);
}

.card-front-face {
  display: flex;
  flex-direction: column;
  color: var(--ink);
  background: var(--white);
}
.card-front-face::before { content: ""; position: absolute; inset: 0 0 auto; height: 9px; background: var(--strategy); }
.crisis-card .card-front-face::before { background: var(--crisis); }
.high-risk .card-front-face::before { background: var(--danger); }

.card-back-face {
  display: grid;
  place-content: center;
  justify-items: center;
  transform: rotateY(180deg);
  border: 1px solid rgba(255,255,255,.22);
  text-align: center;
  color: var(--white);
  background:
    linear-gradient(45deg, rgba(255,255,255,.025) 25%, transparent 25%, transparent 75%, rgba(255,255,255,.025) 75%),
    linear-gradient(-45deg, rgba(255,255,255,.025) 25%, transparent 25%, transparent 75%, rgba(255,255,255,.025) 75%),
    #213857;
  background-size: 30px 30px;
  background-position: 0 0, 15px 15px;
}
.card-back-face::before { content: ""; position: absolute; inset: 16px; border: 1px solid rgba(214,169,74,.45); border-radius: 20px; }
.back-ring { display: grid; place-items: center; width: 120px; height: 120px; border: 1px solid rgba(214,169,74,.75); border-radius: 50%; box-shadow: 0 0 0 13px rgba(214,169,74,.08), 0 0 0 27px rgba(214,169,74,.045); }
.back-ring span { font-family: Georgia, serif; color: #e5c477; font-size: 70px; }
.card-back-face p { margin: 46px 0 20px; color: rgba(255,255,255,.74); line-height: 1.8; }
.card-back-face strong { color: #e5c477; letter-spacing: .16em; }

.card-topline, .card-footer, .board-card-top, .print-card-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.card-type {
  border-radius: 999px;
  padding: 7px 11px;
  color: var(--white);
  background: var(--strategy);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .1em;
}
.crisis-card .card-type { background: var(--crisis-deep); }
.high-risk .card-type { background: var(--danger); }
.card-level { color: var(--ink-soft); font-size: 11px; font-weight: 800; }
.card-content { display: flex; flex: 1; flex-direction: column; justify-content: center; padding: 17px 0 10px; }
.card-kicker { margin-bottom: 8px; color: var(--strategy); font-size: 12px; font-weight: 800; letter-spacing: .12em; }
.crisis-card .card-kicker { color: var(--crisis-deep); }
.high-risk .card-kicker { color: var(--danger); }
.card-content h3 { margin-bottom: 12px; font-size: clamp(24px, 2.5vw, 33px); line-height: 1.25; letter-spacing: -.035em; }
.card-summary { margin-bottom: 15px; color: var(--ink-soft); font-size: 14px; line-height: 1.75; }
.card-details { display: grid; gap: 6px; margin-bottom: 15px; }
.card-details p { margin: 0; border-left: 2px solid rgba(40,123,114,.38); padding-left: 9px; color: #39485d; font-size: 11px; line-height: 1.55; }
.crisis-card .card-details p { border-left-color: rgba(229,106,77,.45); }
.discussion-prompt { border-radius: 12px; padding: 11px 13px; background: #edf5f1; }
.crisis-card .discussion-prompt { background: #fbefea; }
.high-risk .discussion-prompt { color: #6e242c; background: #f9e8e9; }
.discussion-prompt strong { display: block; margin-bottom: 4px; font-size: 10px; letter-spacing: .13em; }
.discussion-prompt p { margin: 0; font-size: 12px; font-weight: 700; line-height: 1.55; }
.card-footer { border-top: 1px solid var(--line); padding-top: 12px; color: var(--ink-soft); font-size: 10px; font-weight: 700; letter-spacing: .1em; }

.draw-controls { display: grid; gap: 12px; align-content: center; max-width: 390px; }
.primary-button, .secondary-button {
  border: 0;
  border-radius: 14px;
  padding: 15px 20px;
  font-weight: 800;
  transition: transform .15s ease, box-shadow .15s ease, opacity .15s ease;
}
.primary-button { color: var(--ink); background: var(--gold); box-shadow: 0 10px 24px rgba(214,169,74,.2); }
.secondary-button { border: 1px solid rgba(255,255,255,.18); color: var(--white); background: rgba(255,255,255,.08); }
.primary-button:hover, .secondary-button:hover { transform: translateY(-2px); }
.primary-button:disabled, .secondary-button:disabled { cursor: not-allowed; opacity: .35; transform: none; }
.draw-controls .primary-button { padding: 19px 24px; font-size: 17px; }
.shortcut-hint { margin: 4px 0 0; color: rgba(255,255,255,.46); font-size: 11px; text-align: center; }

.discussion-section { margin-top: 28px; border-radius: 28px; padding: 34px 36px; background: rgba(255,253,248,.88); box-shadow: 0 12px 35px rgba(30,42,63,.08); }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.discussion-board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  min-height: 210px;
  margin-top: 26px;
}
.board-placeholder {
  grid-column: 1 / -1;
  display: grid;
  place-content: center;
  justify-items: center;
  border: 1px dashed rgba(21,36,61,.24);
  border-radius: 20px;
  color: var(--ink-soft);
  text-align: center;
}
.board-placeholder span { color: rgba(21,36,61,.12); font: 800 62px/1 Georgia, serif; }
.board-placeholder p { margin: 8px 0 0; font-size: 13px; line-height: 1.8; }
.board-card { position: relative; overflow: hidden; min-height: 210px; border: 1px solid var(--line); border-top: 5px solid var(--strategy); border-radius: 17px; padding: 20px; background: var(--white); animation: boardIn .3s ease; }
.board-crisis { border-top-color: var(--crisis); }
.board-high-risk { border-top-color: var(--danger); }
@keyframes boardIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
.board-card-top { color: var(--ink-soft); font-size: 10px; font-weight: 800; letter-spacing: .08em; }
.board-card-top button { border: 0; color: var(--ink-soft); background: transparent; font-size: 10px; }
.board-order { display: block; margin: 19px 0 5px; color: rgba(40,123,114,.25); font: 800 32px/1 Georgia, serif; }
.board-crisis .board-order { color: rgba(229,106,77,.3); }
.board-high-risk .board-order { color: rgba(182,47,59,.3); }
.board-card h3 { margin-bottom: 8px; font-size: 17px; line-height: 1.45; }
.board-card p { margin-bottom: 0; color: var(--ink-soft); font-size: 11px; line-height: 1.7; }

.timer-display {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 14px;
  margin: 24px 0 0;
  border-radius: 16px;
  padding: 12px;
  color: var(--strategy-deep);
  background: #e9f3ef;
}
.timer-display strong { font: 800 36px/1 Georgia, serif; letter-spacing: .05em; }
.timer-display button { border: 0; color: inherit; background: transparent; font-size: 12px; font-weight: 800; text-decoration: underline; }
.timer-ending { color: #8d2731; background: #f7e7e8; }
.hidden { display: none !important; }

footer {
  max-width: 1440px;
  margin: auto;
  padding: 0 46px 34px;
  color: var(--ink-soft);
  font-size: 11px;
  line-height: 1.7;
}
footer p { margin: 4px 0; }

dialog {
  width: min(850px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 25px;
  padding: 28px;
  color: var(--ink);
  background: var(--white);
  box-shadow: 0 30px 100px rgba(10,20,35,.3);
}
dialog::backdrop { background: rgba(13,25,43,.7); backdrop-filter: blur(6px); }
.dialog-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.dialog-header h2 { font-size: 32px; }
.guide-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.guide-step { border: 1px solid var(--line); border-radius: 16px; padding: 18px; }
.guide-step span { color: var(--gold); font: 800 30px/1 Georgia, serif; }
.guide-step h3 { margin: 10px 0 6px; }
.guide-step p, .dialog-intro { margin-bottom: 0; color: var(--ink-soft); font-size: 13px; line-height: 1.75; }
.facilitator-note { margin: 16px 0; border-left: 4px solid var(--strategy); padding: 16px 18px; background: #edf5f1; }
.facilitator-note h3 { margin-bottom: 5px; font-size: 15px; }
.facilitator-note p { margin-bottom: 0; color: var(--strategy-deep); line-height: 1.75; }
dialog .secondary-button { border-color: var(--line); color: var(--ink); background: #f0f1ef; }
dialog .dialog-actions { justify-content: flex-end; }

.resource-form { display: grid; gap: 15px; margin-top: 22px; }
.resource-form label { display: grid; gap: 7px; color: var(--ink-soft); font-size: 12px; font-weight: 800; }
.resource-form input { width: 100%; border: 1px solid var(--line); border-radius: 11px; padding: 13px; color: var(--ink); background: white; outline: none; }
.resource-form input:focus { border-color: var(--strategy); box-shadow: 0 0 0 3px rgba(40,123,114,.1); }

.print-dialog { width: min(1200px, calc(100vw - 32px)); }
.all-cards-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.print-card { break-inside: avoid; border: 1px solid var(--line); border-top: 6px solid var(--strategy); border-radius: 15px; padding: 17px; background: white; }
.print-crisis { border-top-color: var(--crisis); }
.print-high-risk { border-top-color: var(--danger); }
.print-card-top { color: var(--ink-soft); font-size: 9px; letter-spacing: .1em; }
.print-category { margin: 15px 0 5px; color: var(--strategy); font-size: 10px; font-weight: 800; }
.print-crisis .print-category { color: var(--crisis-deep); }
.print-card h3 { margin-bottom: 8px; font-size: 16px; line-height: 1.35; }
.print-card p, .print-card li { color: var(--ink-soft); font-size: 9px; line-height: 1.6; }
.print-card ul { margin: 8px 0; padding-left: 17px; }
.print-prompt { border-radius: 8px; padding: 8px; color: var(--ink); background: #f2f2ee; font-size: 9px; line-height: 1.5; }

@media (max-width: 1020px) {
  .control-panel { align-items: stretch; flex-direction: column; }
  .mode-group { display: grid; grid-template-columns: repeat(3, 1fr); }
  .mode-button { min-width: 0; }
  .panel-tools { justify-content: space-between; }
  .card-area { grid-template-columns: 1fr; justify-items: center; gap: 28px; }
  .draw-controls { width: min(100%, 455px); }
  .draw-stage { min-height: 1040px; }
  .discussion-board, .all-cards-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 700px) {
  body { width: 100%; }
  .topbar, .stage-heading, .section-heading { align-items: stretch; flex-direction: column; }
  .topbar, main, footer { width: 100%; padding-left: 18px; padding-right: 18px; }
  .top-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); width: 100%; }
  .top-actions button { min-width: 0; padding-left: 8px; padding-right: 8px; }
  .safety-strip, .control-panel, .draw-stage, .discussion-section { width: 100%; min-width: 0; }
  .mode-group { grid-template-columns: 1fr; }
  .mode-button, .stage-heading > *, .card-area, .draw-controls { min-width: 0; }
  .panel-tools, .section-actions { align-items: stretch; flex-direction: column; }
  .draw-stage { min-height: 930px; border-radius: 22px; padding: 25px 18px; }
  .stage-heading h2 { overflow-wrap: anywhere; }
  .deck-status { align-self: flex-start; white-space: normal; }
  .card-area { margin-top: 24px; }
  .discussion-section { padding: 25px 18px; }
  .discussion-board, .all-cards-grid, .guide-grid { grid-template-columns: 1fr; }
  .draw-card { max-width: 390px; }
  .shortcut-hint { display: none; }
}

@media print {
  body { background: white; }
  body > *:not(dialog[open]) { display: none !important; }
  dialog[open] { position: static; display: block; width: auto; max-height: none; overflow: visible; border: 0; padding: 0; box-shadow: none; }
  dialog::backdrop, .no-print { display: none !important; }
  .all-cards-grid { grid-template-columns: repeat(2, 1fr); gap: 8mm; }
  .print-card { min-height: 115mm; padding: 6mm; border-radius: 4mm; }
  .print-card h3 { font-size: 16pt; }
  .print-card p, .print-card li, .print-prompt { font-size: 9pt; }
}
