/* =========================================================
   RENNSTRECKE - Styling & Responsive Layout
   ========================================================= */

:root {
  --primary-red: #e63946;
  --primary-yellow: #ffb703;
  --primary-blue: #3a86ff;
  --primary-green: #38b000;
  --bg-dark: #1d3557;
  --bg-card: rgba(255, 255, 255, 0.94);
  --text-dark: #2b2d42;
  --border-radius: 16px;
  --font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

body, html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-family);
  background-color: #8ecae6;
  color: var(--text-dark);
}

#webgl-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  z-index: 0;
}

/* =========================================================
   HUD & OVERLAYS
   ========================================================= */

#ui-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 16px;
}

.interactive {
  pointer-events: auto;
}

/* Top Bar: Title, Level Selector & Target */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  width: 100%;
}

.top-bar-left, .top-bar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.app-title-card {
  background: var(--bg-card);
  padding: 8px 16px;
  border-radius: var(--border-radius);
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-title-card h1 {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--primary-red);
  letter-spacing: -0.5px;
}

.level-selector {
  display: flex;
  background: var(--bg-card);
  padding: 4px;
  border-radius: var(--border-radius);
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  gap: 4px;
}

.level-btn {
  background: #f1faee;
  border: 2px solid #a8dadc;
  border-radius: 10px;
  padding: 6px 12px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--bg-dark);
  cursor: pointer;
  transition: all 0.15s ease;
}

.level-btn:hover {
  background: #e2f0d9;
}

.level-btn.active {
  background: var(--primary-red);
  color: #fff;
  border-color: #c1121f;
  transform: scale(1.03);
}

/* Compact Mission Target Card in Top Bar */
.mission-card-compact {
  background: var(--bg-card);
  border: 2px solid var(--primary-yellow);
  padding: 6px 14px;
  border-radius: var(--border-radius);
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  display: flex;
  align-items: center;
  gap: 10px;
}

.mission-icon {
  font-size: 1.6rem;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.15));
}

.mission-text {
  display: flex;
  flex-direction: column;
}

.mission-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  font-weight: 800;
  color: #6c757d;
  letter-spacing: 0.5px;
}

.mission-text strong {
  font-size: 0.95rem;
  color: var(--bg-dark);
}

.mission-code-hint {
  background: #f8f9fa;
  border: 1px solid #adb5bd;
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--primary-blue);
}

.camera-toggle-btn, .info-toggle-btn {
  background: var(--bg-card);
  border: none;
  border-radius: var(--border-radius);
  padding: 8px 14px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s ease, transform 0.1s ease;
}

.camera-toggle-btn:hover, .info-toggle-btn:hover {
  background: #fff;
  transform: translateY(-1px);
}

.camera-toggle-btn:active, .info-toggle-btn:active {
  transform: scale(0.96);
}

/* Floating Pedagogical Note - Docked non-intrusively in top right */
.pedagogical-box-floating {
  position: absolute;
  top: 68px;
  right: 16px;
  max-width: 380px;
  background: rgba(29, 53, 87, 0.94);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #f1faee;
  padding: 12px 16px;
  border-radius: var(--border-radius);
  font-size: 0.85rem;
  line-height: 1.35;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  border: 1px solid rgba(255,255,255,0.15);
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 20;
}

.pedagogical-box-floating.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px);
}

.pedagogical-box-floating .note-title {
  font-weight: 800;
  color: var(--primary-yellow);
  margin-bottom: 4px;
  font-size: 0.9rem;
}

.pedagogical-box-floating code {
  background: rgba(255,255,255,0.2);
  padding: 1px 4px;
  border-radius: 4px;
  font-weight: bold;
}

/* Bottom Controls: Sequence Bar & Direction Cards */
.bottom-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  width: 100%;
}

.sequence-tray {
  background: var(--bg-card);
  padding: 12px 20px;
  border-radius: 20px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: 900px;
  width: 100%;
}

.tray-label {
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--bg-dark);
  white-space: nowrap;
}

.cards-container {
  flex: 1;
  display: flex;
  gap: 10px;
  min-height: 54px;
  align-items: center;
  background: #f1faee;
  border: 2px dashed #a8dadc;
  border-radius: 14px;
  padding: 6px 12px;
  overflow-x: auto;
}

.empty-hint {
  color: #6c757d;
  font-size: 0.9rem;
  font-style: italic;
}

.seq-card {
  background: #fff;
  border-radius: 10px;
  padding: 6px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 0.95rem;
  box-shadow: 0 3px 6px rgba(0,0,0,0.12);
  border: 2px solid transparent;
  animation: popIn 0.2s ease-out;
}

.seq-slot-empty {
  border: 2px dashed #a8dadc;
  background: rgba(255, 255, 255, 0.7);
  color: #6c757d;
  box-shadow: none;
}

.step-empty-text {
  font-size: 0.85rem;
  font-weight: 600;
  font-style: italic;
}

.note-close-btn {
  position: absolute;
  top: 8px;
  right: 10px;
  background: none;
  border: none;
  color: #adb5bd;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
}

.note-close-btn:hover {
  color: #fff;
}

@keyframes popIn {
  0% { transform: scale(0.6); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.card-left {
  border-color: var(--primary-blue);
  color: var(--primary-blue);
}

.card-right {
  border-color: var(--primary-red);
  color: var(--primary-red);
}

.step-num {
  font-size: 0.8rem;
  color: #888;
}

.remove-btn {
  background: none;
  border: none;
  font-size: 1.2rem;
  color: #999;
  cursor: pointer;
  padding: 0 4px;
}

.remove-btn:hover {
  color: var(--primary-red);
}

/* Action Buttons */
.action-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  width: 100%;
}

.btn-card-add {
  padding: 16px 28px;
  font-size: 1.2rem;
  font-weight: 800;
  border-radius: 16px;
  border: none;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(0,0,0,0.25);
  display: flex;
  align-items: center;
  gap: 10px;
  transition: transform 0.1s ease;
}

.btn-card-add:active {
  transform: scale(0.95);
}

.btn-left {
  background: linear-gradient(135deg, #3a86ff, #0056b3);
}

.btn-right {
  background: linear-gradient(135deg, #ff006e, #c1121f);
}

.btn-start {
  background: linear-gradient(135deg, #38b000, #1b4332);
  font-size: 1.3rem;
  padding: 16px 36px;
  letter-spacing: 0.5px;
}

.btn-clear {
  background: #6c757d;
  font-size: 1rem;
  padding: 12px 18px;
}

/* =========================================================
   MODAL / POPUP
   ========================================================= */

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: #fff;
  padding: 30px;
  border-radius: 24px;
  max-width: 500px;
  width: 90%;
  box-shadow: 0 20px 40px rgba(0,0,0,0.35);
  text-align: center;
  transform: scale(0.9);
  transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-overlay.visible .modal-card {
  transform: scale(1);
}

.modal-title {
  font-size: 1.8rem;
  font-weight: 800;
  margin-bottom: 14px;
}

.modal-msg {
  font-size: 1.05rem;
  line-height: 1.5;
  color: var(--text-dark);
  margin-bottom: 24px;
}

.pedagogy-feedback {
  margin-top: 14px;
  background: #e9ecef;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.95rem;
  color: var(--bg-dark);
  font-weight: 600;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.modal-btn {
  padding: 12px 24px;
  border-radius: 14px;
  border: none;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
}

.modal-btn-primary {
  background: var(--primary-green);
  color: #fff;
}

.modal-btn-secondary {
  background: #dee2e6;
  color: var(--text-dark);
}

/* =========================================================
   RESPONSIVE ADJUSTMENTS FOR TABLETS / MOBILE
   ========================================================= */
@media (max-width: 768px) {
  .top-bar {
    flex-direction: column;
    align-items: flex-start;
  }
  .action-buttons {
    flex-wrap: wrap;
  }
  .btn-card-add {
    padding: 12px 18px;
    font-size: 1rem;
  }
}
