body,
html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #1a1a1a;
    font-family: 'Courier New', Courier, monospace;
    user-select: none;
}

#game-container {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    background-color: #000;
}

#game-container canvas {
    display: block;
    width: 100%;
    height: 100%;
    image-rendering: -moz-crisp-edges;
    image-rendering: -webkit-crisp-edges;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    /* Permette di cliccare attraverso l'UI sul gioco */
}

#timer {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 48px;
    font-weight: bold;
    color: #fff;
    text-shadow: 2px 2px 0 #000;
}

#best-time {
    position: absolute;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 24px;
    color: #ffd700;
    /* Oro */
    text-shadow: 1px 1px 0 #000;
}

#controls-hint {
    position: absolute;
    bottom: 20px;
    width: 100%;
    text-align: center;
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
    pointer-events: auto;
}

#message {
    position: absolute;
    top: 30%;
    width: 100%;
    text-align: center;
    font-size: 40px;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 0 10px #000;
    display: none;
}

button {
    background: #ff4444;
    border: none;
    color: white;
    padding: 5px 10px;
    cursor: pointer;
    font-family: inherit;
    font-weight: bold;
    pointer-events: auto;
}

button:hover {
    background: #ff0000;
}

#countdown {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 120px;
    font-weight: 900;
    color: #fff;
    text-shadow: 0 0 20px #ff0000;
    font-style: italic;
    display: none;
    z-index: 100;
}

.respawn-overlay {
    background-color: rgba(255, 0, 0, 0.3);
}

/* --- MENU SYSTEM --- */
.menu-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #1a1a1a;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    z-index: 2000;
    overflow-y: auto;
}

.menu-overlay h2 {
    color: white;
}

.game-title {
    font-size: min(80px, 15vh);
    color: #fff;
    font-style: italic;
    text-shadow: 4px 4px 0 #ff4444;
    margin-bottom: 20px;
}

.game-title span {
    font-size: min(20px, 4vh);
    color: #888;
    text-shadow: none;
    font-style: normal;
}

.menu-screen {
    display: flex;
    flex-direction: column;
    gap: min(15px, 2.5vh);
    width: 100%;
    max-width: 700px;
    align-items: center;
}

.menu-screen::after {
    content: "";
    min-height: 20px;
}

.menu-btn {
    width: 100%;
    padding: min(15px, 2vh);
    font-size: min(24px, 5vh);
    background: #333;
    border: 2px solid #555;
    color: #fff;
    text-transform: uppercase;
    transition: all 0.2s;
}

.menu-btn:focus {
    background: #fff;
    color: #000;
    transform: scale(1.05);
    outline: 3px solid #00ff00;
}

.menu-btn:hover {
    background: #fff;
    color: #000;
    transform: scale(1.05);
}

.menu-btn.primary {
    background: #00aa00;
    border-color: #00ff00;
}

.menu-btn.secondary {
    background: #555;
}

.menu-btn.danger {
    background: #aa0000;
    border-color: #ff0000;
}

#seed-input {
    width: 100%;
    padding: min(15px, 2vh);
    font-size: min(30px, 6vh);
    text-align: center;
    background: #222;
    border: 2px solid #fff;
    color: #ffd700;
    font-family: 'Courier New', Courier, monospace;
    font-weight: bold;
    text-transform: uppercase;
}

.btn-row {
    display: flex;
    gap: 10px;
    width: 100%;
}

/* Lista Record */
#records-list {
    width: 100%;
    height: 300px;
    overflow-y: auto;
    background: #222;
    border: 1px solid #444;
    margin-bottom: 20px;
}
.record-item {
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    border-bottom: 1px solid #333;
    color: #eee;
    font-size: 14px;
}
.record-item:hover {
    background: #333;
}
.record-meta {
    display: flex;
    flex-direction: column;
    text-align: left;
}
.record-seed {
    color: #fff;
    font-weight: bold;
    font-size: 18px;
}
.record-time {
    color: #ffd700;
    font-weight: bold;
    font-size: 20px;
}
.record-actions button {
    font-size: 12px;
    padding: 5px;
    margin-left: 5px;
    width: auto;
}
.record-item.outdated {
    opacity: 0.5;
    background: #1a1a1a;
    border-bottom: 1px solid #333;
}
.record-item.outdated .record-time {
    color: #888;
}
.record-item.outdated .record-seed {
    color: #888;
}
.record-item:active {
    background: #444;
}
.record-desc {
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 2px;
}
.record-seed.has-desc {
    font-size: 12px;
    color: #eee;
}
.edit-desc-btn {
    background: #555;
}
.edit-desc-btn:hover { background: #777; }
.selection-item {
    display: flex;
    align-items: center;
    padding: 10px;
    border-bottom: 1px solid #333;
    gap: 15px;
}
.selection-item.outdated {
    opacity: 0.5;
    background: #1a1a1a;
    border-bottom: 1px solid #333;
}
.selection-item input[type="checkbox"] {
    width: 25px;
    height: 25px;
    cursor: pointer;
}
.record-item.imported-record {
    border-left: 4px solid #00aaff;
    background: linear-gradient(90deg, rgba(0,170,255,0.1) 0%, rgba(0,0,0,0) 100%);
}
.imported-tag {
    font-size: 12px;
    color: #00aaff;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 2px;
    display: inline-block;
}
.btn-share {
    background: #00aaff;
}
.btn-share:hover {
    background: #0088cc;
}

#pause-modal {
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(5px);
}
.paused-box {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
    max-width: 80%;
    width: fit-content;
    align-items: center;
    background: transparent;
    padding: 40px;
}

/* --- SETTINGS UI --- */
.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    background: rgba(255, 255, 255, 0.1);
    padding: 10px;
    box-sizing: border-box;
}

.setting-row span {
    color: white;
}

.setting-row label {
    color: #fff;
    font-size: 18px;
}

.scrollable-menu {
    max-height: 400px;
    overflow-y: auto;
    width: 100%;
    padding-right: 5px;
}

/* Key Binding UI */
.bind-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-bottom: 5px;
    border-bottom: 1px solid #333;
    padding: 5px 0;
}

.bind-label {
    font-size: 16px;
    color: #ccc;
}

.bind-btn {
    background: #333;
    border: 1px solid #555;
    color: #fff;
    padding: 5px 10px;
    min-width: 80px;
    font-family: 'Courier New';
    font-size: 14px;
}

.bind-btn:hover {
    background: #555;
}

.bind-btn.empty {
    color: #555;
    font-style: italic;
}

/* --- TOUCH CONTROLS --- */
#touch-controls {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
}

.touch-zone {
    position: absolute;
    bottom: 20px;
    display: flex;
    gap: 20px;
    pointer-events: auto;
    /* I pulsanti ricevono input */
}

#touch-left {
    left: 20px;
}

#touch-right {
    right: 20px;
}

.touch-btn {
    position: absolute;
    width: 15vh;
    height: 15vh;
    background: rgba(255, 255, 255, 0.2);
    border: 0.5vh solid rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    color: white;
    font-size: 6vh;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    touch-action: none;
    z-index: 3000;
    margin: 0;
    box-sizing: border-box;
}

.touch-btn.small {
    width: 10vh;
    height: 10vh;
    font-size: 4vh;
}

.touch-btn:active {
    background: rgba(255, 255, 255, 0.5);
}

.touch-btn.is-pressed {
    background: rgba(255, 0, 0, 0.6) !important;
    border-color: #ff0000 !important;
}

/* Touch Editor */
#touch-editor-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 2500;
    display: flex;
    justify-content: center;
    align-items: center;
}

.editor-msg {
    position: absolute;
    top: 20px;
    color: #0f0;
    font-size: 24px;
    font-weight: bold;
    text-align: center;
}

.editable-btn {
    z-index: 3001;
    border: 2px dashed #ffff00;
    background: rgba(255, 0, 0, 0.5);
}

.touch-btn.selected-btn {
    border-color: #00ff00;
    box-shadow: 0 0 15px #00ff00;
    background: rgba(0, 255, 0, 0.3);
}

/* Input Colore Custom */
input[type="color"] {
    border: none;
    width: 50px;
    height: 40px;
    background: none;
    cursor: pointer;
}

input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

input[type="color"]::-webkit-color-swatch {
    border: 2px solid #fff;
    border-radius: 4px;
}

/* Language Selector */
.lang-select-btn {
    width: 150px;
    height: 150px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-size: 18px;
}
#btn-lang-main {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

/* Changelog Styles */
#changelog-content h3 {
    color: #ffd700;
    margin-top: 0;
    border-bottom: 1px solid #444;
    padding-bottom: 5px;
}
#changelog-content ul {
    margin-top: 5px;
    margin-bottom: 20px;
    padding-left: 20px;
}
#changelog-content li {
    margin-bottom: 5px;
}
