:root {
    --bg-color: #0f172a;
    --card-bg: #1e293b;
    --card-back: linear-gradient(135deg, #6366f1, #a855f7);
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --accent: #38bdf8;
    --danger: #ef4444;
    --success: #22c55e;
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background-image: url("imagem/back%20and.jpg");
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    background-repeat: no-repeat;
    width: 100%;
    overflow-x: hidden;
}

.container {
    width: 100%;
    max-width: 1100px;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

header {
    text-align: center;
}

.dandy-world-logo {
    font-family: 'Lilita One', cursive;
    font-size: 4rem;
    margin-bottom: 1.5rem;
    line-height: 1;
    text-shadow: 4px 4px 0 rgba(30, 41, 59, 1), 6px 6px 15px rgba(0,0,0,0.4);
    letter-spacing: 2px;
}

.dandy-world-logo span {
    display: inline-block;
    -webkit-text-stroke: 3px rgba(30, 41, 59, 1);
    animation: float-letter 3s ease-in-out infinite alternate;
}

.dandy-world-logo .l1 { color: #f76565; transform: rotate(-5deg); animation-delay: 0.1s;}
.dandy-world-logo .l2 { color: #facc15; transform: rotate(3deg); animation-delay: 0.2s;}
.dandy-world-logo .l3 { color: #4ade80; transform: rotate(-4deg); animation-delay: 0.3s;}
.dandy-world-logo .l4 { color: #60a5fa; transform: rotate(5deg); animation-delay: 0.4s;}
.dandy-world-logo .l5 { color: #c084fc; transform: rotate(-2deg); animation-delay: 0.5s;}
.dandy-world-logo .l6 { color: #facc15; transform: rotate(4deg); animation-delay: 0.6s;}
.dandy-world-logo .l7 { color: #f76565; transform: rotate(-3deg); animation-delay: 0.7s;}
.dandy-world-logo .l8 { color: #4ade80; transform: rotate(2deg); animation-delay: 0.8s;}
.dandy-world-logo .l9 { color: #60a5fa; transform: rotate(-5deg); animation-delay: 0.9s;}
.dandy-world-logo .l10 { color: #c084fc; transform: rotate(4deg); animation-delay: 1.0s;}
.dandy-world-logo .l11 { color: #facc15; transform: rotate(-2deg); animation-delay: 1.1s;}
.dandy-world-logo .l12 { color: #f76565; transform: rotate(5deg); animation-delay: 1.2s;}

@keyframes float-letter {
    0% { transform: translateY(0); }
    100% { transform: translateY(-5px); }
}

.dandy-world-logo .subtitle {
    font-family: 'Outfit', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 6px;
    margin-top: 10px;
    text-shadow: 2px 2px 0 rgba(30, 41, 59, 1);
    -webkit-text-stroke: 0px;
}

.music-btn {
    background: rgba(30, 41, 59, 0.5);
    color: var(--text-secondary);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.5rem 1.5rem;
    border-radius: 2rem;
    cursor: pointer;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 2rem;
    transition: all 0.3s ease;
}

.music-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    transform: scale(1.05);
}

.scoreboard {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(30, 41, 59, 0.5);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 1rem;
    padding: 1.5rem 2rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.player {
    text-align: center;
    padding: 1rem 2rem;
    border-radius: 0.75rem;
    transition: all 0.3s ease;
    opacity: 0.5;
    transform: scale(0.95);
}

.player h2 {
    font-size: 1.25rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.player .score {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.player.active {
    opacity: 1;
    transform: scale(1.05);
    background: rgba(255, 255, 255, 0.05);
    box-shadow: 0 0 20px rgba(56, 189, 248, 0.2);
    border: 1px solid rgba(56, 189, 248, 0.5);
}

#player1.active {
    box-shadow: 0 0 20px rgba(168, 85, 247, 0.3);
    border-color: rgba(168, 85, 247, 0.5);
}

#player2.active {
    box-shadow: 0 0 20px rgba(34, 197, 94, 0.3);
    border-color: rgba(34, 197, 94, 0.5);
}

.turn-indicator {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
    padding: 0.5rem 1.5rem;
    border-radius: 2rem;
    background: rgba(0, 0, 0, 0.2);
}

.game-board-container {
    width: 100%;
    flex: 1 1 auto;
    min-width: 200px;
    box-sizing: border-box;
}

.game-board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    perspective: 1000px;
    width: 100%;
}

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

.card {
    aspect-ratio: 3/4;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    cursor: pointer;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    border-radius: 0.75rem;
}

.card.flipped {
    transform: rotateY(180deg);
}

.card.matched {
    transform: rotateY(180deg) scale(0.95);
    pointer-events: none;
    box-shadow: 0 0 15px var(--success);
}

.card.matched .card-front .character-img {
    opacity: 0.5;
}

.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 0.75rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.card-back {
    background: var(--card-back);
    border: 2px solid rgba(255, 255, 255, 0.2);
    font-size: 2rem;
    color: white;
}

.card-back-flower {
    width: 60%;
    height: 60%;
    object-fit: contain;
    mix-blend-mode: multiply;
}

.card-front {
    background: #ffffff;
    transform: rotateY(180deg);
    border: 2px solid rgba(255, 255, 255, 0.1);
}

.card-front .character-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 0.75rem;
    padding: 5px;
}

.card-front .name {
    display: none;
}

/* Modal */
.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 100;
}

.modal.show {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: var(--card-bg);
    padding: 3rem;
    border-radius: 1.5rem;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

.modal.show .modal-content {
    transform: translateY(0);
}

.modal-content h2 {
    font-size: 2.5rem;
    margin-bottom: 2rem;
    color: var(--accent);
}

.final-scores {
    font-size: 1.5rem;
    margin-bottom: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

button {
    background: linear-gradient(135deg, #38bdf8, #818cf8);
    color: white;
    border: none;
    padding: 1rem 2.5rem;
    font-size: 1.25rem;
    font-weight: 700;
    border-radius: 0.75rem;
    cursor: pointer;
    font-family: 'Outfit', sans-serif;
    transition: all 0.3s ease;
    box-shadow: 0 10px 20px rgba(56, 189, 248, 0.3);
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 25px rgba(56, 189, 248, 0.4);
}

button:active {
    transform: translateY(1px);
}

.timer-container {
    font-size: 1.5rem;
    font-weight: 900;
    color: var(--text-primary);
    background: rgba(30, 41, 59, 0.8);
    border: 2px solid rgba(255, 68, 68, 0.5);
    padding: 0.5rem 1.5rem;
    border-radius: 1rem;
    display: inline-block;
    margin-bottom: 0.5rem;
}

.timer-warn {
    color: #ef4444;
    animation: flash 1s infinite;
}

@keyframes flash {
    0%, 100% { opacity: 1; text-shadow: 0 0 10px #ef4444; }
    50% { opacity: 0.5; }
}

.dandy-alert {
    position: fixed;
    bottom: -400px;
    right: 5%;
    width: 300px;
    height: auto;
    border-radius: 1rem;
    z-index: 1000;
    box-shadow: 0 0 50px rgba(239, 68, 68, 0.8);
    transition: bottom 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: none;
    border: 5px solid #ef4444;
}

.dandy-alert.show {
    bottom: 20px;
    animation: spin 3s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsividade para Celulares */
@media (max-width: 767px) {
    .container {
        padding: 1rem;
        gap: 1rem;
    }
    
    .dandy-world-logo {
        font-size: 2.2rem;
        margin-bottom: 0.25rem;
        letter-spacing: 1px;
    }
    
    .dandy-world-logo .subtitle {
        font-size: 1rem;
        letter-spacing: 3px;
        margin-top: 5px;
    }
    
    .scoreboard {
        flex-direction: row;
        padding: 0.5rem;
        gap: 0.5rem;
        justify-content: space-between;
        margin-bottom: 0.5rem;
    }
    
    .player {
        padding: 0.25rem 0.5rem;
        font-size: 0.9rem;
    }
    
    .player .score {
        font-size: 1.5rem;
    }
    
    .turn-indicator {
        font-size: 1rem;
        padding: 0.25rem 0.5rem;
        order: -1;
        margin-bottom: 0.5rem;
    }
    
    .game-board {
        grid-template-columns: repeat(6, 1fr); /* 6 colunas x 4 linhas para não dar scroll */
        gap: 0.3rem; /* Espaçamento menor ainda para caber melhor */
    }
    
    .timer-container {
        font-size: 1.1rem;
        padding: 0.4rem 1rem;
        margin-bottom: 0.25rem;
    }
    
    .music-btn {
        font-size: 0.9rem;
        padding: 0.4rem 1rem;
        margin-bottom: 0.5rem;
    }
    
    .modal-content {
        padding: 2rem 1rem;
        width: 90%;
    }
    
    .modal-content h2 {
        font-size: 1.8rem;
    }
    
    .dandy-alert {
        width: 180px;
        right: 2%;
    }
    
    .start-screen {
        min-height: 50vh;
    }
    
    .instructions-box {
        padding: 1rem;
        margin-bottom: 2rem;
    }
    
    .start-btn {
        font-size: 1.2rem;
        padding: 1rem 2rem;
    }
    
    .dandy-world-logo.small-logo {
        font-size: 2rem;
        margin-bottom: 0.5rem;
    }
}

/* Telas Nova Tela Inicial e Jogo */
.start-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 70vh;
    animation: fadeIn 1s ease-in-out;
}

.instructions-box {
    background: rgba(30, 41, 59, 0.7);
    border: 2px solid rgba(168, 85, 247, 0.5);
    border-radius: 1rem;
    padding: 1.5rem 2rem;
    margin-bottom: 2.5rem;
    text-align: center;
    backdrop-filter: blur(10px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.instructions-box p {
    font-size: 1.25rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.instructions-box p:first-child {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.start-btn {
    font-size: 1.5rem;
    padding: 1.25rem 3rem;
    border-radius: 3rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    background: linear-gradient(135deg, #a855f7, #38bdf8);
    box-shadow: 0 10px 25px rgba(168, 85, 247, 0.4);
    animation: pulse 2s infinite;
    color: white;
    font-family: 'Outfit', sans-serif;
    font-weight: 900;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
}

.start-btn:hover {
    transform: scale(1.05) translateY(-2px);
    box-shadow: 0 15px 35px rgba(168, 85, 247, 0.6);
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(168, 85, 247, 0.4); }
    70% { box-shadow: 0 0 0 15px rgba(168, 85, 247, 0); }
    100% { box-shadow: 0 0 0 0 rgba(168, 85, 247, 0); }
}

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

.dandy-world-logo.small-logo {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.dandy-world-logo.small-logo .subtitle {
    display: none;
}


/* Telas do Lobby (Online) */
.main-menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
    max-width: 300px;
}

.online-btn {
    background: linear-gradient(135deg, #22c55e, #10b981);
    box-shadow: 0 10px 25px rgba(34, 197, 94, 0.4);
    animation: none;
}

.online-btn:hover {
    box-shadow: 0 15px 35px rgba(34, 197, 94, 0.6);
}

.lobby-panels {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    align-items: center;
    width: 100%;
    max-width: 600px;
    animation: fadeIn 1s ease-in-out;
}

@media (min-width: 768px) {
    .lobby-panels {
        flex-direction: row;
        align-items: stretch;
    }
}

.host-panel, .join-panel {
    background: rgba(30, 41, 59, 0.8);
    border: 2px solid rgba(255, 255, 255, 0.1);
    padding: 2rem;
    border-radius: 1rem;
    flex: 1;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.host-panel h3, .join-panel h3 {
    margin-bottom: 1rem;
    color: var(--accent);
}

.lobby-panels p {
    margin-bottom: 1.5rem;
    color: var(--text-secondary);
}

.lobby-panels button {
    font-size: 1.2rem;
    padding: 0.8rem 1.5rem;
    border-radius: 2rem;
    background: linear-gradient(135deg, #a855f7, #38bdf8);
    color: white;
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
}

.lobby-panels button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(168, 85, 247, 0.4);
}

.divisor {
    display: flex;
    align-items: center;
    font-weight: 900;
    color: var(--text-secondary);
    font-size: 1.5rem;
}

#join-code-input {
    width: 100%;
    padding: 1rem;
    font-size: 1.5rem;
    text-align: center;
    text-transform: uppercase;
    border-radius: 0.5rem;
    border: 2px solid var(--accent);
    background: rgba(0,0,0,0.5);
    color: var(--text-primary);
    margin-bottom: 1rem;
    font-family: 'Outfit';
    outline: none;
}

#join-code-input:focus {
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.5);
}

.blink {
    animation: blinker 1.5s linear infinite;
    color: var(--text-secondary);
}

@keyframes blinker {
    50% { opacity: 0; }
}

/* Chat & Controls Styles */
.controls-container {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.controls-container .music-btn {
    margin-bottom: 0;
}

#host-name-input, #join-name-input {
    width: 100%;
    padding: 0.8rem;
    font-size: 1.2rem;
    text-align: center;
    border-radius: 0.5rem;
    border: 2px solid var(--accent);
    background: rgba(0,0,0,0.5);
    color: var(--text-primary);
    font-family: 'Outfit';
    outline: none;
}

.game-main-layout {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
    justify-content: center;
    width: 100%;
    box-sizing: border-box;
}

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

.chat-sidebar {
    width: 300px;
    height: 500px;
    background: rgba(30, 41, 59, 0.7);
    border: 2px solid rgba(168, 85, 247, 0.5);
    border-radius: 1rem;
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.chat-header {
    background: rgba(168, 85, 247, 0.3);
    padding: 1rem;
    text-align: center;
    font-weight: 900;
    font-size: 1.2rem;
    border-bottom: 1px solid rgba(168, 85, 247, 0.5);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.chat-messages li {
    background: rgba(0, 0, 0, 0.4);
    padding: 0.8rem;
    border-radius: 0.5rem;
    font-size: 0.95rem;
    word-break: break-word;
}

.chat-messages li.self {
    background: rgba(56, 189, 248, 0.2);
    border-left: 4px solid var(--accent);
    align-self: flex-end;
    width: 90%;
}

.chat-messages li.other {
    background: rgba(34, 197, 94, 0.2);
    border-left: 4px solid var(--success);
    align-self: flex-start;
    width: 90%;
}

.chat-messages strong {
    color: var(--accent);
    display: block;
    font-size: 0.85rem;
    margin-bottom: 0.2rem;
}

.chat-messages li.other strong {
    color: var(--success);
}

.chat-input-area {
    display: flex;
    padding: 0.5rem;
    background: rgba(0, 0, 0, 0.3);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-input-area input {
    flex: 1;
    padding: 0.8rem;
    border: none;
    border-radius: 0.5rem;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    font-family: inherit;
    outline: none;
}

.chat-input-area button {
    background: var(--accent);
    padding: 0 1rem;
    margin-left: 0.5rem;
    border-radius: 0.5rem;
    font-size: 1rem;
    box-shadow: none;
}

@media (max-width: 900px) {
    .game-main-layout {
        flex-direction: column;
        align-items: center;
    }
    .chat-sidebar {
        width: 100%;
        max-width: 400px;
        height: 300px;
    }
}

