@import url('https://fonts.googleapis.com/css2?family=Joti+One:wght@400&display=swap');

:root {
    --primary-gradient: linear-gradient(135deg, #0a0a0a 0%, #1a1a2e 50%, #16213e 100%);
    --card-gradient: linear-gradient(145deg, rgba(0, 0, 0, 0.4), rgba(20, 20, 40, 0.3));
    --border-color: rgba(255, 255, 255, 0.1);
    --text-shadow: 0 0 15px rgba(255, 255, 255, 0.4);
    --box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    --transition: all 0.3s ease;
    --color-success: #00b894;
    --color-danger: #e74c3c;
    --color-info: #3498db;
    --color-gold: #ffd700;
}

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

body {
    font-family: "Joti One", serif;
    background: var(--primary-gradient);
    color: #ffffff;
    min-height: 100vh;
    overflow-x: hidden;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: clamp(8px, 2vw, 15px);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* BUTTONS */
.btn {
    font-family: "Joti One", serif;
    background: linear-gradient(45deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    border-radius: 25px;
    cursor: pointer;
    transition: var(--transition);
    text-transform: uppercase;
    font-weight: bold;
    backdrop-filter: blur(10px);
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: clamp(8px, 2vw, 12px) clamp(16px, 4vw, 25px);
    font-size: clamp(0.8rem, 2vw, 1rem);
}

.btn:hover {
    background: linear-gradient(45deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.1));
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(255, 255, 255, 0.2);
}

.btn--large {
    padding: clamp(15px, 3vw, 18px) clamp(25px, 5vw, 30px);
    font-size: clamp(1.2rem, 3vw, 1.4rem);
}

.btn--square {
    border-radius: 8px;
    min-width: clamp(40px, 8vw, 50px);
    min-height: clamp(40px, 8vw, 50px);
    padding: clamp(8px, 2vw, 10px);
}

.btn--success.active {
    border-color: var(--color-success);
    box-shadow: 0 0 20px rgba(0, 184, 148, 0.5);
}

.btn--danger.active {
    border-color: var(--color-danger);
    box-shadow: 0 0 20px rgba(231, 76, 60, 0.5);
}

/* CARDS */
.card-container {
    background: var(--card-gradient);
    border-radius: 15px;
    border: 2px solid var(--border-color);
    padding: clamp(15px, 3vw, 20px);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(15px);
}

.card-container--large {
    padding: clamp(20px, 4vw, 30px);
    border-radius: 20px;
    box-shadow: var(--box-shadow);
}

/* TEXT */
.text-title {
    font-size: clamp(2rem, 5vw, 2.8rem);
    color: #ffffff;
    text-shadow: var(--text-shadow);
    letter-spacing: 2px;
    line-height: 1;
}

.text-subtitle {
    font-size: clamp(1.2rem, 3vw, 1.6rem);
    color: #ffffff;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
    line-height: 1.2;
}

.text-label {
    font-size: clamp(1.1rem, 2.5vw, 1.4rem);
    margin-bottom: clamp(15px, 3vw, 20px);
    color: #ffffff;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

.text-small {
    font-size: clamp(0.7rem, 1.5vw, 0.8rem);
    opacity: 0.9;
}

/* LAYOUT HELPERS */
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-column { display: flex; flex-direction: column; }
.gap-small { gap: clamp(8px, 2vw, 10px); }
.gap-medium { gap: clamp(12px, 3vw, 15px); }
.gap-large { gap: clamp(16px, 4vw, 20px); }
.hidden { display: none !important; }

/* MENU */
.memory-logo { display: none !important; }
.menu { flex: 1; animation: fadeIn 1s ease-out; }
.menu-header { margin-bottom: 30px; animation: fadeInDown 0.8s ease-out; }
.menu-section {
    text-align: center;
    width: min(90vw, 600px);
    margin: 0 auto;
}
.menu-section > * { margin: clamp(20px, 4vw, 30px) 0; }

/* GAME CONTAINER - POPRAWIONY LAYOUT */
.game-container {
    animation: fadeIn 0.8s ease-out;
    flex: 1;
    display: flex;
    min-height: 0;
    overflow: hidden;
    gap: clamp(8px, 2vw, 16px);
}

/* DEFAULT - PORTRAIT LAYOUT */
.game-container {
    flex-direction: column;
    height: calc(100vh - clamp(16px, 4vw, 30px)); /* Minus container padding */
}

.game-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.game-header {
    flex-shrink: 0;
    margin-bottom: clamp(8px, 2vw, 10px);
}

.game-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    min-height: 0;
    overflow: hidden;
}

.game-sidebar {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}

.stats-container {
    margin: 0;
}

.game-logo {
    width: clamp(30px, 6vw, 40px);
    height: clamp(30px, 6vw, 40px);
}

/* LANDSCAPE LAYOUT - POPRAWIONY */
@media (orientation: landscape) {
    .game-container {
        flex-direction: row;
        height: 100vh;
    }

    .game-main {
        flex: 1;
        min-width: 0;
    }

    .game-header {
        margin-bottom: 0;
    }

    .game-sidebar {
        flex: 0 0 clamp(300px, 28vw, 420px); /* Większy sidebar */
        justify-content: flex-start;
        gap: clamp(8px, 2vw, 16px);
    }
}

/* DESKTOP FIXES - większy ekran */
@media (min-width: 1024px) {
    .game-container {
        height: calc(100vh - 30px);
    }

    .game-sidebar {
        flex: 0 0 350px; /* Stała szerokość na desktop */
    }

    .game-logo {
        width: 40px;
        height: 40px;
    }
}

.game-board {
    display: grid;
    gap: clamp(2px, 0.5vw, 4px);
    justify-content: center;
    align-content: center;
    margin: auto;
    width: 100%;
    height: 100%;
}

/* GAME CARDS */
.game-card {
    background: rgba(40, 40, 60, 0.8);
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.game-card:hover:not(.matched):not(.flipped) {
    transform: scale(1.05);
    border-color: rgba(255, 255, 255, 0.4);
}

.game-card.flipped .card-front {
    transform: rotateY(180deg);
    opacity: 0;
}

.game-card.flipped .card-back {
    transform: rotateY(0deg);
    opacity: 1;
}

.game-card.matched {
    background: rgba(0, 255, 127, 0.2);
    border-color: rgba(0, 255, 127, 0.5);
    animation: matchPulse 0.6s ease-in-out;
}

.game-card.disabled, .game-card.paused {
    pointer-events: none;
}

.game-card.paused {
    filter: brightness(0.3);
}

.game-card.paused .card-back {
    transform: rotateY(180deg);
    opacity: 0;
}

.game-card.paused .card-front {
    transform: rotateY(0deg);
    opacity: 1;
}

.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 7px;
    transition: all 0.4s ease;
    backface-visibility: hidden;
}

.card-front {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.6);
    font-size: clamp(16px, 3vw, 20px);
    transform: rotateY(0deg);
}

.card-back {
    transform: rotateY(180deg);
    opacity: 0;
}

.card-image {
    width: 80%;
    height: 80%;
    object-fit: contain;
}

.card-counter {
    position: absolute;
    top: 2px;
    right: 2px;
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    font-size: clamp(8px, 1.5vw, 10px);
    padding: 2px 4px;
    border-radius: 3px;
    font-weight: bold;
}

/* STATS */
.stats-container {
    transition: var(--transition);
}

.stats-container.red-active {
    background: linear-gradient(145deg, rgba(231, 76, 60, 0.2), rgba(192, 57, 43, 0.1));
    border-color: rgba(231, 76, 60, 0.3);
}

.stats-container.blue-active {
    background: linear-gradient(145deg, rgba(52, 152, 219, 0.2), rgba(41, 128, 185, 0.1));
    border-color: rgba(52, 152, 219, 0.3);
}

.stats-row {
    display: flex;
    gap: clamp(15px, 3vw, 20px);
}

.stat-item {
    text-align: center;
    flex: 1;
    padding: clamp(8px, 2vw, 10px) 0;
}

.stat-label {
    display: block;
    font-size: clamp(0.8rem, 1.8vw, 0.9rem);
    opacity: 0.7;
    margin-bottom: 5px;
}

.stat-value {
    display: block;
    font-size: clamp(1.2rem, 2.5vw, 1.4rem);
    font-weight: bold;
    color: #ffffff;
}

/* TWO PLAYER STATS */
.players-row {
    display: flex;
    gap: clamp(8px, 2vw, 15px);
    width: 100%;
}

.player-stats {
    text-align: center;
    padding: clamp(10px, 2vw, 15px);
    border-radius: 10px;
    border: 3px solid transparent;
    transition: var(--transition);
    flex: 1;
}

.player-stats--red {
    border-color: var(--color-danger);
    background: linear-gradient(145deg, rgba(231, 76, 60, 0.1), rgba(192, 57, 43, 0.05));
}

.player-stats--blue {
    border-color: var(--color-info);
    background: linear-gradient(145deg, rgba(52, 152, 219, 0.1), rgba(41, 128, 185, 0.05));
}

.player-stats.active {
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
    transform: scale(1.02);
}

.player-stats--red.active {
    box-shadow: 0 0 20px rgba(231, 76, 60, 0.5);
}

.player-stats--blue.active {
    box-shadow: 0 0 20px rgba(52, 152, 219, 0.5);
}

.player-label {
    font-size: clamp(0.9rem, 2vw, 1.1rem);
    font-weight: bold;
    margin-bottom: clamp(4px, 1vw, 8px);
}

.player-info {
    display: flex;
    flex-direction: column;
    gap: clamp(2px, 0.5vw, 3px);
}

/* PORTRAIT STATS - HORIZONTAL */
@media (orientation: portrait) {
    .stats-row {
        flex-direction: row;
        justify-content: center;
        flex-wrap: wrap;
    }

    .stat-item {
        min-width: clamp(70px, 15vw, 80px);
        border-bottom: none;
    }

    .players-row {
        flex-direction: row;
        justify-content: space-between;
    }

    .player-stats {
        max-width: 48%;
        min-width: 45%;
        padding: clamp(6px, 1.5vw, 8px);
    }

    .player-label {
        font-size: clamp(0.8rem, 1.8vw, 0.9rem);
        margin-bottom: clamp(2px, 0.5vw, 4px);
    }

    .text-small {
        font-size: clamp(0.65rem, 1.3vw, 0.7rem);
    }
}

/* LANDSCAPE STATS - VERTICAL IN SIDEBAR */
@media (orientation: landscape) {
    .stats-row {
        flex-direction: column;
    }

    .stat-item {
        text-align: left;
        padding: clamp(8px, 2vw, 10px) 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    .stat-item:last-child {
        border-bottom: none;
    }

    .players-row {
        flex-direction: column;
    }

    .player-stats {
        max-width: none;
        min-width: auto;
    }
}

/* SOUND ICON */
.sound-icon {
    font-size: clamp(16px, 3vw, 20px);
    filter: grayscale(0);
    transition: var(--transition);
}

.sound-icon.muted {
    filter: grayscale(1);
    opacity: 0.5;
}

/* SLIDER */
.slider {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    outline: none;
    cursor: pointer;
    appearance: none;
    transition: var(--transition);
}

.slider::-webkit-slider-thumb {
    appearance: none;
    width: clamp(20px, 4vw, 24px);
    height: clamp(20px, 4vw, 24px);
    border-radius: 50%;
    background: linear-gradient(45deg, #fff, #f0f0f0);
    cursor: pointer;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.6);
    transition: var(--transition);
    border: 2px solid #667eea;
}

.slider::-webkit-slider-thumb:hover {
    transform: scale(1.3);
    box-shadow: 0 0 25px rgba(255, 255, 255, 0.8);
}

.slider--speed {
    background: linear-gradient(90deg, #ff9a9e 0%, #fad0c4 50%, #a8edea 100%);
}

/* MODAL */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.modal.hidden {
    display: none !important;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.modal-content {
    background: linear-gradient(145deg, rgba(20, 20, 40, 0.95), rgba(40, 40, 60, 0.9));
    padding: clamp(25px, 5vw, 30px);
    border-radius: 20px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    text-align: center;
    width: min(90vw, 400px);
    backdrop-filter: blur(15px);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    animation: modalSlideIn 0.3s ease-out;
    position: relative;
    z-index: 2;
}

.modal-title {
    font-size: clamp(1.3rem, 3vw, 1.5rem);
    margin-bottom: clamp(20px, 4vw, 25px);
    color: #ffffff;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

.modal-buttons {
    display: flex;
    flex-direction: column;
    gap: clamp(10px, 2vw, 12px);
    margin-top: clamp(15px, 3vw, 20px);
}

/* SPECIAL ELEMENTS */
.pause-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.pause-text {
    font-size: clamp(3rem, 8vw, 4rem);
    color: #ffffff;
    text-shadow: 0 0 30px rgba(255, 255, 255, 0.8);
    font-weight: bold;
    animation: pausePulse 2s ease-in-out infinite;
}

.victory {
    text-align: center;
    margin: clamp(10px, 3vw, 15px) 0;
    animation: bounceIn 1s ease-out;
    padding: clamp(15px, 3vw, 20px);
    background: linear-gradient(145deg, rgba(0, 255, 127, 0.1), rgba(0, 200, 100, 0.05));
    border-radius: 15px;
    border: 2px solid rgba(0, 255, 127, 0.3);
}

.victory-text {
    font-size: clamp(1.4rem, 3.5vw, 1.8rem);
    color: #00ff7f;
    margin-bottom: clamp(8px, 2vw, 10px);
    text-shadow: 0 0 15px rgba(0, 255, 127, 0.5);
}

.special-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: clamp(2rem, 6vw, 3.5rem);
    font-weight: 900;
    color: var(--color-gold);
    text-shadow: 0 0 30px rgba(255, 215, 0, 0.9);
    z-index: 1000;
    pointer-events: none;
    animation: specialPulse 2s ease-out;
    opacity: 0;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.menu-icon {
    display: flex;
    flex-direction: column;
    gap: 3px;
    width: clamp(16px, 3vw, 20px);
}

.menu-icon span {
    height: 3px;
    background: white;
    border-radius: 2px;
    transition: var(--transition);
}

/* ANIMATIONS */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

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

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

@keyframes bounceIn {
    0% { opacity: 0; transform: scale(0.3); }
    50% { opacity: 1; transform: scale(1.1); }
    100% { opacity: 1; transform: scale(1); }
}

@keyframes specialPulse {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
    15% { opacity: 1; transform: translate(-50%, -50%) scale(1.2); }
    85% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
}

@keyframes pausePulse {
    0%, 100% { opacity: 0.8; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.05); }
}

@keyframes modalSlideIn {
    from { opacity: 0; transform: scale(0.8) translateY(-20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}