/* --- Mobile Styles --- */

/* Basic Reset & Font */
body {
    background-color: #000;
    color: #00FF41;
    font-family: 'VT323', monospace;
    font-size: 1.1rem;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

/* Hide Desktop Elements */
#app-container
/* #konami-overlay, */ /* <-- NOT hidden, so JS can find it */
/* #color-picker-modal, */ /* <-- NOT hidden, so JS can find it */
/* #captcha-modal */ /* <-- NOT hidden, so JS can find it */
 {
    display: none !important;
}

/* Show Mobile Container */
#mobile-app-container {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    box-sizing: border-box;
}

/* Welcome Message Area */
#mobile-welcome-message {
    padding: 10px 15px;
    background-color: #050505;
    border-bottom: 1px dashed #00FF41;
    text-align: center;
    flex-shrink: 0;
    white-space: pre-wrap;
    font-size: 1rem;
}

/* Command List Styling */
#mobile-commands {
    padding: 8px 15px; /* Adjusted padding */
    background-color: #080808;
    border-bottom: 1px solid #00FF41;
    flex-shrink: 0;
}

#mobile-commands h4 {
    text-align: center;
    color: #8affab;
    border-bottom: 1px dashed #00FF41;
    /* --- FIX: Negative margins to span padding --- */
    margin: 0 -15px 8px -15px;
    padding: 0 15px 8px 15px;
}

/* Main command list style */
#mobile-commands ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 6px; /* Reduced gap */
    justify-content: center;
}

/* --- Button Revamp: Main command row --- */
#mobile-commands ul:first-of-type {
    gap: 8px; /* A bit more gap */
}
#mobile-commands ul:first-of-type li {
    flex-basis: 0; /* Allow flex-grow to work */
    flex-grow: 1;
}
/* --- End Button Revamp --- */


/* Main command button style */
#mobile-commands li {
    padding: 5px 8px; /* Reduced padding */
    border: 1px solid #333;
    background-color: #111;
    color: #AAA;
    cursor: pointer;
    border-radius: 3px;
    transition: background-color 0.2s, color 0.2s, box-shadow 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.0rem; /* Base font size */
}

#mobile-commands li:hover {
    background-color: #333;
    color: #FFF;
    border-color: #555;
    box-shadow: 0 0 8px #00FF41;
}

/* Click glow for all command buttons */
#mobile-commands li:active {
    background-color: #333;
    color: #FFF;
    border-color: #555;
    animation: glow-pulse 1.2s ease-in-out;
}


/* --- Locked Clippy & Edit Mode Command Styles --- */

/* Keyframe animation for the glow */
@keyframes glow-pulse {
  0% { box-shadow: 0 0 8px #00FF41; }
  50% { box-shadow: 0 0 16px #00FF41, 0 0 12px #00FF41 inset; }
  100% { box-shadow: 0 0 8px #00FF41; }
}

/* Class to apply the glow */
.glow-once {
  animation: glow-pulse 1.2s ease-in-out 2 !important;
  border-color: #00FF41 !important;
}

/* Style for the locked list (adds margin-top) */
.mobile-locked-list {
    margin-top: 12px; 
    gap: 3px; /* --- FIX: Tighter gap --- */
}

/* --- FIX: Reduce font size and padding on menu buttons --- */
#mobile-clippy-list li,
#mobile-edit-mode-list li {
    flex-grow: 0.09;
    font-size: 1.1rem; /* Slightly smaller font */
    padding: 4px 5px;   /* Tighter padding */
}

/* Make the "key" buttons match */
#mobile-clippy-list li.clippy-unlock-button,
#mobile-edit-mode-list li.edit-mode-unlock-button {
    flex-grow: 0.09;
    font-size: 1.1rem;
    padding: 4px 5px;
}
/* --- End Fix --- */


/* Style for the [clippy]: and [edit-mode]: buttons */
.mobile-locked-list li.clippy-unlock-button,
.mobile-locked-list li.edit-mode-unlock-button {
    border: 1px solid #333;
    background-color: #111;
    color: #AAA;
    cursor: pointer;
    border-radius: 3px;
    transition: background-color 0.2s, color 0.2s, box-shadow 0.2s, opacity 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0.6; /* Both buttons now start with opacity */
}
.mobile-locked-list li.clippy-unlock-button:hover,
.mobile-locked-list li.edit-mode-unlock-button:hover {
    background-color: #333;
    color: #FFF;
    border-color: #555;
    box-shadow: 0 0 8px #00FF41;
}

/* [edit-mode] button starts locked (opaque) - This rule is now redundant but harmless */
.mobile-locked-list li.edit-mode-unlock-button {
    opacity: 0.6;
}

/* Style for [clippy]: and [edit-mode]: buttons AFTER unlock */
.mobile-locked-list li.unlocked-key {
    background-color: #111;
    color: #555; /* Dim text color */
    border-color: #333;
    cursor: default;
    opacity: 1; /* Ensure unlocked keys are full opacity */
    box-shadow: none !important;
}
.mobile-locked-list li.unlocked-key:hover {
    background-color: #111;
    color: #555;
    box-shadow: none !important;
}


/* Individual locked button style */
.mobile-locked-list li.mobile-locked {
    border: 1px solid #333;
    background-color: #111;
    color: #AAA;
    cursor: not-allowed;
    border-radius: 3px;
    transition: background-color 0.2s, color 0.2s, box-shadow 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0.6;
}

/* Add the padlock image */
.mobile-locked-list li.mobile-locked::before {
    content: '';
    display: inline-block;
    width: 0.8em; /* --- FIX: Smaller padlock --- */
    height: 0.8em; /* --- FIX: Smaller padlock --- */
    margin-right: 3px; /* --- FIX: Adjusted margin --- */
    background-image: url('./images/locket.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    flex-shrink: 0;
}

/* Prevent hover effect on locked buttons */
.mobile-locked-list li.mobile-locked:hover,
.mobile-locked-list li.mobile-locked:active {
    background-color: #111;
    color: #AAA;
    border-color: #333;
    box-shadow: none;
}
/* --- END Locked Styles --- */


/* Output Area Styling */
#mobile-output-area {
    flex-grow: 1;
    padding: 15px;
    box-sizing: border-box;
    overflow-y: auto;
    word-wrap: break-word;
    background-color: #050505;
    -ms-overflow-style: none;
    scrollbar-width: none;
    /* --- FIX: Add padding to bottom to avoid clippy --- */
    padding-bottom: 120px;
}
#mobile-output-area::-webkit-scrollbar {
    display: none;
}

#mobile-output {
    white-space: pre-wrap;
}
#mobile-output div {
    margin-bottom: 0.5em;
}

/* Confirmation Styles */
.confirmation-prompt-container {
    margin-top: 0.5em;
    display: block;
    margin-left: 0;
    padding-left: 0;
}
.confirmation-prompt-container span:first-child {
     margin-right: 5px;
}
.confirm-btn {
    display: inline-block;
    padding: 2px 8px;
    margin: 0 4px;
    border: 1px solid #555;
    background-color: #333;
    color: #AAA;
    cursor: pointer;
    text-decoration: none !important;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s, box-shadow 0.2s;
    border-radius: 3px;
    font-size: 0.9em;
    line-height: 1.2;
    box-shadow: none;
}
.confirm-btn:hover {
    background-color: #555;
    color: #FFF;
    border-color: #888;
    box-shadow: 0 0 8px #00FF41;
}

/* Mobile Clippy Positioning */
.clippy {
    position: fixed !important;
    bottom: 10px !important;
    right: 10px !important;
    left: auto !important;
    top: auto !important;
    z-index: 6000 !important; /* Higher z-index than modals */
    transform: scale(0.8);
}

.clippy-balloon {
    position: fixed !important;
    bottom: 100px !important;
    right: 10px !important;
    top: auto !important;
    left: auto !important;
    z-index: 6000 !important; /* Higher z-index than modals */
    max-width: calc(100vw - 40px);
    transform: translateX(0);
    box-sizing: border-box;
    padding: 10px;
}

/* Hide desktop-only ASCII */
.ascii-padlock {
    display: none;
}

/* --- Konami/Video Overlay Styles --- */
#nedry-overlay, #konami-video-overlay, #clippy-easter-egg-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.85); display: flex;
    justify-content: center; align-items: center; z-index: 1000;
}
/* This is the fullscreen video style */
#konami-video-overlay, #clippy-easter-egg-overlay {
     background-color: #000; z-index: 4000;
}
#nedry-overlay video, #konami-video-overlay video, #clippy-easter-egg-overlay video {
    max-width: 560px; width: 50%; height: auto; border: 3px solid #00FF41;
}
#konami-video-overlay video, #clippy-easter-egg-overlay video {
     max-width: none; width: 100%; height: 100%;
     /* --- FIX: Changed object-fit to contain to prevent cropping --- */
     object-fit: contain; 
     border: none;
}
/* This is the gamepad overlay */
#konami-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.9); display: flex;
    justify-content: center; align-items: center; z-index: 2000;
}
#gamepad {
    width: 300px; height: 130px; background-color: #444; border-radius: 10px;
    border: 2px solid #222; display: flex; align-items: center;
    justify-content: space-around; padding: 0 20px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
    position: relative;
    transform: scale(0.9);
}
.close-button {
    position: absolute; top: 5px; right: 10px; color: #aaa;
    font-size: 1.5em; cursor: pointer; transition: color 0.2s;
}
.close-button:hover { color: #00FF41; }
.d-pad { position: relative; width: 60px; height: 60px; }
.d-pad .arrow { position: absolute; background: #222; }
.d-pad .up, .d-pad .down { width: 20px; height: 20px; left: 20px; }
.d-pad .left, .d-pad .right { width: 20px; height: 20px; top: 20px; }
.d-pad .up { top: 0; }
.d-pad .down { bottom: 0; }
.d-pad .left { left: 0; }
.d-pad .right { right: 0; }
.d-pad .center-pad { position: absolute; width: 20px; height: 20px; top: 20px; left: 20px; background: #333; }
.action-buttons {
    display: flex; gap: 10px; position: absolute;
    bottom: 10px; left: 50%; transform: translateX(-50%);
}
.button-group { display: flex; flex-direction: column; align-items: center; }
.button-label { font-size: 0.7em; color: #aaa; margin-bottom: 2px; }
.button.select, .button.start { width: 30px; height: 15px; background: #222; border-radius: 10px; }
.face-buttons { display: flex; align-items: center; gap: 10px; }
.face-buttons .button { width: 40px; height: 40px; border-radius: 50%; color: white; display: flex; justify-content: center; align-items: center; font-weight: bold; border: 2px solid #222; }
.b-button { background-color: #d9534f; }
.a-button { background-color: #428bca; }
#gamepad .d-pad .arrow, #gamepad .action-buttons .button, #gamepad .face-buttons .button {
    cursor: pointer; transition: all 0.1s ease-in-out;
}
#gamepad .d-pad .arrow:hover, #gamepad .action-buttons .button:hover, #gamepad .face-buttons .button:hover {
    box-shadow: 0 0 12px #00FF41;
}
#gamepad .d-pad .arrow:active, #gamepad .action-buttons .button:active, #gamepad .face-buttons .button:active {
    transform: scale(0.92); box-shadow: 0 0 5px #00FF41;
}
/* --- END Konami Styles --- */


/* Modal Styles (Based on style.css) */
.modal {
    position: fixed;
    left: 0; top: 0; width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 5000;
    color: #00FF41;
    font-family: 'VT323', monospace;
    padding: 15px;
    box-sizing: border-box;
}
#email-modal { z-index: 5400; }
#captcha-modal { z-index: 5500; }
#color-picker-modal { z-index: 5600; }


.modal-content, .email-modal-content, .captcha-modal-content {
    background-color: #050505;
    padding: 15px 20px;
    border: 1px solid #00FF41;
    width: 95%;
    max-width: 450px;
    text-align: center;
    box-shadow: 0 0 20px rgba(0, 255, 65, 0.5);
    max-height: 90vh;
    overflow-y: auto;
}

.email-modal-content {
    text-align: left;
}
.captcha-modal-content {
    max-width: 400px; /* Copied from style.css */
}


.modal-content h4, .email-modal-content h4, .captcha-modal-content h4 {
    margin-top: 0;
    border-bottom: 1px solid #00FF41;
    padding-bottom: 8px;
    color: #8affab;
    text-align: center;
    margin-bottom: 15px;
    font-size: 1.1rem;
}

/* Email Form Styles */
.email-form { }
.email-form label {
    display: block;
    margin-bottom: 12px;
    color: #8affab;
    font-size: 1rem;
}
.email-form input[type="email"],
.email-form input[type="text"],
.email-form textarea,
.email-form select {
    display: block;
    width: 100%;
    background-color: #111;
    border: 1px solid #444;
    color: #00FF41;
    font-family: inherit;
    font-size: 1rem;
    padding: 6px 9px;
    margin-top: 4px;
    box-sizing: border-box;
}
.email-form select {
     appearance: none;
     background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%2M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22/%3E%3C/svg%3E');
     background-repeat: no-repeat;
     background-position: right .7em top 50%;
     background-size: .65em auto;
     padding-right: 2em;
     cursor: pointer;
}
.email-form .subject-other {
     display: none !important;
}

.email-form textarea {
    min-height: 100px;
    resize: vertical;
}
.char-counter {
    display: block;
    text-align: right;
    font-size: 0.8em;
    color: #888;
    margin-top: 2px;
}
.char-counter.warning {
    color: #FF4136;
    font-weight: bold;
}

.modal-controls {
    display: flex;
    justify-content: space-around;
    margin-top: 20px;
    gap: 10px;
    flex-wrap: wrap;
}

.email-form button {
    background-color: #333;
    color: #AAA;
    border: 1px solid #555;
    padding: 8px 18px;
    cursor: pointer;
    font-family: inherit;
    font-size: 1rem;
    transition: background-color 0.2s, color 0.2s, box-shadow 0.2s, transform 0.1s ease;
    border-radius: 3px;
    box-shadow: none;
    transform: scale(1); /* Base scale */
}
.email-form button:hover:not(:disabled) {
    background-color: #555;
    color: #FFF;
    box-shadow: none; /* Removed hover glow */
}
.email-form button:active:not(:disabled) {
    animation: glow-pulse 1.2s ease-in-out; /* Add click glow animation */
    transform: scale(0.98); /* Add press effect */
}
.email-form button:disabled {
    background-color: #222;
    color: #555;
    border-color: #333;
    cursor: not-allowed;
    box-shadow: none;
    transform: scale(1);
}
#email-cancel-button {
    background-color: #442222;
    border-color: #663333;
}
#email-cancel-button:hover {
     background-color: #663333;
     border-color: #884444;
}

.form-status {
    margin-top: 15px;
    font-style: italic;
    text-align: center;
    min-height: 1.2em;
    font-size: 0.9rem;
}
.form-status.success { color: #8affab; }
.form-status.error { color: #FF4136; }


/* --- Color Picker Styles (from style.css) --- */
#color-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr); /* Force 3 columns */
    gap: 10px; /* Smaller gap for mobile */
    justify-content: center;
    margin: 15px 0;
    max-width: 300px;
    margin-left: auto;
    margin-right: auto;
}
.color-button {
    display: flex;
    flex-direction: column;
    align-items: center;
    border: 1px solid #555;
    background-color: transparent;
    padding: 5px;
    cursor: pointer;
    transition: transform 0.1s ease-out, box-shadow 0.2s;
    color: #AAA;
}
.color-swatch {
    width: 40px;
    height: 40px;
    border: 1px solid #333;
    margin-bottom: 5px;
}
.color-name {
    font-size: 0.9em;
    white-space: normal;
    text-align: center;
    max-width: 70px;
    line-height: 1.1;
}
.color-button:hover {
    transform: scale(1.05);
    box-shadow: 0 0 10px #00FF41;
    color: #00FF41;
    border-color: #00FF41;
}
#color-picker-cancel {
    background-color: #333;
    color: #AAA;
    border: 1px solid #555;
    padding: 8px 15px;
    cursor: pointer;
    margin-top: 10px;
    font-family: inherit;
    font-size: 1rem;
    transition: background-color 0.2s, color 0.2s, box-shadow 0.2s, transform 0.1s ease;
    transform: scale(1);
}
#color-picker-cancel:hover {
    background-color: #555;
    color: #FFF;
    box-shadow: none; /* Removed hover glow */
}
#color-picker-cancel:active {
    animation: glow-pulse 1.2s ease-in-out; /* Add click glow animation */
    transform: scale(0.98); /* Add press effect */
}


/* --- CAPTCHA Styles (from style.css) --- */
#captcha-prompt {
    margin-bottom: 15px;
    font-size: 1.1em;
}

#captcha-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.captcha-image-container {
    position: relative;
    border: 2px solid #555;
    cursor: pointer;
    transition: transform 0.1s ease-out, box-shadow 0.2s ease-out;
    overflow: hidden;
    aspect-ratio: 1 / 1;
    background-color: #000; /* Dark bg for letterboxing */
}
.captcha-image-container img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover; /* Cover the area, may crop slightly */
}
.captcha-image-container:hover {
    box-shadow: 0 0 10px #00FF41;
    border-color: #00FF41;
}

.captcha-image-container.selected {
    transform: scale(0.95);
    border-color: #8affab;
    box-shadow: 0 0 15px #8affab;
}

.captcha-image-container.selected::after {
    content: '✔';
    position: absolute;
    bottom: 5px;
    right: 5px;
    font-size: 1.5em;
    color: #00FF41;
    background-color: rgba(0, 0, 0, 0.6);
    border-radius: 50%;
    padding: 0 4px;
    line-height: 1;
    text-shadow: 1px 1px 2px black;
}

/* Container for Status Messages */
#captcha-status-messages {
    min-height: 1.5em; /* Reserve space */
    margin-bottom: 15px; /* Space between status and buttons */
    text-align: center; /* Center status text */
}

#captcha-loading {
    font-style: italic;
    color: #AAA;
}
#captcha-result {
    font-weight: bold;
}
#captcha-result.success {
    color: #8affab;
}
#captcha-result.error {
    color: #FF4136;
}

/* Centered CAPTCHA Buttons */
#captcha-controls {
    display: flex;
    justify-content: center; /* Center buttons horizontally */
    align-items: center;
    gap: 20px; /* Space between buttons */
    margin-top: 10px; /* Adjusted from margin-bottom */
}

#captcha-verify, #captcha-cancel {
    background-color: #333;
    color: #AAA;
    border: 1px solid #555;
    padding: 8px 15px;
    cursor: pointer;
    font-family: inherit;
    font-size: 1rem;
    transition: background-color 0.2s, color 0.2s, box-shadow 0.2s, transform 0.1s ease; /* Add box-shadow & transform */
    box-shadow: none; /* Default no shadow */
    transform: scale(1); /* Base scale */
}
/* Glow on Hover for CAPTCHA buttons */
#captcha-verify:hover:not(:disabled), #captcha-cancel:hover {
    background-color: #555;
    color: #FFF;
    box-shadow: none; /* Removed hover glow */
}
/* Glow on Click for CAPTCHA buttons */
#captcha-verify:active:not(:disabled), #captcha-cancel:active {
    animation: glow-pulse 1.2s ease-in-out; /* Add click glow animation */
    transform: scale(0.98); /* Add press effect */
}
#captcha-verify:disabled {
    background-color: #222;
    color: #555;
    border-color: #333;
    cursor: not-allowed;
    box-shadow: none;
    transform: scale(1);
}


/* Ensure hidden class works */
.hidden {
    display: none !important;
}