:root {
    --main-bg: linear-gradient(135deg, #232526 0%, #414345 100%);
    --hud-bg: rgba(30, 34, 40, 0.95);
    --hud-border: #00e676;
    --hud-text: #fff;
    --tabuleiro-borda: #d32f2f;
    --tabuleiro-sombra: 0 8px 32px 0 rgba(0,0,0,0.45);
    --peca-bg: #fff;
    --peca-correta: #00e676;
    --peca-text: #232526;
    --peca-sombra: 0 2px 12px 0 rgba(0,0,0,0.18);
    --peca-hover: #f5f5f5;
    --peca-active: #e0e0e0;
    --btn-bg: linear-gradient(90deg, #1976d2 0%, #00e676 100%);
    --btn-text: #fff;
    --btn-hover: #00e676;
    --btn-active: #1976d2;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    width: 100vw;
    height: 100vh;
    margin: 0;
    padding: 0;
    overflow: hidden;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--main-bg);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
}

.container {
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: transparent;
    padding: 0;
    margin: 0;
    box-sizing: border-box;
    overflow: hidden;
}

header {
    text-align: center;
    margin-bottom: 0.2rem;
}

h1 {
    font-size: clamp(1.2rem, 3vw, 2.2rem);
    margin-bottom: 0.2rem;
    letter-spacing: 1px;
    color: #fff;
    text-shadow: 0 2px 8px #000a;
}

.game-info div{
    position: relative;
    background: var(--hud-bg);
    margin: 0.5em 0;
    padding: 0.3em 1em;
    font-weight: 600;
    color: var(--hud-text);
    font-size: clamp(0.9rem, 1.5vw, 1.1rem);
}
.game-info div::after{
    content: "";
    display: block;
    width: 120%;
    height: 100%;
    position: absolute;
    top: -1px;
    left: -0.5em;
    background: transparent;
    border: 1px solid var(--hud-border);
    border-left: none;
    border-top: none;
    -webkit-transform: skew(30deg); /* Chrome, Opera */
    -ms-transform: skew(30deg); /* IE */
    transform: skew(30deg); /* Padrão */
}

.game-controls {
    display: flex;
    gap: 0.5em;
    flex-wrap: wrap;
    justify-content: center;
}

.btn {
    padding: 0.5em 1.1em;
    border-radius: 8px;
    font-size: clamp(0.9rem, 1.5vw, 1.1rem);
}

.difficulty-select {
    padding: 0.4em 0.8em;
    border-radius: 7px;
    font-size: clamp(0.9rem, 1.2vw, 1rem);
}

.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 80px;
    display: flex;
    align-items: center;
    gap: 0.7em;
    background: transparent;
    z-index: 1500;
    padding: 0.5em 1em 0.2em 1em;
    pointer-events: none;
}
.top-bar .hamburger-btn {
    position: static;
    margin-right: 0.5em;
    pointer-events: auto;
}
.logo {
    font-size: 1.7rem;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 2px 8px #000a;
    letter-spacing: 1px;
    pointer-events: auto;
}
.adsense-banner {
    position: fixed;
    left: 50%;
    bottom: 0;
    transform: translateX(-50%);
    width: 100vw;
    max-width: 728px;
    min-height: 50px;
    max-height: 140px;
    background: #222a;
    border-radius: 10px 10px 0 0;
    box-shadow: 0 -1px 8px #0002;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    margin: 0;
    padding: 0.2em 0;
}

.puzzle-container {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100vw;
    height: 100vh;
    padding: 0;
    margin: 0;
}

.puzzle-board {
    position: relative;
    background: var(--tabuleiro-borda);
    border-radius: 18px;
    border: 12px solid var(--tabuleiro-borda);
    box-shadow: var(--tabuleiro-sombra), var(--tabuleiro-sombra) inset;
    aspect-ratio: 1/1;
    max-width: 98vw;
    max-height: 98vh;
    width: 98vw;
    height: 98vw;
    display: block;
    box-sizing: border-box;
    border-width: 6vw;
    z-index: 1;
}

/* 1. Muito retrato: aspect-ratio < 4/5 */
@media (max-aspect-ratio: 4/5) {
    .container {
        flex-direction: column;
        align-items: center;
        justify-content: center;
        width: 100vw;
        min-width: 100vw;
        max-width: 100vw;
        height: 100vh;
        min-height: 100vh;
        max-height: 100vh;
    }
    .adsense-banner {
        width: 100vw;
        height: 20vh;
        max-width: 100vw;
        min-width: 100px;
        max-height: 120px;
        margin: 0 auto;
        border-radius: 10px 10px 0 0;
    }
    .puzzle-container {
        width: 80vw;
        height: 80vw;
        max-width: 80vw;
        max-height: 80vw;
        margin: 0 auto;
        display: flex;
        align-items: center;
        justify-content: center;
        height: 100vh;
    }
    .puzzle-board {
        width: 98vw;
        height: 98vw;
        max-width: 98vw;
        max-height: 98vw;
        margin: 0 auto;
    }
    .hamburger-menu {
        padding-top: 2.5em;
        align-items: flex-start;
    }
}

/* 2. Quase quadrado: 4/5 <= aspect-ratio <= 5/4 */
@media (min-aspect-ratio: 4/5) and (max-aspect-ratio: 5/4) {
    .container {
        flex-direction: column;
        align-items: center;
        justify-content: center;
    }
    .adsense-banner {
        min-height: 60px;
        max-height: 120px;
        margin-bottom: 0.7em;
    }
    .puzzle-container {
        width: 98vw;
        height: 98vw;
        max-width: 98vw;
        max-height: 98vw;
    }
    .puzzle-board {
        width: 80vw;
        height: 80vw;
        max-width: 80vh;
        max-height: 80vh;
        border-width: calc(min(5vh, 5vw));
    }
}

/* 3. Muito paisagem: aspect-ratio > 5/4 */
@media (min-aspect-ratio: 5/4) {
    .hamburger-menu {
        position: fixed;
        top: 0;
        left: 0;
        width: 320px;
        max-width: 30vw;
        height: 100vh;
        background: var(--hud-bg);
        box-shadow: 4px 0 24px #000a;
        z-index: 1300;
        transform: none !important;
        display: flex !important;
        flex-direction: column;
        align-items: flex-start;
        padding: 120px 2vw 2vw 2vw;
        gap: 1.5rem;
        transition: none;
    }
    .menu-overlay,
    .hamburger-btn {
        display: none !important;
    }
    .container {
        margin-left: 320px;
        width: calc(100vw - 320px);
        max-width: calc(100vw - 320px);
    }
    .adsense-banner {
        min-height: 90px;
        max-height: 140px;
        width: 60vw;
        max-width: 468px;
    }
    main {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        height: 100vh;
    }
    .puzzle-container {
        width: 80vh;
        height: 80vh;
        max-width: 80vw;
        max-height: 80vh;
    }
    .puzzle-board {
        width: 80vh;
        height: 80vh;
        max-width: 80vw;
        max-height: 80vh;
        border-width: 6vh;
    }
}

.puzzle-tile {
    position: absolute;
    background: var(--peca-bg);
    color: var(--peca-text);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    border-radius: 8px;
    box-shadow: var(--peca-sombra);
    cursor: pointer;
    user-select: none;
    border: 2px solid #eee;
    transition: left 0.3s, top 0.3s, background 0.2s, color 0.2s, box-shadow 0.2s, transform 0.1s;
    overflow: hidden;
    width: calc(100% / var(--puzzle-size));
    height: calc(100% / var(--puzzle-size));
    font-size: min(8vh, 8vw);
}
.puzzle-tile:hover {
    background: var(--peca-hover);
    box-shadow: 0 4px 16px #0003;
    z-index: 1000;
}
.puzzle-tile:active {
    background: var(--peca-active);
    box-shadow: 0 1px 4px #0002;
    transform: scale(0.98);
}
.puzzle-tile.empty {
    background: transparent;
    border: none;
    cursor: default;
    box-shadow: none;
}
.puzzle-tile.correct {
    background: #fff;
    color: var(--peca-correta);
    border: 2px solid var(--peca-correta);
    box-shadow: 0 0 0 3px #00e67655;
}

.game-status {
    text-align: center;
    min-height: 2rem;
    font-size: clamp(1rem, 2vw, 1.3rem);
    color: #fff;
    margin-top: 1em;
}

.status-message {
    font-weight: 600;
    color: #00e676;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal.hidden {
    display: none;
}
.modal-content {
    background: #232526;
    padding: 2rem;
    border-radius: 20px;
    text-align: center;
    max-width: 400px;
    width: 90vw;
    box-shadow: 0 20px 40px #000a;
    color: #fff;
    border: 2px solid #00e676;
}
.modal-content h2 {
    color: #00e676;
    margin-bottom: 1rem;
}
.stats {
    background: #232526;
    padding: 1rem;
    border-radius: 10px;
    margin: 1rem 0;
    border: 1px solid #00e676;
}
.stats p {
    margin: 0.5rem 0;
    font-weight: 600;
    color: #fff;
}

.install-prompt {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    padding: 1rem;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    display: flex;
    gap: 1rem;
    align-items: center;
    z-index: 1000;
}

.install-prompt.hidden {
    display: none;
}


/* Tema escuro */
@media (prefers-color-scheme: dark) {
    body {
        background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    }
    
    .container {
        background: rgba(52, 73, 94, 0.95);
        color: white;
    }
    
    .btn.secondary {
        background: #34495e;
        color: white;
    }
    
    .btn.secondary:hover {
        background: #2c3e50;
    }
    
    .difficulty-select {
        background: #34495e;
        color: white;
        border-color: #2c3e50;
    }
    
    .modal-content {
        background: #34495e;
        color: white;
    }
    
    .stats {
        background: #2c3e50;
    }
    
    .install-prompt {
        background: #34495e;
        color: white;
    }
}

/* Menu hambúrguer para aspect-ratio < 4/5 */
.hamburger-btn {
    position: fixed;
    top: 1.2vw;
    left: 1.2vw;
    z-index: 1200;
    background: var(--hud-bg);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 2.2rem;
    padding: 0.2em 0.5em;
    box-shadow: 0 2px 8px #0006;
    cursor: pointer;
    display: none;
}
.menu-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1100;
    display: none;
}
.hamburger-menu {
    position: fixed;
    top: 0; left: 0;
    width: 360px;
    max-width: 100vw;
    height: 100vh;
    background: var(--hud-bg);
    box-shadow: 4px 0 24px #000a;
    z-index: 1300;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(.77,0,.18,1);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 100px 0 2vw;
    gap: 1.5rem;
}
.hamburger-menu.open {
    transform: translateX(0);
}
.menu-overlay.open {
    display: block;
}
.hamburger-btn.open {
    display: block;
}

@media (max-aspect-ratio: 4.99/4) {
    .hamburger-btn {
        display: block;
    }
    .hamburger-menu {
        display: flex;
    }
}
@media (min-aspect-ratio: 5/4) {
    .hamburger-btn, .menu-overlay {
        display: none !important;
    }
}

.hamburger-menu .game-controls {
    flex-direction: column;
    gap: 1.2em;
    width: 100%;
    margin-top: 2em;
}

.hamburger-menu .btn, .hamburger-menu .difficulty-select {
    width: 100%;
    font-size: 1.3rem;
    padding: 1em 0;
    margin-bottom: 1em;
    border-radius: 0;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    box-shadow: none;
    border: 1px solid rgba(255, 255, 255, 0.2);
    text-align: center;
    transition: all 0.3s ease;
}

.hamburger-menu .btn:hover, .hamburger-menu .difficulty-select:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.hamburger-menu .btn:active, .hamburger-menu .difficulty-select:active {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* Botão de categoria (acordeão) */
.menu-accordion-btn {
    position: relative;
    width: 90%;
    background: transparent;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 12px 16px;
    font-weight: bold;
    font-size: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    margin-bottom: 2px;
    transition: background 0.2s, color 0.2s;
    box-shadow: 0 2px 6px rgba(0,0,0,0.04);
}

.menu-accordion-btn::after {
    content: "";
    display: block;
    width: 105%;
    height: 100%;
    position: absolute;
    top: 0;
    left: -1em;
    background: transparent;
    border: 1px solid var(--hud-border);
    border-left: none;
    border-top: none;
    -webkit-transform: skew(30deg); /* Chrome, Opera */
    -ms-transform: skew(30deg); /* IE */
    transform: skew(30deg); /* Padrão */
}

.menu-accordion-btn .seta {
    font-size: 1.2em;
    margin-left: 8px;
    transition: transform 0.3s;
}

/* Rotaciona seta quando aberto */
.menu-accordion-item.ativo .seta {
    transform: rotate(180deg);
}

/* Painel de subcategorias */
.menu-accordion-panel {
    max-height: 0;
    width: 70%;
    overflow: hidden;
    transition: max-height 0.3s;
    border-radius: 0 0 6px 6px;
}

.menu-accordion-item{
    width: 100%;
}

.menu-accordion-item.ativo .menu-accordion-panel {
    max-height: 400px; /* Ajuste conforme necessário */
}

/* Subcategoria */
.menu-subcategoria {
    display: block;
    width: 100%;
    padding: 10px 20px;
    background: #ffffff0C;
    color: #fff;
    border: none;
    border-bottom: 1px solid #ddd;
    cursor: pointer;
    font-size: 2em;
    text-align: left;
    transition: background 0.2s;
    font-weight: 200;
}

.menu-subcategoria:hover, .menu-subcategoria:active{
    background: #ffffff11;
}

.menu-subcategoria:last-child {
    border-bottom: none;
}

.menu-subcategoria small{
    font-size: 0.63em;
    font-weight: 200;
    color: #fff;
}

/* Botões finais */
.menu-botoes-finais button,
.menu-final-btn {
    width: 100%;
    background: #127187;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 12px 0;
    font-weight: bold;
    font-size: 1rem;
    cursor: pointer;
    margin-bottom: 8px;
    transition: background 0.2s;
}

.menu-botoes-finais button:last-child,
.menu-final-btn:last-child {
    background: #0097a7;
} 