*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --grass-main: #16b859;
  --grass-light: #23ff53;
}

body {
  font-family: "Georgia", serif;
  background: linear-gradient(135deg, #ffeef8 20%, #d07ba7 100%);
  min-height: 100vh;
  overflow-x: hidden;
  overflow-y: auto;
  transition: background 2s ease;
}

body.withered {
  background: linear-gradient(135deg, #888888 0%, #666666 100%);
}

.grass-field {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 100vw;
  max-width: 100%;
  height: min(45vh, 420px);
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
}

.grass-blade {
  position: absolute;
  bottom: 0;
  left: var(--l);
  width: var(--w);
  height: var(--h);
  border-left: var(--line-w) solid var(--c);
  border-top-left-radius: 100%;
  transform-origin: bottom left;
  transform: rotate(var(--rot)) rotateY(var(--rotY));
  opacity: var(--o);
  -webkit-mask-image: linear-gradient(to top, transparent 5%, #fff 70%);
  mask-image: linear-gradient(to top, transparent 5%, #fff 70%);
  animation: grassWave var(--dur) ease-in-out infinite;
}

body.withered .grass-field {
  filter: grayscale(1) brightness(0.6);
}

body.withered .grass-blade {
  animation: none;
  opacity: 0.25;
}

.grass-blade::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: -1px;
  width: 100%;
  height: 100%;
  background-image: linear-gradient(
    to top,
    transparent 60%,
    rgba(35, 240, 255, 0.5)
  );
  filter: blur(0.4vmin);
  opacity: 0.6;
}

@keyframes grassWave {
  0%,
  100% {
    transform: rotate(var(--rot)) rotateY(var(--rotY));
  }
  50% {
    transform: rotate(calc(var(--rot) - 4deg)) rotateY(var(--rotY));
  }
}

.container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 80px;
  padding: 40px;
  min-height: 100vh;
  overflow: visible;
  position: relative;
  z-index: 2;
}

.timer-container {
  background: white;
  padding: 30px 40px;
  border-radius: 15px;
  box-shadow: 0 8px 30px rgba(255, 105, 180, 0.2);
  text-align: center;
  flex-shrink: 0;
  transition:
    background 2s ease,
    box-shadow 2s ease;
}

.timer-container.disabled {
  pointer-events: none;
  filter: grayscale(1) brightness(0.8);
}

.timer-container.withered {
  background: #f0f0f0;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
}

h1 {
  color: #ff69b4;
  font-size: 1.5em;
  margin-bottom: 20px;
  transition: color 2s ease;
}

h1.withered {
  color: #777777;
}

.countdown {
  display: flex;
  gap: 15px;
  justify-content: center;
  margin-bottom: 20px;
}

.time-unit {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: linear-gradient(135deg, #fff0f6, #ffe6f2);
  padding: 15px 12px;
  border-radius: 10px;
  min-width: 70px;
  box-shadow: 0 2px 8px rgba(255, 105, 180, 0.15);
  transition:
    background 2s ease,
    box-shadow 2s ease;
}

.time-unit.withered {
  background: linear-gradient(135deg, #e0e0e0, #d0d0d0);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.time-number {
  font-size: 2em;
  font-weight: bold;
  color: #ff1493;
  text-shadow: 2px 2px 4px rgba(255, 105, 180, 0.3);
  transition:
    color 2s ease,
    text-shadow 2s ease;
}

.time-number.withered {
  color: #666666;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.time-label {
  font-size: 0.7em;
  color: #ff69b4;
  margin-top: 5px;
  text-transform: uppercase;
  letter-spacing: 1px;
  transition: color 2s ease;
}

.time-label.withered {
  color: #888888;
}

.petals-info {
  color: #ff69b4;
  font-size: 0.95em;
  transition:
    color 2s ease,
    border-color 2s ease;
}

.petals-info.withered {
  color: #777777;
  border-top-color: #d0d0d0;
}

.music-player {
  margin-top: 20px;
  padding-top: 15px;
  border-top: 2px solid #ffe6f2;
  display: flex;
  flex-direction: column;
  gap: 12px;
  color: #ff4fa3;
  transition:
    color 2s ease,
    border-color 2s ease;
}

.music-player.withered {
  color: #777777;
  border-top-color: #d0d0d0;
}

.player-header {
  font-weight: bold;
  letter-spacing: 0.5px;
}

.player-controls {
  display: flex;
  justify-content: center;
  gap: 12px;
}

.player-btn {
  background: linear-gradient(135deg, #ffb6d9, #ff69b4);
  border: none;
  color: white;
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
  box-shadow: 0 4px 10px rgba(255, 105, 180, 0.3);
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

.player-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(255, 105, 180, 0.35);
}

.player-progress {
  display: grid;
  grid-template-columns: 46px 1fr 46px;
  gap: 10px;
  align-items: center;
  font-size: 0.85em;
}

.player-progress input[type="range"] {
  width: 100%;
}

.player-options {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.audio-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.audio-item {
  background: #ffe6f2;
  color: #ff4fa3;
  border: 1px solid rgba(255, 105, 180, 0.25);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.85em;
  cursor: pointer;
  transition: all 0.2s ease;
}

.audio-item:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 12px rgba(255, 105, 180, 0.2);
}

.audio-item.active {
  background: linear-gradient(135deg, #ffb6d9, #ff69b4);
  color: #fff;
}

.player-hint {
  font-size: 0.75em;
  color: #ff77b8;
}

.file-label {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 999px;
  background: #ffe6f2;
  color: #ff4fa3;
  font-size: 0.85em;
  cursor: pointer;
}

.file-label input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

#volume {
  flex: 1;
}

.flower-container {
  position: relative;
  width: 450px;
  height: 550px;
  flex-shrink: 0;
  overflow: visible;
}

.flower {
  position: absolute;
  width: 400px;
  height: 400px;
  top: -3rem;
  left: 50%;
  transform: translateX(-50%);
  animation: verticalSway 1.5s ease-in-out infinite;
}

.flower.withered {
  animation: none;
}

@keyframes verticalSway {
  0%,
  100% {
    transform: translateX(-50%) translateY(0);
  }
  50% {
    transform: translateX(-50%) translateY(-8px);
  }
}

.petal {
  position: absolute;
  background: linear-gradient(145deg, #ffb6d9, #ff1493);
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  top: 50%;
  left: 50%;
  transform-origin: center center;
  opacity: 1;
  transition: none; /* Remove background transition */
  box-shadow:
    0 4px 15px rgba(255, 20, 147, 0.4),
    inset 0 0 10px rgba(255, 255, 255, 0.3);
}

.petal.wilting {
  background: linear-gradient(145deg, #f4d03f, #d4af37) !important;
  box-shadow:
    0 4px 15px rgba(212, 175, 55, 0.4),
    inset 0 0 10px rgba(255, 255, 255, 0.3);
}

.petal.falling {
  background: linear-gradient(145deg, #f4d03f, #d4af37) !important;
  box-shadow:
    0 4px 15px rgba(212, 175, 55, 0.4),
    inset 0 0 10px rgba(255, 255, 255, 0.3);
  animation: fall 3s ease-in forwards;
  pointer-events: none; /* Prevent interaction during fall */
}

.petal.fallen {
  opacity: 0;
}

@keyframes fall {
  0% {
    opacity: 1;
  }
  30% {
    opacity: 0.8;
  }
  100% {
    transform: translate(-50%, -50%) translateY(200px) translateX(50px)
      rotate(720deg) scale(0.2);
    opacity: 0;
  }
}

.flower-center {
  position: absolute;
  width: 80px;
  height: 80px;
  background: radial-gradient(circle at 30% 30%, #fff59d, #ffd700, #ffb700);
  border-radius: 50%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 100;
  box-shadow:
    0 0 30px rgba(255, 215, 0, 0.6),
    inset 0 0 20px rgba(255, 255, 255, 0.5);
  transition:
    background 2s ease,
    box-shadow 2s ease;
}

.flower-center.withered {
  background: radial-gradient(circle at 30% 30%, #999999, #777777, #555555);
  box-shadow:
    0 0 30px rgba(0, 0, 0, 0.3),
    inset 0 0 20px rgba(255, 255, 255, 0.2);
}

.flower-center::before {
  content: "";
  position: absolute;
  width: 100%;
  height: 100%;
  background: radial-gradient(
    circle,
    transparent 40%,
    rgba(255, 140, 0, 0.3) 60%
  );
  border-radius: 50%;
  transition: background 2s ease;
}

.flower-center.withered::before {
  background: radial-gradient(circle, transparent 40%, rgba(0, 0, 0, 0.3) 60%);
}

.stem {
  position: absolute;
  width: 10px;
  height: 24rem;
  background: linear-gradient(to right, #2d5016, #4a7c2c, #2d5016);
  top: 14rem;
  left: 50%;
  transform: translateX(-50%);
  border-radius: 5px;
  z-index: -2;
  box-shadow: inset -2px 0 5px rgba(0, 0, 0, 0.3);
  transition: background 2s ease;
}

.stem.withered {
  background: linear-gradient(to right, #4a3a2a, #6b4423, #4a3a2a);
}

.leaf {
  position: absolute;
  z-index: -1;
  animation: leafSway 2s ease-in-out infinite;
  transition:
    opacity 2s ease,
    transform 2s ease;
}

.leaf.withered {
  animation: none;
  opacity: 0;
  transform: translateY(100px) rotate(45deg);
}

@keyframes leafSway {
  0%,
  100% {
    transform: rotate(0deg);
  }
  50% {
    transform: rotate(-8deg);
  }
}

.leaf::before {
  content: "";
  position: absolute;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #7cb342, #33691e);
  border-radius: 0 70% 70% 0;
  box-shadow:
    0 3px 10px rgba(0, 100, 0, 0.4),
    inset 2px 2px 8px rgba(255, 255, 255, 0.2);
}

.leaf.left {
  width: 55px;
  height: 90px;
  top: 24rem;
  left: calc(50% - 60px);
  transform-origin: right;
}

.leaf.left::before {
  transform: rotate(-25deg);
}

.leaf.right {
  width: 50px;
  height: 85px;
  top: 27rem;
  left: calc(50% + 5px);
  transform-origin: left center;
  animation-delay: 0.8s;
}

.leaf.right::before {
  transform: scaleX(-1) rotate(20deg);
}

.leaf.middle {
  width: 52px;
  height: 88px;
  top: 29rem;
  left: calc(50% - 50px);
  transform-origin: right center;
  animation-delay: 1.6s;
}

.leaf.middle::before {
  transform: rotate(-30deg);
}

/* Responsif untuk tablet */
@media (max-width: 1024px) {
  body {
    position: relative;
  }

  .grass-field {
    position: absolute;
    height: min(50vh, 420px);
  }

  .container {
    flex-direction: column;
    gap: 7rem;
    padding: 40px 20px;
    justify-content: flex-start;
    overflow: visible;
    padding-bottom: 80px;
  }

  .timer-container {
    width: 100%;
    max-width: 400px;
  }

  .flower-container {
    width: 100%;
    max-width: 400px;
    height: 500px;
    overflow: visible;
  }

  .flower {
    width: 350px;
    height: 350px;
  }

  .stem {
    height: 22rem;
    top: 240px;
    width: 14px;
  }

  .leaf.left {
    top: 345px;
    left: calc(50% - 55px);
  }

  .leaf.right {
    top: 395px;
    left: calc(50% + 12px);
  }

  .leaf.middle {
    top: 445px;
    left: calc(50% - 50px);
  }
}

/* Responsif untuk mobile */
@media (max-width: 640px) {
  .grass-field {
    height: min(55vh, 420px);
  }

  .container {
    padding: 30px 15px;
    gap: 5rem;
    overflow: visible;
    padding-bottom: 90px;
  }

  .timer-container {
    padding: 25px 30px;
    max-width: 100%;
  }

  h1 {
    font-size: 1.3em;
    margin-bottom: 15px;
  }

  .countdown {
    gap: 10px;
    flex-wrap: wrap;
  }

  .time-unit {
    min-width: 60px;
    padding: 12px 8px;
  }

  .time-number {
    font-size: 1.6em;
  }

  .time-label {
    font-size: 0.65em;
  }

  .petals-info {
    font-size: 0.85em;
  }

  .flower-container {
    width: 100%;
    max-width: 320px;
    height: 420px;
    margin: 5rem auto;
    overflow: visible;
  }

  .flower {
    width: 280px;
    height: 280px;
  }

  .flower-center {
    width: 65px;
    height: 65px;
  }

  .stem {
    height: 20rem;
    top: 240px;
    width: 14px;
  }

  .leaf.left {
    width: 45px;
    height: 75px;
    top: 20rem;
    left: calc(50% - 48px);
  }

  .leaf.right {
    width: 42px;
    height: 70px;
    top: 24rem;
    left: calc(50% + 5px);
  }

  .leaf.middle {
    width: 44px;
    height: 73px;
    top: 25rem;
    left: calc(50% - 46px);
  }
}

@media (min-width: 1025px) {
  body {
    height: 100vh;
    overflow: hidden;
  }

  .container {
    height: 100vh;
    padding-bottom: 0;
  }

  .flower-container {
    height: min(520px, calc(100vh - 180px));
  }
}
