:root {
  --bg: #1b1340;
  --panel: #2b2070;
  --lime: #b6ff3c;
  --pink: #ff4f8b;
  --sky: #4fd1ff;
  --sun: #ffd23f;
  --good: #38e07b;
  --bad: #ff3b5c;
  --ink: #ffffff;
  --win: #eef2ff;
}

* { box-sizing: border-box; margin: 0; }

body {
  font-family: "Baloo 2", "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  min-height: 100vh;
  padding: 20px;
  background: radial-gradient(circle at 15% 0%, #3d2ba8 0, var(--bg) 55%) fixed;
}

.top { text-align: center; margin-bottom: 18px; }
.top h1 { font-size: clamp(1.8rem, 4vw, 2.8rem); font-weight: 700; color: var(--lime); text-shadow: 0 3px 0 #0006; }
.top p { font-size: 1.1rem; opacity: .9; }

.app {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 22px;
  max-width: 1150px;
  margin: 0 auto;
}

/* ---------- Simulated computer window ---------- */
.window {
  background: var(--win);
  color: #1d1650;
  border-radius: 18px;
  border: 4px solid var(--sky);
  box-shadow: 8px 8px 0 #0006;
  overflow: hidden;
  position: relative;
}
.window.shake { animation: shake .5s linear 4; }
.window.slow { cursor: progress; }

.titlebar {
  display: flex; align-items: center; gap: 12px;
  background: var(--sky); padding: 10px 14px; font-weight: 600; color: #0b2a4a;
}
.dots { display: flex; gap: 6px; }
.dots i { width: 12px; height: 12px; border-radius: 50%; background: #fff9; }
.wtitle { flex: 1; }
.shield-badge { background: var(--good); color: #063; padding: 2px 10px; border-radius: 99px; font-size: .85rem; animation: pop .4s; }

.grid {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  padding: 18px;
  min-height: 330px;
}

.file {
  position: relative;
  background: #fff;
  border: 3px solid #cfd6ff;
  border-radius: 14px;
  padding: 12px 4px 8px;
  text-align: center;
  transition: background .3s, border-color .3s, transform .2s;
}
.file .icon { display: block; font-size: 2.2rem; line-height: 1.2; }
.file .name { display: block; font-size: .78rem; font-weight: 500; word-break: break-all; margin-top: 4px; }
.file .badge { position: absolute; top: -12px; right: -8px; font-size: 1.5rem; }

.file.suspect { border-color: var(--sun); animation: pulse 1s ease-in-out infinite; }
.file.opening { transform: scale(1.12); border-color: var(--pink); box-shadow: 0 0 0 6px #ff4f8b44; }
.file.looking { border-color: var(--sky); background: #e1f6ff; transform: translateY(-4px); }
.file.infected {
  background: #d8ff8f; border-color: #6bbd00;
  animation: wiggle .6s ease-in-out 2;
}
.file.infected .icon { filter: hue-rotate(60deg) saturate(1.6); }
.file.quarantined { background: #d9ffe8; border-color: var(--good); }
.file.quarantined .icon { opacity: .45; }

.bug {
  position: absolute; z-index: 5; font-size: 2rem;
  transform: translate(-50%, -50%); pointer-events: none;
  filter: drop-shadow(0 4px 2px #0005);
}
.bug[hidden] { display: none; }

.popup {
  position: absolute; z-index: 8; width: 190px;
  background: #fff; border: 3px solid var(--bad); border-radius: 12px;
  box-shadow: 4px 4px 0 #0005; animation: pop .35s;
  font-size: .85rem; font-weight: 500;
}
.popup b { display: block; background: var(--bad); color: #fff; padding: 4px 8px; }
.popup span { display: block; padding: 8px; }

.statusbar {
  display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; align-items: center;
  padding: 12px 18px; background: #dfe5ff; font-weight: 500;
}
.status.ok { color: #0a7a3a; }
.status.bad { color: var(--bad); }
.status.safe { color: #0a7a3a; }
.health { display: flex; align-items: center; gap: 8px; }
.bar { width: 130px; height: 16px; background: #fff; border-radius: 99px; border: 2px solid #1d1650; overflow: hidden; }
#healthFill { height: 100%; width: 100%; background: linear-gradient(90deg, var(--bad), var(--sun), var(--good)); background-size: 130px 100%; background-position: right; transition: width .4s; }

/* ---------- Narrator side ---------- */
.side { display: flex; flex-direction: column; gap: 16px; }

.narrator { display: flex; gap: 12px; align-items: flex-start; }
.robo { font-size: 3.6rem; animation: bob 2.4s ease-in-out infinite; }
.bubble {
  position: relative; flex: 1;
  background: var(--panel); border: 3px solid var(--sun); border-radius: 18px;
  padding: 14px 16px; line-height: 1.45; min-height: 150px;
}
.bubble::before {
  content: ""; position: absolute; left: -14px; top: 22px;
  border: 8px solid transparent; border-right: 12px solid var(--sun); border-left: 0;
}
.bubble.fresh { animation: pop .35s; }
.bubble h2 { font-size: 1.25rem; color: var(--sun); margin-bottom: 6px; }
.bubble ul { padding-left: 20px; margin-top: 6px; }
.bubble li { margin-bottom: 4px; }
.bubble .good { color: var(--good); font-weight: 600; }
.bubble .bad { color: var(--pink); font-weight: 600; }

.steps { display: flex; gap: 8px; list-style: none; padding: 0; justify-content: center; }
.steps li { width: 16px; height: 16px; border-radius: 50%; background: #ffffff33; transition: .3s; }
.steps li.done { background: var(--lime); }
.steps li.skipped { background: transparent; border: 2px dashed #ffffff77; }

.controls { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; gap: 10px; }
.row .btn { flex: 1; }

.btn {
  font: inherit; font-weight: 600; font-size: 1.05rem; cursor: pointer;
  padding: 12px 16px; border: 0; border-radius: 14px; color: #1b1340;
  box-shadow: 0 5px 0 #0007; transition: transform .1s, box-shadow .1s, opacity .2s;
}
.btn:hover:not(:disabled) { transform: translateY(-2px); }
.btn:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 #0007; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:focus-visible { outline: 4px solid #fff; outline-offset: 3px; }
.primary { background: var(--lime); }
.auto { background: var(--sky); }
.shield { background: var(--good); }
.shield.on { background: #fff; outline: 4px solid var(--good); }
.ghost { background: #ffffffdd; }
.hint { font-size: .9rem; opacity: .85; text-align: center; }

/* ---------- Animations ---------- */
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes pulse { 50% { transform: scale(1.08); box-shadow: 0 0 0 6px #ffd23f55; } }
@keyframes wiggle { 25% { transform: rotate(-5deg); } 75% { transform: rotate(5deg); } }
@keyframes shake { 25% { transform: translate(-6px, 2px); } 75% { transform: translate(6px, -2px); } }
@keyframes bob { 50% { transform: translateY(-8px); } }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .grid { gap: 8px; padding: 14px 10px; }
  .file .icon { font-size: 1.7rem; }
  .file .name { font-size: .66rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- v2: one message at a time, board-friendly ---------- */
.bubble { display: flex; gap: 16px; align-items: flex-start; min-height: 190px; padding: 18px 20px; }
.bubble::before { display: none; }
.bicon { font-size: 3.4rem; line-height: 1; flex-shrink: 0; }
.bubble h2 { font-size: 1.5rem; }
#bubbleText { font-size: 1.2rem; line-height: 1.5; }

.stage { text-align: center; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.stage-label { font-weight: 600; font-size: 1.1rem; color: var(--sky); }
.msg-count { font-size: .9rem; opacity: .8; }
.steps li.current { background: var(--sun); transform: scale(1.35); }

.row3 { display: flex; gap: 10px; }
.row3 .btn { flex: 1; }
.btn.small { font-size: .95rem; padding: 10px 8px; }
.kbd { font-size: .8rem; opacity: .7; text-align: center; }

/* Projector / board mode: bigger text for the whole class */
body.big .bubble { min-height: 260px; }
body.big .bicon { font-size: 5rem; }
body.big .bubble h2 { font-size: 2.2rem; }
body.big #bubbleText { font-size: 1.8rem; }
body.big .file .icon { font-size: 3rem; }
body.big .file .name { font-size: 1rem; }
body.big .stage-label { font-size: 1.5rem; }
body.big .app { max-width: 1500px; }
body.big .btn { font-size: 1.25rem; }
@media (max-width: 860px) { body.big #bubbleText { font-size: 1.3rem; } body.big .bubble h2 { font-size: 1.6rem; } }

/* ---------- Step counter, back button, board mode ---------- */
.counter { font-size: .85rem; opacity: .75; margin-bottom: 4px; }
.row .primary { flex: 1.4; }

body.board { padding: 14px; }
body.board .app { grid-template-columns: 1.1fr 1fr; max-width: none; }
body.board .top p, body.board .hint { display: none; }
body.board .top h1 { font-size: 2rem; }
body.board .bubble { min-height: 260px; font-size: 1.55rem; line-height: 1.5; }
body.board .bubble h2 { font-size: 2.1rem; }
body.board .counter { font-size: 1.1rem; }
body.board .file .icon { font-size: 3rem; }
body.board .file .name { font-size: 1rem; }
body.board .btn { font-size: 1.2rem; }
body.board .robo { font-size: 4.5rem; }
body.board .statusbar { font-size: 1.2rem; }

/* ---------- Fixed-size message box (never changes height) ---------- */
.bubble { height: 220px; min-height: 0; overflow-y: auto; }
.bubble ul { margin-top: 8px; }
body.board .bubble { height: 360px; min-height: 0; }
@media (max-width: 860px) { .bubble { height: 240px; } }

/* ---------- Baloo 2 adjustments (smaller letters, so slightly larger text) ---------- */
.bubble { height: 250px; font-size: 1.12rem; line-height: 1.35; }
.bubble h2 { font-size: 1.4rem; line-height: 1.2; }
.btn { font-size: 1.1rem; line-height: 1.3; }
.top h1 { font-weight: 800; }
body.board .bubble { height: 380px; font-size: 1.6rem; }
body.board .bubble h2 { font-size: 2.1rem; }
@media (max-width: 860px) { .bubble { height: 260px; } }