:root {
    --background-color: #ffffff;
    --text-color: #333333;
    --card-background: #f8f9fa;
    --card-border: #333333;
    --card-flipped-background: #ffffff;
    --modal-background: #ffffff;
    --modal-text: #333333;
    --modal-border: rgba(0,0,0,0.2);
}

[data-theme="dark"] {
    --background-color: #333333;
    --text-color: #ffffff;
    --card-background: #444444;
    --card-border: #666666;
    --card-flipped-background: #555555;
    --modal-background: #444444;
    --modal-text: #ffffff;
    --modal-border: rgba(255,255,255,0.2);
}

body {
    background-color: var(--background-color);
    color: var(--text-color);
    transition: background-color 0.3s, color 0.3s;
}

#timer {
    margin: 5px auto;
    width: 90%;
    max-width: 280px;
}

#timeDisplay {
    text-align: center;
    font-size: 16px;
    margin: 5px auto;
    width: 85%;
    max-width: 280px;
}

#gameGrid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 3px;
    padding: 2px;
    width: 95%;
    max-width: 300px;
    margin: 2px auto;
    justify-content: center;
}

.card {
    width: 100%;
    aspect-ratio: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--card-background);
    border: 2px solid var(--card-border);
    cursor: pointer;
    margin: 0;
    padding: 0;
    box-shadow: none;
    transition: transform 0.4s ease;
    transform-style: preserve-3d;
    perspective: 1000px;
    max-width: none;
    max-height: none;
    height: calc((100vh - 180px) / 6); 
    min-height: 35px;
    max-height: 65px; 
    transform-origin: center;
    overflow: hidden;
}


.card i {
    font-size: clamp(1.5rem, 4vw, 2.2rem); 
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--card-flipped-background);
    color: var(--text-color);
    opacity: 0;
    transition: none;
    pointer-events: none;
}

.card.flipped {
    transform: rotateY(180deg);
    background-color: var(--card-flipped-background);
}

.card.flipped i {
    opacity: 1;
    transform: translate(-50%, -50%) rotateY(180deg);
    transition: none;
}

#overallScoreboardButton {
    display: none;
    margin: 20px auto;
    display: block;
    width: fit-content;
}

.progress-bar {
    transition: width 1s linear;
    background-color: #28a745;
}

.progress-bar.warning {
    background-color: #dc3545;
}

.container {
    width: 100%;
    padding: 0 5px;
    margin: 0 auto;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    max-width: 800px;
    padding: 0 15px;
}

button {
    min-height: 44px;
    padding: 10px 20px;
    margin: 5px;
}

@media screen and (min-width: 768px) {
    #gameGrid {
        grid-template-columns: repeat(4, 1fr);
        gap: 8px;
        max-width: 600px;
        margin: 5px auto;
    }

    .card {
        aspect-ratio: 3/4;
        height: calc((100vh - 220px) / 4);
        min-height: 70px;
        max-height: 110px;
    }

    .card i {
        font-size: clamp(2.2rem, 4.5vw, 3rem);
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 100%;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        background-color: var(--card-flipped-background);
        color: var(--text-color);
    }

    .card.flipped i {
        transform: translate(-50%, -50%) rotateY(180deg);
    }

    #timer, #timeDisplay {
        width: 80%;
        max-width: 600px;
        margin: 8px auto;
    }

    #timeDisplay {
        font-size: 18px;
    }

    .container {
        padding: 0 20px;
        max-width: 850px;
    }

    button {
        font-size: 18px;
        padding: 12px 25px;
    }

    .title-wrapper {
        height: 12vw;
        min-height: 80px;
        max-height: 120px;
    }
    
    .title-text {
        font-size: 12vw;
    }

    .game-title {
        padding: 15px 0;
        margin-bottom: 12px;
    }
}


@media screen and (min-width: 900px) and (max-width: 1023px) {
    .card i {
        font-size: clamp(2.5rem, 5vw, 3.2rem); 
    }
}

@media screen and (min-width: 1024px) {
    #gameGrid {
        grid-template-columns: repeat(5, 1fr);
        gap: 10px;
        max-width: 800px;
    }

    .card {
        width: 100px;
        height: 140px;
        aspect-ratio: auto;
        min-height: 140px;
        max-height: 140px;
    }

    .card i {
        font-size: 2.5rem; 
    }

    #timer, #timeDisplay {
        width: 50%;
        margin: 10px auto;
    }

    .container {
        width: 580px;
    }

    .title-wrapper {
        height: 12vw;
        max-height: 160px;
    }
    
    .title-text {
        font-size: 10vw;
    }

    .game-title {
        padding: 20px 0;
        margin-bottom: 15px;
    }
}

.modal-dialog {
    margin: 10px;
    max-width: calc(100% - 20px);
    display: flex;
    align-items: center;
    min-height: calc(100% - 60px);
}

@media screen and (min-width: 576px) {
    .modal-dialog {
        margin: 30px auto;
        max-width: 500px;
    }
}

.game-title {
    text-align: center;
    padding: 20px 0;
    margin-bottom: 20px;
    width: 100%;
}

.title-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    width: 100%;
    height: 15vw;
    min-height: 60px;
    max-height: 80px;
    margin: 0 auto;
    padding: 0 15px;
}

.title-svg {
    height: 100%;
    width: 100%;
    overflow: visible;
}

.title-text {
    font-family: 'Bangers', cursive;
    font-weight: normal;
    font-size: clamp(40px, 10vw, 80px);
    fill: url(#titleGradient);
    letter-spacing: 2px;
    text-align: center;
    margin: 0 auto;
    padding: 0 10px;
    white-space: nowrap;
}

.gradient-stop-1 {
    stop-color: #FF0000;
    animation: gradientShift 15s infinite linear;
}

.gradient-stop-2 {
    stop-color: #FF0000;
    animation: gradientShift 15s infinite linear;
    animation-delay: -7.5s;
}

@media screen and (max-width: 768px) {
    .title-wrapper {
        height: 20vw;
        min-height: 50px;
        max-height: 70px;
    }
    
    .title-text {
        font-size: clamp(30px, 8vw, 60px);
    }
}

@media screen and (max-width: 480px) {
    .title-wrapper {
        height: 25vw;
        min-height: 40px;
    }
}

@media screen and (max-width: 768px) {
    .title-text {
        font-size: 3.5rem;
    }

    .title-wrapper {
        gap: 10px;
    }
}

@media screen and (max-height: 600px) {
    .title-wrapper {
        height: 50px;
    }
    
    .title-text {
        font-size: 30px;
    }

    .game-title {
        padding: 5px 0;
        margin-bottom: 5px;
    }
}

@keyframes floatIcon {
    0%, 100% { 
        transform: translateY(0) rotate(0); 
        filter: drop-shadow(0 2px 2px rgba(0,0,0,0.1));
    }
    50% { 
        transform: translateY(-8px) rotate(5deg); 
        filter: drop-shadow(0 8px 6px rgba(0,0,0,0.2));
    }
}

@keyframes shineText {
    0%, 100% { filter: url(#shadow) brightness(1); }
    50% { filter: url(#shadow) brightness(1.2) drop-shadow(0 0 15px rgba(65,88,208,0.5)); }
}

@keyframes float {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-10px) rotate(5deg); }
}

@keyframes glow {
    0%, 100% { 
        filter: url(#shadow) drop-shadow(0 0 5px rgba(65, 88, 208, 0.7));
    }
    50% { 
        filter: url(#shadow) drop-shadow(0 0 20px rgba(200, 80, 192, 0.9));
    }
}

@keyframes wobble {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-5px); }
}

@keyframes bounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

@keyframes floatText {
    0%, 100% { 
        transform: translateY(0);
        filter: url(#shadow) drop-shadow(0 2px 2px rgba(0,0,0,0.1));
    }
    50% { 
        transform: translateY(-8px);
        filter: url(#shadow) drop-shadow(0 8px 6px rgba(0,0,0,0.2));
    }
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

#nicknameModal {
    display: none;
}

#nicknameModal .modal-dialog {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) !important;
    margin: 0;
    width: 90%;
    max-width: 500px;
}

@media screen and (max-height: 600px) {
    .game-title {
        padding: 10px 0;
        margin-bottom: 5px;
    }

    .title-wrapper {
        height: 50px;
    }

    .title-svg {
        height: 50px;
    }

    .title-text {
        font-size: 2rem;
    }

    #timer, #timeDisplay {
        margin: 3px auto;
    }

    #gameGrid {
        grid-template-columns: repeat(6, 1fr);
        gap: 5px;
        padding: 5px;
        max-width: 90vw;
    }

    .card {
        aspect-ratio: 1;
        height: calc((100vh - 120px) / 4);
        max-height: 80px;
    }

    .card i {
        font-size: clamp(1rem, 3vw, 2rem);
    }
}


.theme-switch {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
}

.switch-label {
    position: relative;
    display: inline-block;
    width: 64px;
    height: 32px;
    margin: 0;
    padding: 0;
}

.switch-label input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
    margin: 0;
    padding: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #ffd700;
    border-radius: 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px;
    transition: .4s;
    border: 2px solid rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.slider:before {
    position: absolute;
    content: "";
    height: 24px;
    width: 24px;
    left: 4px;
    background-color: white;
    border-radius: 50%;
    transition: .4s;
    z-index: 2;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.slider i {
    color: #333;
    font-size: 16px;
    z-index: 1;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
}

.slider i.bi-sun {
    right: 7px;
    color: #333;
}

.slider i.bi-moon {
    left: 7px;
    color: #fff;
    opacity: 0;
}


input:checked + .slider {
    background: #2c3e50;
}

input:checked + .slider:before {
    transform: translateX(32px);
}

input:checked + .slider i.bi-sun {
    opacity: 0;
}

input:checked + .slider i.bi-moon {
    opacity: 1;
}

#cookieConsent {
    position: fixed;
    bottom: 0;
    width: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    color: white;
    text-align: center;
    padding: 20px;
    z-index: 9999;
}

.cookie-notice {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 1rem;
    text-align: center;
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
}

.cookie-notice button {
    white-space: nowrap;
    min-width: 120px;
}

.title-text {
    font-size: 48px;
    text-align: center;
    margin: 20px 0;
    color: #333;
    font-family: 'Bangers', cursive;
    background: linear-gradient(90deg, 
        #ff6b6b 0%, 
        #ffd93d 20%, 
        #6bd4ff 40%, 
        #95ff6b 60%, 
        #6b95ff 80%, 
        #ff6bf5 100%
    );
    background-size: 200% auto;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: gradientShift 15s linear infinite;
}


.modal-content {
    background-color: var(--modal-background);
    color: var(--modal-text);
    border-color: var(--modal-border);
}

.modal-header {
    border-bottom-color: var(--modal-border);
}

.modal-footer {
    border-top-color: var(--modal-border);
}

.close {
    color: var(--modal-text);
    text-shadow: none;
}

.close:hover {
    color: var(--modal-text);
    opacity: 0.75;
}


[data-theme="dark"] .form-control {
    background-color: #555555;
    border-color: #666666;
    color: #ffffff;
}

[data-theme="dark"] .form-control:focus {
    background-color: #666666;
    border-color: #777777;
    color: #ffffff;
}


[data-theme="dark"] .table {
    color: var(--text-color);
}

[data-theme="dark"] .table-striped tbody tr:nth-of-type(odd) {
    background-color: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .table-striped tbody tr:nth-of-type(even) {
    background-color: transparent;
}

[data-theme="dark"] .text-center {
    color: var(--text-color);
}

@media screen and (max-width: 320px) {
    #gameGrid {
        grid-template-columns: repeat(3, 1fr);
        gap: 2px;
        padding: 1px;
        margin: 1px auto;
    }

    .card {
        height: calc((100vh - 150px) / 6);
        min-height: 30px;
        max-height: 50px;
    }

    .card i {
        font-size: clamp(1.2rem, 3.5vw, 1.8rem); 
    }

    .title-wrapper {
        height: 50px;
        min-height: 40px;
    }
}

@media screen and (min-height: 800px) {
    .card {
        max-height: none;
    }
}


@media screen and (max-height: 450px) and (orientation: landscape) {
    .title-wrapper {
        height: 25px;
        min-height: 25px;
        margin-bottom: 2px;
    }

    #gameGrid {
        grid-template-columns: repeat(6, 1fr);
        gap: 3px;
        padding: 2px;
        margin: 2px auto;
    }

    .card {
        height: calc((100vh - 60px) / 3);
        min-height: 35px;
        max-height: 60px;
    }

    .card i {
        font-size: clamp(1.3rem, 3vw, 2rem); 
    }
}

.btn {
    display: block;
    margin: 10px auto;
}
