/*
JavaScript Snake — 9×9 Dark Theme
Adapted for the 9×9 Games site (dark purple/black palette)
Original game by Patrick Gillespie: http://patorjk.com/games/snake
Mobile optimizations: responsive layout, touch-friendly controls
*/

body {
  margin: 0;
  padding: 0;
  background-color: #0d0d0d;
  color: #e0d6f0;
  font-family: Verdana, arial, helvetica, sans-serif;
}

/* ── Back link ── */
.back-link {
  position: absolute;
  top: 8px;
  right: 12px;
  z-index: 10001;
}
.back-link a,
.back-link a:link,
.back-link a:visited {
  color: #b794f4;
  text-decoration: none;
  font-size: 14px;
  font-family: Verdana, arial, helvetica, sans-serif;
}
.back-link a:hover {
  color: #d8b4fe;
  text-decoration: underline;
}

/* ── Toolbar ── */
.snake-toolbar {
  color: #a78bfa;
}
.snake-toolbar select,
.snake-toolbar button {
  background-color: #1a1a2e;
  color: #e0d6f0;
  border: 1px solid #6b3fa0;
  border-radius: 3px;
  padding: 2px 6px;
  font-family: Verdana, arial, helvetica, sans-serif;
  font-size: 13px;
}
.snake-toolbar button {
  cursor: pointer;
}
.snake-toolbar button:hover {
  background-color: #2d1f4a;
}

/* ── Toolbar rows (for mobile wrapping) ── */
.toolbar-row {
  display: inline-block;
  margin-right: 10px;
}

/* ── Game area ── */
/* Layout (margin, position) is set in inline <style> so it survives theme switches */
#game-area:focus {
  outline: none;
}

/* ── Mode wrapper ── */
#mode-wrapper {
  display: inline;
  width: auto;
  color: #c4a8f0;
  font-family: Verdana, arial, helvetica, sans-serif;
  font-size: 14px;
}

/* ── Links ── */
a.snake-link,
a.snake-link:link,
a.snake-link:visited {
  color: #b794f4;
}
a.snake-link:hover {
  color: #d8b4fe;
}

/* ── Pause screen ── */
.snake-pause-screen {
  font-family: Verdana, arial, helvetica, sans-serif;
  font-size: 14px;
  position: absolute;
  width: 300px;
  height: 80px;
  text-align: center;
  top: 50%;
  left: 50%;
  margin-top: -40px;
  margin-left: -150px;
  display: none;
  background-color: #1a1a2e;
  color: #e0d6f0;
  border: 1px solid #6b3fa0;
  border-radius: 8px;
}

/* ── Panel component ── */
.snake-panel-component {
  position: absolute;
  font-family: Verdana, arial, helvetica, sans-serif;
  font-size: 14px;
  color: #e0d6f0;
  text-align: center;
  padding: 8px;
  margin: 0;
}

/* ── Snake body ── */
.snake-snakebody-block {
  margin: 0;
  padding: 0;
  background-color: #8b5cf6;
  position: absolute;
  border: 0 solid #4c1d95;
  background-repeat: no-repeat;
}
.snake-snakebody-alive {
  background-image: url("./images/snakeblock.png"),
    url("./images/snakeblock.png");
}
.snake-snakebody-dead {
  background-image: url("./images/deadblock.png"),
    url("./images/deadblock.png");
}

/* ── Food block ── */
.snake-food-block {
  margin: 0;
  padding: 0;
  background-color: #f472b6;
  border: 0 solid #6b3fa0;
  position: absolute;
}

/* ── Playing field (positioned by JS) ── */
.snake-playing-field {
  margin: 0;
  padding: 0;
  position: absolute;
  background-color: #1a1025;
  border: 2px solid #6b3fa0;
}

/* ── Game container (positioned by JS) ── */
.snake-game-container {
  margin: 0;
  padding: 0;
  border-width: 0;
  border-style: none;
  zoom: 1;
  position: absolute;
  background-color: #0d0d0d;
}

/* ── Welcome / Game-over dialogs ── */
.snake-welcome-dialog {
  padding: 8px;
  margin: 0;
  background-color: #1a1a2e;
  color: #e0d6f0;
  font-family: Verdana, arial, helvetica, sans-serif;
  font-size: 14px;
  position: absolute;
  top: 50%;
  left: 50%;
  width: 300px;
  margin-top: -100px;
  margin-left: -158px;
  text-align: center;
  display: block;
  border: 1px solid #6b3fa0;
  border-radius: 8px;
}

.snake-try-again-dialog,
.snake-win-dialog {
  padding: 8px;
  margin: 0;
  background-color: #1a1a2e;
  color: #e0d6f0;
  font-family: Verdana, arial, helvetica, sans-serif;
  font-size: 14px;
  position: absolute;
  top: 50%;
  left: 50%;
  width: 300px;
  height: 100px;
  margin-top: -75px;
  margin-left: -158px;
  text-align: center;
  display: none;
  border: 1px solid #6b3fa0;
  border-radius: 8px;
}

/* ══════════════════════════════════════════════════════════════
   MOBILE / RESPONSIVE (< 600px)
   ══════════════════════════════════════════════════════════════ */
@media (max-width: 599px) {
  /* Back link moves to static position so it never overlaps the game */
  .back-link {
    position: static;
    text-align: center;
    padding: 8px 0 2px 0;
    margin: 0;
  }
  .back-link a {
    font-size: 15px;
    display: inline-block;
    padding: 6px 12px;
  }

  /* Toolbar — wider layout with bigger tap targets */
  .snake-toolbar {
    position: static;
    text-align: center;
    padding: 4px 8px 8px 8px;
  }
  .toolbar-row {
    display: inline-block;
    margin: 4px 6px;
  }
  .snake-toolbar select {
    font-size: 15px;
    padding: 6px 10px;
    min-height: 36px;
    min-width: 44px;
  }
  .snake-toolbar button {
    font-size: 15px;
    padding: 8px 16px;
    min-height: 40px;
    min-width: 44px;
    margin: 4px 4px;
  }

  /* Game area — breathing room via inline styles */

  /* Mode wrapper — center on mobile */
  #mode-wrapper {
    text-align: center;
    display: block;
    width: 100%;
    padding: 4px 0;
  }

  /* Dialogs — scale down if too wide for small viewports */
  .snake-welcome-dialog {
    width: 260px;
    margin-left: -138px;
    font-size: 13px;
  }
  .snake-try-again-dialog,
  .snake-win-dialog {
    width: 260px;
    margin-left: -138px;
    font-size: 13px;
  }
  .snake-pause-screen {
    width: 240px;
    margin-left: -120px;
    font-size: 13px;
  }

  /* Welcome dialog "Play Game" button — bigger tap target */
  .snake-welcome-dialog button {
    font-size: 16px;
    padding: 10px 24px;
    min-height: 44px;
    min-width: 120px;
  }
}
