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

html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 0;
    margin: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    width: 100%;
    overflow-x: hidden;
}

@media (min-width: 480px) {
    body {
        align-items: center;
        padding: 20px;
    }
}

.container {
    width: 100%;
    max-width: 600px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: visible;
    margin: 0 auto;
    position: relative;
    display: block;
}

@media (max-width: 479px) {
    .container {
        border-radius: 0;
        box-shadow: none;
        width: 100%;
        max-width: 100%;
    }
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px 20px;
    text-align: center;
}

@media (min-width: 480px) {
    header {
        padding: 40px 30px;
    }
}

header h1 {
    font-size: 1.8em;
    margin-bottom: 8px;
    word-wrap: break-word;
}

@media (min-width: 480px) {
    header h1 {
        font-size: 2.5em;
        margin-bottom: 10px;
    }
}

.subtitle {
    opacity: 0.9;
    font-size: 0.95em;
    line-height: 1.4;
    margin: 0;
}

.counter {
    margin-top: 12px;
    font-size: 0.9em;
    opacity: 0.85;
    font-weight: 500;
}

@media (min-width: 480px) {
    .subtitle {
        font-size: 1.1em;
    }
    
    .counter {
        font-size: 1em;
    }
}

.tabs {
    display: flex;
    flex-direction: row;
    background: #f5f5f5;
    border-bottom: 2px solid #e0e0e0;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.tab-button {
    flex: 1;
    padding: 12px 6px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 0.85em;
    font-weight: 600;
    color: #666;
    transition: all 0.3s;
    min-height: 44px; /* Minimum touch target size */
    touch-action: manipulation;
    white-space: nowrap;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    user-select: none;
    -webkit-user-select: none;
}

@media (min-width: 480px) {
    .tab-button {
        padding: 15px;
        font-size: 1em;
    }
}

.tab-button:hover {
    background: #e8e8e8;
}

.tab-button.active {
    background: white;
    color: #667eea;
    border-bottom: 3px solid #667eea;
}

.tab-content {
    display: none;
    padding: 20px 15px;
    width: 100%;
    box-sizing: border-box;
}

@media (min-width: 480px) {
    .tab-content {
        padding: 30px;
    }
}

.tab-content.active {
    display: block !important;
    visibility: visible;
    opacity: 1;
}

.card {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card h2 {
    margin-bottom: 20px;
    color: #333;
    font-size: 1.5em;
    line-height: 1.3;
}

@media (min-width: 480px) {
    .card h2 {
        margin-bottom: 25px;
        font-size: 1.8em;
    }
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #555;
    font-weight: 600;
}

.form-group input {
    width: 100%;
    padding: 14px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px; /* Prevents zoom on iOS */
    transition: border-color 0.3s;
    -webkit-appearance: none;
    appearance: none;
    min-height: 44px; /* Minimum touch target size */
}

@media (min-width: 480px) {
    .form-group input {
        padding: 12px 15px;
        font-size: 1em;
    }
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
}

.file-upload-area {
    position: relative;
    margin-bottom: 20px;
}

#file-input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    overflow: hidden;
}

.file-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px 15px;
    border: 3px dashed #667eea;
    border-radius: 12px;
    background: #f8f9ff;
    cursor: pointer;
    transition: all 0.3s;
    min-height: 120px;
    touch-action: manipulation;
}

@media (min-width: 480px) {
    .file-label {
        padding: 40px 20px;
        min-height: auto;
    }
}

.file-label:hover {
    background: #f0f2ff;
    border-color: #764ba2;
}

.upload-icon {
    font-size: 2.5em;
    margin-bottom: 8px;
}

@media (min-width: 480px) {
    .upload-icon {
        font-size: 3em;
        margin-bottom: 10px;
    }
}

.upload-text {
    color: #667eea;
    font-weight: 600;
    font-size: 0.95em;
    text-align: center;
    padding: 0 10px;
}

@media (min-width: 480px) {
    .upload-text {
        font-size: 1.1em;
        padding: 0;
    }
}

.file-name {
    margin-top: 15px;
    padding: 10px;
    background: #e8f4f8;
    border-radius: 8px;
    color: #2c3e50;
    font-weight: 600;
    display: none;
}

.file-name.show {
    display: block;
}

.btn {
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    min-height: 48px; /* Minimum touch target size */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

@media (min-width: 480px) {
    .btn {
        padding: 15px;
        font-size: 1.1em;
    }
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.result {
    margin-top: 20px;
    padding: 15px;
    border-radius: 8px;
    display: none;
}

.result.show {
    display: block;
}

.result.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.result.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.result-code {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 6px;
    margin-top: 10px;
    font-family: 'Courier New', monospace;
    word-break: break-all;
    border: 2px solid #e0e0e0;
    font-size: 0.9em;
    overflow-wrap: break-word;
}

@media (min-width: 480px) {
    .result-code {
        padding: 15px;
        font-size: 1em;
    }
}

.result-code strong {
    display: block;
    margin-bottom: 8px;
    color: #333;
    font-size: 0.95em;
}

@media (min-width: 480px) {
    .result-code strong {
        font-size: 1em;
    }
}

.result-code span {
    display: block;
    font-size: 1em;
    color: #667eea;
    font-weight: bold;
    word-break: break-all;
}

@media (min-width: 480px) {
    .result-code span {
        font-size: 1.2em;
    }
}

.info-content {
    line-height: 1.7;
    font-size: 0.95em;
}

@media (min-width: 480px) {
    .info-content {
        line-height: 1.8;
        font-size: 1em;
    }
}

.info-section {
    margin-bottom: 25px;
}

@media (min-width: 480px) {
    .info-section {
        margin-bottom: 30px;
    }
}

.info-section:last-child {
    margin-bottom: 0;
}

.info-section h3 {
    color: #667eea;
    margin-bottom: 12px;
    font-size: 1.15em;
    line-height: 1.3;
}

@media (min-width: 480px) {
    .info-section h3 {
        margin-bottom: 15px;
        font-size: 1.3em;
    }
}

.info-section p {
    color: #555;
    margin-bottom: 10px;
    font-size: 0.95em;
}

@media (min-width: 480px) {
    .info-section p {
        font-size: 1em;
    }
}

.info-section ul {
    list-style: none;
    padding-left: 0;
    color: #555;
    font-size: 0.95em;
}

@media (min-width: 480px) {
    .info-section ul {
        font-size: 1em;
    }
}

.info-section ul li {
    padding: 6px 0;
    padding-left: 22px;
    position: relative;
    line-height: 1.5;
}

@media (min-width: 480px) {
    .info-section ul li {
        padding: 8px 0;
        padding-left: 25px;
    }
}

.info-section ul li:before {
    content: "•";
    color: #667eea;
    font-weight: bold;
    position: absolute;
    left: 0;
}

.info-section strong {
    color: #333;
    font-weight: 600;
}

/* Additional mobile optimizations */
@media (max-width: 479px) {
    .file-name {
        font-size: 0.9em;
        padding: 8px;
    }
    
    .result {
        padding: 12px;
        font-size: 0.95em;
    }
    
    .form-group label {
        font-size: 0.95em;
    }
    
    /* Ensure tabs are visible and scrollable on very small screens */
    .tabs {
        min-height: 44px;
    }
    
    .tab-button {
        min-width: 80px;
        font-size: 0.8em;
    }
    
    /* Ensure header is visible */
    header {
        min-height: auto;
        display: block;
    }
    
    /* Ensure content is visible */
    .tab-content {
        min-height: 200px;
    }
}

/* Tablet optimizations */
@media (min-width: 481px) and (max-width: 768px) {
    .container {
        max-width: 90%;
    }
}

/* Ensure all interactive elements are visible */
button, input, label {
    -webkit-appearance: none;
    appearance: none;
}

/* Fix for iOS Safari */
@supports (-webkit-touch-callout: none) {
    body {
        -webkit-overflow-scrolling: touch;
    }
    
    .tab-button {
        -webkit-tap-highlight-color: rgba(102, 126, 234, 0.2);
    }
}

/* Ensure container doesn't overflow */
* {
    max-width: 100%;
}

img, video {
    height: auto;
}

