/* ============================================================
   RESPONSIVE.CSS - konsolidiert
   ------------------------------------------------------------
   Zwei klare Breakpoints statt vorher mehrerer teils
   überlappender Regeln (600px / 768px / 1000px):

     TABLET   -> max-width: 1024px
     MOBILE   -> max-width: 640px

   Reihenfolge: allgemeine Layout-Regeln zuerst, dann
   Feinheiten pro Bereich. Mobile-Regeln stehen NACH den
   Tablet-Regeln und überschreiben sie gezielt weiter, statt
   sich zu widersprechen.
   ============================================================ */


/* ======================================
   TABLET  (<= 1024px)
   - Panels dürfen umbrechen
   - Grid-Spalten schmaler, aber noch nebeneinander möglich
====================================== */

@media (max-width: 1024px) {

  .page-grid {
    /* 🔙 Wieder 3 Spalten (siehe style.css) */
    grid-template-columns: minmax(180px, 220px) minmax(0, 1fr) minmax(180px, 220px);
    gap: 16px;
  }

  #gameArea {
    max-width: 100%;
  }

  #statsGrid,
  #boxGrid {
    grid-template-columns: repeat(3, 1fr);
  }
}


/* ======================================
   TABLET SCHMAL / GROSSES HANDY (<= 860px)
   - Seitenspalten (Lexikon/Highscore) brechen unter den
     Hauptinhalt um, statt gequetscht nebeneinander zu stehen
====================================== */

@media (max-width: 860px) {

  .page-grid {
    grid-template-columns: 1fr;
  }

  .page-col-main {
    order: 1;
  }

  .page-col-left {
    order: 2;
    border-right: none;
    border-top: 1px solid #eee;
  }

  .page-col-right {
    order: 3;
    border-left: none;
    border-top: 1px solid #eee;
  }

  .highscoreBox {
    position: static;
    max-width: 480px;
    margin: 0 auto;
  }

  #statsGrid,
  #boxGrid {
    grid-template-columns: repeat(3, 1fr);
  }
}


/* ======================================
   MOBILE  (<= 640px)
   - alles untereinander, keine Panels nebeneinander
   - größere Touch-Ziele für Buttons
====================================== */

@media (max-width: 640px) {

  /* 🗺️ miStudia-Logo mitten in der Weltkarte wirkte auf dem Handy im
     Verhältnis zur Karte immer noch zu groß (auch schon verkleinert) -
     stattdessen jetzt nur das kleine Favicon oben links, das große
     Logo unten mittig wird dafür ausgeblendet. */
  .worldmap-logo {
    display: none;
  }

  .worldmap-favicon-link {
    display: block;
    position: absolute;
    top: 6px;
    left: 6px;
    z-index: 2;
  }

  #worldMapFavicon {
    width: 28px;
    height: 28px;
    display: block;
    border-radius: 6px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
  }

  /* Absolute Titel-Zentrierung war früher nötig, weil das kleine Logo
     neben dem großen, absolut zentrierten Titel stand - jetzt stapelt
     die Basis-Regel (.page-header-row in style.css) das ohnehin schon,
     hier bleibt nur noch der Abstand nach oben relevant. */
  .page-header-row {
    min-height: 0;
  }

  body {
    padding-left: 10px;
    padding-right: 10px;
    padding-bottom: 160px;
    padding-top: 20px;
  }

  .page-wrapper {
    padding: 0 8px;
  }

  /* 🔥 War früher ein kleines Eck-Logo (90px) neben einem großen Titel-
     Balken - jetzt trägt das Logo allein die Marke, bleibt auf Handys
     deshalb deutlich größer als vorher. */
  #logo {
    width: clamp(140px, 60vw, 220px);
    max-width: 70vw;
  }

  #gameTitle {
    font-size: 14px;
  }

  #gameArea,
  #mainCenter,
  #statsPanel,
  #boxPanel {
    width: 100%;
    max-width: 100%;
  }

  .start-box {
    width: 100%;
    max-width: 100%;
    padding: 16px;
  }

  .start-box label {
    grid-template-columns: 1fr;
    gap: 6px;
    font-size: 16px;
  }

  /* 🆕 Schnellstart-Karte, Optionen/Lehrer-Modus-Abschnitte, Highscore-
     Streifen und Mehr-Reihe: auf Handys volle Breite, weniger Padding. */
  .ui-lang-corner,
  .quickstart-card,
  .collapsible-section,
  .more-row {
    max-width: 100%;
  }

  .quickstart-card {
    padding: 16px;
    border-radius: 16px;
  }

  .quickstart-card label,
  .collapsible-body label {
    font-size: 15px;
  }

  .start-cta {
    font-size: 18px;
    padding: 14px;
  }

  .collapsible-toggle {
    padding: 12px 14px;
    font-size: 15px;
  }

  .collapsible-body {
    padding: 4px 14px 14px 14px;
  }

  /* 🔙 Mehr-Reihe ist jetzt durchgehend 1-spaltig (Seitenspalte, siehe
     style.css) - kein extra Mobile-Override mehr nötig. */

  .doubleTimeOption {
    display: flex !important;
    flex-direction: row !important;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    white-space: nowrap;
    width: 100%;
    grid-template-columns: unset !important;
  }

  .doubleTimeOption input {
    width: auto !important;
  }

  #doubleTimeToggle {
    margin-left: 10px;
    margin-right: 15px;
  }

  #startDefaultBtn {
    width: 100%;
    margin-top: 10px;
  }

  /* Vokabelkarten: auf Handys 2 pro Zeile (Basis-Regel ist jetzt fest
     5 Spalten für Desktop, siehe style.css #statsGrid/#boxGrid) */
  #statsGrid,
  #boxGrid {
    grid-template-columns: repeat(2, 1fr);
    row-gap: 16px;
    column-gap: 12px;
  }

  /* Antwortbuttons: dürfen umbrechen, gleich groß, gut tastbar */
  #antworten {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  #antworten.article-mode {
    grid-template-columns: 1fr;
  }

  #antworten button {
    font-size: 20px;
    padding: 18px;
    width: 100%;
    min-height: 54px;
  }

  #textAntwort {
    width: 100%;
    font-size: 18px;
  }

  #speakBtn {
    width: 100%;
    font-size: 18px;
    padding: 16px;
  }

  .wort-box {
    font-size: 28px;
  }

  .learn-answer {
    font-size: inherit;
    line-height: 1.2;
  }

  .highscoreBox {
    text-align: center;
    max-width: 100%;
  }

  #reactionBar,
  .flyingReaction,
  .rocketReaction,
  .spinReaction,
  .simpleReaction,
  .eyeRollReaction {
    display: none !important;
  }

  /* Theme-Toggle (Sonne/Mond-Schalter): ist "position:fixed" oben rechts
     und bleibt beim Scrollen immer an derselben Bildschirmstelle stehen.
     Auf Handys landet die Punkte-/Pause-Zeile beim Spielen aber genau
     dort -> das halbtransparente Blur-Panel + der orange Leucht-Schatten
     des Schalters lagen dadurch optisch über dem Pause-Button und der
     Sternebox. Auf Handys daher: kein Panel-Hintergrund/Blur/Glow mehr,
     nur noch der reine Schalter sichtbar (bleibt voll bedienbar).
     -> style.css bleibt unverändert, betrifft nur Desktop/Tablet nicht. */
  #themeToggle {
    transform: scale(0.85);
    background: transparent;
    backdrop-filter: none;
    box-shadow: none;
    padding: 4px;
  }

  .slider {
    box-shadow: none;
  }

  /* Fortschrittsbalken (Elefant, Häkchen-Segmente, Herz, Ananas) darf auf
     Handys nicht über den Spielbereich (#gameArea) hinausragen.
     - "92vw" bezog sich auf die volle Bildschirmbreite statt auf den
       tatsächlich verfügbaren Platz in #gameArea -> dadurch lief der
       Balken samt Kindern rechts (und leicht links) aus der Karte heraus.
     - Elefant (links, translateX(-50%)) und Ananas (rechts, "right:-Npx")
       ragen bewusst etwas über den eigentlichen Balken hinaus. Der
       Container bekommt daher links/rechts etwas Luft (48px), damit genau
       dieser Überstand noch innerhalb der Karte bleibt. */
  #progressContainer {
    width: calc(100% - 48px);
    max-width: calc(100% - 48px);
    height: 16px;
    margin-left: auto;
    margin-right: auto;
  }

  #progressElefant {
    width: 44px;
    top: -20px;
  }

  #bonusFruit {
    right: -14px;
    font-size: 34px;
  }

  #bonusHeart {
    font-size: 26px;
  }

  /* Timer-Leiste (Balken + "Xs"-Text): war fix 300px breit und dadurch
     auf schmalen Handys ebenfalls breiter als der Spielbereich. Jetzt
     schrumpft sie mit, statt aus der Karte zu laufen. */
  #timerWrapper {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    gap: 8px;
  }

  #timerBarContainer {
    flex: 1 1 auto;
    width: auto;
    min-width: 80px;
    max-width: 220px;
  }

  #timerText {
    flex: 0 0 auto;
    font-size: 14px;
  }

  /* Item-Lexikon / Achievements-Toggle: volle Breite auf Handys */
  #achievementsToggleBtn {
    width: 100%;
  }

  /* 🎓 Zertifikate: auf Handys grundlegend anderes Layout als am
     Desktop - das linke Padding (Platz für den Elefanten) und die
     absolute Positionierung von Medaille/Logo/Maskottchen würden auf
     schmalen Karten alles übereinander schieben. Elefant + Medaille +
     Logo werden daher in den normalen Textfluss zurückgeholt (stapeln
     sich übereinander statt nebeneinander), Stat-Boxen/Footer brechen
     um, Buttons stapeln sich. */
  .certificate-card {
    padding: 24px 16px 20px;
  }

  .certificate-bg-icons {
    display: none;
  }

  .certificate-medal {
    position: static;
    width: auto;
    margin: 0 auto 10px;
  }

  .certificate-medal-circle {
    width: 50px;
    height: 50px;
    font-size: 22px;
    border-width: 4px;
  }

  .certificate-ribbon {
    border-left-width: 10px;
    border-right-width: 10px;
    border-top-width: 24px;
  }

  .certificate-logo {
    position: static;
    text-align: center;
    margin-bottom: 10px;
  }

  .certificate-logo-word {
    font-size: 16px;
  }

  .certificate-logo-tagline {
    font-size: 10px;
  }

  .certificate-mascot {
    position: static;
    width: 130px;
    margin: 0 auto 10px;
  }

  .certificate-books {
    position: static;
    width: 96px;
    margin: 0 auto;
  }

  .certificate-book-bottom {
    width: 96px;
  }

  .certificate-book-top {
    width: 78px;
  }

  .certificate-elephant {
    width: 130px;
    margin-top: -30px;
  }

  .certificate-stars-row {
    margin-top: 8px;
  }

  .certificate-hr {
    width: 40px;
  }

  .certificate-title {
    font-size: 28px;
    letter-spacing: 1px;
  }

  .certificate-name {
    font-size: 32px;
  }

  .certificate-stats {
    gap: 10px;
  }

  .certificate-stat {
    min-width: 90px;
    padding: 10px 12px;
  }

  .certificate-footer {
    flex-wrap: wrap;
    justify-content: center;
    text-align: center;
    gap: 14px;
  }

  .certificate-footer-left {
    flex-direction: column;
    text-align: center;
  }

  .certificate-footer-right {
    text-align: center;
  }

  .certificate-actions {
    flex-direction: column;
    width: 100%;
    max-width: 400px;
  }

  .certificate-actions button {
    width: 100%;
  }

  /* 🐶 Dogdex: kleinere Kartenspalten auf Handys (2 pro Reihe) */
  .dogdex-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
  }

  .dogdex-grid-item {
    height: 260px;
  }

  .dog-stat-label {
    width: 46px;
    font-size: 9px;
  }
}


/* ======================================
   END
====================================== */
