/* Morse-Station Simulator – Design wie ui/Theme.kt: viel Papier, Tinte für Text, Ballfarben nur als Akzent, Gelb nur für Rahmen.
   Alle Maße im Tablet-Bereich (#canvas) sind dp der App; die Fläche wird per JS als Ganzes skaliert. */

@font-face { font-family: "Fredoka"; src: url("../assets/fonts/fredoka_semibold.ttf") format("truetype"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Fredoka"; src: url("../assets/fonts/fredoka_bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Atkinson"; src: url("../assets/fonts/atkinson_regular.otf") format("opentype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Atkinson"; src: url("../assets/fonts/atkinson_bold.otf") format("opentype"); font-weight: 700; font-display: swap; }

:root {
  --ink: #1A2340;
  --paper: #F7F8FC;
  --white: #FFFFFF;
  --red: #D63339;
  --yellow: #F6C21C;
  --green: #2E9E57;
  --ink60: rgba(26, 35, 64, 0.6);
  --ink70: rgba(26, 35, 64, 0.7);
  --ink35: rgba(26, 35, 64, 0.35);
  --ink20: rgba(26, 35, 64, 0.2);
  --ink15: rgba(26, 35, 64, 0.15);
  --ink10: rgba(26, 35, 64, 0.1);
  --ink07: rgba(26, 35, 64, 0.07);
  color-scheme: light;
}

[hidden] { display: none !important; }

html, body { margin: 0; height: 100%; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: "Atkinson", system-ui, sans-serif;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

#app { position: fixed; inset: 0; display: flex; flex-direction: row; }
body.portrait #app { flex-direction: column; }

#stage { position: relative; flex: 1 1 auto; min-width: 0; min-height: 0; overflow: hidden; background: var(--paper); }
#canvas { position: absolute; top: 0; left: 0; transform-origin: 0 0; overflow: hidden; }
#screen { position: absolute; inset: 0; }

/* ---- Taste ------------------------------------------------------------------------------- */
#dock {
  position: relative;
  flex: 0 0 auto;
  width: clamp(124px, 20vw, 260px);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  padding: 28px 12px calc(12px + env(safe-area-inset-bottom)) 12px;
  padding-right: calc(12px + env(safe-area-inset-right));
  box-sizing: border-box;
  border-left: 1px solid var(--ink10);
  background: #EEF0F7;
}
body.portrait #dock {
  width: auto;
  height: clamp(140px, 24vh, 230px);
  border-left: 0;
  border-top: 1px solid var(--ink10);
  padding: 22px 16px calc(10px + env(safe-area-inset-bottom));
}
.back {
  position: absolute; top: 8px; left: 0; right: 0;
  text-align: center;
  font: 400 12px/1.2 "Atkinson", system-ui, sans-serif;
  color: var(--ink60);
  text-decoration: none;
}
.back:hover, .back:focus-visible { color: var(--ink); text-decoration: underline; }
body.portrait .back { left: 12px; right: auto; text-align: left; }

#key {
  width: min(100%, 52vh, 220px);
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  border: 6px solid var(--white);
  background: var(--ink);
  color: var(--white);
  font: 600 clamp(13px, 2.2vmin, 20px)/1.1 "Fredoka", system-ui, sans-serif;
  letter-spacing: 0.04em;
  box-shadow: 0 7px 0 #0B1124, 0 12px 22px rgba(26, 35, 64, 0.3);
  cursor: pointer;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  padding: 0;
  transition: transform 40ms, box-shadow 40ms;
}
#key.down { transform: translateY(5px); box-shadow: 0 2px 0 #0B1124, 0 4px 8px rgba(26, 35, 64, 0.3); }
#key:focus-visible { outline: 4px solid var(--yellow); outline-offset: 4px; }
body.portrait #key { width: auto; height: min(100%, 60vw); flex: 0 1 auto; min-height: 0; }
.key-hint { margin: 0; font-size: 12px; color: var(--ink60); text-align: center; }
@media (hover: none), (pointer: coarse) { .key-hint { display: none; } }
.noscript { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 20px; background: var(--paper); }

/* ---- Grundbausteine (Theme.kt) ----------------------------------------------------------- */
.title { font-family: "Fredoka", system-ui, sans-serif; font-weight: 700; color: var(--ink); text-align: center; line-height: 1.1; margin: 0; }
.body { font-family: "Atkinson", system-ui, sans-serif; font-weight: 400; color: var(--ink); text-align: center; line-height: 1.4; }

.btn {
  font-family: "Fredoka", system-ui, sans-serif; font-weight: 600; font-size: 32px; line-height: 1.2;
  border-radius: 28px; border: 0; padding: 22px 40px;
  background: var(--ink); color: var(--white);
  cursor: pointer; touch-action: manipulation; box-sizing: border-box;
  display: inline-flex; align-items: center; justify-content: center; white-space: nowrap;
}
.btn.secondary { background: var(--white); color: var(--ink); border: 3px solid var(--ink); }
.btn.compact { padding: 10px 22px; }
.btn.disabled { background: var(--ink15); cursor: default; }
.btn:focus-visible { outline: 4px solid var(--yellow); outline-offset: 3px; }
.restart { position: absolute; top: 16px; right: 16px; font-size: 18px; z-index: 5; white-space: pre; }

.centered { position: absolute; inset: 0; padding: 48px; box-sizing: border-box; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.column { position: absolute; inset: 0; padding: 24px 48px; box-sizing: border-box; display: flex; flex-direction: column; align-items: center; }
.grow { flex: 1 1 0; min-height: 0; }

/* Morsezeichen (Components.kt) */
.sigs { display: flex; align-items: center; }
.sig { display: block; flex: 0 0 auto; box-sizing: border-box; background: var(--ink); }
.sig.ink { background: var(--ink); }
.sig.green { background: var(--green); }
.sig.faded { background: var(--ink20); }
.sig.soft { background: rgba(26, 35, 64, 0.75); }
.sig.active { background: var(--ink); border: 4px solid var(--yellow); animation: pulse 500ms ease-in-out infinite alternate; }
.sig.active.wrong { background: var(--red); }
.sig.listen { animation: listen 300ms ease-in-out infinite alternate; }
@keyframes pulse { from { transform: scale(1); } to { transform: scale(1.12); } }
@keyframes listen { from { opacity: 0.35; } to { opacity: 1; } }

.badge { display: flex; align-items: center; gap: 12px; border: 3px solid var(--yellow); border-radius: 20px; padding: 6px 18px; flex: 0 0 auto; }
.badge-t { font-family: "Fredoka", system-ui, sans-serif; font-weight: 700; font-size: 18px; }
.badge-s { font-size: 18px; line-height: 1.3; }

.hint { height: 56px; display: flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.hint-row { display: flex; align-items: center; gap: 14px; }
.dot-red { width: 18px; height: 18px; border-radius: 50%; background: var(--red); flex: 0 0 auto; }
.hint-text { font-size: 28px; }

.bottom-row { position: relative; width: 100%; height: 100px; display: flex; justify-content: center; flex: 0 0 auto; }
.bottom-center { display: flex; justify-content: center; }
.replay { position: absolute; right: 0; top: 50%; transform: translateY(-50%); font-size: 22px; }
.press { height: 100px; display: flex; flex-direction: column; align-items: center; }
.press-box { width: 132px; height: 44px; display: flex; align-items: center; justify-content: center; }
.press-shape { height: 44px; border-radius: 22px; box-sizing: border-box; }
.press-shape.idle { border: 3px solid var(--ink20); }
.press-shape.on { background: var(--ink); }
.press-label { font-size: 22px; margin-top: 8px; line-height: 1.3; }

/* ---- Idle --------------------------------------------------------------------------------- */
.idle-box { position: absolute; inset: 0; cursor: pointer; }
.logo { height: 170px; width: auto; display: block; }
.idle-title { font-size: 96px; margin-top: 24px; }
.idle-row { display: flex; gap: 32px; align-items: center; margin-top: 40px; }
.idle-col { display: flex; flex-direction: column; align-items: center; }
.idle-letter { font-size: 40px; margin-top: 10px; }
.idle-letter.dim { color: var(--ink35); }
.idle-start { font-size: 56px; margin-top: 48px; }
.idle-sub { font-size: 28px; }
.privacy { position: absolute; left: 0; right: 0; bottom: 14px; margin: 0 auto; width: max-content; max-width: 90%; font-size: 15px; color: var(--ink60); text-decoration: underline; text-decoration-color: var(--ink20); text-underline-offset: 3px; }
.privacy:hover, .privacy:focus-visible { color: var(--ink); }

/* ---- Sprache ------------------------------------------------------------------------------ */
.lang-title { font-size: 56px; }
.lang-sub { font-size: 40px; color: var(--ink60); }
.lang-row { display: flex; gap: 48px; margin-top: 56px; }
.lang-col { display: flex; flex-direction: column; align-items: center; }
.lang-btn { width: 360px; height: 160px; font-size: 44px; }
.lang-sig { height: 40px; margin-top: 28px; display: flex; align-items: center; justify-content: center; }
.lang-hint { font-size: 24px; color: var(--ink70); margin-top: 10px; }
.lang-foot { font-size: 22px; color: var(--ink60); margin-top: 36px; }

/* ---- Intro -------------------------------------------------------------------------------- */
.intro-title { font-size: 48px; margin-top: 12px; }
.intro-row { display: flex; gap: 36px; align-items: center; margin-top: 20px; }
.intro-photo { width: 420px; display: flex; flex-direction: column; align-items: center; }
.intro-img { width: 420px; height: 280px; object-fit: cover; border-radius: 16px; display: block; }
.intro-caption { font-size: 15px; color: var(--ink60); margin-top: 6px; }
.intro-text { width: 460px; display: flex; flex-direction: column; align-items: center; }
.intro-body { font-size: 22px; }
.sos { display: flex; gap: 28px; align-items: center; margin-top: 20px; }
.sos-col { display: flex; flex-direction: column; align-items: center; }
.sos-letter { font-size: 32px; }
.intro-btn { font-size: 30px; }
.intro-key { font-size: 20px; color: var(--ink60); margin-top: 8px; }

/* ---- Lernen ------------------------------------------------------------------------------- */
.learn-title { font-size: 56px; margin-top: 16px; }
.learn-sig { margin-top: 28px; height: 120px; display: flex; align-items: center; }
.learn-msg { margin-top: 32px; padding: 12px 32px; border: 4px solid transparent; border-radius: 24px; }
.learn-msg.framed { border-color: var(--yellow); }
.learn-msg-t { font-size: 36px; }
.learn-dots { display: flex; gap: 12px; margin-top: 16px; margin-bottom: 24px; }
.ldot { width: 22px; height: 22px; border-radius: 50%; background: var(--ink15); }
.ldot.on { background: var(--green); }

/* ---- Nachricht tippen --------------------------------------------------------------------- */
.compose { padding: 20px 40px 12px; }
.compose-head { width: 100%; height: 52px; padding-right: 200px; box-sizing: border-box; display: flex; align-items: center; flex: 0 0 auto; }
.compose-title { font-size: 30px; text-align: left; }
.compose-input {
  margin-top: 16px; width: 100%; max-width: 860px; min-height: 64px; box-sizing: border-box;
  background: var(--white); border: 3px solid var(--yellow); border-radius: 20px; padding: 8px 28px;
  display: flex; align-items: center; gap: 12px; flex: 0 0 auto;
}
.compose-text {
  flex: 1 1 auto; min-width: 0; text-align: left;
  font-family: "Fredoka", system-ui, sans-serif; font-weight: 600; font-size: 38px; line-height: 40px; color: var(--ink);
  overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.compose-text.s { font-size: 28px; line-height: 34px; }
.compose-text.xs { font-size: 22px; line-height: 28px; }
.compose-text.empty { color: var(--ink35); }
.compose-count { font-size: 20px; color: var(--ink60); flex: 0 0 auto; }
.ideas-box { margin-top: 12px; min-height: 44px; display: flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.ideas { display: flex; gap: 10px; align-items: center; justify-content: center; flex-wrap: wrap; }
.ideas-label { font-size: 20px; color: var(--ink60); }
.chip { height: 44px; border-radius: 22px; background: var(--ink07); color: var(--ink); padding: 0 18px; font-size: 18px; }
.kb { display: flex; flex-direction: column; align-items: center; flex: 0 0 auto; }
.kb-row { display: flex; gap: 6px; margin-bottom: 6px; }
.kb-last { gap: 16px; align-items: center; margin-bottom: 0; }
.kkey {
  width: 64px; height: 56px; padding: 0; border-radius: 14px;
  background: var(--white); color: var(--ink); border: 2px solid rgba(26, 35, 64, 0.5); font-size: 28px;
}
.kkey:active { background: var(--ink07); }
.kkey.wide { width: 120px; }
.kkey.space { width: 420px; }
.done-btn { font-size: 22px; }

/* ---- Morsen ------------------------------------------------------------------------------- */
.morse { padding: 32px 48px; }
.morse .badge { margin-bottom: 8px; }
.morse-title { font-size: 34px; padding: 0 240px; }
.msg-line { display: flex; gap: 4px; margin-top: 16px; flex: 0 0 auto; }
.msg-c {
  width: 44px; height: 64px; box-sizing: border-box; border: 4px solid transparent; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-family: "Fredoka", system-ui, sans-serif; font-weight: 700; font-size: 40px; color: var(--ink);
}
.msg-c.cur { border-color: var(--yellow); }
.msg-c.future { color: rgba(26, 35, 64, 0.3); }
.progress { margin-top: 12px; width: 100%; max-width: 1000px; height: 8px; border-radius: 4px; background: var(--ink10); flex: 0 0 auto; overflow: hidden; }
.progress-fill { height: 100%; background: var(--ink); border-radius: 4px; }
.morse-main { display: flex; align-items: center; gap: 56px; flex: 0 0 auto; }
.morse-char { font-size: 170px; line-height: 1; }
.morse-great { font-size: 36px; }

/* ---- Geschafft ---------------------------------------------------------------------------- */
.done-box { position: absolute; inset: 0; }
.confetti { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.done { pointer-events: none; }
.done .btn { pointer-events: auto; }
.done-title { font-size: 96px; }
.done-title.long { font-size: 64px; }
.done-text { font-size: 56px; max-width: 1000px; overflow-wrap: anywhere; }
.done-text.s { font-size: 34px; }
.done-text.xs { font-size: 26px; }
.morse-line { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; max-width: 1000px; margin-top: 12px; }
.ml-char { display: flex; align-items: center; }
.ml-space { display: block; height: 1px; }
.done-sim { font-size: 22px; color: var(--ink60); margin-top: 36px; max-width: 760px; }
.done-finish { font-size: 28px; margin-top: 20px; }

/* ---- Timeout ------------------------------------------------------------------------------ */
.countdown { position: absolute; inset: 0; z-index: 10; background: rgba(26, 35, 64, 0.88); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; box-sizing: border-box; }
.countdown .title, .countdown .body { color: var(--white); }
.cd-title { font-size: 64px; }
.cd-num { font-size: 160px; }
.cd-body { font-size: 28px; }

/* ---- Hochformat (Tablet-Fläche 700 dp breit) ----------------------------------------------- */
body.portrait .centered { padding: 48px 32px; }
body.portrait .column { padding: 24px 32px; }
body.portrait .logo { height: 130px; }
body.portrait .idle-title { font-size: 76px; }
body.portrait .idle-row { gap: 22px; }
body.portrait .idle-start { font-size: 52px; }
body.portrait .lang-title { font-size: 50px; }
body.portrait .lang-sub { font-size: 36px; }
body.portrait .lang-row { gap: 36px; }
body.portrait .lang-btn { width: 280px; height: 150px; font-size: 42px; }
body.portrait .intro { padding-top: 76px; }
body.portrait .intro .badge { position: absolute; top: 22px; left: 32px; }
body.portrait .intro-row { flex-direction: column; gap: 20px; }
body.portrait .intro-text { width: 100%; max-width: 620px; }
body.portrait .learn { padding-top: 76px; }
body.portrait .learn .badge { position: absolute; top: 22px; left: 32px; }
body.portrait .learn-msg-t { font-size: 34px; }
body.portrait .bottom-row { height: auto; flex-direction: column; align-items: center; gap: 6px; }
body.portrait .replay { position: static; transform: none; }
body.portrait .compose { padding: 20px 24px 16px; }
body.portrait .compose-head { height: auto; min-height: 52px; padding-right: 190px; }
body.portrait .compose-title { font-size: 30px; }
body.portrait .kkey { width: 53px; height: 60px; }
body.portrait .kkey.wide { width: 104px; }
body.portrait .kkey.space { width: 300px; }
body.portrait .kb-last { flex-direction: column; gap: 14px; }
body.portrait .morse { padding: 24px 32px; }
body.portrait .morse.tut { padding-top: 76px; }
body.portrait .morse.tut .badge { position: absolute; top: 22px; left: 32px; margin: 0; }
body.portrait .morse:not(.tut) .morse-title { margin-top: 64px; }
body.portrait .morse-title { padding: 0; }
body.portrait .morse-main { flex-direction: column; gap: 28px; }
body.portrait .morse-char { font-size: 160px; }
body.portrait .done-title { font-size: 80px; }
body.portrait .done-title.long { font-size: 60px; }
body.portrait .done-text { max-width: 100%; }

@media (prefers-reduced-motion: reduce) {
  .sig.active, .sig.listen { animation: none; }
  #key { transition: none; }
}
