/* ==== CSS Variables ==== */
:root {
  --background-color-light: #222;
  --background-color-dark: #222;
  --shadow-small: 0 2px 4px rgba(0, 0, 0, 0.6);
  --shadow-large: 0 4px 16px rgba(0, 0, 0, 0.6);
  --font-family: Arial, sans-serif;
  --font-size-small: 10px;
  --font-size-standard: 12px;
  --font-size-large: 14px;
  --font-size-title: 32px;
  --text-color-light: white;
  --text-color-mid: lightgray;
  --text-color-dark: black;
}
/* ==== Global Reset ==== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  /* outline: 1px red dashed; */
}

html, body {
  overflow: hidden;
}

/* ==== App Layout ==== */

body {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  background-color: var(--background-color-dark);
}

.app {
  width: 370px;
  max-width: 370px;
  height: 640px;
  max-height: 640px;
  position: relative;
  border-radius: 12px;
  box-shadow: var(--shadow-large);
  background-color: var(--background-color-light);
  font-family: var(--font-family);
  font-size: var(--font-size-standard);
  color: var(--text-color-light);
  margin: 10px;
}

.header {
  width: 100%;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.header-side {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: lightgray;
  text-align: center;
}

.header-center {
  flex: 2.5;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  font-weight: bold;
  text-shadow: 2px 2px 4px rgba(0,0,0,1);
  color: white;
}

/* ======== GAME AREA ======== */
#game-area {
  position: relative;
  width: 370px;
  height: 570px;
  margin: 0 auto;
  background-color: #676767;
  border: 2px solid black;
  overflow: hidden;
  background-image:
    repeating-linear-gradient(
      to bottom,
      white 0px,
      white 20px,
      transparent 20px,
      transparent 40px
    ),
    repeating-linear-gradient(
      to bottom,
      white 0px,
      white 20px,
      transparent 20px,
      transparent 40px
    );
  background-repeat: repeat-y, repeat-y;
  background-position: 122px 0, 244px 0;
  background-size: 4px 40px, 4px 40px;
}

.road-moving {
  animation: roadMove 0.5s linear infinite;
}

@keyframes roadMove {
  to {
    background-position: 122px 40px, 244px 40px;
  }
}

#score {
  position: absolute;
  top: 10px;
  left: 10px;
  font-size: 16px;
  background: none;
  color: white;
}

/* ======== CARS ======== */
#car img, .enemy-car img {
  display: block;
  width: 80px;
  height: 160px;
  filter: drop-shadow(0 10px 10px rgba(0,0,0,1));
  pointer-events: none;
}

#car {
  position: absolute;
  bottom: 110px;
  left: 145px;
  width: 80px;
  height: 160px;
  pointer-events: none;
  transition: left 0.2s;
  z-index: 3;
}

.enemy-car {
  position: absolute;
  width: 80px;
  height: 160px;
  top: -160px;
  pointer-events: none;
  z-index: 2;
}

/* ======== EXPLOSION ======== */
.explosion {
  position: absolute;
  pointer-events: none;
  z-index: 5;
}

.explosion .star {
  position: absolute;
  width: 40px;
  height: 40px;
  transform: translate(0, 0) scale(0);
  opacity: 1;
  animation: starburst 1s ease-out forwards;
  pointer-events: none;
}

@keyframes starburst {
  to {
    transform: var(--transform);
    opacity: 1;
  }
}

/* ======== CONTROLS ======== */
#controls {
  position: absolute;
  bottom: 15px;
  display: flex;
  flex: 1;
  justify-content: center;
  align-items: center;
  gap: 20px;
  width: 370px;
  z-index: 10;
}

#controls button {
  background: none;
  border: none;
  cursor: pointer;
}

#left-btn img, #right-btn img {
  width: 70px;
  height: 70px;
}

#start-btn img {
  width: 120px;
  height: 50px;
}

#start-btn.disabled {
  opacity: 0.5;
  pointer-events: none;
}

/* ==== Footer ==== */
.footer {
  width: 100%;
  height: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-bottom-left-radius: 12px;
  border-bottom-right-radius: 12px;
  font-size: var(--font-size-small);
  color: var(--text-color-mid);
  padding: 0 10px;
}

.footer-content {
  width: 100%;
  display: flex;
  justify-content: space-between;
}

.footer a {
  color: var(--text-color-mid);
  text-decoration: none;
}