.agreement-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    overflow: auto;
    display: flex;
    padding: max(20px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
    box-sizing: border-box;
    background: radial-gradient(ellipse at top, #263b32, #111820 70%);
    touch-action: auto;
    user-select: text;
    -webkit-user-select: text;
    font: 16px/1.5 Arial, sans-serif;
    color: #e6e8df;
}
.agreement-panel { margin: auto; width: min(100%, 580px); padding: clamp(18px, 4vw, 32px); box-sizing: border-box; border: 2px solid #8d946e; border-radius: 12px; background: #17211b; box-shadow: 0 18px 60px #0008; }
.agreement-brand { font: 12px/1.8 'Press Start 2P', monospace; color: #d5b778; margin: 0 0 18px; }
.agreement-panel h1 { color: #f3d985; font-size: clamp(26px, 5vw, 34px); line-height: 1.2; margin: 0; }
.agreement-panel p { margin: 14px 0; }
.agreement-documents { display: grid; gap: 10px; }
.agreement-documents a, .agreement-documents span { display: block; padding: 13px 15px; border: 1px solid #849379; border-radius: 5px; background: #24352c; color: #f3d985; font-weight: bold; overflow-wrap: anywhere; }
.agreement-documents a:hover { background: #344a3d; }
.agreement-hint { color: #c0c9be; font-size: 13px; }
.agreement-check { display: flex; align-items: flex-start; gap: 12px; padding: 10px 0; cursor: pointer; }
.agreement-check input { flex: 0 0 22px; width: 22px; height: 22px; margin: 2px 0 0; accent-color: #78b794; }
.agreement-panel button { width: 100%; min-height: 48px; padding: 12px; border-radius: 5px; font: bold 14px/1.5 Arial, sans-serif; cursor: pointer; }
.agreement-accept { border: 1px solid #8cb89b; background: #39725e; color: white; }
.agreement-accept:disabled { cursor: default; opacity: .45; }
.agreement-decline { margin-top: 10px; border: 1px solid #798372; background: transparent; color: #e6e8df; }
.agreement-status { color: #f3d985; font-size: 14px; }
.agreement-panel :focus-visible { outline: 3px solid #f3d985; outline-offset: 3px; }

html,
body,
#app,
#game-container {
    box-sizing: border-box;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
}

html,
body {
    overflow: hidden;
    background: #080b0e;
    overscroll-behavior: none;
}

body {
    color: white;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

#app,
#game-container {
    display: flex;
    justify-content: center;
    align-items: center;
}

canvas {
    display: block;
    touch-action: none;
}

/* Keep the desktop battlefield manageable without scaling down text or controls. */
@media (hover: hover) and (pointer: fine) and (min-width: 1100px) and (min-height: 760px) {
    #game-container {
        flex: none;
        width: min(80vw, 1440px);
        height: min(90vh, 960px);
        box-shadow: 0 0 0 2px #304139, 0 12px 48px #0008;
    }
}

/* Touch devices: a black border keeps the game inside the safe area (notches,
   cutouts, system bars). Capacitor injects --safe-area-inset-* on Android WebViews
   that report env() as zero; the larger value wins. */
@media (hover: none) and (pointer: coarse) {
    html,
    body,
    #app {
        background: #000;
    }
    #app {
        position: fixed;
        inset: 0;
        padding:
            max(env(safe-area-inset-top), var(--safe-area-inset-top, 0px))
            max(env(safe-area-inset-right), var(--safe-area-inset-right, 0px))
            max(env(safe-area-inset-bottom), var(--safe-area-inset-bottom, 0px))
            max(env(safe-area-inset-left), var(--safe-area-inset-left, 0px));
    }
}

.account-overlay { position:fixed; inset:0; z-index:2147483647; display:flex; align-items:center; justify-content:center; padding:max(20px,env(safe-area-inset-top)) 20px max(20px,env(safe-area-inset-bottom)); box-sizing:border-box; background:rgba(3,5,7,.72); overflow:auto; touch-action:auto; user-select:text; }
.account-panel { width:min(430px,100%); padding:22px; box-sizing:border-box; border:3px solid #d5b778; border-radius:10px; background:#17212a; color:#fff; font-family:Arial,sans-serif; box-shadow:0 12px 50px #000; }
.account-panel h1 { margin:0 0 18px; text-align:center; font:22px "Arial Black",Arial,sans-serif; color:#f3d985; }
.account-panel label { display:block; margin:12px 0; font-weight:bold; font-size:13px; color:#c8d1d5; }
.account-panel input:not([type=checkbox]) { display:block; width:100%; margin-top:6px; padding:11px; box-sizing:border-box; border:2px solid #82907d; border-radius:5px; font-size:18px; background:#f5f1e5; color:#101417; }
.account-panel .password-label { margin-bottom:0; }
.password-row { display:grid; grid-template-columns:minmax(0,1fr) 76px; gap:7px; margin-top:6px; }
.account-panel .password-row input { min-width:0; min-height:48px; margin-top:0; }
.password-row input::-ms-reveal { display:none; }
.account-panel .password-row .reveal { min-height:48px; padding:0 8px; background:#384f60; }
.account-panel :focus-visible { outline:3px solid #f3d985; outline-offset:3px; }
.account-panel button { cursor:pointer; border:0; border-radius:5px; color:white; font:bold 14px "Arial Black",Arial,sans-serif; }
.account-primary,.account-secondary { display:block; width:100%; padding:13px; margin-top:10px; background:#39725e; }
.account-secondary { background:#384f60; }
.account-link { display:block; margin:14px auto 0; padding:5px; background:transparent; color:#b9c7cc!important; text-decoration:underline; }
.remember { display:flex!important; align-items:center; gap:8px; }
.remember input { width:20px; height:20px; }
.account-error { min-height:30px; color:#ef9b91; text-align:center; font-weight:bold; font-size:13px; }
.conflict-panel p { text-align:center; line-height:1.4; }
.save-card { display:flex; flex-direction:column; width:100%; margin:12px 0; padding:14px; gap:7px; text-align:left; background:#263846; border:2px solid #82907d!important; }
.save-card strong { color:#f3d985; font-size:17px; }.save-card span { font-size:18px; }.save-card small { line-height:1.5; color:#d7dfe2; }.save-card b { align-self:center; margin-top:3px; color:#9fd7a9; }
