:root {
    --bg-color: #202028;
    --ui-color: #333340;
    --text-color: #ffffff;
    --accent-color: #f0f0f0;
}

* {
    box-sizing: border-box;
    touch-action: none;
    user-select: none;
}

body {
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
}

#game-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    height: 100%;
    max-width: 500px;
}

#ui-header {
    display: flex;
    justify-content: space-between;
    width: 100%;
    padding: 10px 20px;
    background-color: var(--ui-color);
    border-bottom: 2px solid #000;
    flex: 0 0 auto;
    border-radius: 0px 0px 20px 20px;
}

.stat-box {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.label {
    font-size: 0.8rem;
    color: #aaa;
}

#score, #level {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--accent-color);
}

#canvas-wrapper {
    position: relative;
    margin-top: 50px;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 0;
    padding: 10px;
}

#game-canvas {
    background-color: #000;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    border: 1px solid #444;
    display: block;

    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    aspect-ratio: 7 / 17;
    image-rendering: pixelated;
}

#options-panel {
    margin-top: 12px;
    display: flex;
    gap: 18px;
    align-items: center;
    color: var(--accent-color);
    font-size: 0.95rem;
}

.option-item {
    display: flex;
    gap: 8px;
    align-items: center;
}

#vibration-option {
    display: none;
}

#mobile-controls {
    display: none;
    width: 100%;
    padding: 10px 20px;
    justify-content: space-between;
    flex: 0 0 auto;
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    top: 50vh;
    max-width: 520px;
    z-index: 5;
}

.controls-left, .controls-right {
    display: flex;
    flex-direction: column;
    gap: 30px;
    align-items: center;
    justify-content: center;
}

.controls-left {
    align-items: flex-start;
}
.controls-right {
    align-items: flex-end;
}

.control-btn {
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    color: white;
    font-size: 24px;
    cursor: pointer;
    outline: none;
    display: flex;
    justify-content: center;
    align-items: center;
    -webkit-tap-highlight-color: transparent;
}

.control-btn:active {
    background: rgba(255, 255, 255, 0.3);
}

#controls-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: flex;
    justify-content: center;
    align-items: center;
}

#game-over-screen {
    pointer-events: auto;
    background: rgba(0, 0, 0, 1);
    padding: 30px;
    border-radius: 10px;
    text-align: center;
    border: 2px solid #fff;
    z-index: 10;
}

#save-record {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 12px 0 6px;
}

#save-record label {
    font-size: 0.95rem;
    color: #ccc;
}

#save-record input {
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #555;
    background: #111;
    color: #fff;
}

#save-record-status {
    min-height: 18px;
    margin: 0;
}

.muted {
    color: #a5a5b0;
    font-size: 0.9rem;
}

#records-panel {
    margin-top: 12px;
    text-align: left;
}

#records-panel h2 {
    margin: 0 0 8px;
    font-size: 1rem;
    text-align: center;
}

#records-panel ol {
    margin: 0;
    padding-left: 20px;
    max-height: 200px;
    overflow-y: auto;
}

#records-panel li {
    margin-bottom: 6px;
    color: #f0f0f0;
}

.hidden {
    display: none !important;
}

#restart-btn,
#save-record-btn {
    padding: 10px 20px;
    font-size: 1.05rem;
    cursor: pointer;
    border: none;
    border-radius: 8px;
    width: 100%;
    margin-top: 8px;
}

#restart-btn {
    background: #4CAF50;
    color: white;
}

#save-record-btn {
    background: #3498db;
    color: white;
}

@media (hover: none) and (pointer: coarse) {
    #mobile-controls {
        display: flex;
    }

    #vibration-option {
        display: flex;
    }
}

@media screen and (max-height: 700px) {
    #ui-header {
        padding: 5px 10px;
    }
    .control-btn {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
}
