/* Blaster World — kid-friendly FPS hub */
:root {
    --panel: #fffef7;
    --ink: #2c3e50;
    --accent: #ff6b6b;
    --accent-dark: #e84a4a;
    --font: "Fredoka", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    font-family: var(--font);
    color: var(--ink);
    background: linear-gradient(180deg, #1a3a5c 0%, #2d6a4f 55%, #40916c 100%);
    background-attachment: fixed;
    overflow: hidden;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

#game-container {
    width: min(100vw, 720px);
    margin: 0 auto;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.5rem 0.55rem 0.85rem;
    gap: 0.35rem;
}

header {
    width: 100%;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 0.4rem;
}

.home-link {
    text-decoration: none;
    font-size: 1.35rem;
    padding: 0.25rem 0.4rem;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.55);
}

h1 {
    margin: 0;
    font-size: clamp(1.1rem, 4.2vw, 1.5rem);
    font-weight: 700;
    text-align: center;
    color: #ffe66d;
    text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.25);
}

#stats {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1.25;
    background: rgba(255, 255, 255, 0.55);
    padding: 0.28rem 0.48rem;
    border-radius: 10px;
    white-space: nowrap;
}

#combo { color: #8e44ad; }

main {
    position: relative;
    width: 100%;
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 0;
}

#gameCanvas {
    display: block;
    width: 100%;
    max-width: 640px;
    height: auto;
    max-height: min(58vh, 480px);
    border-radius: 16px;
    border: 4px solid #fff;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.22);
    background: #87ceeb;
    touch-action: none;
    cursor: crosshair;
}

.overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(20, 40, 60, 0.4);
    border-radius: 16px;
    padding: 1rem;
}

.overlay.hidden { display: none; }

.panel {
    background: var(--panel);
    border-radius: 20px;
    padding: 1.3rem 1.15rem;
    max-width: 340px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.22);
    border: 3px solid var(--accent);
}

.panel h2 {
    margin: 0 0 0.55rem;
    font-size: 1.55rem;
    color: var(--accent);
}

.panel p {
    margin: 0 0 0.7rem;
    font-size: 0.98rem;
    line-height: 1.35;
}

.panel .hint {
    font-size: 0.82rem;
    opacity: 0.75;
    margin-bottom: 0.65rem;
}

.diff-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    justify-content: center;
    margin: 0 0 0.45rem;
}

.diff-btn {
    font-family: var(--font);
    font-size: 0.88rem;
    font-weight: 700;
    padding: 0.45rem 0.7rem;
    border: 2px solid #dfe6e9;
    border-radius: 999px;
    background: #f8f9fa;
    color: var(--ink);
    cursor: pointer;
    box-shadow: 0 3px 0 rgba(0, 0, 0, 0.08);
}

.diff-btn:hover { filter: brightness(1.03); }

.diff-btn.is-active {
    border-color: var(--accent);
    background: #ffe8e8;
    color: #c0392b;
    box-shadow: 0 3px 0 var(--accent-dark);
}

.diff-btn[data-diff="easy"].is-active {
    border-color: #27ae60;
    background: #e8f8ef;
    color: #1e8449;
    box-shadow: 0 3px 0 #1e8449;
}

.diff-btn[data-diff="medium"].is-active {
    border-color: #f39c12;
    background: #fff6e5;
    color: #b9770e;
    box-shadow: 0 3px 0 #b9770e;
}

.diff-btn[data-diff="hard"].is-active {
    border-color: #e74c3c;
    background: #fdecea;
    color: #c0392b;
    box-shadow: 0 3px 0 #c0392b;
}

.diff-btn:active { transform: translateY(2px); box-shadow: none; }

.diff-blurb {
    font-size: 0.8rem !important;
    font-weight: 600;
    opacity: 0.8;
    margin-bottom: 0.85rem !important;
    min-height: 1.2em;
}

#start-btn {
    font-family: var(--font);
    font-size: 1.2rem;
    font-weight: 700;
    padding: 0.65rem 1.9rem;
    border: none;
    border-radius: 999px;
    background: var(--accent);
    color: white;
    cursor: pointer;
    box-shadow: 0 5px 0 var(--accent-dark);
}

#start-btn:active {
    transform: translateY(4px);
    box-shadow: 0 1px 0 var(--accent-dark);
}

#diff-stat { color: #1e8449; }

.hud {
    position: absolute;
    inset: 0;
    pointer-events: none;
    border-radius: 16px;
}

.hud.hidden { display: none; }

.crosshair {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 22px;
    height: 22px;
    margin: -11px 0 0 -11px;
    border: 2px solid rgba(255, 255, 255, 0.95);
    border-radius: 50%;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25), inset 0 0 0 1px rgba(0, 0, 0, 0.15);
}

.crosshair::before,
.crosshair::after {
    content: "";
    position: absolute;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2);
}

.crosshair::before {
    left: 50%;
    top: -6px;
    width: 2px;
    height: 34px;
    margin-left: -1px;
}

.crosshair::after {
    top: 50%;
    left: -6px;
    height: 2px;
    width: 34px;
    margin-top: -1px;
}

.float-msg {
    position: absolute;
    left: 50%;
    top: 18%;
    transform: translateX(-50%);
    font-weight: 700;
    font-size: 1.15rem;
    color: #fff;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
    opacity: 0;
    transition: opacity 0.15s;
    white-space: nowrap;
}

.float-msg.show { opacity: 1; }

.bottom-bar {
    width: 100%;
    max-width: 640px;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding: 0.15rem 0.35rem 0;
    align-items: center;
}

.tip {
    margin: 0;
    font-size: 0.78rem;
    font-weight: 600;
    opacity: 0.8;
    text-align: center;
    color: #f8f9fa;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.touch-pad {
    display: none;
    width: 100%;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.15rem 0;
}

.stick-zone {
    position: relative;
    width: 96px;
    height: 96px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.28);
    border: 2px solid rgba(255, 255, 255, 0.55);
    touch-action: none;
    flex-shrink: 0;
}

.stick-knob {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.85);
    box-shadow: 0 3px 0 rgba(0, 0, 0, 0.12);
    pointer-events: none;
}

.stick-label {
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1.15rem;
    text-align: center;
    font-size: 0.68rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

#fire-btn {
    font-family: var(--font);
    font-size: 1.7rem;
    width: 76px;
    height: 76px;
    border: none;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    cursor: pointer;
    box-shadow: 0 5px 0 var(--accent-dark);
    flex-shrink: 0;
}

#fire-btn:active {
    transform: translateY(4px);
    box-shadow: 0 1px 0 var(--accent-dark);
}

#done-btn {
    font-family: var(--font);
    font-size: 1rem;
    font-weight: 700;
    padding: 0.6rem 1rem;
    border: none;
    border-radius: 999px;
    background: #9b59b6;
    color: white;
    cursor: pointer;
    box-shadow: 0 4px 0 #8e44ad;
    width: 100%;
}

#done-btn:active {
    transform: translateY(3px);
    box-shadow: 0 1px 0 #8e44ad;
}

@media (hover: none), (max-width: 820px) {
    .touch-pad { display: flex; }
    #gameCanvas { max-height: min(48vh, 420px); }
}

@media (max-height: 700px) {
    h1 { font-size: 1.05rem; }
    #stats { font-size: 0.65rem; }
    .stick-zone { width: 84px; height: 84px; }
    #fire-btn { width: 68px; height: 68px; font-size: 1.45rem; }
}
