:root {
  --bg: #0f0f0f;
  --panel: #151515;
  --ink: #e8e8e8;
  --accent: #00ffa0;
  --dead: #1a1a1a;
  --alive: #00ffa0;
  --grid: rgba(255, 255, 255, 0.03);
}

body,html {
  margin: 0;
  padding: 0;

  height: 100%;
  width: 100%;
  position: relative;
  overflow-x: hidden;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial,
    "Apple Color Emoji", "Segoe UI Emoji";
  color: var(--ink);
  min-height: 100vh;
  display: grid;
  box-sizing: border-box;
  place-items: center;
}

body {
  display: flex;
  flex-direction: column;
}


/* Background video */
#bg-video {
  position: fixed;
  top: 50%;
  left: 50%;
  min-width: 100%;
  min-height: 100%;
  width: auto;
  height: auto;
  z-index: -2; /* behind everything */
  transform: translate(-50%, -50%);
  object-fit: cover;
}

/* Dark overlay over the video */
#video-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.6); /* same as your gradient darkness */
  z-index: -1; /* above video, below content */
}


.title {
    font-family: "Felipa", serif;
  font-weight: 400;
  font-style: normal;
  font-size: 100px;
  padding-top: 100px;
  color: rgba(255,255,255,.8);
text-shadow: 0 0 15px rgba(255,255,255,.5), 0 0 10px rgba(255,255,255,.5);
}

.copy{
  text-align: center;
  font-size: 35px;
  padding-top: 20px;
  padding-left: 50px;
  padding-right: 50px;
  font-family: 'Courier New', Courier, monospace;
}

.wrap {
  width: min(1240px, 96vw);
  padding: 0px;
  flex: 1;
}

.wrapper {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 24px;
  width: 100%;
  max-width: 100%;
  padding: 20px;
  box-sizing: border-box;
  overflow-x: hidden;
}

/* RULES PANEL */
.rules {
 
  flex: 0 0 320px;         
  min-width: 320px;
  max-width: 360px;
  background: var(--panel);
  padding: 13px;
  border-radius: 12px;
  color: #ddd;
  font-size: 21px;
  font-family: 'Courier New', Courier, monospace;
  line-height: 1.6;
  box-sizing: border-box;
  border: 1px solid #232323;
  transition: transform 0.3s ease;
}

.rules-header {
  display: flex;
  justify-content: center;
  align-items: center;
}

.rules-header h2 {
  margin: 0;
  padding-top: 30px;
  font-family: "Felipa", serif;
  text-align: center;
  font-size: 35px;
  color: #00ffa0;
  
text-shadow: 0 0 15px rgba(0, 255, 64, 0.5), 0 0 10px rgba(255,255,255,.5);
}

.rules-header button {
  background: transparent;
  border: none;
  color: #00ffa0;
  font-size: 1.2rem;
  cursor: pointer;
}






h1 {
  font-size: 44px;
  margin: 0 0 12px 0;
  letter-spacing: 0.3px;
    text-align: center;
  margin-bottom: 10px;
}


.panel {
  flex: 1 1 0;
  min-width: 0;                   /* IMPORTANT in flex rows */
  background: var(--panel);
  border: 1px solid #232323;
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 10px 30px rgba(0,0,0,.35);
}

.toolbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
  margin-top: 20px;
}
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
button,
.slider {
  background: #1f1f1f;
  color: var(--ink);
  border: 1px solid #2a2a2a;
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
}
button:hover {
  background: #262626;
}
button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
label {
  font-size: 12px;
  opacity: 0.85;
}
input[type="range"] {
  width: 180px;
  vertical-align: middle;
}

.stats {
  display: flex;
  gap: 12px;
  font-size: 13px;
  opacity: 0.9;
}

#presets {
  padding: 6px;
  border-radius: 6px;
}

canvas {
  width: min(900px, 100%);  /* shrink to fit when needed */
  height: auto;             /* keep aspect ratio */
  aspect-ratio: 3 / 2;      /* same as your 900x600 */
  display: block;
  border-radius: 12px;
  outline: 1px solid #2a2a2a;
  background: var(--bg);
  margin-top: 10px;
}



/* MOBILE BEHAVIOR */
@media (max-width: 768px) {
  .wrapper {
    flex-direction: column;   /* stack vertically */
    align-items: stretch;     /* make both children full width */
  }

  .rules {
    position: relative;       /* no fixed sliding panel */
    width: 100%;              /* take full width */
    max-width: none;          /* remove desktop max */
    min-width: auto;          /* let it shrink */
    transform: none;          /* reset hidden panel behavior */
    margin-bottom: 1rem;      /* space below rules */
  }

  .panel {
    width: 100%;              /* game takes full width */
    max-width: none;
  }

  .floating-btn {
    display: none;            /* not needed if rules are stacked */
  }
}

/* ---------- Desktop layout (keeps current look) ---------- */
.toolbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
  margin-top: 20px;
}

/* left side: buttons */
.buttons-container {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* make buttons visually consistent */
.buttons-container button {
  padding: 8px 12px;
  border-radius: 10px;
  background: #1f1f1f;
  color: var(--ink);
  border: 1px solid #2a2a2a;
  cursor: pointer;
  font-size: 14px;
}

/* right side: slider + label */
.slider-container {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}
.slider-container label { font-size: 12px; opacity: .85; }
.slider-container input[type="range"] { width: 180px; }

/* stats container desktop: inline items */
.stats-container {
  display: flex;
  gap: 12px;
  font-size: 13px;
  opacity: 0.9;
  margin-top: 10px;
  align-items: center;
}
.stats-container .stat { display: flex; gap: 6px; align-items: baseline; }

/* ---------- Mobile layout (stack controls vertically) ---------- */
@media (max-width: 600px) {
  /* make toolbar a vertical stack */
  .toolbar {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  /* Buttons stacked vertically and full width for easy tapping */
  .buttons-container {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: row;
    gap: 8px;
  }
  .buttons-container button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px; /* space between icon and optional text */
  padding: 10px 12px;
  font-size: 18px;
  border-radius: 10px;
  background: #1f1f1f;
  color: var(--ink);
  border: 1px solid #2a2a2a;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.1s ease;
}

.buttons-container button:hover {
  background: #262626;
  transform: scale(1.05);
}

.buttons-container button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

  /* Slider centered and full width */
  .slider-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    width: 100%;
  }
  .slider-container input[type="range"] { width: 90%; }

  /* Stats become a vertical block so they fit */
  .stats-container {
    flex-direction: column;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    margin-bottom: 10px;
  }

  /* ensure the panel takes full width and canvas fits inside */
  .panel {
    width: 100%;
    box-sizing: border-box;
  }
  canvas {
    width: 100%;
    height: auto;
    aspect-ratio: 3/2;
  }
}



/* footer */

.footer-row {
  display: flex;
  align-items: center;      /* vertical centering */
  justify-content: center;  /* horizontal centering */
  gap: 20px;                /* space between toggle button and footer */
  flex-wrap: wrap;          /* wrap on small screens */
  margin: 30px 0;
}

#lang-toggle {
  background: #151515;
  box-shadow: 0 10px 30px rgba(0,0,0,.35);
  border: 1px solid #232323;
  color: #fff;
  padding: 10px 15px;
  font-size: 35px;
  border-radius: 12px;
  cursor: pointer;
 
}

#lang-toggle:hover {
  background: #262626;
}

.footer {
  flex: 1 1 0;
  min-width: 0;                  /* match panel behavior */
  background: #151515;
  border: 1px solid #232323;
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 10px 30px rgba(0,0,0,.35);
  gap: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  margin: 20px 0;                 /* same spacing as panels */
  font-size: 14px;
  color: #fff;
}

.footer-left,
.footer-right {
  margin: 5px 0;
}

.footer-right a {
  margin-left: 10px;
  color: #fff;
  font-size: 18px;
}

.footer a {
  color: #fff;
  text-decoration: none;
   transition: color 0.3s ease;
}

.footer-left a:hover {
  
  color: #00ffa0;
  
}

.footer-right a {
  margin-left: 15px;
  font-size: 18px; /* Icon size */
   transition: color 0.3s ease;
}

.footer-right a:hover {
  
  color: #00ffa0; /* Example hover color, can customize per icon */
}

/* Responsive behavior */
@media (max-width: 600px) {

  .footer-row{
    flex-direction: column;
  }
  .footer {
    flex-direction: column;
    text-align: center;
    margin-left: 30px;
    margin-right: 30px;
  }
  .footer-right {
    margin-top: 10px;
  }

  .title{
    margin-left: 30px;
    margin-right: 30px;
  }

}


/* preloader */
#overlayer {
  width:100%;
  height:100%;  
  position:absolute;
  z-index:1;
  background:#151515;
}
.loader {
  display: inline-block;
  width: 30px;
  height: 30px;
  position: absolute;
  z-index:3;
  border: 4px solid #00ffa0;
  top: 50%;
  animation: loader 2s infinite ease;
}

.loader-inner {
  vertical-align: top;
  display: inline-block;
  width: 100%;
  background-color: #00ffa0;;
  animation: loader-inner 2s infinite ease-in;
}

@keyframes loader {
  0% {
    transform: rotate(0deg);
  }
  
  25% {
    transform: rotate(180deg);
  }
  
  50% {
    transform: rotate(180deg);
  }
  
  75% {
    transform: rotate(360deg);
  }
  
  100% {
    transform: rotate(360deg);
  }
}

@keyframes loader-inner {
  0% {
    height: 0%;
  }
  
  25% {
    height: 0%;
  }
  
  50% {
    height: 100%;
  }
  
  75% {
    height: 100%;
  }
  
  100% {
    height: 0%;
  }
}