* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent; /* Remove tap highlight on mobile */
}

body {
    font-family: 'Courier New', monospace;
    background: #0a0e14;
    color: #00ff00;
    overflow: hidden;
    height: 100vh;
    position: fixed;
    width: 100%;
    /* Prevent text selection on buttons */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Allow text selection in terminal */
.terminal, .terminal * {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

.container {
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 20px;
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
    overflow: hidden;
}

.terminal {
    flex: 1;
    min-height: 0;
    max-height: calc(100vh - 200px);
    background: #000;
    border: 2px solid #00ff00;
    border-radius: 4px;
    padding: 20px;
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: 0 0 20px rgba(0, 255, 0, 0.3);
    margin-bottom: 20px;
    position: relative;
    cursor: pointer;
}

.terminal::before {
    content: 'SIGNALS IN THE VOID - TERMINAL ACCESS v2.4.1';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 5px 20px;
    background: #00ff00;
    color: #000;
    font-weight: bold;
    font-size: 12px;
}

.terminal-output {
    padding-top: 30px;
    padding-bottom: 20px;
    min-height: 300px;
}

.line {
    margin-bottom: 8px;
    line-height: 1.5;
    animation: fadeIn 0.3s;
}

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

.line.system {
    color: #00aaff;
}

.line.entity {
    color: #ff00ff;
}

.line.player {
    color: #ffff00;
}

.line.memory {
    color: #ff8800;
    font-weight: bold;
}

.line.error {
    color: #ff0000;
}

.line.success {
    color: #00ff88;
}

.typing {
    display: inline-block;
}

.typing::after {
    content: '▋';
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

.choices {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.choice-btn {
    background: #001a00;
    border: 2px solid #00ff00;
    color: #00ff00;
    padding: 12px 20px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    border-radius: 4px;
}

.choice-btn:hover {
    background: #00ff00;
    color: #000;
    box-shadow: 0 0 10px rgba(0, 255, 0, 0.5);
}

.choice-btn.memory {
    border-color: #ff8800;
    color: #ff8800;
}

.choice-btn.memory:hover {
    background: #ff8800;
    color: #000;
}

.choice-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.stats {
    display: flex;
    gap: 30px;
    font-size: 12px;
    color: #00ff00;
    padding: 10px;
    background: #001a00;
    border: 1px solid #00ff00;
    border-radius: 4px;
}

.endings-stat, .settings-stat {
    cursor: pointer;
    transition: all 0.2s;
}

.endings-stat:hover, .settings-stat:hover {
    color: #ffff00;
    text-shadow: 0 0 5px rgba(255, 255, 0, 0.5);
    transform: scale(1.1);
}

.settings-stat {
    font-size: 16px;
}

.terminal-input-line {
    display: flex;
    align-items: center;
    margin-top: 10px;
}

.prompt {
    color: #00ff00;
    margin-right: 8px;
}

.terminal-input {
    flex: 1;
    background: transparent;
    border: none;
    color: #00ff00;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    outline: none;
}

/* Scrollbar styling */
.terminal::-webkit-scrollbar {
    width: 10px;
}

.terminal::-webkit-scrollbar-track {
    background: #000;
}

.terminal::-webkit-scrollbar-thumb {
    background: #00ff00;
    border-radius: 5px;
}

.terminal::-webkit-scrollbar-thumb:hover {
    background: #00ff88;
}

/* Endings Gallery */
.endings-gallery {
    background: #000;
    border: 2px solid #00ff00;
    border-radius: 4px;
    padding: 20px;
    margin-bottom: 20px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    box-shadow: 0 0 20px rgba(0, 255, 0, 0.3);
}

.gallery-header {
    text-align: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #00ff00;
}

.gallery-header h2 {
    color: #00ff00;
    margin: 0 0 10px 0;
    font-size: 24px;
    letter-spacing: 2px;
}

.gallery-header p {
    color: #00ff88;
    margin: 0;
    font-size: 14px;
}

.endings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.ending-card {
    background: #001a00;
    border: 2px solid #00ff00;
    border-radius: 4px;
    padding: 15px;
    transition: all 0.3s;
}

.ending-card.unlocked {
    cursor: default;
}

.ending-card.unlocked:hover {
    background: #002200;
    box-shadow: 0 0 10px rgba(0, 255, 0, 0.3);
    transform: translateY(-2px);
}

.ending-card.locked {
    opacity: 0.4;
    border-color: #004400;
}

.ending-number {
    color: #00ff00;
    font-weight: bold;
    font-size: 18px;
    margin-bottom: 8px;
}

.ending-card.locked .ending-number {
    color: #004400;
}

.ending-name {
    color: #00ff88;
    font-weight: bold;
    font-size: 14px;
    margin-bottom: 8px;
    min-height: 20px;
}

.ending-card.locked .ending-name {
    color: #004400;
}

.ending-hint {
    color: #00aa66;
    font-size: 11px;
    font-style: italic;
    line-height: 1.4;
}

.ending-card.locked .ending-hint {
    color: #003300;
}

.endings-gallery > .choice-btn {
    width: 100%;
    max-width: 300px;
    margin: 20px auto 0;
    display: block;
}

.endings-gallery::-webkit-scrollbar {
    width: 10px;
}

.endings-gallery::-webkit-scrollbar-track {
    background: #000;
}

.endings-gallery::-webkit-scrollbar-thumb {
    background: #00ff00;
    border-radius: 5px;
}

.endings-gallery::-webkit-scrollbar-thumb:hover {
    background: #00ff88;
}

/* Enhanced Gallery Styles */
.ending-card.unlocked {
    cursor: pointer !important;
    position: relative;
}

.ending-click-hint {
    font-size: 10px;
    color: #00aa66;
    margin-top: 8px;
    opacity: 0;
    transition: opacity 0.3s;
}

.ending-card.unlocked:hover .ending-click-hint {
    opacity: 1;
}

.locked-text {
    color: #333 !important;
}

/* Ending Detail Modal */
.ending-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.3s;
}

.ending-modal {
    background: #000;
    border: 3px solid #00ff00;
    border-radius: 8px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 0 30px rgba(0, 255, 0, 0.5);
    animation: slideIn 0.3s;
}

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    padding: 20px;
    text-align: center;
    font-weight: bold;
}

.modal-header h2 {
    margin: 0;
    font-size: 20px;
    letter-spacing: 2px;
}

.modal-body {
    padding: 30px;
    color: #00ff88;
}

.modal-hint {
    color: #ffff00;
    font-size: 16px;
    margin-bottom: 20px;
    text-align: center;
}

.modal-synopsis {
    color: #00ff88;
    font-size: 15px;
    line-height: 1.8;
    margin-bottom: 20px;
    text-align: justify;
}

.modal-stats {
    color: #00aaff;
    font-size: 13px;
    text-align: center;
    font-style: italic;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #00ff0033;
}

.ending-modal .choice-btn {
    margin: 20px;
    width: calc(100% - 40px);
}

.ending-modal::-webkit-scrollbar {
    width: 8px;
}

.ending-modal::-webkit-scrollbar-track {
    background: #000;
}

.ending-modal::-webkit-scrollbar-thumb {
    background: #00ff00;
    border-radius: 4px;
}

.ending-modal::-webkit-scrollbar-thumb:hover {
    background: #00ff88;
}

/* Main Menu */
.main-menu {
    background: #000;
    border: 2px solid #00ff00;
    border-radius: 4px;
    padding: 40px;
    max-width: 600px;
    margin: 20px auto;
    box-shadow: 0 0 20px rgba(0, 255, 0, 0.3);
}

.menu-header {
    text-align: center;
    margin-bottom: 40px;
    padding-bottom: 30px;
    border-bottom: 2px solid #00ff00;
}

.menu-header h1 {
    color: #00ff00;
    font-size: 32px;
    letter-spacing: 4px;
    margin: 0 0 20px 0;
    text-shadow: 0 0 10px rgba(0, 255, 0, 0.5);
}

.menu-tagline {
    color: #00ff88;
    font-size: 14px;
    font-style: italic;
    margin: 0;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 30px;
}

.menu-btn {
    background: #001a00;
    border: 2px solid #00ff00;
    color: #00ff00;
    padding: 15px 20px;
    font-family: 'Courier New', monospace;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    border-radius: 4px;
    font-weight: bold;
}

.menu-btn:hover {
    background: #00ff00;
    color: #000;
    box-shadow: 0 0 15px rgba(0, 255, 0, 0.5);
    transform: translateY(-2px);
}

.menu-btn.continue-btn {
    border-color: #ffff00;
    color: #ffff00;
    animation: pulse 2s infinite;
}

.menu-btn.continue-btn:hover {
    background: #ffff00;
    color: #000;
    box-shadow: 0 0 15px rgba(255, 255, 0, 0.5);
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 5px rgba(255, 255, 0, 0.3);
    }
    50% {
        box-shadow: 0 0 15px rgba(255, 255, 0, 0.6);
    }
}

.menu-btn.reset-btn {
    border-color: #ff4444;
    color: #ff4444;
    margin-top: 10px;
}

.menu-btn.reset-btn:hover {
    background: #ff4444;
    color: #000;
    box-shadow: 0 0 15px rgba(255, 68, 68, 0.5);
}

.menu-stats {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 20px;
    background: #001a00;
    border: 1px solid #00ff00;
    border-radius: 4px;
    color: #00ff88;
    font-size: 14px;
    text-align: center;
}

.menu-stats div {
    padding: 5px;
}

/* Save & Quit button in choices */
.save-quit-btn {
    background: #1a1a00;
    border: 2px solid #ffff00;
    color: #ffff00;
}

.save-quit-btn:hover {
    background: #ffff00;
    color: #000;
}

/* Save Slot Menu */
.save-slot-menu {
    background: #000;
    border: 2px solid #00ff00;
    border-radius: 4px;
    padding: 30px;
    max-width: 800px;
    margin: 20px auto;
    box-shadow: 0 0 20px rgba(0, 255, 0, 0.3);
}

.save-slots {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 20px;
}

.save-slot {
    background: #001a00;
    border: 2px solid #00ff00;
    border-radius: 4px;
    padding: 15px;
    transition: all 0.2s;
}

.save-slot.empty {
    border-color: #004400;
    opacity: 0.6;
}

.save-slot:hover {
    box-shadow: 0 0 10px rgba(0, 255, 0, 0.3);
}

.slot-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid #00ff0033;
}

.slot-number {
    color: #00ff00;
    font-weight: bold;
    font-size: 14px;
}

.slot-actions {
    display: flex;
    gap: 10px;
}

.slot-action-btn {
    background: #001a00;
    border: 2px solid #00ff00;
    color: #00ff00;
    padding: 6px 12px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    border-radius: 3px;
}

.slot-action-btn:hover {
    background: #00ff00;
    color: #000;
    box-shadow: 0 0 8px rgba(0, 255, 0, 0.5);
}

.slot-action-btn.delete {
    border-color: #ff4444;
    color: #ff4444;
}

.slot-action-btn.delete:hover {
    background: #ff4444;
    color: #000;
}

.slot-action-btn.overwrite {
    border-color: #ffaa00;
    color: #ffaa00;
}

.slot-action-btn.overwrite:hover {
    background: #ffaa00;
    color: #000;
}

.slot-content {
    color: #00ff88;
    font-size: 13px;
}

.slot-content.empty-slot {
    text-align: center;
    padding: 20px;
    color: #004400;
}

.slot-content.empty-slot p {
    margin-bottom: 15px;
}

.save-name {
    font-size: 16px;
    font-weight: bold;
    color: #00ff00;
    margin-bottom: 8px;
}

.save-timestamp {
    font-size: 11px;
    color: #00aa66;
    margin-bottom: 10px;
}

.save-stats {
    display: flex;
    gap: 15px;
    margin-bottom: 8px;
    font-size: 12px;
}

.save-stats span {
    color: #00ff88;
}

.save-scene {
    font-size: 12px;
    color: #ffff00;
    font-style: italic;
    margin-top: 8px;
}

/* Help Screen */
.help-screen, .settings-screen, .stats-screen {
    background: #000;
    border: 2px solid #00ff00;
    border-radius: 4px;
    padding: 30px;
    max-width: 800px;
    margin: 20px auto;
    box-shadow: 0 0 20px rgba(0, 255, 0, 0.3);
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}

.help-content, .settings-content, .stats-content {
    color: #00ff88;
    margin-bottom: 20px;
}

.help-section, .stats-section, .badges-section {
    background: #001a00;
    border: 1px solid #00ff0033;
    border-radius: 4px;
    padding: 20px;
    margin-bottom: 15px;
}

.help-section h3, .stats-section h3, .badges-section h3 {
    color: #00ff00;
    margin: 0 0 15px 0;
    font-size: 18px;
}

.help-section p {
    margin: 8px 0;
    line-height: 1.6;
}

.help-section p strong {
    color: #ffff00;
}

/* Settings Screen */
.setting-item {
    background: #001a00;
    border: 1px solid #00ff0033;
    border-radius: 4px;
    padding: 20px;
    margin-bottom: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.setting-item.danger {
    border-color: #ff444433;
}

.setting-label h3 {
    color: #00ff00;
    margin: 0 0 8px 0;
    font-size: 16px;
}

.setting-label p {
    color: #00aa66;
    margin: 0;
    font-size: 13px;
}

.setting-control {
    flex-shrink: 0;
}

.setting-btn {
    background: #001a00;
    border: 2px solid #00ff00;
    color: #00ff00;
    padding: 10px 25px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    border-radius: 4px;
    min-width: 80px;
}

.setting-btn:hover {
    background: #00ff00;
    color: #000;
}

.setting-btn.active {
    background: #00ff00;
    color: #000;
}

.setting-btn.danger {
    border-color: #ff4444;
    color: #ff4444;
}

.setting-btn.danger:hover {
    background: #ff4444;
    color: #000;
}

.setting-info {
    color: #00ff88;
    font-size: 13px;
}

.setting-info p {
    margin: 5px 0;
}

.speed-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.speed-btn {
    min-width: 70px;
    padding: 8px 15px;
    font-size: 12px;
}

/* Stats Screen */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.stat-box {
    background: #002200;
    border: 2px solid #00ff0033;
    border-radius: 4px;
    padding: 20px;
    text-align: center;
}

.stat-box.highlight {
    border-color: #ffff00;
    background: #1a1a00;
}

.stat-value {
    color: #00ff00;
    font-size: 32px;
    font-weight: bold;
    margin-bottom: 8px;
}

.stat-box.highlight .stat-value {
    color: #ffff00;
}

.stat-label {
    color: #00aa66;
    font-size: 12px;
    text-transform: uppercase;
}

.badges-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.badge-card {
    background: #002200;
    border: 2px solid #00ff0033;
    border-radius: 4px;
    padding: 20px;
    text-align: center;
    transition: all 0.3s;
}

.badge-card.earned {
    border-color: #00ff00;
    background: #001a00;
}

.badge-card.locked {
    opacity: 0.4;
}

.badge-icon {
    font-size: 48px;
    margin-bottom: 10px;
}

.badge-name {
    color: #00ff00;
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 8px;
}

.badge-card.locked .badge-name {
    color: #004400;
}

.badge-desc {
    color: #00aa66;
    font-size: 12px;
}

.badge-card.locked .badge-desc {
    color: #003300;
}

/* Mobile Optimizations */
@media (max-width: 768px) {
    body {
        position: fixed;
        overflow: hidden;
        height: 100vh;
        width: 100%;
    }

    .container {
        height: 100vh;
        min-height: 100vh;
        padding: 10px;
        overflow: hidden;
    }

    .terminal {
        margin-bottom: 15px;
        padding: 15px;
        font-size: 14px;
        max-height: calc(100vh - 250px);
        min-height: 300px;
    }

    .terminal::before {
        font-size: 10px;
        padding: 3px 15px;
    }

    .line {
        margin-bottom: 10px;
        line-height: 1.6;
    }

    /* Larger, more touch-friendly buttons */
    .choice-btn {
        padding: 15px 20px;
        font-size: 16px;
        min-height: 50px;
        border-width: 3px;
    }

    .choice-btn:active {
        transform: scale(0.98);
    }

    /* Stats bar - vertical on mobile */
    .stats {
        flex-direction: column;
        gap: 8px;
        font-size: 11px;
        padding: 8px;
    }

    /* Main menu */
    .main-menu {
        padding: 20px;
        margin: 10px;
    }

    .menu-header h1 {
        font-size: 24px;
        letter-spacing: 2px;
    }

    .menu-tagline {
        font-size: 12px;
    }

    .menu-btn {
        padding: 18px 20px;
        font-size: 18px;
        min-height: 60px;
    }

    /* Save slots */
    .save-slot-menu {
        padding: 15px;
        margin: 10px;
    }

    .save-slot {
        padding: 12px;
    }

    .slot-action-btn {
        padding: 8px 14px;
        font-size: 13px;
        min-height: 40px;
    }

    /* Endings gallery */
    .endings-gallery {
        padding: 15px;
        max-height: none;
    }

    .endings-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 12px;
    }

    .ending-card {
        padding: 12px;
    }

    /* Modal */
    .ending-modal {
        width: 95%;
        max-height: 90vh;
    }

    .modal-body {
        padding: 20px;
    }

    /* Help, Settings, Stats screens */
    .help-screen, .settings-screen, .stats-screen {
        padding: 15px;
        margin: 10px;
        max-height: calc(100vh - 20px);
    }

    .help-section, .stats-section, .badges-section {
        padding: 15px;
    }

    .help-section h3, .stats-section h3, .badges-section h3 {
        font-size: 16px;
    }

    .setting-item {
        flex-direction: column;
        align-items: flex-start;
        padding: 15px;
    }

    .setting-control {
        width: 100%;
    }

    .setting-btn {
        width: 100%;
    }

    .speed-buttons {
        width: 100%;
    }

    .speed-btn {
        flex: 1;
        min-width: 60px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .stat-box {
        padding: 15px;
    }

    .stat-value {
        font-size: 24px;
    }

    .badges-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    /* Prevent zoom on input focus */
    input, select, textarea, button {
        font-size: 16px !important;
    }
}

/* Very small screens */
@media (max-width: 400px) {
    .terminal {
        padding: 10px;
        font-size: 13px;
    }

    .choice-btn {
        padding: 12px 15px;
        font-size: 15px;
    }

    .menu-header h1 {
        font-size: 20px;
    }

    .endings-grid {
        grid-template-columns: 1fr;
    }

    .save-stats {
        flex-direction: column;
        gap: 5px;
    }
}

/* Landscape mobile */
@media (max-width: 900px) and (orientation: landscape) {
    .terminal {
        max-height: 50vh;
    }

    .container {
        max-width: 100%;
    }
}

/* Touch device specific improvements */
@media (hover: none) and (pointer: coarse) {
    /* Larger tap targets */
    .choice-btn, .menu-btn, .slot-action-btn {
        min-height: 48px; /* iOS recommendation */
    }

    /* Remove hover effects on touch devices */
    .choice-btn:hover,
    .menu-btn:hover,
    .ending-card.unlocked:hover {
        transform: none;
        box-shadow: none;
    }

    /* Active state instead */
    .choice-btn:active,
    .menu-btn:active {
        background: #00ff00;
        color: #000;
    }
}

/* Splash Screen */
.splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #0a0e14;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    cursor: pointer;
    animation: fadeIn 0.5s;
}

.splash-ascii {
    color: #00ff00;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.2;
    text-align: left;
    margin: 0;
    padding: 20px;
    text-shadow: 0 0 10px rgba(0, 255, 0, 0.5);
}

.splash-continue {
    animation: blinkSlow 1.5s infinite;
}

@keyframes blinkSlow {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0.3; }
}

/* Mobile responsive splash screen */
@media (max-width: 768px) {
    .splash-ascii {
        font-size: 8px;
        padding: 10px;
    }
}

@media (max-width: 600px) {
    .splash-ascii {
        font-size: 7px;
        padding: 5px;
    }
}

@media (max-width: 480px) {
    .splash-ascii {
        font-size: 6px;
        padding: 2px;
    }
}

/* Very small screens - ultra compact */
@media (max-width: 400px) {
    .splash-ascii {
        font-size: 5.5px;
        padding: 0;
    }
}
