* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --frame-bottom: 0px;
    --frame-left: 0px;
    --frame-right: 0px;
    --accent: #1d4ed8;
}

html, body {
    height: 100%;
}

/* Inside the site iframe a fixed footer bar (~40px, "Etusivu / Tietoa pelistä") covers the bottom.
   The site hides that bar when height <= 400px. */
html.in-frame { --frame-bottom: 44px; }
@media (max-height: 400px) {
    html.in-frame { --frame-bottom: 0px; }
}

body {
    font-family: 'Arial', sans-serif;
    background: #0b1220;
    color: #fff;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

#app {
    position: relative;
    width: 100%;
    max-width: 100%;
    height: calc(100vh - var(--frame-bottom));
    height: calc(100dvh - var(--frame-bottom));
    margin: 0 auto;
}

.screen {
    display: none;
    position: absolute;
    inset: 0 var(--frame-right) 0 var(--frame-left);
    flex-direction: column;
    align-items: center;
}

.screen.active {
    display: flex;
}

/* ---------- Start screen ---------- */
#start-screen {
    justify-content: center;
    padding: 20px;
    text-align: center;
    background: linear-gradient(180deg, #0b1220 0%, #1e3a8a 60%, #3b82f6 100%);
}

.logo svg { display: block; margin: 0 auto 6px; filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.4)); }

#start-screen h1 {
    font-size: 40px;
    letter-spacing: 2px;
    margin-bottom: 12px;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.4);
}

#start-screen .desc {
    font-size: 17px;
    line-height: 1.5;
    max-width: 340px;
    margin-bottom: 24px;
}

.start-info {
    margin-top: 14px;
    font-size: 15px;
    opacity: 0.95;
    min-height: 1.2em;
    line-height: 1.5;
}

/* ---------- Buttons ---------- */
.btn {
    display: block;
    width: 250px;
    max-width: 100%;
    border: none;
    padding: 14px 20px;
    margin: 7px auto;
    font-size: 19px;
    font-weight: bold;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    font-family: inherit;
}

.btn:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3); }
.btn:active { transform: translateY(0); }

.btn-primary { background: #fff; color: var(--accent); }
.btn-secondary { background: rgba(255, 255, 255, 0.18); color: #fff; border: 2px solid rgba(255, 255, 255, 0.7); }

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.7);
    background: rgba(15, 23, 42, 0.6);
    color: #fff;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    flex-shrink: 0;
    pointer-events: auto;
}

/* ---------- Game screen ---------- */
#game-screen {
    justify-content: center;
    background: #0b1220;
}

#stage {
    position: relative;
    height: 100%;
    aspect-ratio: 400 / 720;
    max-width: 100%;
}

#scene {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
}

#hud {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    padding: 2.2% 2.5% 0;
    pointer-events: none;
}

.hud-bar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 6px;
}

.hud-center {
    flex: 1;
    text-align: center;
    background: rgba(15, 23, 42, 0.78);
    border-radius: 12px;
    padding: 6px 8px;
    min-height: 54px;
}

.hud-level { font-size: 17px; font-weight: bold; letter-spacing: 1px; }
.hud-task-label { font-size: 9px; letter-spacing: 1px; color: #cbd5e1; margin-top: 2px; }
.hud-task { font-size: 12px; font-weight: bold; color: #fde047; line-height: 1.25; }

.hud-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 6px;
    padding: 0 2px;
}

.hud-shots { display: flex; gap: 5px; align-items: center; }
.hud-shots .puck { width: 20px; height: 9px; border-radius: 50%; background: #e5e7eb; box-shadow: inset 0 -2px 0 #9ca3af; }
.hud-shots .puck.used { background: #475569; box-shadow: none; opacity: .6; }
.hud-shots .puck.bonus { background: #fde047; box-shadow: inset 0 -2px 0 #ca8a04; }

.hud-goals {
    font-size: 14px;
    font-weight: bold;
    background: rgba(15, 23, 42, 0.78);
    border-radius: 10px;
    padding: 4px 10px;
}
.hud-goals b { color: #4ade80; font-size: 16px; }

.hud-clock {
    min-width: 44px;
    text-align: right;
    font-size: 20px;
    font-weight: bold;
    color: #fde047;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
}
.hud-clock.urgent { color: #f87171; animation: pulse 0.5s infinite alternate; }

/* result banner */
.banner {
    position: absolute;
    left: 50%;
    top: 46%;
    transform: translate(-50%, -50%) scale(0.6);
    font-size: 44px;
    font-weight: 900;
    letter-spacing: 2px;
    color: #fff;
    -webkit-text-stroke: 1.5px #0b1220;
    text-shadow: 0 4px 0 #0b1220, 0 8px 18px rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    white-space: nowrap;
    text-align: center;
    transition: opacity 0.15s;
}
.banner.show { animation: bannerIn 1.3s ease forwards; }
.banner.goal { color: #4ade80; }
.banner.bad { color: #f87171; }
.banner.bonus { color: #fde047; font-size: 30px; }
.banner.small { font-size: 22px; white-space: normal; max-width: 90%; }

/* level intro overlay */
.intro {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(5, 7, 13, 0.55);
    text-align: center;
    pointer-events: none;
}
.intro.show { display: flex; animation: fadeIn 0.3s ease; }
#intro-level { font-size: 48px; font-weight: 900; letter-spacing: 3px; text-shadow: 0 4px 12px rgba(0, 0, 0, 0.6); }
#intro-task { font-size: 20px; font-weight: bold; color: #fde047; margin-top: 10px; max-width: 80%; line-height: 1.3; }
#intro-task small { display: block; font-size: 14px; color: #fff; font-weight: normal; margin-top: 8px; }

/* ---------- Modals ---------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 400;
    padding: 16px calc(16px + var(--frame-right)) calc(16px + var(--frame-bottom)) calc(16px + var(--frame-left));
}

.modal-overlay.show { display: flex; }

.modal {
    background: #fff;
    color: #374151;
    border-radius: 16px;
    padding: 24px 20px;
    width: 100%;
    max-width: 380px;
    max-height: 100%;
    overflow-y: auto;
    text-align: center;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4);
    animation: modalIn 0.25s ease;
}

.modal h2 {
    font-size: 26px;
    margin-bottom: 10px;
    color: var(--accent);
}

.modal .btn-primary { background: var(--accent); color: #fff; }
.modal .btn-secondary { background: #fff; color: var(--accent); border-color: var(--accent); }

.result-text { font-size: 15px; line-height: 1.45; }

.modal-buttons { margin-top: 14px; }
.modal-buttons .btn { width: 100%; max-width: 260px; }

.modal.help { text-align: left; }
.modal.help h2 { text-align: center; }
.modal.help p { font-size: 15px; line-height: 1.45; margin: 8px 0; }

/* ---------- Animations ---------- */
@keyframes bannerIn {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.6); }
    15% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
    25% { transform: translate(-50%, -50%) scale(1); }
    80% { opacity: 1; }
    100% { opacity: 0; transform: translate(-50%, -60%) scale(1); }
}
@keyframes pulse { from { transform: scale(1); } to { transform: scale(1.15); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* ---------- Small / short screens ---------- */
@media (max-width: 360px) {
    #start-screen h1 { font-size: 32px; }
    .hud-level { font-size: 15px; }
    .hud-task { font-size: 11px; }
}

@media (max-height: 600px) {
    #start-screen h1 { font-size: 30px; margin-bottom: 6px; }
    .logo { display: none; }
    #start-screen .desc { margin-bottom: 12px; font-size: 15px; }
    .btn { padding: 10px 18px; font-size: 17px; margin: 5px auto; }
}
