@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Courier+Prime:wght@400;700&display=swap');

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

body {
    font-family: 'Orbitron', 'Courier Prime', monospace;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 25%, #0f3460 50%, #533483 75%, #1a1a2e 100%);
    background-size: 400% 400%;
    min-height: 100vh;
    padding: 20px;
    position: relative;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        radial-gradient(circle at 20% 50%, rgba(255, 107, 107, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(78, 205, 196, 0.1) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

header {
    text-align: center;
    color: white;
    margin-bottom: 40px;
    animation: slideDown 0.6s ease-out;
    position: relative;
    z-index: 10;
}

.header-logo {
    display: flex;
    justify-content: center;
    margin-bottom: 15px;
    animation: float 3s ease-in-out infinite;
    /* keep the logo container aligned with the page content width */
    width: auto;
    margin-left: 0;
}

.header-logo a {
    display: flex;
    justify-content: center;
    align-items: center;
    text-decoration: none;
}

.thermofly-logo {
    /* make the logo span the full width of the viewport */
    display: block;
    width: auto; /* keep natural aspect ratio */
    /* cap size so it stays readable but never overflows on small screens */
    max-width: 220px;
    max-height: 90px;
    height: auto;
    object-fit: contain;
    filter: drop-shadow(0 0 20px rgba(255, 107, 107, 0.6)) drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.5));
    transition: transform 0.3s ease;
    cursor: pointer;
}

/* Reduce logo size further on small phones */
@media (max-width: 480px) {
    .thermofly-logo {
        max-width: 140px;
        max-height: 60px;
    }
}

/* Ensure header text scales on small screens so logo remains visible */
@media (max-width: 600px) {
    header h1 {
        font-size: 2.2rem;
    }
    header .subtitle {
        font-size: 1rem;
    }
}

/* On very small screens, put logo and title on one line */
@media (max-width: 480px) {
    header {
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: center;
        gap: 12px;
        text-align: center; /* keep centered alignment for multi-line fallback */
        margin-bottom: 20px;
    }

    .header-logo {
        margin-bottom: 0; /* remove extra gap so logo sits inline */
        flex: 0 0 auto;
    }

    header h1 {
        font-size: 1.6rem;
        line-height: 1;
        margin: 0; /* tighten spacing */
    }

    header .subtitle {
        display: none; /* hide subtitle to keep header on one line */
    }
}

.thermofly-logo:hover {
    transform: scale(1.1) rotate(5deg);
}

@keyframes float {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-10px);
    }
}

header h1 {
    font-size: 4.5rem;
    margin-bottom: 10px;
    margin-top: 0;
    line-height: 1.1;
    text-shadow: 0 0 20px rgba(255, 107, 107, 0.8), 2px 2px 4px rgba(0, 0, 0, 0.8);
    letter-spacing: 2px;
    font-weight: 900;
}

header .subtitle {
    font-size: 1.2rem;
    opacity: 0.9;
    text-shadow: 0 0 10px rgba(78, 205, 196, 0.5);
    letter-spacing: 1px;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Setup Section */
.setup-section {
    display: flex;
    justify-content: center;
    align-items: center;
}

.setup-card {
    background: linear-gradient(135deg, rgba(26, 26, 46, 0.95) 0%, rgba(15, 52, 96, 0.95) 100%);
    border-radius: 20px;
    padding: 40px;
    box-shadow: 
        0 20px 60px rgba(0, 0, 0, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.1),
        0 0 20px rgba(255, 107, 107, 0.2);
    max-width: 500px;
    width: 100%;
    animation: fadeInUp 0.6s ease-out;
    border: 1px solid rgba(78, 205, 196, 0.3);
    color: white;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.setup-card h2 {
    color: #4ECDC4;
    margin-bottom: 30px;
    font-size: 2rem;
    text-shadow: 0 0 10px rgba(78, 205, 196, 0.5);
    letter-spacing: 1px;
}

.form-group {
    margin-bottom: 25px;
}

.form-group label {
    display: block;
    margin-bottom: 10px;
    color: #4ECDC4;
    font-weight: 700;
    font-size: 1rem;
    text-shadow: 0 0 5px rgba(78, 205, 196, 0.3);
}

.form-group select,
.form-group input[type="file"] {
    width: 100%;
    padding: 12px;
    border: 2px solid rgba(78, 205, 196, 0.5);
    border-radius: 8px;
    font-size: 1rem;
    background: rgba(255, 255, 255, 0.05);
    color: white;
    font-family: 'Orbitron', 'Courier Prime', monospace;
    transition: all 0.3s ease;
}
    transition: all 0.3s ease;
}

.form-group select:focus,
.form-group input[type="file"]:focus {
    outline: none;
    border-color: #4ECDC4;
    box-shadow: 0 0 0 3px rgba(78, 205, 196, 0.2), inset 0 0 10px rgba(78, 205, 196, 0.1);
    background: rgba(255, 255, 255, 0.1);
}

.image-options {
    display: flex;
    gap: 10px;
}

.btn-option {
    flex: 1;
    padding: 15px;
    border: 2px solid rgba(78, 205, 196, 0.3);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 700;
    color: #4ECDC4;
    font-family: 'Orbitron', 'Courier Prime', monospace;
}

.btn-option:hover {
    border-color: #4ECDC4;
    background: rgba(78, 205, 196, 0.1);
    box-shadow: 0 0 15px rgba(78, 205, 196, 0.3);
}

.btn-option.active {
    border-color: #4ECDC4;
    background: linear-gradient(135deg, rgba(78, 205, 196, 0.3), rgba(255, 107, 107, 0.2));
    color: #4ECDC4;
    box-shadow: 0 0 20px rgba(78, 205, 196, 0.5);
}

.btn-option .preview {
    display: block;
    font-size: 0.9rem;
}

.uploaded-images {
    margin-bottom: 20px;
    padding: 15px;
    background: rgba(78, 205, 196, 0.1);
    border-radius: 8px;
    border: 1px solid rgba(78, 205, 196, 0.3);
}

.uploaded-images h4 {
    color: #4ECDC4;
    margin-bottom: 10px;
    text-shadow: 0 0 5px rgba(78, 205, 196, 0.3);
}

.image-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 10px;
}

.image-preview-grid img {
    width: 100%;
    height: 80px;
    object-fit: cover;
    border-radius: 8px;
    border: 2px solid #4ECDC4;
    box-shadow: 0 0 10px rgba(78, 205, 196, 0.3);
}

.btn-primary,
.btn-secondary {
    width: 100%;
    padding: 15px;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 10px;
    font-family: 'Orbitron', monospace;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.btn-primary {
    background: linear-gradient(135deg, #FF6B6B 0%, #FF3333 100%);
    color: white;
    box-shadow: 0 5px 15px rgba(255, 107, 107, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(255, 107, 107, 0.5);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: transparent;
    color: #4ECDC4;
    border: 2px solid #4ECDC4;
    box-shadow: 0 0 10px rgba(78, 205, 196, 0.2);
}

.btn-secondary:hover {
    background: rgba(78, 205, 196, 0.1);
    box-shadow: 0 0 20px rgba(78, 205, 196, 0.4);
}

/* Game Section */
.game-section {
    animation: fadeInUp 0.6s ease-out;
}

.game-info {
    background: white;
    border-radius: 15px;
    padding: 25px;
    margin-bottom: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.score-board {
    margin-bottom: 20px;
}

.player-score {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    background: #f5f7ff;
    border-radius: 8px;
    margin-bottom: 10px;
    font-weight: 600;
}

.player-score.active-player {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

.player-name {
    font-size: 1.1rem;
    color: #4ECDC4;
    font-family: 'Orbitron', monospace;
    letter-spacing: 0.5px;
}

.player-score-value {
    font-size: 1.3rem;
    color: #FF6B6B;
    font-weight: 900;
    font-family: 'Orbitron', monospace;
}

.game-stats {
    display: flex;
    justify-content: space-around;
    padding-top: 15px;
    border-top: 1px solid rgba(78, 205, 196, 0.3);
}

.stat {
    text-align: center;
}

.stat-label {
    display: block;
    color: rgba(78, 205, 196, 0.7);
    font-size: 0.9rem;
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    display: block;
    font-size: 1.8rem;
    color: #FF6B6B;
    font-weight: 900;
    font-family: 'Orbitron', monospace;
}

/* Game Board */
.game-board {
    display: grid;
    gap: 15px;
    margin-bottom: 30px;
    padding: 20px;
    background: linear-gradient(135deg, rgba(26, 26, 46, 0.5) 0%, rgba(15, 52, 96, 0.5) 100%);
    border-radius: 15px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(78, 205, 196, 0.2);
    box-shadow: 
        inset 0 1px 0 rgba(255, 255, 255, 0.05),
        0 10px 30px rgba(0, 0, 0, 0.3);
}

.game-board.grid-2x2 {
    grid-template-columns: repeat(2, 1fr);
}

.game-board.grid-2x4 {
    grid-template-columns: repeat(2, 1fr);
}

.game-board.grid-3x4 {
    grid-template-columns: repeat(3, 1fr);
}

.game-board.grid-4x4 {
    grid-template-columns: repeat(4, 1fr);
}

@media (min-width: 768px) {
    .game-board.grid-2x4 {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .game-board.grid-3x4 {
        grid-template-columns: repeat(4, 1fr);
    }
}

.card {
    aspect-ratio: 1;
    background: linear-gradient(135deg, rgba(255, 107, 107, 0.8) 0%, rgba(255, 51, 51, 0.8) 100%);
    border: 2px solid rgba(78, 205, 196, 0.3);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    box-shadow: 
        0 5px 15px rgba(255, 107, 107, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    font-size: 5.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 0;
    font-family: 'Orbitron', monospace;
}

.card-back {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #c41e3a 0%, #a01829 50%, #c41e3a 100%);
    position: relative;
    font-size: 3rem;
    text-shadow: 0 0 10px rgba(255, 107, 107, 0.5);
}

.card-back::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        repeating-linear-gradient(45deg, transparent, transparent 35px, rgba(255,255,255,.05) 35px, rgba(255,255,255,.05) 70px),
        repeating-linear-gradient(-45deg, transparent, transparent 35px, rgba(255,255,255,.05) 35px, rgba(255,255,255,.05) 70px);
    pointer-events: none;
}

.card-back::after {
    content: '♠';
    position: relative;
    z-index: 1;
    color: white;
    font-size: 2.5rem;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.card-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

.card:hover:not(.matched):not(.flipped) {
    transform: translateY(-5px);
    box-shadow: 
        0 10px 25px rgba(255, 107, 107, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    border-color: rgba(78, 205, 196, 0.5);
}

.card:active:not(.matched):not(.flipped) {
    transform: translateY(-2px);
}

.card.flipped {
    background: linear-gradient(135deg, rgba(78, 205, 196, 0.8) 0%, rgba(76, 205, 196, 0.6) 100%);
    pointer-events: none;
    animation: flip 0.6s ease-in-out;
    padding: 0;
    border-color: rgba(78, 205, 196, 0.5);
}

.card.flipped .card-back {
    display: none;
}

.card.flipped .card-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.card.matched {
    background: linear-gradient(135deg, rgba(76, 205, 150, 0.8) 0%, rgba(76, 205, 150, 0.6) 100%);
    animation: matched 0.6s ease-in-out;
    pointer-events: none;
    box-shadow: 
        0 5px 15px rgba(76, 205, 150, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.2),
        0 0 20px rgba(76, 205, 150, 0.3);
    border-color: rgba(76, 205, 150, 0.5);
}

.card.shake {
    animation: shake 0.5s ease-in-out;
}

@keyframes flip {
    0% {
        transform: rotateY(0deg);
    }
    100% {
        transform: rotateY(180deg);
    }
}

@keyframes matched {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-10px);
    }
    75% {
        transform: translateX(10px);
    }
}

/* Game Over Modal */
.game-over {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease-out;
}

.game-over-content {
    background: white;
    border-radius: 20px;
    padding: 50px;
    text-align: center;
    max-width: 500px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: popIn 0.4s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes popIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.game-over-content h2 {
    color: #667eea;
    font-size: 2.5rem;
    margin-bottom: 30px;
}

.results-container {
    margin-bottom: 30px;
    text-align: left;
}

.result-item {
    padding: 15px;
    margin-bottom: 10px;
    background: rgba(78, 205, 196, 0.1);
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid rgba(78, 205, 196, 0.3);
    color: #4ECDC4;
    font-weight: 700;
    font-family: 'Orbitron', monospace;
}

.result-item.winner {
    background: linear-gradient(135deg, rgba(255, 107, 107, 0.3) 0%, rgba(78, 205, 196, 0.2) 100%);
    color: #FF6B6B;
    font-weight: 900;
    font-size: 1.1rem;
    border: 2px solid rgba(255, 107, 107, 0.5);
    box-shadow: 0 0 15px rgba(255, 107, 107, 0.2);
}

.result-item.podium {
    border-left: 4px solid #4ECDC4;
}

/* Responsive */
@media (max-width: 768px) {
    header h1 {
        font-size: 2.5rem;
    }
    
    .setup-card {
        padding: 25px;
    }
    
    .game-board {
        gap: 10px;
        padding: 15px;
    }
    
    .card {
        font-size: 2rem;
    }
    
    .game-over-content {
        padding: 30px 20px;
    }
}

/* Additional responsive styles for logo */
@media (max-width: 768px) {
    .container {
        padding: 10px;
        max-width: 100%;
    }

    header h1 {
        font-size: 2rem;
    }

    header .subtitle {
        font-size: 0.95rem;
    }

    /* Let JS control the exact width, but ensure CSS cap and auto-scaling */
    .thermofly-logo {
        width: auto !important;
        height: auto !important;
        max-width: 75vw !important;
    }

    /* Reduce board density on small screens so cards remain tappable */
    .game-board.grid-4x4,
    .game-board.grid-3x4 {
        grid-template-columns: repeat(2, 1fr);
    }

    .game-board.grid-2x4 {
        grid-template-columns: repeat(2, 1fr);
    }

    .card {
        font-size: 1.6rem;
        border-radius: 10px;
    }

    .btn-primary,
    .btn-secondary {
        padding: 14px;
        font-size: 1rem;
    }

    /* Improve touch behaviour */
    button,
    .card {
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }
}

@media (max-width: 420px) {
    header h1 {
        font-size: 1.6rem;
    }
    .card {
        font-size: 1.4rem;
    }
    .setup-card {
        padding: 18px;
    }
}
