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

body {
    font-family: 'Comic Sans MS', 'Arial', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    overflow-x: hidden;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

/* Controls Panel */
.controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.controls-right {
    display: flex;
    gap: 10px;
}

.btn {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    border: none;
    border-radius: 15px;
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

.btn:active {
    transform: scale(0.95);
}

.btn svg {
    width: 24px;
    height: 24px;
    color: white;
}

.btn-back {
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
}

.btn-sound {
    background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
}

.btn-restart {
    background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
}

/* Level Display */
.level-display {
    display: flex;
    align-items: baseline;
    gap: 5px;
    font-size: 20px;
    font-weight: bold;
    color: #667eea;
}

.level-number {
    font-size: 32px;
    color: #f5576c;
}

.level-total {
    font-size: 18px;
    color: #999;
}

/* Game Container */
.game-container {
    display: flex;
    gap: 20px;
    padding: 20px;
    max-width: 1400px;
    margin: 0 auto;
    min-height: calc(100vh - 80px);
    align-items: stretch;
}

/* Board with holes */
.board {
    flex: 1;
    background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
    border-radius: 30px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
}

.board-title {
    font-size: 24px;
    color: #333;
    text-align: center;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(255, 255, 255, 0.5);
}

.holes-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    flex: 1;
    justify-content: center;
}

.hole {
    background: rgba(255, 255, 255, 0.5);
    border: 4px dashed #999;
    border-radius: 20px;
    padding: 20px;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    position: relative;
}

.hole.drag-over {
    background: rgba(255, 255, 255, 0.8);
    border-color: #4CAF50;
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(76, 175, 80, 0.5);
}

.hole.filled {
    border-style: solid;
    border-color: #4CAF50;
    background: rgba(76, 175, 80, 0.1);
}

.hole.hint-glow {
    animation: hintPulse 1.5s ease-in-out infinite;
    border-color: #ff00ff;
    box-shadow: 0 0 30px rgba(255, 0, 255, 0.8);
}

@keyframes hintPulse {
    0%, 100% {
        box-shadow: 0 0 20px rgba(255, 0, 255, 0.6), 0 0 40px rgba(255, 0, 255, 0.4);
    }
    50% {
        box-shadow: 0 0 40px rgba(255, 0, 255, 0.9), 0 0 60px rgba(255, 0, 255, 0.6);
    }
}

/* Hole silhouettes */
.hole-silhouette {
    opacity: 0.2;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.hole-silhouette svg {
    width: 80px;
    height: 80px;
}

.hole.filled .hole-silhouette {
    opacity: 0;
}

.hole.drag-over .hole-silhouette {
    opacity: 0.4;
}

/* Shapes Area */
.shapes-area {
    flex: 1;
    background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
    border-radius: 30px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
}

.shapes-title {
    font-size: 24px;
    color: #333;
    text-align: center;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(255, 255, 255, 0.5);
}

.shapes-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    flex: 1;
    justify-content: center;
    align-items: center;
}

.shape {
    background: white;
    border-radius: 20px;
    padding: 20px;
    cursor: grab;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 100px;
    min-height: 100px;
    touch-action: none;
}

.shape:active {
    cursor: grabbing;
}

.shape.dragging {
    opacity: 0.5;
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
    z-index: 1000;
}

.shape.hint-glow {
    animation: hintPulse 1.5s ease-in-out infinite;
    box-shadow: 0 0 30px rgba(255, 0, 255, 0.8);
}

.shape svg {
    width: 80px;
    height: 80px;
    pointer-events: none;
}

.shape.placed {
    cursor: default;
    opacity: 0;
    transform: scale(0);
    transition: all 0.4s ease;
}

/* Success animation */
@keyframes successPop {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
    }
}

.hole.success {
    animation: successPop 0.5s ease;
}

/* Confetti particles */
.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #f5576c;
    animation: confettiFall 2s ease-out forwards;
    pointer-events: none;
}

@keyframes confettiFall {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(300px) rotate(360deg);
        opacity: 0;
    }
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.modal.show {
    display: flex;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-content {
    background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
    border-radius: 30px;
    padding: 40px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.4s ease;
    max-width: 90%;
}

.modal-large {
    padding: 50px;
    max-width: 600px;
}

@keyframes slideUp {
    from {
        transform: translateY(100px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.celebration-emoji {
    font-size: 60px;
    margin-bottom: 20px;
    animation: bounce 1s ease infinite;
}

.celebration-large {
    font-size: 80px;
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-20px);
    }
}

.modal-title {
    font-size: 36px;
    color: #f5576c;
    margin-bottom: 15px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.modal-title-large {
    font-size: 48px;
}

.modal-text {
    font-size: 24px;
    color: #333;
    margin-bottom: 20px;
}

.modal-subtext {
    font-size: 20px;
    color: #666;
    margin-bottom: 30px;
}

.stars {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 30px;
    font-size: 40px;
}

.star {
    animation: starPop 0.5s ease forwards;
    opacity: 0;
}

.star:nth-child(1) {
    animation-delay: 0.2s;
}

.star:nth-child(2) {
    animation-delay: 0.4s;
}

.star:nth-child(3) {
    animation-delay: 0.6s;
}

@keyframes starPop {
    0% {
        transform: scale(0) rotate(0deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.3) rotate(180deg);
    }
    100% {
        transform: scale(1) rotate(360deg);
        opacity: 1;
    }
}

.btn-next,
.btn-play-again,
.btn-home {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 20px;
    padding: 15px 40px;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.3);
    margin: 10px;
    min-width: 200px;
    min-height: 60px;
}

.btn-next:hover,
.btn-play-again:hover,
.btn-home:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}

.btn-next:active,
.btn-play-again:active,
.btn-home:active {
    transform: scale(0.95);
}

/* Responsive Design */
@media (max-width: 768px) {
    .game-container {
        flex-direction: column;
        padding: 10px;
    }

    .board,
    .shapes-area {
        min-height: auto;
    }

    .board-title,
    .shapes-title {
        font-size: 20px;
    }

    .shape svg {
        width: 60px;
        height: 60px;
    }

    .hole {
        min-height: 100px;
    }

    .hole-silhouette svg {
        width: 60px;
        height: 60px;
    }

    .modal-content {
        padding: 30px;
    }

    .modal-title {
        font-size: 28px;
    }

    .btn-next,
    .btn-play-again,
    .btn-home {
        font-size: 20px;
        padding: 12px 30px;
        min-width: 150px;
    }
}

@media (max-width: 480px) {
    .controls {
        padding: 10px;
    }

    .level-display {
        font-size: 16px;
    }

    .level-number {
        font-size: 24px;
    }

    .btn svg {
        width: 20px;
        height: 20px;
    }

    .board,
    .shapes-area {
        padding: 20px;
    }

    .board-title,
    .shapes-title {
        font-size: 18px;
    }

    .shape {
        min-width: 80px;
        min-height: 80px;
    }

    .shape svg {
        width: 50px;
        height: 50px;
    }

    .hole-silhouette svg {
        width: 50px;
        height: 50px;
    }
}

/* Дуже маленькі телефони */
@media (max-width: 400px) {
    .controls {
        padding: 8px;
    }

    .level-display {
        font-size: 14px;
    }

    .level-number {
        font-size: 20px;
    }

    .btn {
        padding: 10px 12px;
        min-width: 40px;
        min-height: 40px;
    }

    .btn svg {
        width: 18px;
        height: 18px;
    }

    .game-container {
        padding: 8px;
        gap: 15px;
    }

    .board,
    .shapes-area {
        padding: 15px;
        border-radius: 20px;
    }

    .board-title,
    .shapes-title {
        font-size: 16px;
        margin-bottom: 15px;
    }

    .holes-container,
    .shapes-container {
        gap: 15px;
    }

    .hole {
        min-height: 90px;
        padding: 15px;
    }

    .shape {
        min-width: 70px;
        min-height: 70px;
        padding: 15px;
    }

    .shape svg {
        width: 45px;
        height: 45px;
    }

    .hole-silhouette svg {
        width: 45px;
        height: 45px;
    }

    .modal-content {
        padding: 25px;
    }

    .modal-title {
        font-size: 24px;
    }

    .modal-text {
        font-size: 18px;
    }

    .btn-next,
    .btn-play-again,
    .btn-home {
        font-size: 18px;
        padding: 10px 25px;
        min-width: 130px;
        min-height: 50px;
    }
}

/* Landscape orientation для телефонів */
@media (max-width: 896px) and (orientation: landscape) {
    .game-container {
        flex-direction: row;
        padding: 10px;
        gap: 15px;
    }

    .controls {
        padding: 8px 15px;
    }

    .level-display {
        font-size: 16px;
    }

    .level-number {
        font-size: 22px;
    }

    .btn {
        padding: 8px 12px;
        min-width: 40px;
        min-height: 40px;
    }

    .btn svg {
        width: 18px;
        height: 18px;
    }

    .board,
    .shapes-area {
        padding: 15px;
    }

    .board-title,
    .shapes-title {
        font-size: 16px;
        margin-bottom: 10px;
    }

    .holes-container,
    .shapes-container {
        gap: 12px;
    }

    .hole {
        min-height: 80px;
        padding: 12px;
    }

    .shape {
        min-width: 70px;
        min-height: 70px;
        padding: 12px;
    }

    .shape svg {
        width: 45px;
        height: 45px;
    }

    .hole-silhouette svg {
        width: 45px;
        height: 45px;
    }
}

/* Touch-specific improvements */
@media (hover: none) and (pointer: coarse) {
    /* Видаляємо hover ефекти на touch пристроях */
    .btn:hover,
    .btn-next:hover,
    .btn-play-again:hover,
    .btn-home:hover {
        transform: none;
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    }

    /* Активні стани вже добре налаштовані, залишаємо як є */

    /* Додаємо всім кнопкам -webkit-tap-highlight-color */
    .btn,
    .btn-next,
    .btn-play-again,
    .btn-home,
    .shape {
        -webkit-tap-highlight-color: transparent;
    }

    /* Покращений курсор для тач-пристроїв */
    .shape {
        cursor: default;
    }

    .shape:active {
        cursor: default;
    }
}
