@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    height: 100%;
    height: -webkit-fill-available;
}

body {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    min-height: 100%;
    min-height: -webkit-fill-available;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: 'Press Start 2P', cursive;
    color: #ffd700;
    overflow: hidden;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

#game-container {
    background: #0a0a0a;
    border: 2px solid #ffd700;
    border-radius: 8px;
    padding: 6px;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.3);
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 360px;
    height: 100%;
    max-height: 100vh;
    max-height: -webkit-fill-available;
}

/* Header - compact mobile */
#header {
    text-align: center;
    margin-bottom: 4px;
    flex-shrink: 0;
}

#header h1 {
    font-size: 11px;
    text-shadow: 2px 2px 0 #b8860b;
    margin-bottom: 4px;
    letter-spacing: 1px;
}

#stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 10px;
    background: #1a1a1a;
    border: 2px solid #333;
    border-radius: 4px;
}

#score {
    font-size: 8px;
    color: #4ecdc4;
}

#lives .heart {
    color: #ff6b6b;
    font-size: 12px;
    margin-left: 3px;
    text-shadow: 0 0 5px #ff6b6b;
}

#lives .heart.lost {
    color: #333;
    text-shadow: none;
}

/* Game Area - mobile stacked layout */
#game-area {
    display: flex;
    flex-direction: column;
    gap: 6px;
    justify-content: center;
    align-items: center;
    flex: 1;
    min-height: 0;
}

#game-canvas {
    background: linear-gradient(180deg, #1a1a2e 0%, #2d2d44 50%, #3d3d5c 100%);
    border: 2px solid #4a4a6a;
    border-radius: 4px;
    image-rendering: pixelated;
    width: 100%;
    max-width: 300px;
    aspect-ratio: 4/5;
    touch-action: none;
}

#image-reveal {
    width: 80px;
    height: 160px;
    background: #1a1a1a;
    border: 2px solid #4a4a6a;
    border-radius: 4px;
    overflow: hidden;
    position: relative;
    flex-shrink: 0;
}

#mucha-container {
    position: relative;
    width: 100%;
    height: 100%;
}

#mucha-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    image-rendering: auto;
}

#mucha-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(6, 1fr);
}

.tile {
    background: #0a0a0a;
    border: 1px solid #1a1a1a;
    transition: opacity 0.4s ease;
}

.tile.revealed {
    opacity: 0;
}

/* Mobile Controls - prominent at bottom */
#mobile-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    margin-top: auto;
    flex-shrink: 0;
    gap: 20px;
}

.control-btn {
    flex: 1;
    max-width: 100px;
    height: 60px;
    font-size: 24px;
    background: linear-gradient(180deg, #ffd700 0%, #b8860b 100%);
    border: none;
    border-radius: 12px;
    color: #000;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
    box-shadow:
        0 4px 0 #8b6914,
        0 6px 12px rgba(0, 0, 0, 0.4);
    transition: transform 0.05s, box-shadow 0.05s;
    -webkit-tap-highlight-color: transparent;
}

.control-btn:active,
.control-btn.pressed {
    transform: translateY(3px);
    box-shadow:
        0 1px 0 #8b6914,
        0 2px 4px rgba(0, 0, 0, 0.4);
}

/* Overlays */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
    padding: 20px;
}

/* Start screen with background image */
#start-screen {
    background:
        linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.6)),
        url('../assets/pivni_secese_bg.jpg') center center / cover no-repeat;
    background-color: #1a1a2e;
}

.overlay.hidden {
    display: none;
}

.overlay h2 {
    font-size: 20px;
    margin-bottom: 15px;
    text-shadow: 3px 3px 0 #b8860b;
    animation: pulse 1s ease-in-out infinite;
    text-align: center;
}

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

.overlay p {
    font-size: 10px;
    margin-bottom: 10px;
    color: #ccc;
    text-align: center;
}

.overlay .controls {
    color: #4ecdc4;
    font-size: 8px;
}

.overlay button {
    margin-top: 15px;
    padding: 12px 30px;
    font-family: 'Press Start 2P', cursive;
    font-size: 11px;
    background: linear-gradient(180deg, #ffd700 0%, #b8860b 100%);
    border: none;
    border-radius: 4px;
    color: #000;
    cursor: pointer;
    box-shadow:
        0 3px 0 #8b6914,
        0 4px 8px rgba(0, 0, 0, 0.4);
    -webkit-tap-highlight-color: transparent;
}

.overlay button:active {
    transform: translateY(2px);
    box-shadow:
        0 1px 0 #8b6914,
        0 2px 4px rgba(0, 0, 0, 0.4);
}

.button-row {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.button-row button {
    margin-top: 0;
    padding: 12px 20px;
    font-size: 9px;
}

.production {
    margin-top: 30px;
    font-size: 7px;
    color: #666;
    letter-spacing: 1px;
    text-transform: lowercase;
    font-style: italic;
}

/* Language toggle */
.lang-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    padding: 8px 12px;
    font-family: 'Press Start 2P', cursive;
    font-size: 10px;
    background: transparent;
    border: 2px solid #ffd700;
    border-radius: 4px;
    color: #ffd700;
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.lang-btn:hover,
.lang-btn:active {
    background: #ffd700;
    color: #000;
}

#revealed-artist,
#gameover-artist {
    margin-top: 8px;
    font-size: 8px;
    color: #4ecdc4;
    text-align: center;
}

#mucha-quote {
    margin-top: 12px;
    padding: 10px 15px;
    font-size: 7px;
    color: #ccc;
    text-align: center;
    font-style: italic;
    line-height: 1.6;
    max-width: 300px;
    border-left: 2px solid #ffd700;
    border-right: 2px solid #ffd700;
}

/* Download wallpaper button */
.download-btn {
    margin-top: 12px;
    padding: 10px 20px;
    font-family: 'Press Start 2P', cursive;
    font-size: 9px;
    background: linear-gradient(180deg, #4ecdc4 0%, #2d9a94 100%);
    border: none;
    border-radius: 4px;
    color: #000;
    cursor: pointer;
    box-shadow:
        0 3px 0 #1f6f6a,
        0 4px 8px rgba(0, 0, 0, 0.4);
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.1s, box-shadow 0.1s;
}

.download-btn:active {
    transform: translateY(2px);
    box-shadow:
        0 1px 0 #1f6f6a,
        0 2px 4px rgba(0, 0, 0, 0.4);
}

/* Result image on end screens */
.result-image-container {
    width: 140px;
    height: 280px;
    margin: 10px auto;
    border: 2px solid #ffd700;
    border-radius: 4px;
    overflow: hidden;
    position: relative;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.3);
}

.result-image-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    image-rendering: auto;
}

.result-image-container .result-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(6, 1fr);
}

.result-image-container .result-overlay .tile {
    background: #0a0a0a;
    border: 1px solid #1a1a1a;
}

.result-image-container .result-overlay .tile.revealed {
    opacity: 0;
}

/* Speed indicator */
.speed-indicator {
    position: absolute;
    top: 5px;
    left: 5px;
    font-size: 7px;
    color: #ff6b6b;
    text-shadow: 0 0 5px #ff6b6b;
}

/* Mobile-first: hide desktop-only */
.desktop-only {
    display: none;
}

.mobile-only {
    display: block;
}

/* Landscape mobile */
@media (orientation: landscape) and (max-height: 500px) {
    #game-container {
        flex-direction: row;
        flex-wrap: wrap;
        max-width: 100%;
        padding: 4px 10px;
    }

    #header {
        width: 100%;
        margin-bottom: 2px;
    }

    #header h1 {
        font-size: 10px;
        margin-bottom: 2px;
    }

    #game-area {
        flex-direction: row;
        flex: 1;
    }

    #game-canvas {
        max-width: 200px;
        height: auto;
        aspect-ratio: 3/4;
    }

    #image-reveal {
        width: 60px;
        height: 120px;
    }

    #mobile-controls {
        flex-direction: column;
        width: 80px;
        gap: 10px;
        padding: 4px;
    }

    .control-btn {
        height: 50px;
        max-width: 70px;
    }
}

/* Tablet and desktop */
@media (min-width: 600px) and (min-height: 600px) {
    #game-container {
        padding: 16px;
        max-width: 650px;
    }

    #header h1 {
        font-size: 20px;
        margin-bottom: 8px;
    }

    #stats {
        padding: 8px 16px;
    }

    #score {
        font-size: 11px;
    }

    #lives .heart {
        font-size: 16px;
    }

    #game-area {
        flex-direction: row;
        gap: 15px;
    }

    #game-canvas {
        width: 350px;
        max-width: 350px;
        height: 350px;
        aspect-ratio: auto;
    }

    #image-reveal {
        width: 175px;
        height: 350px;
    }

    .result-image-container {
        width: 160px;
        height: 320px;
    }
}

/* Large desktop */
@media (min-width: 900px) {
    #game-container {
        padding: 20px;
        max-width: 720px;
    }

    #header h1 {
        font-size: 24px;
        margin-bottom: 10px;
    }

    #stats {
        padding: 10px 20px;
    }

    #score {
        font-size: 12px;
    }

    #game-area {
        gap: 20px;
    }

    #game-canvas {
        width: 400px;
        max-width: 400px;
        height: 400px;
    }

    #image-reveal {
        width: 200px;
        height: 400px;
    }

    #mobile-controls {
        display: none;
    }

    .desktop-only {
        display: block;
    }

    .mobile-only {
        display: none;
    }

    .overlay h2 {
        font-size: 28px;
        margin-bottom: 25px;
    }

    .overlay p {
        font-size: 12px;
        margin-bottom: 15px;
    }

    .overlay .controls {
        font-size: 10px;
    }

    .overlay button {
        padding: 15px 40px;
        font-size: 14px;
    }

    .result-image-container {
        width: 180px;
        height: 360px;
    }

    #revealed-artist,
    #gameover-artist {
        font-size: 10px;
    }
}

/* Safe area for notch/dynamic island */
@supports (padding: env(safe-area-inset-top)) {
    body {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
}
