html, body {
    height: 100%;
    margin: 0;
    padding: 0;
}

body {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background-color: #f0f0f0;
    font-family: Arial, sans-serif;
    overflow: hidden;
}

.game-container {
    display: grid;
    grid-template-columns: 2fr 1fr;
    width: 100vw;
    height: 100vh;
}

.game-board {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    width: 100%;
    position: relative;
    background-image: url('assets/grid_background.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.side-panel {
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding: 40px;
    background-color: #f8f8f8;
    background-image: url('assets/sidegrid_background_wood.png'), url('assets/grid_background.png');
    background-size: cover, cover;
    background-position: center, center;
    background-repeat: no-repeat, no-repeat;
    border-radius: 0;
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
    align-items: center;
    justify-content: space-between;
    height: 100vh;
    width: 33.33vw;
    box-sizing: border-box;
}

.difficulty-buttons {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 15px;
    justify-content: center;
}

.difficulty-btn {
    padding: 0;
    background: none;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

.difficulty-btn:hover {
    transform: translateY(-2px) scale(1.05);
}

.difficulty-btn.active {
    transform: scale(1.1);
    box-shadow: 0 0 15px rgba(21, 101, 192, 0.6);
}

.difficulty-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.difficulty-btn.disabled:hover {
    transform: none;
    opacity: 0.5;
}

.difficulty-btn:focus, .difficulty-btn:active {
    outline: none;
    box-shadow: none;
}

.button-image {
    width: 110px;
    height: 110px;
    object-fit: cover;
    border-radius: 8px;
    transition: all 0.3s ease;
    display: block;
}

/* Responsive design for smaller screens */
@media (max-width: 768px) {
    .button-image {
        width: 80px;
        height: 80px;
    }
    
    .difficulty-buttons {
        gap: 8px;
    }
}

@media (max-width: 480px) {
    .button-image {
        width: 60px;
        height: 60px;
    }
    
    .difficulty-buttons {
        gap: 6px;
    }
}

.difficulty-btn:hover .button-image {
    filter: brightness(1.1);
}

.difficulty-btn.active .button-image {
    filter: brightness(1.2) drop-shadow(0 0 10px rgba(21, 101, 192, 0.8));
}

.difficulty-btn#classic-btn .button-image {
    transform: scaleY(1.25);
}

.difficulty-btn#forest-btn .button-image {
    border-radius: 32px;
    transform: scaleY(0.7);
}

.difficulty-btn#mountain-btn .button-image {
    transform: scaleY(0.8);
}

.available-blocks {
    margin: 15px 0;
    padding: 10px;
    background-color: #f0f0f0;
    border-radius: 8px;
    border: 1px solid #ddd;
}

.blocks-title {
    font-size: 14px;
    font-weight: bold;
    color: #333;
    margin-bottom: 8px;
    text-align: center;
}

.blocks-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    align-items: center;
}

.block-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 5px;
    background-color: white;
    border: 1px solid #ccc;
    border-radius: 4px;
    min-width: 40px;
    transition: all 0.2s ease;
}

.block-item.selected {
    background-color: #e3f2fd;
    border: 2px solid #2196F3;
    box-shadow: 0 0 8px rgba(33, 150, 243, 0.3);
}

.block-sprite {
    width: 24px;
    height: 24px;
    background-size: cover;
    background-repeat: no-repeat;
    border-radius: 2px;
    margin-bottom: 2px;
}

.block-name {
    font-size: 10px;
    color: #666;
    text-align: center;
    text-transform: capitalize;
}

.main-button {
    padding: 12px 24px;
    font-size: 16px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.main-button:hover {
    background-color: #45a049;
}

.mini-icons {
    display: flex;
    gap: 15px;
    margin-top: auto;
    flex-wrap: wrap;
    justify-content: center;
    max-width: 300px;
    padding: 30px 0;
}

.mini-button {
    width: 45px;
    height: 45px;
    border-radius: 5px;
    background-color: #2196F3;
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    transition: background-color 0.3s;
    position: relative;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.mini-button:hover {
    background-color: #1976D2;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.mini-button[title] {
    position: relative;
}

.mini-button[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 5px 10px;
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 1000;
    margin-bottom: 5px;
}

.controls-info {
    margin-bottom: 5px;
    font-size: 16px;
    color: #333;
}

.game-info-overlay {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: row;
    gap: 20px;
    z-index: 10;
}

.timer-info {
    margin-bottom: 5px;
    font-size: 18px;
    color: #444;
    transition: all 0.3s ease;
    background-color: rgba(255, 255, 255, 0.9);
    padding: 8px 12px;
    border-radius: 5px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.timer-info.speed-up {
    color: #ff6b6b;
    text-shadow: 0 0 10px #ff6b6b;
    animation: pulse 0.5s infinite;
}

.round-info {
    margin-bottom: 5px;
    font-size: 18px;
    color: #444;
    background-color: rgba(255, 255, 255, 0.9);
    padding: 8px 12px;
    border-radius: 5px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.turn-info {
    margin-top: -30px;
    margin-bottom: 0;
    padding-top: 0;
    padding-bottom: 0;
    line-height: 1;
    font-size: 20px;
    color: #222;
    font-weight: bold;
}

.turn-details {
    color: #4FC3F7;
    font-weight: 600;
}

.hider-glow {
    color: #4CAF50;
    text-shadow: 0 0 10px rgba(76, 175, 80, 0.8);
    animation: hiderGlow 2s ease-in-out infinite;
}

.seeker-glow {
    color: #FF9800;
    text-shadow: 0 0 10px rgba(255, 152, 0, 0.8);
    animation: seekerGlow 2s ease-in-out infinite;
}

@keyframes hiderGlow {
    0%, 100% { text-shadow: 0 0 10px rgba(76, 175, 80, 0.8); }
    50% { text-shadow: 0 0 20px rgba(76, 175, 80, 1), 0 0 30px rgba(76, 175, 80, 0.6); }
}

@keyframes seekerGlow {
    0%, 100% { text-shadow: 0 0 10px rgba(255, 152, 0, 0.8); }
    50% { text-shadow: 0 0 20px rgba(255, 152, 0, 1), 0 0 30px rgba(255, 152, 0, 0.6); }
}

.grid-container {
    display: grid;
    grid-template-columns: repeat(28, 1fr);
    grid-template-rows: repeat(28, 1fr);
    gap: 1px;
    background-color: #333;
    padding: 1px;
    border: 1px solid #333;
    box-sizing: border-box;
    width: min(90vw, calc(90vh * (28 / 28)));
    height: min(calc(90vw * (28 / 28)), 90vh);
    aspect-ratio: 28 / 28;
    max-width: 98vw;
    max-height: 90vh;
    margin-top: 50px;
}

.grid-item {
    background-color: white;
    border: 1px solid #000;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 2px;
}

.hiding-block {
    background-color: #4CAF50;
    box-shadow: 0 0 5px rgba(76, 175, 80, 0.5);
}

.hiding-block.hidden {
    background-color: #000;
    box-shadow: none;
}

.seeker {
    background-color: #FF9800;
    box-shadow: 0 0 5px rgba(255, 152, 0, 0.5);
}

.obstacle {
    background-color: #333;
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.3);
}

.border-block {
    background-color: #000;
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.3);
}

.found {
    background-color: #2196F3;
}

.game-over {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    display: none;
    z-index: 10;
}

.restart-btn {
    margin-top: 20px;
    padding: 10px 20px;
    font-size: 16px;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}

.restart-btn:hover {
    background-color: #45a049;
}

.found-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(33, 150, 243, 0.9);
    color: white;
    padding: 20px 40px;
    border-radius: 10px;
    font-size: 32px;
    font-weight: bold;
    display: none;
    z-index: 100;
    animation: fadeInOut 2s ease-in-out;
}

.start-prompt {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 20px 40px;
    border-radius: 10px;
    font-size: 24px;
    font-weight: bold;
    text-align: center;
    z-index: 100;
}

@keyframes fadeInOut {
    0%, 100% { opacity: 0; }
    50% { opacity: 1; }
}

.leaderboard-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    display: none;
}

.leaderboard-popup table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.leaderboard-popup th, .leaderboard-popup td {
    padding: 8px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

.leaderboard-popup th {
    background-color: #f5f5f5;
}

.game-title {
    font-size: 2.5em;
    color: #2196F3;
    margin: 0;
    padding: 10px 0;
    text-align: center;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
}

.game-title-logo {
    margin-top: 0;
    margin-bottom: 0;
    padding-top: 0;
    padding-bottom: 0;
    display: block;
    line-height: 1;
    max-width: 600px;
    max-height: 300px;
    width: auto;
    height: auto;
    margin: 0 auto;
}

.terrain-selection {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    margin: 20px 0;
    padding: 20px;
    background-color: #f0f0f0;
    border-radius: 10px;
    border: 2px solid #ddd;
}

.terrain-selection h2 {
    margin: 0;
    color: #333;
    font-size: 18px;
}

.terrain-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

/* Terrain sprite styling - remove borders for cleaner appearance */
.forest-sprite, .ocean-sprite, .mountain-sprite, .desert-sprite {
    border: none !important;
    border-radius: 0 !important;
}

.compass {
    position: absolute;
    right: 30px;
    bottom: 30px;
    width: 100px;
    height: 100px;
    background-color: #fff;
    border: 3px solid #333;
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    z-index: 100;
    transition: all 0.3s ease;
}

.compass.countdown {
    border-color: #ff4444;
    animation: compassPulse 1s infinite;
}

@keyframes compassPulse {
    0% { box-shadow: 0 0 0 0 rgba(255, 68, 68, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(255, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 68, 68, 0); }
}

.compass-arrow {
    width: 4px;
    height: 70px;
    background-color: #ff0000;
    position: relative;
    transform-origin: center;
    transition: transform 0.1s ease-out;
    will-change: transform;
}

.compass-arrow::before {
    content: '';
    position: absolute;
    top: 0;
    left: -6px;
    width: 0;
    height: 0;
    border-left: 7px solid transparent;
    border-right: 7px solid transparent;
    border-bottom: 12px solid #ff0000;
    transition: transform 0.1s ease-out;
    will-change: transform;
}

.tutorial-btn {
    background: none;
    border: none;
    padding: 0;
    box-shadow: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tutorial-btn:hover {
    transform: translateY(-2px) scale(1.05);
}

.tutorial-btn.active {
    transform: scale(1.1);
    box-shadow: 0 0 15px rgba(21, 101, 192, 0.6);
}

.tutorial-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.tutorial-btn.disabled:hover {
    transform: none;
    opacity: 0.5;
}

.tutorial-btn:focus, .tutorial-btn:active {
    outline: none;
    box-shadow: none;
}

.tutorial-btn .button-image {
    width: 150px;
    height: 150px;
}

@media (max-width: 768px) {
    .tutorial-btn .button-image {
        width: 110px;
        height: 110px;
    }
}

@media (max-width: 480px) {
    .tutorial-btn .button-image {
        width: 80px;
        height: 80px;
    }
}

.tutorial-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    display: none;
    z-index: 1000;
    overflow: hidden;
}

.tutorial-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    background: linear-gradient(135deg, #9C27B0, #7B1FA2);
    color: white;
}

.tutorial-header h3 {
    margin: 0;
    font-size: 20px;
}

.tutorial-close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.3s;
}

.tutorial-close-btn:hover {
    background-color: rgba(255,255,255,0.2);
}

.tutorial-content {
    padding: 25px;
    max-height: 400px;
    overflow-y: auto;
}

.tutorial-progress {
    font-weight: bold;
    color: #666;
}

.tutorial-section {
    background-color: #f8f9fa;
    border: 2px solid #9C27B0;
    border-radius: 8px;
    margin: 10px 0;
    padding: 18px 24px;
    width: 95%;
    max-width: none;
    box-sizing: border-box;
    animation: slideDown 0.3s ease-out;
    align-self: center;
}

@keyframes slideDown {
    from { 
        opacity: 0; 
        transform: translateY(-10px); 
        max-height: 0;
    }
    to { 
        opacity: 1; 
        transform: translateY(0); 
        max-height: 500px;
    }
}

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

.tutorial-step-container {
    position: relative;
}

.tutorial-step {
    display: none;
    animation: fadeIn 0.3s ease-in;
}

.tutorial-step.active {
    display: block;
}

.tutorial-step h4 {
    color: #9C27B0;
    margin-bottom: 10px;
    font-size: 16px;
}

.tutorial-step p {
    margin-bottom: 10px;
    line-height: 1.4;
    color: #333;
    font-size: 14px;
}

.tutorial-step ul {
    margin: 10px 0;
    padding-left: 20px;
}

.tutorial-step li {
    margin-bottom: 5px;
    font-size: 14px;
}

.tutorial-step .key-highlight {
    background-color: #E1BEE7;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: bold;
    color: #7B1FA2;
}

.tutorial-step .demo-keys {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
    margin: 10px 0;
}

.tutorial-step .demo-key {
    background-color: #9C27B0;
    color: white;
    padding: 6px 10px;
    border-radius: 4px;
    font-weight: bold;
    font-size: 12px;
    min-width: 30px;
    text-align: center;
    transition: all 0.2s ease;
}

.tutorial-step .demo-key.pressed {
    background-color: #ccc;
    color: #666;
    transform: scale(0.95);
}

.tutorial-step p:last-child {
    margin-top: 15px;
    font-weight: bold;
    color: #9C27B0;
    text-align: center;
}

.tutorial-note {
    background-color: #E8F5E8;
    border-left: 4px solid #4CAF50;
    padding: 10px 15px;
    margin: 15px 0 10px 0;
    border-radius: 4px;
    font-size: 13px;
    color: #2E7D32;
    font-style: italic;
}

.tutorial-finish {
    background-color: #9C27B0;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    font-size: 14px;
    transition: background-color 0.3s;
    margin-top: 10px;
}

.tutorial-finish:hover {
    background-color: #7B1FA2;
    transform: translateY(-2px);
}

.demo-game-container {
    background-color: #f0f0f0;
    border: 2px solid #9C27B0;
    border-radius: 8px;
    padding: 15px;
    margin: 15px 0;
    text-align: center;
}

.demo-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    gap: 1px;
    background-color: #333;
    padding: 1px;
    border: 1px solid #333;
    width: 200px;
    height: 200px;
    margin: 0 auto 15px auto;
}

.demo-grid-item {
    background-color: white;
    border: 1px solid #ccc;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 2px;
    transition: all 0.2s ease;
}

.demo-hider {
    background-color: #4CAF50;
    box-shadow: 0 0 5px rgba(76, 175, 80, 0.5);
}

.demo-seeker {
    background-color: #FF9800;
    box-shadow: 0 0 5px rgba(255, 152, 0, 0.5);
}

.demo-obstacle {
    background-color: #333;
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.3);
}

.demo-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-weight: bold;
    color: #333;
}

.demo-turn {
    color: #9C27B0;
    font-size: 14px;
}

.demo-timer {
    color: #666;
    font-size: 14px;
}

.demo-instruction {
    font-style: italic;
    color: #666;
    margin-top: 10px;
    font-size: 12px;
}
