* {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            background: #1a1a2e;
            display: flex;
            flex-direction: column;
            align-items: center;
            height: 100dvh;
            overflow: hidden;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            touch-action: none;
            -webkit-user-select: none;
            user-select: none;
        }

        #game-wrapper {
            width: 100%;
            max-width: 900px;
            flex: 1;
            min-height: 0;
            position: relative;
            overflow: hidden;
            background: linear-gradient(180deg, #16213e 0%, #0f3460 50%, #1a1a2e 100%);
            visibility: hidden;
        }

        #ui-bar {
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            height: 48px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 0 16px;
            background: rgba(0, 0, 0, 0.4);
            z-index: 10;
            color: #fff;
            font-size: 16px;
            font-weight: 600;
        }


        #ui-bar .score-label {
            color: #e94560;
            font-size: 14px;
            text-transform: uppercase;
            letter-spacing: 1px;
        }

        #ui-bar .score-value {
            font-size: 22px;
            color: #fff;
        }

        #ui-bar .clock-label {
            color: #22c55e;
            font-size: 14px;
            text-transform: uppercase;
            letter-spacing: 1px;
        }

        #ui-bar .clock-value {
            font-size: 22px;
            color: #fff;
        }

        #ui-bar button {
            background: #e94560;
            border: none;
            color: #fff;
            padding: 6px 16px;
            border-radius: 6px;
            font-size: 14px;
            font-weight: 600;
            cursor: pointer;
            transition: background 0.2s;
        }

        #ui-bar button:hover {
            background: #c73652;
        }

        canvas {
            display: block;
            width: 100%;
            height: 100%;
        }

        #overlay {
            display: none;
            position: absolute;
            inset: 0;
            background: rgba(0, 0, 0, 0.75);
            z-index: 20;
            justify-content: center;
            align-items: center;
            flex-direction: column;
            color: #fff;
            text-align: center;
            padding: 20px;
        }

        #overlay.active {
            display: flex;
        }

        #overlay h1 {
            font-size: clamp(28px, 6vw, 48px);
            margin-bottom: 12px;
        }

        #overlay .final-score {
            font-size: clamp(18px, 4vw, 28px);
            color: #e94560;
            margin-bottom: 24px;
        }

        #overlay .score-big {
            font-size: clamp(40px, 10vw, 72px);
            font-weight: 800;
            color: #e94560;
            margin: 8px 0 4px;
            line-height: 1.1;
        }

        #overlay .score-big-label {
            font-size: clamp(14px, 3vw, 18px);
            color: #94a3b8;
            text-transform: uppercase;
            letter-spacing: 2px;
            margin-bottom: 0;
        }

        #overlay .stats-row {
            display: flex;
            gap: clamp(16px, 5vw, 40px);
            justify-content: center;
            margin: 16px 0 20px;
        }

        #overlay .stat-item {
            text-align: center;
        }

        #overlay .stat-value {
            font-size: clamp(20px, 5vw, 32px);
            font-weight: 700;
            color: #fff;
        }

        #overlay .stat-label {
            font-size: clamp(11px, 2.5vw, 14px);
            color: #94a3b8;
            text-transform: uppercase;
            letter-spacing: 1px;
        }

        #overlay button {
            background: #e94560;
            border: none;
            color: #fff;
            padding: 12px 36px;
            border-radius: 8px;
            font-size: 18px;
            font-weight: 700;
            cursor: pointer;
            transition: transform 0.15s, background 0.2s;
            margin: 4px;
        }

        #overlay button:hover {
            background: #c73652;
            transform: scale(1.05);
        }

        #save-phase, #share-phase {
            display: flex;
            flex-direction: column;
            align-items: center;
            width: 100%;
        }

        #save-btn {
            background: #e94560;
            border: none;
            color: #fff;
            padding: 14px 48px;
            border-radius: 8px;
            font-size: 20px;
            font-weight: 700;
            cursor: pointer;
            transition: transform 0.15s, background 0.2s;
            margin-top: 8px;
        }
        #save-btn:hover {
            background: #c73652;
            transform: scale(1.05);
        }

        #restart-btn {
            background: #e94560;
            border: none;
            color: #fff;
            padding: 14px 48px;
            border-radius: 8px;
            font-size: 20px;
            font-weight: 700;
            cursor: pointer;
            transition: transform 0.15s, background 0.2s;
            margin-top: 8px;
        }
        #restart-btn:hover {
            background: #c73652;
            transform: scale(1.05);
        }

        #share-buttons {
            display: flex;
            gap: 10px;
            flex-wrap: wrap;
            justify-content: center;
            margin-bottom: 10px;
        }

        #share-btn {
            background: #0ea5e9 !important;
            padding: 14px 32px !important;
            font-size: 20px !important;
            font-weight: 700 !important;
            border-radius: 10px !important;
            box-shadow: 0 0 20px rgba(14, 165, 233, 0.4);
            animation: pulse-share 2s ease-in-out infinite;
        }
        #share-btn:hover {
            background: #0284c7 !important;
            transform: scale(1.08);
        }
        @keyframes pulse-share {
            0%, 100% { box-shadow: 0 0 20px rgba(14, 165, 233, 0.4); }
            50% { box-shadow: 0 0 35px rgba(14, 165, 233, 0.7); }
        }

        #overlay-btn {
            background: rgba(255,255,255,0.12) !important;
            border: 1px solid rgba(255,255,255,0.2) !important;
            padding: 12px 28px !important;
            font-size: 16px !important;
            font-weight: 500 !important;
        }
        #overlay-btn:hover {
            background: rgba(255,255,255,0.2) !important;
        }

        #share-link-box {
            background: rgba(255,255,255,0.1);
            border: 1px solid rgba(255,255,255,0.2);
            border-radius: 10px;
            padding: 12px 16px;
            margin: 8px 0 4px;
            width: 340px;
            max-width: 85vw;
        }
        #share-link-box label {
            display: block;
            font-size: 13px;
            color: #aaa;
            margin-bottom: 6px;
        }
        .share-link-row {
            display: flex;
            gap: 6px;
        }
        #share-link-input {
            flex: 1;
            background: rgba(0,0,0,0.3);
            border: 1px solid rgba(255,255,255,0.15);
            color: #fff;
            padding: 8px 10px;
            border-radius: 6px;
            font-size: 13px;
            outline: none;
            min-width: 0;
        }
        #share-link-copy {
            background: #0ea5e9 !important;
            padding: 8px 14px !important;
            font-size: 13px !important;
            border-radius: 6px !important;
            margin: 0 !important;
            white-space: nowrap;
        }

        #overlay .name-input-area label {
            display: block;
            font-size: 16px;
            margin-bottom: 8px;
            color: #ccc;
        }

        #overlay .name-input-area input {
            background: rgba(255,255,255,0.1);
            border: 2px solid #e94560;
            color: #fff;
            padding: 10px 16px;
            border-radius: 8px;
            font-size: 18px;
            text-align: center;
            outline: none;
            width: 220px;
            max-width: 80vw;
            font-family: inherit;
        }

        #overlay .name-input-area input::placeholder {
            color: rgba(255,255,255,0.35);
        }

        #highscore-panel {
            display: none;
            position: absolute;
            inset: 0;
            background: rgba(0, 0, 0, 0.88);
            z-index: 25;
            justify-content: center;
            align-items: flex-start;
            padding: 20px;
            overflow-y: auto;
            color: #fff;
        }

        #highscore-panel.active {
            display: flex;
        }

        #highscore-panel .hs-container {
            width: 100%;
            max-width: 600px;
            max-height: none;
            overflow-y: visible;
            margin: 0 auto;
            position: relative;
        }

        #highscore-panel .hs-x {
            position: absolute;
            top: 0;
            right: 0;
            background: none;
            border: none;
            color: #fff;
            font-size: 32px;
            line-height: 1;
            cursor: pointer;
            padding: 4px 10px;
            opacity: 0.7;
            transition: opacity 0.2s;
        }

        #highscore-panel .hs-x:hover {
            opacity: 1;
        }

        #highscore-panel h2 {
            text-align: center;
            font-size: clamp(22px, 5vw, 36px);
            margin-bottom: 20px;
            color: #e94560;
        }

        #highscore-panel .hs-tabs {
            display: flex;
            justify-content: center;
            gap: 8px;
            margin-bottom: 16px;
        }

        #highscore-panel .hs-tab {
            background: rgba(255,255,255,0.1);
            border: 2px solid transparent;
            color: #ccc;
            padding: 8px 20px;
            border-radius: 8px;
            font-size: 15px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.2s;
        }

        #highscore-panel .hs-tab.active {
            border-color: #e94560;
            color: #fff;
            background: rgba(233, 69, 96, 0.2);
        }

        #highscore-panel table {
            width: 100%;
            border-collapse: collapse;
            margin-bottom: 20px;
        }

        #highscore-panel th {
            text-align: left;
            padding: 8px 12px;
            font-size: 13px;
            text-transform: uppercase;
            letter-spacing: 1px;
            color: #e94560;
            border-bottom: 1px solid rgba(255,255,255,0.15);
        }

        #highscore-panel td {
            padding: 8px 12px;
            font-size: 15px;
            border-bottom: 1px solid rgba(255,255,255,0.06);
        }

        #highscore-panel td:first-child {
            color: #e94560;
            font-weight: 700;
            width: 36px;
        }

        #highscore-panel .hs-empty {
            text-align: center;
            color: #888;
            padding: 30px;
            font-size: 16px;
        }

        #highscore-panel .hs-score-explanation {
            text-align: center;
            color: #94a3b8;
            font-size: 13px;
            padding: 10px 0 4px;
            font-style: italic;
        }

        #highscore-panel .hs-newest td {
            background: rgba(233, 69, 96, 0.08);
        }

        #highscore-panel .hs-new-badge {
            display: inline-block;
            background: #e94560;
            color: #fff;
            font-size: 10px;
            font-weight: 700;
            padding: 1px 6px;
            border-radius: 4px;
            letter-spacing: 0.5px;
            vertical-align: middle;
            margin-left: 6px;
        }

        #highscore-panel .hs-score-th {
            text-decoration: underline;
            text-decoration-style: dashed;
            text-underline-offset: 3px;
            cursor: pointer;
        }

        #highscore-panel .hs-ppm-val {
            text-decoration: underline;
            text-decoration-style: dashed;
            text-underline-offset: 3px;
            cursor: pointer;
            position: relative;
        }

        #highscore-panel .hs-tooltip {
            position: absolute;
            bottom: calc(100% + 8px);
            left: 50%;
            transform: translateX(-50%);
            background: #1e293b;
            border: 1px solid rgba(255,255,255,0.15);
            border-radius: 6px;
            padding: 6px 12px;
            font-size: 13px;
            white-space: nowrap;
            color: #e2e8f0;
            z-index: 100;
            pointer-events: none;
            box-shadow: 0 4px 12px rgba(0,0,0,0.4);
        }
        #highscore-panel .hs-tooltip::after {
            content: '';
            position: absolute;
            top: 100%;
            left: 50%;
            transform: translateX(-50%);
            border: 6px solid transparent;
            border-top-color: #1e293b;
        }

        #highscore-panel .hs-close {
            display: block;
            margin: 10px auto 0;
            background: #e94560;
            border: none;
            color: #fff;
            padding: 10px 32px;
            border-radius: 8px;
            font-size: 16px;
            font-weight: 600;
            cursor: pointer;
        }

        #aim-line {
            position: absolute;
            bottom: 0;
            left: 0;
            right: 0;
            pointer-events: none;
        }

        #highscore-panel .hs-rules h1 {
            font-size: 22px;
            color: #fff;
            margin: 0 0 8px;
        }
        #highscore-panel .hs-rules h3 {
            font-size: 18px;
            color: #0ea5e9;
            margin: 18px 0 8px;
        }
        #highscore-panel .hs-rules p,
        #highscore-panel .hs-rules li {
            font-size: 15px;
            line-height: 1.6;
            color: #ccc;
        }
        #highscore-panel .hs-rules ul {
            padding-left: 20px;
            margin: 8px 0;
        }
        #highscore-panel .hs-rules li {
            margin-bottom: 4px;
        }

        #ad-banner {
            width: 100%;
            max-width: 900px;
            min-height: 110px;
            padding-top: 20px;
            display: none;
            justify-content: center;
            align-items: center;
            background: rgba(0, 0, 0, 0.5);
            border-top: 1px solid rgba(255, 255, 255, 0.1);
        }

        #ad-banner.active {
            display: flex;
        }

        #ad-message {
            display: none;
            position: fixed;
            top: 12%;
            left: 0;
            right: 0;
            z-index: 100000;
            text-align: center;
            font-family: sans-serif;
            font-size: 15px;
            color: #fff;
            pointer-events: none;
        }

        #ad-message.active {
            display: block;
        }