/* =========================================================
   משחק התליה — מצוות האישה
   Theme rose poudré + or, conçu pour bat mitsva
   ========================================================= */

:root {
  --bg-1: #fdf3f6;
  --bg-2: #fce0ea;
  --bg-3: #f9d3e0;
  --rose-soft: #f7cad8;
  --rose: #e8a4be;
  --rose-deep: #c76b8e;
  --rose-text: #6b3148;
  --gold-light: #f6dca0;
  --gold: #d4a574;
  --gold-deep: #a87439;
  --cream: #fff8ee;
  --ink: #4a2233;
  --success: #6ba37c;
  --success-bg: #e7f5ec;
  --error: #c96b6b;
  --error-bg: #fbe8e8;
  --shadow: 0 8px 24px rgba(199, 107, 142, 0.18);
  --shadow-strong: 0 12px 32px rgba(168, 116, 57, 0.25);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: "Heebo", "Frank Ruhl Libre", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(ellipse at top right, var(--bg-3) 0%, transparent 50%),
    radial-gradient(ellipse at bottom left, var(--bg-2) 0%, transparent 55%),
    linear-gradient(180deg, var(--bg-1) 0%, #fff8fa 100%);
  background-attachment: fixed;
  direction: rtl;
}

/* déco fond */
.bg-deco { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.bg-deco .corner { position: absolute; width: 220px; height: 220px; opacity: 0.55; }
.corner-tr { top: -30px; right: -30px; transform: rotate(15deg); }
.corner-bl { bottom: -30px; left: -30px; transform: rotate(195deg); }

.game {
  position: relative;
  z-index: 1;
  max-width: 980px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

/* ---------- header ---------- */
.game-header {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 4px;
  text-align: center;
  margin-bottom: 24px;
  position: relative;
}
.game-title {
  font-family: "Suez One", "Frank Ruhl Libre", serif;
  font-size: clamp(2rem, 5.5vw, 3.4rem);
  margin: 0;
  background: linear-gradient(180deg, var(--gold-light) 0%, var(--gold) 45%, var(--gold-deep) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 2px 0 rgba(255,255,255,0.6);
  letter-spacing: 0.5px;
}
.game-subtitle {
  font-family: "Frank Ruhl Libre", serif;
  font-weight: 500;
  font-size: clamp(0.95rem, 2.2vw, 1.25rem);
  color: var(--rose-deep);
  margin: 4px 0 0;
}
.header-deco {
  position: absolute;
  font-size: 1.8rem;
  color: var(--rose);
  top: 6px;
  opacity: 0.7;
}
.header-deco-right { right: 8px; }
.header-deco-left  { left: 8px; }

/* ---------- board ---------- */
.game-board {
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(8px);
  border: 1.5px solid var(--rose-soft);
  border-radius: 24px;
  padding: 24px 22px 22px;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: minmax(220px, 280px) 1fr;
  grid-template-areas:
    "rose word"
    "rose keyboard"
    "bin  bin";
  gap: 22px;
}

@media (max-width: 760px) {
  .game-board {
    grid-template-columns: 1fr;
    grid-template-areas:
      "rose"
      "word"
      "keyboard"
      "bin";
    padding: 18px 14px 16px;
  }
}

/* ---------- rose stage ---------- */
.rose-stage {
  grid-area: rose;
  background: linear-gradient(160deg, #fff7fb 0%, #fce7f0 100%);
  border-radius: 18px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--rose-soft);
  position: relative;
}
.rose { width: 100%; max-width: 220px; height: auto; display: block; }

.petals { transform-origin: 110px 110px; }
.petal {
  transform-origin: 110px 110px;
  transform: rotate(var(--angle));
  transition: opacity 0.6s ease;
}
.petal.fallen {
  animation: fallPetal 1.1s cubic-bezier(.46,.07,.4,1) forwards;
}
@keyframes fallPetal {
  0%   { opacity: 1; transform: rotate(var(--angle)) translateY(0) scale(1); }
  35%  { opacity: 1; transform: rotate(var(--angle)) translateY(20px) rotate(-15deg) scale(1.02); }
  100% {
    opacity: 0;
    transform: rotate(var(--angle)) translate(calc(var(--drift, 30px)), 220px) rotate(360deg) scale(0.6);
  }
}

.lives-counter {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-family: "Suez One", serif;
}
#livesLeft {
  font-size: 1.9rem;
  color: var(--gold-deep);
  line-height: 1;
}
.lives-label {
  font-family: "Heebo", sans-serif;
  font-size: 0.85rem;
  color: var(--rose-deep);
  margin-top: 2px;
  font-weight: 400;
}

/* ---------- word zone ---------- */
.word-zone {
  grid-area: word;
  text-align: center;
  padding: 8px 4px 0;
}
.category {
  display: inline-block;
  background: linear-gradient(180deg, #fff 0%, var(--rose-soft) 100%);
  color: var(--rose-deep);
  font-size: 0.85rem;
  font-weight: 700;
  padding: 4px 14px;
  border-radius: 999px;
  border: 1px solid var(--rose);
  margin-bottom: 8px;
}
.hint {
  color: var(--rose-text);
  font-size: 1rem;
  margin-bottom: 14px;
  min-height: 1.4em;
}
.word {
  font-family: "Frank Ruhl Libre", serif;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 10px;
  font-size: clamp(1.7rem, 4.5vw, 2.6rem);
  font-weight: 700;
  direction: rtl;
  unicode-bidi: isolate;
}
.letter-slot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.4em;
  height: 1.7em;
  padding: 0 0.15em;
  border-bottom: 3px solid var(--gold);
  color: var(--gold-deep);
  background: linear-gradient(180deg, transparent 70%, rgba(212,165,116,0.08) 100%);
  border-radius: 4px 4px 0 0;
  position: relative;
  perspective: 600px;
}
.letter-slot.space { border-bottom: none; min-width: 0.6em; }
.letter-slot.revealed {
  animation: revealLetter 0.7s ease forwards;
}
@keyframes revealLetter {
  0%   { transform: rotateY(0deg); color: transparent; }
  50%  { transform: rotateY(180deg); color: transparent; }
  51%  { transform: rotateY(0deg); }
  100% { transform: rotateY(0deg); color: var(--gold-deep); text-shadow: 0 0 14px rgba(244,201,125,0.7); }
}
.letter-slot.revealed::after {
  content: "✿";
  position: absolute;
  top: -8px;
  font-size: 0.5em;
  color: var(--rose);
  opacity: 0;
  animation: sparkle 1.2s ease 0.2s forwards;
}
@keyframes sparkle {
  0%   { opacity: 0; transform: translateY(0) scale(0.5); }
  40%  { opacity: 1; transform: translateY(-6px) scale(1.2); }
  100% { opacity: 0; transform: translateY(-18px) scale(0.4); }
}

/* ---------- keyboard ---------- */
.keyboard {
  grid-area: keyboard;
  display: grid;
  grid-template-columns: repeat(11, 1fr);
  gap: 6px;
  padding: 6px 2px 0;
  direction: rtl;
}
@media (max-width: 480px) {
  .keyboard { grid-template-columns: repeat(8, 1fr); gap: 5px; }
}

.key {
  font-family: "Frank Ruhl Libre", serif;
  font-size: clamp(1.1rem, 3vw, 1.5rem);
  font-weight: 700;
  color: var(--rose-text);
  background: linear-gradient(180deg, #fff 0%, #fff1f6 100%);
  border: 1.5px solid var(--rose-soft);
  border-radius: 12px;
  padding: 10px 0;
  cursor: pointer;
  transition: all 0.18s ease;
  box-shadow: 0 2px 0 var(--rose-soft);
  user-select: none;
}
.key:hover:not(:disabled) {
  background: linear-gradient(180deg, var(--gold-light) 0%, var(--gold) 100%);
  color: #fff;
  border-color: var(--gold);
  transform: translateY(-1px);
  box-shadow: 0 4px 0 var(--gold-deep);
}
.key:active:not(:disabled) { transform: translateY(1px); box-shadow: 0 1px 0 var(--gold-deep); }

.key.correct {
  background: linear-gradient(180deg, var(--success-bg) 0%, #c8e6cf 100%);
  color: var(--success);
  border-color: var(--success);
  box-shadow: 0 2px 0 var(--success);
  cursor: default;
  animation: pulseCorrect 0.5s ease;
}
.key.wrong {
  background: var(--error-bg);
  color: var(--error);
  border-color: var(--error);
  box-shadow: 0 2px 0 var(--error);
  cursor: default;
  opacity: 0.75;
  text-decoration: line-through;
  animation: shake 0.45s ease;
}
.key:disabled { cursor: default; pointer-events: none; }

@keyframes pulseCorrect {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.18); box-shadow: 0 0 18px rgba(107,163,124,0.5); }
  100% { transform: scale(1); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-4px); }
  40%, 80% { transform: translateX(4px); }
}

/* ---------- bin (poubelle / סל) ---------- */
.used-bin {
  grid-area: bin;
  background: linear-gradient(180deg, #fff8fb 0%, #fce7f0 100%);
  border: 1.5px dashed var(--rose);
  border-radius: 16px;
  padding: 12px 14px;
  min-height: 70px;
}
.bin-title {
  font-family: "Suez One", serif;
  color: var(--rose-deep);
  font-size: 1rem;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.bin-title::before { content: "🌸"; font-size: 1.1rem; }
.bin-content {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  direction: rtl;
}
.bin-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  font-family: "Frank Ruhl Libre", serif;
  font-size: 1.2rem;
  font-weight: 700;
  border: 1.2px solid;
  position: relative;
  animation: dropIn 0.45s ease;
}
@keyframes dropIn {
  0%   { transform: translateY(-12px) scale(0.7); opacity: 0; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}
.bin-letter.correct {
  background: var(--success-bg);
  color: var(--success);
  border-color: var(--success);
}
.bin-letter.correct::before {
  content: "✓";
  position: absolute;
  top: -6px;
  left: -6px;
  font-size: 0.7rem;
  background: var(--success);
  color: #fff;
  border-radius: 50%;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.bin-letter.wrong {
  background: var(--error-bg);
  color: var(--error);
  border-color: var(--error);
  text-decoration: line-through;
}
.bin-letter.wrong::before {
  content: "✗";
  position: absolute;
  top: -6px;
  right: -6px;
  font-size: 0.7rem;
  background: var(--error);
  color: #fff;
  border-radius: 50%;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- footer / buttons ---------- */
.game-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 18px;
  margin-top: 18px;
  flex-wrap: wrap;
}
.btn-restart {
  font-family: "Heebo", sans-serif;
  font-weight: 700;
  font-size: 1rem;
  color: #fff;
  background: linear-gradient(180deg, var(--rose) 0%, var(--rose-deep) 100%);
  border: none;
  border-radius: 14px;
  padding: 12px 24px;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--rose-deep);
  transition: all 0.18s ease;
}
.btn-restart:hover { transform: translateY(-1px); box-shadow: 0 5px 0 var(--rose-deep); }
.btn-restart:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--rose-deep); }
.btn-restart.big { font-size: 1.2rem; padding: 14px 32px; }

.admin-link {
  color: var(--rose-deep);
  text-decoration: none;
  font-size: 0.9rem;
  border-bottom: 1px dashed var(--rose);
  padding-bottom: 2px;
}
.admin-link:hover { color: var(--gold-deep); border-color: var(--gold); }

.btn-mute {
  font-size: 1.4rem;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1.5px solid var(--rose);
  background: linear-gradient(180deg, #fff 0%, #fff1f6 100%);
  cursor: pointer;
  box-shadow: 0 3px 0 var(--rose-soft);
  transition: all 0.18s ease;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-mute:hover { transform: translateY(-1px); background: linear-gradient(180deg, var(--gold-light), var(--gold)); border-color: var(--gold); }
.btn-mute:active { transform: translateY(1px); box-shadow: 0 1px 0 var(--rose-soft); }
.btn-mute.muted { opacity: 0.55; filter: grayscale(0.4); }

/* ---------- overlay ---------- */
.overlay {
  position: fixed; inset: 0;
  background: rgba(108, 49, 72, 0.45);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  animation: fadeIn 0.35s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.overlay[hidden] { display: none; }
.overlay-card {
  background: linear-gradient(180deg, #fff 0%, #fff5f9 100%);
  border: 2px solid var(--gold);
  border-radius: 22px;
  padding: 28px 36px;
  text-align: center;
  max-width: 460px;
  width: calc(100% - 32px);
  box-shadow: var(--shadow-strong);
  animation: popIn 0.4s cubic-bezier(.34,1.56,.64,1);
}
@keyframes popIn { from { transform: scale(0.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.overlay-icon { font-size: 3.4rem; margin-bottom: 6px; }
.overlay-title {
  font-family: "Suez One", serif;
  margin: 0 0 8px;
  font-size: 2rem;
  background: linear-gradient(180deg, var(--gold-light) 0%, var(--gold-deep) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.overlay-text {
  color: var(--rose-text);
  font-size: 1.05rem;
  margin: 0 0 10px;
}
.overlay-word {
  font-family: "Frank Ruhl Libre", serif;
  font-size: 1.8rem;
  color: var(--gold-deep);
  margin: 8px 0 18px;
  font-weight: 700;
  letter-spacing: 1px;
}

/* ---------- confettis ---------- */
.confetti-layer {
  position: fixed; inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 11;
}
.confetto {
  position: absolute;
  top: -20px;
  width: 10px;
  height: 14px;
  border-radius: 2px;
  animation: confettiFall linear forwards;
}
@keyframes confettiFall {
  0%   { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(110vh) rotate(720deg); opacity: 0.8; }
}
