:root {
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN", sans-serif;
  background: #101824;
  color: #e5edf5;
  --mint: #73e1ba;
  --muted: #8292a7;
  --border: #293648
}

* {
  box-sizing: border-box
}

body {
  margin: 0;
  background: radial-gradient(ellipse at 80% 10%, #14323855, transparent 55%)
}

button,
a,
input {
  -webkit-tap-highlight-color: transparent
}

button {
  font: inherit;
  cursor: pointer
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 3px solid #ffc76c;
  outline-offset: 3px
}

header,
main,
footer {
  max-width: 1140px;
  margin: auto
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 28px 24px;
  border-bottom: 1px solid var(--border)
}

.brand {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: .07em;
  color: #f1f7fc;
  text-decoration: none
}

.brand>span:last-child {
  color: var(--mint);
  margin-left: 5px
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  margin-right: 9px;
  color: var(--mint);
  background: #224138;
  border-radius: 8px
}

.header-tag {
  font: 10px ui-monospace, monospace;
  color: var(--muted);
  letter-spacing: .07em
}

main {
  padding: 0 24px
}

.intro {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 48px 0 32px
}

.eyebrow {
  font: 10px ui-monospace, monospace;
  letter-spacing: .13em;
  color: var(--mint)
}

h1 {
  font-size: 36px;
  line-height: 1.5;
  letter-spacing: .04em;
  margin: 16px 0
}

h1 span {
  color: #a7b8c9
}

.intro p {
  font-size: 12px;
  line-height: 1.9;
  color: var(--muted)
}

.daily-summary {
  border-left: 1px solid var(--border);
  padding: 15px 0 15px 35px;
  min-width: 235px
}

.daily-summary>span {
  font: 10px ui-monospace, monospace;
  color: var(--muted)
}

.daily-summary strong {
  font: 50px ui-monospace, monospace;
  display: block;
  margin-top: 14px
}

.daily-summary small {
  font-size: 11px;
  color: var(--mint)
}

.daily-summary p {
  margin-bottom: 0
}

.modes {
  display: flex;
  gap: 8px;
  margin-bottom: 20px
}

.modes button {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 17px 18px;
  text-align: left;
  color: #a6b3c4;
  background: #172232;
  font-size: 13px
}

.modes button>span {
  color: #52677e;
  font: 11px ui-monospace, monospace;
  margin-right: 10px
}

.modes small {
  float: right;
  font: 9px ui-monospace, monospace;
  color: #6e8396;
  margin-top: 3px
}

.modes .selected {
  background: #203a36;
  border-color: #558c77;
  color: #a1f2d2
}

.modes .selected>span,
.modes .selected small {
  color: #80b69c
}

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

.game-card,
.info-card {
  background: #172231;
  border: 1px solid var(--border);
  border-radius: 13px;
  overflow: hidden
}

.game-heading {
  padding: 23px 25px;
  display: flex;
  justify-content: space-between;
  align-items: center
}

.game-heading h2 {
  font-size: 19px;
  margin: 10px 0 0
}

.text-button {
  border: 0;
  background: transparent;
  color: #91a6b9;
  font-size: 11px;
  padding: 8px
}

.metrics {
  margin: 0 25px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 17px 0
}

.metrics span {
  display: block;
  color: var(--muted);
  font-size: 9px;
  margin-bottom: 9px
}

.metrics strong {
  font: 20px ui-monospace, monospace;
  color: #d9e6f2
}

.metrics>div:first-child strong {
  color: var(--mint)
}

.board-wrap {
  padding: 28px 35px 22px;
  background: radial-gradient(ellipse at center, #23433c30, transparent 70%)
}

.board {
  display: grid;
  grid-template-columns: repeat(var(--size), 1fr);
  gap: 7px;
  max-width: 480px;
  margin: auto
}

.tile {
  aspect-ratio: 1;
  position: relative;
  background: #1e2d3e;
  border: 1px solid #314155;
  border-radius: 9px;
  padding: 4px;
  display: block;
  min-width: 0;
  touch-action: manipulation;
  transition: background .18s, border-color .18s
}

.tile:hover {
  background: #2a3c50;
  border-color: #68829a
}

.tile svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible
}

.tile .wire {
  stroke: #566a82;
  stroke-width: 8;
  stroke-linecap: round;
  fill: none
}

.tile .terminal {
  fill: #172231;
  stroke: #71849c;
  stroke-width: 3
}

.tile.powered {
  background: #203a38;
  border-color: #40695c
}

.tile.powered .wire {
  stroke: var(--mint)
}

.tile.powered .terminal {
  stroke: var(--mint);
  fill: #264f43
}

.tile.source {
  border-color: #d6b66e;
  box-shadow: 0 0 0 2px #dfbc6c22
}

.tile .source-core {
  fill: #f7ce77;
  stroke: #162432;
  stroke-width: 3
}

.tile .source-icon {
  fill: #24362f
}

.board.solved .tile {
  border-color: #6eae91
}

.board.solved {
  animation: online .65s ease
}

.board-footer {
  padding: 0 25px 20px;
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 9px
}

.board-footer>span {
  display: flex;
  align-items: center;
  gap: 5px
}

.board-footer label {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px
}

input {
  accent-color: var(--mint)
}

.legend {
  width: 7px;
  height: 7px;
  background: #566a82;
  border-radius: 50%
}

.legend.on {
  background: var(--mint)
}

.action-bar {
  border-top: 1px solid var(--border);
  padding: 14px 25px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  background: #14202d
}

.action-bar p {
  color: #8ca6b5;
  font-size: 11px;
  line-height: 1.7;
  margin: 0
}

.primary,
.secondary {
  border-radius: 7px;
  padding: 11px 16px;
  font-size: 11px
}

.primary {
  background: var(--mint);
  border: 1px solid var(--mint);
  color: #16362d;
  font-weight: 700
}

.secondary {
  background: #263648;
  border: 1px solid #40556a;
  color: #d4e2ef
}

.primary:hover {
  background: #a5f1d6
}

.secondary:hover {
  background: #34485c
}

.info-card {
  padding: 23px;
  margin-bottom: 18px
}

.info-card h2 {
  font-size: 16px;
  margin: 13px 0 20px
}

.info-card ol {
  list-style: none;
  counter-reset: steps;
  padding: 0;
  margin: 0
}

.info-card li {
  position: relative;
  padding: 0 0 23px 30px;
  counter-increment: steps
}

.info-card li:before {
  content: counter(steps, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: 3px;
  font: 10px ui-monospace, monospace;
  color: var(--mint)
}

.info-card b {
  display: block;
  font-size: 12px;
  margin-bottom: 8px
}

.info-card li span,
.info-card p {
  font-size: 11px;
  line-height: 1.9;
  color: var(--muted)
}

.info-card .keyboard-note {
  font-size: 10px;
  border-top: 1px solid var(--border);
  padding-top: 15px;
  margin: 0
}

.memo {
  background: #1b302f;
  border-color: #304a42
}

.memo .small {
  font-size: 9px;
  color: #78958b
}

.stages {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 7px
}

.stages button {
  border: 1px solid #3b4b60;
  background: #213246;
  color: #b7c7d6;
  aspect-ratio: 1;
  border-radius: 5px;
  font: 12px ui-monospace, monospace
}

.stages button.cleared {
  color: var(--mint);
  background: #224639
}

.stages button.current {
  outline: 2px solid #e6bd71;
  outline-offset: 1px
}

.result {
  background: #203d34;
  margin: 0 25px 22px;
  padding: 24px;
  border: 1px solid #4c866a;
  border-radius: 10px;
  text-align: center
}

.result h2 {
  font-size: 22px;
  margin: 13px 0
}

.stars {
  font-size: 29px;
  letter-spacing: 6px;
  color: #f3cf7a
}

.result p {
  font-size: 12px;
  color: #afcbbd;
  line-height: 1.8
}

.result-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 18px
}

#record-text {
  color: #f3cf7a
}

#share-status {
  font-size: 10px;
  margin: 10px 0 0;
  overflow-wrap: anywhere;
  white-space: pre-line
}

.result .eyebrow {
  font-size: 9px
}

footer {
  display: flex;
  justify-content: space-between;
  padding: 35px 24px;
  color: #728499;
  font: 10px ui-monospace, monospace
}

footer small {
  font-size: 9px;
  margin-left: 10px
}

footer>span:last-child {
  font-size: 9px
}

[hidden] {
  display: none !important
}

@keyframes online {
  50% {
    filter: brightness(1.35)
  }
}

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

@media(max-width:850px) {
  .game-layout {
    grid-template-columns: minmax(0, 1fr) 240px
  }

  .info-card {
    padding: 18px
  }

  .board-wrap {
    padding: 24px
  }

  .board {
    gap: 5px
  }

  .modes small {
    display: none
  }
}

@media(max-width:650px) {
  header {
    padding: 20px 16px
  }

  .header-tag {
    font-size: 8px
  }

  .brand {
    font-size: 13px
  }

  .brand-mark {
    width: 27px;
    height: 27px;
    margin-right: 3px
  }

  main {
    padding: 0 14px
  }

  .intro {
    padding: 30px 0 22px
  }

  h1 {
    font-size: 22px
  }

  .intro p {
    font-size: 10px
  }

  .daily-summary {
    min-width: 0;
    padding-left: 12px;
    max-width: 115px
  }

  .daily-summary>span {
    font-size: 8px
  }

  .daily-summary strong {
    font-size: 34px
  }

  .daily-summary small {
    display: block;
    font-size: 9px
  }

  .daily-summary p {
    font-size: 9px
  }

  .modes {
    gap: 5px
  }

  .modes button {
    font-size: 10px;
    padding: 13px 8px
  }

  .modes button>span {
    font-size: 9px;
    margin-right: 3px
  }

  .game-layout {
    grid-template-columns: 1fr
  }

  .game-heading {
    padding: 20px
  }

  .game-heading h2 {
    font-size: 17px
  }

  .metrics {
    margin: 0 20px;
    gap: 5px
  }

  .metrics span {
    font-size: 8px
  }

  .metrics strong {
    font-size: 17px
  }

  .board-wrap {
    padding: 23px 19px
  }

  .tile {
    border-radius: 6px;
    padding: 2px
  }

  .board-footer {
    padding: 0 20px 18px;
    gap: 10px
  }

  .board-footer label {
    margin-left: 0
  }

  .result {
    margin: 0 16px 18px;
    padding: 20px 12px
  }

  .result h2 {
    font-size: 20px
  }

  .info-card {
    padding: 22px
  }

  .info-card li {
    padding-bottom: 16px
  }

  .action-bar {
    padding: 15px 20px
  }

  footer {
    padding: 25px 16px;
    gap: 15px
  }

  footer small {
    display: block;
    margin: 7px 0 0
  }

  footer>span:last-child {
    max-width: 130px;
    line-height: 1.8
  }
}

/* Expanded puzzle modes and city progression. */
.modes {
  flex-wrap: wrap;
}

.modes button {
  min-width: 150px;
}

.daily-levels {
  padding: 0 25px 15px;
}

.tier-buttons {
  display: flex;
  gap: 8px;
}

.tier-buttons button {
  background: #213246;
  border: 1px solid #40556a;
  border-radius: 6px;
  color: #b7c7d6;
  font-size: 11px;
  padding: 9px 13px;
}

.tier-buttons button.selected {
  border-color: #73e1ba;
  color: #a1f2d2;
  background: #203a36;
}

.tier-buttons button.cleared::after {
  content: ' ✓';
  color: #73e1ba;
}

#daily-progress {
  color: #8292a7;
  font-size: 10px;
  line-height: 1.7;
}

.tile.fixed {
  border-style: dashed;
  border-color: #b59d6a;
}

.lock-icon {
  position: absolute;
  top: 3px;
  right: 5px;
  font-size: 12px;
  color: #f3cf7a;
  line-height: 1;
}

.tile.bridge {
  border-color: #a58cd1;
}

.tile .wire.live-wire {
  stroke: #73e1ba;
}

.tile .wire.dead-wire {
  stroke: #566a82;
}

.tile.powered .wire:not(.dead-wire) {
  stroke-dasharray: 8 3;
  animation: packet-flow 1.2s linear infinite;
}

.tile.hinted {
  outline: 3px solid #ffc76c;
  outline-offset: 1px;
}

.board.solved .tile {
  animation: terminal-online .55s ease both;
}

.board-footer button {
  font-size: 10px;
  padding: 7px 10px;
}

button:disabled {
  cursor: default;
  opacity: .6;
}

.city-card {
  padding: 27px;
  background: #172231;
  border: 1px solid #293648;
  border-radius: 13px;
  margin-top: 24px;
}

.city-card h2 {
  font-size: 19px;
  margin: 12px 0;
}

.city-card p {
  font-size: 11px;
  color: #8292a7;
  line-height: 1.8;
}

.city-map {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 10px;
  margin: 20px 0;
}

.building {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 20px 5px;
  border: 1px solid #334256;
  background: #1a2636;
  border-radius: 9px;
  color: #728397;
}

.building strong {
  font-size: 29px;
}

.building span {
  font-size: 11px;
}

.building small {
  font: 9px ui-monospace, monospace;
}

.building.online {
  background: #203d34;
  color: #a1f2d2;
  border-color: #4c866a;
}

.city-card .city-note {
  font-size: 10px;
}

@keyframes packet-flow {
  to {
    stroke-dashoffset: -22;
  }
}

@keyframes terminal-online {
  50% {
    filter: brightness(1.7);
  }
}

@media (max-width: 850px) {
  .city-map {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 650px) {
  .modes button {
    min-width: 90px;
  }

  .city-card {
    padding: 20px 15px;
  }

  .city-map {
    gap: 6px;
  }

  .building {
    padding: 14px 3px;
  }

  .daily-levels {
    padding: 0 20px 12px;
  }
}

@media (prefers-reduced-motion: reduce) {

  .tile.powered .wire,
  .board.solved .tile {
    animation: none !important;
  }
}

/* Fixed banners stay in normal flow, separated from all game controls. */
.ad-section {
  margin: 24px auto;
  text-align: center;
}

.ad-label {
  margin: 0 0 8px;
  color: #8292a7;
  font-size: 10px;
  letter-spacing: 0.12em;
}

.ad-space {
  margin: 0 auto;
  line-height: 0;
  /* Keep the loaded creative intact on resize; no clipping or refresh. */
}

.ad-preview {
  line-height: 1.5;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border: 1px dashed #40556a;
  border-radius: 6px;
  background: repeating-linear-gradient(135deg, #172231, #172231 12px, #192635 12px, #192635 24px);
  color: #91a6b9;
  font-size: 11px;
}

.ad-preview-mark {
  padding: 2px 7px;
  border: 1px solid #52677e;
  border-radius: 4px;
  font: 11px ui-monospace, monospace;
}

.ad-preview b {
  margin-left: 5px;
  font-weight: 400;
}

/* The intro supplies the safe distance without a second empty spacer. */
.ad-section:not([hidden]) + .intro {
  min-height: 160px;
}


/* Relative navigation back to the blog game catalog. */
.header-nav {
  display: flex;
  align-items: center;
  gap: 18px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid #40556a;
  border-radius: 7px;
  color: #b7c7d6;
  font-size: 12px;
  text-decoration: none;
}

.back-link:hover {
  color: #a1f2d2;
  background: #203a36;
  border-color: #558c77;
}

@media (max-width: 650px) {
  header {
    flex-wrap: wrap;
    gap: 12px;
  }

  .header-nav {
    gap: 8px;
    flex-wrap: wrap;
  }

  .header-nav .header-tag {
    display: none;
  }

  .back-link {
    font-size: 11px;
    padding: 8px 10px;
  }
}
