/* Font Faces */
@font-face {
    font-family: 'Nivea-Bold';
    src: url('assets/Nivea-Bold.otf') format('opentype');
    font-weight: bold;
    font-style: normal;
}

@font-face {
    font-family: 'Nivea-Regular';
    src: url('assets/Nivea-Regular.otf') format('opentype');
    font-weight: normal;
    font-style: normal;
}

/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Nivea-Regular', Arial, sans-serif;
    min-height: 100vh;
    background-image: url('assets/niveabg.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    color: white;
}

/* Game Container */
.game-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 10px 15px;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 20px;
    background: white;
    border-radius: 50px;
    margin-bottom: 10px;
    position: relative;
    z-index: 200;
}

.logo-img {
    width: 45px;
    height: 45px;
    object-fit: contain;
}

.nav-links {
    display: flex;
    gap: 25px;
}

.nav-link {
    color: #003366;
    text-decoration: none;
    font-family: 'Nivea-Regular', Arial, sans-serif;
    font-size: 14px;
    transition: opacity 0.3s ease;
}

.nav-link:hover {
    opacity: 0.7;
}

/* Game Title Section */
.game-title-section {
    text-align: center;
    margin-bottom: 8px;
}

.game-title {
    font-family: 'Nivea-Bold', Arial, sans-serif;
    font-size: 28px;
    letter-spacing: 2px;
    margin-bottom: 4px;
    text-transform: uppercase;
    font-style: italic;
}

.subtitle-timer-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
}

.game-subtitle {
    font-family: 'Nivea-Regular', Arial, sans-serif;
    font-size: 14px;
    opacity: 0.95;
    margin: 0;
}

.timer {
    font-family: 'Nivea-Bold', Arial, sans-serif;
    font-size: 16px;
    color: white;
    background: rgba(255, 255, 255, 0.2);
    padding: 3px 10px;
    border-radius: 20px;
}

/* Cards Grid */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    max-width: 420px;
    margin: 0 auto;
}

/* Card Styles */
.card {
    aspect-ratio: 0.8;
    perspective: 1000px;
    cursor: pointer;
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s ease;
    transform-style: preserve-3d;
}

.card.flipped .card-inner {
    transform: rotateY(180deg);
}

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    border: 3px solid #003366;
}

.card-front {
    transform: rotateY(180deg);
}

.card-back img,
.card-front img {
    width: 85%;
    height: 85%;
    object-fit: contain;
}

/* Card matched state */
.card.matched {
    cursor: default;
}

.card.matched .card-inner {
    animation: matchPulse 0.5s ease;
}

@keyframes matchPulse {

    0%,
    100% {
        transform: rotateY(180deg) scale(1);
    }

    50% {
        transform: rotateY(180deg) scale(1.05);
    }
}

/* Card disabled state */
.card.disabled {
    pointer-events: none;
}

/* Sparkle Effect */
.sparkle-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: visible;
    z-index: 10;
}

.sparkle-particle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: radial-gradient(circle, #4A90D9 0%, #003366 50%, transparent 70%);
    border-radius: 50%;
    animation: sparkleFloat 0.8s ease-out forwards;
}

.sparkle-particle::before {
    content: '✦';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 14px;
    color: #4A90D9;
    text-shadow: 0 0 5px #003366;
}

@keyframes sparkleFloat {
    0% {
        opacity: 1;
        transform: scale(0) rotate(0deg);
    }

    50% {
        opacity: 1;
        transform: scale(1.2) rotate(180deg);
    }

    100% {
        opacity: 0;
        transform: scale(0.5) rotate(360deg) translateY(-30px);
    }
}

/* Start Overlay - positioned below navbar */
.start-overlay {
    position: fixed;
    top: 80px;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 51, 102, 0.95);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(8px);
}

.start-overlay.active {
    display: flex;
}

.start-content {
    text-align: center;
    animation: modalSlideIn 0.5s ease;
}

.start-logo {
    width: 120px;
    height: 120px;
    object-fit: contain;
    margin-bottom: 30px;
}

.start-title {
    font-family: 'Nivea-Bold', Arial, sans-serif;
    font-size: 48px;
    color: white;
    letter-spacing: 4px;
    margin-bottom: 15px;
    text-transform: uppercase;
    font-style: italic;
}

.start-subtitle {
    font-family: 'Nivea-Regular', Arial, sans-serif;
    font-size: 20px;
    color: white;
    margin-bottom: 40px;
    opacity: 0.9;
}

.start-btn {
    font-family: 'Nivea-Bold', Arial, sans-serif;
    font-size: 20px;
    padding: 15px 50px;
    background: white;
    color: #003366;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.start-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 51, 102, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.modal-overlay.active {
    display: flex;
}

/* Confetti Container */
.confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1001;
    overflow: hidden;
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    background: white;
    opacity: 0.9;
    animation: confettiFall linear forwards;
}

.confetti:nth-child(odd) {
    border-radius: 50%;
}

.confetti:nth-child(even) {
    transform: rotate(45deg);
}

@keyframes confettiFall {
    0% {
        transform: translateY(-10px) rotate(0deg);
        opacity: 1;
    }

    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

.modal {
    background: white;
    padding: 50px 70px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.5s ease;
    z-index: 1002;
    position: relative;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(-30px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-title {
    font-family: 'Nivea-Bold', Arial, sans-serif;
    font-size: 36px;
    color: #003366;
    margin-bottom: 15px;
}

.modal-text {
    font-family: 'Nivea-Regular', Arial, sans-serif;
    font-size: 20px;
    color: #003366;
    margin-bottom: 30px;
}

.modal-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.modal-btn {
    font-family: 'Nivea-Regular', Arial, sans-serif;
    font-size: 16px;
    padding: 12px 30px;
    background: #003366;
    color: white;
    border: none;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
}

.modal-btn:hover {
    background: #004488;
    transform: scale(1.05);
}

.modal-btn-outline {
    background: transparent;
    border: 2px solid #003366;
    color: #003366;
}

.modal-btn-outline:hover {
    background: #003366;
    color: white;
}

/* Leaderboard Page Styles */
.leaderboard-page {
    max-width: 700px;
    margin: 0 auto;
    padding: 20px 15px;
    min-height: 100vh;
}

.leaderboard-hero {
    text-align: center;
    margin: 40px 0 30px;
}

.leaderboard-page-title {
    font-family: 'Nivea-Bold', Arial, sans-serif;
    font-size: 42px;
    color: white;
    text-transform: uppercase;
    letter-spacing: 3px;
    margin-bottom: 10px;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.leaderboard-page-subtitle {
    font-family: 'Nivea-Regular', Arial, sans-serif;
    font-size: 18px;
    color: white;
    opacity: 0.9;
}

.leaderboard-cta {
    text-align: center;
    margin-top: 30px;
}

.leaderboard-cta .start-btn {
    text-decoration: none;
    display: inline-block;
}

.leaderboard-container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.leaderboard-title {
    font-family: 'Nivea-Bold', Arial, sans-serif;
    font-size: 32px;
    color: #003366;
    text-align: center;
    margin-bottom: 25px;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.leaderboard-table-wrapper {
    max-height: 400px;
    overflow-y: auto;
    border-radius: 10px;
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'Nivea-Regular', Arial, sans-serif;
}

.leaderboard-table thead {
    background: #003366;
    color: white;
    position: sticky;
    top: 0;
}

.leaderboard-table th {
    padding: 15px 20px;
    text-align: left;
    font-family: 'Nivea-Bold', Arial, sans-serif;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.leaderboard-table th.rank-col {
    width: 60px;
    text-align: center;
}

.leaderboard-table th.time-col {
    width: 120px;
    text-align: right;
}

.leaderboard-table tbody tr {
    border-bottom: 1px solid rgba(0, 51, 102, 0.1);
    transition: background 0.3s ease;
}

.leaderboard-table tbody tr:hover {
    background: rgba(0, 51, 102, 0.05);
}

.leaderboard-table td {
    padding: 15px 20px;
    color: #003366;
    font-size: 16px;
}

.leaderboard-table td.rank-col {
    text-align: center;
    font-family: 'Nivea-Bold', Arial, sans-serif;
    font-size: 18px;
}

.leaderboard-table td.time-col {
    text-align: right;
    font-family: 'Nivea-Bold', Arial, sans-serif;
}

/* Top 3 rankings with medals */
.leaderboard-table tbody tr:nth-child(1) td.rank-col {
    color: #FFD700;
}

.leaderboard-table tbody tr:nth-child(2) td.rank-col {
    color: #C0C0C0;
}

.leaderboard-table tbody tr:nth-child(3) td.rank-col {
    color: #CD7F32;
}

.leaderboard-table tbody tr:nth-child(1) {
    background: rgba(255, 215, 0, 0.1);
}

.leaderboard-table tbody tr:nth-child(2) {
    background: rgba(192, 192, 192, 0.1);
}

.leaderboard-table tbody tr:nth-child(3) {
    background: rgba(205, 127, 50, 0.1);
}

.empty-row td {
    text-align: center;
    color: #666;
    font-style: italic;
    padding: 40px 20px;
}

/* Rank badges */
.rank-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    font-weight: bold;
}

.rank-1 {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    color: white;
    box-shadow: 0 2px 8px rgba(255, 215, 0, 0.4);
}

.rank-2 {
    background: linear-gradient(135deg, #C0C0C0, #A0A0A0);
    color: white;
    box-shadow: 0 2px 8px rgba(192, 192, 192, 0.4);
}

.rank-3 {
    background: linear-gradient(135deg, #CD7F32, #B87333);
    color: white;
    box-shadow: 0 2px 8px rgba(205, 127, 50, 0.4);
}

/* Registration Form Styles */
.register-modal {
    max-width: 650px !important;
    /* Wider modal like Mentos game */
    width: 90% !important;
    padding: 40px !important;
    border-radius: 20px !important;
    background: #ffffff !important;
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.3) !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    margin: 20px auto !important;
}

.register-form {
    text-align: left;
    width: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 25px !important;
    /* More space between fields */
    margin-top: 25px !important;
}

.form-group {
    margin-bottom: 0 !important;
    /* Managed by form gap */
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
    /* Space between label and input */
    width: 100% !important;
}

.form-group label {
    display: block;
    font-family: 'Nivea-Bold', Arial, sans-serif;
    font-size: 14px;
    color: #003366;
    margin-left: 10px !important;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.form-group input {
    width: 100%;
    padding: 15px 20px !important;
    font-family: 'Nivea-Regular', Arial, sans-serif;
    font-size: 16px;
    border: 2px solid #e0e0e0;
    border-radius: 50px !important;
    /* Pill shape */
    transition: all 0.3s ease;
    color: #003366;
    background: #fcfcfc !important;
}

.form-group input:focus {
    outline: none;
    border-color: #003366;
    box-shadow: 0 0 10px rgba(0, 51, 102, 0.1) !important;
    background: white !important;
}

.form-group input::placeholder {
    color: #003366 !important;
    opacity: 0.3 !important;
    /* Faded placeholders */
}

.form-buttons {
    display: flex !important;
    gap: 20px !important;
    margin-top: 15px !important;
    width: 100% !important;
    flex-wrap: nowrap !important;
    /* Don't bend buttons */
}

.form-buttons .modal-btn {
    flex: 1 !important;
    padding: 16px !important;
    white-space: nowrap !important;
}

.form-message {
    margin-top: 15px;
    font-family: 'Nivea-Regular', Arial, sans-serif;
    font-size: 14px;
    text-align: center;
    min-height: 20px;
}

.form-message.success {
    color: #28a745;
}

.form-message.error {
    color: #dc3545;
}

.form-message.info {
    color: #003366;
}

/* Responsive Design */

@media (max-width: 768px) {
    .game-container {
        padding: 15px;
    }

    .header {
        padding: 12px 20px;
        border-radius: 30px;
        margin-bottom: 20px;
    }

    .logo-img {
        width: 50px;
        height: 50px;
    }

    .nav-links {
        gap: 15px;
    }

    .nav-link {
        font-size: 14px;
    }

    .game-title {
        font-size: 28px;
        letter-spacing: 2px;
    }

    .subtitle-timer-row {
        gap: 15px;
    }

    .game-subtitle {
        font-size: 14px;
    }

    .timer {
        font-size: 16px;
    }

    .cards-grid {
        gap: 10px;
    }

    .modal {
        padding: 30px 40px;
        margin: 20px;
    }

    .modal-title {
        font-size: 28px;
    }

    .modal-text {
        font-size: 16px;
    }

    .start-logo {
        width: 80px;
        height: 80px;
        margin-bottom: 20px;
    }

    .start-title {
        font-size: 32px;
        letter-spacing: 2px;
    }

    .start-subtitle {
        font-size: 16px;
        margin-bottom: 30px;
        padding: 0 20px;
    }

    .start-btn {
        font-size: 16px;
        padding: 12px 40px;
    }
}

@media (max-width: 500px) {
    .game-container {
        padding: 8px;
    }

    .header {
        padding: 8px 12px;
        flex-direction: row;
        border-radius: 25px;
        margin-bottom: 15px;
    }

    .logo-img {
        width: 35px;
        height: 35px;
    }

    .nav-links {
        gap: 8px;
    }

    .nav-link {
        font-size: 11px;
    }

    .game-title-section {
        margin-bottom: 8px;
    }

    .game-title {
        font-size: 18px;
        letter-spacing: 1px;
        margin-bottom: 4px;
    }

    .subtitle-timer-row {
        gap: 10px;
    }

    .game-subtitle {
        font-size: 10px;
    }

    .timer {
        font-size: 12px;
        padding: 3px 8px;
    }

    .cards-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 5px;
        max-width: 100%;
    }

    .card {
        aspect-ratio: 0.75;
    }

    .card-face {
        border-width: 2px;
        border-radius: 6px;
    }

    .card-back img,
    .card-front img {
        width: 80%;
        height: 80%;
    }

    .start-title {
        font-size: 22px;
    }

    .start-subtitle {
        font-size: 13px;
        padding: 0 15px;
    }

    .start-btn {
        font-size: 14px;
        padding: 10px 30px;
    }

    .modal {
        padding: 25px 20px !important;
        margin: 15px !important;
        width: 92% !important;
        max-height: 90vh !important;
        overflow-y: auto !important;
    }

    .register-modal {
        padding: 30px 20px !important;
    }

    .register-form {
        gap: 15px !important;
    }

    .form-buttons {
        gap: 10px !important;
    }

    .modal-title {
        font-size: 24px;
    }

    .modal-text {
        font-size: 14px;
    }

    .modal-btn {
        font-size: 14px;
        padding: 12px 20px !important;
    }
}

/* Extra small screens - keep 4x2 grid but even smaller */
@media (max-width: 380px) {
    .game-container {
        padding: 6px;
    }

    .header {
        padding: 6px 10px;
        margin-bottom: 10px;
    }

    .logo-img {
        width: 30px;
        height: 30px;
    }

    .nav-link {
        font-size: 10px;
    }

    .game-title {
        font-size: 14px;
    }

    .subtitle-timer-row {
        gap: 8px;
    }

    .game-subtitle {
        font-size: 9px;
    }

    .timer {
        font-size: 10px;
        padding: 2px 6px;
    }

    .cards-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 4px;
    }

    .card {
        aspect-ratio: 0.75;
    }

    .card-face {
        border-width: 1px;
        border-radius: 4px;
    }

    .card-back img,
    .card-front img {
        width: 75%;
        height: 75%;
    }

    .start-logo {
        width: 60px;
        height: 60px;
        margin-bottom: 15px;
    }

    .start-title {
        font-size: 18px;
    }

    .start-subtitle {
        font-size: 11px;
        margin-bottom: 20px;
    }

    .start-btn {
        font-size: 12px;
        padding: 8px 25px;
    }
}