/* =========================
   Base layout
   ========================= */
html, body {
  height: 100%;
  margin: 0;
}

body {
  background:radial-gradient(
      circle at center,
      #1a0f0a 0%,
      #0b0b0b 65%
    );
  display: grid;
  place-items: center;
}

body { min-height: 100vh; }

.game {
  width: 100vw;
  height: 100vh;
  display: grid;
  place-items: center;
}

/* =========================
   Scene (table background)
   Table image is 1536x1024 => aspect-ratio: 3 / 2
   ========================= */
.scene {
  position: relative;
  width: min(1400px, 98vw);
  aspect-ratio: 3 / 2;
  background: url("Assets/Table.png") center / cover no-repeat;

  image-rendering: pixelated;

  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  border-radius: 12px;
  overflow: hidden;
}

/* Crisp pixel art */
.scene img {
  image-rendering: pixelated;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}

/* =========================
   Props (interactive items)
   ========================= */
.prop {
  position: absolute;
  height: auto;
  z-index: 2;

  transform-origin: center;
  cursor: pointer;
  pointer-events: auto;

  transition: transform 140ms ease, filter 140ms ease;
}

.prop:hover {
  transform: scale(1.04);
  filter:
    brightness(1.08)
    drop-shadow(0 0 10px rgba(255, 200, 120, 0.35))
    drop-shadow(0 0 24px rgba(255, 160, 90, 0.18));
}

.prop:active {
  transform: scale(1.01);
  filter: brightness(1.02);
}

/* Candle is decorative */
.candle {
  width: 11%;
  left: 86%;
  top: 2%;

  z-index: 1;
  cursor: default;
  pointer-events: none;
  filter: none;
  transform: none;
}

/* =========================
   Prop placement + sizing
   Use % for stable responsive layout
   ========================= */
.ornament {
  width: 18%;
  left: 51%;
  top: 58%;
}

.badminton {
  width: 38%;
  left: 26%;
  top: 8%;
}

.cookie {
  width: 30%;
  left: 7%;
  top: 62%;
}

/* Letter wrapper takes the letter's position */
.letterWrap {
  position: relative;  /* IMPORTANT: anchor lock + counter to the wrapper */
  width: 30%;
  left: 68%;
  top: 26%;
  z-index: 2;
}

.letterSprite {
  width: 100%;
  height: auto;
  display: block;
  image-rendering: pixelated;
}

/* Lock overlay image on top of the letter */
.letterLock {
  position: absolute;
  inset: 0;
  width: 100%;
  height: auto;
  z-index: 3;
  pointer-events: none;
  image-rendering: pixelated;
}

/* Counter on the blank square plate */
.lockCounter {
  position: absolute;
  z-index: 4;
  pointer-events: none;

  left: 49%;
  top: 67%;
  transform: translate(-50%, -50%);

  width: 35%;
  height: 70%;
  display: grid;
  place-items: center;

  font-family: "Pixelify Sans", sans-serif;
  font-size: clamp(16px, 2vw, 22px);
  color: black;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
}

/* Locked: disable hover glow/scale on the wrapper */
.letterWrap.locked {
  cursor: default;
}

.letterWrap.locked:hover {
  transform: none;
  filter: none;
}

/* Shake on decrement */
.letterWrap.shake {
  animation: shake 220ms ease-in-out;
}

@keyframes shake {
  0%   { transform: translateX(0) rotate(0deg); }
  25%  { transform: translateX(-1.2%) rotate(-0.5deg); }
  50%  { transform: translateX(1.2%) rotate(0.5deg); }
  75%  { transform: translateX(-0.8%) rotate(-0.35deg); }
  100% { transform: translateX(0) rotate(0deg); }
}

/* Unlock fade: separate animations to avoid jumping */
.letterWrap.unlocking .letterLock {
  animation: lockFade 650ms ease forwards;
}

.letterWrap.unlocking .lockCounter {
  animation: counterFade 650ms ease forwards;
}

@keyframes lockFade {
  to { opacity: 0; transform: scale(0.98); }
}

@keyframes counterFade {
  to { opacity: 0; transform: translate(-50%, -50%) scale(0.98); }
}

/* After unlock, allow normal hover glow */
.letterWrap.unlocked {
  cursor: pointer;
}

.lavender {
  width: 24%;
  left: 76%;
  top: 64%;
}

/* =========================
   Note modal
   ========================= */
.noteOverlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;

  background: rgba(0, 0, 0, 0.35);
  z-index: 50;
}

.noteOverlay.hidden {
  display: none;
  pointer-events: none;
}

.noteWrap {
  position: relative;
  width: min(520px, 70%);
  transform: translateY(-2%);
}

.noteImg {
  width: 100%;
  height: auto;
  image-rendering: pixelated;
  filter: drop-shadow(0 20px 50px rgba(0, 0, 0, 0.45));
}

/* Text on the note */
.noteText {
  position: absolute;
  left: 12%;
  top: 18%;
  width: 76%;
  height: 68%;

  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;

  font-family: "Pixelify Sans", sans-serif;
  font-size: clamp(16px, 2vw, 22px);
  line-height: 1.4;

  color: #3a2316;
  text-shadow:
    0 1px 0 rgba(255, 255, 255, 0.4),
    0 0 2px rgba(0, 0, 0, 0.15);

  padding: 0 4%;
  box-sizing: border-box;
}

/* Close hotspot (X) */
.noteClose {
  position: absolute;
  top: 6%;
  right: 10.5%;
  width: 22%;
  height: 17%;

  background: transparent;
  border: 0;
  cursor: pointer;
  z-index: 3;
}

/* Focused glow ONLY around the X */
.noteClose::before {
  content: "";
  position: absolute;
  inset: -12%;
  border-radius: 50%;

  background: radial-gradient(
    circle,
    rgba(255, 200, 120, 0.55) 0%,
    rgba(255, 160, 90, 0.35) 40%,
    rgba(255, 160, 90, 0.0) 70%
  );

  opacity: 0;
  transform: scale(0.85);
  transition: opacity 120ms ease, transform 120ms ease;
  pointer-events: none;
}

.noteClose:hover::before {
  opacity: 1;
  transform: scale(1.15);
}

.noteClose:active::before {
  transform: scale(1.05);
}

/* =========================
   Debug (optional)
   ========================= */
/*
.prop {
  outline: 1px solid rgba(255, 0, 0, 0.25);
}
*/

/* =========================
   Loading screen
   ========================= */
.loading {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at center, #1a0f0a 0%, #0b0b0b 70%);
}

.loading.hidden {
  display: none;
}

.loadingCard {
  width: min(520px, 86vw);
  padding: 22px 24px;
  border-radius: 18px;
  background: rgba(255, 245, 235, 0.08);
  border: 1px solid rgba(255, 200, 120, 0.18);
  box-shadow: 0 20px 60px rgba(0,0,0,0.55);
  text-align: center;
  backdrop-filter: blur(8px);
}

.loadingTitle {
  font-family: "Pixelify Sans", sans-serif;
  font-size: 32px;
  color: rgba(255, 235, 210, 0.95);
  text-shadow: 0 2px 0 rgba(0,0,0,0.35);
}

.loadingSub {
  margin-top: 6px;
  font-family: "Pixelify Sans", sans-serif;
  font-size: 16px;
  color: rgba(255, 220, 190, 0.8);
}

.loadingDots {
  margin-top: 16px;
  display: inline-flex;
  gap: 10px;
}

.loadingDots span {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 200, 120, 0.7);
  box-shadow: 0 0 14px rgba(255, 160, 90, 0.25);
  animation: dot 1.1s infinite ease-in-out;
}

.loadingDots span:nth-child(2) { animation-delay: 0.15s; }
.loadingDots span:nth-child(3) { animation-delay: 0.30s; }

@keyframes dot {
  0%, 100% { transform: translateY(0); opacity: 0.55; }
  50% { transform: translateY(-6px); opacity: 1; }
}

.musicbox {
  width: 18%;
  left: 4%;
  top: 28%;
}

.musicbox.on {
  animation: musicPulse 1.6s ease-in-out infinite;
}

@keyframes musicPulse {
  0%, 100% { filter: brightness(1.02); }
  50% { filter: brightness(1.10); }
}

/* =========================
   Start Screen
   ========================= */
.startScreen {
  position: fixed;
  inset: 0;
  z-index: 90; /* below loading, above game */
  display: grid;
  place-items: center;
  background: #0b0b0b;
  transition: opacity 420ms ease;
}

.startScreen.hidden {
  display: none;
}

.startScene {
  position: relative;
  width: min(1400px, 98vw);
  aspect-ratio: 3 / 2;
}

/* Background */
.startBg {
  width: 100%;
  height: auto;
  image-rendering: pixelated;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.45);
}

/* Title */
.startTitle {
  position: absolute;
  top: 14%;
  left: 50%;
  transform: translateX(-50%);
  width: 65%;
  image-rendering: pixelated;
}

/* Start button */
.startButton {
  position: absolute;
  top: 62%;
  left: 50%;
  transform: translateX(-50%);
  width: 28%;
  image-rendering: pixelated;
  cursor: pointer;

  animation: float 2.6s ease-in-out infinite;
  transition: transform 120ms ease, filter 120ms ease;
}

.startButton:hover {
  transform: translateX(-50%) scale(1.06);
  filter:
    brightness(1.1)
    drop-shadow(0 0 14px rgba(255,200,120,0.45));
}

@keyframes float {
  0%, 100% { transform: translate(-50%, 0); }
  50% { transform: translate(-50%, -8px); }
}
