/* Biology Lab Safety — 1920×1080 design base, scaled via --scaleFactor */

:root {
  --scaleFactor: 1;
  --color-bg: #0a1218;
  --color-surface: #14202c;
  --color-surface-2: #1a2d3d;
  --color-accent: #ff9f1a;
  --color-accent-dark: #d68300;
  --color-correct: #219150;
  --color-correct-light: #4ade80;
  --color-wrong: #ff6f61;
  --color-wrong-dark: #d4574c;
  --color-text: #f1f5f9;
  --color-text-muted: #94a3b8;
  --color-border: #2a4a60;
  --color-heading: #ffab40;
  --font: 'Comfortaa', Arial, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  font-size: 115%;
  margin: 0;
  padding: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  font-family: var(--font);
  background: #050a0e;
  color: var(--color-text);
}

.responsive-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.responsive-wrapper {
  width: 1920px;
  height: 1080px;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: scale(var(--scaleFactor)) translate(-50%, -50%);
  transform-origin: top left;
  background: linear-gradient(180deg, #0d1824 0%, #0a1218 45%, #070e14 100%);
}

.applet-root {
  width: 1920px;
  height: 1080px;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* --- Nav bar --- */
.applet-nav {
  flex: 0 0 auto;
  padding: 20px 48px 12px;
  text-align: center;
  border-bottom: 1px solid rgba(42, 74, 96, 0.5);
  background: rgba(10, 18, 24, 0.85);
}

.applet-nav__title {
  margin: 0 0 8px;
  font-size: 34px;
  font-weight: 700;
  color: var(--color-heading);
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}

.applet-nav__instruction {
  margin: 0;
  font-size: 2rem;
  color: #ffd54f;
  font-weight: 600;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}

/* --- Main stage --- */
.applet-stage {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  min-height: 0;
  padding: 12px 40px 8px;
}

.applet-work-area {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
}

.applet-scene-wrap {
  position: relative;
  isolation: isolate;
  z-index: 0;
  width: 100%;
  height: 100%;
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid var(--color-border);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45), inset 0 0 0 1px rgba(255, 255, 255, 0.04);
  background: #0d1824;
}

/* --- Photo lab scene (replaces SVG room) --- */
.lab-scene-composite {
  position: relative;
  z-index: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0a0e12;
}

/* Fill the scene — avoid aspect-ratio alone (older WebViews can size width to 0). */
.lab-scene-inner {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 200px;
  margin: 0 auto;
  overflow: hidden;
  border-radius: 8px;
}

.lab-scene-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  display: block;
  pointer-events: none;
  user-select: none;
}

.lab-scene-props {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.lab-scene-prop {
  position: absolute;
  transform: translate(-50%, -50%);
  height: auto;
  object-fit: contain;
  filter: drop-shadow(2px 6px 12px rgba(0, 0, 0, 0.35));
  transition: filter 0.25s ease, transform 0.25s ease;
  pointer-events: none;
  user-select: none;
}

.lab-scene-prop--selected {
  filter:
    drop-shadow(2px 6px 12px rgba(0, 0, 0, 0.35))
    drop-shadow(0 0 16px rgba(255, 159, 26, 0.95))
    drop-shadow(0 0 30px rgba(255, 159, 26, 0.65));
}

.lab-scene-prop--correct {
  filter:
    drop-shadow(2px 6px 12px rgba(0, 0, 0, 0.35))
    drop-shadow(0 0 18px rgba(33, 145, 80, 0.95))
    drop-shadow(0 0 32px rgba(88, 217, 139, 0.75));
}

.lab-scene-prop--wrong {
  filter:
    drop-shadow(2px 6px 12px rgba(0, 0, 0, 0.35))
    drop-shadow(0 0 18px rgba(255, 111, 97, 0.95))
    drop-shadow(0 0 32px rgba(255, 143, 131, 0.75));
}

.lab-scene-prop--hint-correct {
  animation: hintCorrectPulse 1.35s ease-in-out infinite;
  filter:
    drop-shadow(2px 6px 12px rgba(0, 0, 0, 0.35))
    drop-shadow(0 0 14px rgba(255, 183, 77, 0.9))
    drop-shadow(0 0 28px rgba(183, 240, 143, 0.72));
}

@keyframes hintCorrectPulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.82;
  }
}

/* SVG is visual-only — clicks go through HTML hit layer (transform/scale breaks SVG hit-testing). */
.lab-scene-hotspots {
  position: absolute;
  inset: 0;
  z-index: 5;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
  touch-action: manipulation;
}

/*
 * Sibling of LabScene + HintCard under .applet-scene-wrap — must be last + high z-index
 * so nothing inside the scaled lab tree stacks above these buttons.
 */
.scene-hit-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: clamp(420px, 30%, 620px);
  bottom: 0;
  z-index: 50;
  pointer-events: none;
}

.scene-hit-btn {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 64px;
  height: 64px;
  min-width: 44px;
  min-height: 44px;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  pointer-events: auto;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  box-shadow: none;
}

.scene-hit-btn:disabled {
  cursor: default;
  pointer-events: none;
}

.scene-hit-btn:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
}

/* index.html?debug=hits — verify slice alignment vs SVG markers */
body.debug-scene-hits .scene-hit-btn {
  background: rgba(255, 60, 60, 0.28);
  box-shadow: inset 0 0 0 3px rgba(255, 40, 40, 0.9);
}

.lab-scene-speech {
  position: absolute;
  left: calc(2% + 400px);
  top: 6%;
  max-width: 34%;
  min-width: 220px;
  z-index: 6;
  pointer-events: none;
}

.lab-scene-speech__inner {
  position: relative;
  padding: 14px 18px;
  background: rgba(0, 0, 0, 0.4);
  border: none;
  border-radius: 14px;
  font-size: 2rem;
  line-height: 1.45;
  font-weight: 600;
  color: #e2e8f0;
  font-family: var(--font);
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.55);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.lab-scene-speech__inner::after {
  content: none;
  position: absolute;
  left: 24px;
  bottom: -10px;
  width: 0;
  height: 0;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-top: 10px solid rgba(74, 144, 217, 0.55);
}

/* --- Hint card --- */
.hint-card {
  position: absolute;
  top: 16px;
  right: 16px;
  max-width: 380px;
  padding: 14px 18px;
  background: rgba(20, 40, 60, 0.92);
  border: 1px solid rgba(74, 144, 217, 0.45);
  border-radius: 10px;
  font-size: 16px;
  line-height: 1.35;
  color: #cbd5e1;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
  z-index: 10;
  pointer-events: none;
}

/* --- Control bar --- */
.control-bar {
  flex: 0 0 120px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  gap: 24px;
  background: linear-gradient(0deg, rgba(8, 14, 20, 0.98), rgba(12, 22, 32, 0.92));
  border: 2px solid rgba(42, 74, 96, 0.5);
  border-radius: 12px;
}

.control-bar__left {
  flex: 1;
  min-width: 0;
}

.control-bar__instruction {
  font-size: 2rem;
  line-height: 1.35;
  color: #e2e8f0;
  font-weight: 600;
  text-align: center;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.55);
}

.control-bar__actions {
  display: flex;
  gap: 16px;
  flex: 0 0 auto;
}

/* --- Buttons --- */
.applet-btn {
  font-family: var(--font);
  font-size: 1.7rem;
  font-weight: 700;
  padding: 14px 32px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.45);
}

.applet-btn span {
  pointer-events: none;
}

.applet-btn:active:not(:disabled) {
  transform: scale(0.95);
}

.applet-btn--primary {
  background: linear-gradient(180deg, #ffb84d 0%, var(--color-accent) 40%, var(--color-accent-dark) 100%);
  color: #1a0a00;
  box-shadow: 0 0 12px rgba(241, 196, 15, 0.45), 0 4px 0 #a65f00;
  animation: btnPulse 2s ease-in-out infinite;
}

.applet-btn--primary:not(:disabled):hover {
  box-shadow: 0 0 20px rgba(255, 159, 26, 0.65), 0 4px 0 #a65f00;
}

.applet-btn--secondary {
  background: linear-gradient(180deg, #3d5a73 0%, #2a4055 100%);
  color: #e2e8f0;
  border: 2px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.applet-btn--secondary:hover:not(:disabled) {
  background: linear-gradient(180deg, #4a6a85 0%, #354d63 100%);
}

.applet-btn:disabled,
.applet-btn--disabled {
  opacity: 0.72;
  cursor: not-allowed;
  animation: none;
  box-shadow: none;
  outline: 1px solid rgba(255, 255, 255, 0.22);
  outline-offset: 2px;
}

@keyframes btnPulse {
  0%,
  100% {
    box-shadow: 0 0 12px rgba(241, 196, 15, 0.45), 0 4px 0 #a65f00;
  }
  50% {
    box-shadow: 0 0 22px rgba(241, 196, 15, 0.75), 0 4px 0 #a65f00;
  }
}

/* Hotspot pulse (SVG class) */
.hotspot-pulse {
  animation: hotspotPulseInner 2s ease-in-out infinite;
}

.hotspot-pulse-ring {
  animation: hotspotPulseRing 2s ease-in-out infinite;
}

@keyframes hotspotPulseInner {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.88;
  }
}

@keyframes hotspotPulseRing {
  0%,
  100% {
    opacity: 0.4;
  }
  50% {
    opacity: 0.85;
  }
}

/* --- Feedback panel: right-side mid overlay (30% width) --- */
.feedback-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: 30%;
  height: 100%;
  min-width: 420px;
  max-width: 620px;
  padding: 14px 16px;
  z-index: 100;
  pointer-events: auto;
  overflow-y: auto;
  background: linear-gradient(180deg, rgba(12, 22, 32, 0.94) 0%, rgba(8, 14, 22, 0.98) 100%);
  border-left: 2px solid var(--color-border);
  box-shadow: -8px 0 24px rgba(0, 0, 0, 0.45);
}

.applet-scene-wrap {
  padding-right: clamp(420px, 30%, 620px);
}

.feedback-panel__left {
  min-width: 0;
}

.feedback-panel__header {
  font-size: 2rem;
  font-weight: 700;
  margin: 0 0 6px;
  color: var(--color-heading);
  text-align: center;
  opacity: 0.45;
  transition: opacity 0.2s ease;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.feedback-panel--active .feedback-panel__header {
  opacity: 1;
}

.feedback-panel__evaluation {
  font-size: 1.4rem;
  line-height: 1.35;
  color: var(--color-text-muted);
  margin: 0 0 8px;
  max-width: none;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.35);
}

.feedback-panel__reinforcement {
  font-size: 1.3rem;
  line-height: 1.3;
  color: var(--color-accent);
  font-weight: 600;
  margin: 8px 0 0;
  max-width: none;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.45);
}

.feedback-panel__stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.feedback-panel__lead-in {
  margin: 0;
  font-size: 1.55rem;
  line-height: 1.35;
  color: #d9f99d;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.45);
}

.feedback-panel__subheader {
  margin: 0;
  font-size: 2rem;
  color: #b7f08f;
  font-weight: 700;
  text-align: center;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.45);
}

.feedback-panel__summary-body {
  margin: 0;
  font-size: 1.55rem;
  line-height: 1.35;
  color: #d9f99d;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.45);
}

.feedback-panel__list {
  margin: 0;
  padding-left: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  list-style: disc;
}

.feedback-panel__point {
  font-size: 1.52rem;
  line-height: 1.36;
  color: #e2e8f0;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.35);
}

.feedback-panel__remember-card {
  display: grid;
  grid-template-columns: 25% 75%;
  align-items: center;
  gap: 12px;
  min-height: 88px;
  padding: 14px 14px;
  border-radius: 10px;
  border: 1px solid rgba(183, 240, 143, 0.4);
  background: rgba(34, 66, 40, 0.35);
}

.feedback-panel__remember-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(88, 217, 139, 0.25);
  border: 1px solid rgba(88, 217, 139, 0.65);
  color: #b7f08f;
  font-size: 1.25rem;
  font-weight: 800;
  flex: 0 0 40px;
  margin: 0 auto;
}

.feedback-panel__remember-icon-image {
  width: 62px;
  height: 62px;
  object-fit: contain;
  flex: 0 0 62px;
  margin: 0 auto;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.35));
}

.feedback-panel__remember-text {
  font-size: 1.58rem;
  line-height: 1.4;
  color: #e9f8db;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.35);
}

.feedback-rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
}

.feedback-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 10px;
  background: rgba(30, 48, 64, 0.65);
  border-radius: 8px;
  border-left: 4px solid #475569;
  animation: fadeInRow 0.35s ease-out both;
}

.feedback-row__icon {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 800;
  line-height: 1;
}

.feedback-row__label {
  display: block;
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 2px;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.45);
}

.feedback-row__desc {
  font-size: 1.32rem;
  color: #cbd5e1;
  line-height: 1.3;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.35);
}

.feedback-row--correct {
  border-left-color: var(--color-correct-light);
}

.feedback-row--incorrect {
  border-left-color: var(--color-wrong);
}

.feedback-row--missed {
  border-left-color: #fbbf24;
}

@keyframes fadeInRow {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.feedback-row__icon--correct {
  background: rgba(33, 145, 80, 0.35);
  color: var(--color-correct-light);
}

.feedback-row__icon--incorrect {
  background: rgba(255, 111, 97, 0.3);
  color: #fecaca;
}

.feedback-row__icon--missed {
  background: rgba(251, 191, 36, 0.25);
  color: #fbbf24;
}

.feedback-row__text {
  flex: 1;
  min-width: 0;
}

/* Summary cards */
.summary-section__title {
  font-size: 22px;
  font-weight: 700;
  color: var(--color-heading);
  margin: 8px 0 16px;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.summary-cards {
  display: flex;
  gap: 18px;
  margin-bottom: 24px;
}

.summary-card {
  flex: 1 1 0;
  min-width: 0;
  padding: 18px 16px;
  background: rgba(25, 45, 62, 0.9);
  border: 1px solid rgba(74, 144, 217, 0.35);
  border-radius: 12px;
  font-size: 17px;
  line-height: 1.35;
  color: #e2e8f0;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.45);
  display: flex;
  gap: 12px;
  align-items: flex-start;
  animation: popIn 0.4s ease-out both;
}

.summary-card:nth-child(1) {
  animation-delay: 0.05s;
}
.summary-card:nth-child(2) {
  animation-delay: 0.1s;
}
.summary-card:nth-child(3) {
  animation-delay: 0.15s;
}

.summary-card__bullet {
  flex: 0 0 auto;
  color: var(--color-correct-light);
  font-weight: 800;
  font-size: 20px;
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: scale(0.96);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@media (max-width: 960px) {
  .summary-cards {
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
