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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.container {
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    text-align: center;
    max-width: 500px;
    width: 90%;
}

.header {
    margin-bottom: 20px;
}

h1 {
    color: #333;
    margin-bottom: 15px;
    font-size: 2.5em;
}

.stats {
    display: flex;
    justify-content: space-around;
    gap: 20px;
    margin-bottom: 20px;
}

.stat {
    background: #f0f0f0;
    padding: 10px 20px;
    border-radius: 10px;
    flex: 1;
}

.stat .label {
    display: block;
    color: #666;
    font-size: 0.9em;
    margin-bottom: 5px;
}

.stat .value {
    display: block;
    color: #667eea;
    font-size: 1.8em;
    font-weight: bold;
}

#gameCanvas {
    border: 3px solid #333;
    background: #000;
    display: block;
    margin: 20px auto;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    max-width: 100%;
    height: auto;
}

.controls {
    display: flex;
    gap: 10px;
    margin: 20px 0;
    justify-content: center;
    flex-wrap: wrap;
    align-items: center;
}

.color-control {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f0f0f0;
    padding: 10px 14px;
    border-radius: 10px;
}

.color-control label {
    color: #333;
    font-size: 0.95em;
}

.color-control input {
    width: 40px;
    height: 40px;
    padding: 0;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}

.battle-info {
    display: grid;
    gap: 10px;
    margin-top: 16px;
    text-align: left;
}

.battle-stat {
    background: #f0f0f0;
    border-radius: 12px;
    padding: 10px 14px;
}

.enemy-list {
    display: grid;
    gap: 8px;
}

.enemy-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fafafa;
    border-radius: 10px;
    padding: 10px 12px;
    color: #333;
}

.enemy-color {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 0 1px rgba(0,0,0,.1);
}

.btn {
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #e0e0e0;
    color: #333;
}

.btn-secondary:hover:not(:disabled) {
    background: #d0d0d0;
    transform: translateY(-2px);
}

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

.instructions {
    background: #f9f9f9;
    padding: 15px;
    border-radius: 10px;
    text-align: left;
    margin-top: 20px;
}

.instructions h3 {
    color: #333;
    margin-bottom: 10px;
    font-size: 1.1em;
}

.instructions ul {
    list-style: none;
    padding: 0;
}

.instructions li {
    color: #666;
    padding: 5px 0;
    font-size: 0.95em;
}

.instructions strong {
    color: #667eea;
}

@media (max-width: 480px) {
    .container {
        padding: 20px;
    }

    h1 {
        font-size: 1.8em;
    }

    #gameCanvas {
        width: 100%;
        max-width: 100%;
    }

    .controls {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }
}

/* Touch controls styling */
.touch-controls {
    display: none;
    margin: 14px auto 0;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.touch-row {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.touch-btn {
    width: 64px;
    height: 64px;
    border-radius: 12px;
    border: none;
    font-size: 1.4rem;
    background: rgba(0,0,0,0.7);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 18px rgba(0,0,0,0.25);
    -webkit-tap-highlight-color: transparent;
}

.touch-btn:active {
    transform: translateY(2px);
    opacity: 0.95;
}

@media (max-width: 640px) {
    /* Hide the on-screen arrow buttons; tapping the canvas controls movement */
    .touch-controls { display: none; }
    .container { padding-bottom: 24px; }
    #gameCanvas { width: 100%; height: auto; }
}
