/* ==========================================================================
   Animals & Habitats Lesson — shared game UI styles.
   Built on top of styles.css (which provides typography, colour vars, and
   habitat gradient classes).
   ========================================================================== */

/* ---------- Page chrome shared by every game ---------- */
.game-page {
  min-height: 100vh;
  background:
    radial-gradient(circle at 10% 10%, #ffe9a8 0%, transparent 45%),
    radial-gradient(circle at 90% 20%, #ffc0b1 0%, transparent 45%),
    linear-gradient(180deg, #fff8ec 0%, #fff8ec 100%);
  padding: 16px 16px 80px;
}

.game-bar {
  max-width: 1100px;
  margin: 0 auto 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.game-bar h1 {
  font-family: var(--font-display);
  font-size: 1.6rem;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.game-bar .nav-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: white;
  color: var(--ink);
  border: none;
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 999px;
  text-decoration: none;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 12px 24px rgba(43,33,64,0.2); }
.btn:active { transform: translateY(0); }

.btn-primary { background: var(--accent); color: white; }
.btn-dark    { background: var(--ink); color: white; }
.btn-ghost   { background: rgba(255,255,255,0.7); }
.btn-ok      { background: var(--ok); color: white; }

.score-strip {
  background: white;
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 10px 16px;
  display: flex;
  gap: 18px;
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--ink);
  font-size: 0.95rem;
  flex-wrap: wrap;
}

.score-strip .stat strong {
  color: var(--accent);
  font-size: 1.05rem;
}

/* ---------- Game stage / panel ---------- */
.stage {
  max-width: 1100px;
  margin: 0 auto;
  background: white;
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.stage h2 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  margin-bottom: 12px;
}

.stage p { color: var(--ink-soft); }

.stage .help-text {
  font-size: 0.95rem;
  color: var(--ink-soft);
  margin-bottom: 16px;
}

/* ---------- Difficulty / start screens ---------- */
.start-screen {
  text-align: center;
  padding: 24px 16px;
}

.start-screen h2 {
  font-size: 1.8rem;
  margin-bottom: 6px;
}

.start-screen p { margin-bottom: 22px; }

.difficulty-row {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.difficulty-row .btn {
  font-size: 1.05rem;
  padding: 14px 24px;
}

/* ==========================================================================
   GAME: Memory Match
   ========================================================================== */

.memory-board {
  display: grid;
  gap: 12px;
  margin: 0 auto;
}

.memory-board.grid-12 { grid-template-columns: repeat(4, minmax(0, 1fr)); max-width: 720px; }
.memory-board.grid-16 { grid-template-columns: repeat(4, minmax(0, 1fr)); max-width: 760px; }
.memory-board.grid-20 { grid-template-columns: repeat(5, minmax(0, 1fr)); max-width: 900px; }

@media (max-width: 600px) {
  .memory-board.grid-12,
  .memory-board.grid-16,
  .memory-board.grid-20 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.memory-card {
  aspect-ratio: 3 / 4;
  perspective: 800px;
  cursor: pointer;
}

.memory-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.4s ease;
  transform-style: preserve-3d;
}

.memory-card.flipped .memory-card-inner,
.memory-card.matched .memory-card-inner {
  transform: rotateY(180deg);
}

.memory-card-face {
  position: absolute;
  inset: 0;
  border-radius: 14px;
  backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px;
  text-align: center;
  font-family: var(--font-display);
  box-shadow: 0 4px 10px rgba(43,33,64,0.15);
}

.memory-card-back {
  background: linear-gradient(135deg, var(--accent), #ffb074);
  color: white;
  font-size: 2rem;
}

.memory-card-back::after {
  content: '?';
  font-size: 3rem;
  font-weight: 700;
}

.memory-card-front {
  transform: rotateY(180deg);
  background: white;
  color: var(--ink);
  font-size: 0.85rem;
  border: 3px solid #eee;
}

.memory-card-front .big-emoji {
  font-size: 2.4rem;
  line-height: 1;
  margin-bottom: 6px;
}

.memory-card-front .label {
  font-weight: 600;
  font-size: 0.85rem;
  line-height: 1.15;
}

.memory-card.type-animal .memory-card-front  { border-color: #ffb074; }
.memory-card.type-habitat .memory-card-front { border-color: #6fc5e0; }

.memory-card.type-animal .memory-card-front  .tag { color: #e15c2a; }
.memory-card.type-habitat .memory-card-front .tag { color: #2680a8; }

.memory-card-front .tag {
  font-size: 0.65rem;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.memory-card.matched .memory-card-front {
  background: #e5f7f0;
  border-color: var(--ok);
  animation: pop 0.35s ease;
}

@keyframes pop {
  0%   { transform: rotateY(180deg) scale(1); }
  50%  { transform: rotateY(180deg) scale(1.07); }
  100% { transform: rotateY(180deg) scale(1); }
}

/* ==========================================================================
   GAME: Who Am I?
   ========================================================================== */

.whoami-clues {
  background: linear-gradient(135deg, #fff4e4, #ffe5cc);
  border-radius: 18px;
  padding: 20px 24px;
  margin-bottom: 22px;
  border: 3px dashed var(--accent);
}

.whoami-clues h3 {
  font-family: var(--font-display);
  color: var(--accent);
  margin-bottom: 10px;
  font-size: 1.05rem;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.whoami-clues ul { list-style: none; padding: 0; margin: 0; }

.whoami-clues li {
  padding: 8px 0 8px 30px;
  position: relative;
  font-size: 1.05rem;
}

.whoami-clues li::before {
  content: '🔍';
  position: absolute;
  left: 0;
  top: 8px;
}

.whoami-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.whoami-option {
  background: white;
  border: 3px solid transparent;
  border-radius: 16px;
  padding: 16px 8px;
  text-align: center;
  cursor: pointer;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.95rem;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.whoami-option:hover { transform: translateY(-3px); border-color: var(--accent-2); }

.whoami-option .emoji { display: block; font-size: 2.4rem; margin-bottom: 4px; }

.whoami-option.correct {
  background: #e5f7f0;
  border-color: var(--ok);
  animation: pop2 0.35s ease;
}
.whoami-option.wrong {
  border-color: #e15c2a;
  animation: shake 0.4s ease;
}
.whoami-option.disabled {
  opacity: 0.5;
  pointer-events: none;
}

@keyframes pop2 {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.12); }
  100% { transform: scale(1); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%      { transform: translateX(-6px); }
  40%      { transform: translateX(6px); }
  60%      { transform: translateX(-4px); }
  80%      { transform: translateX(4px); }
}

.next-row {
  display: flex;
  justify-content: center;
  margin-top: 20px;
}

/* ==========================================================================
   GAME: Empathy Hero
   ========================================================================== */

.empathy-scene {
  background: linear-gradient(135deg, #ddf3ea, #ffeed6);
  border-radius: 18px;
  padding: 24px;
  margin-bottom: 18px;
  text-align: center;
}

.empathy-emoji {
  font-size: 4rem;
  line-height: 1;
  margin-bottom: 6px;
}

.empathy-scene-text {
  font-size: 1.1rem;
  color: var(--ink);
  max-width: 640px;
  margin: 0 auto;
}

.empathy-question {
  font-family: var(--font-display);
  font-size: 1.25rem;
  text-align: center;
  margin: 6px 0 18px;
  color: var(--ink);
}

.empathy-choices {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.empathy-choice {
  background: white;
  border: 3px solid #eee;
  border-radius: 14px;
  padding: 14px 18px;
  font-family: var(--font-body);
  font-size: 1rem;
  text-align: left;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
  color: var(--ink);
}

.empathy-choice:hover { transform: translateY(-2px); border-color: var(--accent-2); }

.empathy-choice.correct   { background: #e5f7f0; border-color: var(--ok); }
.empathy-choice.incorrect { background: #fff0eb; border-color: #e15c2a; }
.empathy-choice.disabled  { pointer-events: none; opacity: 0.7; }

.empathy-feedback {
  margin-top: 16px;
  padding: 14px 18px;
  border-radius: 14px;
  font-size: 1rem;
  border-left: 5px solid var(--ok);
  background: #e5f7f0;
  color: var(--ink);
}

.empathy-feedback.bad {
  border-left-color: #e15c2a;
  background: #fff0eb;
}

.badge-row {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 6px;
  margin-top: 18px;
}

@media (max-width: 600px) {
  .badge-row { grid-template-columns: repeat(5, 1fr); }
}

.badge-slot {
  aspect-ratio: 1 / 1;
  background: #f1ebde;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  filter: grayscale(100%) opacity(0.4);
  border: 3px solid transparent;
  transition: all 0.3s ease;
}

.badge-slot.earned {
  filter: none;
  background: linear-gradient(135deg, #ffe68a, #ffd166);
  border-color: var(--accent);
  animation: pop2 0.4s ease;
}

/* ==========================================================================
   GAME: Diorama Builder
   ========================================================================== */

.builder-shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 16px;
  max-width: 1200px;
  margin: 0 auto;
}

@media (max-width: 800px) {
  .builder-shell { grid-template-columns: 1fr; }
}

.toolbox {
  background: white;
  border-radius: 18px;
  padding: 14px;
  box-shadow: var(--shadow);
  max-height: 70vh;
  overflow-y: auto;
}

.toolbox h3 {
  font-family: var(--font-display);
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent);
  margin: 6px 0 8px;
}

.toolbox h3:first-child { margin-top: 0; }

.toolbox-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  margin-bottom: 10px;
}

.tool-btn {
  background: #fff8ec;
  border: 2px solid transparent;
  border-radius: 10px;
  padding: 6px 0;
  font-size: 1.4rem;
  cursor: pointer;
  transition: transform 0.1s ease, border-color 0.1s ease, background 0.1s ease;
  line-height: 1;
}

.tool-btn:hover { transform: scale(1.08); border-color: var(--accent-2); }

.tool-btn.selected {
  border-color: var(--accent);
  background: #fff4e4;
  transform: scale(1.08);
}

.builder-main {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.backdrop-row {
  background: white;
  border-radius: 18px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.backdrop-row .label {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--ink-soft);
}

.backdrop-chip {
  background: #f1ebde;
  border: 2px solid transparent;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.85rem;
  font-family: var(--font-display);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 4px;
}

.backdrop-chip:hover { background: #fff4e4; }

.backdrop-chip.selected {
  border-color: var(--accent);
  background: white;
  box-shadow: 0 4px 8px rgba(43,33,64,0.1);
}

.canvas-shell {
  background: white;
  border-radius: 18px;
  padding: 14px;
  box-shadow: var(--shadow);
}

.canvas-help {
  font-size: 0.85rem;
  color: var(--ink-soft);
  margin-bottom: 10px;
  font-style: italic;
}

#scene {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: inset 0 0 0 4px #fff8ec;
  cursor: crosshair;
  user-select: none;
  -webkit-user-select: none;
}

#scene .placed {
  position: absolute;
  font-size: 2.6rem;
  cursor: pointer;
  transform: translate(-50%, -50%);
  user-select: none;
  filter: drop-shadow(0 3px 4px rgba(0,0,0,0.25));
  transition: transform 0.1s ease;
  line-height: 1;
}

#scene .placed.selected {
  outline: 3px dashed white;
  outline-offset: 6px;
  border-radius: 6px;
  animation: pulse 0.9s ease-in-out infinite alternate;
}

@keyframes pulse {
  from { transform: translate(-50%, -50%) scale(1); }
  to   { transform: translate(-50%, -50%) scale(1.08); }
}

/* Backdrop scenes for the diorama builder */
.bd-savanna {
  background:
    linear-gradient(180deg, #ffd68a 0%, #ffd68a 55%, #d49855 55%, #c08746 100%);
}
.bd-antarctic {
  background:
    linear-gradient(180deg, #cde9ff 0%, #cde9ff 50%, #f5fbff 50%, #d4e8f5 100%);
}
.bd-ocean {
  background:
    linear-gradient(180deg, #6fc5e0 0%, #2680a8 60%, #e9c387 100%);
}
.bd-bamboo {
  background:
    linear-gradient(180deg, #cdeac9 0%, #a8e6a1 50%, #4fa85e 100%);
}
.bd-forest {
  background:
    linear-gradient(180deg, #c5e8c2 0%, #8bc28a 55%, #4f7a3f 100%);
}
.bd-desert {
  background:
    linear-gradient(180deg, #ffd9a0 0%, #ffd9a0 50%, #e6a663 50%, #b87a40 100%);
}
.bd-rainforest {
  background:
    linear-gradient(180deg, #5bc07d 0%, #2f8e58 50%, #1f5e3c 100%);
}
.bd-arctic {
  background:
    linear-gradient(180deg, #e8f4ff 0%, #c2dfee 55%, #fbfdff 55%, #d6e7ef 100%);
}
.bd-meadow {
  background:
    linear-gradient(180deg, #fff8c2 0%, #ffe68a 50%, #8ac74b 100%);
}
.bd-eucalyptus {
  background:
    linear-gradient(180deg, #e3eddf 0%, #c9dec4 50%, #6a9b7a 100%);
}

.builder-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

/* ==========================================================================
   Win / End screens (used by Memory + Who Am I + Empathy)
   ========================================================================== */

.end-screen {
  text-align: center;
  padding: 30px 16px;
}

.end-screen .trophy {
  font-size: 5rem;
  line-height: 1;
  margin-bottom: 8px;
  animation: bounce 1.4s ease infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-12px); }
}

.end-screen h2 {
  font-family: var(--font-display);
  font-size: 2rem;
  margin-bottom: 6px;
}

.end-screen .summary {
  font-size: 1.15rem;
  color: var(--ink-soft);
  margin-bottom: 20px;
}

.hidden { display: none !important; }

/* Print: only print the diorama scene cleanly */
@media print {
  .game-bar, .toolbox, .backdrop-row, .builder-actions, .canvas-help { display: none !important; }
  .game-page { background: white; padding: 0; }
  .stage, .canvas-shell { box-shadow: none; padding: 0; }
  #scene { aspect-ratio: 16 / 9; box-shadow: none; }
}
