:root {
    color-scheme: dark;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #050915;
    color: #edf2fb;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
    background: radial-gradient(circle at top, rgba(56, 86, 178, 0.22), transparent 30%),
        radial-gradient(circle at right bottom, rgba(173, 77, 198, 0.18), transparent 30%),
        #050915;
}

button,
input {
    font: inherit;
}

button {
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 14px;
    padding: 14px 20px;
    cursor: pointer;
    color: white;
    background: linear-gradient(135deg, #5873f9, #7a53f7);
    transition: transform 0.2s ease, filter 0.2s ease, background 0.2s ease;
}

button:hover,
button:focus-visible {
    transform: translateY(-2px);
    filter: brightness(1.08);
    outline: 3px solid rgba(255, 255, 255, 0.35);
    outline-offset: 4px;
}

button:focus {
    outline: 3px solid #84a9ff;
    outline-offset: 3px;
}

.app-shell {
    width: min(1040px, 100%);
    display: grid;
    gap: 18px;
}

.screen {
    display: none;
    justify-content: center;
    align-items: center;
    position: fixed;
    inset: 0;
    overflow-y: auto;
    padding: 20px;
    z-index: 5;
    visibility: hidden;
    pointer-events: none;
}

.screen.active {
    display: grid;
    visibility: visible;
    pointer-events: auto;
}

.panel {
    width: min(760px, 100%);
    padding: 30px 32px;
    background: rgba(10, 18, 34, 0.96);
    border-radius: 26px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.28);
    text-align: center;
}

.welcome-panel h1,
.menu-panel h1 {
    margin: 0;
    font-size: clamp(2rem, 3vw, 2.8rem);
}

.welcome-panel p,
.menu-panel p,
.hint-panel div,
.info-item span {
    color: #b8c4d9;
}

.menu-buttons {
    display: flex;
    justify-content: center;
    gap: 16px;
    flex-wrap: wrap;
    margin-top: 24px;
}

.tutorial-panel .tutorial-text {
    text-align: left;
    line-height: 1.8;
    color: #cbd5e1;
    margin-bottom: 18px;
}

.tutorial-panel .tutorial-text p {
    margin: 12px 0;
}

.game-screen {
    display: grid;
    gap: 16px;
}

.game-header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
    padding: 18px 24px;
    background: rgba(10, 18, 34, 0.94);
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.game-controls {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.game-info {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 16px 24px;
    background: rgba(10, 18, 34, 0.94);
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.info-item {
    padding: 12px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 18px;
    display: grid;
    gap: 6px;
    color: #cbd5e1;
    line-height: 1.5;
}

.arena {
    position: relative;
    background: linear-gradient(180deg, rgba(7, 16, 32, 0.98), rgba(12, 22, 44, 0.99));
    border-radius: 30px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 42px 110px rgba(0, 0, 0, 0.25);
    touch-action: none;
}

.control-buttons {
    display: flex;
    justify-content: center;
    gap: 16px;
    padding: 0 24px 18px;
}

@media (max-width: 760px) {
    .control-buttons {
        display: none;
    }
}

.control-buttons button {
    min-width: 140px;
    padding: 14px 18px;
    font-size: 1rem;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #edf2fb;
    transition: transform 0.15s ease, background 0.15s ease;
}

.control-buttons button:hover,
.control-buttons button:focus-visible {
    background: rgba(255, 255, 255, 0.12);
    transform: translateY(-1px);
}

canvas {
    display: block;
    width: 100%;
    min-height: 520px;
}

.overlay {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(2, 8, 20, 0.65);
    color: #edf2fb;
    font-size: 1.1rem;
    text-align: center;
    backdrop-filter: blur(5px);
}

.hint-panel {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 14px;
    padding: 18px 22px;
    background: rgba(14, 25, 42, 0.92);
    border-radius: 22px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.hint-list {
    display: flex;
    gap: 10px;
}

.hint-list span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.06);
    color: #cbd5e1;
    font-weight: 700;
}

.settings-panel {
    width: min(760px, 100%);
    padding: 30px 32px;
    background: rgba(10, 18, 34, 0.96);
    border-radius: 26px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.28);
    text-align: center;
}

.settings-panel h1 {
    margin-top: 0;
    margin-bottom: 18px;
}

.settings-panel label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
    color: #dbe2ff;
}

.settings-panel input[type='checkbox'] {
    width: 22px;
    height: 22px;
}

#backToMenuBtn {
    width: 100%;
    margin-top: 18px;
    background: #7d5cff;
}

@media (max-width: 760px) {
    .menu-buttons,
    .game-controls,
    .game-info,
    .hint-list {
        flex-direction: column;
        align-items: stretch;
    }

    .game-info {
        grid-template-columns: 1fr;
    }
}
