:root {
    --sky-1: #180a2b;
    --sky-2: #451451;
    --sky-3: #8a2350;
    --sky-4: #d84f2f;
    --sky-5: #f7a23c;
    --gold: #ffc94d;
    --gold-light: #ffe08a;
    --orange: #ff8a3d;
    --chili: #ff4d5e;
    --teal: #34d3c2;
    --cream: #fff3df;
    --ink: #3a1206;

    --glass: rgba(26, 14, 40, 0.6);
    --glass-panel: linear-gradient(160deg, rgba(92, 60, 112, 0.82) 0%, rgba(64, 40, 84, 0.82) 100%);
    --glass-soft: rgba(255, 255, 255, 0.08);
    --glass-border: rgba(255, 255, 255, 0.15);
    --glass-blur: blur(22px) saturate(1.2);

    --radius-lg: 24px;
    --radius-md: 14px;
    --radius-sm: 10px;

    --stage-w: min(calc(100vw - 32px), calc((100vh - 32px) * 1.5), 1200px);

    --shadow-panel: 0 24px 70px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.12);
    --font-body: 'Poppins', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

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

@font-face {
    font-family: 'Zabars';
    src: url('./fonts/Zabars.ttf') format('truetype');
}

body {
    font-family: var(--font-body);
    background-color: var(--sky-1);
    background-image:
        linear-gradient(180deg,
            rgba(20, 8, 40, 0.78) 0%,
            rgba(90, 25, 80, 0.55) 35%,
            rgba(216, 79, 47, 0.42) 68%,
            rgba(18, 7, 36, 0.92) 100%),
        url('./img/game_background/mostafaelturkey36-desert-5112222_1920.png');
    background-position: center, center bottom;
    background-size: cover, cover;
    background-attachment: fixed;
    color: var(--cream);
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px;
    gap: 15px;
    overflow: hidden;
}

body::after {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(ellipse at 50% 42%, transparent 45%, rgba(0, 0, 0, 0.55) 100%);
    z-index: 0;
}

.rotate-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: linear-gradient(160deg, var(--sky-1) 0%, var(--sky-3) 100%);
    z-index: 10000;
    align-items: center;
    justify-content: center;
}

.rotate-content {
    text-align: center;
    color: var(--gold);
    padding: 20px;
}

.phone-icon {
    margin-bottom: 20px;
    animation: rotatePhone 2s ease-in-out infinite;
}

.rotate-arrow {
    font-size: 60px;
    color: var(--chili);
    margin: 10px 0;
    animation: pulse 1.5s ease-in-out infinite;
    filter: drop-shadow(0 4px 10px rgba(255, 77, 94, 0.5));
}

.rotate-overlay h2 {
    font-size: 26px;
    margin-bottom: 10px;
    color: var(--gold);
    font-weight: 800;
    letter-spacing: 0.5px;
}

.rotate-overlay p {
    font-size: 16px;
    color: var(--cream);
    opacity: 0.85;
}

@keyframes rotatePhone {

    0%,
    100% {
        transform: rotate(0deg);
    }

    50% {
        transform: rotate(90deg);
    }
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.2);
        opacity: 0.7;
    }
}

.startscreen {
    position: relative;
    width: var(--stage-w);
    aspect-ratio: 3 / 2;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
    animation: panelIn 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.screen-background {
    position: absolute;
    inset: 0;
    background: var(--glass);
    -webkit-backdrop-filter: var(--glass-blur);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-panel);
    overflow: hidden;
}

.screen-background::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--gold), var(--orange), var(--chili));
}

.screen-content {
    position: relative;
    z-index: 1;
    text-align: center;
    width: 100%;
    padding: 32px;
}

.title-container {
    margin-bottom: 34px;
}

.startscreen-title {
    font-family: 'Zabars', sans-serif;
    font-size: clamp(38px, 7vw, 66px);
    line-height: 1;
    margin-bottom: 14px;
    letter-spacing: 2px;
    background: linear-gradient(180deg, var(--gold-light) 0%, var(--gold) 45%, var(--orange) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 3px 0 rgba(120, 20, 10, 0.4)) drop-shadow(0 8px 22px rgba(255, 120, 40, 0.4));
}

.subtitle {
    font-size: clamp(15px, 3vw, 18px);
    color: var(--cream);
    font-weight: 500;
    opacity: 0.9;
    max-width: 460px;
    margin: 0 auto;
}

.game-menu {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
}

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 28px;
    font-family: var(--font-body);
    font-size: clamp(14px, 2vw, 16px);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    width: 100%;
    max-width: 300px;
    transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.btn-primary {
    background: linear-gradient(135deg, var(--gold) 0%, var(--orange) 100%);
    color: var(--ink);
    box-shadow: 0 8px 22px rgba(255, 138, 61, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 30px rgba(255, 138, 61, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.btn-primary:active {
    transform: translateY(1px);
    box-shadow: 0 4px 12px rgba(255, 138, 61, 0.4);
}

.btn-secondary {
    background: var(--glass-soft);
    color: var(--cream);
    border: 1px solid rgba(255, 255, 255, 0.2);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.16);
    border-color: rgba(255, 201, 77, 0.6);
    transform: translateY(-2px);
}

.btn-secondary:active {
    transform: translateY(1px);
}

.btn-icon {
    font-size: 1.25em;
    line-height: 1;
}

.loading-screen {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 300;
    background: rgba(12, 5, 24, 0.65);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    align-items: center;
    justify-content: center;
}

.loading-screen.show {
    display: flex;
}

.loading-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
    padding: 30px 40px;
    background: var(--glass);
    -webkit-backdrop-filter: var(--glass-blur);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-panel);
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 4px solid rgba(255, 255, 255, 0.15);
    border-top-color: var(--gold);
    border-right-color: var(--orange);
    animation: spin 0.8s linear infinite;
}

.loading-text {
    color: var(--cream);
    font-weight: 600;
    font-size: 17px;
    letter-spacing: 0.5px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes panelIn {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(12, 5, 24, 0.72);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: var(--glass-panel);
    -webkit-backdrop-filter: var(--glass-blur);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 520px;
    color: var(--cream);
    box-shadow: var(--shadow-panel);
    max-height: 90vh;
    overflow-y: auto;
    animation: panelIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 22px 26px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
}

.modal-header::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 64px;
    height: 3px;
    background: linear-gradient(90deg, var(--gold), var(--orange));
    border-radius: 3px;
}

.modal-header h2 {
    font-size: clamp(20px, 4vw, 28px);
    font-weight: 800;
    letter-spacing: 0.5px;
    color: var(--gold);
}

.close-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    background: var(--glass-soft);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 50%;
    color: var(--cream);
    font-size: 22px;
    cursor: pointer;
    line-height: 1;
    transition: all 0.2s;
}

.close-btn:hover {
    background: var(--chili);
    border-color: var(--chili);
    transform: rotate(90deg);
}

.modal-body {
    padding: 26px;
}

.modal-body h3 {
    margin-bottom: 16px;
    color: var(--gold);
    font-weight: 700;
    font-size: clamp(16px, 3vw, 19px);
}

.modal-body p {
    line-height: 1.6;
    color: var(--cream);
    opacity: 0.92;
}

.modal-body strong {
    color: var(--gold-light);
}

.pause-menu-content {
    max-width: 420px;
}

.pause-menu-header {
    justify-content: center;
    text-align: center;
}

.pause-menu-header::after {
    left: 50%;
    transform: translateX(-50%);
}

.pause-menu-header h2 {
    font-size: 34px;
    font-weight: 900;
    letter-spacing: 2px;
    color: var(--gold);
}

.pause-menu-body {
    padding: 24px;
}

.pause-game-menu {
    gap: 12px;
}

#pauseMenuModal {
    z-index: 900;
}

.key-bindings {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.key-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
}

.key-item {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--glass-soft);
    padding: 12px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-sm);
}

.key {
    background: linear-gradient(180deg, #3a2450, #241636);
    color: var(--gold-light);
    padding: 8px 12px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 8px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 2px 0 rgba(0, 0, 0, 0.35);
    font-weight: 700;
    min-width: 56px;
    text-align: center;
    font-size: 14px;
}

.action {
    flex: 1;
    font-weight: 500;
    font-size: 15px;
    color: var(--cream);
}

.setting-item {
    margin-bottom: 22px;
}

.setting-item label {
    display: block;
    margin-bottom: 12px;
    font-weight: 700;
    color: var(--gold);
    font-size: 16px;
}

.volume-control {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--glass-soft);
    padding: 14px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-sm);
}

.volume-icon {
    font-size: 22px;
}

#volumeSlider {
    flex: 1;
    height: 6px;
    background: rgba(255, 255, 255, 0.18);
    outline: none;
    border-radius: 4px;
    -webkit-appearance: none;
    appearance: none;
}

#volumeSlider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--gold), var(--orange));
    cursor: pointer;
    border: 2px solid rgba(255, 255, 255, 0.6);
    box-shadow: 0 2px 8px rgba(255, 138, 61, 0.5);
}

#volumeSlider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--gold), var(--orange));
    cursor: pointer;
    border: 2px solid rgba(255, 255, 255, 0.6);
}

.volume-value {
    min-width: 46px;
    text-align: right;
    font-weight: 700;
    color: var(--gold-light);
}

.display-controls {
    display: flex;
    gap: 12px;
}

.display-btn {
    flex: 1;
    padding: 13px;
    background: var(--glass-soft);
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: var(--cream);
    cursor: pointer;
    font-family: var(--font-body);
    font-weight: 600;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.display-btn:hover {
    background: rgba(255, 255, 255, 0.16);
    border-color: rgba(255, 201, 77, 0.6);
}

.display-btn.active {
    background: linear-gradient(135deg, var(--gold), var(--orange));
    color: var(--ink);
    border-color: transparent;
    box-shadow: 0 4px 14px rgba(255, 138, 61, 0.4);
}

.mobile-controls {
    display: none;
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 100;
}

.controls-left,
.controls-right {
    position: absolute;
    display: flex;
    gap: 10px;
    pointer-events: all;
    bottom: 12px;
}

.controls-left {
    left: 15px;
    gap: 24px;
}

.controls-right {
    right: 15px;
}

.control-btn {
    width: 44px;
    height: 44px;
    background: rgba(26, 14, 40, 0.5);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    border: 1px solid rgba(255, 201, 77, 0.7);
    border-radius: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: var(--gold);
    transition: all 0.1s;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.control-btn:active {
    background: linear-gradient(135deg, var(--gold), var(--orange));
    color: var(--ink);
    transform: scale(0.94);
}

.control-btn span {
    pointer-events: none;
}

.control-icon-img {
    width: 24px;
    height: 24px;
    object-fit: contain;
    display: block;
}

.game-container {
    position: relative;
    width: var(--stage-w);
    line-height: 0;
    z-index: 1;
}

#canvas {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 3 / 2;
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(0, 0, 0, 0.2);
}

.game-ui {
    position: absolute;
    top: 14px;
    right: 14px;
    display: flex;
    gap: 10px;
}

.game-ui-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    background: rgba(26, 14, 40, 0.55);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    border: 1px solid rgba(255, 201, 77, 0.5);
    border-radius: 14px;
    color: var(--gold);
    font-size: 22px;
    cursor: pointer;
    font-weight: 700;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.game-ui-btn:hover {
    background: linear-gradient(135deg, var(--gold), var(--orange));
    color: var(--ink);
    border-color: transparent;
    transform: translateY(-2px);
}

.endscreen {
    display: none;
    position: relative;
    width: var(--stage-w);
    aspect-ratio: 3 / 2;
    z-index: 200;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease-in-out;
}

.endscreen.show {
    display: flex;
    opacity: 1;
    pointer-events: auto;
}

.endimage-container {
    position: relative;
    z-index: 2;
    margin-bottom: 32px;
    text-align: center;
}

.endimage-container img {
    max-width: 100%;
    max-height: 210px;
    width: auto;
    height: auto;
    filter: drop-shadow(0 10px 30px rgba(0, 0, 0, 0.5));
}

/* #region Responsive */
@media (max-width: 768px) {
    body {
        padding: 5px;
        gap: 10px;
    }

    .screen-content {
        padding: 24px;
    }

    .btn {
        padding: 12px 24px;
        max-width: 260px;
    }

    .game-ui {
        top: 6px;
        right: 6px;
        gap: 6px;
    }

    .game-ui-btn {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }

    .endimage-container img {
        max-height: 160px;
    }
}

@media (max-width: 480px) {
    .startscreen-title {
        font-size: 36px;
    }

    .subtitle {
        font-size: 14px;
    }

    .btn {
        padding: 11px 20px;
        font-size: 13px;
        max-width: 230px;
    }

    .modal-body {
        padding: 18px;
    }

    .endimage-container {
        margin-bottom: 22px;
    }

    .endimage-container img {
        max-height: 130px;
    }
}

@media (orientation: landscape) and (max-height: 500px) {
    body {
        gap: 8px;
        padding: 5px;
    }

    .screen-content {
        padding: 18px;
    }

    .title-container {
        margin-bottom: 16px;
    }

    .startscreen-title {
        font-size: 34px;
        margin-bottom: 8px;
    }

    .subtitle {
        font-size: 15px;
    }

    .game-menu {
        gap: 8px;
    }

    .btn {
        padding: 9px 22px;
        font-size: 14px;
        max-width: 260px;
    }

    .game-ui {
        top: 6px;
        right: 6px;
    }

    .game-ui-btn {
        width: 34px;
        height: 34px;
    }

    .endimage-container {
        margin-bottom: 16px;
    }

    .endimage-container img {
        max-height: 120px;
    }
}

@media (orientation: landscape) and (max-height: 400px) {
    .screen-content {
        padding: 12px;
    }

    .title-container {
        margin-bottom: 10px;
    }

    .startscreen-title {
        font-size: 26px;
    }

    .subtitle {
        font-size: 13px;
    }

    .game-menu {
        gap: 6px;
    }

    .btn {
        padding: 7px 18px;
        font-size: 12px;
        max-width: 220px;
    }

    .game-ui-btn {
        width: 30px;
        height: 30px;
        font-size: 14px;
    }

    .endimage-container img {
        max-height: 90px;
    }
}

@media (hover: none) and (pointer: coarse) and (orientation: landscape) {
    .mobile-controls {
        display: block;
    }
}

@media screen and (max-width: 767px) and (orientation: portrait) {
    .rotate-overlay {
        display: flex !important;
    }
}
/* #endregion */
