/* Fotobox – Modern Photo Booth UI */

:root {
    --bg: #0f0f13;
    --bg-card: #1a1a24;
    --bg-elevated: #242433;
    --text: #f0f0f5;
    --text-muted: #8888a0;
    --accent: #ff3d6e;
    --accent-hover: #ff5c85;
    --accent-glow: rgba(255, 61, 110, 0.35);
    --secondary: #3d8bff;
    --success: #2ecc71;
    --border: #2a2a3a;
    --radius: 18px;
    --radius-sm: 14px;
    --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
    /* Touch / Kinderhände */
    --touch-min: 56px;
    --touch-lg: 64px;
    --touch-xl: 72px;
    --touch-gap: 12px;
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    -webkit-tap-highlight-color: transparent;
    overflow-x: hidden;
}

body {
    background: radial-gradient(ellipse at 50% 0%, #1a1030 0%, var(--bg) 60%);
    min-height: 100dvh;
}

/* ── Layout ── */
.container {
    max-width: 480px;
    margin: 0 auto;
    padding: 24px 16px;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

/* ── Hero ── */
.hero {
    text-align: center;
    padding: 32px 0 24px;
}

.logo {
    font-size: 56px;
    margin-bottom: 8px;
}

.hero h1 {
    font-size: 2.2rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #fff 30%, var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--text-muted);
    margin-top: 8px;
    font-size: 0.95rem;
    line-height: 1.5;
}

/* ── Cards ── */
.cards {
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex: 1;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
}

.card-icon {
    font-size: 40px;
    margin-bottom: 12px;
}

.card h2 {
    font-size: 1.25rem;
    margin-bottom: 8px;
}

.card p {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 20px;
}

/* ── Buttons (Touch / Kinderhände) ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: var(--touch-lg);
    padding: 16px 28px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
    color: #fff;
    width: 100%;
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
}

.btn:active {
    transform: scale(0.96);
}

.btn-primary {
    background: var(--accent);
    box-shadow: 0 4px 20px var(--accent-glow);
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    background: var(--bg-elevated);
    border: 2px solid var(--border);
    margin-top: 0;
}

.btn-accent {
    background: var(--secondary);
}

.btn-lg {
    min-height: var(--touch-xl);
    padding: 20px 32px;
    font-size: 1.25rem;
    border-radius: 16px;
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.btn-shutter {
    background: linear-gradient(135deg, var(--accent), #ff6b35);
    font-size: 1.35rem;
    min-height: 80px;
    padding: 22px;
    border-radius: 18px;
    box-shadow: 0 6px 30px var(--accent-glow);
    margin-top: 8px;
}

/* ── Room Code ── */
.room-code {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: 6px;
    color: var(--accent);
    margin: 16px 0 8px;
}

.qr-wrap {
    margin: 16px auto;
    background: #fff;
    padding: 12px;
    border-radius: 12px;
    display: inline-block;
}

.qr-wrap img {
    display: block;
    width: 220px;
    height: 220px;
}

/* ── Join Form ── */
.join-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.join-form input {
    padding: 16px 18px;
    min-height: var(--touch-lg);
    border: 3px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
    font-size: 1.35rem;
    text-align: center;
    letter-spacing: 4px;
    text-transform: uppercase;
    font-weight: 700;
}

.join-form input:focus {
    outline: none;
    border-color: var(--accent);
}

/* ── Footer ── */
.footer {
    text-align: center;
    padding: 24px 0 8px;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.fullscreen-hint {
    margin-top: 10px;
    line-height: 1.45;
    max-width: 360px;
    margin-left: auto;
    margin-right: auto;
}

/* Home-Bildschirm / Standalone: Statusleiste berücksichtigen */
@supports (padding: env(safe-area-inset-top)) {
    .page-controller .controller-app,
    .page-camera .camera-app,
    .result-compact {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
}

@media (display-mode: standalone) {
    body {
        /* Keine Browser-Leiste – etwas kompakter */
        overscroll-behavior: none;
    }
}

.hidden {
    display: none !important;
}

.hint {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ── Top Bar ── */
.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.badge {
    background: var(--bg-elevated);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.badge-live {
    color: var(--success);
}

.badge-done {
    color: var(--secondary);
}

.room-label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.back-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #666;
    display: inline-block;
}

.status-dot.connected {
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
}

/* ── Camera Page ── */
.camera-app {
    display: flex;
    flex-direction: column;
    height: 100dvh;
}

.video-container {
    flex: 1;
    position: relative;
    background: #000;
    overflow: hidden;
}

.video-container video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.flash-overlay {
    position: absolute;
    inset: 0;
    background: #fff;
    z-index: 10;
    animation: flash-anim 0.2s ease-out;
}

@keyframes flash-anim {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

.countdown-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    z-index: 5;
}

.countdown-overlay span {
    font-size: 8rem;
    font-weight: 900;
    color: #fff;
    text-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
    animation: pulse 0.8s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.camera-info {
    padding: 16px;
    text-align: center;
    background: var(--bg-card);
}

.camera-info p {
    margin-bottom: 4px;
}

/* ── Controller Page ── */
.controller-app {
    height: 100dvh;
    display: flex;
    flex-direction: column;
}

.screen {
    display: none;
    flex-direction: column;
    height: 100dvh;
}

.screen.active {
    display: flex;
}

/* Connect screen */
.connect-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 24px;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Preview */
.preview-wrap {
    position: relative;
    background: #000;
    aspect-ratio: 4/3;
    max-height: 45vh;
    overflow: hidden;
}

.preview-wrap video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.countdown-display {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.55);
    z-index: 5;
}

.countdown-display span {
    font-size: 6rem;
    font-weight: 900;
    color: #fff;
    animation: pulse 0.8s ease-in-out infinite;
}

.capture-progress {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    z-index: 6;
}

/* Controls */
.controls-panel {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
}

.controls-panel h3 {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.mode-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--touch-gap);
    margin-bottom: 16px;
}

.mode-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: var(--touch-xl);
    padding: 16px 10px;
    background: var(--bg-elevated);
    border: 3px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    cursor: pointer;
    font-size: 1rem;
    font-weight: 700;
    transition: border-color 0.15s, background 0.15s;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
}

.mode-btn.active {
    border-color: var(--accent);
    background: rgba(255, 61, 110, 0.1);
}

.mode-icon {
    font-size: 2rem;
}

.format-select {
    margin-bottom: 16px;
}

.format-select label,
.timer-select label {
    display: block;
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.format-dropdown {
    width: 100%;
    min-height: var(--touch-lg);
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    border: 3px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: 1.05rem;
    font-weight: 700;
}

.format-dropdown:focus {
    outline: none;
    border-color: var(--secondary);
}

.format-hint {
    margin-top: 6px;
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.4;
    min-height: 1.2em;
}

/* Setup / Raum-Einstellungen */
.setup-panel {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
}

.setup-panel h2 {
    font-size: 1.3rem;
    margin-bottom: 6px;
}

.setup-intro {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.45;
    margin-bottom: 20px;
}

.layout-select {
    margin-bottom: 16px;
}

.layout-select label {
    display: block;
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.layout-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}

.layout-btn {
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: var(--touch-lg);
    padding: 14px 16px;
    background: var(--bg-elevated);
    border: 3px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    cursor: pointer;
    text-align: left;
    touch-action: manipulation;
}

.layout-btn.active {
    border-color: var(--accent);
    background: rgba(255, 61, 110, 0.1);
}

.layout-mini {
    position: relative;
    display: block;
    width: 54px;
    height: 72px;
    background: #fff;
    border-radius: 4px;
    flex-shrink: 0;
    overflow: hidden;
}

.layout-mini span {
    position: absolute;
    background: #ff3d6e;
    border-radius: 2px;
    opacity: 0.85;
}

.layout-label {
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.3;
}

.room-settings-summary {
    color: var(--text-muted);
    font-size: 0.8rem;
    text-align: center;
    margin: 8px 0 12px;
    line-height: 1.4;
}

.settings-link {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.4rem;
    cursor: pointer;
    padding: 10px 12px;
    min-width: var(--touch-min);
    min-height: var(--touch-min);
}

.timer-select {
    margin-bottom: 16px;
}

.timer-btns {
    display: flex;
    gap: var(--touch-gap);
}

.timer-btn {
    flex: 1;
    min-height: var(--touch-min);
    padding: 14px 8px;
    background: var(--bg-elevated);
    border: 3px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-weight: 700;
    font-size: 1.05rem;
    cursor: pointer;
    transition: border-color 0.15s;
    touch-action: manipulation;
}

.timer-btn.active {
    border-color: var(--secondary);
    color: var(--secondary);
}

/* Result screen – alles ohne Scrollen in einem Viewport */
.result-compact {
    height: 100dvh;
    display: flex;
    flex-direction: column;
    padding: 10px 12px 12px;
    gap: 10px;
    overflow: hidden;
    box-sizing: border-box;
}

.result-photo {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    border-radius: 12px;
    padding: 8px;
    border: 1px solid var(--border);
}

.result-photo img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
}

.result-bottom {
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 12px;
    align-items: center;
}

.qr-section {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.qr-caption {
    color: var(--text-muted);
    font-size: 0.7rem;
}

.qr-image {
    width: 110px;
    height: 110px;
    background: #fff;
    padding: 6px;
    border-radius: 10px;
    display: block;
}

.result-btns {
    display: flex;
    flex-direction: column;
    gap: var(--touch-gap);
}

.result-btns .btn {
    min-height: var(--touch-xl);
    padding: 18px 20px;
    font-size: 1.2rem;
    border-radius: 16px;
}

.review-bottom {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.review-timer,
.idle-timer {
    text-align: center;
    color: var(--text-muted);
    font-size: 1rem;
    margin: 0;
}

.review-timer strong,
.idle-timer strong {
    color: var(--accent);
    font-size: 1.25rem;
}

@media (orientation: landscape) {
    .review-compact {
        flex-direction: row;
        align-items: stretch;
    }

    .review-compact .review-bottom {
        flex: 0 0 clamp(180px, 30vw, 260px);
        justify-content: center;
    }
}

/* Querformat: Foto links, QR + Buttons rechts */
@media (orientation: landscape) {
    .result-compact {
        flex-direction: row;
        align-items: stretch;
        padding: 8px 10px;
        gap: 12px;
    }

    .result-photo {
        flex: 1 1 0;
        min-width: 0;
    }

    .result-bottom {
        flex: 0 0 clamp(160px, 28vw, 240px);
        display: flex;
        flex-direction: column;
        justify-content: center;
        gap: 12px;
        grid-template-columns: none;
    }

    .qr-section {
        width: 100%;
    }

    .qr-image {
        width: min(180px, 42vh);
        height: min(180px, 42vh);
    }

    .qr-caption {
        font-size: 0.75rem;
    }

    .result-btns {
        width: 100%;
    }

    .result-btns .btn {
        min-height: var(--touch-lg);
        padding: 14px 16px;
        font-size: 1.1rem;
    }
}

/* Legacy result classes (Galerie etc.) */
.result-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 16px;
    gap: 16px;
    overflow-y: auto;
}

.action-btns {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ── Print ── */
/* Nicht display:none – sonst rendert Safari das Bild oft erst beim 2. Druck */
.print-only {
    position: fixed;
    left: -100vw;
    top: 0;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    z-index: -1;
}

.print-only img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

@media print {
    html, body {
        background: #fff !important;
    }

    body * {
        visibility: hidden !important;
    }

    .print-only,
    .print-only * {
        visibility: visible !important;
    }

    .print-only {
        position: fixed !important;
        left: 0 !important;
        top: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        height: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        opacity: 1 !important;
        background: #fff !important;
        z-index: 99999 !important;
    }

    .print-only img {
        display: block !important;
        width: 100% !important;
        height: 100% !important;
        max-width: 100% !important;
        max-height: 100% !important;
        object-fit: contain !important;
        margin: 0 !important;
        padding: 0 !important;
    }
}

.gallery-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.gallery-item img {
    width: 100%;
    border-radius: 10px;
    display: block;
    background: #fff;
}

.gallery-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 12px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.gallery-meta strong {
    color: var(--text);
}

.view-card {
    text-align: center;
}

.view-photo {
    width: 100%;
    max-height: 70vh;
    object-fit: contain;
    border-radius: 12px;
    background: #111;
    display: block;
}

/* ── Responsive ── */
@media (min-width: 600px) {
    .container {
        max-width: 520px;
        padding-top: 48px;
    }

    .mode-grid {
        grid-template-columns: 1fr 1fr;
    }
}
