@font-face {
  font-family: "Exo";
  src: url("../fonts/Exo2-Regular.otf") format("opentype");
  font-weight: 400;
}

@font-face {
  font-family: "Exo";
  src: url("../fonts/Exo2-SemiBold.otf") format("opentype");
  font-weight: 700;
}

:root {
  color-scheme: dark;
  --ink: #07090a;
  --panel: #111617;
  --line: #313a39;
  --text: #eef2ef;
  --muted: #8c9793;
  --cyan: #36c8d0;
  --coral: #ff5b65;
  --yellow: #ffd34d;
  --lime: #64d87b;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  background: var(--ink);
}

body {
  color: var(--text);
  font-family: "Exo", ui-monospace, monospace;
  overflow: hidden;
}

button,
a {
  font: inherit;
}

.game-shell {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 520px;
  overflow: hidden;
  background: var(--ink);
}

#canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: var(--ink);
  transition: opacity 180ms ease, filter 180ms ease;
}

.grid-field {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.16;
  background-image:
    linear-gradient(rgba(238, 242, 239, 0.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(238, 242, 239, 0.12) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: linear-gradient(to bottom, black, transparent 72%);
}

.status-mark {
  position: absolute;
  top: 86px;
  left: 96px;
  z-index: 20;
  display: grid;
  gap: 2px;
  pointer-events: none;
}

.status-mark strong {
  color: var(--coral);
  font-size: 18px;
}

.status-mark span,
#highScoreInGameTextHeader {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

#openSideBar,
#pauseBtn,
#restartBtn {
  position: absolute;
  z-index: 100;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  margin: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: rgba(7, 9, 10, 0.88);
  color: var(--text);
  cursor: pointer;
}

.icon-control svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.icon-control [data-icon="back"],
.icon-control [data-icon="resume"] {
  display: none;
}

.icon-control[data-mode="back"] [data-icon="help"],
.icon-control[data-mode="resume"] [data-icon="pause"] {
  display: none;
}

.icon-control[data-mode="back"] [data-icon="back"],
.icon-control[data-mode="resume"] [data-icon="resume"] {
  display: block;
}

#openSideBar {
  top: 82px;
  left: 24px;
}

#pauseBtn {
  top: 82px;
  right: 24px;
  bottom: auto;
}

#restartBtn {
  right: 80px;
  top: 82px;
  bottom: auto;
  left: auto;
}

#openSideBar,
#pauseBtn,
#restartBtn {
  opacity: 0.82;
}

#highScoreInGameText {
  top: 84px;
  left: 50%;
  z-index: 20;
  width: 180px;
  margin-left: -90px;
  text-align: center;
}

#currentHighScore {
  margin-top: 0;
  color: var(--text);
  font-size: 22px;
  font-weight: 700;
}

#startActions {
  position: absolute;
  z-index: 40;
  top: 50%;
  left: 50%;
  display: grid;
  justify-items: center;
  width: min(360px, calc(100% - 48px));
  gap: 12px;
  transform: translate(-50%, -10%);
}

.start-emblem {
  width: clamp(82px, 12vw, 112px);
  height: auto;
  pointer-events: none;
}

#startSaveNote {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.start-buttons {
  display: flex;
  justify-content: center;
  gap: 8px;
  width: 100%;
}

#startBtn,
#newGameBtn {
  position: static;
  top: auto;
  left: auto;
  z-index: auto;
  width: auto;
  height: auto;
  min-width: 132px;
  min-height: 46px;
  padding: 0 18px;
  border: 1px solid var(--cyan);
  border-radius: 4px;
  color: var(--ink);
  background: var(--cyan);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

#newGameBtn {
  border-color: var(--line);
  color: var(--text);
  background: rgba(7, 9, 10, 0.9);
}

#startBtn:focus-visible,
#newGameBtn:focus-visible {
  outline: 2px solid var(--yellow);
  outline-offset: 3px;
}

.overlay {
  z-index: 70;
  color: var(--text);
}

.centeredHeader {
  color: var(--text);
  font-size: clamp(30px, 6vw, 68px);
  font-weight: 700;
  line-height: 1.1;
}

.centeredSubHeader {
  margin-top: 12px;
  color: var(--muted);
  font-size: 14px;
}

#helpScreen {
  z-index: 90;
  color: var(--text);
  background: rgba(7, 9, 10, 0.97);
}

#inst_main_body {
  width: min(520px, calc(100% - 64px));
  max-width: 520px;
  color: #b8c0bd;
  font-size: 16px;
  line-height: 1.55;
}

#instructions_head {
  margin-bottom: 22px;
  color: var(--text);
  font-size: 32px;
  font-weight: 700;
  text-align: left;
}

#inst_main_body hr {
  height: 1px;
  margin: 24px 0;
  border: 0;
  background: var(--line);
}

#inst_main_body a,
.source-note a {
  color: var(--cyan);
}

#firewallHud {
  position: absolute;
  z-index: 60;
  right: 24px;
  bottom: 22px;
  left: 24px;
  display: grid;
  grid-template-columns: minmax(180px, 420px) 112px;
  justify-content: center;
  gap: 10px;
  pointer-events: none;
}

.firewall-readout {
  align-self: center;
  min-width: 0;
}

.firewall-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.firewall-track {
  height: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #141a1a;
}

#firewallFill {
  display: block;
  width: 0;
  height: 100%;
  background: var(--cyan);
  transition: width 180ms ease;
}

#firewallTrigger {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: #64706c;
  background: #111617;
  font-size: 13px;
  font-weight: 700;
  pointer-events: auto;
}

#rushTrigger {
  display: none;
}

#firewallTrigger span,
#rushTrigger span {
  display: block;
  margin-bottom: 2px;
  font-size: 9px;
}

#firewallHud.is-ready #firewallTrigger {
  border-color: var(--cyan);
  color: var(--ink);
  background: var(--cyan);
  cursor: pointer;
  animation: firewall-ready 900ms steps(2, end) infinite;
}

#firewallFlash {
  position: absolute;
  inset: 0;
  z-index: 55;
  border: 0 solid var(--cyan);
  pointer-events: none;
  opacity: 0;
}

#firewallFlash.is-firing {
  animation: firewall-fire 420ms ease-out;
}

#gameoverscreen {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: none;
  padding: 0;
  color: var(--text);
  background: rgba(7, 9, 10, 0.9);
}

#container {
  top: 48%;
  display: none;
  color: var(--text);
}

#gameOverBox {
  color: var(--coral);
  font-size: 18px;
}

#cScore {
  margin: 2px 0 24px;
  color: var(--text);
  font-size: 72px;
}

#highScoresTitle {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
}

.score {
  display: grid;
  grid-template-columns: 36px 1fr;
  width: 180px;
  margin: 0 auto;
  padding: 5px 0;
  border-top: 1px solid var(--line);
  text-align: left;
}

.scoreNum {
  color: var(--muted);
}

#bottomContainer {
  bottom: 84px;
  z-index: 90;
}

#restart {
  position: absolute;
  bottom: 0;
  left: 50%;
  display: none;
  width: 164px;
  height: 48px;
  margin: 0;
  border: 1px solid var(--text);
  border-radius: 4px;
  color: var(--ink);
  background: var(--text);
  font-weight: 700;
  transform: translateX(-50%);
  cursor: pointer;
}

#buttonCont,
#socialShare {
  display: none !important;
}

.source-note {
  position: absolute;
  z-index: 65;
  bottom: 24px;
  left: 24px;
  max-width: 280px;
  color: #66706d;
  font-size: 10px;
  line-height: 1.45;
}

.blur {
  opacity: 0.12;
  filter: grayscale(1);
}

@keyframes firewall-ready {
  50% { opacity: 0.72; }
}

@keyframes firewall-fire {
  0% { border-width: 0; opacity: 0; }
  20% { border-width: 12px; opacity: 0.9; }
  100% { border-width: 80px; opacity: 0; }
}

@media (max-width: 700px) {
  .game-shell {
    min-height: 600px;
  }

  .status-mark {
    display: none;
  }

  #openSideBar,
  #pauseBtn,
  #restartBtn {
    width: 44px;
    height: 44px;
  }

  #openSideBar {
    top: 16px;
    left: 16px;
  }

  #pauseBtn {
    top: 16px;
    right: 16px;
  }

  #restartBtn {
    top: 16px;
    right: 68px;
    bottom: auto;
  }

  #startActions {
    top: 47%;
    transform: translate(-50%, -5%);
  }

  .start-emblem {
    width: 84px;
  }

  #startBtn,
  #newGameBtn {
    min-width: 118px;
    min-height: 48px;
    padding: 0 14px;
  }

  #highScoreInGameText {
    top: 17px;
  }

  #firewallHud {
    right: 16px;
    bottom: 18px;
    left: 16px;
    grid-template-columns: minmax(96px, 1fr) 76px 82px;
    gap: 8px;
  }

  #rushTrigger {
    display: block;
    min-height: 48px;
    border: 1px solid var(--line);
    border-radius: 4px;
    color: var(--text);
    background: #171c1d;
    font-size: 12px;
    font-weight: 700;
    pointer-events: auto;
    touch-action: none;
  }

  #rushTrigger.is-active {
    border-color: var(--yellow);
    color: var(--ink);
    background: var(--yellow);
  }

  .source-note {
    display: none;
  }

  #inst_main_body {
    width: calc(100% - 48px);
    font-size: 14px;
  }

  #instructions_head {
    font-size: 26px;
  }
}

@media (prefers-reduced-motion: reduce) {
  #firewallFill,
  #canvas {
    transition: none;
  }

  #firewallHud.is-ready #firewallTrigger,
  #firewallFlash.is-firing {
    animation: none;
  }
}
