/* ===== RESET & BASE ===== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --green-dark: #2d6a2d;
    --green-mid: #3a8a3a;
    --green-light: #4caf50;
    --cream: #f5f0e8;
    --brown: #8b5e3c;
    --brown-dark: #5a3a1a;
    --text: #1a1a1a;
    --shadow: rgba(0, 0, 0, .35);
    --gold: #f0c040;
}

html,
body {
    height: 100%;
    font-family: 'Segoe UI', system-ui, sans-serif;
    background: var(--green-dark);
    color: var(--cream);
    overflow: hidden;
}

/* ===== SCREENS ===== */
.screen {
    display: none;
    position: fixed;
    inset: 0;
    align-items: center;
    justify-content: center;
}

.screen.active {
    display: flex;
}

/* ===== MENU BOX ===== */
.menu-box {
    background: linear-gradient(160deg, #3d2b1f, #5a3a1a);
    border: 3px solid var(--brown);
    border-radius: 18px;
    padding: 2.4rem 3rem;
    min-width: 340px;
    max-width: 480px;
    width: 90%;
    box-shadow: 0 8px 40px var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    align-items: center;
    text-align: center;
}

.menu-box.wide {
    max-width: 700px;
}

h1 {
    font-size: 2.2rem;
    letter-spacing: .04em;
}

h2 {
    font-size: 1.7rem;
}

.subtitle {
    color: #c8b99a;
    font-size: .95rem;
}

/* ===== SETTINGS ===== */
.settings {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: .8rem;
    text-align: left;
}

.settings label {
    display: flex;
    flex-direction: column;
    gap: .3rem;
    font-size: .9rem;
    color: #c8b99a;
}

.settings .checkbox-label {
    flex-direction: row;
    align-items: center;
    gap: .55rem;
    color: var(--cream);
    cursor: pointer;
}

.settings .checkbox-label input[type="checkbox"] {
    accent-color: var(--green-light);
    width: 16px;
    height: 16px;
    flex: 0 0 auto;
}

.settings select,
.settings input[type="text"] {
    padding: .45rem .8rem;
    border-radius: 8px;
    border: 2px solid var(--brown);
    background: #2a1a0e;
    color: var(--cream);
    font-size: 1rem;
    outline: none;
    transition: border-color .2s;
}

.settings select:focus,
.settings input[type="text"]:focus {
    border-color: var(--green-light);
}

.radio-group {
    display: flex;
    gap: .8rem;
    flex-wrap: wrap;
}

.radio-label {
    display: flex;
    flex-direction: row !important;
    align-items: center;
    gap: .35rem;
    font-size: .9rem;
    color: var(--cream);
    cursor: pointer;
    padding: .35rem .7rem;
    border: 2px solid var(--brown);
    border-radius: 8px;
    background: #2a1a0e;
    transition: border-color .2s, background .2s;
}

.radio-label:has(input:checked) {
    border-color: var(--green-light);
    background: rgba(76, 175, 80, .15);
}

.radio-label input[type="radio"] {
    accent-color: var(--green-light);
    width: 15px;
    height: 15px;
}

/* ===== BUTTONS ===== */
.btn-primary,
.btn-secondary {
    padding: .7rem 2rem;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform .1s, filter .2s;
    width: 100%;
}

.btn-primary {
    background: var(--green-light);
    color: #fff;
}

.btn-secondary {
    background: var(--brown);
    color: var(--cream);
}

.btn-primary:hover {
    filter: brightness(1.15);
    transform: translateY(-2px);
}

.btn-secondary:hover {
    filter: brightness(1.2);
    transform: translateY(-2px);
}

.btn-primary:active,
.btn-secondary:active {
    transform: translateY(0);
}

.credits {
    width: 100%;
    margin-top: .2rem;
    padding-top: .7rem;
    border-top: 1px solid rgba(255, 255, 255, .15);
    font-size: .85rem;
    color: #c8b99a;
    line-height: 1.5;
}

.credits strong {
    color: #e8dcc7;
}

.credits a {
    color: #f0c040;
    text-decoration: none;
}

.credits a:hover,
.credits a:focus-visible {
    text-decoration: underline;
}

/* ===== HUD ===== */
#hud {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    gap: 2.5rem;
    padding: .55rem 1rem;
    background: rgba(26, 10, 0, .72);
    backdrop-filter: blur(4px);
    border-bottom: 2px solid var(--brown-dark);
    z-index: 10;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: .02em;
}

.hud-item {
    color: var(--cream);
}

/* ===== CANVAS ===== */
#game-canvas {
    display: block;
    /* touch-action: none zabrání scrollování a zoom na dotykových zařízeních */
    touch-action: none;
    /* cursor se nastavuje dynamicky přes JS podle zvoleného ovládání */
    image-rendering: pixelated;
}

/* ===== LEADERBOARD TABLE ===== */
#leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .9rem;
}

#leaderboard-table th {
    background: var(--brown-dark);
    padding: .5rem .7rem;
    text-align: left;
    color: var(--gold);
}

#leaderboard-table td {
    padding: .45rem .7rem;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}

#leaderboard-table tr:nth-child(even) td {
    background: rgba(255, 255, 255, .04);
}

#leaderboard-table tr:first-child td {
    color: var(--gold);
    font-weight: 700;
}

/* ===== RESULT STATS ===== */
#result-stats {
    background: rgba(0, 0, 0, .25);
    border-radius: 10px;
    padding: 1rem 1.4rem;
    width: 100%;
    font-size: 1rem;
    line-height: 2;
    text-align: left;
}

#result-stats strong {
    color: var(--gold);
}

.status-message {
    width: 100%;
    min-height: 1.4rem;
    font-size: .92rem;
    line-height: 1.4;
}

.status-message.is-success {
    color: #cdecc5;
}

.status-message.is-error {
    color: #ffb9b9;
}