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

/* iOS safe area support for notched devices */
@supports (padding: max(0px)) {
    body {
        padding-left: max(20px, env(safe-area-inset-left));
        padding-right: max(20px, env(safe-area-inset-right));
        padding-top: max(0px, env(safe-area-inset-top));
        padding-bottom: max(0px, env(safe-area-inset-bottom));
    }
}

body {
    font-family: 'Courier New', monospace;
    background: #2a2520;
    color: #d4c5a0;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    /* Allow scrolling for ship selection */
    overflow-y: auto;
    overflow-x: hidden;
    /* Prevent pull-to-refresh on mobile */
    overscroll-behavior: none;
    /* Prevent text selection during touch interactions */
    -webkit-user-select: none;
    user-select: none;
    padding: 20px;
}

/* Touch action for canvas to prevent browser gestures */
#gameCanvas {
    touch-action: none;
    -webkit-touch-callout: none;
}

.screen {
    display: none;
}

/* Show ship selection by default */
#ship-selection.screen {
    display: block;
}

/* Ship Selection Screen */
#ship-selection {
    max-width: 950px;
    width: 100%;
    padding: 30px;
    background: #3d3528;
    border: 3px solid #8b7355;
    border-radius: 4px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    position: relative;
}

.game-logo {
    display: block;
    max-width: 200px;
    max-height: 80px;
    margin: 0 auto 20px;
    border-radius: 4px;
    border: 2px solid #6b5a48;
    opacity: 0.8;
    filter: sepia(0.3) brightness(0.9);
}

.game-logo-small {
    display: block;
    width: 30px;
    height: 30px;
    border-radius: 3px;
    border: 1px solid #6b5a48;
    opacity: 0.7;
    filter: sepia(0.3) brightness(0.9);
    transition: opacity 0.3s ease;
    flex-shrink: 0;
}

.game-logo-small:hover {
    opacity: 0.9;
}

#ship-selection h2 {
    color: #c9a959;
    font-size: 2rem;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
    text-align: center;
    margin-bottom: 30px;
    border-bottom: 2px solid #6b5a48;
    padding-bottom: 15px;
}

.game-tips {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 2px solid #6b5a48;
    text-align: center;
    color: #a09080;
    font-size: 0.9rem;
    line-height: 1.6;
}

.game-tips p {
    margin: 8px 0;
}

.game-tips strong {
    color: #c9a959;
    font-weight: 600;
}

#ship-options {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: nowrap;
    /* Ensure options are visible and clickable */
    position: relative;
    z-index: 10;
}

.ship-option {
    background: #4a4035;
    border: 2px solid #6b5a48;
    border-radius: 4px;
    padding: 15px 10px 15px 15px;
    width: 295px;
    flex-shrink: 0;
    cursor: pointer;
    transition: all 0.3s ease;
    box-sizing: border-box;
    /* Ensure clickable */
    position: relative;
    z-index: 11;
}

.ship-option:hover {
    border-color: #c9a959;
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(201, 169, 89, 0.3);
}

.beginner-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 70px;
    height: 70px;
    background: linear-gradient(135deg, #8b7355 0%, #6b5a48 50%, #4a4035 100%);
    border: 3px solid #c9a959;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4), inset 0 2px 5px rgba(201, 169, 89, 0.3);
    z-index: 12;
    pointer-events: none;
}

.beginner-badge .badge-text {
    color: #c9a959;
    font-size: 0.65rem;
    font-weight: bold;
    text-align: center;
    line-height: 1.2;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    padding: 0 8px;
    font-family: 'Cinzel Decorative', 'Georgia', serif;
    letter-spacing: 0.5px;
}

.ship-option canvas {
    background: #3d3528;
    border-radius: 4px;
    margin-bottom: 15px;
    border: 1px solid #5a4a3a;
    display: block;
    max-width: 100%;
    /* Allow clicks to pass through to parent */
    pointer-events: none;
    /* Ensure canvas has dimensions */
    width: 260px;
    height: 195px;
}

.ship-option h3 {
    color: #d4c5a0;
    font-size: 1.3rem;
    margin-bottom: 15px;
    text-align: center;
}

.ship-option .stats {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 15px;
}

.ship-option .stat {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
}

.ship-option .stat .label {
    min-width: 50px;
    color: #a0a0a0;
}

.ship-option .stat .bar {
    flex: 1;
    height: 8px;
    background: #2a2520;
    border-radius: 4px;
    overflow: hidden;
}

.ship-option .stat .fill {
    height: 100%;
    background: linear-gradient(90deg, #6a6050, #8a7a65);
    border-radius: 4px;
    transition: width 0.3s ease;
}

/* HP: Green (health/survivability) */
.ship-option .stat .fill.hp {
    background: linear-gradient(90deg, #5a8050, #7aa060);
}

/* Speed: Yellow/amber (fast/agile) */
.ship-option .stat .fill.speed {
    background: linear-gradient(90deg, #a08030, #d0a050);
}

/* Range: Red/orange (firepower reach) */
.ship-option .stat .fill.range {
    background: linear-gradient(90deg, #a05040, #d07050);
}

/* Damage: Purple/magenta (attack power) */
.ship-option .stat .fill.damage {
    background: linear-gradient(90deg, #805070, #a07090);
}

/* Ram: Orange/red for physical impact */
.ship-option .stat .fill.ram {
    background: linear-gradient(90deg, #c06040, #e08050);
}

.ship-option .stat .value {
    min-width: 35px;
    text-align: right;
    font-weight: bold;
    color: #e8e8e8;
}

.ship-option .description {
    font-size: 0.85rem;
    color: #a0a0a0;
    text-align: center;
    line-height: 1.4;
}

/* Game Screen */
#game-container {
    display: none;
    gap: 15px;
    padding: 15px;
    background: #3d3528;
    border: 3px solid #6b5a48;
    border-radius: 4px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    /* Fit within viewport without scroll */
    max-width: calc(100vw - 40px);
    max-height: calc(100vh - 40px);
    overflow: hidden;
}

#game-container.screen {
    display: flex;
}

#canvas-wrapper {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    max-height: 100%;
}

#gameCanvas {
    background: #c4b080;
    border: 3px solid #5a4630;
    border-radius: 4px;
    cursor: crosshair;
    /* Fill the available space while maintaining aspect ratio */
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    display: block;
}

#ui {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 165px;
    max-width: 210px;
    flex-shrink: 0;
}

.whats-new {
    background: #3a3530;
    border: 1px solid #5a5045;
    border-radius: 4px;
    padding: 8px 10px;
    margin-top: 12px;
    font-size: 0.68rem;
    color: #a89878;
    line-height: 1.35;
}

.whats-new-title {
    font-weight: bold;
    color: #c8b890;
    margin-bottom: 5px;
    font-size: 0.72rem;
    border-bottom: 1px solid #5a5045;
    padding-bottom: 3px;
}

.whats-new-list {
    margin: 0;
    padding-left: 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.whats-new-list li {
    list-style: disc;
}

.feedback-section {
    background: #3a3530;
    border: 1px solid #5a5045;
    border-radius: 4px;
    padding: 8px 10px;
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.feedback-title {
    font-weight: bold;
    color: #c8b890;
    font-size: 0.72rem;
    border-bottom: 1px solid #5a5045;
    padding-bottom: 3px;
}

.feedback-input {
    background: #2a2520;
    border: 1px solid #5a5045;
    border-radius: 3px;
    color: #a89878;
    font-size: 0.65rem;
    padding: 4px 6px;
    resize: none;
    font-family: inherit;
    line-height: 1.3;
}

.feedback-input::placeholder {
    color: #6a5a48;
}

.feedback-input:focus {
    outline: none;
    border-color: #8b7355;
}

.feedback-submit {
    background: #5a4a38;
    border: 1px solid #7a6a58;
    border-radius: 3px;
    color: #c8b890;
    font-size: 0.65rem;
    padding: 4px 8px;
    cursor: pointer;
    font-family: inherit;
    align-self: flex-end;
}

.feedback-submit:hover {
    background: #6a5a48;
}

.feedback-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.ui-header {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-bottom: 2px solid #6b5a48;
    padding-bottom: 8px;
}

.ui-header h1 {
    font-size: 0.9rem;
    margin: 0;
    padding: 0;
    border: none;
}

h1 {
    color: #8b7355;
    font-size: 1.5rem;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
    border-bottom: 2px solid #6b5a48;
    padding-bottom: 10px;
}

.ship-info {
    background: #4a4035;
    padding: 8px;
    border-radius: 4px;
    font-size: 0.85rem;
    border: 1px solid #6b5a48;
    color: #d4c5a0;
    text-align: center;
}

#status {
    background: #4a4035;
    padding: 10px;
    border-radius: 4px;
    font-size: 0.78rem;
    border: 1px solid #6b5a48;
    text-align: center;
}

button {
    background: #8b7355;
    color: #1a1a2e;
    border: none;
    padding: 12px 20px;
    font-family: 'Courier New', monospace;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
}

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

button:disabled {
    background: #4a4a5a;
    cursor: not-allowed;
    transform: none;
}

.sound-btn {
    background: #6b5a48;
    padding: 8px 16px;
    font-size: 0.9rem;
}

.sound-btn:hover {
    background: #8b7355;
}

.sound-btn.muted {
    background: #4a4a4a;
    opacity: 0.7;
}

.music-btn {
    background: #6b5a48;
    padding: 8px 16px;
    font-size: 0.9rem;
}

.music-btn:hover {
    background: #8b7355;
}

.music-btn.muted {
    background: #4a4a4a;
    opacity: 0.7;
}

#stats {
    background: #4a4035;
    padding: 10px;
    border-radius: 4px;
    border: 1px solid #6b5a48;
}

#stats > div {
    padding: 5px 0;
    font-size: 0.9rem;
    text-align: center;
}

#stats span {
    color: #4ade80;
    font-weight: bold;
}

/* Enemy Stats - Individual enemy health bars */
.enemy-stats {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 150px;
    overflow-y: auto;
}

.enemy-stat {
    background: #3a3530;
    padding: 6px 8px;
    border-radius: 4px;
    border: 1px solid #5a5045;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.enemy-stat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
}

.enemy-stat-name {
    color: #d4c5a0;
    font-weight: bold;
}

.enemy-stat-hp {
    color: #ff6b6b;
    font-weight: bold;
}

.enemy-stat-bar {
    height: 6px;
    background: #2a2520;
    border-radius: 3px;
    overflow: hidden;
}

.enemy-stat-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease, background-color 0.3s ease;
}

.enemy-stat-fill.high {
    background: linear-gradient(90deg, #5a8050, #7aa060);
}

.enemy-stat-fill.medium {
    background: linear-gradient(90deg, #a08030, #d0a050);
}

.enemy-stat-fill.low {
    background: linear-gradient(90deg, #a05040, #d07050);
}

.enemy-stat-fill.critical {
    background: linear-gradient(90deg, #802030, #c04050);
}

/* Power-up status display */
.power-up-status {
    background: #3a3530;
    padding: 8px 12px;
    border-radius: 4px;
    border: 1px solid #5a5045;
    margin: 5px 0;
}

.power-up-active {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    font-weight: bold;
}

.power-up-icon {
    font-size: 1.2rem;
}

.power-up-name {
    flex: 1;
}

.power-up-turns {
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.8rem;
}

/* Status effects display (stunned, burning) */
.status-effect {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    font-weight: bold;
    margin-top: 4px;
    padding: 4px 8px;
    border-radius: 3px;
    background: rgba(0, 0, 0, 0.2);
}

.status-effect.stunned {
    border-left: 3px solid #888888;
}

.status-effect.burning {
    border-left: 3px solid #ff4500;
}

.status-icon {
    font-size: 1.1rem;
}

.status-name {
    flex: 1;
}

.status-turns {
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.6rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Zoom controls for mobile - hidden by default on desktop */
.mobile-only {
    display: none;
}

/* Visually hidden but crawler-accessible (SEO/GEO) */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.zoom-controls {
    gap: 5px;
    justify-content: center;
    width: 100%;
}

.zoom-btn {
    padding: 8px 12px;
    min-height: 40px;
    min-width: 40px;
    font-size: 1.2rem;
    font-weight: bold;
    flex: 0 0 auto;
}

/* ========================
   MOBILE RESPONSIVE STYLES
   ======================== */

/* Tablet and smaller screens - only on touch devices */
@media (max-width: 1024px) and (hover: none), (max-width: 1024px) and (pointer: coarse) {
    body {
        padding: 10px;
    }

    #ship-selection {
        max-width: 100%;
        padding: 20px;
        margin: 10px auto;
    }

    #ship-options {
        flex-wrap: wrap;
        gap: 15px;
        justify-content: center;
    }

    .ship-option {
        width: calc(50% - 10px);
        min-width: 260px;
        max-width: 320px;
    }

    .beginner-badge {
        width: 60px;
        height: 60px;
        top: 8px;
        right: 8px;
        border-width: 2px;
    }

    .beginner-badge .badge-text {
        font-size: 0.55rem;
        padding: 0 6px;
    }

    /* Show mobile elements on tablets */
    .mobile-only {
        display: flex;
    }

    /* Game screen adjustments for tablets */
    #game-container {
        max-width: 100vw;
        max-height: calc(100vh - 20px);
        padding: 10px;
        gap: 10px;
    }

    #canvas-wrapper {
        max-width: calc(100vw - 220px);
        max-height: calc(100vh - 40px);
        flex: 1;
    }

    #gameCanvas {
        max-width: 100%;
        max-height: 100%;
        width: auto;
        height: auto;
    }

    #ui {
        min-width: 180px;
        max-width: 220px;
        overflow-x: visible;
        flex-shrink: 0;
    }

    /* Tablet-specific: scale down UI text slightly to fit */
    #ui .ui-header h1 {
        font-size: 0.8rem;
    }

    #ui .ship-info {
        font-size: 0.75rem;
    }

    #ui #status {
        font-size: 0.72rem;
        padding: 8px;
        text-align: center;
    }

    #ui button {
        padding: 10px 16px;
        font-size: 0.9rem;
    }

    #ui .sound-btn {
        font-size: 0.85rem;
        padding: 8px 12px;
    }

    #ui .music-btn {
        font-size: 0.85rem;
        padding: 8px 12px;
    }

    .whats-new {
        font-size: 0.63rem;
        padding: 6px 8px;
    }

    .feedback-section {
        padding: 6px 8px;
        font-size: 0.62rem;
    }
}

/* Mobile portrait (phones) - only on touch devices */
@media (max-width: 768px) and (hover: none), (max-width: 768px) and (pointer: coarse),
       (max-width: 768px) and (-webkit-touch-callout: none) {
    body {
        align-items: flex-start;
        padding: 0;
        min-height: 100svh;
        min-height: 100vh;
    }

    /* Ship Selection Screen - Mobile */
    #ship-selection {
        padding: 15px;
        margin: 0;
    }

    #ship-selection h2 {
        font-size: 1.5rem;
        margin-bottom: 20px;
    }

    #ship-options {
        flex-direction: column;
        align-items: center;
        gap: 15px;
    }

    .ship-option {
        width: 100%;
        max-width: 100%;
        padding: 15px;
    }

    .ship-option canvas {
        width: 100%;
        height: auto;
        margin: 0 auto;
        display: block;
    }

    .beginner-badge {
        width: 65px;
        height: 65px;
        top: 10px;
        right: 10px;
    }

    .beginner-badge .badge-text {
        font-size: 0.6rem;
    }

    /* Game Screen - Mobile Portrait */
    #game-container {
        flex-direction: column;
        padding: 0;
        gap: 8px;
        width: 100vw;
        max-width: 100vw;
        max-height: none;
        height: 100svh;
        height: 100vh;
        border: none;
        border-radius: 0;
        overflow: visible;
    }

    #canvas-wrapper {
        width: 100%;
        height: auto;
        order: 1;
        max-width: none;
        min-height: 50svh;
        display: flex;
        align-items: center;
        justify-content: center;
        max-height: 70dvh;
        max-height: 70vh;
    }

    #gameCanvas {
        max-width: 100%;
        max-height: 100%;
        width: auto;
        height: auto;
        border-left: none;
        border-right: none;
        border-radius: 0;
    }

    #ui {
        min-width: auto;
        max-width: 100%;
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
        order: 2;
    }

    .ui-header {
        width: 100%;
        justify-content: center;
        padding-bottom: 8px;
        border-bottom: 2px solid #6b5a48;
    }

    .ui-header h1 {
        font-size: 1rem;
    }

    .ship-info {
        flex: 1;
        min-width: 120px;
        font-size: 0.8rem;
        padding: 6px;
    }

    #status {
        width: 100%;
        font-size: 0.85rem;
        padding: 8px;
        text-align: center;
    }

    /* Larger touch targets for mobile */
    button {
        padding: 14px 20px;
        min-height: 48px;
        font-size: 1rem;
        flex: 1;
        min-width: 100px;
    }

    .sound-btn {
        padding: 10px 16px;
        min-width: 80px;
    }

    .music-btn {
        padding: 10px 16px;
        min-width: 80px;
    }

    #stats {
        width: 100%;
        display: flex;
        justify-content: space-around;
        padding: 8px;
    }

    #stats > div {
        font-size: 0.85rem;
        text-align: center;
    }

    .enemy-stats {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
        max-height: 80px;
        gap: 4px;
    }

    .enemy-stat {
        flex: 1;
        min-width: 80px;
        max-width: calc(50% - 4px);
        padding: 4px 6px;
    }

    .enemy-stat-header {
        font-size: 0.7rem;
    }

    .enemy-stat-bar {
        height: 4px;
    }

    .status-turns {
        font-size: 0.55rem;
        padding: 1px 4px;
    }

    #restartBtn {
        width: 100%;
    }

    /* Show zoom controls on mobile */
    .mobile-only {
        display: flex;
    }

    .zoom-controls {
        display: flex;
        flex-direction: row;
        gap: 6px;
        width: 100%;
    }

    .zoom-btn {
        padding: 12px 8px;
        min-height: 44px;
        min-width: 0;
        flex: 1;
        font-size: 1.1rem;
    }

    .whats-new {
        width: 100%;
        flex-basis: 100%;
        margin-top: 0;
        font-size: 0.65rem;
        padding: 7px 10px;
        order: 99;
        display: block;
    }

    .feedback-section {
        width: 100%;
        flex-basis: 100%;
        margin-top: 0;
        order: 100;
        display: block;
    }

    .feedback-input {
        width: 100%;
        box-sizing: border-box;
    }

    .feedback-submit {
        width: auto;
        min-width: 140px;
        align-self: center;
        display: flex;
        align-items: center;
        justify-content: center;
        margin: 0 auto;
        padding: 6px 10px;
        font-size: 0.75rem !important;  /* forces override */
        min-height: 12px;
        max-height: 18px;
        line-height: 1.2;
    }

    /* Center language selector in portrait mode */
    #ui .lang-selector {
        width: 100%;
        display: flex;
        justify-content: center;
        order: 101;
    }

    #ui .lang-dropdown {
        width: auto;
        min-width: 140px;
    }
}

/* Mobile landscape (phones in landscape mode) - only on touch devices */
/* Covers iPhones up to 14 Pro Max (932px width in landscape) */
@media (max-width: 950px) and (orientation: landscape) and (hover: none),
       (max-width: 950px) and (orientation: landscape) and (pointer: coarse),
       (max-width: 950px) and (orientation: landscape) and (-webkit-touch-callout: none) {
    body {
        align-items: center;
        padding: 5px;
        min-height: 100svh;
        min-height: 100vh;
    }

    /* Ship selection in landscape */
    #ship-selection {
        max-width: 100%;
        padding: 15px;
        margin: 5px;
    }

    #ship-selection h2 {
        font-size: 1.4rem;
        margin-bottom: 15px;
    }

    #ship-options {
        flex-direction: row;
        flex-wrap: nowrap;
        gap: 10px;
        justify-content: center;
        align-items: stretch;
    }

    .ship-option {
        width: calc(33.333% - 10px);
        min-width: 200px;
        max-width: 280px;
        padding: 10px;
        display: flex;
        flex-direction: column;
    }

    .ship-option canvas {
        width: 100%;
        height: auto;
        max-height: 140px;
        flex-shrink: 0;
    }

    .beginner-badge {
        width: 50px;
        height: 50px;
        top: 5px;
        right: 5px;
        border-width: 2px;
    }

    .beginner-badge .badge-text {
        font-size: 0.5rem;
        padding: 0 4px;
        line-height: 1.1;
    }

    /* Game screen in landscape */
    #game-container {
        flex-direction: row;
        padding: 8px;
        gap: 8px;
        max-width: 100vw;
        max-height: calc(100vh - 10px);
        width: 100%;
    }

    #canvas-wrapper {
        max-height: calc(100vh - 20px);
        height: auto;
        max-width: calc(100vw - 240px);
        flex: 1 1 auto;
        order: 1;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    #gameCanvas {
        max-width: 100%;
        max-height: 100%;
        width: auto;
        height: auto;
    }

    #ui {
        width: 220px;
        min-width: 200px;
        max-width: 240px;
        flex-direction: column;
        gap: 5px;
        order: 2;
        flex-shrink: 0;
        flex-grow: 0;
        overflow-y: auto;
        max-height: calc(100vh - 20px);
    }

    /* whats-new and feedback in landscape mode */
    #ui .whats-new,
    #ui .feedback-section {
        display: block;
        font-size: 0.58rem;
        padding: 5px;
        margin-top: 5px;
        width: 100%;
        box-sizing: border-box;
    }

    #ui .whats-new-title,
    #ui .feedback-title {
        font-size: 0.62rem;
    }

    #ui .feedback-input {
        font-size: 0.52rem;
        min-height: 35px;
        padding: 3px;
    }

    .ui-header {
        width: 100%;
        padding-bottom: 6px;
    }

    .ui-header h1 {
        font-size: 0.85rem;
    }

    .ship-info {
        width: 100%;
        font-size: 0.75rem;
        padding: 6px;
    }

    #status {
        width: 100%;
        font-size: 0.68rem;
        padding: 6px;
        text-align: center;
    }

    #stats {
        width: 100%;
        padding: 6px;
    }

    #stats > div {
        font-size: 0.75rem;
        text-align: center;
    }

    .enemy-stats {
        max-height: 100px;
        gap: 4px;
    }

    .enemy-stat {
        padding: 4px 6px;
    }

    .enemy-stat-header {
        font-size: 0.7rem;
    }

    .enemy-stat-bar {
        height: 4px;
    }

    .status-turns {
        font-size: 0.55rem;
        padding: 1px 4px;
    }

    button {
        width: 100%;
        padding: 10px 12px;
        min-height: 40px;
        font-size: 0.85rem;
    }

    .sound-btn {
        padding: 8px 12px;
        min-height: 36px;
    }

    .music-btn {
        padding: 8px 12px;
        min-height: 36px;
    }

    .mobile-only {
        display: flex;
    }

    .zoom-controls {
        display: flex;
        flex-direction: row;
        gap: 4px;
        width: 100%;
        justify-content: space-between;
    }

    .zoom-btn {
        padding: 4px 2px;
        min-height: 28px;
        min-width: 0;
        flex: 1;
        font-size: 0.85rem;
        line-height: 1;
    }

    .whats-new {
        font-size: 0.58rem;
        padding: 5px 7px;
        width: 100%;
        box-sizing: border-box;
    }

    .feedback-section {
        padding: 5px 7px;
        width: 100%;
        box-sizing: border-box;
    }

    .feedback-input {
        font-size: 0.6rem;
        width: 100%;
        box-sizing: border-box;
    }

    .feedback-submit {
        font-size: 0.75rem !important;  /* forces override */
        width: 100%;
        min-height: 12px;
        max-height: 16px;
        line-height: 1.2;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Game over screen landscape fixes */
    .game-over-screen {
        align-items: flex-start;
        padding: 10px;
    }

    .game-over-content {
        padding: 20px 25px;
        max-width: 320px;
        margin: auto;
    }

    .game-over-title {
        font-size: 1.8rem;
        letter-spacing: 2px;
        margin: 0 0 15px 0;
    }

    .game-over-score {
        margin: 15px 0;
        padding: 12px;
    }

    .score-value {
        font-size: 2.5rem;
    }

    .game-over-message {
        font-size: 0.9rem;
        margin: 10px 0;
    }

    .game-over-btn {
        font-size: 0.95rem;
        padding: 10px 25px;
        margin-top: 10px;
    }

    .coffee-section {
        margin-top: 15px;
        padding-top: 12px;
    }

    .coffee-text {
        font-size: 0.75rem;
        margin: 0 0 8px 0;
    }
}

/* Small phones */
@media (max-width: 380px) {
    #ship-selection h2 {
        font-size: 1.3rem;
    }

    .ship-option h3 {
        font-size: 1.1rem;
    }

    .ship-option .stat {
        font-size: 0.8rem;
    }

    .beginner-badge {
        width: 55px;
        height: 55px;
    }

    .beginner-badge .badge-text {
        font-size: 0.55rem;
    }

    button {
        padding: 12px 16px;
        font-size: 0.9rem;
    }
}

/* Prevent hover effects on touch devices */
@media (hover: none) {
    .ship-option:hover {
        transform: none;
        box-shadow: none;
    }

    button:hover {
        transform: none;
    }

    /* Add active states for touch feedback */
    .ship-option:active {
        border-color: #c9a959;
        background: #5a5045;
    }

    button:active {
        background: #c9a959;
        transform: scale(0.98);
    }
}

/* Game Over Screen Styles */
.game-over-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(26, 20, 16, 0.95);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    z-index: 100;
    animation: fadeIn 0.5s ease-in;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    padding: 20px 0;
    box-sizing: border-box;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.game-over-content {
    background: linear-gradient(135deg, #2a2520 0%, #1a1410 100%);
    border: 3px solid #8a7a65;
    border-radius: 8px;
    padding: 40px 60px;
    text-align: center;
    box-shadow: 0 0 40px rgba(138, 122, 101, 0.3), inset 0 0 60px rgba(0, 0, 0, 0.5);
    max-width: 400px;
    width: 90%;
    margin: auto;
    flex-shrink: 0;
}

.game-over-title {
    font-family: 'Cinzel Decorative', 'Georgia', serif;
    font-size: 2.5rem;
    color: #c9a959;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    margin: 0 0 30px 0;
    letter-spacing: 4px;
}

.game-over-score {
    margin: 30px 0;
    padding: 20px;
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid #5a5045;
    border-radius: 4px;
}

.score-label {
    display: block;
    font-family: 'Courier New', monospace;
    font-size: 1rem;
    color: #8a7a65;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 10px;
}

.score-value {
    display: block;
    font-family: 'Cinzel Decorative', 'Georgia', serif;
    font-size: 4rem;
    color: #c9a959;
    text-shadow: 0 0 20px rgba(201, 169, 89, 0.5);
    line-height: 1;
}

.game-over-message {
    font-family: 'Courier New', monospace;
    font-size: 1.1rem;
    color: #a09080;
    margin: 20px 0 30px 0;
    font-style: italic;
}

.game-over-btn {
    background: linear-gradient(135deg, #8a7a65 0%, #6a5a45 100%);
    color: #1a1410;
    font-family: 'Cinzel Decorative', 'Georgia', serif;
    font-size: 1.2rem;
    font-weight: bold;
    padding: 15px 40px;
    border: 2px solid #c9a959;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.game-over-btn:hover {
    background: linear-gradient(135deg, #c9a959 0%, #8a7a65 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(201, 169, 89, 0.4);
}

.game-over-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(201, 169, 89, 0.3);
}

/* Mobile adjustments for game over screen */
@media (max-width: 600px) {
    .game-over-content {
        padding: 30px 25px;
    }

    .game-over-title {
        font-size: 2rem;
        letter-spacing: 2px;
    }

    .score-value {
        font-size: 3rem;
    }

    .score-label {
        font-size: 0.9rem;
    }

    .game-over-message {
        font-size: 1rem;
    }

    .game-over-btn {
        font-size: 1rem;
        padding: 12px 30px;
    }
}

/* ========================
   COFFEE / PAYMENT SECTION
   ======================== */

.coffee-section {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid #5a5045;
}

.coffee-text {
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    color: #8a7a65;
    margin: 0 0 12px 0;
    line-height: 1.6;
    font-style: italic;
    text-align: center;
}

.coffee-text br {
    display: block;
    content: "";
    margin-top: 4px;
}

.coffee-btn {
    background: transparent;
    color: #c9a959;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    padding: 8px 20px;
    border: 1px solid #5a5045;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    letter-spacing: 1px;
}

.coffee-btn:hover {
    border-color: #8a7a65;
    color: #d4c5a0;
}

/* Payment Panel Overlay (z-index above game-over-screen's 100) */
.payment-panel {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(26, 20, 16, 0.97);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 101;
    animation: fadeIn 0.25s ease-in;
}

.payment-panel-content {
    background: linear-gradient(135deg, #2a2520 0%, #1a1410 100%);
    border: 3px solid #8a7a65;
    border-radius: 8px;
    padding: 32px 40px;
    width: 90%;
    max-width: 420px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 0 40px rgba(138, 122, 101, 0.3), inset 0 0 60px rgba(0, 0, 0, 0.5);
}

.payment-close-btn {
    position: absolute;
    top: 12px;
    right: 14px;
    background: transparent;
    border: none;
    color: #8a7a65;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
    font-family: 'Courier New', monospace;
    transition: color 0.2s;
    min-height: auto;
    width: auto;
}

.payment-close-btn:hover {
    color: #c9a959;
}

.payment-title {
    font-family: 'Cinzel Decorative', 'Georgia', serif;
    font-size: 1.4rem;
    color: #c9a959;
    margin: 0 0 4px 0;
    letter-spacing: 2px;
    text-align: center;
}

.payment-subtitle {
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    color: #8a7a65;
    text-align: center;
    margin: 0 0 20px 0;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.amount-selector {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 20px;
}

.amount-btn {
    flex: 1;
    padding: 10px 0;
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid #5a5045;
    border-radius: 4px;
    color: #a09080;
    font-family: 'Courier New', monospace;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: auto;
}

.amount-btn:hover {
    border-color: #8a7a65;
    color: #d4c5a0;
}

.amount-btn.active {
    border-color: #c9a959;
    color: #c9a959;
    background: rgba(201, 169, 89, 0.1);
}

/* Stripe Payment Element container */
#payment-element {
    margin-bottom: 20px;
}

.payment-submit-btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #8a7a65 0%, #6a5a45 100%);
    color: #1a1410;
    font-family: 'Cinzel Decorative', 'Georgia', serif;
    font-size: 1rem;
    font-weight: bold;
    border: 2px solid #c9a959;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    min-height: auto;
    letter-spacing: 1px;
}

.payment-submit-btn:hover {
    background: linear-gradient(135deg, #c9a959 0%, #8a7a65 100%);
}

.payment-submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.payment-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(26, 20, 16, 0.3);
    border-top-color: #1a1410;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

.payment-success {
    margin-top: 16px;
    padding: 12px;
    background: rgba(74, 222, 128, 0.1);
    border: 1px solid rgba(74, 222, 128, 0.3);
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    color: #4ade80;
    text-align: center;
}

.payment-error {
    margin-top: 12px;
    padding: 10px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    color: #ef4444;
    text-align: center;
}

/* Mobile adjustments for payment panel */
@media (max-width: 600px) {
    .payment-panel-content {
        padding: 24px 20px;
        max-width: 100%;
        width: 95%;
        max-height: 85vh;
    }

    .payment-title {
        font-size: 1.1rem;
    }

    .amount-btn {
        font-size: 0.9rem;
        padding: 10px 0;
    }

    .coffee-text {
        font-size: 0.8rem;
        line-height: 1.5;
    }

    .coffee-text br {
        margin-top: 2px;
    }

    .coffee-btn {
        min-height: 44px;
        font-size: 0.85rem;
    }

    .payment-close-btn,
    .amount-btn {
        min-height: auto !important;
    }
}

/* =====================================================
   Language Selector Dropdown
   ===================================================== */

.lang-dropdown {
    background: #4a4035;
    color: #d4c5a0;
    border: 1px solid #6b5a48;
    border-radius: 4px;
    padding: 4px 6px;
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    cursor: pointer;
    width: 100%;
}

.lang-dropdown:focus {
    outline: 1px solid #8b7355;
}

.lang-dropdown option {
    background: #3d3528;
    color: #d4c5a0;
}

/* Selection-screen dropdown: absolutely positioned top-right */
#lang-selector-selection {
    position: absolute;
    top: 15px;
    right: 15px;
    z-index: 20;
    width: 120px;
}

/* Game sidebar dropdown */
#ui .lang-selector {
    padding-top: 4px;
}

/* =====================================================
   Long-string layout fixes (German etc.)
   ===================================================== */

/* Prevent long status messages from clipping in 180px sidebar */
#status {
    word-break: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

/* Prevent long stat labels from crushing the bar visualization */
.stat .label {
    white-space: nowrap;
    font-size: 0.8rem;
}

/* =====================================================
   Mobile overrides for language dropdown
   ===================================================== */

@media (max-width: 768px) and (pointer: coarse) {
    #lang-selector-selection {
        position: relative;
        top: auto;
        right: auto;
        width: auto;
        margin: 0 auto 10px;
        display: flex;
        justify-content: center;
    }

    #lang-selector-selection .lang-dropdown {
        width: auto;
        min-width: 140px;
    }
}
