/* ============================================
   MAZE GAME - Styling
   ============================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.container {
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    padding: 30px;
    max-width: 1000px;
    width: 100%;
}

.header {
    text-align: center;
    margin-bottom: 30px;
}

.header h1 {
    color: #2C3E50;
    font-size: 2.5em;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.info {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
    background: #ECF0F1;
    padding: 20px;
    border-radius: 10px;
}

.controls-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.controls-group label {
    font-weight: bold;
    color: #2C3E50;
}

.controls-group select {
    padding: 8px 12px;
    font-size: 1em;
    border: 2px solid #3498DB;
    border-radius: 5px;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

.controls-group select:hover {
    background: #F8F9FA;
}

.controls-group select:focus {
    outline: none;
    border-color: #2980B9;
    box-shadow: 0 0 5px rgba(52, 152, 219, 0.3);
}

#timer {
    font-size: 1.1em;
    color: #E74C3C;
    font-weight: bold;
    min-width: 100px;
    text-align: center;
}

.btn {
    padding: 10px 25px;
    font-size: 1em;
    background: #3498DB;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: bold;
    white-space: nowrap;
}

.btn:hover {
    background: #2980B9;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(52, 152, 219, 0.4);
}

.btn:active {
    transform: translateY(0);
}

.game-wrapper {
    display: flex;
    justify-content: center;
    margin: 30px 0;
    background: #34495E;
    padding: 20px;
    border-radius: 10px;
}

#mazeCanvas {
    border: 3px solid #2C3E50;
    background: #ECF0F1;
    border-radius: 5px;
    max-width: 100%;
    height: auto;
    display: block;
}

.message {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #2ECC71;
    color: white;
    padding: 40px;
    border-radius: 15px;
    font-size: 2em;
    font-weight: bold;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    z-index: 1000;
    animation: popIn 0.3s ease;
}

.end-screen {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 2000;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.end-content {
    background: white;
    padding: 40px;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    max-width: 500px;
    animation: slideUp 0.4s ease;
}

.end-content h2 {
    color: #2C3E50;
    font-size: 2em;
    margin-bottom: 20px;
}

.end-content h3 {
    color: #2C3E50;
    font-size: 1.3em;
    margin: 20px 0 10px 0;
}

.end-content p {
    color: #34495E;
    font-size: 1.1em;
    margin: 10px 0;
}

.time-display {
    font-size: 1.3em !important;
    color: #E74C3C;
    font-weight: bold;
    margin: 20px 0 !important;
}

.times-table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
    background: #F8F9FA;
    border-radius: 8px;
    overflow: hidden;
}

.times-table th,
.times-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #ECF0F1;
    color: #34495E;
    font-size: 1em;
}

.times-table th {
    background: #3498DB;
    color: white;
    font-weight: bold;
}

.times-table tr:last-child td {
    border-bottom: none;
}

.times-table .total-row {
    background: #E8F5E9;
    font-weight: bold;
}

.times-table .total-row td {
    color: #2E7D32;
}

.btn-large {
    margin-top: 30px;
    padding: 15px 40px;
    font-size: 1.1em;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.instructions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 30px;
}

.instruction-box {
    background: #F8F9FA;
    padding: 20px;
    border-radius: 10px;
    border-left: 4px solid #3498DB;
}

.instruction-box h3 {
    color: #2C3E50;
    margin-bottom: 15px;
    font-size: 1.1em;
}

.instruction-box ul,
.instruction-box ol {
    margin-left: 20px;
    line-height: 1.8;
    color: #34495E;
}

.instruction-box li {
    margin-bottom: 10px;
}

.instruction-box code {
    background: #ECF0F1;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    color: #E74C3C;
}

.instruction-box p {
    margin-bottom: 10px;
    color: #34495E;
}

/* ============================================
   VIRTUAL D-PAD STYLING
   ============================================ */

.dpad-container {
    display: flex;  /* Always visible */
    flex-direction: column;
    align-items: center;
    gap: 5px;
    margin-top: 20px;
    user-select: none;
}

.dpad-middle {
    display: flex;
    gap: 5px;
    justify-content: center;
    align-items: center;
}

.dpad-btn {
    width: 50px;
    height: 50px;
    font-size: 24px;
    border: 2px solid #3498DB;
    background: linear-gradient(135deg, #3498DB 0%, #2980B9 100%);
    color: white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.1s ease;
    font-weight: bold;
    touch-action: manipulation;  /* Prevent double-tap zoom on buttons */
    display: flex;
    align-items: center;
    justify-content: center;
}

.dpad-btn:active {
    transform: scale(0.95);
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.3);
    background: #2980B9;
}

.dpad-btn:hover {
    background: linear-gradient(135deg, #2980B9 0%, #1f618d 100%);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.dpad-btn:disabled {
    background: #95a5a6;
    border-color: #7f8c8d;
    cursor: not-allowed;
    opacity: 0.5;
}

.dpad-btn:disabled:hover {
    background: #95a5a6;
    box-shadow: none;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 20px;
    }

    .header h1 {
        font-size: 1.8em;
    }

    .info {
        flex-direction: column;
        gap: 15px;
    }

    .controls-group {
        width: 100%;
        justify-content: center;
    }

    .controls-group select {
        flex: 1;
        max-width: 300px;
    }

    .instructions {
        grid-template-columns: 1fr;
    }

    .btn {
        width: 100%;
    }

    #timer {
        width: 100%;
    }
}
