* { box-sizing: border-box; margin: 0; padding: 0; user-select: none; -webkit-user-select: none; }
body {
    background: #030712;
    color: #f8fafc;
    font-family: system-ui, -apple-system, sans-serif;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.game-wrapper {
    width: 100%;
    max-width: 480px;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 8px 10px 65px; /* 65px ensures bottom ad never covers canvas */
}
.game-hud {
    height: 54px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(17, 24, 39, 0.85);
    border: 1px solid rgba(56, 189, 248, 0.25);
    border-radius: 12px;
    padding: 4px 12px;
    margin-bottom: 8px;
    flex-shrink: 0;
}
.hud-card { display: flex; flex-direction: column; align-items: center; }
.hud-label { font-size: 0.62rem; font-weight: 800; color: #94a3b8; letter-spacing: 0.5px; }
.hud-val { font-size: 1.15rem; font-weight: 900; color: #38bdf8; }
.best-card .hud-val { color: #f59e0b; }
.icon-btn {
    width: 34px; height: 34px; border-radius: 8px;
    background: rgba(2, 6, 23, 0.7); border: 1px solid rgba(56, 189, 248, 0.3);
    color: #f8fafc; font-size: 1rem; cursor: pointer;
}
.canvas-container {
    flex: 1;
    position: relative;
    width: 100%;
    border-radius: 16px;
    overflow: hidden;
    border: 2px solid rgba(56, 189, 248, 0.3);
    background: #020617;
}
#game-canvas {
    width: 100%;
    height: 100%;
    display: block;
}
.tap-hint {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(56, 189, 248, 0.4);
    padding: 8px 16px;
    border-radius: 20px;
    color: #38bdf8;
    font-weight: 700;
    font-size: 0.85rem;
    pointer-events: none;
    transition: opacity 0.4s;
    animation: pulse-hint 1.5s infinite;
}
@keyframes pulse-hint {
    0%, 100% { opacity: 0.8; transform: translate(-50%, -50%) scale(0.98); }
    50% { opacity: 1; transform: translate(-50%, -50%) scale(1.02); }
}
.tap-hint.hidden {
    animation: none;
    opacity: 0 !important;
    visibility: hidden;
    pointer-events: none;
}
.modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.85);
    display: flex; align-items: center; justify-content: center;
    z-index: 20000; opacity: 0; visibility: hidden; transition: all 0.2s;
}
.modal.active { opacity: 1; visibility: visible; }
.modal-box {
    background: #0f172a; border: 2px solid rgba(56, 189, 248, 0.35);
    border-radius: 16px; padding: 24px; text-align: center;
    max-width: 320px; width: 90%;
}
.gameover-title { color: #f43f5e; font-size: 1.4rem; font-weight: 900; margin-bottom: 12px; }
.modal-stat { font-size: 1rem; color: #cbd5e1; margin-bottom: 8px; }
.highlight-val { color: #38bdf8; font-weight: 800; }
.record-badge {
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    color: white; padding: 6px; border-radius: 6px;
    font-weight: 800; font-size: 0.8rem; margin: 10px 0;
}
.action-btn {
    width: 100%; padding: 12px; border-radius: 10px;
    background: #38bdf8; border: none; font-weight: 900;
    cursor: pointer; margin-top: 14px; color: #020617; font-size: 1rem;
}
