/* Kite-Lernspiel – Layout für Handy hochkant: Spielbild | Bar-Feld | Knöpfe, alles ohne Scrollen (100dvh). */
:root {
  --navy: #0b2440;
  --teal: #2ec4b6;
  --teal-d: #1a9e92;
  --red: #e5484d;
  --blue: #3b82f6;
  --green: #34d399;
  --ink: #0b2440;
  --paper: #f6fbfb;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--navy); color: #fff; font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { overflow: hidden; overscroll-behavior: none; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
button { font: inherit; cursor: pointer; }

#app {
  position: relative;
  height: 100vh; height: 100dvh;
  display: grid;
  grid-template-rows: 1fr minmax(150px, 27dvh) calc(56px + var(--safe-b));
  max-width: 820px; margin: 0 auto;
}
#view { position: relative; overflow: hidden; min-height: 0; }
#scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* --- Anzeigen über dem Spielbild */
#hud { position: absolute; inset: 0; pointer-events: none; }
.step-card {
  position: absolute; left: 8px; right: 140px; top: 8px;
  display: flex; flex-direction: column; gap: 2px;
  padding: 8px 10px; border-radius: 12px;
  background: rgba(11, 36, 64, .78); backdrop-filter: blur(4px);
  font-size: .86rem;
}
.step-card strong { font-size: .98rem; color: var(--teal); }
.hud-right { position: absolute; right: 8px; top: 8px; width: 124px; display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
#clock { width: 124px; height: 72px; border-radius: 12px; background: rgba(11, 36, 64, .78); }
.gauges { padding: 6px 8px; border-radius: 12px; background: rgba(11, 36, 64, .78); font-size: .75rem; font-variant-numeric: tabular-nums; }
.gauges .g-row { display: flex; justify-content: space-between; gap: 6px; }
.gauges .g-bar { height: 5px; border-radius: 3px; background: rgba(255,255,255,.15); margin: 2px 0 4px; overflow: hidden; }
.gauges .g-bar i { display: block; height: 100%; background: var(--teal); }
.gauges .g-bar i.hot { background: var(--red); }
.choices { position: absolute; left: 0; right: 0; top: 42%; display: flex; justify-content: center; gap: 24px; pointer-events: auto; }
.choices button { width: 92px; height: 72px; border: 0; border-radius: 18px; background: var(--teal); color: var(--navy); font-size: 2rem; font-weight: 800; box-shadow: 0 6px 20px rgba(0,0,0,.3); }
.toasts { position: absolute; left: 8px; right: 8px; bottom: 10px; display: flex; flex-direction: column; gap: 6px; align-items: center; }
.toast { max-width: 520px; width: 100%; padding: 9px 12px; border-radius: 12px; font-size: .84rem; box-shadow: 0 6px 18px rgba(0,0,0,.25); animation: tin .2s ease-out; }
.toast b { display: block; font-size: .92rem; }
.toast--error { background: rgba(160, 30, 40, .94); }
.toast--ok { background: rgba(20, 130, 100, .94); }
.toast--info { background: rgba(11, 60, 100, .92); }
@keyframes tin { from { transform: translateY(8px); opacity: 0; } }
.hud-btns { display: flex; justify-content: flex-end; gap: 6px; }
.hud-btn { pointer-events: auto; width: 40px; height: 38px; border: 0; border-radius: 10px;
  background: rgba(11,36,64,.7); color: #fff; font-size: 1.1rem; }
.hud-btn.on { background: var(--teal-d); }
#debug { position: absolute; left: 8px; right: 140px; top: 104px; overflow: hidden; margin: 0; padding: 6px 8px; border-radius: 8px; background: rgba(0,0,0,.65);
  font: 11px/1.35 ui-monospace, Menlo, Consolas, monospace; color: #b8f5ec; white-space: pre; pointer-events: none; }

/* --- Bar-Feld */
#barfield { position: relative; background: linear-gradient(#0d2b4d, #08192d); border-top: 1px solid rgba(255,255,255,.08); }
#bar { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; }

/* --- Knöpfe */
#buttons { display: grid; grid-template-columns: 1fr 76px; gap: 8px; padding: 8px 8px calc(8px + var(--safe-b)); background: #08192d; }
.btn-action { border: 0; border-radius: 14px; background: var(--teal); color: var(--navy); font-weight: 800; font-size: 1.05rem; }
.btn-action:disabled { background: #22405f; color: rgba(255,255,255,.45); }
.btn-action.held { background: #fff; }
.btn-hint { align-self: center; color: rgba(255,255,255,.5); font-size: .8rem; padding-left: 6px; }
#btn-action[hidden] { display: none; }
.btn-qr { border: 0; border-radius: 14px; background: var(--red); color: #fff; font-weight: 900; letter-spacing: .04em; }

/* --- Bildschirme (Menü, Ende) */
.screen { position: absolute; inset: 0; z-index: 10; overflow-y: auto; background: linear-gradient(160deg, #0b2440 0%, #0f3a5e 55%, #136b7a 100%); }
.screen[hidden] { display: none; }
.screen-inner { max-width: 520px; margin: 0 auto; padding: 28px 18px 40px; }
.brand { margin: 0; color: var(--teal); font-weight: 800; letter-spacing: .08em; text-transform: uppercase; font-size: .78rem; }
.screen h1, .screen h2 { margin: 4px 0 8px; font-size: 1.9rem; line-height: 1.1; }
.lead { color: rgba(255,255,255,.85); margin: 0 0 16px; }
.settings { display: grid; gap: 12px; padding: 14px; border-radius: 16px; background: rgba(255,255,255,.07); margin-bottom: 16px; }
.settings label { display: grid; gap: 6px; font-weight: 600; font-size: .9rem; }
.settings label output { font-weight: 400; color: var(--teal); margin-left: 6px; }
.settings label.chk { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.settings input[type=range] { width: 100%; accent-color: var(--teal); }
.seg { display: flex; gap: 6px; }
.seg button { flex: 1; padding: 9px 0; border: 1px solid rgba(255,255,255,.25); border-radius: 10px; background: transparent; color: #fff; font-weight: 700; }
.seg button.on { background: var(--teal); color: var(--navy); border-color: var(--teal); }
.lessons { display: grid; gap: 8px; margin-bottom: 16px; }
.btn-primary, .btn-ghost { padding: 13px 16px; border-radius: 14px; font-weight: 800; font-size: 1rem; text-align: left; }
.btn-primary { border: 0; background: var(--teal); color: var(--navy); }
.btn-ghost { border: 1px solid rgba(255,255,255,.25); background: transparent; color: #fff; }
.btn-ghost:disabled { opacity: .5; cursor: default; }
.btn-ghost small, .btn-primary small { font-weight: 500; opacity: .75; }
.howto { background: rgba(255,255,255,.06); border-radius: 14px; padding: 10px 14px; margin-bottom: 14px; font-size: .88rem; }
.howto summary { cursor: pointer; font-weight: 700; }
.howto ul { padding-left: 18px; margin: 8px 0 0; }
.howto li { margin-bottom: 4px; }
.disclaimer { font-size: .8rem; color: rgba(255,255,255,.7); border-left: 3px solid var(--teal); padding-left: 10px; }
.links { font-size: .85rem; }
.links a { color: var(--teal); }
#end-list .err { background: rgba(255,255,255,.07); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; font-size: .88rem; }
#end-list .err b { color: #ffb4b4; }
#end-list .good { background: rgba(52,211,153,.15); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; font-size: .88rem; }

@media (min-width: 821px) { #app { border-left: 1px solid rgba(255,255,255,.06); border-right: 1px solid rgba(255,255,255,.06); } }
@media (max-height: 560px) { #app { grid-template-rows: 1fr minmax(120px, 30dvh) calc(52px + var(--safe-b)); } .step-card { font-size: .78rem; } }

/* 01.12.: Modus-Wahl, Anleitung, Sprungknopf */
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 4px 0 12px; }
.mode { display: grid; gap: 2px; justify-items: start; text-align: left; padding: 14px 14px 12px; border-radius: 16px; border: 1px solid rgba(255,255,255,.25);
  background: rgba(255,255,255,.07); color: #fff; font: inherit; cursor: pointer; }
.mode b { font-size: 1.08rem; }
.mode small { opacity: .75; font-size: .8rem; line-height: 1.25; }
.mode-ic { font-size: 1.6rem; line-height: 1; margin-bottom: 4px; }
.mode[data-mode="free"] { background: var(--teal); color: var(--navy); border-color: var(--teal); }
.mode[aria-expanded="true"] { border-color: var(--teal); box-shadow: inset 0 0 0 1px var(--teal); }
#learn-list[hidden] { display: none; }
.intro-steps { padding-left: 22px; margin: 6px 0 12px; }
.intro-steps li { margin-bottom: 8px; line-height: 1.35; }
.intro-steps b { color: var(--teal); }
.intro-ctl { background: rgba(255,255,255,.07); border-radius: 12px; padding: 10px 12px; font-size: .88rem; margin: 0 0 14px; }
#buttons.jump { grid-template-columns: 1fr 76px; }
#buttons.jump .btn-hint { display: none; }
.btn-action small { display: block; font-weight: 600; font-size: .7rem; opacity: .7; }
.btn-action { touch-action: none; user-select: none; -webkit-user-select: none; }
.btn-action.held { background: #fff; transform: scale(.98); }
.step-card.compact { padding: 6px 10px; }
.step-card.compact strong { font-size: .86rem; }
.step-card.compact span { font-size: .76rem; opacity: .85; }

/* Sprunghöhe groß in der Bildmitte */
.jumpbig { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%); padding: 6px 16px; border-radius: 999px;
  background: rgba(11, 36, 64, .72); color: #fff; font-weight: 800; font-size: 1.9rem; font-variant-numeric: tabular-nums; pointer-events: none; }
.jumpbig.done { color: var(--teal); font-size: 1.4rem; }
.jumpbig[hidden] { display: none; }

/* 02.12.: Grundkurs – Menügruppen und Strand-Missionen */
.lessons .grp { margin: 8px 0 0; font-size: .78rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: rgba(255,255,255,.7); }
.btn-theory { background: #cfeee9; }
.lessons button.next { box-shadow: 0 0 0 3px #ffd166; position: relative; }
.lessons button.next::after { content: 'Weiter hier'; position: absolute; right: 12px; top: -9px; font-size: .68rem; font-weight: 800; color: var(--navy);
  background: #ffd166; border-radius: 999px; padding: 2px 8px; }
.lessons .done { color: #0b6b5f; font-weight: 800; }
#mission .screen-inner { padding-bottom: 110px; }
.m-top { display: flex; align-items: center; gap: 10px; }
.m-top .brand { flex: 1; }
.m-count { font-size: .8rem; color: rgba(255,255,255,.7); font-variant-numeric: tabular-nums; }
.m-close { width: 36px; height: 36px; border: 0; border-radius: 10px; background: rgba(255,255,255,.12); color: #fff; font-size: 1rem; }
.m-prog { height: 6px; border-radius: 3px; background: rgba(255,255,255,.15); overflow: hidden; margin: 0 0 14px; }
.m-prog i { display: block; height: 100%; width: 0; background: var(--teal); transition: width .3s; }
.m-q { font-size: 1.08rem; margin: 10px 0 10px; line-height: 1.3; }
.m-n { display: inline-block; min-width: 2.4em; font-size: .78rem; color: var(--navy); background: var(--teal); border-radius: 999px; padding: 1px 7px; margin-right: 4px; vertical-align: 2px; }
.m-intro { margin: 4px 0 0; color: rgba(255,255,255,.85); }
.m-info { background: rgba(255,255,255,.07); border-radius: 14px; padding: 4px 16px; }
.m-info li { margin-bottom: 6px; }
.m-art { margin: 6px 0 10px; border-radius: 14px; overflow: hidden; background: #0d2b4d; }
.m-art svg.art { display: block; width: 100%; height: auto; max-height: 46dvh; }
.m-art svg.art--tall { max-height: 58dvh; }
.m-art .part .hit { fill: transparent; stroke: transparent; pointer-events: all; }
/* Linien-Tippflächen (Fronttube, Struts, Leinen): nur der breite Strich zählt – ein Bogen würde sonst die ganze Fläche darunter abdecken */
.m-art .part path.hit { fill: none; pointer-events: stroke; }
.m-art--tap .part { cursor: pointer; }
.m-art .part.done { filter: drop-shadow(0 0 5px #34d399) drop-shadow(0 0 2px #34d399); }
.m-art .part.wrong { filter: drop-shadow(0 0 6px #ff5a5f); }
.m-art .part[data-hz].done::after { content: ''; }
.m-opts { display: grid; gap: 8px; }
.m-opt { text-align: left; padding: 12px 14px; border-radius: 12px; border: 1px solid rgba(255,255,255,.25); background: rgba(255,255,255,.06); color: #fff; font-weight: 600; line-height: 1.3; }
.m-opt.ok { background: rgba(52,211,153,.25); border-color: var(--green); }
.m-opt.bad { background: rgba(229,72,77,.22); border-color: var(--red); }
.m-opt:disabled:not(.ok):not(.bad) { opacity: .55; }
.m-done { margin: 0 0 10px; padding-left: 22px; color: var(--green); font-size: .9rem; }
.m-done li { margin-bottom: 4px; }
.m-fb { margin: 12px 0 0; padding: 10px 12px; border-radius: 12px; font-size: .92rem; line-height: 1.35; }
.m-fb--ok { background: rgba(52,211,153,.18); border-left: 4px solid var(--green); }
.m-fb--bad { background: rgba(229,72,77,.18); border-left: 4px solid var(--red); }
.m-foot { position: fixed; left: 0; right: 0; bottom: 0; padding: 10px 18px calc(12px + var(--safe-b)); background: linear-gradient(transparent, rgba(11,36,64,.95) 30%); display: flex; justify-content: center; z-index: 11; }
.m-foot .btn-primary { width: 100%; max-width: 484px; text-align: center; }
.m-foot .btn-primary:disabled { background: #22405f; color: rgba(255,255,255,.5); }
#mission[hidden] .m-foot { display: none; }

/* 02.12.: Zurück im Missions-Fuß, Tastenhilfe */
.m-foot { gap: 8px; }
.m-foot .btn-ghost { flex: 0 0 auto; width: auto; text-align: center; background: rgba(11,36,64,.9); }
.m-foot .btn-ghost[hidden] { display: none; }
.keyhelp { display: none; }
.keyhelp kbd { display: inline-block; min-width: 1.6em; padding: 0 5px; margin-right: 2px; border-radius: 5px; border: 1px solid rgba(255,255,255,.35);
  background: rgba(255,255,255,.08); font: 600 .78rem/1.5 system-ui, sans-serif; text-align: center; }

/* 02.12.: Breitbild am Desktop – Spielbild über die ganze Breite, unten Tastenhilfe | Bar-Feld | Knöpfe */
@media (min-width: 1000px) and (min-aspect-ratio: 5/4) {
  #app {
    max-width: none; border: 0;
    grid-template-columns: 1fr minmax(420px, 640px) 1fr;
    grid-template-rows: 1fr 168px;
    grid-template-areas: "view view view" "keys bar btns";
  }
  #view { grid-area: view; }
  #barfield { grid-area: bar; border-left: 1px solid rgba(255,255,255,.08); border-right: 1px solid rgba(255,255,255,.08); }
  #buttons { grid-area: btns; display: flex; flex-direction: column; justify-content: center; align-items: flex-start; gap: 8px; padding: 14px 22px; }
  #buttons .btn-qr { width: 110px; height: 54px; order: -1; }
  #buttons .btn-action { width: 220px; height: 54px; }
  #buttons.jump .btn-hint { display: block; }
  .keyhelp { grid-area: keys; display: flex; flex-direction: column; justify-content: center; align-items: flex-end; gap: 5px;
    padding: 14px 22px; background: #08192d; color: rgba(255,255,255,.7); font-size: .82rem; text-align: right; }
  .keyhelp b { color: #fff; font-size: .85rem; }
  .step-card { right: auto; width: min(560px, calc(100% - 180px)); font-size: .92rem; }
  .hud-right { width: 150px; }
  #clock { width: 150px; height: 88px; }
  .gauges { font-size: .82rem; }
  .toasts { bottom: 16px; }
  .toast { max-width: 560px; }
  #debug { right: auto; width: 520px; }
  /* Menü, Anleitung, Ende, Missionen: breiter, Menü zweispaltig */
  .screen-inner { max-width: 720px; padding-top: 40px; }
  #mission .screen-inner { max-width: 760px; }
  .m-art svg.art { max-height: 52vh; }
  .m-foot .btn-primary { max-width: 560px; }
  #learn-list { grid-template-columns: 1fr 1fr; }
  #learn-list .grp { grid-column: 1 / -1; }
  .settings { grid-template-columns: 1fr 1fr; column-gap: 20px; }
  .settings label.chk { grid-column: auto; }
}

/* 02.12.: Sprachwahl */
.lang-sel { width: 100%; padding: 9px 10px; border-radius: 10px; border: 1px solid rgba(255,255,255,.25); background: rgba(255,255,255,.08); color: #fff; font: inherit; }
.lang-sel option { color: #0b2440; }

/* 02.12.: Leiste oben im Menü – Weg zurück zur Website immer sichtbar */
.kg-top { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: rgba(8, 25, 45, .92); backdrop-filter: blur(6px);
  border-bottom: 1px solid rgba(255,255,255,.08); }
.kg-exit { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 999px; background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.22); color: #fff; font-weight: 700; font-size: .9rem; text-decoration: none; }
.kg-exit:hover { background: rgba(255,255,255,.18); }
.kg-logo { color: var(--teal); font-weight: 800; letter-spacing: .08em; text-transform: uppercase; font-size: .8rem; text-decoration: none; }
#menu .screen-inner { padding-top: 18px; }
.btn-resume { width: 100%; margin: 0 0 12px; }
.btn-resume[hidden] { display: none; }

/* 02.12.: Kopfzeile im Spiel – „← Menü“ oben links, Lektion in der Mitte */
.hud-head { position: absolute; left: 0; right: 0; top: 0; height: calc(44px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 8px 0;
  display: flex; align-items: center; gap: 10px; background: linear-gradient(rgba(8,25,45,.85), rgba(8,25,45,.55)); }
.hud-back { pointer-events: auto; display: inline-flex; align-items: center; gap: 5px; height: 32px; padding: 0 14px; border-radius: 999px;
  border: 1px solid rgba(255,255,255,.3); background: rgba(255,255,255,.12); color: #fff; font: 700 .88rem system-ui, sans-serif; cursor: pointer; }
.hud-back:hover { background: rgba(255,255,255,.22); }
.hud-name { flex: 1; min-width: 0; text-align: center; color: #fff; font-weight: 700; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-brand { color: var(--teal); font-weight: 800; letter-spacing: .08em; text-transform: uppercase; font-size: .7rem; }
#hud .step-card { top: calc(52px + env(safe-area-inset-top)); }
#hud .hud-right { top: calc(52px + env(safe-area-inset-top)); }
@media (max-width: 420px) { .hud-brand { display: none; } }

/* 02.12.: Beta-Hinweis */
.beta { display: inline-block; vertical-align: middle; margin-left: 6px; padding: 2px 7px; border-radius: 999px; background: #f59e0b; color: #1a1300;
  font: 700 .6rem/1.3 system-ui, sans-serif; letter-spacing: .06em; text-transform: uppercase; }
h1 .beta { font-size: .32em; vertical-align: .55em; }
