:root {
    --color-success: #22c55e;
    --color-warning: #eab308;
    --color-error: #ef4444;
    --color-notfound: #f97316;
    --color-bg: #0f172a;
    --color-text: #f8fafc;
    --safe-area-inset-bottom: env(safe-area-inset-bottom, 0px);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    user-select: none;
    -webkit-user-select: none;
}

body {
    background-color: var(--color-bg);
    color: var(--color-text);
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

/* Screen Management */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    z-index: 10;
}

.screen.active {
    display: flex;
}

/* Setup Screen */
.content-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 2rem;
    text-align: center;
}

h1 {
    font-size: 2rem;
    margin-bottom: 1rem;
}

p {
    margin-bottom: 2rem;
    color: #94a3b8;
}

.btn {
    background: #3b82f6;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    touch-action: manipulation;
}

.auth-input {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 1rem;
    border-radius: 0.5rem;
    font-size: 1.25rem;
    margin-bottom: 2rem;
    width: 100%;
    max-width: 300px;
    text-align: center;
}

.auth-input:focus {
    outline: none;
    border-color: #3b82f6;
}

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

.btn.large {
    padding: 1rem 2.5rem;
    font-size: 1.25rem;
}

.version {
    position: absolute;
    bottom: 1rem;
    font-size: 0.8rem;
    opacity: 0.5;
}

/* Scanner Screen */
#scanner-screen {
    background: black;
}

#reader {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#reader video {
    object-fit: cover;
}

.scanner-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    z-index: 20;
}

.overlay-top {
    background: rgba(0, 0, 0, 0.5);
    padding: 1rem;
    text-align: center;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.overlay-bottom {
    background: rgba(0, 0, 0, 0.5);
    padding: 1.5rem;
    padding-bottom: calc(1.5rem + var(--safe-area-inset-bottom));
    text-align: center;
    color: rgba(255, 255, 255, 0.9);
}

.scan-area-guide {
    flex: 1;
    margin: 2rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 1rem;
    box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.5);
}

/* Result Screen */
#result-screen {
    transition: background-color 0.2s ease;
    cursor: pointer;
}

.result-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 2rem;
    text-align: center;
    pointer-events: none; /* Let clicks pass through to container */
}

.status-icon {
    font-size: 5rem;
    margin-bottom: 1rem;
    line-height: 1;
}

#status-text {
    font-size: 3rem;
    font-weight: 800;
    margin-bottom: 2rem;
    letter-spacing: 0.05em;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.ticket-info {
    background: rgba(255, 255, 255, 0.1);
    padding: 1.5rem;
    border-radius: 1rem;
    width: 100%;
    max-width: 400px;
    backdrop-filter: blur(10px);
}

.label {
    font-size: 0.8rem;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 0.25rem;
    margin-top: 1rem;
}

.label:first-child {
    margin-top: 0;
}

.value {
    font-size: 1.5rem;
    font-weight: 600;
    word-break: break-all;
}

.tap-hint {
    position: absolute;
    bottom: calc(2rem + var(--safe-area-inset-bottom));
    opacity: 0.7;
    animation: pulse 2s infinite;
}

/* States */
.state-success {
    background-color: var(--color-success);
}
.state-success .ticket-info { display: block; }

.state-duplicate {
    background-color: var(--color-warning);
    color: black;
}
.state-duplicate .ticket-info { display: block; color: black; }
.state-duplicate .label { color: rgba(0,0,0,0.6); }

.state-notfound {
    background-color: var(--color-notfound);
}
.state-notfound .ticket-info { display: none; }

.state-invalid {
    background-color: var(--color-error);
}
.state-invalid .ticket-info { display: none; }

@keyframes pulse {
    0% { opacity: 0.4; }
    50% { opacity: 0.8; }
    100% { opacity: 0.4; }
}
