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

body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  font-family: 'Press Start 2P', monospace;
  background: #000;
  color: #00FF00;
}

header {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem;
  gap: 0.5rem;
  background: #111;
}

#lives {
  font-size: 3rem;
  color: #FF0000;
}

#score-level {
  display: flex;
  gap: 2rem;
  font-size: 1rem;
}

#timer-bar {
  position: relative;
  width: 80%;
  max-width: 400px;
  height: 10px;
  background: #222;
  border: 1px solid #00FF00;
}

#timer-fill {
  position: absolute;
  height: 100%;
  width: 100%;
  background: #00FF00;
  transition: width 0.1s linear;
}

/* Ghost area sits below header, centered */
#ghost-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
}

/* Each row holds up to 10 ghosts side by side */
.ghost-row {
  display: flex;
  justify-content: center;
  flex-wrap: nowrap;
  gap: 0.25rem;
}

/* Utility class to hide elements */
.hidden {
  display: none !important;
}

/* Number Scale styling */
#number-scale-container {
  padding: 1.5rem 0;
  display: flex;
  justify-content: center;
}

#number-scale {
  display: flex;
  justify-content: space-between;
  align-items: flex-start; /* Align ticks to the top */
  width: 90%;
  max-width: 600px;
  position: relative;
}

.scale-line {
  position: relative;
  width: 2px;
  height: 8px; /* Standard height */
  background: #FFFF00; /* Yellow as requested */
}

.scale-line-medium {
  height: 16px; /* Double height */
}

.scale-line-large {
  height: 24px; /* Triple height */
}

/* Labels for major ticks */
.scale-line[data-label]::after {
  content: attr(data-label);
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  padding-top: 4px;
  color: #FFFF00;
  font-size: 0.7rem;
}

/* Ghost image styling */
.ghost {
  width: 40px;
  height: 40px;
  opacity: 0;
}
/* Inner div wrapper for wiggle */
.ghost-inner {
  width: 100%;
  height: 100%;
  background-size: contain;
  background-repeat: no-repeat;
  animation: ghost-wiggle 0.3s linear infinite;
}

/* Keyframes for sliding in */
@keyframes slide-in-left {
  from { transform: translateX(-100px); opacity: 0; }
  to   { transform: translateX(0);     opacity: 1; }
}
@keyframes slide-in-right {
  from { transform: translateX(100px); opacity: 0; }
  to   { transform: translateX(0);     opacity: 1; }
}
@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes slide-out-right {
  from { transform: translateX(0);    opacity: 1; }
  to   { transform: translateX(100px); opacity: 0; }
}

@keyframes ghost-wiggle {
  0%   { transform: rotate(0deg); }
  25%  { transform: rotate(2deg); }
  50%  { transform: rotate(-2deg); }
  75%  { transform: rotate(2deg); }
  100% { transform: rotate(0deg); }
}


.fade-in {
  animation: fade-in 0.5s ease-out forwards;
}

.slide-out-right {
  animation: slide-out-right 0.5s ease-out forwards;
  
}

/* Attach animations */
.from-left {
  animation: slide-in-left 0.5s ease-out forwards;
}
.from-right {
  animation: slide-in-right 0.5s ease-out forwards;
}

/* Background images */
.ghost.blinky .ghost-inner { background-image: url('blinky.png'); }
.ghost.clyde .ghost-inner  { background-image: url('clyde.png'); }
.ghost.inky .ghost-inner   { background-image: url('inky.png'); }
.ghost.pinky .ghost-inner  { background-image: url('pinky.png'); }


main {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 1rem;
}

#exercise {
  font-size: 2rem;
  margin-bottom: 1rem;
  white-space: nowrap;
}

#answer {
  margin-left: 0.5rem;
  font-size: 2rem;
}

#keypad {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.5rem;
  width: 100%;
  max-width: 500px;
}

#keypad button {
  font-size: 1rem;
  padding: 1rem;
  background: #111;
  color: #00FF00;
  border: 1px solid #00FF00;
  border-radius: 5px;
  font-family: 'Press Start 2P', monospace;
}

#keypad button:active {
  background: #222;
}

.level-complete {
  text-align: center;
  color: #00FF00;
  background: rgba(0,0,0,0.9);
  padding: 2rem;
}

.level-complete h2 {
  margin-bottom: 1rem;
  font-size: 1.5rem;
}

.level-complete div {
  margin: 0.5rem 0;
  font-size: 1rem;
}

/* Level-complete overlay covers entire game area */
#level-complete-overlay {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.95);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  color: #00FF00;
  z-index: 1000;
  pointer-events: all;
}

#level-complete-overlay h2 {
  margin-bottom: 1rem;
  font-size: 1.5rem;
}

#level-complete-overlay div {
  margin: 0.5rem 0;
  font-size: 1rem;
}


.game-over {
  text-align: center;
  font-size: 1.2rem;
  line-height: 2rem;
  color: #00FF00;
}

.game-over #final-score,
.game-over #final-level {
  font-size: 1rem;
}

.game-over button {
  margin-top: 1rem;
  font-size: 1rem;
  padding: 0.5rem 1rem;
  background: #00FF00;
  color: #000;
  border: none;
  border-radius: 5px;
}

.game-over button:active {
  background: #00cc00;
}