/* --- Generelle hjælpere --- */
.hidden-key {
  visibility: hidden;
  pointer-events: none;
}

@keyframes hintFlash {
  0% {
    box-shadow: 0 0 0 rgba(255, 255, 255, 0);
  }
  50% {
    box-shadow: 0 0 18px rgba(255, 255, 255, 0.9);
  }
  100% {
    box-shadow: 0 0 0 rgba(255, 255, 255, 0);
  }
}

.hint-key {
  background-color: #c0eaff !important;
  animation: hintFlash 1.2s ease-in-out;
}

/* --- Layout & Body --- */
html,
body {
  margin: 0;
  padding: 0;
  background-color: #ffe3b3; /* varm orange tone */
  font-family: sans-serif;
  display: flex;
  justify-content: center;
  min-height: 100vh;
  box-sizing: border-box;
}

body {
  padding-top: env(safe-area-inset-top);
  width: 100vw;
  overflow-x: hidden;
  outline: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.app-container {
  position: relative;

  width: 100%;
  max-width: 1100px;

  min-height: 100vh;

  margin: 0 auto;

  padding: 0;

  background: transparent;
}

#back-button {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: white;
  border: 2px solid #ccc;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  cursor: pointer;
  transition: background-color 0.3s ease;
}

video {
  width: 100%;
  height: auto;
  display: block;
  opacity: 0;
  transition: opacity 0.2s ease;
}

/* Den store play-knap i midten */
#play-btn.center-play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 64px;
  height: 64px;
  background-color: rgba(255, 255, 255, 0.85);
  border: none;
  border-radius: 50%;
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.3);
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  /* NYT: Klik går igennem knappen til video-beholderen */
  pointer-events: none;
}

#play-btn.center-play::before {
  content: "";
  display: block;
  width: 0;
  height: 0;
  border-left: 16px solid black;
  border-top: 10px solid transparent;
  border-bottom: 10px solid transparent;
  margin-left: 4px;
}

.keyboard {
  position: fixed;
  bottom: 20px;

  left: 50%;
  transform: translate(-50%, 110%);
  transition: transform 0.3s ease;

  width: 94%;
  max-width: 600px;

  display: flex;
  flex-direction: column;
  gap: 14px;

  padding: 20px;
  box-sizing: border-box;

  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(1px);

  border-radius: 28px;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.35);

  z-index: 5;
}

.keyboard.visible {
  transform: translate(-50%, 0);
}

.key:active {
  transform: translateY(3px);
  box-shadow:
    0 1px 0 rgba(0, 0, 0, 0.35),
    0 3px 6px rgba(0, 0, 0, 0.35);
}

.keyboard-row {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex: 1;
}

.key {
  flex: 1;

  max-width: 70px;
  height: 60px; /* fast højde i stedet for 100% */

  display: flex;
  align-items: center;
  justify-content: center;

  font-size: 22px; /* fast størrelse → mere stabil */
  font-weight: 700;

  border-radius: 14px;

  background: linear-gradient(to bottom, #ffffff, #e6e6e6);

  box-shadow:
    0 4px 0 rgba(0, 0, 0, 0.35),
    0 8px 18px rgba(0, 0, 0, 0.35);

  transition: transform 0.05s ease;
}

.key {
  color: #1f2732; /* mørk tekst */
}

/* --- Bunden af tastaturet (Aftalt Gap & Højde) --- */
.space-row {
  display: flex;
  justify-content: center;
  align-items: center; /* ← tilføj denne */
}

.space-key {
  flex: 0 0 50%; /* ← vigtig */
  max-width: none; /* så den ikke begrænses af max-width: 70px */
  height: 60px;
  border-radius: 16px;
}

/* --- Øvrige klasser --- */
.key.vowel,
.key.consonant {
  background-color: #0097a7 !important;
  color: white !important;
}

.pulse {
  animation: pulseAnim 1.6s infinite;
}
@keyframes pulseAnim {
  0%,
  100% {
    transform: translate(-50%, -50%) scale(1);
  }
  50% {
    transform: translate(-50%, -50%) scale(1.1);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.inactive-key {
  opacity: 0.35;
  pointer-events: none;
}

.active-key {
  opacity: 1;
}

.cake-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.cake {
  width: 90px;
  height: 90px;
  border-radius: 50%;

  background: conic-gradient(#4caf50 50%, #ddd 0);

  box-shadow:
    inset 0 4px 6px rgba(255, 255, 255, 0.6),
    inset 0 -6px 10px rgba(0, 0, 0, 0.15),
    0 6px 0 #2e7d32,
    0 8px 12px rgba(0, 0, 0, 0.25);

  transition:
    transform 0.08s ease,
    box-shadow 0.08s ease;
  cursor: pointer;
}

.cake-text {
  font-weight: bold;
  font-size: 18px;
}

.cake:active {
  transform: translateY(4px);

  box-shadow:
    inset 0 4px 6px rgba(255, 255, 255, 0.6),
    inset 0 -6px 10px rgba(0, 0, 0, 0.15),
    0 2px 0 #2e7d32,
    0 4px 6px rgba(0, 0, 0, 0.25);
}

.cake:hover {
  filter: brightness(1.05);
}

.cake::after {
  content: "";
  position: absolute;
  width: 70%;
  height: 35%;
  top: 10%;
  left: 15%;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(255, 255, 255, 0.8), rgba(255, 255, 255, 0) 70%);
  pointer-events: none;
}

.cake {
  position: relative;
}

.keyboard-disabled .key {
  opacity: 0.35;
  pointer-events: none;
}

.output-container,
.video-container {
  width: 100%;
  margin: 0 auto;
}

/* Start-overlay */
.video-container {
  position: relative;
}

.phonetic-toggle {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 8;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 999px;
  background: rgba(20, 28, 38, 0.72);
  color: #fff;
  font: 700 14px/1 Arial, sans-serif;
  letter-spacing: 0;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.phonetic-toggle[hidden] {
  display: none;
}

.phonetic-toggle.is-on {
  background: rgba(255, 255, 255, 0.92);
  color: #1f2732;
  border-color: rgba(31, 39, 50, 0.28);
}

.phonetic-toggle:active {
  transform: scale(0.98);
}

.color-mode-toggle {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 9;

  width: 76px;
  height: 44px;
  padding: 6px 8px;

  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;

  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 14px;
  background: rgba(20, 28, 38, 0.68);
  cursor: pointer;
  box-shadow:
    0 4px 0 rgba(0, 0, 0, 0.28),
    0 10px 22px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  touch-action: manipulation;
}

.color-mode-toggle:active {
  transform: translateY(2px);
  box-shadow:
    0 2px 0 rgba(0, 0, 0, 0.28),
    0 6px 14px rgba(0, 0, 0, 0.22);
}

.color-mode-toggle__key {
  width: 25px;
  height: 27px;

  display: flex;
  align-items: center;
  justify-content: center;

  border-radius: 8px;
  color: #fff;
  font: 800 15px/1 Arial, sans-serif;
  letter-spacing: 0;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.3),
    0 2px 0 rgba(0, 0, 0, 0.26);
}

.color-mode-toggle__key--vowel {
  background: linear-gradient(to bottom, #ff7777, #e74c3c);
  border: 1px solid #c0392b;
}

.color-mode-toggle__key--consonant {
  background: linear-gradient(to bottom, #62aaff, #2e86de);
  border: 1px solid #2980b9;
}

.app-container.keyboard-colors-on .color-mode-toggle {
  background: rgba(255, 255, 255, 0.92);
  border-color: rgba(31, 39, 50, 0.22);
}

.app-container.keyboard-colors-on .color-mode-toggle__key {
  background: linear-gradient(to bottom, #ffffff, #dde1e5);
  border: 1px solid rgba(31, 39, 50, 0.2);
  color: #1f2732;
}

/* Pulse animation */
@keyframes pulseStart {
  0% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 0.8;
  }
  50% {
    transform: translate(-50%, -50%) scale(1.15);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 0.8;
  }
}

/* Når startet → skjul pil */
.video-container.started::after {
  opacity: 0;
}

/* --- Output-container og Home-knap --- */
.output-container {
  position: relative; /* Gør det muligt at placere knappen i forhold til bjælken */
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 80px;
  background-color: #1f2732;
}

.home-btn-output {
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  cursor: pointer;
  z-index: 1000; /* Meget høj z-index så den altid er øverst */
  transition: all 0.1s ease;
}

.home-btn-output:active {
  transform: translateY(-50%) scale(0.9);
  background: rgba(255, 255, 255, 0.2);
}

/* Skjul alle gamle checkmærker hvis de stadig skulle ligge i DOM'en */
.check-mark {
  display: none !important;
}

.home-btn-output:active {
  transform: translateY(-50%) scale(0.9); /* Bevarer center-position ved klik */
  background: rgba(255, 255, 255, 0.2);
}

/* --- Progress Bar Justeringer --- */
.progress-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  /* Gør de grå billeder tydeligere (0.95 brightness) */
  filter: grayscale(100%) brightness(0.95) opacity(0.9);
  transition: all 0.4s ease;
}

/* KUN farve når status er 'perfect' */
.progress-item.perfect img,
.progress-item.end-reached img {
  filter: grayscale(0%) brightness(1.4) contrast(1.2); /* Gør billedet ekstra "levende" */
  opacity: 1;
}

/* Den nye placering af Home-knappen */
.output-container {
  position: relative; /* Gør det muligt at placere knappen absolut */
}

.output-container .mask {
  font-size: 28px;
  font-weight: 600;
  color: #ffffff;
  letter-spacing: 1px;
  line-height: 1;
}

#result-chart-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;

  display: flex;
  align-items: center; /* Centerer kagen lodret */
  justify-content: flex-end; /* Skubber kagen helt til højre */

  padding-right: 20px; /* Luft fra højre kant (juster efter behov) */
  box-sizing: border-box; /* Sørger for at padding ikke gør containeren bredere */

  opacity: 0;
  pointer-events: none; /* Deaktiveret indtil øvelsen er slut */
  z-index: 100;
  transition: opacity 0.3s ease;
}

#result-chart-container.visible {
  opacity: 1;
  pointer-events: auto; /* Aktiverer klik-fangst når kagen vises */
}

/* Sørg for at canvas stadig er klikbar */
#result-chart-container canvas {
  cursor: pointer;
  pointer-events: none;
}

#result-chart-container.visible canvas {
  pointer-events: auto;
}

#result-chart-container.result-ring {
  pointer-events: none;
}

#result-chart-container.result-ring canvas {
  cursor: default;
  pointer-events: none;
}

body {
  background: #142436; /* dyb blå */
}

.progress-item {
  aspect-ratio: 16 / 9; /* Bevarer formatet */
  width: 100%;
  height: auto;
  overflow: hidden;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: #2c3e50;
  padding: 0;
  position: relative;
}

/* --- Progress Bar Justeringer --- */
.progress-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  /* Justeret: Gør de grå billeder tydeligere så man kan se motivet */
  filter: grayscale(100%) brightness(0.9) opacity(0.8);
  transition: all 0.4s ease;
}

/* KUN farve når øvelsen er løst helt korrekt (perfect) */
.progress-item.perfect img,
.progress-item.end-reached img {
  filter: grayscale(0%) brightness(1) opacity(1);
}

/* Nuværende øvelse skal være tydeligt markeret, men stadig grå indtil løst */
.progress-item.current {
  outline: 3px solid #ffffff;
  outline-offset: -3px;
  z-index: 10;
  box-shadow: 0 0 15px rgba(255, 255, 255, 0.5);
}

.progress-item.locked {
  opacity: 0.3;
}

.progress-item.done {
  background: linear-gradient(#66bb6a, #4caf50);
}

/* Fjern de gamle grønne baggrunde da billedet nu er indikatoren */
.progress-item.perfect {
  background: none;
  border: none;
}

.progress-item.clickable {
  cursor: pointer;
  transition: transform 0.15s ease;
}

.progress-item.clickable:active {
  transform: scale(0.95);
}

@keyframes cakePulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
  }
}

.start-cake-pulse {
  animation: cakePulse 1.8s ease-in-out infinite;
}

.start-cake-pulse {
  animation: cakePulse 1.8s ease-in-out infinite;
}

.progress-wrapper {
  position: relative;
  width: 100%;
  align-items: center;
  justify-content: center;
}

.home-btn {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);

  z-index: 20;

  width: 44px; /* 🔵 større */
  height: 44px;

  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.9); /* 🔵 ring */

  background: transparent; /* 🔵 ikke fyldt */

  display: flex;
  align-items: center;
  justify-content: center;

  font-size: 22px; /* 🔵 større hus */
  line-height: 1;

  cursor: pointer;
  transition:
    transform 0.15s ease,
    background 0.2s ease;
}

.home-btn:active {
  transform: translateY(-50%) scale(0.92);
}

.home-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

/* Start-kage (neutral/hvid) */
.start-cake canvas {
  filter: brightness(1.15) saturate(0.2);
}

/* Slut-kage (grøn) */
.finish-cake canvas {
  filter: none;
}

/* Home-knap helt ude til venstre */
.home-btn {
  position: absolute;
  left: 10px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: white;
  font-size: 20px;
  cursor: pointer;
}

/* Selve øvelsesknapperne */
.progress-item {
  /* 🔴 Fjern fast width: 40px og erstat med: */
  flex: 0 1 40px; /* De starter på 40px, men må skrumpe (1) */
  min-width: 20px; /* De må ikke blive helt usynlige */
  height: 40px; /* Behold højden */

  display: flex;
  align-items: center;
  justify-content: center;

  border-radius: 8px; /* Lidt mindre radius ser bedre ud på små knapper */
  font-weight: bold;
  font-size: 14px; /* 🔴 Mindre tekst giver bedre plads til de 20 tal */

  background: #2c3e50;
  color: white;
  cursor: pointer;
}

/* Statusfarver */
.progress-item.done {
  background: #4caf50;
}

/* Styling for den fejlfrie cirkel */
.progress-item.perfect {
  background-color: #2ecc71; /* En flot klar grøn */
  color: white;
  font-weight: bold;
  font-size: 22px; /* Gør checkmærket lidt tydeligere */
  border: 2px solid #27ae60;
}

/* En lille animation når progress-baren ruller ind */
.progress-wrapper {
  animation: slideUp 0.4s ease-out;
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.progress-item.locked {
  opacity: 0.4;
  pointer-events: none;
}

/* Klasse der simulerer et fysisk tastetryk på skærmen */
.key.physical-press {
  background-color: #7ed957 !important; /* Den grønne kage-farve */
  color: white !important;
  transform: scale(0.95);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* --- Samlet Progress Bar Optimering --- */
.progress-container {
  display: grid !important;
  /* 10 store knapper pr. række gør farvebelønningen tydeligere */
  grid-template-columns: repeat(10, 1fr);
  grid-auto-rows: auto;

  /* HER STYRER DU AFSTANDEN (Horisontalt og Vertikalt) */
  gap: 10px;

  /* HER STYRER DU BREDDEN (Sat til 1100px for at matche billedet/app'en) */
  width: 100%;
  max-width: 1100px;

  margin: 0 auto;
  padding: 10px; /* Lille smule luft ind mod kanten af skærmen */
  box-sizing: border-box;
}

.progress-item {
  /* HER STYRER DU HØJDEN PÅ KNAPPERNE */
  height: 62px;

  width: 100%; /* Lad grid'et bestemme bredden */
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: #2c3e50;
  color: white;
  cursor: pointer;

  /* HER STYRER DU TEKSTSTØRRELSEN I KNAPPEN */
  font-size: 18px;
  font-weight: bold;
}

/* --- Optimering til Portræt-visning (lodret tablet/mobil) --- */
@media (orientation: portrait) {
  .app-container {
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  @media (orientation: portrait) {
    /* Gør progress-baren læselig og trykbar på mobilen */
    .progress-container {
      grid-template-columns: repeat(5, 1fr) !important; /* Kun 5 i træk i stedet for 15 */
      gap: 8px;
      padding: 15px;
    }

    .progress-item {
      height: 60px; /* Gør dem højere så de er nemmere at ramme */
      font-size: 20px;
    }

    /* Juster output-teksten så den ikke fylder det hele */
    .output-container .mask {
      font-size: 24px; /* Lidt mindre tekst i portræt */
    }
  }

  .keyboard {
    /* Ophæv den faste placering i bunden */
    position: relative;
    bottom: auto;
    left: auto;
    transform: none; /* Fjerner centrerings-forskydningen fra fixed */

    /* Flyt den tættere på videoen */
    margin-top: 40px;
    margin-bottom: 40px;

    /* Sørg for den stadig er centreret og fylder rigtigt */
    width: 90%;
    max-width: 600px;
    transition: opacity 0.3s ease; /* Vi fjerner slide-op animationen her */
  }

  /* Sørger for at den 'synlige' klasse ikke ødelægger layoutet */
  .keyboard.visible {
    transform: none;
    opacity: 1;
  }
}

@media screen and (max-width: 600px) {
  .key {
    height: 50px; /* Lidt lavere taster på små skærme */
    font-size: 18px;
    border-radius: 10px;
  }

  .keyboard {
    padding: 10px;
    gap: 8px;
    width: 98%; /* Brug hele bredden på en telefon */
  }

  .space-key {
    height: 50px;
  }
}

/* Specifikke rettelser til smartphone (små skærme) */
@media screen and (max-width: 600px) {
  .keyboard {
    width: 98%; /* Bruger mere af skærmens bredde */
    padding: 12px 6px; /* Mindre luft i siderne giver tasterne mere plads */
    gap: 10px; /* Afstand mellem de tre rækker */
  }

  .keyboard-row {
    gap: 4px; /* VIGTIGT: Mindre afstand mellem de enkelte taster gør dem bredere */
  }

  .key {
    height: 46px; /* Gør tasterne kortere (før 60px) */
    font-size: 18px; /* Tilpasser bogstavernes størrelse til de nye rammer */
    border-radius: 8px; /* En mindre radius får dem til at se mindre "ovale" ud */
  }

  .space-key {
    height: 46px; /* Mellemrumstasten skal have samme højde */
    flex: 0 0 60%; /* Gør mellemrumstasten lidt længere på mobilen */
  }
}

.output-line {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  margin: 0 0.2ch;
  font-size: 2rem;
}

/* Basis oval med luft imellem */
.mask-char {
  display: inline-flex; /* Ændret fra inline-block for bedre kontrol */
  align-items: center;
  justify-content: center;

  width: 1.1ch;
  height: 1.1em;

  margin: 0 1px; /* Her styrer du luften (2px på hver side = 4px totalt) */

  border: 1.5px solid white;
  border-radius: 999px;
  box-sizing: border-box;
  vertical-align: middle;
}

/* Sørg for at maskens container ikke wrapper midt i et ord hvis muligt */
.mask {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0; /* Vi bruger margin på selve ovalerne i stedet */
  padding: 10px;
}

/* Aktive vokal-taster (Rød) */
.key.vowel-key {
  background: linear-gradient(to bottom, #ff6b6b, #e74c3c) !important;
  color: white !important;
  border: 1px solid #c0392b;
}

/* Aktive konsonant-taster (Blå) */
.key.consonant-key {
  background: linear-gradient(to bottom, #54a0ff, #2e86de) !important;
  color: white !important;
  border: 1px solid #2980b9;
}

/* Sørg for at teksten stadig er tydelig når tasten trykkes ned */
.key.vowel-key:active,
.key.consonant-key:active {
  background: #333 !important; /* Mørk feedback ved tryk */
}

/* Hvis en tast er "physical-press" (fra fysisk tastatur), overskriver vi farven kortvarigt */
.key.physical-press {
  background: #7ed957 !important;
  color: white !important;
}

/* Vokaler */
.vowel {
  background-color: #e74c3c; /* rød */
}

/* Konsonanter */
.consonant {
  background-color: #2e86de; /* blå */
}

/* Øvrige (mellemrum, punktum osv.) */
.other {
  background-color: transparent;
}

/* Gør mellemrum bredere */
.space {
  width: 1.4ch;
}

/* Mellemrum i masken (oppe i teksten) */
.mask-char.space {
  background-color: #bdc3c7; /* Mellemgrå */
  border-color: #95a5a6;
  width: 0.9ch;
}

/* Mellemrumstasten på tastaturet */
.key.space-key.active-key {
  background: linear-gradient(to bottom, #bdc3c7, #95a5a6) !important;
  color: #2c3e50 !important;
  border: 1px solid #7f8c8d;
}

/* Sørg for at den stadig ser trykket ud */
.key.space-key:active {
  background: #7f8c8d !important;
}

/* Den magiske plads i masken (oppe i teksten) */
.mask-char.magic-char {
  background-color: #f1c40f; /* Dæmpet gul/guld */
  border-color: #f39c12;
  opacity: 0.8;
}

/* Den magiske tast på tastaturet */
.key.magic-key.active-key {
  background: linear-gradient(to bottom, #f1c40f, #f39c12) !important;
  color: #1f2732 !important;
  border: 1px solid #d4ac0d;
}

/* Feedback ved tryk */
.key.magic-key:active {
  background: #d4ac0d !important;
}

/* Animation til cursoren */
@keyframes cursorPulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0px rgba(255, 255, 255, 0);
    filter: brightness(1);
  }
  50% {
    transform: scale(1.1); /* Lidt større for at poppe ud */
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.8);
    filter: brightness(1.3); /* Gør farven lidt klarere */
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0px rgba(255, 255, 255, 0);
    filter: brightness(1);
  }
}

/* Anvend animationen på den aktive cursor */
.mask-char.cursor {
  animation: cursorPulse 2s ease-in-out infinite; /* 2 sekunder for en rolig frekvens */
  position: relative;
  z-index: 2; /* Sørg for at den ligger over de andre */
  border: 2px solid white !important; /* Gør rammen lidt tydeligere på cursoren */
}

/* Det løste mellemrum skal nu være usynligt, men beholde sin plads */
.mask-char.space.solved {
  background-color: transparent !important;
  border-color: transparent !important;
  box-shadow: none !important;
  width: 0.4ch; /* Bevarer den vandrette afstand */
  margin: 0 4px;
}

/* Sørg for at det ikke-løste mellemrum stadig er gråt, så barnet kan finde det */
.mask-char.space:not(.solved) {
  background-color: #bdc3c7;
  border: 1.5px solid white;
}

.app-container.keyboard-colors-off .key.vowel-key.active-key,
.app-container.keyboard-colors-off .key.consonant-key.active-key,
.app-container.keyboard-colors-off .key.magic-key.active-key,
.app-container.keyboard-colors-off .key.space-key.active-key {
  background: linear-gradient(to bottom, #ffffff, #d9dde2) !important;
  border: 1px solid rgba(31, 39, 50, 0.22) !important;
  color: #1f2732 !important;
}

.app-container.keyboard-colors-off .mask-char:not(.space),
.app-container.keyboard-colors-off .mask-char.magic-char {
  background: linear-gradient(to bottom, #ffffff, #d9dde2) !important;
  border-color: rgba(255, 255, 255, 0.96) !important;
}

.app-container.keyboard-colors-off .mask-char.space:not(.solved) {
  position: relative;
  width: 1.5ch;
  background: linear-gradient(to bottom, #aeb8c3, #7f8b98) !important;
  border-color: rgba(255, 255, 255, 0.98) !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    0 0 10px rgba(255, 255, 255, 0.18);
}

.app-container.keyboard-colors-off .mask-char.space:not(.solved)::before {
  content: "";
  width: 58%;
  height: 3px;
  border-radius: 999px;
  background: rgba(31, 39, 50, 0.7);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.28);
}

/* --- Spilfølelse uden nye assets --- */
@keyframes foundKeyPop {
  0% {
    transform: scale(1);
    box-shadow: 0 4px 0 rgba(0, 0, 0, 0.35);
  }
  45% {
    transform: scale(1.08);
    box-shadow:
      0 0 0 5px rgba(126, 217, 87, 0.35),
      0 8px 20px rgba(0, 0, 0, 0.28);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 4px 0 rgba(0, 0, 0, 0.35);
  }
}

.key.found-key {
  animation: foundKeyPop 0.5s ease;
  background: linear-gradient(to bottom, #9be873, #69b347) !important;
  color: #163017 !important;
  border-color: #5c9b3f !important;
}

@keyframes guideFocus {
  0%,
  100% {
    box-shadow: inset 0 0 0 rgba(255, 215, 106, 0);
  }
  50% {
    box-shadow: inset 0 -5px 0 rgba(255, 215, 106, 0.55);
  }
}

.app-container.guide-mode .output-container {
  animation: guideFocus 0.75s ease;
}

.app-container.guide-mode .mask-char.cursor {
  box-shadow: 0 0 0 5px rgba(255, 215, 106, 0.35);
  filter: brightness(1.25);
}

.completion-actions {
  position: absolute;
  left: 50%;
  top: clamp(14px, 2.5vw, 28px);
  z-index: 140;

  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;

  max-width: min(92%, 520px);
  transform: translate(-50%, -8px);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
}

.completion-actions.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
}

.completion-actions.start-actions {
  top: 50%;
  transform: translate(-50%, -48%);
}

.completion-actions.start-actions.visible {
  transform: translate(-50%, -50%);
}

.completion-btn {
  min-width: 124px;
  height: 56px;
  padding: 0 22px;

  border: 2px solid rgba(255, 255, 255, 0.82);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: #1f2732;

  font: inherit;
  font-size: 20px;
  font-weight: 800;
  line-height: 1;

  cursor: pointer;
  box-shadow:
    0 5px 0 rgba(0, 0, 0, 0.28),
    0 12px 26px rgba(0, 0, 0, 0.24);
  touch-action: manipulation;
  transition:
    transform 0.1s ease,
    box-shadow 0.1s ease,
    background 0.15s ease;
}

.completion-btn.primary {
  background: linear-gradient(to bottom, #9be873, #69b347);
  border-color: rgba(255, 255, 255, 0.92);
  color: #173117;
}

.completion-actions.start-actions .completion-btn {
  min-width: 168px;
  height: 66px;
  font-size: 24px;
}

.completion-btn.secondary {
  background: rgba(255, 255, 255, 0.88);
}

.completion-btn.with-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.completion-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: sans-serif;
  font-size: 1.12em;
  font-weight: 900;
  line-height: 1;
}

.completion-btn.restart-action .completion-icon {
  font-size: 1.38em;
  transform: translateY(-1px);
}

.completion-btn.next-action .completion-icon {
  font-size: 1.08em;
}

.completion-btn:active {
  transform: translateY(4px) scale(0.98);
  box-shadow:
    0 1px 0 rgba(0, 0, 0, 0.26),
    0 5px 12px rgba(0, 0, 0, 0.2);
}

.progress-item.done {
  background: #3c4652;
  border: 1px solid rgba(248, 220, 122, 0.7);
}

.progress-item.done img {
  filter: grayscale(100%) brightness(0.82) opacity(0.82);
}

.progress-item.done::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 7px;
  background: linear-gradient(to right, #d6a63c, #f8dc7a);
}

.progress-item.perfect img,
.progress-item.end-reached img {
  filter: grayscale(0%) brightness(1.05) opacity(1);
}

.progress-item.next-recommended {
  outline: 3px solid #ffd76a;
  outline-offset: -3px;
  box-shadow:
    0 0 0 3px rgba(255, 215, 106, 0.22),
    0 0 18px rgba(255, 215, 106, 0.36);
}

@media (orientation: portrait) {
  .completion-actions {
    position: relative;
    left: auto;
    top: auto;
    bottom: auto;
    width: min(92%, 460px);
    margin: 12px auto 0;
    transform: translateY(10px);
  }

  .completion-actions.visible {
    transform: translateY(0);
  }

  .completion-actions.start-actions {
    position: absolute;
    left: 50%;
    top: 50%;
    width: auto;
    margin: 0;
    transform: translate(-50%, -48%);
  }

  .completion-actions.start-actions.visible {
    transform: translate(-50%, -50%);
  }
}

@media screen and (max-width: 600px) {
  .phonetic-toggle {
    left: 8px;
    bottom: 8px;
    min-height: 34px;
    padding: 7px 10px;
    font-size: 12px;
  }

  .color-mode-toggle {
    right: 8px;
    bottom: 8px;
    width: 66px;
    height: 38px;
    padding: 5px 7px;
    gap: 6px;
    border-radius: 12px;
  }

  .color-mode-toggle__key {
    width: 21px;
    height: 23px;
    border-radius: 7px;
    font-size: 13px;
  }

  .completion-actions {
    gap: 8px;
    width: 94%;
    max-width: none;
  }

  .completion-btn {
    flex: 1;
    min-width: 0;
    height: 50px;
    padding: 0 12px;
    font-size: 18px;
  }

  .completion-actions.start-actions {
    width: auto;
  }

  .completion-actions.start-actions .completion-btn {
    min-width: 148px;
    height: 58px;
    font-size: 22px;
  }
}

@media (orientation: portrait) {
  .keyboard:not(.visible) {
    display: none;
  }
}
