:root {
    --bg-deep: #083220;
    --bg-mid: #0f5f37;
    --grain: rgba(248, 216, 149, 0.18);
    --panel: #faebc8;
    --panel-soft: #f4dfaf;
    --panel-line: #bf8b4e;
    --header: #cb9634;
    --header-shadow: #8e5c2a;
    --ink: #2f170a;
}

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

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
}

body {
    background:
        radial-gradient(circle at 20% 20%, rgba(255, 216, 143, 0.16), transparent 35%),
        radial-gradient(circle at 80% 0%, rgba(116, 227, 155, 0.14), transparent 32%),
        linear-gradient(165deg, var(--bg-mid) 0%, var(--bg-deep) 100%);
    font-family: "Trebuchet MS", "Franklin Gothic Medium", "Segoe UI", sans-serif;
    color: var(--ink);
}

.game-container {
    width: 100vw;
    height: 100vh;
    display: grid;
    grid-template-rows: auto 1fr auto;
    background:
        radial-gradient(circle at 0 0, var(--grain) 2px, transparent 2px),
        var(--panel);
    background-size: 28px 28px, auto;
    border-top: 6px solid #f9cf7a;
    border-bottom: 8px solid #8d5727;
    box-shadow: inset 0 0 0 2px #f7d48d;
}

.farm-header {
    background: var(--header);
    border-bottom: 5px solid var(--header-shadow);
    box-shadow: inset 0 -2px 0 #f3ca76;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

h1 {
    margin: 0;
    color: #fff3cf;
    font-size: clamp(1.25rem, 1.9vw, 2rem);
    letter-spacing: 1px;
    text-transform: uppercase;
    text-shadow: 3px 3px 0 #6f3d12;
    font-weight: 900;
}

.top-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.coin-purse {
    background: #312115;
    color: #ffd470;
    border: 2px solid #644327;
    border-radius: 999px;
    padding: 8px 14px;
    min-width: 120px;
    text-align: center;
    font-weight: 900;
    font-size: 1rem;
    box-shadow: inset 0 1px 2px rgba(255, 222, 153, 0.45), 0 3px 0 #1f1209;
}

.field-label {
    font-size: 0.8rem;
    font-weight: 900;
    color: #55311a;
    text-transform: uppercase;
}

.field-input {
    width: 100%;
    border: 2px solid #c89957;
    border-radius: 12px;
    padding: 9px 11px;
    font-size: 0.95rem;
    background: #fff8e9;
    color: #321b0b;
    font-family: inherit;
}

.arena-wrap {
    min-height: 0;
    min-width: 0;
    padding: 10px;
    display: grid;
}

#gameCanvas {
    width: 100%;
    height: 100%;
    border: 2px solid #9e6a33;
    border-radius: 12px;
    background: linear-gradient(to bottom, #bdefff 0%, #9ce072 36%, #72c24b 100%);
    image-rendering: pixelated;
}

.care-btn,
.danger-btn {
    border-radius: 999px;
    padding: 9px 14px;
    border: none;
    font-family: inherit;
    font-weight: 900;
    letter-spacing: 0.3px;
    cursor: pointer;
}

.care-btn {
    color: #fff;
    background: #4d8a34;
    box-shadow: 0 3px 0 #2a531a;
}

.care-btn:active {
    transform: translateY(1px);
    box-shadow: 0 1px 0 #2a531a;
}

.danger-btn {
    color: #fff;
    background: #a73923;
    box-shadow: 0 3px 0 #5f1f12;
}

.status-bar {
    min-height: 34px;
    padding: 7px 16px;
    background: #3d2410;
    color: #ffe6b0;
    font-weight: 900;
    border-top: 3px solid #6f441f;
    display: flex;
    align-items: center;
}

.login-overlay {
    position: fixed;
    inset: 0;
    background: rgba(17, 12, 6, 0.62);
    display: grid;
    place-items: center;
    padding: 16px;
    z-index: 20;
}

.login-overlay.hidden {
    display: none;
}

.login-card {
    width: min(520px, 96vw);
    background: linear-gradient(160deg, #f7e6bb 0%, #efd6a0 100%);
    border: 3px solid #b17a3d;
    border-radius: 22px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 247, 223, 0.75);
    padding: 22px;
    display: grid;
    gap: 8px;
}

.login-card h2 {
    margin: 0 0 2px;
    text-transform: uppercase;
    color: #39210d;
}

.login-card p {
    margin: 0 0 10px;
    color: #684022;
    font-weight: 700;
}

.login-btn {
    margin-top: 10px;
    width: 100%;
    font-size: 1rem;
}

@media (max-width: 1100px) {
    .farm-header {
        padding: 10px 12px;
    }
}
