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

html, body {
  height: 100%;
  background: #0b1410;
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overflow: hidden;
}

/* ---------- Scene (fullscreen) ---------- */
.scene {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

.scene .bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.9s ease;
  pointer-events: none;
  user-select: none;
}

.scene.state-rain #bgRain { opacity: 1; }
.scene.state-ready #bgReady { opacity: 1; }
.scene.state-success #bgSuccess { opacity: 1; }

/* ---------- Rain ---------- */
.rain-layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.6s ease;
  z-index: 2;
}

.scene.state-rain .rain-layer { opacity: 1; }

.drop {
  position: absolute;
  top: -12%;
  width: 2px;
  height: 40px;
  background: linear-gradient(to bottom, rgba(220,235,255,0), rgba(220,235,255,0.65));
  animation: fall linear infinite;
}

@keyframes fall {
  to { transform: translateY(135vh); }
}

/* ---------- Eyes ---------- */
/* left/top/width/height are computed and set by script.js so the pupil
   stays aligned with Totoro's eye socket even when the background image
   is cropped by object-fit: cover at different viewport ratios. */
.eye {
  position: fixed;
  z-index: 3;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.pupil {
  width: 100%;
  height: 100%;
  object-fit: contain;
  will-change: transform;
  transition: transform 0.08s linear;
}

/* hide the animated eyes once Totoro's expression already changed (smile frame) */
.scene.state-success .eye { opacity: 0; transition: opacity 0.4s ease; }

/* ---------- Leaves following the cursor ---------- */
.leaf-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
}

.leaf {
  position: absolute;
  top: 0;
  left: 0;
  will-change: transform, opacity;
  animation: leafFade 0.9s ease-out forwards;
}

@keyframes leafFade {
  0%   { opacity: 0.9; transform: translate(var(--tx), var(--ty)) scale(1) rotate(var(--rot)); }
  100% { opacity: 0;   transform: translate(calc(var(--tx) + var(--dx)), calc(var(--ty) + var(--dy))) scale(0.6) rotate(calc(var(--rot) + 40deg)); }
}

/* ---------- Login card (left side, doesn't cover the child + Totoro) ---------- */
.login-card {
  position: absolute;
  left: 4%;
  top: 50%;
  transform: translateY(-50%);
  width: min(32%, 420px);
  min-width: 300px;
  background: rgba(10, 22, 16, 0.62);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  padding: 5% 5.5%;
  color: #eef4ee;
  z-index: 4;
}

.login-card h1 {
  font-size: clamp(1.2rem, 2.2vw, 1.6rem);
  margin-bottom: 4px;
}

.login-card .subtitle {
  font-size: clamp(0.75rem, 1.2vw, 0.9rem);
  opacity: 0.75;
  margin-bottom: 16px;
}

.login-card label {
  display: block;
  font-size: clamp(0.7rem, 1.1vw, 0.82rem);
  opacity: 0.85;
  margin-bottom: 4px;
  margin-top: 10px;
}

.login-card input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.92);
  font-size: clamp(0.8rem, 1.2vw, 0.92rem);
  outline: none;
}

.login-card input:focus {
  border-color: #6fcf97;
  box-shadow: 0 0 0 2px rgba(111,207,151,0.35);
}

.login-card button {
  width: 100%;
  margin-top: 16px;
  padding: 9px 10px;
  border: none;
  border-radius: 8px;
  background: #3a7d55;
  color: white;
  font-weight: 600;
  font-size: clamp(0.82rem, 1.2vw, 0.95rem);
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease;
}

.login-card button:hover { background: #4a9c6a; }
.login-card button:active { transform: scale(0.97); }

.error-msg {
  min-height: 1.2em;
  margin-top: 10px;
  font-size: clamp(0.62rem, 1.1vw, 0.75rem);
  color: #ff9b9b;
}

.shake { animation: shake 0.35s; }
@keyframes shake {
  0%, 100% { transform: translateY(-50%) translateX(0); }
  25% { transform: translateY(-50%) translateX(-6px); }
  75% { transform: translateY(-50%) translateX(6px); }
}

.success-msg {
  display: none;
  margin-top: 14px;
  font-size: clamp(0.7rem, 1.2vw, 0.85rem);
  color: #9be8ac;
  font-weight: 600;
}

.scene.state-success .login-card form { display: none; }
.scene.state-success .login-card .success-msg { display: block; }

@media (max-width: 640px) {
  .login-card {
    left: 50%;
    top: 6%;
    transform: translate(-50%, 0);
    width: 90%;
  }
  .shake { animation: none; }
}
