/* Glitch Snake — Matrix snake (app.rrmyers.com). */

.game-shell.gs-shell,
.gs-shell {
  position: relative;
  background: #050805;
  border: 1px solid rgba(57, 255, 20, 0.35);
  border-radius: 12px;
  box-shadow: 0 0 24px rgba(57, 255, 20, 0.12);
  overflow: hidden;
  aspect-ratio: 1 / 1;
  max-height: min(72vh, 560px);
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}


.gs-shell canvas {
  display: block;
  width: 100%;
  height: auto;
  flex: 1 1 auto;
  cursor: default;
  touch-action: none;
}

.gs-shell .game-hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.8rem;
  color: #7cff6b;
  pointer-events: none;
  text-shadow: 0 0 8px rgba(57, 255, 20, 0.45);
  z-index: 2;
}

.gs-shell .game-hud strong {
  color: #39ff14;
  font-weight: 700;
}

.gs-shell .game-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1.5rem;
  text-align: center;
  background: rgba(0, 0, 0, 0.78);
  z-index: 3;
  font-family: "JetBrains Mono", ui-monospace, monospace;
}

.gs-shell .game-overlay[hidden] {
  display: none !important;
}

.gs-shell .game-overlay h2 {
  margin: 0;
  font-size: clamp(1.35rem, 4vw, 1.85rem);
  color: #39ff14;
  letter-spacing: 0.04em;
  text-shadow: 0 0 12px rgba(57, 255, 20, 0.5);
}

.gs-shell .game-overlay p {
  margin: 0;
  max-width: 28rem;
  color: #a8e6a8;
  font-size: 0.9rem;
  line-height: 1.5;
}

.gs-shell .game-overlay .muted {
  color: #6a9a6a;
  font-size: 0.8rem;
}

.gs-shell .game-overlay .score-line {
  color: #7cff6b;
  font-size: 1rem;
}

.gs-shell .game-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.55rem 1.4rem;
  margin-top: 0.35rem;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: #0a0a0a;
  background: #39ff14;
  border: 2px solid #39ff14;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.gs-shell .game-btn:hover,
.gs-shell .game-btn:focus {
  background: #7cff6b;
  border-color: #7cff6b;
  outline: none;
}

.gs-shell .game-btn:active {
  transform: scale(0.98);
}

.gs-shell .gs-share-btn {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.82rem;
}

.gs-shell .gs-share-btn[hidden] {
  display: none !important;
}

/* On-screen D-pad (visible on touch / narrow viewports) */
.gs-pad {
  display: none;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 0.35rem;
  padding: 0.5rem 0.65rem 0.7rem;
  z-index: 2;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.55));
}

.gs-pad__btn {
  min-height: 42px;
  padding: 0.35rem;
  font-size: 0.95rem;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  color: #39ff14;
  background: rgba(13, 31, 14, 0.9);
  border: 1px solid rgba(57, 255, 20, 0.4);
  border-radius: 10px;
  cursor: pointer;
  touch-action: manipulation;
}

.gs-pad__btn:active {
  background: rgba(57, 255, 20, 0.22);
}

.gs-pad__btn[data-gs-dir="up"] { grid-column: 2; grid-row: 1; }
.gs-pad__btn[data-gs-dir="left"] { grid-column: 1; grid-row: 2; }
.gs-pad__btn--pause { grid-column: 2; grid-row: 2; color: #a8e6a8; font-size: 0.75rem; }
.gs-pad__btn[data-gs-dir="right"] { grid-column: 3; grid-row: 2; }
.gs-pad__btn[data-gs-dir="down"] { grid-column: 2; grid-row: 3; }

.gs-pad {
  grid-template-rows: repeat(3, 1fr);
}

.gs-pad__btn[aria-pressed="true"] {
  border-color: #39ff14;
  background: rgba(57, 255, 20, 0.18);
}

@media (max-width: 720px), (pointer: coarse) {
  .gs-pad {
    display: grid;
    /* Keep all three rows in the shell's natural height. */
    grid-template-rows: repeat(3, minmax(42px, auto));
    flex: 0 0 auto;
  }

  .game-shell.gs-shell {
    /* The D-pad is part of the mobile flow, not an overlay in a square box. */
    aspect-ratio: auto;
    max-height: none;
    overflow: visible;
  }

  .gs-shell canvas {
    /* Let the canvas occupy one complete square above the D-pad. */
    flex: 0 0 auto;
    max-width: 100%;
    min-height: 0;
  }
}

@media (max-width: 520px) {
  .gs-shell .game-hud {
    font-size: 0.72rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .gs-shell .game-btn {
    transition: none;
  }

  .gs-shell {
    box-shadow: none;
  }
}

.game-howto {
  margin: 1.25rem 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.95rem;
  color: var(--text);
}

.game-howto li {
  margin: 0.4rem 0;
  padding-left: 1.1rem;
  position: relative;
}

.game-howto li::before {
  content: "▸";
  position: absolute;
  left: 0;
  color: #39ff14;
}

.game-howto .signal {
  color: #39ff14;
  font-family: "JetBrains Mono", ui-monospace, monospace;
}


/* Difficulty toggle (Easy wrap / Normal walls) */
.gs-mode {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  max-width: 480px;
  margin: 0 auto 0.65rem;
}

.gs-mode__btn {
  min-height: 40px;
  padding: 0.4rem 0.9rem;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #7cff6b;
  background: rgba(13, 31, 14, 0.85);
  border: 1px solid rgba(57, 255, 20, 0.35);
  border-radius: 999px;
  cursor: pointer;
  touch-action: manipulation;
}

.gs-mode__btn:hover,
.gs-mode__btn:focus {
  border-color: #39ff14;
  outline: none;
}

.gs-mode__btn.is-active,
.gs-mode__btn[aria-pressed="true"] {
  color: #0a0a0a;
  background: #39ff14;
  border-color: #39ff14;
}

/* Clearer mobile pause tip near D-pad / HUD */
.gs-pause-tip {
  display: block;
  max-width: 480px;
  margin: 0.45rem auto 0;
  text-align: center;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.82rem;
  color: #7cff6b;
  text-shadow: 0 0 8px rgba(57, 255, 20, 0.35);
}

.gs-pause-tip strong {
  color: #39ff14;
}

@media (max-width: 720px), (pointer: coarse) {
  .gs-pause-tip {
    font-size: 0.9rem;
    margin-top: 0.55rem;
    padding: 0.35rem 0.5rem;
    border: 1px solid rgba(57, 255, 20, 0.28);
    border-radius: 8px;
    background: rgba(13, 31, 14, 0.55);
  }
}

@media (max-width: 520px) {
  .gs-mode__btn {
    font-size: 0.72rem;
    padding: 0.35rem 0.7rem;
  }
}
