/* RESET + VARIABLES */
:root{
    --bg-inner-div-color:#020618;
    --bg-main-box-color:#1d293d;
    --text-primary-color:#ebe7e7;
    --bg-primary-color:#314158;
    --snake-color:#eff6ff;

    --space-xs:4px;
    --space-sm:8px;
    --space-md:16px;
    --space-lg:24px;
    --space-xl:32px;
    --space-xxl:40px;

    --br-sm:8px;
    --br-md:16px;
    --br-xl:32px;
}

*{
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,body{
    height: 100%;
    width: 100%;
    background-color: var(--bg-primary-color);
    color: var(--text-primary-color);
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
}

/* Main layout */
main{
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

#main-box{
    background: var(--bg-main-box-color);
    width: 90%;
    height: 90%;
    border-radius: var(--br-xl);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    
}

/* Section layout */
section{
    padding:15px;
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    flex: 1; /* makes section take full height inside main-box */

}

/* Top bar (3 infos) */
.infos-container {
    display: flex;
    justify-content: space-between; /* left-center-right */
    align-items: center;
    width: 100%;
}

.infos {
    padding: 2px var(--space-md);
    display: flex;
    align-items: center;
    gap: var(--space-lg);
    background-color: rgba(224, 223, 223, 0.418);
    border-radius: 25px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.25);
}

/* Board (Fills remaining space) */
/* Board (Fills remaining space) */
.board {
  flex: 1;                       /* fill remaining space in the section */
  width: 100%;                   /* stretch full width of parent */
  height: 100%;                  /* <-- ensure it actually has height */
  min-height: 0;                 /* allow flexbox to shrink properly */

  display: grid;
  /* each column is exactly 30px, JS also uses 30px for blockWidth */
 grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); grid-auto-rows: repeat(auto-fill, minmax(40px, 1fr));
  /* each auto-created row is exactly 30px */

  gap: 0;                        /* NO gap — JS doesn’t account for it */
  padding: 0;                    /* NO padding — keeps math clean */
  border: 0;

  background: var(--bg-inner-div-color);
  border-radius: var(--br-md);
  overflow: hidden;              /* avoid scrollbars changing clientHeight */
  align-self: stretch;
  justify-self: stretch;
}


/* block: exact 30x30, include borders in box-sizing if you want them */
.block {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 100%;
  border: 1px solid rgba(112, 111, 111, 0.432);
}

.fill{
    background-color: var(--snake-color);
}
.food {
  position: relative;
 background: #ff637e;
  overflow: hidden;
}

.btn{
  padding: var(--space-sm);
  border: none;
  border-radius: var(--br-xl);
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn:hover{
  transform: scale(1.1);
}


/* -------------------------------------------- */
/* 1) LEFT → RIGHT                               */
/* -------------------------------------------- */
.food::after {
  content: "";
  position: absolute;
  top: 0;
  left: -180%;
  width: 120%;
  height: 100%;
  display: block;
  pointer-events: none;
  will-change: transform, opacity;
  background: linear-gradient(
    115deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 240, 32, 0.7) 50%,
    rgba(255, 255, 255, 0) 100%
  );
  animation: shineRight 2.2s ease-in-out infinite;
}

/* -------------------------------------------- */
/* 2) RIGHT → LEFT                               */
/* -------------------------------------------- */
.food::before {
  content: "";
  position: absolute;
  top: 0;
  left: 180%;
  width: 120%;
  height: 100%;
  display: block;
  pointer-events: none;
  will-change: transform, opacity;
  background: linear-gradient(
    -115deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(249, 35, 35, 0.7) 50%,
    rgba(255, 255, 255, 0) 100%
  );
  animation: shineLeft 2.3s ease-in-out infinite;
}

/* -------------------------------------------- */
/* 3) TOP → BOTTOM                               */
/* -------------------------------------------- */
.food .shine-top {
  content: "";
  position: absolute;
  top: -180%;
  left: 0;
  width: 100%;
  height: 120%;
  display: block;
  pointer-events: none;
  will-change: transform, opacity;
  background: linear-gradient(
    180deg,
    rgba(255,255,255,0) 0%,
    rgba(243, 26, 26, 0.7) 50%,
    rgba(255,255,255,0) 100%
  );
  animation: shineDown 2.7s ease-in-out infinite;
}

/* -------------------------------------------- */
/* 4) BOTTOM → TOP                               */
/* -------------------------------------------- */
.food .shine-bottom {
  content: "";
  position: absolute;
  top: 180%;
  left: 0;
  width: 100%;
  height: 120%;
  display: block;
  pointer-events: none;
  will-change: transform, opacity;
  background: linear-gradient(
    0deg,
    rgba(255,255,255,0) 0%,
    rgba(248, 44, 44, 0.75) 50%,
    rgba(255,255,255,0) 100%
  );
  animation: shineUp 2.9s ease-in-out infinite;
}

/* -------------------------------------------- */
/* KEYFRAMES – SCALE WORKS NOW                  */
/* -------------------------------------------- */

@keyframes shineRight {
  0%   { left: -180%; opacity: 0.3; transform: scale(1); }
  50%  { left: 180%;  opacity: 1;   transform: scale(1.3); }
  100% { left: 180%;  opacity: 0.3; transform: scale(1); }
}

@keyframes shineLeft {
  0%   { left: 180%;  opacity: 0.3; transform: scale(1); }
  50%  { left: -180%; opacity: 1;   transform: scale(1.3); }
  100% { left: -180%; opacity: 0.3; transform: scale(1); }
}

@keyframes shineDown {
  0%   { top: -180%; opacity: 0.3; transform: scale(1); }
  50%  { top: 180%;  opacity: 1;   transform: scale(1.3); }
  100% { top: 180%;  opacity: 0.3; transform: scale(1); }
}

@keyframes shineUp {
  0%   { top: 180%;  opacity: 0.3; transform: scale(1); }
  50%  { top: -180%; opacity: 1;   transform: scale(1.3); }
  100% { top: -180%; opacity: 0.3; transform: scale(1); }
}

.modal{
  height: 100vh;
  width: 100%;
  position: fixed;
  top: 0;
  background-color: #e2a0a0af;
  backdrop-filter: blur;
  display: flex;
  justify-content: center;
  align-items: center;
}
.modal .start-game,.modal .game-over{
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-lg);
}

.modal .game-over{
display: none;
}

/* -----------------------
   Improved Modal Styles
   (Drop into styles.css; replaces previous .modal rules)
   ----------------------- */

.modal{
  position: fixed;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background: linear-gradient(rgba(2,6,18,0.55), rgba(2,6,18,0.55));
  backdrop-filter: blur(6px) saturate(120%);
  -webkit-backdrop-filter: blur(6px) saturate(120%);
  z-index: 999;
  transition: opacity 180ms ease;
  padding: 24px;
}

/* Card container used by both start & game-over sections */
.modal .start-game,
.modal .game-over {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: min(420px, calc(100% - 48px));
  padding: 22px;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
  box-shadow:
    0 18px 40px rgba(3,8,20,0.6),
    inset 0 1px 0 rgba(255,255,255,0.02);
  color: var(--text-primary-color);
  transform-origin: center;
  animation: modalPop 260ms cubic-bezier(.2,.9,.3,1) both;
  text-align: center;
  border: 1px solid rgba(255,255,255,0.03);
}

/* Slight visual distinction for Game Over card */
.modal .game-over {
  background: linear-gradient(180deg, rgba(255,255,255,0.01), rgba(255,99,126,0.02));
  border: 1px solid rgba(255, 99, 126, 0.06);
}

/* Headings inside modal */
.modal h3 {
  font-size: 1.25rem;
  margin: 0;
  letter-spacing: 0.2px;
  font-weight: 700;
  color: var(--text-primary-color);
}

/* Primary buttons (Start / Play Again) */
.btn {
  padding: 10px 18px;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, opacity 160ms;
  border: none;
  font-weight: 700;
  letter-spacing: 0.3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Start button styling */
.btn-start {
  background: linear-gradient(90deg, #06b6d4, #7c3aed);
  color: white;
  box-shadow: 0 10px 26px rgba(124,58,237,0.18);
  padding: 10px 20px;
}

/* Restart / Play Again button styling */
.btn-restart {
  background: linear-gradient(90deg, #ff6b6b, #ff9a9e);
  color: white;
  box-shadow: 0 10px 26px rgba(255,99,126,0.14);
  padding: 10px 20px;
}

/* subtle hover interactions */
.btn-start:hover, .btn-restart:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 14px 30px rgba(0,0,0,0.28);
}

/* secondary button look (if needed) */
.modal .secondary {
  background: transparent;
  color: rgba(235,231,231,0.9);
  border: 1px solid rgba(255,255,255,0.06);
  padding: 8px 14px;
  border-radius: 10px;
}

/* Hide the game-over section by default (JS controls visibility) */
.modal .game-over { 
  display: none;
}

/* Ensure start-game visible by default */
.modal .start-game {
  display: flex;
}

/* Animated pop */
@keyframes modalPop {
  0%   { opacity: 0; transform: translateY(-8px) scale(0.98); }
  60%  { opacity: 1; transform: translateY(2px) scale(1.02); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

/* Responsive tweak */
@media (max-width: 420px) {
  .modal .start-game,
  .modal .game-over {
    padding: 16px;
    border-radius: 12px;
  }
  .btn-start, .btn-restart {
    width: 100%;
    padding: 12px 16px;
  }
}
