@import url(https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css);
@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Rajdhani:wght@300;400;500;600;700&display=swap');

/* ============================================
   NEON SNAKE - Cyberpunk Theme
   ============================================ */

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  touch-action: manipulation;
}

body {
  font-family: 'Rajdhani', 'Source Code Pro', Menlo, Consolas, Monaco, monospace;
  background: #0a0a0f;
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(0, 255, 100, 0.03) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 50%, rgba(0, 200, 255, 0.03) 0%, transparent 50%);
  color: #00ff88;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Scanline overlay */
body::after {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.03) 2px,
    rgba(0, 0, 0, 0.03) 4px
  );
  pointer-events: none;
  z-index: 9999;
}

/* ============================================
   TYPOGRAPHY
   ============================================ */

.game-name {
  font-family: 'Orbitron', monospace;
  font-weight: 900;
  font-size: 4em !important;
  letter-spacing: 0.15em;
  color: #00ff88;
  text-shadow:
    0 0 10px #00ff88,
    0 0 20px #00ff88,
    0 0 40px #00cc66,
    0 0 80px #00cc66,
    0 0 120px #009944;
  animation: titlePulse 2s ease-in-out infinite, titleFlicker 4s linear infinite;
}

@keyframes titlePulse {
  0%, 100% { text-shadow: 0 0 10px #00ff88, 0 0 20px #00ff88, 0 0 40px #00cc66, 0 0 80px #00cc66; }
  50% { text-shadow: 0 0 15px #00ff88, 0 0 30px #00ff88, 0 0 60px #00cc66, 0 0 100px #00cc66, 0 0 140px #009944; }
}

@keyframes titleFlicker {
  0%, 19.999%, 22%, 62.999%, 64%, 64.999%, 70%, 100% { opacity: 1; }
  20%, 21.999%, 63%, 63.999%, 65%, 69.999% { opacity: 0.85; }
}

h1 {
  font-family: 'Orbitron', monospace;
  font-weight: 700;
  color: #ff0055;
  text-shadow: 0 0 10px #ff0055, 0 0 30px #ff003388;
  letter-spacing: 0.1em;
}

h2 {
  font-family: 'Orbitron', monospace;
  color: #00ccff;
  text-transform: uppercase;
  letter-spacing: 2px;
  text-shadow: 0 0 10px #00ccff88;
}

.controls-hint {
  color: #00ccff;
  font-family: 'Rajdhani', monospace;
  font-size: 0.9em;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  margin-top: -10px;
  margin-bottom: 20px;
  text-shadow: 0 0 8px #00ccff44;
}

/* Show/hide hints based on touch capability */
.mobile-hint { display: none; }

@media (pointer: coarse) {
  .controls-hint:not(.mobile-hint) { display: none; }
  .mobile-hint { display: block; }
}

/* ============================================
   MENU & LAYOUT
   ============================================ */

.menu {
  padding: 40px;
  position: relative;
}

@media only screen and (max-width: 768px) {
  .center { width: 95%; margin: auto; }
  .game-name { font-size: 2.5em !important; }
  .menu { padding: 20px 15px; }
}

@media only screen and (min-width: 768px) {
  .center { width: 50%; margin: auto; }
}

/* ============================================
   NEON BUTTONS
   ============================================ */

a.animated-button:link,
a.animated-button:visited {
  position: relative;
  display: block;
  margin: 20px auto 0;
  padding: 14px 20px;
  color: #00ff88;
  font-family: 'Orbitron', monospace;
  font-size: 1em;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  overflow: hidden;
  border: 2px solid #00ff88;
  border-radius: 4px;
  background: transparent;
  text-shadow: 0 0 8px #00ff8866;
  box-shadow:
    0 0 10px rgba(0, 255, 136, 0.15),
    inset 0 0 10px rgba(0, 255, 136, 0.05);
  transition: all 0.3s ease;
}

a.animated-button:link::after,
a.animated-button:visited::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 150%;
  height: 0%;
  background: linear-gradient(135deg, #00ff88, #00cc66);
  transform: translateX(-50%) translateY(-50%) rotate(25deg);
  transition: all 0.4s ease;
  z-index: -1;
}

a.animated-button:hover,
a.animated-button:link:hover,
a.animated-button:visited:hover {
  color: #0a0a0f;
  text-shadow: none;
  box-shadow:
    0 0 20px rgba(0, 255, 136, 0.4),
    0 0 40px rgba(0, 255, 136, 0.2),
    inset 0 0 20px rgba(0, 255, 136, 0.1);
}

a.animated-button:link:hover::after,
a.animated-button:visited:hover::after {
  height: 450%;
}

a.animated-button.victoria-two {
  border: 2px solid #00ff88;
}

a.animated-button.victoria-two::after {
  background: linear-gradient(135deg, #00ff88, #00cc66);
  transform: translateX(-50%) translateY(-50%) rotate(25deg);
}

/* ============================================
   GAME AREA & CANVAS
   ============================================ */

#game-area {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}

canvas {
  border: 2px solid #00ff8844;
  border-radius: 4px;
  box-shadow:
    0 0 30px rgba(0, 255, 136, 0.15),
    0 0 60px rgba(0, 255, 136, 0.05),
    inset 0 0 30px rgba(0, 0, 0, 0.5);
  margin: auto;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  position: absolute;
  transition: box-shadow 0.3s ease;
}

canvas.shake {
  animation: screenShake 0.15s ease-out;
}

@keyframes screenShake {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-3px, 2px); }
  50% { transform: translate(3px, -2px); }
  75% { transform: translate(-2px, -1px); }
  100% { transform: translate(0, 0); }
}

/* Mobile canvas: flow layout instead of absolute */
@media only screen and (max-width: 768px) {
  #game-area {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    padding-top: 10px;
  }

  canvas {
    position: static;
    margin: 0 auto;
    max-width: calc(100vw - 16px);
  }
}

/* ============================================
   MOBILE CONTROLS - D-PAD & PAUSE
   ============================================ */

#mobile-controls {
  display: none;
}

@media only screen and (max-width: 768px), (pointer: coarse) {
  #mobile-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 0 20px;
    gap: 8px;
  }
}

.mobile-pause-btn {
  font-family: 'Orbitron', monospace;
  font-size: 0.8em;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: #00ccff;
  background: transparent;
  border: 2px solid #00ccff44;
  border-radius: 4px;
  padding: 8px 30px;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.2s ease;
  -webkit-user-select: none;
  user-select: none;
}

.mobile-pause-btn:active {
  background: #00ccff22;
  border-color: #00ccff;
  box-shadow: 0 0 15px #00ccff44;
}

.dpad {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  -webkit-user-select: none;
  user-select: none;
}

.dpad-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.dpad-btn {
  width: 64px;
  height: 64px;
  font-size: 1.6em;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 255, 136, 0.06);
  border: 2px solid #00ff8844;
  border-radius: 10px;
  color: #00ff88;
  cursor: pointer;
  transition: all 0.1s ease;
  -webkit-user-select: none;
  user-select: none;
  outline: none;
  padding: 0;
}

.dpad-btn:active,
.dpad-btn.active {
  background: rgba(0, 255, 136, 0.2);
  border-color: #00ff88;
  box-shadow: 0 0 20px rgba(0, 255, 136, 0.3);
  color: #ffffff;
  transform: scale(0.95);
}

.dpad-center {
  width: 64px;
  height: 64px;
  border-radius: 10px;
  background: rgba(0, 255, 136, 0.02);
  border: 1px solid #00ff8811;
}

/* Larger D-pad on bigger phones */
@media only screen and (min-width: 400px) and (max-width: 768px) {
  .dpad-btn {
    width: 72px;
    height: 72px;
    font-size: 1.8em;
  }
  .dpad-center {
    width: 72px;
    height: 72px;
  }
}

/* ============================================
   SCORE DISPLAY
   ============================================ */

#score {
  padding: 10px;
  font-family: 'Orbitron', monospace;
  font-size: 1.8em;
  font-weight: 700;
  color: #00ff88;
  text-shadow: 0 0 10px #00ff8866;
  letter-spacing: 0.05em;
}

@media only screen and (max-width: 768px) {
  #score {
    font-size: 1.2em;
    padding: 5px;
  }
}

/* ============================================
   DEBUG PANEL
   ============================================ */

#debug {
  display: block;
  position: absolute;
  float: left;
  padding: 15px 20px;
  top: 2%;
  left: 1%;
  border: 1px solid #00ff8833;
  border-radius: 8px;
  background: rgba(10, 10, 15, 0.85);
  backdrop-filter: blur(5px);
  box-shadow: 0 0 20px rgba(0, 255, 136, 0.08);
  font-size: 0.85em;
  font-family: 'Rajdhani', monospace;
  color: #00ff88aa;
  width: 250px;
  height: auto;
  z-index: 5;
}

#debug:empty {
  display: none;
  margin: 0;
  padding: 0;
  border: 0;
}

#debug .debugvalue {
  float: right;
  color: #00ccff;
}

/* Hide debug panel on mobile */
@media only screen and (max-width: 768px) {
  #debug {
    display: none !important;
  }
}

/* ============================================
   GAME OVER OVERLAY
   ============================================ */

#endgamemenu {
  margin: auto;
  left: 0;
  right: 0;
  bottom: 0;
  position: absolute;
  z-index: 9;
  width: 35%;
  margin: 15% auto;
  background: rgba(10, 10, 15, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 12px;
  border: 2px solid #ff005544;
  box-shadow:
    0 0 40px rgba(255, 0, 85, 0.2),
    0 0 80px rgba(255, 0, 85, 0.1),
    inset 0 0 40px rgba(0, 0, 0, 0.5);
  transition: all 0.5s ease-in-out;
  animation: gameOverAppear 0.5s ease-out;
}

@media only screen and (max-width: 768px) {
  #endgamemenu {
    width: 85%;
    margin: 25% auto;
    padding: 20px;
    position: fixed;
    top: 0;
  }

  #endgamemenu h1 {
    font-size: 1.5em;
  }
}

@keyframes gameOverAppear {
  0% {
    opacity: 0;
    transform: scale(0.8);
  }
  50% {
    transform: scale(1.02);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

#endgamemenu h1 {
  animation: gameOverFlash 1s ease-in-out infinite alternate;
}

@keyframes gameOverFlash {
  0% { text-shadow: 0 0 10px #ff0055, 0 0 30px #ff005588; }
  100% { text-shadow: 0 0 20px #ff0055, 0 0 50px #ff0055, 0 0 80px #ff005566; }
}

#final-score {
  font-family: 'Orbitron', monospace;
  font-size: 1.4em;
  color: #00ccff;
  text-shadow: 0 0 10px #00ccff66;
  padding: 10px 0;
}

/* ============================================
   HIGHSCORE TABLE
   ============================================ */

#highscore-cont {
  color: #00ff88;
}

#highscore-cont .table {
  color: #00ff88cc;
  font-family: 'Rajdhani', monospace;
  border-collapse: separate;
  border-spacing: 0 4px;
}

#highscore-cont .table thead th {
  border: none;
  color: #00ccff;
  font-family: 'Orbitron', monospace;
  font-size: 0.85em;
  letter-spacing: 0.1em;
  text-shadow: 0 0 8px #00ccff44;
}

#highscore-cont .table tbody tr {
  background: rgba(0, 255, 136, 0.03);
  transition: background 0.2s ease;
}

#highscore-cont .table tbody tr:hover {
  background: rgba(0, 255, 136, 0.08);
}

#highscore-cont .table td {
  border: none;
  padding: 8px 12px;
}

#size-picker {
  background: #0a0a0f;
  color: #00ccff;
  border: 1px solid #00ccff44;
  padding: 6px 12px;
  border-radius: 4px;
  font-family: 'Orbitron', monospace;
  font-size: 0.9em;
  outline: none;
  margin-bottom: 15px;
}

#size-picker:focus {
  border-color: #00ccff;
  box-shadow: 0 0 10px #00ccff33;
}

/* ============================================
   FORM CONTROLS
   ============================================ */

.form-control {
  background: rgba(0, 255, 136, 0.05);
  border: 1px solid #00ff8833;
  color: #00ff88;
  font-family: 'Rajdhani', monospace;
  border-radius: 4px;
  transition: all 0.3s ease;
}

.form-control:focus {
  background: rgba(0, 255, 136, 0.08);
  border-color: #00ff88;
  box-shadow: 0 0 15px rgba(0, 255, 136, 0.15);
  color: #00ff88;
}

.form-control::placeholder {
  color: #00ff8844;
}

label {
  font-family: 'Orbitron', monospace;
  font-size: 0.75em;
  letter-spacing: 0.08em;
  color: #00ccff;
  text-transform: uppercase;
}

input:invalid,
input:placeholder-shown {
  box-shadow: 0 0 15px 1px rgba(255, 0, 85, 0.3);
}

/* ============================================
   SLIDERS
   ============================================ */

.slidecontainer {
  width: 100%;
}

.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: linear-gradient(90deg, #00ff8833, #00ff8866);
  outline: none;
  opacity: 0.8;
  border-radius: 3px;
  transition: opacity 0.2s;
}

.slider:hover {
  opacity: 1;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 28px;
  height: 28px;
  background: #00ff88;
  cursor: pointer;
  border-radius: 50%;
  box-shadow: 0 0 10px #00ff8888;
  transition: box-shadow 0.2s ease;
}

.slider::-webkit-slider-thumb:hover {
  box-shadow: 0 0 20px #00ff88;
}

.slider::-moz-range-thumb {
  width: 28px;
  height: 28px;
  background: #00ff88;
  cursor: pointer;
  border-radius: 50%;
  border: none;
  box-shadow: 0 0 10px #00ff8888;
}

/* ============================================
   TOGGLE SWITCH
   ============================================ */

input[type=checkbox] {
  visibility: hidden;
}

.switch-cont {
  width: 120px;
  height: 40px;
  background: #111118;
  margin: 20px 60px;
  border-radius: 50px;
  position: relative;
  border: 1px solid #00ff8822;
}

.switch-cont::before {
  content: '';
  position: absolute;
  top: 19px;
  left: 14px;
  height: 2px;
  width: 90px;
  background: #00ff8822;
  border-radius: 1px;
}

.switch-cont label {
  display: block;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  cursor: pointer;
  position: absolute;
  top: 9px;
  z-index: 1;
  left: 12px;
  background: #334;
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
}

.switch-cont input[type=checkbox]:checked + label {
  left: 84px;
  background: #00ff88;
  box-shadow: 0 0 15px #00ff8888;
}

/* ============================================
   KEYBOARD FEEDBACK
   ============================================ */

#control-feedback {
  display: block;
  position: absolute;
  float: left;
  top: 50%;
  left: 3%;
  border-radius: 20px;
  font-size: 1em;
  width: auto;
  height: auto;
}

#control-feedback .row .col {
  padding: 0;
}

kbd {
  color: #00ff8866;
  font-family: 'Orbitron', monospace;
  line-height: 2.5em;
  cursor: pointer;
  padding: 0.35em 0.9em 0.55em 0.5em;
  margin: 0.15em;
  white-space: nowrap;
  background-color: #111118;
  border: 1px solid #00ff8833;
  border-radius: 6px;
  user-select: none;
  transition: all 0.2s ease;
}

#control-feedback kbd.pressed {
  background-color: #00ff8822;
  box-shadow: 0 0 15px rgba(0, 255, 136, 0.3);
  color: #00ff88;
  border-color: #00ff88;
}

/* ============================================
   CREATING NEW GAME HEADER
   ============================================ */

#newgame-menu .h2 {
  font-family: 'Orbitron', monospace;
  color: #00ccff;
  text-shadow: 0 0 10px #00ccff44;
  font-size: 1.3em;
}

@media only screen and (max-width: 768px) {
  #newgame-menu .h2 {
    font-size: 1em;
  }
}

/* ============================================
   PARTICLE CANVAS (overlay)
   ============================================ */

#particle-canvas {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 10;
}

/* ============================================
   FOOTER
   ============================================ */

footer {
  margin-bottom: 0 !important;
  margin-top: 80px;
}

footer p {
  margin: 0;
  padding: 0;
}
