:root {
    --bg:    #0b1220;
    --card:  #131d30;
    --card2: #1a2540;
    --line:  #1e2d47;
    --txt:   #e4eaf5;
    --muted: #7a8fad;
    --blue:  #2d6ef7;
    --ok:    #1fbc6e;
    --err:   #e04646;
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0; padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    height: 100%;
    overflow: hidden;
    background: var(--bg);
    color: var(--txt);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    user-select: none;
    touch-action: manipulation;
}

/* ── Screens ─────────────────────────────────────────────────────────────── */
.screen {
    display: none;
    position: fixed;
    inset: 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    gap: 16px;
}
.screen.active { display: flex; }

/* ── IDLE ────────────────────────────────────────────────────────────────── */
#screen-idle { cursor: pointer; }

.brand {
    font-size: clamp(56px, 12vw, 96px);
    font-weight: 800;
    letter-spacing: -2px;
    color: var(--txt);
    line-height: 1;
}
.brand span { color: var(--blue); }

.brand-sub {
    font-size: clamp(14px, 3vw, 22px);
    letter-spacing: 4px;
    text-transform: uppercase;
    color: var(--muted);
    margin-top: 4px;
}

.location-name {
    font-size: clamp(16px, 3.5vw, 26px);
    color: var(--blue);
    font-weight: 600;
    min-height: 1.4em;
    margin-top: 8px;
}

.idle-hint {
    margin-top: 32px;
    font-size: clamp(14px, 2.5vw, 20px);
    color: var(--muted);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 12px 36px;
    animation: pulse 2.4s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: .4; }
    50%       { opacity: 1; }
}

/* ── INPUT ───────────────────────────────────────────────────────────────── */
#screen-input { justify-content: flex-start; padding-top: max(32px, 5vh); gap: 20px; }

.input-box {
    width: 100%;
    max-width: 420px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 18px 24px;
    text-align: center;
}
.input-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--muted);
    margin-bottom: 6px;
}
.input-digits {
    font-size: clamp(40px, 10vw, 64px);
    font-weight: 700;
    font-family: monospace;
    letter-spacing: 10px;
    color: var(--txt);
    min-height: 1.2em;
}

.numpad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: clamp(8px, 2vw, 14px);
    width: 100%;
    max-width: 420px;
}

.key {
    aspect-ratio: 1.4;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    color: var(--txt);
    font-size: clamp(24px, 6vw, 40px);
    font-weight: 600;
    cursor: pointer;
    transition: background .08s, transform .06s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.key:active { background: var(--card2); transform: scale(.93); }

.key-del { color: var(--err); font-size: clamp(20px, 4vw, 30px); }
.key-ok  { background: var(--blue); color: #fff; letter-spacing: 1px; }
.key-ok:active { background: #1a56d4; }

.btn-cancel {
    font-size: 15px;
    color: var(--muted);
    background: none;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 10px 36px;
    cursor: pointer;
    margin-top: 4px;
}

/* ── QR ──────────────────────────────────────────────────────────────────── */
#screen-qr { gap: 20px; }

.qr-ma-name {
    font-size: clamp(22px, 5vw, 36px);
    font-weight: 700;
    color: var(--txt);
}
.qr-hint { font-size: 15px; color: var(--muted); }

.qr-wrap {
    background: #fff;
    padding: 16px;
    border-radius: 16px;
    box-shadow: 0 0 40px rgba(45,110,247,.25);
}

.qr-footer { margin-top: 8px; }

.cd-ring { position: relative; width: 80px; height: 80px; }
.cd-ring svg { transform: rotate(-90deg); display: block; }

.ring-bg { fill: none; stroke: var(--line); stroke-width: 7; }
.ring-fg {
    fill: none;
    stroke: #1fbc6e;
    stroke-width: 7;
    stroke-linecap: round;
    transition: stroke-dashoffset 1s linear, stroke 1s linear;
}

/* ── ERGEBNIS ────────────────────────────────────────────────────────────── */
#screen-result { gap: 18px; transition: background .3s; }
#screen-result.kommen { background: #06180e; }
#screen-result.gehen  { background: #091428; }

.result-check {
    font-size: clamp(60px, 14vw, 100px);
    color: var(--ok);
    line-height: 1;
}
#screen-result.gehen .result-check { color: var(--blue); }

.result-avatar {
    width: clamp(90px, 18vw, 130px);
    height: clamp(90px, 18vw, 130px);
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid var(--ok);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--card2);
    font-size: clamp(32px, 7vw, 52px);
    font-weight: 700;
    color: var(--txt);
}
#screen-result.gehen .result-avatar { border-color: var(--blue); }

.result-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.result-name {
    font-size: clamp(24px, 5.5vw, 40px);
    font-weight: 700;
    text-align: center;
}

.result-aktion {
    font-size: clamp(32px, 8vw, 56px);
    font-weight: 800;
    letter-spacing: 4px;
    color: var(--ok);
}
#screen-result.gehen .result-aktion { color: var(--blue); }

.result-zeit {
    font-size: clamp(18px, 4vw, 28px);
    color: var(--muted);
    font-family: monospace;
}

/* ── WARTE AUF FREIGABE ──────────────────────────────────────────────────── */
#screen-waiting { gap: 20px; }

.wait-icon {
    font-size: clamp(60px, 14vw, 90px);
    animation: pulse 2.4s ease-in-out infinite;
}
.wait-title {
    font-size: clamp(22px, 5vw, 36px);
    font-weight: 700;
    color: var(--txt);
}
.wait-id {
    font-size: 14px;
    color: var(--muted);
    font-family: monospace;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px 20px;
}
.wait-hint {
    font-size: clamp(13px, 2.5vw, 16px);
    color: var(--muted);
    text-align: center;
    max-width: 380px;
    line-height: 1.5;
}

/* ── FEHLER ──────────────────────────────────────────────────────────────── */
#screen-error { background: #160606; }

.error-x {
    font-size: clamp(60px, 14vw, 100px);
    color: var(--err);
}

.error-msg {
    font-size: clamp(18px, 4vw, 26px);
    color: var(--txt);
    text-align: center;
    max-width: 440px;
    line-height: 1.4;
}

.btn-retry {
    margin-top: 8px;
    font-size: 18px;
    font-weight: 600;
    padding: 14px 48px;
    background: var(--err);
    color: #fff;
    border: none;
    border-radius: 14px;
    cursor: pointer;
}

/* ── HELP BUTTON + TUTORIAL ──────────────────────────────────────────────── */
.help-btn {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--card);
    border: 1px solid var(--line);
    color: var(--muted);
    font-size: 22px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: border-color .2s, color .2s;
}
.help-btn:active { border-color: var(--blue); color: var(--blue); }

/* ── TUTORIAL OVERLAY ────────────────────────────────────────────────────── */
.tut-overlay {
    position: fixed;
    inset: 0;
    background: rgba(11,18,32,.93);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(6px);
}
.tut-box {
    width: min(92vw, 400px);
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 24px;
    padding: 24px 20px 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}
.tut-scene {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    width: 100%;
}
.tut-scene.active { display: flex; }
.tut-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--muted);
}
.tut-stage {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 160px;
    width: 100%;
}
.tut-caption {
    font-size: clamp(14px, 3.5vw, 17px);
    color: var(--txt);
    text-align: center;
    line-height: 1.4;
}
.tut-dots {
    display: flex;
    gap: 8px;
}
.tut-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--line);
    transition: background .3s;
}
.tut-dot.active { background: var(--blue); }
.tut-close-hint { font-size: 12px; color: var(--muted); }

/* ── Szene 1: Antippen ───────────────────────────────────────────────────── */
.tut-device {
    width: 160px; height: 100px;
    background: var(--card2);
    border: 2px solid var(--blue);
    border-radius: 12px;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 6px; position: relative;
}
.tut-device-brand {
    font-size: 22px; font-weight: 800; color: var(--txt); letter-spacing: -1px;
}
.tut-device-brand span { color: var(--blue); }
.tut-device-hint {
    font-size: 9px; color: var(--muted); letter-spacing: 1px;
    border: 1px solid var(--line); border-radius: 99px; padding: 3px 10px;
}
.tut-finger-wrap {
    position: absolute;
    bottom: -44px; left: 50%; transform: translateX(-50%);
    display: flex; flex-direction: column; align-items: center;
}
.tut-finger {
    width: 18px; height: 28px;
    background: #c8d0e0;
    border-radius: 9px 9px 5px 5px;
    animation: s1-tap 1.8s ease-in-out infinite;
}
@keyframes s1-tap {
    0%,100% { transform: translateY(0);    opacity: 1; }
    35%      { transform: translateY(-30px); opacity: 1; }
    50%      { transform: translateY(-4px);  opacity: 1; }
    65%      { transform: translateY(-30px); opacity: 1; }
}
.tut-ripple {
    width: 8px; height: 8px;
    border-radius: 50%;
    border: 2px solid var(--blue);
    position: absolute;
    bottom: 0; left: 50%;
    transform: translateX(-50%);
    animation: s1-ripple 1.8s ease-out infinite;
}
@keyframes s1-ripple {
    0%,45%  { width: 8px;  height: 8px;  opacity: 0;   margin-left: -4px; }
    50%     { width: 8px;  height: 8px;  opacity: 1;   margin-left: -4px; }
    100%    { width: 44px; height: 44px; opacity: 0;   margin-left: -22px; }
}

/* ── Szene 2: Code eingeben ──────────────────────────────────────────────── */
.tut-code-wrap {
    display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.tut-display {
    width: 160px; height: 44px;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    gap: 12px;
}
.tut-d {
    font-size: 24px; font-weight: 700; font-family: monospace;
    color: var(--txt); opacity: 0;
    animation: s2-digit 2.4s ease-in-out infinite;
}
.d1 { animation-delay: 0.2s; }
.d2 { animation-delay: 0.7s; }
.d3 { animation-delay: 1.2s; }
@keyframes s2-digit {
    0%,10%   { opacity: 0; transform: translateY(6px); }
    20%,75%  { opacity: 1; transform: translateY(0); }
    90%,100% { opacity: 0; transform: translateY(0); }
}
.tut-pad {
    display: grid; grid-template-columns: repeat(3, 36px); gap: 5px;
}
.tut-key {
    width: 36px; height: 24px;
    background: var(--card2);
    border: 1px solid var(--line);
    border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; color: var(--txt);
}
.tut-key.ok  { background: var(--blue); font-weight: 700; }
.tut-key.sm  { font-size: 10px; color: var(--err); }

/* ── Szene 3: Scannen ────────────────────────────────────────────────────── */
.tut-scan-row {
    display: flex; align-items: center; gap: 12px;
}
.tut-screen-qr {
    width: 80px; height: 100px;
    background: var(--card2);
    border: 1px solid var(--line);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    position: relative; overflow: hidden;
}
.tut-qr-block {
    width: 54px; height: 54px;
    background: #fff;
    border-radius: 4px;
    display: flex; align-items: center; justify-content: center;
}
.tut-qr-inner {
    width: 36px; height: 36px;
    background:
        linear-gradient(#000 0,#000) 0 0/12px 12px no-repeat,
        linear-gradient(#000 0,#000) 24px 0/12px 12px no-repeat,
        linear-gradient(#000 0,#000) 0 24px/12px 12px no-repeat,
        linear-gradient(#000 0,#000) 14px 8px/8px 5px no-repeat,
        linear-gradient(#000 0,#000) 22px 16px/5px 8px no-repeat,
        linear-gradient(#000 0,#000) 14px 22px/14px 5px no-repeat;
    background-color: #fff;
}
.tut-beam {
    position: absolute;
    left: 8px; right: 8px; height: 2px;
    background: var(--blue);
    box-shadow: 0 0 6px var(--blue);
    top: 22px;
    animation: s3-beam 1.6s ease-in-out infinite;
}
@keyframes s3-beam {
    0%   { top: 22px; opacity: 1; }
    50%  { top: 72px; opacity: 1; }
    100% { top: 22px; opacity: 1; }
}
.tut-arrow { font-size: 22px; color: var(--blue); }
.tut-phone {
    width: 52px; height: 90px;
    background: var(--card2);
    border: 2px solid var(--blue);
    border-radius: 10px;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 8px;
}
.tut-phone-cam {
    width: 32px; height: 32px;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: var(--bg);
}
.tut-phone-ok {
    font-size: 16px; color: var(--ok);
    animation: s3-ok 1.6s ease-in-out infinite;
}
@keyframes s3-ok {
    0%,49% { opacity: 0; transform: scale(.5); }
    60%,100% { opacity: 1; transform: scale(1); }
}

/* ── Szene 4: Fertig ─────────────────────────────────────────────────────── */
.tut-done-circle {
    width: 110px; height: 110px;
    border-radius: 50%;
    background: #06180e;
    border: 3px solid var(--ok);
    display: flex; align-items: center; justify-content: center;
    animation: s4-pop .5s cubic-bezier(.17,.67,.4,1.4) both;
}
@keyframes s4-pop {
    0%   { transform: scale(0); }
    100% { transform: scale(1); }
}
.tut-done-check {
    font-size: 56px; color: var(--ok); line-height: 1;
}
.tut-done-txt {
    color: var(--ok); font-weight: 700;
    font-size: clamp(15px, 4vw, 20px);
}
