* {
    box-sizing: border-box;
}
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #111;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    height: 100dvh; 
    margin: 0;
    padding: 10px;
    overflow: hidden;
}
#game-container {
    background: #333;
    padding: 0.5%;
    border-radius: 0.5%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    max-width: 100%;
    max-height: 100%;
}
.board-wrapper {
    position: relative;
    width: min(95vw, 90vh);
    height: min(95vw, 90vh);
    margin-bottom: 1%;
}
#board {
    background: #1110; 
    width: 100%;
    height: 100%;
    position: relative; /* <--- ИЗМЕНИТЬ С ABSOLUTE НА RELATIVE */
    top: 0;
    left: 0;
    z-index: 2;
    filter: drop-shadow(0.1vmax 0.2vmax 0.3vmax rgba(0, 0, 0, 0.9));
    transition: opacity 0.6s ease, filter 0.4s ease;
}
#board.fade-out {
    opacity: 0;
    padding: 0px;
}
#full-image-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1; 
    opacity: 0;
    transition: opacity 0.4s ease;
    filter: drop-shadow(0.1vmax 0.2vmax 0.3vmax rgba(0, 0, 0, 0.9));
}
#full-image-layer.fade-in {
    opacity: 1;
    padding: 0px;
    transition: opacity 0.4s ease, padding 0.4s ease;
}

.full-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.tile {
    position: absolute; 
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%); 
    background-repeat: no-repeat;
    cursor: pointer;
    user-select: none;
    -webkit-touch-callout: none; 
    clip-path: inset(1px round 24px); 
    filter: drop-shadow(0px 2px 4px rgba(0, 0, 0, 0.8)); 
    transition: transform 0.1s ease-out, clip-path 0.4s ease, filter 0.4s ease; 
    -webkit-tap-highlight-color: transparent; /* Полностью убирает мобильную подсветку */
}
#board.fade-out .tile {
    clip-path: inset(0px); 
    filter: drop-shadow(0px 0px 0px rgba(0, 0, 0, 0));
}
.tile:hover {
    opacity: 1.0;
}
.empty {
    background-image: none !important;
    background: #1110;
    cursor: default;
    box-shadow: none;
}
.controls-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: min(95vw, 90vh);
    padding: 0px;
    gap: 10px;
}
button {
    background: #1b5e20;
    color: #fff;
    border: none;
    padding: 12px 24px;
    font-size: 24px;
    font-weight: bold;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
    flex-shrink: 0;
}
button:hover {
    background: #2e7d32;
}
#image-title {
    color: #fff;
    font-size: 22px;
    opacity: 0;
    transform: translateX(-20px);
    transition: opacity 0.6s ease, transform 0.6s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-grow: 1; /* Позволяет тексту занимать все свободное место слева */
    text-shadow: 0px 2px 4px rgba(0, 0, 0, 0.8); 
}
#image-title.show {
    opacity: 1;
    transform: translateX(0);
}