/* ==========================================================================
   ORDHOPPET – Pedagogiskt Plattformsspråkspel
   Stylesheet: Natur, Näckrosor & Sagoskog Tema (F–3)
   ========================================================================== */

:root {
  --bg-deep: #062419;
  --emerald-main: #10b981;
  --emerald-light: #34d399;
  --teal-accent: #14b8a6;
  --amber-gold: #f59e0b;
  --water-blue: #38bdf8;
  --card-bg: rgba(6, 36, 25, 0.85);
  --border-emerald: rgba(52, 211, 153, 0.35);
  --text-main: #f8fafc;
  --text-muted: #a7f3d0;
  --font-title: 'Fredoka', cursive, sans-serif;
  --font-body: 'Nunito', sans-serif;
}

* {
  box-sizing: border-box;
}

body.ordhoppet-page {
  background-color: var(--bg-deep);
  background-image: 
    radial-gradient(ellipse at 50% 0%, rgba(16, 185, 129, 0.18) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 80%, rgba(56, 189, 248, 0.12) 0%, transparent 50%),
    linear-gradient(180deg, #041d14 0%, #082f21 100%);
  color: var(--text-main);
  font-family: var(--font-body);
  margin: 0;
  padding: 0;
  min-height: 100vh;
  overflow-x: hidden;
  user-select: none;
  -webkit-user-select: none;
}

/* Container */
.oh-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 16px 40px;
}

/* --------------------------------------------------------------------------
   Top Bar
   -------------------------------------------------------------------------- */
.oh-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  background: rgba(6, 44, 30, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-emerald);
  border-radius: 18px;
  padding: 10px 18px;
  margin-bottom: 14px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}

.oh-topbar-left, .oh-topbar-right, .oh-topbar-center {
  display: flex;
  align-items: center;
  gap: 12px;
}

.oh-btn-back {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #cbd5e1;
  padding: 6px 14px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.84rem;
  text-decoration: none;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
}

.oh-btn-back:hover {
  background: rgba(52, 211, 153, 0.2);
  border-color: var(--emerald-light);
  color: #ffffff;
  text-decoration: none;
  transform: translateX(-2px);
}

.oh-game-badge {
  display: flex;
  align-items: center;
  gap: 8px;
}

.oh-badge-icon {
  font-size: 1.6rem;
  filter: drop-shadow(0 2px 6px rgba(16, 185, 129, 0.5));
}

.oh-badge-title {
  font-family: var(--font-title);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.8px;
  background: linear-gradient(135deg, #a7f3d0 0%, #34d399 50%, #fde047 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.oh-badge-level {
  background: rgba(16, 185, 129, 0.2);
  border: 1px solid var(--emerald-light);
  color: #a7f3d0;
  font-size: 0.74rem;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: 20px;
}

/* Talsyntes / Lyssna-knapp i toppbaren */
.oh-speak-pill {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.25) 0%, rgba(5, 150, 105, 0.4) 100%);
  border: 2px solid #34d399;
  box-shadow: 0 0 16px rgba(52, 211, 153, 0.35);
  color: #ffffff;
  font-family: var(--font-title);
  font-size: 1rem;
  font-weight: 600;
  padding: 6px 18px;
  border-radius: 30px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.oh-speak-pill:hover {
  transform: scale(1.04);
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.4) 0%, rgba(5, 150, 105, 0.6) 100%);
  box-shadow: 0 0 24px rgba(52, 211, 153, 0.6);
}

.oh-speak-pill:active {
  transform: scale(0.96);
}

.oh-speak-wave {
  animation: wavePulse 1.5s infinite ease-in-out;
}

@keyframes wavePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

/* Stat Pill */
.oh-stat-pill {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 6px 12px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  gap: 6px;
}

.oh-stat-pill span {
  font-family: var(--font-title);
  color: #34d399;
}

.oh-lives-pill {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.95rem;
  padding: 6px 10px;
  background: rgba(244, 63, 94, 0.12);
  border: 1px solid rgba(244, 63, 94, 0.3);
  border-radius: 12px;
}

.oh-icon-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #cbd5e1;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.oh-icon-btn:hover {
  background: rgba(52, 211, 153, 0.25);
  border-color: var(--emerald-light);
  color: #ffffff;
  transform: scale(1.05);
}

/* --------------------------------------------------------------------------
   Canvas Play Area
   -------------------------------------------------------------------------- */
.oh-canvas-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 1000 / 560;
  max-height: 70vh;
  margin: 0 auto;
  background: #021a12;
  border-radius: 20px;
  border: 2px solid rgba(52, 211, 153, 0.4);
  box-shadow: 
    0 0 35px rgba(16, 185, 129, 0.2),
    0 20px 50px rgba(0, 0, 0, 0.7);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

#ordCanvas {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  touch-action: none;
}

/* --------------------------------------------------------------------------
   Modals & Overlays
   -------------------------------------------------------------------------- */
.oh-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(3, 24, 16, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
  animation: fadeIn 0.25s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}

.oh-modal-content {
  background: linear-gradient(135deg, rgba(6, 44, 30, 0.96) 0%, rgba(10, 60, 42, 0.94) 100%);
  border: 2px solid var(--border-emerald);
  border-radius: 24px;
  box-shadow: 
    0 0 40px rgba(52, 211, 153, 0.25),
    0 25px 60px rgba(0, 0, 0, 0.7);
  max-width: 680px;
  width: 100%;
  max-height: 92%;
  overflow-y: auto;
  padding: 28px;
  text-align: center;
}

.victory-glow {
  border-color: rgba(245, 158, 11, 0.7);
  box-shadow: 0 0 50px rgba(245, 158, 11, 0.35);
}

.gameover-glow {
  border-color: rgba(56, 189, 248, 0.6);
  box-shadow: 0 0 50px rgba(56, 189, 248, 0.3);
}

.oh-modal-header .oh-modal-icon {
  font-size: 2.8rem;
  display: block;
  margin-bottom: 6px;
}

.oh-modal-header h2 {
  font-family: var(--font-title);
  font-size: 1.8rem;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 6px;
}

.oh-modal-header p {
  color: #a7f3d0;
  font-size: 0.95rem;
  margin-bottom: 20px;
}

/* Level Grid */
.oh-level-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

@media (max-width: 680px) {
  .oh-level-grid {
    grid-template-columns: 1fr;
  }
}

.oh-level-card {
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  padding: 14px;
  text-align: left;
  cursor: pointer;
  color: var(--text-main);
  transition: all 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
  display: flex;
  flex-direction: column;
}

.oh-level-card:hover {
  background: rgba(52, 211, 153, 0.12);
  border-color: var(--emerald-light);
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.25);
}

.oh-level-card.active {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.3) 0%, rgba(5, 150, 105, 0.35) 100%);
  border-color: #34d399;
  box-shadow: 0 0 20px rgba(52, 211, 153, 0.4);
}

.oh-level-num {
  font-family: var(--font-title);
  font-size: 0.76rem;
  font-weight: 700;
  color: #34d399;
  letter-spacing: 0.8px;
  margin-bottom: 2px;
}

.oh-level-title {
  font-weight: 800;
  font-size: 0.95rem;
  color: #ffffff;
  margin-bottom: 4px;
}

.oh-level-desc {
  font-size: 0.78rem;
  color: #cbd5e1;
  line-height: 1.4;
  margin-bottom: 8px;
}

.oh-level-tag {
  margin-top: auto;
  font-size: 0.72rem;
  font-weight: 700;
  color: #fde047;
}

/* Modal Buttons */
.oh-modal-footer {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.oh-btn-primary {
  background: linear-gradient(135deg, #059669 0%, #10b981 100%);
  border: none;
  color: #ffffff;
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 1.05rem;
  padding: 12px 30px;
  border-radius: 14px;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(16, 185, 129, 0.4);
  transition: all 0.2s ease;
}

.oh-btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(16, 185, 129, 0.6);
  filter: brightness(1.1);
}

.oh-btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #ffffff;
  font-family: var(--font-title);
  font-weight: 600;
  font-size: 0.95rem;
  padding: 12px 24px;
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.oh-btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: #ffffff;
  transform: translateY(-2px);
}

/* Victory Stats */
.oh-victory-stats {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.oh-v-stat {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 12px 20px;
  border-radius: 14px;
  min-width: 120px;
}

.oh-v-label {
  font-size: 0.76rem;
  color: #a7f3d0;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.oh-v-val {
  font-family: var(--font-title);
  font-size: 1.3rem;
  font-weight: 700;
  color: #fde047;
}

/* Toast Message */
.oh-toast {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%) translateY(-30px);
  background: rgba(6, 44, 30, 0.94);
  border: 2px solid var(--emerald-light);
  box-shadow: 0 4px 25px rgba(52, 211, 153, 0.4);
  color: #ffffff;
  padding: 10px 24px;
  border-radius: 30px;
  font-family: var(--font-title);
  font-size: 1rem;
  pointer-events: none;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 50;
}

.oh-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.oh-toast.success {
  border-color: #34d399;
  color: #a7f3d0;
}

.oh-toast.error {
  border-color: #f43f5e;
  color: #fecdd3;
}

/* --------------------------------------------------------------------------
   Mobile Touch Controls
   -------------------------------------------------------------------------- */
.oh-touch-controls {
  position: absolute;
  bottom: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  pointer-events: none;
  z-index: 20;
}

.oh-touch-dpad, .oh-touch-action, .oh-touch-answers {
  pointer-events: auto;
  display: flex;
  gap: 10px;
}

.oh-touch-btn {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: rgba(6, 44, 30, 0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 2px solid rgba(52, 211, 153, 0.6);
  color: #ffffff;
  font-size: 1.3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
  transition: transform 0.1s;
}

.oh-touch-btn:active {
  transform: scale(0.92);
  background: rgba(16, 185, 129, 0.5);
  border-color: #ffffff;
}

.oh-btn-jump {
  width: 68px;
  height: 68px;
  background: linear-gradient(135deg, #059669 0%, #10b981 100%);
  border-color: #ffffff;
  flex-direction: column;
  gap: 2px;
}

.oh-btn-jump span {
  font-family: var(--font-title);
  font-size: 0.72rem;
  font-weight: 700;
}

/* Quick Answer Buttons for Mobile */
.oh-touch-answers {
  margin-bottom: 8px;
  background: rgba(6, 44, 30, 0.9);
  border: 1px solid var(--border-emerald);
  border-radius: 30px;
  padding: 4px;
}

.oh-touch-ans-btn {
  min-width: 48px;
  height: 48px;
  padding: 0 10px;
  border-radius: 25px;
  border: 2px solid #ffffff;
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 1.05rem;
  color: #ffffff;
  cursor: pointer;
  touch-action: manipulation;
}

.oh-touch-ans-btn.ans-1 {
  background: #0284c7;
}
.oh-touch-ans-btn.ans-2 {
  background: #ea580c;
}
.oh-touch-ans-btn.ans-3 {
  background: #059669;
}

/* Hide on desktop if pointer is fine */
@media (hover: hover) and (pointer: fine) and (min-width: 900px) {
  .oh-touch-controls {
    display: none;
  }
}

/* --------------------------------------------------------------------------
   Instruction / Pedagogical Section
   -------------------------------------------------------------------------- */
.oh-instructions-card {
  margin-top: 20px;
  background: rgba(6, 44, 30, 0.75);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(52, 211, 153, 0.2);
  border-radius: 18px;
  padding: 24px;
}

.oh-control-guide {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.oh-guide-item {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.88rem;
  color: #cbd5e1;
}

.oh-key {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  padding: 2px 8px;
  font-family: monospace;
  font-weight: 700;
  color: #ffffff;
  font-size: 0.82rem;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.3);
}

.oh-guide-desc {
  color: #a7f3d0;
  margin-left: 4px;
}

.oh-lgr22-box {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(52, 211, 153, 0.3);
  border-radius: 14px;
  padding: 16px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .oh-topbar {
    padding: 8px 12px;
  }
  .oh-badge-title {
    font-size: 1rem;
  }
  .oh-topbar-center {
    order: 3;
    width: 100%;
    justify-content: center;
    margin-top: 4px;
  }
}
