/* =========================================================
   Lernspiele 2. Klasse – gemeinsames Design für alle Seiten
   ========================================================= */

* {
  box-sizing: border-box;
}

:root {
  --px: 5px;   /* Thermometer: Pixel pro Grad (auf dem Handy kleiner) */
}

body {
  margin: 0;
  padding: 16px;
  font-family: "Comic Sans MS", "Chalkboard SE", "Segoe UI", Arial, sans-serif;
  background: linear-gradient(#dff3ff, #fff6e0);
  background-attachment: fixed;
  color: #333;
  min-height: 100vh;
}

/* Kein Doppeltipp-Zoom auf iPad/Handy, kein grauer Blitz beim Tippen */
button {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

h1 {
  text-align: center;
  margin: 0 0 16px;
  font-size: 2rem;
}

.hidden    { display: none !important; }
.invisible { visibility: hidden; }

/* ---------- Zurück-Link ---------- */

.back {
  display: inline-block;
  padding: 8px 14px;
  background: white;
  border-radius: 12px;
  color: #333;
  text-decoration: none;
  font-weight: bold;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

.back:hover { background: #ffca28; }

/* ---------- Startseite ---------- */

.intro {
  text-align: center;
  font-size: 1.4rem;
}

.menu {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 24px;
  max-width: 1000px;
  margin: 24px auto 0;
}

.card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 24px 16px;
  background: white;
  border-radius: 24px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  color: #333;
  text-decoration: none;
  text-align: center;
  transition: transform 0.2s;
}

.card:hover { transform: scale(1.05); }

.card-icon  { font-size: 4.5rem; }
.card-title { font-size: 1.6rem; font-weight: bold; }
.card-text  { font-size: 1rem; color: #666; }

/* ---------- Grundlayout: Bild + Bedienung ---------- */

.layout {
  display: flex;
  gap: 32px;
  justify-content: center;
  align-items: flex-start;
  flex-wrap: wrap;
}

.layout.column {
  flex-direction: column;
  align-items: center;
}

.box {
  background: white;
  border-radius: 20px;
  padding: 20px 30px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  text-align: center;
}

.box.wide {
  width: 100%;
  max-width: 1100px;
  padding: 20px;
}

.panel {
  background: white;
  border-radius: 20px;
  padding: 20px;
  width: 380px;
  max-width: 100%;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.big-value {
  font-size: 2.5rem;
  font-weight: bold;
  margin-top: 10px;
}

.big-value.cold-text { color: #1565c0; }
.big-value.warm-text { color: #c62828; }

/* ---------- Tabs ---------- */

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.tab {
  flex: 1;
  padding: 10px 6px;
  font-size: 1rem;
  font-family: inherit;
  color: #333;
  border: none;
  border-radius: 12px;
  background: #eee;
  cursor: pointer;
}

.tab.active {
  background: #ffca28;
  font-weight: bold;
}

/* ---------- Eingaben und Knöpfe ---------- */

.hint {
  font-size: 1.15rem;
  margin: 8px 0;
}

.row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 12px 0;
  font-size: 1.1rem;
}

input[type="text"] {
  width: 120px;
  font-size: 2rem;
  text-align: center;
  padding: 6px;
  border: 3px solid #90caf9;
  border-radius: 12px;
  font-family: inherit;
}

select {
  font-size: 1rem;
  padding: 8px;
  border-radius: 10px;
  font-family: inherit;
  max-width: 100%;
}

.unit {
  font-size: 2rem;
  font-weight: bold;
}

.step {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  font-size: 2rem;
  color: #333;
  border: none;
  border-radius: 50%;
  background: #e0e0e0;
  cursor: pointer;
}

.go,
.next,
.help {
  display: block;
  width: 100%;
  padding: 14px;
  margin-top: 10px;
  font-size: 1.3rem;
  font-family: inherit;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  color: white;
}

.go   { background: #43a047; }
.next { background: #7e57c2; }
.help { background: #fbc02d; color: #333; }

.go:hover, .next:hover, .help:hover, .step:hover { filter: brightness(1.1); }

.message {
  font-size: 1.3rem;
  text-align: center;
  min-height: 1.6em;
  margin: 10px 0;
}

.message.right { color: #2e7d32; font-weight: bold; }
.message.wrong { color: #c62828; font-weight: bold; }

.score {
  text-align: center;
  font-size: 1.2rem;
}

/* ---------- Zahlenfeld ---------- */

.numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  max-width: 260px;
  margin: 0 auto;
}

.num {
  height: 54px;
  font-size: 1.7rem;
  font-weight: bold;
  font-family: inherit;
  color: #333;
  border: none;
  border-radius: 12px;
  background: #e3f2fd;
  cursor: pointer;
}

.num:active { background: #90caf9; }
.num-special { background: #ffe0b2; }

/* ---------- Thermometer ---------- */

.thermo {
  position: relative;
  width: 140px;
  height: calc(var(--px) * 100 + 90px);
  margin: 0 auto;
}

.scale {
  position: absolute;
  left: 0;
  top: 10px;
  width: 70px;
  height: calc(var(--px) * 100);
}

.tick {
  position: absolute;
  right: 0;
  height: 2px;
  background: #666;
  transform: translateY(50%);
}

.tick.small  { width: 8px;  height: 1px; background: #aaa; }
.tick.medium { width: 14px; }
.tick.big    { width: 22px; height: 3px; background: #333; }
.tick.zero   { width: 30px; height: 4px; background: black; }

.tick-label {
  position: absolute;
  right: 28px;
  transform: translateY(50%);
  font-size: 14px;
  font-weight: bold;
}

.tick-label.neg  { color: #1565c0; }
.tick-label.pos  { color: #c62828; }
.tick-label.zero { font-size: 18px; color: black; right: 36px; }

.tube {
  position: absolute;
  left: 75px;
  top: 0;
  width: 30px;
  height: calc(var(--px) * 100 + 30px);
  background: #f4f4f4;
  border: 3px solid #999;
  border-bottom: none;
  border-radius: 15px 15px 0 0;
  overflow: hidden;
}

.mercury {
  position: absolute;
  bottom: 0;
  left: 4px;
  right: 4px;
  height: 0;
  border-radius: 8px 8px 0 0;
  transition: height 0.8s ease;
  /* Wie im Schulbuch: bis zur 0-Linie blau, darüber rot.
     Die 0-Linie liegt 50 Grad + 20px über dem Boden der Säule. */
  background: linear-gradient(
    to top,
    #1e88e5 calc(var(--px) * 50 + 20px),
    #e53935 calc(var(--px) * 50 + 20px)
  );
}

.bulb {
  position: absolute;
  left: 60px;
  top: calc(var(--px) * 100 + 20px);
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 3px solid #999;
  background: #1e88e5;   /* die Kugel ist immer unter 0, also blau */
}


/* ---------- Meterstab ---------- */

#ruler {
  width: 100%;
  height: auto;
}

.rotate-hint {
  display: none;
  margin: 0 0 6px;
  font-size: 0.95rem;
  color: #7e57c2;
  font-weight: bold;
}

/* ---------- Kompass ---------- */

.compass {
  width: 320px;
  max-width: 100%;
  height: auto;
}

#needle {
  transform-origin: 150px 150px;
  transition: transform 1s ease;
}

.merk {
  font-size: 1.1rem;
  margin: 6px 0 0;
}

.dir-grid {
  display: grid;
  grid-template-columns: repeat(3, 76px);
  gap: 10px;
  justify-content: center;
  margin: 16px 0;
}

.dir {
  height: 64px;
  font-size: 1.6rem;
  font-weight: bold;
  font-family: inherit;
  color: #333;
  border: none;
  border-radius: 14px;
  background: #90caf9;
  cursor: pointer;
}

.dir.diag {
  font-size: 1.2rem;
  background: #c5e1a5;
}

.dir:hover { filter: brightness(1.1); }

.dir-center {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
}

/* richtig / falsch bei Kompass- und Uhr-Knöpfen */
.dir.correct, .choice.correct { background: #43a047; color: white; }
.dir.wrong,   .choice.wrong   { background: #e53935; color: white; }

/* ---------- Uhr ---------- */

.clock {
  width: 340px;
  max-width: 100%;
  height: auto;
}

.hand {
  transform-origin: 180px 180px;
  transition: transform 0.8s ease;
}

.time-words {
  font-size: 1.4rem;
  color: #555;
  min-height: 1.4em;
}

.legend {
  font-size: 1rem;
  line-height: 1.7;
  margin: 6px 0;
}

.dot-red, .dot-blue {
  display: inline-block;
  width: 26px;
  height: 8px;
  border-radius: 4px;
  vertical-align: middle;
}

.dot-red  { background: #e53935; width: 18px; height: 10px; }
.dot-blue { background: #1e88e5; width: 30px; height: 6px; }

.task {
  font-size: 1.3rem;
  text-align: center;
  background: #fff8e1;
  border-radius: 12px;
  padding: 10px;
}

.set-label {
  width: 90px;
  font-weight: bold;
}

.set-label.red  { color: #c62828; }
.set-label.blue { color: #1565c0; }

.choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 12px 0;
}

.choice {
  padding: 12px 6px;
  font-size: 1.05rem;
  font-family: inherit;
  font-weight: bold;
  color: #333;
  border: none;
  border-radius: 14px;
  background: #e3f2fd;
  cursor: pointer;
}

.choice small {
  display: block;
  font-weight: normal;
  font-size: 0.9rem;
  margin-top: 4px;
}

.check {
  display: block;
  text-align: center;
  margin-top: 14px;
  font-size: 0.95rem;
  color: #666;
}

/* ---------- Geld ---------- */

.tray {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  align-items: center;
  min-height: 120px;
  padding: 14px;
  background: #d7b98e;
  border-radius: 16px;
  box-shadow: inset 0 0 0 4px #b8925f;
}

.tray-empty {
  color: #6d4c41;
  font-size: 1.1rem;
}

.palette {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  align-items: center;
  margin: 12px 0;
}

.coin,
.note {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
  font-family: inherit;
  cursor: pointer;
}

.coin:disabled, .note:disabled { cursor: default; }

.coin {
  border-radius: 50%;
  border: 3px solid;
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.3);
}

.coin b     { font-size: 1.05rem; }
.coin small { font-size: 0.5rem; }

.copper { background: radial-gradient(#e8a96b, #b87333); border-color: #8b4513; color: #3e1f00; }
.gold   { background: radial-gradient(#ffe082, #d4a017); border-color: #b8860b; color: #4e3b00; }
.euro1  { background: radial-gradient(circle, #e0e0e0 55%, #e0b030 57%); border-color: #b8860b; color: #333; }
.euro2  { background: radial-gradient(circle, #f2c94c 55%, #c8c8c8 57%); border-color: #9e9e9e; color: #333; }

.note {
  width: 96px;
  height: 54px;
  border-radius: 6px;
  border: 2px solid rgba(0, 0, 0, 0.25);
  color: white;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.3);
}

.note b     { font-size: 1.4rem; }
.note small { font-size: 0.7rem; }

.n5   { background: linear-gradient(135deg, #9e9e9e, #757575); }
.n10  { background: linear-gradient(135deg, #e57373, #c62828); }
.n20  { background: linear-gradient(135deg, #64b5f6, #1565c0); }
.n50  { background: linear-gradient(135deg, #ffb74d, #e65100); }
.n100 { background: linear-gradient(135deg, #81c784, #2e7d32); }

/* ---------- Einmaleins ---------- */

.dots {
  display: grid;
  gap: 6px;
  justify-content: center;
  margin: 14px auto;
  min-height: 20px;
}

.dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
}

.dot.red  { background: #e53935; }
.dot.blue { background: #1e88e5; }

.sum-line {
  font-size: 1.2rem;
  color: #555;
  min-height: 1.4em;
  margin: 4px 0 0;
}

.factor {
  width: 50px;
  font-size: 2rem;
  font-weight: bold;
  text-align: center;
}

.row-picker {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin-bottom: 8px;
}

.row-btn {
  padding: 8px 0;
  font-size: 1rem;
  font-family: inherit;
  color: #333;
  border: none;
  border-radius: 10px;
  background: #eee;
  cursor: pointer;
}

.row-btn.active {
  background: #66bb6a;
  color: white;
  font-weight: bold;
}

/* =========================================================
   Handy (und kleine Tablets)
   ========================================================= */

@media (max-width: 700px), (max-height: 760px) {
  :root { --px: 3.6px; }
}

@media (max-width: 700px) {
  body { padding: 8px; }

  h1 {
    font-size: 1.4rem;
    margin: 6px 0 10px;
  }

  .back {
    padding: 5px 10px;
    font-size: 0.9rem;
  }

  .intro { font-size: 1.1rem; }

  .menu {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 12px;
  }

  .card        { padding: 14px 8px; border-radius: 18px; }
  .card-icon   { font-size: 3rem; }
  .card-title  { font-size: 1.2rem; }
  .card-text   { font-size: 0.85rem; }

  .layout { gap: 12px; }

  /* Thermometer und Bedienung nebeneinander */
  .layout.side {
    flex-wrap: nowrap;
    gap: 8px;
  }

  .layout.side .panel {
    flex: 1;
    min-width: 0;
  }

  .box       { padding: 10px; }
  .box.wide  { padding: 10px; }
  .panel     { padding: 12px; width: 100%; }

  /* Bild bleibt beim Scrollen oben sichtbar */
  .sticky-mobile {
    position: sticky;
    top: 0;
    z-index: 10;
  }

  .big-value  { font-size: 1.6rem; margin-top: 4px; }
  .time-words { font-size: 1.1rem; }

  .tabs { gap: 4px; }
  .tab  { font-size: 0.85rem; padding: 8px 2px; }

  .hint    { font-size: 1rem; }
  .row     { gap: 6px; margin: 8px 0; }
  .message { font-size: 1.05rem; }

  input[type="text"] { width: 90px; font-size: 1.6rem; padding: 4px; }
  .unit  { font-size: 1.5rem; }
  .step  { width: 46px; height: 46px; font-size: 1.6rem; }
  .num   { height: 46px; font-size: 1.5rem; }

  .go, .next, .help { padding: 10px; font-size: 1.1rem; }

  /* Thermometer schmaler */
  .thermo      { width: 104px; }
  .scale       { width: 46px; }
  .tube        { left: 54px; width: 24px; }
  .bulb        { left: 41px; width: 50px; height: 50px; }
  .tick-label  { font-size: 12px; right: 24px; }
  .tick-label.zero { font-size: 14px; right: 30px; }
  .tick.zero   { width: 26px; }

  /* Kompass, Uhr, Geld, Punkte kleiner */
  .compass  { width: 220px; }
  .clock    { width: 230px; }
  .merk     { font-size: 0.9rem; }
  .legend   { font-size: 0.9rem; }
  .dir-grid { grid-template-columns: repeat(3, 66px); gap: 8px; margin: 10px 0; }
  .dir      { height: 52px; }

  .tray   { min-height: 80px; gap: 6px; padding: 8px; }
  .note   { width: 78px; height: 44px; }
  .note b { font-size: 1.1rem; }

  .dot  { width: 15px; height: 15px; }
  .dots { gap: 4px; margin: 8px auto; }
  .sum-line { font-size: 1rem; }
}

/* Handy hochkant: Hinweis "quer drehen" beim Meterstab */
@media (max-width: 700px) and (orientation: portrait) {
  .rotate-hint { display: block; }
}
