/* Kraken-Alarm (js/crewgame.js). Oben: großer Bildschirm, unten: Schaltpult am Handy. */

/* ---------- großer Bildschirm ---------- */
.cr-stage { display: flex; flex-direction: column; gap: 12px; text-align: left; }
.cr-top { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.cr-zone { font-size: 1.25rem; color: var(--gold); white-space: nowrap; }
.cr-meter { flex: 1; min-width: 150px; display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: .95rem; white-space: nowrap; }
.cr-bar { flex: 1; height: 14px; background: rgba(0, 0, 0, .4); border: 2px solid #0d0a26; overflow: hidden; }
.cr-bar i { display: block; height: 100%; width: 0; background: var(--gold); transition: width .5s ease-out; }
.cr-meter.hull .cr-bar i { background: var(--ok); }
.cr-meter.hull.low .cr-bar i { background: var(--bad); }
.cr-hull-t { min-width: 3.2em; text-align: right; color: var(--dim); }

.cr-sea { position: relative; height: clamp(170px, 34vh, 300px); overflow: hidden; border: 4px solid #0d0a26; border-radius: 6px; background: linear-gradient(#1c7ed6, #1864ab 45%, #0b3a6e); image-rendering: pixelated; }
.cr-sea.hit { border-color: var(--bad); }
.cr-dark { position: absolute; inset: 0; background: #050a1f; opacity: 0; transition: opacity 2s; }
.cr-floor { position: absolute; left: 0; right: 0; bottom: 0; height: 14%; background: repeating-linear-gradient(90deg, #5c4a1e 0 24px, #6b5724 24px 48px); border-top: 4px solid #8a7030; }
.cr-sub, .cr-kraken { position: absolute; top: 50%; transform: translateY(-50%); transition: left .7s ease-out; }
.cr-sub { width: 15%; left: 36%; }
.cr-kraken { width: 14%; left: -5%; top: 46%; }
.cr-sub svg, .cr-kraken svg { display: block; width: 100%; height: auto; }
.cr-sub.warp { left: 115% !important; transition: left 1.6s ease-in; }
.cr-kraken.grab { transition: left 1.2s ease-in; }
.cr-alert { position: absolute; left: 50%; top: 10px; transform: translateX(-50%); max-width: 92%; padding: 8px 18px; border: 3px solid #0d0a26; background: var(--panel); font-size: clamp(1.2rem, 3.2vw, 1.9rem); font-weight: 700; text-align: center; opacity: 0; transition: opacity .25s; pointer-events: none; }
.cr-alert.on { opacity: 1; }
.cr-alert.warn { background: var(--pri2); }
.cr-alert.good { background: #2b8a3e; }
.cr-alert small { display: block; font-size: .55em; font-weight: 600; color: #fff; }
.cr-news { min-height: 1.5em; color: var(--dim); font-size: 1rem; text-align: center; }
.cr-news b { color: var(--ink); }

.cr-crew { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.cr-chip { display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 84px; padding: 8px 8px 6px; background: var(--panel2); border: 3px solid transparent; border-radius: 10px; transition: border-color .2s, background .2s; }
.cr-chip b { font-size: .9rem; max-width: 96px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cr-chip em { font-style: normal; font-size: .8rem; color: var(--dim); }
.cr-chip.ok { border-color: var(--ok); background: #2b6a4a; }
.cr-chip.bad { border-color: var(--bad); background: #7a2a3c; }
.cr-chip.hold { border-color: var(--gold); }
.cr-end { margin: 14px 0 8px; }

/* ---------- Schaltpult am Handy ---------- */
/* Die Standardansicht zentriert und polstert großzügig – das Pult braucht jeden Pixel. */
#cview:has(.cr-phone) { padding: 8px 10px 10px; justify-content: flex-start; }
.cr-phone { --rh: 70px; position: relative; width: 100%; display: flex; flex-direction: column; gap: 6px; text-align: left; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
/* Zeilenhöhe passt sich der Bildschirmhöhe an, damit vier Zeilen ohne Scrollen passen (360 x 640: 75 px). */
@supports (height: 100dvh) { .cr-phone { --rh: clamp(54px, calc((100dvh - 340px) / 4), 78px); } }
.cr-phone.cr-lv { --rh: 56px; }
.cr-phone.hurt { outline: 3px solid var(--bad); outline-offset: 2px; }

.cr-ins { height: 92px; display: flex; flex-direction: column; background: #0d0a26; border: 3px solid var(--panel2); border-radius: 8px; overflow: hidden; }
.cr-ins-t { flex: 1; display: flex; align-items: center; justify-content: center; padding: 4px 10px; text-align: center; font-size: 1.12rem; line-height: 1.2; font-weight: 700; color: var(--dim); overflow-wrap: anywhere; }
.cr-ins.on { border-color: var(--gold); }
.cr-ins.on .cr-ins-t { color: var(--gold); }
.cr-ins.hurry { border-color: var(--pri2); }
.cr-ins.ok { border-color: var(--ok); }
.cr-ins.ok .cr-ins-t { color: var(--ok); }
.cr-ins.bad { border-color: var(--bad); }
.cr-ins.bad .cr-ins-t { color: var(--bad); }
.cr-tbar { height: 10px; background: rgba(255, 255, 255, .08); flex: none; }
.cr-tbar i { display: block; height: 100%; width: 0; background: var(--gold); }
.cr-ins.hurry .cr-tbar i { background: var(--pri2); }

.cr-stat { display: flex; align-items: center; gap: 8px; height: 20px; font-size: .78rem; color: var(--dim); white-space: nowrap; }
.cr-st { flex: 1; display: flex; align-items: center; gap: 4px; }
.cr-st-bar { flex: 1; height: 8px; background: rgba(0, 0, 0, .45); overflow: hidden; }
.cr-st-bar i { display: block; height: 100%; width: 0; background: var(--gold); transition: width .4s; }
.cr-st.hull .cr-st-bar i { background: var(--ok); }

.cr-wrap { position: relative; overflow: hidden; border-radius: 10px; }
.cr-panel { display: flex; flex-direction: column; gap: 6px; padding: 6px; background: #4a4e69; border: 3px solid #22223b; border-radius: 10px; transition: transform .25s; }
.cr-panel.loose { transform: rotate(-4deg) translateY(10px) scale(.94); filter: brightness(.6); }
.cr-row { display: flex; gap: 6px; height: var(--rh); }
.cr-ctl { position: relative; flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; justify-content: space-between; gap: 2px; padding: 4px 6px 5px; background: var(--panel); border: 2px solid #15102f; border-radius: 6px; overflow: hidden; cursor: pointer; }
.cr-ctl.good { border-color: var(--ok); box-shadow: inset 0 0 0 2px var(--ok); }
.cr-ctl.zap { border-color: var(--gold); box-shadow: inset 0 0 0 2px var(--gold); }
.cr-lab { font-size: .78rem; line-height: 1.1; font-weight: 600; text-align: center; overflow-wrap: anywhere; hyphens: auto; max-height: 2.2em; overflow: hidden; pointer-events: none; }
.cr-lab.sym { font-size: 1.25rem; letter-spacing: .15em; max-height: none; }

/* Schalter */
.cr-sw { align-self: center; width: 78px; height: 26px; line-height: 22px; border: 2px solid #15102f; border-radius: 13px; background: #15102f; color: var(--dim); font-size: .75rem; font-weight: 700; text-align: right; padding: 0 9px; position: relative; pointer-events: none; }
.cr-sw::before { content: ''; position: absolute; left: 2px; top: 2px; width: 18px; height: 18px; border-radius: 50%; background: #868e96; transition: left .12s; }
.cr-t.on .cr-sw { background: var(--ok); color: #0d2b13; text-align: left; }
.cr-t.on .cr-sw::before { left: 54px; background: #fff; }
/* Knopf */
.cr-cap { align-self: center; width: 70%; max-width: 110px; flex: 1; max-height: 34px; min-height: 18px; border-radius: 8px; background: var(--pri2); box-shadow: 0 5px 0 #8a1c3a; margin-bottom: 5px; pointer-events: none; }
.cr-b.hit .cr-cap { transform: translateY(4px); box-shadow: 0 1px 0 #8a1c3a; }
/* Schieber: Raster mit festen Stufen; der Knauf sitzt bei --f (0 … 1) */
.cr-sl { position: relative; flex: 1; min-height: 34px; --f: 0; cursor: ew-resize; }
.cr-sl-line { position: absolute; left: 22px; right: 22px; top: 50%; height: 8px; margin-top: -4px; background: #15102f; border-radius: 4px; }
.cr-sl-n { position: absolute; left: 22px; right: 22px; top: 0; bottom: 0; pointer-events: none; }
.cr-sl-n span { position: absolute; top: 50%; width: 20px; margin: -9px 0 0 -10px; text-align: center; font-size: .75rem; font-weight: 700; line-height: 18px; color: var(--dim); }
.cr-sl-n span:nth-child(1) { left: 0; } .cr-sl-n span:nth-child(2) { left: 25%; } .cr-sl-n span:nth-child(3) { left: 50%; } .cr-sl-n span:nth-child(4) { left: 75%; } .cr-sl-n span:nth-child(5) { left: 100%; }
.cr-sl-th { position: absolute; top: 50%; left: calc(22px + (100% - 44px) * var(--f)); width: 34px; height: 34px; margin: -17px 0 0 -17px; border-radius: 8px; background: var(--pri); border: 3px solid #fff; opacity: .92; pointer-events: none; transition: left .08s; }
.cr-ctl.drag .cr-sl-th { background: var(--gold); }
/* Drehwähler */
.cr-dl { flex: 1; min-height: 34px; display: flex; align-items: stretch; gap: 5px; }
.cr-kn { flex: none; width: 34px; align-self: center; height: 34px; border-radius: 50%; background: #15102f; border: 2px solid #868e96; position: relative; pointer-events: none; }
.cr-kn i { position: absolute; left: 50%; top: 2px; width: 4px; height: 14px; margin-left: -2px; background: var(--gold); border-radius: 2px; transform-origin: 50% 13px; transition: transform .15s; }
.cr-pos { flex: 1; display: grid; place-items: center; background: var(--panel2); border: 2px solid #15102f; border-radius: 6px; font-weight: 700; font-size: 1rem; }
.cr-pos.sel { background: var(--gold); color: #1b1444; }

/* Störungen */
.cr-ink { position: absolute; inset: 0; z-index: 2; display: flex; flex-direction: column; align-items: center; justify-content: center; background: radial-gradient(ellipse at 40% 45%, #000 55%, #1a0b2e 80%); color: #fff; font-size: .85rem; line-height: 1.2; cursor: grab; }
.cr-ink span { font-size: .72rem; color: var(--dim); }
.cr-loose { position: absolute; inset: 0; z-index: 3; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-align: center; background: rgba(13, 10, 38, .55); font-size: 1.05rem; }
.cr-loose span { font-size: .85rem; color: var(--gold); }
.cr-screw { position: absolute; top: 6px; width: 56px; height: 56px; display: grid; place-items: center; font-size: 1.6rem; background: var(--pri2); border: 3px solid #fff; border-radius: 50%; cursor: pointer; }
.cr-screw.s0 { left: 6px; } .cr-screw.s1 { right: 6px; }
.cr-screw.done { background: var(--ok); }

/* Gemeinschaftsaufgabe: deckt das ganze Pult zu */
.cr-grp { position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 10px 0; background: #0d0a26; border: 3px solid var(--pri2); border-radius: 10px; overflow: hidden; text-align: center; }
.cr-grp.ok { border-color: var(--ok); } .cr-grp.bad { border-color: var(--bad); }
.cr-grp-t { font-size: 1.35rem; font-weight: 700; color: var(--gold); line-height: 1.15; }
.cr-grp-t small { display: block; font-size: .95rem; color: var(--ink); margin-top: 2px; }
.cr-grp-b { flex: 1; width: 100%; max-height: 220px; display: grid; place-items: center; font-size: 2rem; font-weight: 700; background: var(--pri2); border-radius: 18px; box-shadow: 0 8px 0 #8a1c3a; cursor: pointer; }
.cr-grp-b.on, .cr-grp-b.hit { transform: translateY(6px); box-shadow: 0 2px 0 #8a1c3a; }
.cr-grp-b.on { background: var(--ok); box-shadow: 0 2px 0 #1e6b30; }
.cr-grp-i { min-height: 1.3em; font-size: .95rem; color: var(--dim); margin-top: 6px; }
.cr-grp .cr-tbar { width: calc(100% + 20px); }

/* Ersatzfeld am Computer: schmaler, kleiner */
.cr-lv .cr-ins { height: 72px; }
.cr-lv .cr-ins-t { font-size: .92rem; }
.cr-lv .cr-lab { font-size: .68rem; }
.cr-lv .cr-sw { width: 64px; }
.cr-lv .cr-t.on .cr-sw::before { left: 40px; }
.cr-lv .cr-sl { min-height: 28px; }
.cr-lv .cr-sl-th, .cr-lv .cr-kn { width: 28px; height: 28px; }
.cr-lv .cr-sl-th { margin: -14px 0 0 -14px; }
.cr-lv .cr-kn i { height: 11px; transform-origin: 50% 10px; }
.cr-lv .cr-grp-t { font-size: 1.05rem; }
.cr-lv .cr-grp-b { font-size: 1.4rem; }
.cr-lv .cr-screw { width: 44px; height: 44px; font-size: 1.2rem; }
