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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: #1a1a2e;
}

#game-container {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/* Sky */
#sky {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 55%;
  background: linear-gradient(to bottom, #0f0c29, #302b63, #24243e);
}

/* Road */
#road {
  position: absolute;
  bottom: 25%;
  left: 0;
  width: 100%;
  height: 25%;
  background: #2d2d2d;
  border-top: 4px solid #444;
  border-bottom: 4px solid #444;
}

#road::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  width: 100%;
  height: 4px;
  background: repeating-linear-gradient(90deg, #fff 0, #fff 40px, transparent 40px, transparent 80px);
}

/* Sidewalk */
#sidewalk {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 25%;
  background: #555;
  border-top: 6px solid #666;
}

#sidewalk::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: repeating-linear-gradient(90deg, transparent 0, transparent 98px, #444 98px, #444 100px);
}

/* Character */
#character-wrapper {
  position: absolute;
  bottom: 15%;
  left: 50%;
  transform: translateX(-50%);
  width: 120px;
  height: 220px;
  z-index: 10;
}

#character {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.05s;
}

#character .head {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 70px;
  background: #d4a373;
  border-radius: 50% 50% 45% 45%;
  z-index: 5;
}

#character .eye {
  position: absolute;
  top: 28px;
  width: 10px;
  height: 10px;
  background: #fff;
  border-radius: 50%;
  z-index: 6;
}

#character .eye.left { left: 50%; margin-left: -18px; }
#character .eye.right { left: 50%; margin-left: 8px; }

#character .eye::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 4px;
  height: 4px;
  background: #000;
  border-radius: 50%;
}

#character .mouth {
  position: absolute;
  top: 48px;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 10px;
  background: #6d1a1a;
  border-radius: 0 0 50% 50%;
  z-index: 6;
  transition: height 0.1s;
}

#character .body {
  position: absolute;
  top: 65px;
  left: 50%;
  transform: translateX(-50%);
  width: 50px;
  height: 80px;
  background: #c0392b;
  border-radius: 10px;
  z-index: 4;
}

#character .arm {
  position: absolute;
  top: 75px;
  width: 14px;
  height: 60px;
  background: #d4a373;
  border-radius: 7px;
  z-index: 3;
  transform-origin: top center;
  transition: transform 0.1s;
}

#character .arm.left {
  left: 50%;
  margin-left: -38px;
}

#character .arm.right {
  left: 50%;
  margin-left: 24px;
}

#character .leg {
  position: absolute;
  top: 140px;
  width: 16px;
  height: 70px;
  background: #2c3e50;
  border-radius: 8px;
  z-index: 3;
  transform-origin: top center;
  transition: transform 0.1s;
}

#character .leg.left {
  left: 50%;
  margin-left: -20px;
}

#character .leg.right {
  left: 50%;
  margin-left: 4px;
}

/* Shaking / Freaking Out */
#character.shaking {
  animation: shake 0.1s infinite;
}

#character.freaking {
  animation: freakOut 0.08s infinite;
}

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

@keyframes freakOut {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  20% { transform: translate(-6px, 4px) rotate(-5deg); }
  40% { transform: translate(6px, -4px) rotate(5deg); }
  60% { transform: translate(-4px, -6px) rotate(-3deg); }
  80% { transform: translate(4px, 6px) rotate(3deg); }
}

/* Score & Combo */
#score-display {
  position: absolute;
  top: 20px;
  left: 20px;
  font-size: 28px;
  font-weight: bold;
  color: #fff;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.7);
  z-index: 100;
}

#combo-display {
  position: absolute;
  top: 55px;
  left: 20px;
  font-size: 20px;
  font-weight: bold;
  color: #f1c40f;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.7);
  z-index: 100;
  opacity: 0;
  transition: opacity 0.2s;
}

#combo-display.visible {
  opacity: 1;
}

/* Timer Bar */
#timer-bar-container {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 200px;
  height: 24px;
  background: rgba(0,0,0,0.5);
  border: 2px solid #fff;
  border-radius: 12px;
  overflow: hidden;
  z-index: 100;
}

#timer-bar {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #2ecc71, #f1c40f, #e74c3c);
  border-radius: 10px;
  transition: width 0.1s linear, background 0.3s;
}

/* Crack Button */
#crack-btn {
  position: absolute;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  padding: 18px 48px;
  font-size: 24px;
  font-weight: bold;
  color: #fff;
  background: linear-gradient(135deg, #8e44ad, #6c3483);
  border: none;
  border-radius: 50px;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0,0,0,0.4);
  z-index: 100;
  transition: transform 0.1s, box-shadow 0.1s;
  user-select: none;
}

#crack-btn:active {
  transform: translateX(-50%) scale(0.95);
  box-shadow: 0 3px 10px rgba(0,0,0,0.4);
}

#crack-btn:hover {
  background: linear-gradient(135deg, #9b59b6, #7d3c98);
}

/* Floating Points */
.floating-points {
  position: absolute;
  font-size: 24px;
  font-weight: bold;
  color: #2ecc71;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
  pointer-events: none;
  z-index: 200;
  animation: floatUp 1s ease-out forwards;
}

@keyframes floatUp {
  0% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-80px) scale(1.3); }
}

/* Message Overlay */
#message-overlay {
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 48px;
  font-weight: bold;
  color: #e74c3c;
  text-shadow: 2px 2px 6px rgba(0,0,0,0.8);
  z-index: 200;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  white-space: nowrap;
}

#message-overlay.show {
  opacity: 1;
}

/* Screens */
#start-screen, #game-over-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 300;
  color: #fff;
}

#start-screen h1, #game-over-screen h1 {
  font-size: 64px;
  margin-bottom: 20px;
  color: #e74c3c;
  text-shadow: 3px 3px 6px rgba(0,0,0,0.8);
}

#start-screen p, #game-over-screen p {
  font-size: 20px;
  margin-bottom: 10px;
  text-align: center;
  max-width: 500px;
  line-height: 1.5;
}

#start-btn, #restart-btn {
  margin-top: 30px;
  padding: 16px 48px;
  font-size: 22px;
  font-weight: bold;
  color: #fff;
  background: linear-gradient(135deg, #e74c3c, #c0392b);
  border: none;
  border-radius: 50px;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0,0,0,0.4);
  transition: transform 0.1s;
}

#start-btn:hover, #restart-btn:hover {
  transform: scale(1.05);
}

#start-btn:active, #restart-btn:active {
  transform: scale(0.95);
}

.hidden {
  display: none !important;
}

/* Responsive */
@media (max-width: 600px) {
  #crack-btn {
    font-size: 18px;
    padding: 14px 36px;
  }
  #score-display { font-size: 20px; }
  #combo-display { font-size: 16px; }
  #start-screen h1, #game-over-screen h1 { font-size: 40px; }
}
