/* ISSMCSP Cyber Range — RPG v3 (ZDD arcade edition) */
:root {
  color-scheme: dark;
  --bg: #1a1a2e;
  --bg2: #16213e;
  --card: #0f3460;
  --panel: #141c37;
  --panel-2: #172142;
  --border: rgba(255, 255, 255, 0.10);
  --border-bright: rgba(78, 205, 196, 0.42);
  --text: #f5f5f5;
  --muted: #a0a0b8;
  --accent: #e94560;
  --amber: #f9a826;
  --teal: #4ecdc4;
  --green: #53d769;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}
* { box-sizing: border-box; }
html { min-height: 100%; background: #12121f; }
body {
  min-height: 100%; margin: 0; color: var(--text);
  background:
    radial-gradient(circle at 18% 0%, rgba(233, 69, 96, 0.14), transparent 34rem),
    radial-gradient(circle at 92% 8%, rgba(78, 205, 196, 0.12), transparent 30rem),
    linear-gradient(180deg, #1a1a2e 0%, #12121f 100%);
  font-family: var(--mono);
  letter-spacing: 0.01em;
}
button, a { font: inherit; }
button { cursor: pointer; }

.app-shell { width: min(1200px, 100%); margin: 0 auto; padding: 18px clamp(12px, 3vw, 30px) 40px; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.brand { display: inline-flex; align-items: baseline; gap: 10px; color: var(--accent); font-size: 1.02rem; font-weight: 900; text-decoration: none; text-transform: uppercase; letter-spacing: 0.06em; }
.brand small { color: var(--muted); font-size: 0.64rem; font-weight: 600; letter-spacing: 0.18em; }
.header-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.text-link, .quiet-button {
  border: 1px solid var(--border); border-radius: 7px; background: transparent; color: var(--muted);
  padding: 7px 10px; font-size: 0.72rem; text-decoration: none;
  transition: border-color 150ms ease, color 150ms ease, background 150ms ease;
}
.text-link:hover, .quiet-button:hover { color: var(--teal); border-color: var(--teal); background: rgba(78, 205, 196, 0.08); }

.game-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; margin-top: 16px; align-items: start; }

.stage-wrap { position: relative; min-width: 0; overflow: hidden; border: 1px solid var(--border-bright); border-radius: 12px; background: #06080f; box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45), inset 0 0 0 1px rgba(255, 255, 255, 0.03); }
#gameCanvas { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; outline: none; background: #06080f; touch-action: manipulation; }
#gameCanvas:focus-visible { box-shadow: inset 0 0 0 3px var(--teal); }
.scanlines { pointer-events: none; position: absolute; inset: 0; opacity: 0.13; background: repeating-linear-gradient(0deg, transparent 0, transparent 3px, rgba(255, 255, 255, 0.07) 4px); mix-blend-mode: screen; }
.stage-hint { position: absolute; left: 12px; bottom: 9px; color: rgba(245, 245, 245, 0.7); font-size: 0.64rem; text-shadow: 0 2px 0 #000; pointer-events: none; }

.zone-banner { position: absolute; top: 12px; left: 50%; transform: translate(-50%, -14px); display: grid; gap: 1px; justify-items: center; padding: 8px 16px; border: 1px solid var(--border-bright); border-radius: 8px; background: rgba(10, 14, 26, 0.86); opacity: 0; pointer-events: none; transition: opacity 220ms ease, transform 220ms ease; }
.zone-banner.show { opacity: 1; transform: translate(-50%, 0); }
.zone-banner b { color: var(--teal); font-size: 0.78rem; letter-spacing: 0.16em; }
.zone-banner span { color: var(--muted); font-size: 0.6rem; letter-spacing: 0.1em; text-transform: uppercase; }

.timer-banner { position: absolute; top: 12px; left: 12px; display: flex; align-items: center; gap: 10px; padding: 7px 12px; border: 1px solid var(--border-bright); border-radius: 8px; background: rgba(10, 14, 26, 0.9); font-size: 0.68rem; }
.timer-banner .tb-label { color: var(--accent); letter-spacing: 0.14em; }
.timer-banner .tb-time { color: var(--text); font-weight: 900; font-size: 0.95rem; }
.timer-banner .tb-count { color: var(--muted); letter-spacing: 0.08em; }
.timer-banner.hot { border-color: var(--accent); box-shadow: 0 0 0 1px rgba(233, 69, 96, 0.4), 0 0 24px rgba(233, 69, 96, 0.28); animation: pulse 0.9s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 1px rgba(233, 69, 96, 0.7), 0 0 30px rgba(233, 69, 96, 0.45); } }

.mission-panel { border: 1px solid var(--border); border-radius: 12px; background: linear-gradient(180deg, rgba(20, 28, 55, 0.95), rgba(18, 24, 46, 0.92)); padding: 14px; box-shadow: 0 12px 30px rgba(0, 0, 0, 0.28); }
.panel-kicker { color: var(--teal); font-size: 0.64rem; font-weight: 800; letter-spacing: 0.18em; text-transform: uppercase; }
.panel-title { margin: 5px 0 12px; color: #fff; font-size: 1rem; letter-spacing: 0.04em; }

.mission-list { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 5px; }
.mission-list li { display: flex; gap: 8px; align-items: baseline; border: 1px solid var(--border); border-radius: 7px; padding: 7px 9px; font-size: 0.72rem; color: var(--muted); background: rgba(255, 255, 255, 0.02); }
.mission-list li.active { border-color: var(--amber); color: var(--text); background: rgba(249, 168, 38, 0.08); }
.mission-list li.done { border-color: rgba(83, 215, 105, 0.5); color: var(--text); background: rgba(83, 215, 105, 0.07); }
.mission-list .m-status { color: var(--amber); font-weight: 900; }
.mission-list li.done .m-status { color: var(--green); }
.mission-list li.locked .m-status { color: var(--muted); }

.incident-card { margin: 10px 0 2px; border: 1px solid rgba(233, 69, 96, 0.38); border-left: 3px solid var(--accent); border-radius: 7px; padding: 9px 10px; background: rgba(233, 69, 96, 0.06); }
.incident-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--accent); font-size: 0.58rem; font-weight: 900; letter-spacing: 0.12em; }
.incident-live { color: var(--muted); font-size: 0.52rem; }
.incident-card h2 { margin: 5px 0 3px; color: #fff; font-size: 0.78rem; }
.incident-card p { margin: 0; color: var(--muted); font-size: 0.64rem; line-height: 1.5; }

.report-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
.report-grid > div { border: 1px solid var(--border); border-radius: 7px; padding: 9px; background: rgba(255, 255, 255, 0.025); }
.report-grid span { display: block; color: var(--muted); font-size: 0.58rem; letter-spacing: 0.1em; text-transform: uppercase; }
.report-grid strong { display: block; margin-top: 4px; color: #fff; font-size: 0.86rem; }

.objective { border-left: 3px solid var(--amber); background: rgba(249, 168, 38, 0.09); padding: 9px 10px; color: #f7f7fb; font-size: 0.76rem; line-height: 1.5; border-radius: 0 6px 6px 0; }

.xp-block { margin: 12px 0; }
.xp-head { display: flex; justify-content: space-between; color: var(--muted); font-size: 0.68rem; margin-bottom: 5px; }
.xp-head b { color: #fff; }
.xp-bar { height: 9px; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; background: rgba(0, 0, 0, 0.35); }
.xp-bar span { display: block; height: 100%; width: 0%; background: linear-gradient(90deg, var(--teal), var(--green)); transition: width 320ms ease; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin: 12px 0; }
.stat { border: 1px solid var(--border); border-radius: 7px; padding: 8px; background: rgba(255, 255, 255, 0.025); }
.stat-label { display: block; color: var(--muted); font-size: 0.58rem; letter-spacing: 0.1em; text-transform: uppercase; }
.stat-value { display: block; margin-top: 3px; color: #fff; font-size: 0.86rem; font-weight: 900; }
.stat-value.good { color: var(--green); }

.badge-list { list-style: none; margin: 4px 0 12px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.badge-empty { color: var(--muted); font-size: 0.68rem; }
.badge-chip { border: 1px solid rgba(249, 168, 38, 0.6); background: rgba(249, 168, 38, 0.1); color: var(--amber); border-radius: 999px; padding: 4px 9px; font-size: 0.6rem; font-weight: 800; letter-spacing: 0.08em; }

.controls-list { margin: 0; padding: 0; list-style: none; color: var(--muted); font-size: 0.7rem; line-height: 1.85; }
.controls-list b { color: var(--text); }
.panel-actions { display: grid; gap: 8px; margin-top: 12px; }

.primary-button, .secondary-button {
  border-radius: 8px; padding: 10px 12px; font-size: 0.76rem; font-weight: 900;
  letter-spacing: 0.05em; text-transform: uppercase; text-align: center; text-decoration: none;
  transition: transform 120ms ease, filter 120ms ease, border-color 120ms ease;
}
.primary-button:hover, .secondary-button:hover { filter: brightness(1.12); transform: translateY(-1px); }
.primary-button { border: 1px solid var(--accent); background: var(--accent); color: #fff; display: inline-block; }
.secondary-button { border: 1px solid var(--border-bright); background: #16213e; color: var(--text); }
.cta-link { display: inline-block; }

.story-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 16px; }
.story-card { border: 1px solid var(--border); border-radius: 9px; background: rgba(20, 28, 55, 0.72); padding: 12px; color: var(--muted); font-size: 0.7rem; line-height: 1.55; }
.story-card strong { display: block; margin-bottom: 4px; color: var(--accent); font-size: 0.72rem; letter-spacing: 0.06em; }

.overlay { position: fixed; z-index: 20; inset: 0; display: grid; place-items: center; padding: 18px; background: rgba(6, 8, 18, 0.8); backdrop-filter: blur(4px); }
.overlay[hidden] { display: none; }
.modal { width: min(720px, 100%); max-height: min(780px, calc(100vh - 36px)); overflow: auto; border: 1px solid var(--border-bright); border-radius: 12px; background: #141c37; box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.05); }
.modal-dialogue { width: min(620px, 100%); }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 15px 18px 12px; border-bottom: 1px solid var(--border); }
.modal-title { margin: 0; color: #fff; font-size: 0.98rem; }
.modal-subtitle { margin: 4px 0 0; color: var(--muted); font-size: 0.7rem; }
.modal-close { flex: 0 0 auto; border: 1px solid var(--border); border-radius: 6px; background: transparent; color: var(--muted); padding: 5px 9px; }
.modal-close:hover { color: #fff; border-color: var(--teal); }
.modal-body { padding: 18px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 13px 18px; border-top: 1px solid var(--border); }

.intro-mark { display: inline-flex; align-items: center; justify-content: center; width: 56px; height: 56px; margin-bottom: 12px; border: 1px solid var(--accent); border-radius: 10px; color: var(--accent); background: rgba(233, 69, 96, 0.12); font-size: 0.95rem; font-weight: 900; letter-spacing: 0.05em; }
.intro-copy { color: #d9dceb; font-size: 0.82rem; line-height: 1.7; }
.intro-copy strong { color: #fff; }
.intro-copy .red, .red { color: var(--accent); }
.intro-rules { display: grid; gap: 7px; margin: 15px 0; padding: 0; list-style: none; color: var(--muted); font-size: 0.75rem; }
.intro-rules li { display: flex; gap: 8px; }
.intro-rules li::before { content: "▸"; color: var(--teal); }

.dialogue-head { display: flex; align-items: center; gap: 12px; }
.dialogue-portrait { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 10px; border: 1px solid var(--border-bright); background: linear-gradient(160deg, rgba(78, 205, 196, 0.22), rgba(233, 69, 96, 0.18)); color: #fff; font-weight: 900; font-size: 0.9rem; }
.dialogue-line { min-height: 84px; color: #eef0f8; font-size: 0.9rem; line-height: 1.65; margin: 0; }
.dialogue-progress { margin-top: 12px; color: var(--muted); font-size: 0.66rem; text-align: right; }

.challenge-intro { color: #cdd2e6; font-size: 0.78rem; line-height: 1.6; }
.challenge-grid { display: grid; gap: 9px; margin-top: 14px; }
.email-card { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; align-items: center; gap: 10px; border: 1px solid var(--border); border-radius: 9px; background: #101830; padding: 11px; text-align: left; color: var(--text); transition: border-color 140ms ease, background 140ms ease, transform 140ms ease; }
.email-card:hover { border-color: var(--teal); background: #14203c; transform: translateY(-1px); }
.email-card.is-picked { border-color: var(--amber); background: rgba(249, 168, 38, 0.1); }
.email-card.is-wrong { border-color: var(--accent); background: rgba(233, 69, 96, 0.1); }
.email-card.is-right { border-color: var(--green); background: rgba(83, 215, 105, 0.1); }
.email-card.locked { pointer-events: none; opacity: 0.85; }
.email-icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 7px; background: rgba(78, 205, 196, 0.14); color: var(--teal); font-weight: 900; font-size: 0.72rem; }
.email-subject { color: #fff; font-size: 0.78rem; font-weight: 800; }
.email-from { display: block; margin-top: 3px; color: var(--muted); font-size: 0.66rem; line-height: 1.45; overflow-wrap: anywhere; }
.email-flag { border: 1px solid var(--border); border-radius: 6px; background: #16213e; color: var(--muted); padding: 5px 8px; font-size: 0.62rem; font-weight: 800; white-space: nowrap; }

.option-card { position: relative; display: grid; gap: 3px; border: 1px solid var(--border); border-radius: 9px; background: #101830; padding: 12px 12px; text-align: left; color: var(--text); transition: border-color 140ms ease, background 140ms ease; }
.option-card:hover { border-color: var(--teal); }
.option-card.is-picked { border-color: var(--amber); background: rgba(249, 168, 38, 0.1); }
.option-card.toggle { padding-right: 76px; }
.option-card .opt-switch { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); border: 1px solid var(--border); border-radius: 999px; padding: 4px 10px; font-size: 0.6rem; font-weight: 900; color: var(--muted); }
.option-card.is-on { border-color: var(--green); background: rgba(83, 215, 105, 0.1); }
.option-card.is-on .opt-switch { border-color: var(--green); color: var(--green); }
.opt-title { font-size: 0.8rem; font-weight: 800; color: #fff; }
.opt-note { font-size: 0.68rem; color: var(--muted); }

.crack-window { border: 1px solid var(--border-bright); border-radius: 10px; background: #0a1020; padding: 14px; text-align: center; }
.crack-pw { font-size: 1.3rem; font-weight: 900; color: var(--teal); letter-spacing: 0.04em; overflow-wrap: anywhere; }
.crack-timerbar { margin-top: 12px; height: 8px; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; background: rgba(0, 0, 0, 0.4); }
.crack-timerbar span { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, var(--green), var(--teal)); transition: width 120ms linear; }
.crack-timerbar span.low { background: linear-gradient(90deg, var(--amber), var(--accent)); }
.crack-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin-top: 14px; }
.bucket-btn { border: 1px solid var(--border-bright); border-radius: 9px; background: #16213e; color: var(--text); padding: 14px 8px; font-weight: 900; letter-spacing: 0.08em; font-size: 0.72rem; transition: border-color 140ms ease, background 140ms ease, transform 140ms ease; }
.bucket-btn:hover { border-color: var(--teal); transform: translateY(-1px); }
.bucket-btn.locked { pointer-events: none; opacity: 0.7; }
.bucket-btn.is-right { border-color: var(--green); background: rgba(83, 215, 105, 0.16); color: #fff; opacity: 1; }
.bucket-btn.is-wrong { border-color: var(--accent); background: rgba(233, 69, 96, 0.16); color: #fff; opacity: 1; }

.feedback { min-height: 44px; margin-top: 12px; border-left: 3px solid var(--amber); padding: 9px 10px; background: rgba(249, 168, 38, 0.09); color: #eef0f8; font-size: 0.74rem; line-height: 1.6; border-radius: 0 6px 6px 0; }
.feedback.good { border-color: var(--green); background: rgba(83, 215, 105, 0.1); }
.feedback.bad { border-color: var(--accent); background: rgba(233, 69, 96, 0.1); }

.rank-block { display: grid; place-items: center; gap: 2px; margin: 6px 0 14px; padding: 14px; border: 1px solid var(--border-bright); border-radius: 10px; background: rgba(78, 205, 196, 0.07); }
.rank-kicker { color: var(--muted); font-size: 0.62rem; letter-spacing: 0.2em; text-transform: uppercase; }
.rank-value { color: var(--amber); font-size: 2.6rem; font-weight: 900; line-height: 1; }

.toast { position: fixed; z-index: 30; left: 50%; bottom: 22px; transform: translate(-50%, 16px); max-width: min(560px, calc(100vw - 28px)); border: 1px solid var(--border-bright); border-radius: 9px; background: #16213e; color: #f5f5f5; padding: 10px 14px; box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4); font-size: 0.74rem; opacity: 0; pointer-events: none; transition: opacity 180ms ease, transform 180ms ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.selftest-output { margin: 16px auto; max-width: 900px; padding: 12px; border: 1px solid var(--border); border-radius: 8px; background: #0a1020; color: var(--green); font-size: 0.7rem; white-space: pre-wrap; }

.mobile-controls { display: none; }

@media (max-width: 980px) {
  .story-strip { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 860px) {
  .app-shell { padding-top: 12px; }
  .brand { font-size: 0.86rem; }
  .brand small { display: block; }
  .header-actions { gap: 5px; }
  .text-link, .quiet-button { padding: 6px 8px; font-size: 0.64rem; }
  .game-layout { grid-template-columns: 1fr; }
  .mission-panel { order: 2; }
  .story-strip { grid-template-columns: 1fr; }
  .mobile-controls { display: grid; grid-template-columns: repeat(3, 52px); grid-template-rows: repeat(2, 52px); gap: 8px; position: absolute; left: 12px; bottom: 32px; opacity: 0.94; }
  .mobile-controls button { border: 1px solid rgba(78, 205, 196, 0.5); border-radius: 9px; background: rgba(10, 16, 32, 0.82); color: var(--teal); font-size: 1.1rem; font-weight: 900; touch-action: none; }
  .mobile-controls button:active { background: rgba(78, 205, 196, 0.24); }
  .mobile-controls .up { grid-column: 2; grid-row: 1; }
  .mobile-controls .left { grid-column: 1; grid-row: 2; }
  .mobile-controls .down { grid-column: 2; grid-row: 2; }
  .mobile-controls .right { grid-column: 3; grid-row: 2; }
  .mobile-controls .action { grid-column: 3; grid-row: 1; border-color: rgba(233, 69, 96, 0.65); color: var(--accent); }
  .stage-hint { bottom: 96px; font-size: 0.6rem; }
  .modal-footer { flex-wrap: wrap; }
  .stats { grid-template-columns: repeat(3, 1fr); }
  .crack-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}
