/* ======================================================
   MEMÓRIA DAS CONSOANTES V2 - game.css
   Estilo baseado em memoria-vogais-v2
   ====================================================== */

:root {
    --game-primary:   #7B1FA2;
    --game-secondary: #E91E63;
    --game-accent:    #FFE66D;

    --shadow-sm:   0 2px 8px rgba(0,0,0,.10);
    --shadow-md:   0 4px 12px rgba(0,0,0,.15);
    --shadow-lg:   0 8px 24px rgba(0,0,0,.20);
    --shadow-card: 0 10px 30px rgba(0,0,0,.25);
}

/* ======================================================
   GAME CONTAINER
   ====================================================== */

.game-container {
    position: relative;
    background: linear-gradient(135deg, #7B1FA2 0%, #E91E63 100%);
    border-radius: 20px;
    padding: 30px;
    margin: 30px 0;
    box-shadow: var(--shadow-lg);
    min-height: 500px;
    overflow: hidden;
}

.fullscreen-btn {
    position: absolute;
    top: 20px; right: 20px;
    background: rgba(255,255,255,.95);
    border: none; border-radius: 50%;
    width: 50px; height: 50px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: all .3s ease;
    z-index: 1000;
}
.fullscreen-btn:hover { background: white; transform: scale(1.1); box-shadow: var(--shadow-lg); }
.fullscreen-btn svg   { color: #7B1FA2; transition: transform .3s ease; }
.fullscreen-btn:hover svg { transform: rotate(90deg); }

.game-container:fullscreen,
.game-container:-webkit-full-screen,
.game-container:-moz-full-screen,
.game-container:-ms-fullscreen {
    border-radius: 0;
    display: flex; flex-direction: column;
    align-items: center; justify-content: flex-start;
    padding: 20px; box-sizing: border-box; overflow-y: auto;
}

/* ======================================================
   LEVEL SELECTION
   ====================================================== */

.level-selection { text-align: center; padding: 20px; animation: fadeIn .5s ease; }

.level-title {
    font-family: var(--font-primary);
    font-size: 36px; font-weight: 800;
    color: white; margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,.2);
}
.level-subtitle {
    font-family: var(--font-secondary);
    font-size: 18px; color: rgba(255,255,255,.9); margin-bottom: 40px;
}

.level-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 25px; margin-top: 30px;
}

.level-card {
    background: white; border-radius: 20px;
    padding: 30px 20px; cursor: pointer;
    transition: all .3s cubic-bezier(.4,0,.2,1);
    box-shadow: var(--shadow-md);
    position: relative; overflow: hidden;
}
.level-card::before {
    content: '';
    position: absolute; top: 0; left: 0; right: 0; height: 5px;
    background: linear-gradient(90deg, var(--game-primary), var(--game-secondary));
    transform: scaleX(0); transition: transform .3s ease;
}
.level-card:hover { transform: translateY(-10px); box-shadow: 0 15px 35px rgba(0,0,0,.2); }
.level-card:hover::before { transform: scaleX(1); }

.level-icon {
    font-size: 60px; margin-bottom: 15px;
    animation: bounce 1s ease-in-out infinite;
}
.level-card:nth-child(2) .level-icon { animation-delay: .2s; }
.level-card:nth-child(3) .level-icon { animation-delay: .4s; }

.level-name  { font-family: var(--font-primary); font-size: 24px; font-weight: 700; color: #333; margin: 15px 0 10px; }
.level-description { font-family: var(--font-secondary); font-size: 16px; color: #666; margin-bottom: 10px; }
.level-age   { font-size: 20px; margin: 10px 0; }
.level-info  { font-family: var(--font-secondary); font-size: 14px; color: #999; font-style: italic; }

/* ======================================================
   GAME PLAY
   ====================================================== */

.game-play { position: relative; animation: fadeIn .5s ease; }

.game-header {
    background: rgba(255,255,255,.95);
    border-radius: 15px; padding: 20px; margin-bottom: 20px;
    box-shadow: var(--shadow-md);
}
.game-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
    gap: 15px; text-align: center;
}
.stat-item  { display: flex; flex-direction: column; gap: 5px; }
.stat-label {
    font-family: var(--font-secondary);
    font-size: 14px; color: #666; font-weight: 600;
    text-transform: uppercase; letter-spacing: .5px;
}
.stat-value {
    font-family: var(--font-primary);
    font-size: 32px; font-weight: 800; color: #7B1FA2; line-height: 1;
}

.action-buttons { display: flex; gap: 15px; justify-content: center; flex-wrap: wrap; margin-top: 25px; }
.btn-action {
    font-family: var(--font-primary); font-size: 16px; font-weight: 700;
    padding: 12px 30px; border: none; border-radius: 50px;
    cursor: pointer; transition: all .3s ease;
    box-shadow: var(--shadow-sm); display: flex; align-items: center; gap: 8px;
}
.btn-restart { background: linear-gradient(135deg,#4ECDC4,#44A08D); color: white; }
.btn-restart:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.btn-quit    { background: #FF6B6B; color: white; }
.btn-quit:hover { background: #FF5252; transform: translateY(-2px); box-shadow: var(--shadow-md); }

/* ======================================================
   MEMORY GRID
   ====================================================== */

.memory-grid {
    display: grid; gap: 12px;
    margin: 25px auto; justify-content: center;
    perspective: 1000px;
}
.memory-grid.level-easy   { grid-template-columns: repeat(4, 90px); }
.memory-grid.level-medium { grid-template-columns: repeat(4, 90px); }
.memory-grid.level-hard   { grid-template-columns: repeat(6, 80px); }

/* ======================================================
   CARTAS
   ====================================================== */

.memory-card {
    width: 100%; height: 110px;
    cursor: pointer;
    transform-style: preserve-3d;
    transition: transform .55s cubic-bezier(.4,0,.2,1);
    position: relative;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}
.memory-card.flipped  { transform: rotateY(180deg); }
.memory-card.matched  { transform: rotateY(180deg) !important; pointer-events: none; animation: matchedPulse .6s ease forwards; }
.memory-card.disabled { pointer-events: none; }

.card-face {
    position: absolute; inset: 0;
    backface-visibility: hidden; -webkit-backface-visibility: hidden;
    border-radius: 15px;
    display: flex; align-items: center; justify-content: center;
    box-shadow: var(--shadow-card); overflow: hidden;
}

/* Verso */
.card-back { background: linear-gradient(135deg,#667eea 0%,#764ba2 100%); }
.card-back::before {
    content: '?';
    font-family: var(--font-primary);
    font-size: 50px; font-weight: 800;
    color: white; text-shadow: 2px 2px 4px rgba(0,0,0,.3);
}
.card-back::after {
    content: '';
    position: absolute;
    top: 10px; left: 10px; right: 10px; bottom: 10px;
    border: 3px dashed rgba(255,255,255,.35);
    border-radius: 10px;
}

/* Frente */
.card-front { background: white; transform: rotateY(180deg); border: 4px solid #7B1FA2; }
.card-front.type-letter {
    background: linear-gradient(160deg,#E1BEE7 0%,#CE93D8 100%);
    border-color: #7B1FA2;
}
.card-front.type-image {
    background: linear-gradient(160deg,#BBDEFB 0%,#90CAF9 100%);
    border-color: #1E88E5;
}

.card-content {
    text-align: center; font-family: var(--font-primary);
    display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.card-content.letter {
    font-size: 58px; font-weight: 900;
    color: #4A148C; text-shadow: 1px 2px 4px rgba(0,0,0,.12);
}
.card-content.image  { font-size: 56px; }
.card-content.image .card-word {
    font-size: 12px; color: #1565C0;
    font-weight: 700; text-transform: capitalize; letter-spacing: .3px;
}

/* Par encontrado */
.memory-card.matched .card-front {
    background: var(--pair-bg,  #E8F5E9) !important;
    border-color: var(--pair-bd, #66BB6A) !important;
}

.memory-card.mismatch { animation: shake .5s ease; }
.memory-card.flipped.mismatch { transform: rotateY(180deg); }

/* ======================================================
   TELA DE RESULTADO
   ====================================================== */

.result-screen { text-align: center; padding: 40px 20px; animation: zoomIn .5s cubic-bezier(.175,.885,.32,1.275); }
.result-icon   { font-size: 100px; margin-bottom: 20px; animation: bounce 1s ease-in-out infinite; }
.result-title  { font-family: var(--font-primary); font-size: 42px; font-weight: 800; color: white; margin-bottom: 15px; text-shadow: 2px 2px 4px rgba(0,0,0,.2); }
.result-message { font-family: var(--font-secondary); font-size: 20px; color: rgba(255,255,255,.95); margin-bottom: 30px; line-height: 1.6; }

.result-stars {
    font-size: 56px; letter-spacing: 8px; display: block; margin: 10px 0 30px;
    animation: starsIn .5s .2s cubic-bezier(.34,1.56,.64,1) both;
}
@keyframes starsIn { from { transform: scale(0); opacity:0; } to { transform: scale(1); opacity:1; } }

.result-stats { display: grid; grid-template-columns: repeat(auto-fit,minmax(120px,1fr)); gap: 20px; margin: 30px 0; }
.result-stat  { background: white; border-radius: 15px; padding: 25px 15px; box-shadow: var(--shadow-md); transition: transform .3s ease; }
.result-stat:hover { transform: translateY(-5px); }
.result-stat-label { font-family: var(--font-secondary); font-size: 14px; color: #666; font-weight: 600; text-transform: uppercase; margin-bottom: 10px; }
.result-stat-value { font-family: var(--font-primary); font-size: 36px; font-weight: 800; color: #7B1FA2; line-height: 1; }

.result-buttons { display: flex; flex-wrap: wrap; gap: 15px; justify-content: center; margin-top: 30px; }

/* Confete */
#confettiContainer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; border-radius: inherit; z-index: 0; }
.confetti-piece    { position: absolute; opacity: 0; animation: confettiFall 1.1s ease-out forwards; }
@keyframes confettiFall {
    0%  { opacity:1; transform: translateY(0) rotate(0deg) scale(1); }
    80% { opacity:1; }
    100%{ opacity:0; transform: translateY(260px) rotate(720deg) scale(.4); }
}

/* ======================================================
   PARTÍCULAS
   ====================================================== */

.particle {
    position: absolute; pointer-events: none; z-index: 9999;
    font-size: 24px; animation: particleFloat 1s ease-out forwards;
}
@keyframes particleFloat {
    0%   { transform: translate(0,0) scale(1); opacity:1; }
    100% { transform: translate(var(--tx),var(--ty)) scale(0); opacity:0; }
}

/* ======================================================
   ANIMAÇÕES
   ====================================================== */

@keyframes fadeIn       { from { opacity:0; } to { opacity:1; } }
@keyframes bounce       { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
@keyframes zoomIn       { from { opacity:0; transform:scale(.5); } to { opacity:1; transform:scale(1); } }
@keyframes matchedPulse { 0% { transform:scale(1) rotateY(180deg); } 50% { transform:scale(1.15) rotateY(180deg); } 100% { transform:scale(1) rotateY(180deg); } }
@keyframes shake        { 0%,100% { transform:translateX(0) rotateY(180deg); } 25% { transform:translateX(-10px) rotateY(180deg); } 75% { transform:translateX(10px) rotateY(180deg); } }

/* ======================================================
   RESPONSIVO
   ====================================================== */

@media (max-width: 768px) {
    .game-container { padding: 20px; min-height: 400px; }
    .level-title    { font-size: 26px; }
    .level-subtitle { font-size: 15px; }
    .level-cards    { grid-template-columns: 1fr; gap: 15px; }
    .level-icon     { font-size: 48px; }
    .stat-value     { font-size: 24px; }
    .memory-grid.level-easy   { grid-template-columns: repeat(4, 78px); gap: 10px; }
    .memory-grid.level-medium { grid-template-columns: repeat(4, 72px); gap:  9px; }
    .memory-grid.level-hard   { grid-template-columns: repeat(5, 66px); gap:  8px; }
    .memory-card    { height: 95px; }
    .card-back::before { font-size: 40px; }
    .card-content.letter { font-size: 44px; }
    .card-content.image  { font-size: 44px; }
    .result-title   { font-size: 30px; }
    .result-message { font-size: 16px; }
    .result-stats   { grid-template-columns: repeat(2,1fr); }
}

@media (max-width: 480px) {
    .game-container  { padding: 15px; border-radius: 15px; }
    .level-title     { font-size: 20px; margin-bottom: 6px; }
    .level-subtitle  { font-size: 13px; margin-bottom: 16px; }
    .level-card      { padding: 18px 12px; }
    .level-icon      { font-size: 36px; margin-bottom: 8px; }
    .level-name      { font-size: 18px; }
    .level-description { font-size: 14px; }
    .level-info      { font-size: 12px; }
    .stat-label      { font-size: 11px; }
    .stat-value      { font-size: 20px; }
    .memory-grid.level-easy   { grid-template-columns: repeat(4, 68px); gap: 8px; }
    .memory-grid.level-medium { grid-template-columns: repeat(4, 62px); gap: 7px; }
    .memory-grid.level-hard   { grid-template-columns: repeat(5, 56px); gap: 6px; }
    .memory-card     { height: 84px; }
    .card-back::before { font-size: 32px; }
    .card-content.letter { font-size: 36px; }
    .card-content.image  { font-size: 36px; }
    .card-content.image .card-word { font-size: 10px; }
    .result-screen   { padding: 20px 12px; }
    .result-icon     { font-size: 60px; margin-bottom: 10px; }
    .result-title    { font-size: 24px; }
    .result-message  { font-size: 14px; margin-bottom: 20px; }
    .result-stars    { font-size: 44px; }
    .result-stats    { grid-template-columns: 1fr; gap: 10px; margin: 20px 0; }
    .result-stat     { padding: 15px 10px; }
    .result-stat-value { font-size: 26px; }
    .result-buttons  { flex-direction: column; gap: 10px; margin-top: 20px; }
    .result-buttons .btn-action { width: 100%; justify-content: center; font-size: 14px; }
    .fullscreen-btn  { width: 42px; height: 42px; top: 14px; right: 14px; }
}

.memory-card:focus { outline: 3px solid white; outline-offset: 3px; }
.btn-action:focus  { outline: 3px solid white; outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) {
    * { animation-duration: .01s !important; animation-iteration-count: 1 !important; transition-duration: .01s !important; }
    .memory-card { transition: none; }
}
