/* ============================================================
   MINI GAME // KEEP THE SERVER ALIVE
   Monochrome. HTML + CSS only. No images. No canvas.
   ============================================================ */

.game {
  background: var(--bg);
}

.game__head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem 2rem;
}

.game__sub {
  margin: 0;
  max-width: 42ch;
  color: var(--muted);
  font-size: clamp(.95rem, 1.6vw, 1.08rem);
  line-height: 1.6;
}

.game__label {
  margin: 1.4rem 0 .35rem;
  font-size: .72rem;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--faint);
}

.game__shell {
  border: 1px solid var(--fg);
  background: var(--bg);
}

/* ---------------------------------------------- HUD */
.hud {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .3rem 1.4rem;
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: .72rem;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
}

.hud__item {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  white-space: nowrap;
}

.hud__item b {
  font-weight: 500;
  color: var(--fg);
}

.hud__end { margin-left: auto; }

.hud__status .dot { width: 7px; height: 7px; }

.hud__status.is-down .dot {
  animation: none;
  background: var(--line-2);
}

/* ---------------------------------------------- Arena */
.arena {
  position: relative;
  height: clamp(240px, 42vh, 340px);
  overflow: hidden;
  background: var(--bg);
  touch-action: none;
  outline: none;
}

.arena__grid {
  position: absolute;
  inset: 0;
  background-image: linear-gradient(to right, var(--line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--line) 1px, transparent 1px);
  background-size: 56px 56px;
  opacity: .55;
  pointer-events: none;
}

.arena__ground {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 46px;
  height: 1px;
  background-image: repeating-linear-gradient(90deg, var(--line-2) 0 10px, transparent 10px 18px);
}

.server,
.obstacle {
  position: absolute;
  left: 0;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: .5rem .7rem;
  border: 1px solid var(--fg);
  font-family: var(--font-mono);
  line-height: 1;
  letter-spacing: .06em;
  white-space: nowrap;
  will-change: transform;
}

.server {
  background: var(--fg);
  color: var(--bg);
  font-size: .74rem;
  font-weight: 500;
}

.server.is-hit { animation: hit .25s steps(1) 3; }

@keyframes hit {
  50% { opacity: .2; }
}

.obstacle {
  background: var(--bg);
  color: var(--fg);
  font-size: .7rem;
}

/* ---------------------------------------------- Overlays */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  padding: 1.5rem;
  text-align: center;
  background: rgba(255, 255, 255, .96);
  opacity: 0;
  visibility: hidden;
  transition: opacity .3s var(--ease);
}

.overlay.is-active {
  opacity: 1;
  visibility: visible;
}

.overlay__title {
  margin: 0;
  font-size: .78rem;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--faint);
}

.overlay__copy,
.overlay__reason,
.overlay__flavor {
  margin: 0;
  color: var(--muted);
  font-size: .92rem;
  line-height: 1.6;
  white-space: pre-line;
}

.overlay__kicker {
  margin: 0;
  font-size: clamp(1.1rem, 3vw, 1.5rem);
  letter-spacing: .14em;
  color: var(--fg);
}

.overlay__reason { font-size: .76rem; }

.overlay__stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .4rem 1.6rem;
  margin: .4rem 0 .2rem;
  font-size: .72rem;
}

.overlay__stats dt {
  color: var(--faint);
  letter-spacing: .12em;
}

.overlay__stats dd {
  margin: .15rem 0 0;
  color: var(--fg);
  font-size: .95rem;
}

.overlay__flavor {
  max-width: 46ch;
  color: var(--fg);
  font-size: .86rem;
}

.overlay__hint {
  margin: .35rem 0 0;
  font-size: .68rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--faint);
  line-height: 1.7;
}

/* ---------------------------------------------- Text buttons */
.linkbtn {
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  margin: .35rem 0;
  padding: .45rem .2rem;
  border: 0;
  background: none;
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: .8rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  cursor: pointer;
}

.linkbtn::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: .25rem;
  height: 1px;
  background: var(--fg);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .3s var(--ease);
}

.linkbtn:hover::after,
.linkbtn:focus-visible::after {
  transform: scaleX(1);
}

.linkbtn--sm {
  font-size: .68rem;
  letter-spacing: .1em;
}

/* ---------------------------------------------- Touch controls */
.touch {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid var(--line);
}

.touch__btn {
  -webkit-appearance: none;
  appearance: none;
  padding: 1rem .5rem;
  border: 0;
  border-right: 1px solid var(--line);
  background: none;
  color: var(--fg);
  font-size: .84rem;
  letter-spacing: .12em;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background .18s var(--ease), color .18s var(--ease);
}

.touch__btn:last-child { border-right: 0; }

.touch__btn:hover,
.touch__btn.is-down {
  background: var(--fg);
  color: var(--bg);
}

/* ---------------------------------------------- Footer strip */
.game__foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .4rem 1.5rem;
  padding: .75rem 1rem;
  border-top: 1px solid var(--line);
  font-size: .68rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--faint);
}

.game__foot .linkbtn { margin-left: auto; }

.game__ach b { color: var(--fg); font-weight: 500; }

/* ---------------------------------------------- Achievements */
.ach {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  padding: .75rem 1rem;
  border-top: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: .64rem;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.ach:empty { display: none; }

.ach__badge {
  padding: .28rem .5rem;
  border: 1px solid var(--line-2);
  color: var(--faint);
  opacity: .5;
}

.ach__badge[data-unlocked="1"] {
  border-color: var(--fg);
  color: var(--fg);
  opacity: 1;
}

/* ---------------------------------------------- In-game toasts */
.game-toasts {
  position: absolute;
  top: .7rem;
  left: .7rem;
  right: .7rem;
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: .4rem;
  pointer-events: none;
}

.game-toast {
  max-width: 300px;
  padding: .5rem .7rem;
  border: 1px solid var(--fg);
  background: var(--fg);
  color: var(--bg);
  font-family: var(--font-mono);
  font-size: .7rem;
  line-height: 1.55;
  white-space: pre-line;
  animation: gIn .28s var(--ease) both;
}

.game-toast.is-out { animation: gOut .28s var(--ease) both; }

@keyframes gIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}

@keyframes gOut {
  to { opacity: 0; transform: translateY(-6px); }
}

@media (max-width: 880px) {
  .hud__end { margin-left: 0; }
  .arena { height: 300px; }
  .overlay__stats { gap: .3rem 1.1rem; }
}
