/* scene-match/scene-match.css */
:root {
  --game-accent: #0F9B8E;
  --game-accent-dim: rgba(15, 155, 142, 0.15);
  --game-accent-contrast: #ffffff;
}

[data-context="phone"] {
  --game-accent: #0F9B8E;
}

[data-context="projector"] {
  --game-accent: #0F9B8E;
}

/* Base Styles for Scene Match Container */
.sm-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 1000px;
  margin: 0 auto;
  padding: 1rem;
  box-sizing: border-box;
}

.sm-header-card {
  background: #ffffff;
  border-radius: 12px;
  padding: 1rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.sm-room-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.sm-tab-btn {
  background: #f3f4f6;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: #374151;
  cursor: pointer;
  transition: all 0.2s ease;
}

.sm-tab-btn:hover {
  background: #e5e7eb;
}

.sm-tab-btn.active {
  background: var(--game-accent);
  color: var(--game-accent-contrast);
  border-color: var(--game-accent);
}

.sm-tab-lvl {
  font-size: 0.75rem;
  opacity: 0.85;
}

.sm-instruction {
  font-size: 0.95rem;
  color: #4b5563;
  margin-bottom: 0.75rem;
}

.sm-progress-bar-wrap {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.sm-progress-track {
  flex: 1;
  height: 10px;
  background: #e5e7eb;
  border-radius: 5px;
  overflow: hidden;
}

.sm-progress-fill {
  height: 100%;
  background: var(--game-accent);
  transition: width 0.3s ease;
}

.sm-progress-text {
  font-size: 0.85rem;
  font-weight: 700;
  color: #374151;
  white-space: nowrap;
}

/* Stage Area & Parallax Container */
.sm-stage {
  position: relative;
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  background: #1e293b;
  aspect-ratio: 8 / 5;
}

.sm-svg-scene {
  width: 100%;
  height: 100%;
  display: block;
}

/* Parallax Layers */
.sm-layer {
  transition: transform 0.1s cubic-bezier(0.25, 1, 0.5, 1);
  transform-origin: center center;
}

/* Auto-drift for touch / mobile environments */
@keyframes sm-auto-drift-bg {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(-10px, -5px); }
}

@keyframes sm-auto-drift-mid {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(12px, 6px); }
}

@keyframes sm-auto-drift-fg {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(-18px, 10px); }
}

[data-context="phone"] .sm-layer-bg,
.is-touch-device .sm-layer-bg {
  animation: sm-auto-drift-bg 8s ease-in-out infinite;
}

[data-context="phone"] .sm-layer-mid,
.is-touch-device .sm-layer-mid {
  animation: sm-auto-drift-mid 6s ease-in-out infinite;
}

[data-context="phone"] .sm-layer-fg,
.is-touch-device .sm-layer-fg {
  animation: sm-auto-drift-fg 5s ease-in-out infinite;
}

/* Doorways & Hotspots */
.sm-door-hotspot {
  cursor: pointer;
  outline: none;
}

.sm-door-hotspot > rect {
  fill: rgba(255, 255, 255, 0.01);
  stroke: rgba(255, 255, 255, 0.3);
  stroke-dasharray: 4 4;
  stroke-width: 2;
  transition: all 0.2s ease;
}

.sm-door-hotspot:hover > rect,
.sm-door-hotspot:focus > rect {
  fill: rgba(15, 155, 142, 0.25);
  stroke: var(--game-accent);
  stroke-width: 3;
  stroke-dasharray: none;
}

.sm-door-bg {
  fill: rgba(15, 23, 42, 0.85);
  rx: 4px;
}

.sm-door-label {
  fill: #ffffff;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 11px;
  font-weight: 700;
}

.sm-hotspot {
  cursor: pointer;
  outline: none;
}

.hs-hit {
  fill: rgba(255, 255, 255, 0.01);
  stroke: rgba(255, 255, 255, 0.2);
  stroke-dasharray: 4 4;
  stroke-width: 2;
  transition: all 0.2s ease;
}

.sm-hotspot:hover .hs-hit,
.sm-hotspot:focus .hs-hit {
  fill: rgba(15, 155, 142, 0.2);
  stroke: var(--game-accent);
  stroke-width: 3;
  stroke-dasharray: none;
}

.sm-hotspot.shake .hs-hit {
  animation: sm-shake 0.45s ease-in-out;
  stroke: #ef4444;
  fill: rgba(239, 68, 68, 0.25);
}

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

/* Radiating Ring Pulse */
.sm-pulse-ring {
  fill: none;
  stroke: var(--game-accent);
  stroke-width: 4;
  opacity: 0.9;
  transform-origin: center center;
  animation: sm-ring-pulse 1.2s ease-out infinite;
}

[data-context="projector"] .sm-pulse-ring {
  stroke-width: 6;
  animation-duration: 2.5s;
}

@keyframes sm-ring-pulse {
  0% {
    r: 10px;
    opacity: 1;
    stroke-width: 6;
  }
  100% {
    r: 50px;
    opacity: 0;
    stroke-width: 1;
  }
}

/* Pinned Labels */
.sm-pinned-bg {
  fill: var(--game-accent);
  rx: 6px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.sm-pinned-label {
  fill: var(--game-accent-contrast);
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 13px;
  font-weight: 700;
}

/* Word Bank */
.sm-word-bank-card {
  background: #ffffff;
  border-radius: 12px;
  padding: 1rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.sm-bank-title {
  font-size: 1rem;
  font-weight: 700;
  color: #1f2937;
  margin-bottom: 0.75rem;
}

.sm-words-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.sm-word-btn {
  background: #f3f4f6;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  padding: 0.6rem 1rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: #1f2937;
  cursor: pointer;
  transition: all 0.2s ease;
}

.sm-word-btn:hover:not(:disabled) {
  border-color: var(--game-accent);
  color: var(--game-accent);
  background: var(--game-accent-dim);
}

.sm-word-btn.selected {
  background: var(--game-accent);
  color: var(--game-accent-contrast);
  border-color: var(--game-accent);
  box-shadow: 0 0 0 3px rgba(15, 155, 142, 0.3);
}

.sm-word-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  text-decoration: line-through;
  background: #e5e7eb;
}

/* Context: Phone Layout Modifications */
[data-context="phone"] .sm-container {
  padding: 0.5rem;
  gap: 0.75rem;
}

@media screen and (max-height: 500px) and (orientation: landscape) {
  .sm-container {
    padding: 0.25rem;
    gap: 0.5rem;
  }
  .sm-header-card {
    padding: 0.5rem;
  }
  .sm-instruction {
    display: none;
  }
  .sm-stage {
    aspect-ratio: 16 / 7;
    max-height: 60vh;
  }
  [data-context="phone"] .sm-word-bank-card {
    padding: 0.4rem;
  }
  [data-context="phone"] .sm-word-btn {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
  }
}

[data-context="phone"] .sm-word-bank-card {
  position: sticky;
  bottom: 0;
  z-index: 100;
  background: #ffffff;
  border-radius: 12px 12px 0 0;
  border-top: 2px solid var(--game-accent);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.15);
  padding: 0.75rem;
  margin: 0 -0.5rem -0.5rem -0.5rem;
}

[data-context="phone"] .sm-words-grid {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  -webkit-overflow-scrolling: touch;
}

[data-context="phone"] .sm-word-btn {
  flex: 0 0 auto;
  white-space: nowrap;
  padding: 0.75rem 1.2rem;
  font-size: 1rem;
}

/* Context: Projector Layout Modifications */
[data-context="projector"] .sm-container {
  max-width: 1400px;
}

[data-context="projector"] .sm-word-btn {
  font-size: 1.25rem;
  padding: 0.85rem 1.5rem;
}

[data-context="projector"] .sm-pinned-label {
  font-size: 16px;
}
