:root {
  --ink: #161a3d;
  --bg: #231f5c;
  --paper: #fffaf0;
  --mint: #3ddc97;
  --red: #ff4d6d;
  --yellow: #ffd23f;
  --blue: #4cc9f0;
  --shadow: 4px 4px 0 var(--ink);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Baloo 2", "Segoe UI", Arial, system-ui, sans-serif;
  line-height: 1.3;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 10%, #3b33a0 0, transparent 40%),
    radial-gradient(circle at 90% 90%, #5b2a86 0, transparent 40%),
    var(--bg);
  min-height: 100vh;
  padding: 16px;
}
.top { text-align: center; color: #fff; margin-bottom: 14px; }
.top h1 { margin: 0; font-size: clamp(1.6rem, 4vw, 2.6rem); letter-spacing: .5px; text-shadow: 3px 3px 0 var(--ink); font-weight: 800; }
.top p { margin: 6px 0 0; font-size: 1.1rem; color: #d9d6ff; }

.layout { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 16px; max-width: 1200px; margin: 0 auto; }
@media (max-width: 860px) { .layout { grid-template-columns: 1fr; } }

.stage {
  position: relative; min-height: 460px; aspect-ratio: 16 / 10;
  background: var(--paper); border: 4px solid var(--ink); border-radius: 22px; box-shadow: 6px 6px 0 var(--ink);
  background-image: radial-gradient(#d9d2bd 1.5px, transparent 1.5px); background-size: 22px 22px;
  overflow: hidden;
}
.links { position: absolute; inset: 0; width: 100%; height: 100%; }
.links line { stroke: #9a95c9; stroke-width: 4; stroke-dasharray: 2 9; stroke-linecap: round; }
.links line.hot { stroke: var(--red); stroke-dasharray: none; }

.attacker { position: absolute; left: 2%; top: 3%; text-align: center; font-size: 2.4rem; line-height: 1; }
.attacker small { display: block; font-size: .85rem; font-weight: 600; }

.node {
  position: absolute; transform: translate(-50%, -50%);
  width: 84px; padding: 6px 4px 4px; text-align: center; cursor: pointer; font: inherit; color: var(--ink);
  background: #fff; border: 4px solid var(--mint); border-radius: 16px; box-shadow: var(--shadow);
  transition: transform .15s, background .3s, border-color .3s;
}
.node:hover { transform: translate(-50%, -50%) scale(1.07); }
.node:focus-visible { outline: 4px solid var(--blue); outline-offset: 3px; }
.node .pc { font-size: 2rem; display: block; line-height: 1.1; }
.node .name { font-weight: 600; font-size: .9rem; }
.node .badge { position: absolute; top: -16px; right: -14px; font-size: 1.5rem; }
.node.shielded { border-color: var(--blue); background: #e6f8ff; }
.node.infected { border-color: var(--red); background: #ffe3e8; animation: shake .5s, throb 1.2s ease-in-out .5s infinite; cursor: default; }
.node.scanning { box-shadow: 0 0 0 6px var(--yellow), var(--shadow); }
.node.blocked { animation: bounce .6s; }
@keyframes throb { 50% { box-shadow: 0 0 0 8px rgba(255, 77, 109, .35), var(--shadow); } }
@keyframes shake { 20% { translate: -6px 0; } 40% { translate: 6px 0; } 60% { translate: -4px 0; } 80% { translate: 4px 0; } }
@keyframes bounce { 30% { scale: 1.2; } 60% { scale: .92; } }

.flyer { position: absolute; font-size: 1.8rem; transform: translate(-50%, -50%); transition: left .9s ease-in-out, top .9s ease-in-out; pointer-events: none; z-index: 5; }

.legend { position: absolute; right: 10px; bottom: 8px; display: flex; gap: 12px; flex-wrap: wrap; font-size: .85rem; font-weight: 500; background: #ffffffcc; padding: 4px 10px; border-radius: 12px; }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--ink); vertical-align: -1px; }
.dot.healthy { background: var(--mint); } .dot.shielded { background: var(--blue); } .dot.infected { background: var(--red); }

.panel { display: flex; flex-direction: column; gap: 12px; }
.card { background: var(--paper); border: 4px solid var(--ink); border-radius: 18px; box-shadow: var(--shadow); padding: 12px 16px; }
.explain { background: var(--yellow); }
.explain h2 { margin: 0 0 6px; font-size: 1.35rem; }
.explain p { margin: 0; font-size: 1.08rem; line-height: 1.45; max-width: 60ch; }
.counters { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.count { text-align: center; border: 4px solid var(--ink); border-radius: 16px; box-shadow: var(--shadow); padding: 6px 4px; }
.count b { display: block; font-size: 2rem; line-height: 1; }
.count span { font-size: .85rem; font-weight: 500; }
.c-healthy { background: var(--mint); } .c-shielded { background: var(--blue); } .c-infected { background: var(--red); color: #fff; }
.logbox { flex: 1; min-height: 120px; max-height: 240px; overflow: auto; }
.logbox h3 { margin: 0 0 6px; font-size: 1.05rem; }
.logbox ol { margin: 0; padding-left: 22px; font-size: .95rem; line-height: 1.4; }
.logbox li { margin-bottom: 3px; }

.controls { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; max-width: 1200px; margin: 18px auto 6px; }
.btn {
  font: inherit; font-weight: 600; font-size: 1.05rem; color: var(--ink); background: #fff;
  border: 4px solid var(--ink); border-radius: 16px; padding: 10px 18px; cursor: pointer; box-shadow: var(--shadow);
  transition: transform .1s, box-shadow .1s;
}
.btn:hover:not(:disabled) { transform: translate(-1px, -1px); }
.btn:active:not(:disabled) { transform: translate(4px, 4px); box-shadow: 0 0 0 var(--ink); }
.btn:focus-visible { outline: 4px solid var(--blue); outline-offset: 3px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--yellow); font-size: 1.25rem; }
.btn.green { background: var(--mint); }
.btn.blue { background: var(--blue); }
.hint { text-align: center; color: #d9d6ff; margin: 6px 0 0; }

.tips { max-width: 1200px; margin: 18px auto 0; background: var(--mint); border: 4px solid var(--ink); border-radius: 22px; box-shadow: 6px 6px 0 var(--ink); padding: 14px 22px; }
.tips[hidden] { display: none; }
.tips h2 { margin: 0 0 8px; }
.tips ul { margin: 0; padding-left: 20px; font-size: 1.1rem; line-height: 1.7; }
footer { text-align: center; color: #b7b3ec; margin-top: 22px; font-size: .9rem; }

@media (max-width: 600px) {
  .stage { min-height: 380px; aspect-ratio: auto; height: 420px; }
  .node { width: 66px; } .node .pc { font-size: 1.5rem; } .node .name { font-size: .75rem; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; } .flyer { transition-duration: .01s; } }

.notice { max-width: 1200px; margin: 8px auto 0; text-align: center; font-weight: 600; color: var(--ink); }
.notice:not(:empty) { background: var(--yellow); border: 4px solid var(--ink); border-radius: 16px; box-shadow: var(--shadow); padding: 8px 14px; }

/* ---------- Board mode (big screen / projector) ---------- */
body.board { padding: 10px 16px; height: 100vh; overflow: hidden; display: flex; flex-direction: column; }
.board .top, .board .controls, .board .notice, .board .tips { flex-shrink: 0; }
.board .layout { flex: 1; min-height: 0; grid-template-rows: minmax(0, 1fr); }
.board .panel { min-height: 0; }
.board .counters { flex-shrink: 0; }
.board .top { margin-bottom: 8px; }
.board .top h1 { font-size: 2.2rem; }
.board .top p, .board .hint, .board footer { display: none; }
.board .layout, .board .controls, .board .tips, .board .notice { max-width: none; }
.board .controls { margin: 10px 0 0; }
.board .layout { grid-template-columns: minmax(0, 2.3fr) minmax(340px, 1fr); }
.board .stage { aspect-ratio: auto; height: auto; min-height: 0; }
.board .node { width: 128px; padding: 8px 6px 6px; border-width: 5px; }
.board .node .pc { font-size: 3.2rem; }
.board .node .name { font-size: 1.35rem; }
.board .node .badge { font-size: 2.2rem; top: -22px; right: -18px; }
.board .links line { stroke-width: 6; }
.board .flyer { font-size: 3rem; }
.board .attacker { font-size: 3.6rem; }
.board .attacker small { font-size: 1.2rem; }
.board .legend { font-size: 1.15rem; gap: 18px; }
.board .explain { flex-shrink: 1; min-height: 0; overflow: auto; }
.board .explain h2 { font-size: 2rem; }
.board .explain p { font-size: 1.5rem; line-height: 1.4; }
.board .count b { font-size: 3.2rem; }
.board .count span { font-size: 1.2rem; }
.board .logbox { flex: 1; min-height: 0; max-height: none; overflow: auto; }
.board .logbox h3 { font-size: 1.4rem; }
.board .logbox ol { font-size: 1.2rem; }
.board .btn { font-size: 1.2rem; padding: 8px 16px; }
.board .btn.primary { font-size: 1.4rem; }
.board .notice { font-size: 1.4rem; }
.board .panel .tips { flex: 1; min-height: 0; max-height: none; overflow: auto; margin: 0; padding: 10px 16px; border-radius: 18px; box-shadow: var(--shadow); }
.board.finished .logbox { display: none; }
.board .tips h2 { font-size: 1.35rem; margin-bottom: 4px; }
.board .tips ul { font-size: 1.1rem; line-height: 1.3; padding-left: 18px; }
/* In board mode the notice floats above the controls so the layout never jumps */
.board .notice:not(:empty) { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); z-index: 20; max-width: 80vw; }
