:root {
    --primary: #8b5cf6;
    --primary-dark: #7c3aed;
    --primary-gradient: linear-gradient(135deg, #7c3aed 0%, #8b5cf6 100%);
    --surface-glass: rgba(5, 15, 25, 0.4);
    --surface-glass-border: rgba(255, 255, 255, 0.1);
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.6);
    --accent: #facc15;
    --radius-lg: 16px;
    --radius-md: 12px;
    --shadow-glass: 0 10px 40px -10px rgba(0, 0, 0, 0.5);
    --bg-deep: #020617;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
    background: #020617;
    background: radial-gradient(circle at 20% 30%, #0c4a6e 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, #1e1b4b 0%, transparent 50%),
        linear-gradient(180deg, #020617 0%, #0f172a 100%);
    min-height: 100vh;
    color: var(--text-primary);
    overflow: hidden;
    user-select: none;
    -webkit-font-smoothing: antialiased;
}

select {
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    font-size: 1rem;
    outline: none;
}

select option {
    background: #0a1f33;
    color: white;
}

/* User Table Styles */
.user-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    background: var(--surface-glass);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.user-table th,
.user-table td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid var(--surface-glass-border);
}

.user-table th {
    background: rgba(0, 229, 255, 0.1);
    color: var(--primary);
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 1px;
}

.user-table tr:hover {
    background: rgba(255, 255, 255, 0.05);
}


.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

.sidebar {
    width: 350px;
    background: var(--surface-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-right: 1px solid var(--surface-glass-border);
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    box-shadow: var(--shadow-glass);
    z-index: 10;
}

.title {
    font-size: 2rem;
    font-weight: 800;
    background: linear-gradient(to right, #fff, #a5a5a5);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.control-group {
    background: rgba(0, 0, 0, 0.1);
    padding: 1.5rem;
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.label {
    display: block;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    font-weight: 600;
}

input[type="number"],
input[type="text"],
input[type="password"] {
    width: 100%;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.75rem;
    border-radius: 8px;
    color: white;
    font-size: 1rem;
    margin-bottom: 0.5rem;
    transition: all 0.2s;
}

input:focus {
    outline: none;
    border-color: var(--accent);
    background: rgba(255, 255, 255, 0.15);
}

.file-upload-label {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: var(--primary-gradient);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 600;
    transition: transform 0.2s, box-shadow 0.2s;
    text-align: center;
    color: white;
    border: none;
}

.file-upload-label:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(118, 75, 162, 0.4);
}

.play-area {
    flex-grow: 1;
    position: relative;
    background-image:
        radial-gradient(circle at 10% 20%, rgba(255, 255, 255, 0.03) 0%, transparent 20%),
        radial-gradient(circle at 90% 80%, rgba(255, 255, 255, 0.03) 0%, transparent 20%);
    overflow: hidden;
    cursor: grab;
}

.play-area:active {
    cursor: grabbing;
}

canvas {
    display: block;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    border-radius: 4px;
}

#guide-image {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 200px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    opacity: 0.8;
    pointer-events: none;
    z-index: 100;
    display: none;
}

/* Win Overlay & Modals */
.win-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

.win-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.win-title {
    font-size: 4rem;
    font-weight: 900;
    background: var(--primary-gradient);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 2rem;
    transform: scale(0.5);
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.win-overlay.active .win-title {
    transform: scale(1);
}

.btn-reset {
    background: white;
    color: #302b63;
    border: none;
    padding: 1rem 2rem;
    font-size: 1.2rem;
    font-weight: bold;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: transform 0.2s;
}

.btn-reset:hover {
    transform: scale(1.05);
}

/* UI Views and Navigation */
.view-section {
    width: 100vw;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    padding-top: 80px;
}

.hero {
    text-align: center;
    padding: 3rem 2rem;
}

.nav-btn {
    color: white;
    text-decoration: none;
    margin-left: 20px;
    font-weight: 600;
    font-size: 0.9rem;
    transition: color 0.2s;
}

.nav-btn:hover {
    color: var(--accent);
}

.nav-btn-h {
    background: var(--primary-gradient);
    border: none;
    padding: 8px 20px;
    border-radius: 20px;
    color: white;
    cursor: pointer;
    margin-left: 20px;
    font-weight: 600;
    transition: transform 0.2s;
    text-decoration: none;
}

.nav-btn-h:hover {
    transform: translateY(-2px);
}

.nav-btn-h.active {
    background: #fff !important;
    color: #000 !important;
}

/* Sub-navigation for admin categories */
.sub-nav .nav-btn-h {
    padding: 6px 12px;
    font-size: 0.8rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.sub-nav .nav-btn-h.active {
    background: var(--primary) !important;
    color: #000 !important;
    border-color: var(--primary);
}

/* Voucher Status Badges */
.status-badge {
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
}

.status-active {
    background: #4CAF50;
}

.status-expired {
    background: #f44336;
}

.status-inactive {
    background: #2196F3;
}

/* Grid and Cards */
.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 2.5rem;
    padding: 2rem 5rem;
}

.card {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(5px);
}

.card:hover {
    transform: translateY(-10px);
    background: rgba(255, 255, 255, 0.12);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4);
}

.card-img {
    width: 100%;
    height: 180px;
    object-fit: cover;
}

.card-body {
    padding: 1.5rem;
}

.card-title {
    font-weight: 800;
    margin-bottom: 8px;
    font-size: 1.1rem;
    color: #fff;
}

.card-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Delete button on cards */
.btn-delete-puzzle {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(244, 67, 54, 0.9);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    backdrop-filter: blur(5px);
    z-index: 10;
}

.btn-delete-puzzle:hover {
    background: rgba(244, 67, 54, 1);
    transform: scale(1.1);
}


/* Admin Styles */
.admin-list {
    max-width: 800px;
    margin-top: 20px;
}

.admin-item {
    transition: background 0.2s;
}

#auth-modal>div,
#difficulty-modal>div {
    animation: modalPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes modalPop {
    from {
        transform: scale(0.8);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes float {
    0% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-10px);
    }

    100% {
        transform: translateY(0px);
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

/* Puzzle Timer Overlay */
.puzzle-timer-overlay {
    position: absolute;
    top: 15px;
    left: 15px;
    z-index: 100;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'Orbitron', monospace;
    font-size: 1.2rem;
    font-weight: 800;
    color: #facc15;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    pointer-events: none;
}

.puzzle-timer-overlay #timer-icon {
    font-size: 1rem;
}

/* Corner Upload Items */
.corner-upload-item {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 6px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.corner-upload-btn {
    display: block;
    width: 100%;
    padding: 4px;
    margin-top: 4px;
    background: rgba(124, 58, 237, 0.3);
    border: 1px dashed rgba(124, 58, 237, 0.5);
    border-radius: 6px;
    color: white;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s;
}

.corner-upload-btn:hover:not(:disabled) {
    background: rgba(124, 58, 237, 0.5);
}

.corner-upload-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.corner-upload-btn.loaded {
    background: rgba(76, 175, 80, 0.3);
    border-color: rgba(76, 175, 80, 0.5);
}

/* Embed Floating Controls */
.embed-controls-bar {
    position: fixed;
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(12px);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 500;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}

.embed-controls-bar button {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: white;
    padding: 8px 14px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.2s;
}

.embed-controls-bar button:hover {
    background: rgba(124, 58, 237, 0.5);
    transform: translateY(-1px);
}

/* Order Status Badges */
.order-status-badge {
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
}

.order-status-pending { background: #FF9800; color: #000; }
.order-status-processing { background: #2196F3; color: #fff; }
.order-status-completed { background: #4CAF50; color: #fff; }
.order-status-rejected { background: #f44336; color: #fff; }

/* Embed Puzzle Item Card */
.embed-item {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 12px;
    transition: background 0.2s;
}

.embed-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

/* Toast Animations */
@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* Range input styling */
input[type="range"] {
    -webkit-appearance: none;
    height: 6px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(124, 58, 237, 0.4);
}