.ep-page {
  --ep-ink: #1f2f29;
  --ep-muted: #5a6b62;
  --ep-green: #20473a;
  --ep-green-mid: #356e57;
  --ep-green-soft: #e7f1ec;
  --ep-gold: #ffd978;
  --ep-line: #d6e2dc;
  --ep-red: #b3261e;
  margin: 0;
  background: #f5f8f6;
  color: var(--ep-ink);
}
.ep-page [hidden] { display: none !important; }
.ep-page.ep-playing { overflow: hidden; }

.ep-wrap { max-width: 1180px; margin: 0 auto; padding: 20px 16px 48px; }

.ep-header {
  padding: 22px 26px;
  border-radius: 18px;
  background: linear-gradient(135deg, #20473a, #356e57);
  color: #fff;
}
.ep-header .back-btn { color: #fff; opacity: 0.85; text-decoration: none; font-weight: 600; }
.ep-header .back-btn:hover, .ep-header .back-btn:focus-visible { opacity: 1; text-decoration: underline; }
.ep-eyebrow { margin: 14px 0 4px; color: var(--ep-gold); font-weight: 700; letter-spacing: 0.04em; }
.ep-header h1 { margin: 0 0 8px; font-size: clamp(26px, 4vw, 36px); }
.ep-header p:last-child { margin: 0; max-width: 720px; line-height: 1.6; opacity: 0.92; }

.ep-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 20px;
  margin-top: 20px;
  align-items: start;
}
@media (max-width: 820px) { .ep-layout { grid-template-columns: minmax(0, 1fr); } }

.ep-panel { min-width: 0; padding: 22px; border: 1px solid var(--ep-line); border-radius: 16px; background: #fff; }
.ep-panel h2 { margin: 0 0 12px; font-size: 22px; }
.ep-panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.ep-kicker { margin: 0 0 4px; color: var(--ep-green-mid); font-size: 13px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; }
.ep-hint { margin: 4px 0 10px; color: var(--ep-muted); font-size: 14px; line-height: 1.55; }
.ep-hint code { padding: 1px 6px; border-radius: 6px; background: var(--ep-green-soft); overflow-wrap: anywhere; }
.ep-label { display: block; margin: 14px 0 2px; font-weight: 700; font-size: 15px; }
.ep-count { margin: 8px 0 0; color: var(--ep-muted); font-size: 14px; min-height: 1.4em; }
.ep-error { margin: 0 0 8px; color: var(--ep-red); font-weight: 600; min-height: 1.4em; }
.ep-credit { margin: 16px 4px 0; color: var(--ep-muted); font-size: 14px; }

.ep-input {
  box-sizing: border-box;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #b9cbc2;
  border-radius: 10px;
  background: #fff;
  color: inherit;
  font: inherit;
  font-size: 17px;
  line-height: 1.6;
}
textarea.ep-input { resize: vertical; min-height: 160px; }
.ep-input:focus-visible { outline: 3px solid var(--ep-gold); outline-offset: 1px; border-color: var(--ep-green-mid); }

.ep-field { margin: 16px 0 0; padding: 0; border: 0; min-width: 0; }
.ep-field legend { display: block; margin: 0 0 8px; padding: 0; font-weight: 700; font-size: 15px; }
.ep-options { display: flex; flex-wrap: wrap; gap: 8px; }
.ep-options label { position: relative; cursor: pointer; }
.ep-options input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.ep-options span { display: block; padding: 8px 16px; border: 1px solid #b9cbc2; border-radius: 999px; background: #fff; font-size: 15px; font-weight: 600; }
.ep-options input:checked + span { border-color: var(--ep-green); background: var(--ep-green); color: #fff; }
.ep-options input:focus-visible + span { outline: 3px solid var(--ep-gold); outline-offset: 2px; }
.ep-checks { display: grid; gap: 6px; }
.ep-checks label, .ep-check { display: flex; align-items: center; gap: 8px; font-size: 15px; cursor: pointer; }
.ep-checks input, .ep-check input { width: 18px; height: 18px; accent-color: var(--ep-green); }
.ep-source { margin-top: 4px; }

.ep-names { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-top: 12px; }
.ep-name { display: flex; align-items: center; gap: 6px; }
.ep-name .ep-input { padding: 6px 10px; font-size: 15px; }
.ep-token-face {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--team, var(--ep-green));
  font-size: 19px;
  line-height: 1;
}

.ep-rules { margin: 18px 0 12px; padding: 10px 14px; border-radius: 12px; background: #f8fbf9; border: 1px solid var(--ep-line); }
.ep-rules summary { cursor: pointer; font-weight: 700; }
.ep-rules ol, .ep-rules-dialog ol { margin: 10px 0 0; padding-left: 22px; line-height: 1.6; font-size: 15px; }

.ep-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border: 1px solid var(--ep-green);
  border-radius: 12px;
  background: var(--ep-green);
  color: #fff;
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}
.ep-btn:hover { background: #183a2f; }
.ep-btn:focus-visible { outline: 3px solid var(--ep-gold); outline-offset: 2px; }
.ep-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.ep-btn-ghost { background: #fff; color: var(--ep-green); border-color: #b9cbc2; }
.ep-btn-ghost:hover { background: var(--ep-green-soft); }
.ep-btn-big { width: 100%; padding: 14px 18px; font-size: 19px; }
.ep-btn-small { padding: 6px 10px; font-size: 14px; }
.ep-btn-yes { background: #2f8a3e; border-color: #2f8a3e; }
.ep-btn-yes:hover { background: #24702f; }
.ep-btn-no { background: #c0392b; border-color: #c0392b; }
.ep-btn-no:hover { background: #a02e22; }

/* ---------- stage ---------- */
.ep-stage {
  position: fixed;
  inset: 0;
  z-index: 400; /* above the site menu (z 100) */
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  background: #fbf8f1;
}
.ep-stage-board { position: relative; display: grid; place-items: center; min-width: 0; min-height: 0; padding: 8px; container-type: size; overflow: hidden; }
/* The board always fits its area (portrait or landscape boards): --ratio is width / height. */
.ep-board { --ratio: 1.2; position: relative; width: min(100cqw - 16px, (100cqh - 16px) * var(--ratio)); aspect-ratio: 2494 / 2076; container-type: inline-size; border-radius: 12px; overflow: hidden; background: #fff; box-shadow: 0 4px 22px rgba(32, 71, 58, 0.15); user-select: none; }
.ep-board img { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.ep-overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.ep-connector { fill: none; stroke: #20473a; stroke-width: 9; stroke-dasharray: 22 16; stroke-linecap: round; filter: drop-shadow(0 0 4px #fff) drop-shadow(0 0 4px #fff); }
.ep-target { fill: none; stroke-width: 9; stroke-dasharray: 18 10; opacity: 0.9; transition: cx 0.25s, cy 0.25s; animation: ep-spin 6s linear infinite; transform-box: fill-box; transform-origin: center; }
@keyframes ep-spin { to { transform: rotate(360deg); } }

.ep-tokens { position: absolute; inset: 0; pointer-events: none; }
.ep-token {
  position: absolute;
  display: grid;
  place-items: center;
  width: 3.8%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: #fff;
  border: 0.45cqw solid var(--team);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.35);
  font-size: 2.4cqw;
  line-height: 1;
  transition: left 0.22s ease-out, top 0.22s ease-out, transform 0.2s;
}
.ep-token.is-active { z-index: 2; transform: translate(-50%, -50%) scale(1.22); box-shadow: 0 0 0 0.4cqw #fff, 0 0 0 0.8cqw var(--team), 0 4px 12px rgba(0, 0, 0, 0.4); }
.ep-token.is-long { transition: left 0.8s cubic-bezier(0.5, 0, 0.3, 1), top 0.8s cubic-bezier(0.5, 0, 0.3, 1), transform 0.2s; }

.ep-toast {
  position: absolute;
  left: 50%;
  top: 4%;
  transform: translate(-50%, -20px);
  padding: 0.5em 1.1em;
  border-radius: 999px;
  background: var(--ep-green);
  color: #fff;
  font-size: 4.6cqw;
  font-weight: 800;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.25s;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
}
.ep-toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.ep-toast.is-good { background: #2f8a3e; }
.ep-toast.is-bad { background: #c0392b; }

/* question card */
.ep-card-layer { position: absolute; inset: 0; display: grid; place-items: center; padding: 3vh 3vw; background: rgba(31, 47, 41, 0.35); z-index: 5; }
.ep-card {
  position: relative;
  box-sizing: border-box;
  width: min(760px, 90%);
  max-height: 100%;
  overflow: auto;
  padding: 0 28px 24px;
  border-radius: 22px;
  background: #fff;
  text-align: center;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.3);
}
.ep-card::before {
  content: '';
  display: block;
  height: 18px;
  margin: 0 -28px 16px;
  background: linear-gradient(90deg, #e94b5a, #f39a3d, #f7d64a, #67b85a, #4f8fd8, #8e64c4);
}
.ep-card-layer.is-in .ep-card { animation: ep-flip 0.45s ease-out; }
@keyframes ep-flip { from { transform: rotateY(80deg) scale(0.8); opacity: 0; } to { transform: none; opacity: 1; } }
.ep-card-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.ep-card-team { padding: 4px 14px; border-radius: 999px; background: var(--team); color: #fff; font-weight: 800; font-size: 18px; }
.ep-card-count { color: var(--ep-muted); font-weight: 700; }
.ep-card-label { margin: 18px 0 0; color: var(--ep-green-mid); font-size: clamp(18px, 2.4vw, 28px); font-weight: 700; }
.ep-card-q { margin: 14px 0 18px; font-size: clamp(26px, 4vw, 52px); font-weight: 800; line-height: 1.35; overflow-wrap: anywhere; outline: none; }
.ep-card-q.is-big { font-size: clamp(48px, 9vw, 120px); line-height: 1.15; }
.ep-card-a { margin: 14px 0 0; padding: 10px 16px; border-radius: 14px; background: #fff6d6; font-family: Andika, "Microsoft YaHei", sans-serif; font-size: clamp(22px, 3.2vw, 40px); font-weight: 700; overflow-wrap: anywhere; }
.ep-card-judge { display: flex; justify-content: center; gap: 14px; margin-top: 22px; flex-wrap: wrap; }
.ep-card-judge .ep-btn { min-width: 150px; padding: 14px 22px; font-size: 22px; }

.ep-results h2 { margin: 6px 0 14px; font-size: clamp(28px, 4vw, 44px); }
.ep-ranking { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.ep-ranking li { display: flex; align-items: center; gap: 14px; padding: 10px 16px; border-radius: 14px; background: #f8fbf9; border: 2px solid var(--team); font-size: clamp(20px, 2.6vw, 30px); font-weight: 800; }
.ep-ranking li:nth-child(n + 4) { font-size: 18px; opacity: 0.8; }
.ep-medal { width: 1.6em; text-align: center; }
.ep-ranking .ep-token-face { width: 1.6em; height: 1.6em; font-size: 0.9em; }

/* side panel */
.ep-side { display: flex; flex-direction: column; gap: 14px; padding: 16px; border-left: 1px solid var(--ep-line); background: #fff; overflow-y: auto; }
.ep-turn { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 14px; background: var(--ep-green-soft); border: 3px solid var(--team, var(--ep-green)); }
.ep-turn .ep-token-face { width: 56px; height: 56px; font-size: 32px; border-color: var(--team, var(--ep-green)); }
.ep-turn-label { margin: 0; color: var(--ep-muted); font-size: 14px; font-weight: 700; }
.ep-turn h2 { margin: 2px 0 0; font-size: 26px; line-height: 1.2; overflow-wrap: anywhere; }
.ep-dice-row { display: flex; align-items: center; gap: 12px; }
.ep-status { margin: 0; font-size: 17px; font-weight: 600; line-height: 1.4; }
.ep-die {
  flex: none;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 4px;
  width: 78px;
  height: 78px;
  padding: 10px;
  border: 2px solid #c9d6cf;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 4px 0 #c9d6cf;
  cursor: pointer;
}
.ep-die:disabled { cursor: default; }
.ep-die:focus-visible { outline: 3px solid var(--ep-gold); outline-offset: 2px; }
.ep-die span { border-radius: 50%; background: var(--ep-green); visibility: hidden; }
.ep-die span.on { visibility: visible; }
.ep-die.is-rolling { animation: ep-shake 0.12s linear infinite; }
@keyframes ep-shake { 0% { transform: rotate(-8deg); } 50% { transform: rotate(8deg); } 100% { transform: rotate(-8deg); } }
.ep-actions { display: grid; gap: 8px; }
.ep-manual p { margin: 0 0 6px; color: var(--ep-muted); font-size: 14px; }
.ep-manual div { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.ep-manual .ep-btn { padding: 10px 0; font-size: 20px; }
.ep-team-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.ep-team-list li { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 10px; border: 2px solid transparent; }
.ep-team-list li.is-current { border-color: var(--team); background: #f8fbf9; }
.ep-team-list .ep-token-face { width: 30px; height: 30px; font-size: 17px; }
.ep-team-name { flex: 1; font-weight: 700; min-width: 0; overflow-wrap: anywhere; }
.ep-team-info { color: var(--ep-muted); font-size: 14px; white-space: nowrap; }
.ep-side-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: auto; padding-top: 10px; border-top: 1px solid var(--ep-line); }
.ep-side-credit { margin: 0; color: var(--ep-muted); font-size: 12px; }

.ep-rollstage { position: absolute; inset: 0; z-index: 6; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3vh; background: rgba(20, 40, 32, 0.28); pointer-events: none; }
.ep-bigdie { width: min(30vh, 30vw); height: min(30vh, 30vw); border-radius: 18%; background: #fff; border: max(6px, 0.9vh) solid var(--team, #20473a); box-shadow: 0 2.4vh 5vh rgba(0, 0, 0, 0.3); }
.ep-bigdie svg { display: block; width: 100%; height: 100%; }
.ep-rollnum { margin: 0; padding: 0.5em 1.2em; border-radius: 999px; background: #fff; color: #20473a; font-weight: 800; font-size: clamp(1.2rem, 3.6vh, 2.2rem); box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18); opacity: 0; transform: translateY(1vh); transition: opacity 0.2s, transform 0.2s; }
.ep-rollnum.is-in { opacity: 1; transform: none; }
.ep-rollnum b { color: #c8553d; font-size: 1.3em; }
.ep-rules-dialog { max-width: 560px; border: 0; border-radius: 18px; padding: 22px 26px; box-shadow: 0 18px 50px rgba(0, 0, 0, 0.3); }
.ep-rules-dialog h2 { margin: 0; }
.ep-rules-dialog form { margin-top: 16px; text-align: right; }

@media (max-width: 900px) {
  .ep-stage { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
  .ep-side { border-left: 0; border-top: 1px solid var(--ep-line); max-height: 45vh; }
}
@media (prefers-reduced-motion: reduce) {
  .ep-token, .ep-token.is-long, .ep-toast, .ep-target { transition: none; animation: none; }
  .ep-card-layer.is-in .ep-card, .ep-die.is-rolling { animation: none; }
}

/* game picker (学生设计桌游) */
.ep-games { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; margin-top: 8px; }
.ep-game { position: relative; display: grid; gap: 6px; padding: 8px; border: 2px solid var(--ep-line); border-radius: 14px; background: #fff; cursor: pointer; }
.ep-game input { position: absolute; opacity: 0; pointer-events: none; }
.ep-game img { width: 100%; aspect-ratio: 6 / 5; object-fit: cover; border-radius: 9px; background: #f6f2e8; }
.ep-game span { display: grid; gap: 2px; }
.ep-game small { color: var(--ep-muted); font-size: 13px; }
.ep-game:has(input:checked) { border-color: var(--ep-green); box-shadow: 0 0 0 3px rgba(53, 110, 87, 0.18); }
.ep-game:has(input:focus-visible) { outline: 3px solid var(--ep-green); outline-offset: 2px; }

/* Candy Race fork choice */
.ep-fork { display: grid; gap: 8px; padding: 10px; border-radius: 14px; background: #fff4dc; }
.ep-fork-q { margin: 0; font-weight: 800; font-size: 18px; }
.ep-fork .ep-btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* marks drawn over a student's photo board (Candy Race) */
.ep-link { fill: none; stroke: #c2417a; stroke-width: 12; stroke-dasharray: 28 18; stroke-linecap: round; filter: drop-shadow(0 0 3px #fff) drop-shadow(0 0 3px #fff); }
.ep-fork-ring { fill: rgba(255, 236, 200, 0.35); stroke: #d9661f; stroke-width: 12; stroke-dasharray: 16 10; }
.ep-mark-text { font-family: KaiTi, STKaiti, "Kaiti SC", serif; font-weight: 700; fill: #20473a; text-anchor: middle; paint-order: stroke; stroke: #fff; stroke-width: 16px; stroke-linejoin: round; }
.ep-podium-box { stroke: #20473a; stroke-width: 6; }
.ep-podium-1 { fill: #f5d55a; }
.ep-podium-2 { fill: #d9d9e0; }
.ep-podium-3 { fill: #e0a066; }

/* Escape the Classroom: the chasing teacher */
.ep-token.ep-teacher { --team: #c62f2f; z-index: 3; width: 4.6%; font-size: 2.9cqw; background: #fff5f2; }

/* Escape the Classroom: desk words written on the board */
.ep-desk-text { font-family: KaiTi, STKaiti, "Kaiti SC", serif; font-weight: 700; fill: #2b2118; text-anchor: middle; }
.ep-desk-text.is-blank { fill: #8a6a48; font-family: "Segoe Print", cursive; }
#epDeskFromWords { margin-top: 6px; }

/* 汉字大富翁: who owns a square */
.ep-owner { fill: #fff; stroke-width: 7; }
.ep-owner-face { text-anchor: middle; }
