:root {
    color-scheme: dark;
    --bg: #000000;
    --panel: #090909;
    --line: #1c1c1c;
    --text: #f5f5f5;
    --muted: #8e8e8e;
    --accent: #8af4ff;
    --danger: #ff5f7a;
    --ad-bar-height: 88px;
    --ad-bottom-pad: 16px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html,
body {
    margin: 0;
    width: 100%;
    min-height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: "Pretendard", "Noto Sans KR", "Apple SD Gothic Neo", "Segoe UI", sans-serif;
    overflow-x: hidden;
}

body {
    display: block;
}

.hidden {
    display: none !important;
}

.main-shell {
    width: 100%;
    max-width: 430px;
    margin: 0 auto;
    padding: calc(var(--safe-top) + 10px) 0 10px;
    display: grid;
    gap: 12px;
}

.test-menu {
    border: 1px solid #1b1b1b;
    border-radius: 16px;
    background: linear-gradient(180deg, #111111, #090909);
    padding: 12px;
}

.test-menu-head h2 {
    margin: 6px 0 0;
    font-size: 18px;
    letter-spacing: 0.01em;
}

.test-menu-eyebrow {
    margin: 0;
    color: #8f8f8f;
    font-size: 10px;
    letter-spacing: 0.14em;
}

.test-card-grid {
    margin-top: 10px;
    display: grid;
    gap: 8px;
}

.test-card {
    display: grid;
    gap: 4px;
    border-radius: 12px;
    border: 1px solid #2b2b2b;
    background: #0f0f0f;
    padding: 10px;
    color: #f5f5f5;
    text-decoration: none;
}

.test-card strong {
    font-size: 13px;
    letter-spacing: 0.04em;
}

.test-card span {
    font-size: 12px;
    color: #a8a8a8;
}

.test-card.active {
    border-color: #4a4a4a;
    background: linear-gradient(180deg, #161616, #101010);
}

.game-root {
    width: 100%;
    height: 100dvh;
    scroll-margin-top: calc(var(--safe-top) + 8px);
}

.phone-stage {
    width: 100%;
    height: 100%;
    display: grid;
    grid-template-rows: auto 1fr auto auto;
    background:
        radial-gradient(circle at 50% -10%, #1f1f1f 0%, #050505 36%, #000000 70%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 24%);
    border: 1px solid #151515;
    overflow: hidden;
}

.hud {
    display: grid;
    gap: 8px;
    padding: 12px 14px 10px;
    border-bottom: 1px solid var(--line);
    background: rgba(0, 0, 0, 0.78);
    backdrop-filter: blur(5px);
}

.hud-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.hud-right {
    display: grid;
    gap: 4px;
    justify-items: end;
}

.hud-lang {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.hud-lang span {
    font-size: 10px;
    letter-spacing: 0.08em;
    color: #8e8e8e;
}

.hud-lang select {
    width: 112px;
    height: 24px;
    border-radius: 8px;
    border: 1px solid #343434;
    background: rgba(8, 8, 8, 0.92);
    color: #ffffff;
    font-size: 11px;
    padding: 0 6px;
}

.brand {
    margin: 0;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.11em;
    color: #c9c9c9;
}

.hud-stats {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
    font-size: 11px;
    color: var(--muted);
}

.hud-stats strong {
    margin-left: 4px;
    color: #ffffff;
    font-size: 14px;
}

.level-track {
    width: 100%;
    height: 6px;
    border-radius: 999px;
    background: #131313;
    border: 1px solid #202020;
    overflow: hidden;
}

.level-track span {
    display: block;
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #68efff, #b0f9ff);
    box-shadow: 0 0 12px rgba(114, 242, 255, 0.6);
    transition: width 0.18s linear;
}

.buff-row {
    min-height: 26px;
    display: flex;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
}

.buff-row::-webkit-scrollbar {
    display: none;
}

.buff-chip {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 999px;
    border: 1px solid #2e2e2e;
    background: rgba(16, 16, 16, 0.92);
    font-size: 11px;
    color: #d7d7d7;
}

.buff-chip b {
    font-size: 10px;
    letter-spacing: 0.03em;
}

.buff-chip span {
    color: #9fefff;
    font-variant-numeric: tabular-nums;
}

.game-stage {
    position: relative;
    min-height: 0;
}

#flight-game {
    width: 100%;
    height: 100%;
    display: block;
    background: #000000;
    touch-action: none;
}

.overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.82), rgba(0, 0, 0, 0.92));
}

.overlay.hidden {
    display: none;
}

.overlay-card {
    width: min(344px, 100%);
    max-height: min(82dvh, 640px);
    overflow-y: auto;
    border: 1px solid #2d2d2d;
    border-radius: 18px;
    padding: 18px 16px;
    text-align: center;
    background: linear-gradient(180deg, rgba(16, 16, 16, 0.94), rgba(4, 4, 4, 0.94));
    box-shadow: 0 18px 44px rgba(0, 0, 0, 0.62);
}

.overlay-eyebrow {
    margin: 0 0 8px;
    font-size: 10px;
    letter-spacing: 0.16em;
    color: #808080;
}

.overlay-card h1 {
    margin: 0;
    font-size: 27px;
    letter-spacing: 0.04em;
}

.overlay-card p {
    margin: 10px 0 0;
    font-size: 13px;
    line-height: 1.45;
    color: #c6c6c6;
}

.save-grid label span {
    font-size: 11px;
    color: #9e9e9e;
}

.save-grid select,
.save-grid input {
    height: 34px;
    border-radius: 10px;
    border: 1px solid #333333;
    background: #101010;
    color: #ffffff;
    font-size: 12px;
    padding: 0 8px;
}

.google-translate-host {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.ranking-panel {
    margin-top: 10px;
    border: 1px solid #2a2a2a;
    border-radius: 12px;
    background: rgba(7, 7, 7, 0.9);
    text-align: left;
}

.ranking-panel.hidden {
    display: none;
}

.ranking-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-bottom: 1px solid #232323;
}

.ranking-head strong {
    font-size: 12px;
    letter-spacing: 0.04em;
}

#refresh-ranking-btn {
    height: 26px;
    border-radius: 8px;
    border: 1px solid #3a3a3a;
    background: #141414;
    color: #dfdfdf;
    font-size: 11px;
    padding: 0 8px;
}

.ranking-scroll {
    max-height: none;
    overflow: hidden;
}

.ranking-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
}

.ranking-table th,
.ranking-table td {
    padding: 6px 7px;
    border-bottom: 1px solid #1d1d1d;
    text-align: left;
}

.ranking-table th {
    color: #939393;
    font-size: 10px;
    letter-spacing: 0.05em;
    position: sticky;
    top: 0;
    background: #0b0b0b;
    z-index: 1;
}

.ranking-table td {
    color: #e7e7e7;
}

.ranking-table .rank-col {
    width: 24px;
    color: #9fefff;
}

.ranking-table .country-col {
    white-space: nowrap;
}

.ranking-empty {
    text-align: center;
    color: #8d8d8d;
}

.save-panel {
    margin-top: 12px;
    padding: 10px;
    border: 1px solid #2f2f2f;
    border-radius: 12px;
    background: rgba(10, 10, 10, 0.9);
    text-align: left;
}

.save-panel.hidden {
    display: none;
}

.save-title {
    margin: 0;
    font-size: 11px;
    letter-spacing: 0.08em;
    color: #b7b7b7;
}

.save-grid {
    display: grid;
    gap: 7px;
    margin-top: 8px;
}

.save-grid label {
    display: grid;
    gap: 4px;
}

#save-score-btn {
    margin-top: 8px;
    width: 100%;
    height: 36px;
    border-radius: 10px;
    border: 1px solid #3e3e3e;
    background: linear-gradient(180deg, #1a1a1a, #0d0d0d);
    color: #ffffff;
    font-size: 12px;
    font-weight: 700;
}

.save-status {
    min-height: 16px;
    margin: 8px 0 0;
    font-size: 11px;
    color: #8de9ff;
}

#overlay-button {
    margin-top: 16px;
    width: 100%;
    height: 46px;
    border-radius: 12px;
    border: 1px solid #3f3f3f;
    background: linear-gradient(180deg, #171717, #0c0c0c);
    color: #ffffff;
    font-size: 14px;
    font-weight: 700;
}

#overlay-button:active {
    transform: translateY(1px);
}

.touch-controls {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
    padding: 10px 14px 12px;
    border-top: 1px solid var(--line);
    background: var(--panel);
}

.control-btn {
    height: 52px;
    border-radius: 14px;
    border: 1px solid #313131;
    background: linear-gradient(180deg, #151515 0%, #0a0a0a 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
    color: #ffffff;
    font-size: 24px;
    font-weight: 700;
    touch-action: none;
    user-select: none;
}

.control-fire {
    color: var(--accent);
}

.control-btn:active,
.control-btn.is-active {
    background: linear-gradient(180deg, #202020 0%, #111111 100%);
    border-color: #4e4e4e;
}

.game-ad-bar {
    border-top: 1px solid #222222;
    background: #ffffff;
    height: calc(var(--ad-bar-height) + var(--safe-bottom) + var(--ad-bottom-pad));
    padding-bottom: calc(var(--safe-bottom) + var(--ad-bottom-pad));
}

.game-legal-footer {
    min-height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px;
    background: #111111;
    color: #d8d8d8;
    font-size: 10px;
    line-height: 1;
    white-space: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    border-top: 1px solid #222222;
}

.game-legal-footer::-webkit-scrollbar {
    display: none;
}

.legal-link-btn {
    border: 0;
    padding: 0;
    margin: 0;
    background: transparent;
    color: #aeefff;
    text-decoration: none;
    font-size: 10px;
    line-height: 1;
    cursor: pointer;
}

.game-legal-label {
    color: #bfbfbf;
}

.game-dot {
    color: #707070;
}

.legal-modal {
    position: absolute;
    inset: 0;
    z-index: 220;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(4px);
}

.legal-modal-card {
    width: min(320px, 100%);
    border: 1px solid #333333;
    border-radius: 14px;
    background: #0f0f0f;
    padding: 14px;
    text-align: left;
}

.legal-modal-title {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: #ffffff;
}

.legal-modal-body {
    margin: 9px 0 0;
    font-size: 13px;
    line-height: 1.52;
    color: #d1d1d1;
    white-space: pre-line;
}

#legal-modal-close {
    margin-top: 12px;
    width: 100%;
    height: 38px;
    border-radius: 10px;
    border: 1px solid #3a3a3a;
    background: #141414;
    color: #ffffff;
    font-size: 13px;
    font-weight: 700;
}

.game-ad-link {
    display: grid;
    grid-template-columns: 30% 70%;
    width: 100%;
    height: var(--ad-bar-height);
}

.game-ad-link img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

#game-ad-image {
    object-fit: cover;
}

.game-ad-logo {
    object-fit: contain;
    padding: 8px 10px;
    background: #ffffff;
    border-right: 1px solid #e6e6e6;
}

@media (min-width: 480px) {
    .main-shell {
        padding: 12px 0;
    }

    .game-root {
        height: min(100dvh - 24px, 900px);
    }

    .phone-stage {
        border-radius: 24px;
        box-shadow: 0 20px 54px rgba(0, 0, 0, 0.62);
    }
}
