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

:root {
    --primary: #c41e3a;
    --primary-dark: #8b1528;
    --secondary: #1a472a;
    --secondary-light: #2d5a3d;
    --gold: #d4af37;
    --white: #ffffff;
    --gray: #f5f5f5;
    --dark: #333333;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, var(--secondary) 0%, var(--secondary-light) 100%);
    min-height: 100vh;
    color: var(--dark);
}

.container {
    max-width: 500px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

h1 {
    color: var(--white);
    text-align: center;
    font-size: 2.5rem;
    margin-top: 40px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.subtitle {
    color: var(--gold);
    text-align: center;
    font-size: 1.2rem;
    margin-bottom: 40px;
}

.menu {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: auto;
    margin-bottom: auto;
}

.btn {
    display: block;
    padding: 20px 40px;
    border-radius: 12px;
    text-decoration: none;
    text-align: center;
    font-size: 1.3rem;
    font-weight: 600;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: var(--shadow);
}

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

.btn-primary {
    background: var(--primary);
    color: var(--white);
}

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

.btn-secondary {
    background: var(--white);
    color: var(--secondary);
    border: 2px solid var(--gold);
}

.btn-small {
    padding: 12px 24px;
    font-size: 1rem;
}

/* Card styles */
.card {
    background: var(--white);
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.card h2 {
    color: var(--secondary);
    margin-bottom: 16px;
    font-size: 1.5rem;
}

/* Clue display */
.clue-box {
    background: var(--gray);
    border-left: 4px solid var(--primary);
    padding: 20px;
    border-radius: 0 12px 12px 0;
    font-size: 1.2rem;
    line-height: 1.6;
    font-style: italic;
    margin: 20px 0;
}

/* QR Scanner */
.scanner-container {
    background: var(--dark);
    border-radius: 16px;
    overflow: hidden;
    aspect-ratio: 1;
    position: relative;
}

#qr-reader {
    width: 100% !important;
}

#qr-reader video {
    border-radius: 16px;
}

/* Photo carousel */
.carousel-container {
    overflow: hidden;
    margin: 0 -20px;
    padding: 0 20px;
}

.carousel {
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 16px;
    padding-bottom: 16px;
}

.carousel::-webkit-scrollbar {
    display: none;
}

.carousel-item {
    flex: 0 0 calc(100% - 40px);
    scroll-snap-align: center;
    background: var(--white);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow);
    position: relative;
}

.carousel-item img {
    width: 100%;
    aspect-ratio: 4/3;
    object-fit: cover;
    display: block;
    user-select: none;
    -webkit-user-drag: none;
}

.carousel {
    cursor: grab;
}

.carousel.dragging {
    cursor: grabbing;
}

/* Photo viewer overlay */
.photo-viewer {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    padding: 10px;
    padding-top: env(safe-area-inset-top, 10px);
    padding-bottom: env(safe-area-inset-bottom, 10px);
    box-sizing: border-box;
    overflow: hidden;
}

.photo-viewer.hidden {
    display: none;
}

.photo-viewer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.photo-viewer-header h3 {
    color: var(--white);
    margin: 0;
    font-size: 1rem;
}

.photo-viewer-close {
    background: none;
    border: none;
    color: var(--white);
    font-size: 2rem;
    cursor: pointer;
    padding: 5px 10px;
    line-height: 1;
}

.photo-viewer-image {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    min-height: 0;
    overflow: hidden;
}

.photo-viewer-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.photo-viewer-hint {
    color: white;
    text-align: center;
    padding: 8px;
    flex-shrink: 0;
    font-size: 0.9rem;
}

@media (orientation: landscape) {
    .photo-viewer {
        padding: 10px;
    }

    .photo-viewer-header {
        position: absolute;
        top: 10px;
        right: 10px;
        z-index: 10;
    }

    .photo-viewer-header h3 {
        display: none;
    }

    .photo-viewer-image {
        width: 100%;
        height: 100%;
    }

    .photo-viewer-hint {
        display: none;
    }
}

/* Penalty overlay */
.penalty-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(196, 30, 58, 0.95);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--white);
}

.penalty-overlay.hidden {
    display: none;
}

.penalty-timer {
    font-size: 6rem;
    font-weight: bold;
    margin: 20px 0;
}

.penalty-message {
    font-size: 1.5rem;
    text-align: center;
    padding: 0 20px;
}

/* Progress indicator */
.progress {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin: 20px 0;
}

.progress-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--white);
    border: 2px solid var(--white);
}

.progress-dot.current {
    background: var(--gold);
    border-color: var(--gold);
    box-shadow: 0 0 8px var(--gold);
}

/* Admin styles */
.player-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.player-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: var(--gray);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.player-item:hover {
    background: #e8e8e8;
}

.player-name {
    font-weight: 600;
    font-size: 1.1rem;
}

/* QR Display */
.qr-display {
    text-align: center;
    padding: 20px;
}

.qr-display canvas {
    max-width: 100%;
    border-radius: 8px;
}

.qr-label {
    margin-top: 16px;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--secondary);
}

/* Status messages */
.status {
    text-align: center;
    padding: 40px 20px;
    color: var(--white);
}

.status h2 {
    color: var(--gold);
    margin-bottom: 16px;
}

.status p {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Completion screen */
.completion {
    text-align: center;
    padding: 40px 20px;
}

.completion h1 {
    font-size: 3rem;
    margin-bottom: 20px;
}

.completion p {
    color: var(--white);
    font-size: 1.3rem;
}

/* Tabs for admin */
.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.tab {
    flex: 1;
    padding: 12px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 8px;
    color: var(--white);
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s;
}

.tab.active {
    background: var(--white);
    color: var(--secondary);
    font-weight: 600;
}

/* Form elements */
input, textarea, select {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    margin-bottom: 12px;
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--secondary);
}

label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: var(--secondary);
}

/* Hotspot editor */
.hotspot-editor {
    position: relative;
    display: inline-block;
}

.hotspot-editor img {
    max-width: 100%;
    display: block;
}

.hotspot-marker {
    position: absolute;
    width: 40px;
    height: 40px;
    border: 3px solid var(--primary);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    box-shadow: 0 0 0 4px rgba(196, 30, 58, 0.3);
}

/* Hidden utility */
.hidden {
    display: none !important;
}

/* Back button */
.back-btn {
    position: absolute;
    top: 20px;
    left: 20px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: var(--white);
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
}

/* Screen sections */
.screen {
    display: none;
}

.screen.active {
    display: block;
}

/* Hotspot indicator in photo viewer */
.hotspot-indicator {
    position: absolute;
    border: 3px solid var(--gold);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    box-shadow: 0 0 0 4px rgba(212, 175, 55, 0.3),
                0 0 20px rgba(212, 175, 55, 0.4);
    animation: pulse-hotspot 2s ease-in-out infinite;
}

@keyframes pulse-hotspot {
    0%, 100% {
        box-shadow: 0 0 0 4px rgba(212, 175, 55, 0.3),
                    0 0 20px rgba(212, 175, 55, 0.4);
        transform: translate(-50%, -50%) scale(1);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(212, 175, 55, 0.2),
                    0 0 30px rgba(212, 175, 55, 0.5);
        transform: translate(-50%, -50%) scale(1.1);
    }
}
