: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;
}
