body {
  font-family: 'Arial', sans-serif;
  margin: 0;
  padding: 0;
  background: #f0f8ff;
  color: #333;
}

header {
  background-image: url('banner.jpg');
  background-size: cover;
  background-position: center;
  color: white;
  padding: 3em 1em;
  text-align: center;
  position: relative;
}

header::before {
  content: "";
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 122, 204, 0.5);
  z-index: 0;
}

header h1,
header nav {
  position: relative;
  z-index: 1;
}

nav a {
  color: white;
  margin: 0 1em;
  text-decoration: none;
  padding: 5px 10px;
  border-radius: 4px;
}

a:hover{
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

main {
  padding: 2em;
  max-width: 1200px;
  margin: 0 auto;
}
.container {
  display: grid;
  grid-template-columns: 300px 300px;
  column-gap: 20px;
  justify-content: center;
  margin-top: 20px;
}
.box {
  border: 2px solid black;
  padding: 10px;
  border-radius: 8px;
  background-color: #f9f9f9;
}
.img {
  width: 100%;
  height: 250px;
  display: block;
  border-radius: 5px;
}
main {
  text-align: center;
  padding: 20px;
}
.formula {
  font-size: 1.5em;
  font-weight: bold;
  color: #007acc;
  margin: 20px 0;
  padding: 10px;
  background-color: #f0f8ff;
  border-radius: 5px;
  display: inline-block;
}
.energy-types {
  display: flex;
  justify-content: space-around;
  margin: 30px 0;
}
.energy-type {
  width: 45%;
  padding: 15px;
  border-radius: 8px;
}
.ke {
  background-color: #3498db20;
  border: 2px solid #3498db;
}
.pe {
  background-color: #e74c3c20;
  border: 2px solid #e74c3c;
}
.controls {
  margin: 20px;
  padding: 15px;
  background: #f8f8f8;
  border-radius: 5px;
  text-align: center;
}

.controls label {
  margin-right: 10px;
}

.controls input[type="range"] {
  width: 200px;
  margin-right: 10px;
  vertical-align: middle;
}

.controls button {
  padding: 8px 16px;
  margin: 0 5px;
  cursor: pointer;
  background: #007acc;
  color: white;
  border: none;
  border-radius: 4px;
}

.controls button:hover {
  background: #0062a3;
}

.speed-control {
  background: #e8e8e8;
  padding: 10px;
  border-radius: 5px;
  margin: 10px 0;
  display: inline-block;
}

.simulation-container {
  display: flex;
  justify-content: center;
  align-items: stretch;
  gap: 40px;
  margin: 20px auto;
}

.pendulum-box {
  flex: 1;
  min-width: 600px;
  background: white;
  border: 1px solid #000;
  border-radius: 8px;
  padding: 10px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  display: flex;
  justify-content: center;
  align-items: center;
}

canvas {
  width: 100%;
  height: 100%;
}

.energy-container {
  flex: 1;
  min-width: 400px;
  background: #f8f8f8;
  border: 1px solid #000;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.energy-display {
  display: flex;
  justify-content: space-between;
  height: 100%;
}

.energy-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  width: 30%;
  padding: 10px;
}

.energy-bar h3 {
  margin: 0 0 15px 0;
  font-size: 1.1em;
  text-align: center;
}

.bar-container {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  height: 300px;
  width: 100%;
}

.bar {
  width: 40px;
  background: #f0f0f0;
  border: 1px solid #000;
  position: relative;
  height: 100%;
}

.fill {
  position: absolute;
  bottom: 0;
  width: 100%;
  transition: height 0.1s;
}

#kinetic-fill {
  background: #3498db;
}

#potential-fill {
  background: #e74c3c;
}

#total-fill {
  background: #2ecc71;
}

.energy-bar p {
  margin: 15px 0 0;
  font-weight: bold;
  text-align: center;
}


@media (max-width: 1200px) {
  .simulation-container {
    flex-direction: column;
    align-items: center;
    gap: 20px;
  }
  
  .pendulum-box, .energy-container {
    width: 100%;
    min-width: auto;
  }
}

@media (max-width: 600px) {
  .energy-display {
    flex-direction: column;
    align-items: center;
  }
  
  .energy-bar {
    width: 100%;
    margin-bottom: 20px;
  }
  
  .bar-container {
    height: 200px;
  }
  
  .controls {
    padding: 10px;
    margin: 10px;
  }
  
  .controls input[type="range"] {
    width: 150px;
  }
}
#pendulum-container {
  position: relative;
  width: 100%;
  height: 430px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  overflow: visible;
}

#pendulum-image {
  position: absolute;
  top: 0;
  width: 40px;
  height: auto;
  transform-origin: 50% 0; 
  transition: transform 0.05s linear;
}
#pendulum-state {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background-color: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 14px;
  text-align: center;
  min-width: 250px;
  transition: all 0.3s ease;
}
