:root {
    /* Moody Color Palette */
    --sky-dusk: #4a5568;
    --sky-dark: #2d3748;
    --concrete-gray: #718096;
    --warning-yellow: #f6ad55;
    --danger-red: #fc8181;
    --hope-blue: #63b3ed;
    --dust-brown: #a0826d;
    --border-white: #e2e8f0;
    --text-light: #f7fafc;
    --text-dark: #1a202c;
    --glass-overlay: rgba(255, 255, 255, 0.1);

    /* UI Colors */
    --panel-bg: rgba(26, 32, 44, 0.85);
    --panel-border: rgba(226, 232, 240, 0.2);
    --button-primary: #f6ad55;
    --button-hover: #ed8936;
    --success-green: #68d391;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(180deg, var(--sky-dark) 0%, var(--sky-dusk) 100%);
    color: var(--text-light);
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    touch-action: none;
    /* Prevent default touch behaviors */
    /* iOS safe area (notch support) */
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

#game-canvas {
    display: block;
    background: linear-gradient(180deg, #2d3748 0%, #4a5568 50%, #718096 100%);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    border-radius: 8px;
    max-width: 100%;
    max-height: 100%;
}

/* UI Overlay */
#ui-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

#ui-overlay>* {
    pointer-events: auto;
}

/* Top HUD */
#top-hud {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 1200px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    padding: 15px 25px;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    backdrop-filter: blur(10px);
}

.hud-section {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.hud-section.center {
    flex: 1;
    align-items: center;
}

.hud-section.right {
    align-items: flex-end;
}

.hud-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 1.5px;
    color: var(--concrete-gray);
    text-transform: uppercase;
}

.hud-value {
    font-size: 24px;
    font-weight: 900;
    color: var(--warning-yellow);
    text-shadow: 0 2px 8px rgba(246, 173, 85, 0.3);
}

.sarcastic-msg {
    font-size: 14px;
    font-weight: 600;
    font-style: italic;
    color: var(--border-white);
    text-align: center;
    opacity: 0.9;
}

/* Duck Panel */
#duck-panel {
    position: absolute;
    top: 120px;
    right: 20px;
    padding: 15px;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    backdrop-filter: blur(10px);
    min-width: 180px;
}

.panel-title {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.2px;
    color: var(--concrete-gray);
    text-transform: uppercase;
    margin-bottom: 10px;
}

#duck-slots {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.duck-slot {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    transition: all 0.2s ease;
}

.duck-slot.used {
    opacity: 0.3;
}

.duck-slot.active {
    background: rgba(246, 173, 85, 0.2);
    border: 1px solid var(--warning-yellow);
}

.duck-icon {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--hope-blue);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.duck-name {
    font-size: 12px;
    font-weight: 600;
    flex: 1;
}

/* Launch Info */
#launch-info {
    position: absolute;
    bottom: 20px;
    left: 20px;
    padding: 15px;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    backdrop-filter: blur(10px);
    min-width: 150px;
    z-index: 10;
}

.info-row {
    display: flex;
    justify-content: space-between;
    gap: 15px;
    margin-bottom: 8px;
    font-size: 13px;
}

.info-row:last-child {
    margin-bottom: 0;
}

.info-label {
    font-weight: 600;
    color: var(--concrete-gray);
}

#power-value,
#angle-value {
    font-weight: 700;
    color: var(--warning-yellow);
}

/* Screens */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(26, 32, 44, 0.95);
    backdrop-filter: blur(20px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    animation: fadeIn 0.3s ease;
}

.screen.hidden {
    display: none;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.screen-content {
    text-align: center;
    max-width: 600px;
    padding: 40px;
    background: var(--panel-bg);
    border: 2px solid var(--panel-border);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.game-title {
    font-size: 72px;
    font-weight: 900;
    letter-spacing: -2px;
    color: var(--warning-yellow);
    text-shadow: 0 4px 20px rgba(246, 173, 85, 0.5);
    margin-bottom: 10px;
}

.game-subtitle {
    font-size: 18px;
    font-weight: 600;
    font-style: italic;
    color: var(--border-white);
    margin-bottom: 40px;
    opacity: 0.8;
}

.screen-title {
    font-size: 48px;
    font-weight: 900;
    letter-spacing: -1px;
    color: var(--warning-yellow);
    margin-bottom: 20px;
}

/* Buttons */
.btn {
    padding: 15px 40px;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Inter', sans-serif;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: var(--button-primary);
    color: var(--text-dark);
}

.btn-primary:hover {
    background: var(--button-hover);
}

.btn-secondary {
    background: var(--concrete-gray);
    color: var(--text-light);
}

.btn-secondary:hover {
    background: var(--sky-dusk);
}

.btn-group {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 30px;
}

/* Menu Info */
.menu-info {
    margin-top: 40px;
    padding-top: 30px;
    border-top: 1px solid var(--panel-border);
}

.menu-info p {
    margin-bottom: 10px;
    color: var(--border-white);
    opacity: 0.8;
}

.small-text {
    font-size: 13px;
    color: var(--concrete-gray);
}

/* Stats Display */
.stats {
    margin: 30px 0;
    padding: 20px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    font-size: 16px;
    border-bottom: 1px solid var(--panel-border);
}

.stat-row:last-child {
    border-bottom: none;
}

.stat-row span:first-child {
    color: var(--concrete-gray);
    font-weight: 600;
}

.stat-row span:last-child {
    color: var(--warning-yellow);
    font-weight: 700;
}

/* Stars Display */
.stars {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin: 20px 0;
    font-size: 48px;
}

.star {
    color: var(--concrete-gray);
    transition: all 0.3s ease;
}

.star.earned {
    color: var(--warning-yellow);
    text-shadow: 0 0 20px rgba(246, 173, 85, 0.6);
    animation: starPop 0.5s ease;
}

@keyframes starPop {
    0% {
        transform: scale(0);
    }

    50% {
        transform: scale(1.3);
    }

    100% {
        transform: scale(1);
    }
}

/* Responsive - Tablet */
@media (max-width: 768px) {
    #game-canvas {
        max-width: 95vw;
        max-height: 65vh;
    }

    .game-title {
        font-size: 48px;
    }

    .screen-title {
        font-size: 36px;
    }

    #top-hud {
        flex-direction: column;
        gap: 10px;
        padding: 10px 15px;
        top: 10px;
        width: 95%;
    }

    .hud-section {
        width: 100%;
        align-items: center !important;
    }

    .hud-value {
        font-size: 20px;
    }

    /* Move launch info to top left on mobile to avoid blocking launcher */
    #launch-info {
        top: 120px;
        left: 10px;
        bottom: auto;
        padding: 10px;
        min-width: 120px;
    }

    .info-row {
        font-size: 11px;
        gap: 10px;
    }

    /* Adjust duck panel for mobile */
    #duck-panel {
        top: 120px;
        right: 10px;
        min-width: 140px;
        padding: 10px;
    }

    .panel-title {
        font-size: 9px;
    }

    .duck-slot {
        padding: 6px;
    }

    .duck-icon {
        width: 25px;
        height: 25px;
        font-size: 14px;
    }

    .duck-name {
        font-size: 11px;
    }

    /* Make buttons more touch-friendly */
    .btn {
        padding: 18px 35px;
        font-size: 15px;
        min-height: 50px;
    }

    .screen-content {
        padding: 30px 20px;
        max-width: 90%;
    }

    .sarcastic-msg {
        font-size: 12px;
    }
}

/* Responsive - Mobile */
@media (max-width: 480px) {
    #game-canvas {
        max-width: 98vw;
        max-height: 60vh;
    }

    .game-title {
        font-size: 36px;
    }

    .screen-title {
        font-size: 28px;
    }

    #top-hud {
        padding: 8px 10px;
        top: 5px;
    }

    .hud-value {
        font-size: 18px;
    }

    .hud-label {
        font-size: 9px;
    }

    /* Position launch info at top left to not block launcher */
    #launch-info {
        top: 90px;
        left: 5px;
        padding: 8px;
        min-width: 100px;
    }

    .info-row {
        font-size: 10px;
        gap: 8px;
    }

    #duck-panel {
        top: 90px;
        right: 5px;
        min-width: 110px;
        padding: 8px;
    }

    .panel-title {
        font-size: 8px;
    }

    .duck-icon {
        width: 22px;
        height: 22px;
        font-size: 12px;
    }

    .duck-name {
        font-size: 10px;
    }

    .btn {
        padding: 15px 25px;
        font-size: 14px;
    }

    .screen-content {
        padding: 25px 15px;
    }

    .game-subtitle {
        font-size: 14px;
    }
}

/* Fullscreen Button */
#fullscreen-btn {
    position: fixed;
    bottom: 16px;
    right: 16px;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 10px;
    background: rgba(26, 32, 44, 0.75);
    color: var(--warning-yellow);
    font-size: 22px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(6px);
    z-index: 9999;
    transition: background 0.2s ease, transform 0.15s ease;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
    /* Only show on touch/mobile devices */
    display: none;
}

@media (pointer: coarse) {
    #fullscreen-btn {
        display: flex;
    }
}

#fullscreen-btn:active {
    transform: scale(0.9);
    background: rgba(246, 173, 85, 0.3);
}

/* =========================================
   LANDSCAPE MOBILE — full-screen gameplay
   ========================================= */
@media (orientation: landscape) and (max-height: 500px) {

    body {
        background: #1a202c;
    }

    #game-container {
        width: 100vw;
        height: 100vh;
        padding: 0;
    }

    #game-canvas {
        width: 100vw !important;
        height: 100vh !important;
        max-width: 100vw !important;
        max-height: 100vh !important;
        border-radius: 0;
        box-shadow: none;
    }

    /* Slim compact HUD */
    #top-hud {
        top: 4px;
        width: 100%;
        border-radius: 0;
        padding: 4px 10px;
        gap: 8px;
        flex-direction: row;
        border-left: none;
        border-right: none;
        border-top: none;
    }

    .hud-section {
        width: auto;
        align-items: flex-start !important;
    }

    .hud-value {
        font-size: 14px;
    }

    .hud-label {
        font-size: 8px;
    }

    .sarcastic-msg {
        font-size: 10px;
    }

    /* Duck panel: compact on left side below HUD */
    #duck-panel {
        top: 44px;
        left: 8px;
        right: auto;
        min-width: 100px;
        padding: 6px 8px;
        max-height: calc(100vh - 60px);
        overflow-y: auto;
    }

    .panel-title {
        font-size: 7px;
        margin-bottom: 4px;
    }

    #duck-slots {
        gap: 4px;
    }

    .duck-slot {
        padding: 4px;
    }

    .duck-icon {
        width: 20px;
        height: 20px;
        font-size: 11px;
    }

    .duck-name {
        font-size: 9px;
    }

    /* Launch info: compact bottom-left */
    #launch-info {
        bottom: 8px;
        left: 8px;
        top: auto;
        padding: 6px 8px;
        min-width: 90px;
    }

    .info-row {
        font-size: 9px;
        gap: 6px;
        margin-bottom: 4px;
    }

    /* Screen dialogs: compact for landscape */
    .screen-content {
        padding: 16px 20px;
        max-width: 85vw;
        max-height: 90vh;
        overflow-y: auto;
    }

    .game-title {
        font-size: 36px;
        margin-bottom: 6px;
    }

    .game-subtitle {
        font-size: 13px;
        margin-bottom: 16px;
    }

    .screen-title {
        font-size: 26px;
        margin-bottom: 10px;
    }

    .stars {
        font-size: 30px;
        margin: 10px 0;
    }

    .stats {
        margin: 10px 0;
        padding: 10px;
    }

    .stat-row {
        font-size: 13px;
        padding: 6px 0;
    }

    .btn {
        padding: 10px 24px;
        font-size: 13px;
        min-height: 40px;
    }

    .btn-group {
        margin-top: 14px;
        gap: 10px;
    }

    .menu-info {
        margin-top: 14px;
        padding-top: 12px;
    }

    #fullscreen-btn {
        bottom: 8px;
        right: 8px;
        width: 36px;
        height: 36px;
        font-size: 18px;
    }
}