
:root {
    --bg-main: #FAF9F6;
    --bg-header: #0A0A0A;
    --text-main: #111;
    --text-meta: #666;
    --text-light: #888;
    --link-color: #CC0000;
    --link-hover: #FF0000;
    --accent-red: #DC143C;
    --tag-exploit: #CC0000;
    --tag-rev: #4682B4;
    --tag-blue: #00BFFF;
    --tag-lol: #808080;
    --border-light: #E0E0E0;
    --shadow-light: rgba(0, 0, 0, 0.05);
    --shadow-medium: rgba(0, 0, 0, 0.1);
}

/* Subtle theme preference detection */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

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

body {
    font-family: 'JetBrains Mono', 'IBM Plex Mono', 'Courier New', monospace;
    background: linear-gradient(135deg, var(--bg-main) 0%, #F8F6F3 100%);
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
    letter-spacing: -0.01em;
}

/* Header */
.header {
    background: var(--bg-header);
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--accent-red);
    backdrop-filter: blur(8px);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(220, 20, 60, 0.1);
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #FFF;
    font-size: 18px;
    font-weight: bold;
    text-decoration: none;
}

.logo::before {
    content: "⚡";
    font-size: 20px;
}

.nav {
    display: flex;
    gap: 20px;
    align-items: center;
}

.nav a {
    color: #CCC;
    text-decoration: none;
    font-size: 14px;
    transition: color 0.2s;
}

.nav a:hover {
    color: var(--accent-red);
}

.nav .separator {
    color: var(--text-meta);
}

/* Main content */
.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
}

/* Story list */
.story-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.story {
    display: flex;
    gap: 12px;
    padding: 16px 12px;
    border-bottom: 1px solid var(--border-light);
    transition: all 0.3s ease;
    border-radius: 8px;
    margin: 4px 0;
}

.story:hover {
    background: linear-gradient(135deg, rgba(220, 20, 60, 0.03), rgba(220, 20, 60, 0.01));
    transform: translateX(4px);
    box-shadow: -4px 0 0 var(--accent-red), 0 2px 12px rgba(220, 20, 60, 0.05);
}

.rank {
    min-width: 30px;
    text-align: right;
    color: var(--text-meta);
    font-size: 14px;
    padding-top: 2px;
}

.story-content {
    flex: 1;
}

.story-title {
    display: inline;
    font-size: 16px;
    font-weight: 600;
}

.story-title a {
    color: var(--text-main);
    text-decoration: none;
}

.story-title a:hover {
    text-decoration: underline;
}

.story-title a:visited {
    color: var(--text-meta);
}

/* Tags */
.tag {
    display: inline-block;
    padding: 2px 6px;
    margin-left: 8px;
    font-size: 11px;
    font-weight: bold;
    border-radius: 3px;
    color: white;
    position: relative;
    cursor: help;
}

.tag.exploit {
    background: var(--tag-exploit);
}

.tag.rev {
    background: var(--tag-rev);
}

.tag.blue {
    background: var(--tag-blue);
}

.tag.lol {
    background: var(--tag-lol);
}

.tag:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #222;
    color: white;
    padding: 4px 8px;
    border-radius: 3px;
    font-size: 11px;
    white-space: nowrap;
    margin-bottom: 4px;
    z-index: 10;
}

/* Metadata */
.story-meta {
    margin-top: 4px;
    font-size: 12px;
    color: var(--text-meta);
}

.story-meta a {
    color: var(--text-meta);
    text-decoration: none;
}

.story-meta a:hover {
    text-decoration: underline;
}

.points {
    color: var(--text-main);
    font-weight: 600;
}

/* Footer */
.footer {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-meta);
    font-size: 12px;
}

.footer a {
    color: var(--link-color);
    text-decoration: none;
}

/* Mobile and Touch Device Improvements */
@media (max-width: 768px) {
    .header {
        padding: 12px 16px;
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .logo {
        font-size: 16px;
        order: 1;
    }
    
    .nav {
        gap: 8px;
        font-size: 13px;
        order: 2;
        flex-wrap: wrap;
    }
    
    .nav a {
        font-size: 13px;
        padding: 4px 6px;
        border-radius: 4px;
        transition: background-color 0.2s;
    }
    
    .nav a:active {
        background-color: rgba(220, 20, 60, 0.1);
    }
    
    .container {
        padding: 12px;
    }
    
    .story {
        padding: 12px 8px;
        gap: 8px;
    }
    
    .story:hover {
        transform: none; /* Disable hover transform on mobile */
    }
    
    .rank {
        min-width: auto;
        text-align: left;
        font-size: 13px;
    }
    
    .story-title {
        font-size: 15px;
        line-height: 1.4;
    }
    
    .story-meta {
        font-size: 11px;
    }
}

/* iPhone 15 Pro specific (430x932) and similar aspect ratios */
@media (max-width: 430px) {
    .header {
        padding: 10px 12px;
    }
    
    .logo {
        font-size: 15px;
    }
    
    .nav {
        gap: 6px;
        font-size: 12px;
    }
    
    .nav a {
        font-size: 12px;
        padding: 3px 5px;
    }
    
    .nav .separator {
        display: none; /* Hide separators on very small screens */
    }
    
    .container {
        padding: 10px;
    }
    
    .story {
        padding: 10px 6px;
        margin: 2px 0;
    }
    
    .story-title {
        font-size: 14px;
    }
    
    .story-meta {
        font-size: 10px;
    }
}

/* Loading animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-light);
    border-radius: 50%;
    border-top-color: var(--accent-red);
    animation: spin 0.8s linear infinite;
    margin: 20px auto;
}

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

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

.story {
    animation: fadeInUp 0.4s ease-out;
}



/* Submit form */
.submit-form {
    background: var(--bg-main);
    padding: 20px 0;
    border-bottom: 1px solid var(--border-light);
}

.submit-form h2 {
    margin-bottom: 20px;
    font-size: 20px;
}

.submit-form form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 600px;
}

.submit-form input,
.submit-form textarea {
    padding: 12px 16px;
    border: 2px solid var(--border-light);
    border-radius: 8px;
    font-family: inherit;
    font-size: 16px; /* Prevents zoom on iOS */
    background: #FFF;
    transition: all 0.3s ease;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05);
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    box-sizing: border-box;
}

.submit-form input:focus,
.submit-form textarea:focus {
    outline: none;
    border-color: var(--accent-red);
    box-shadow: 0 0 0 3px rgba(220, 20, 60, 0.1), inset 0 1px 3px rgba(0, 0, 0, 0.05);
    transform: translateY(-1px);
}

.form-buttons {
    display: flex;
    gap: 10px;
}

.form-buttons button {
    padding: 10px 20px;
    border: 1px solid var(--border-light);
    border-radius: 6px;
    background: var(--bg-main);
    color: var(--text-main);
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.form-buttons button[type="submit"] {
    background: linear-gradient(135deg, var(--accent-red), #B91C3C);
    color: white;
    border-color: var(--accent-red);
    box-shadow: 0 2px 4px rgba(220, 20, 60, 0.2);
}

.form-buttons button:hover {
    background: var(--border-light);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.form-buttons button[type="submit"]:hover {
    background: linear-gradient(135deg, #B91C3C, var(--accent-red));
    box-shadow: 0 4px 12px rgba(220, 20, 60, 0.3);
    transform: translateY(-1px);
}

/* Comments section */
.comments-section {
    background: var(--bg-main);
    min-height: 100vh;
}

.story-detail {
    padding: 20px 0;
    border-bottom: 2px solid var(--border-light);
    margin-bottom: 20px;
}

.story-detail h2 {
    font-size: 18px;
    margin-bottom: 8px;
}

.story-detail p {
    margin-bottom: 8px;
    color: var(--text-meta);
}

.story-detail a {
    color: var(--link-color);
}

#comment-form-container {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-light);
}

.comment {
    padding: 12px 0;
    border-bottom: 1px solid var(--border-light);
}

.comment-meta {
    font-size: 12px;
    color: var(--text-meta);
    margin-bottom: 6px;
}

.comment-meta strong {
    color: var(--text-main);
}

.comment-text {
    font-size: 14px;
    line-height: 1.4;
}

/* Authentication Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
    padding: 20px;
    box-sizing: border-box;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    /* Ensure modal is touchable on mobile */
    touch-action: manipulation;
}

.modal-content {
    background: var(--bg-main);
    padding: 30px;
    border-radius: 12px;
    width: 100%;
    max-width: 400px;
    position: relative;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    margin: auto;
    max-height: 90vh;
    overflow-y: auto;
}

/* Mobile modal improvements */
@media (max-width: 768px) {
    .modal {
        padding: 20px;
        align-items: center;
        justify-content: center;
    }
    
    .modal-content {
        padding: 24px;
        border-radius: 12px;
        max-height: 85vh;
        width: 100%;
        max-width: 350px;
        margin: 0;
    }
    
    /* Improve header navigation on mobile */
    .header {
        padding: 8px 12px;
        flex-wrap: wrap;
    }
    
    .nav {
        font-size: 13px;
    }
    
    .nav a {
        padding: 8px 4px;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }
    
    .separator {
        display: none;
    }
}

@media (max-width: 430px) {
    .modal {
        padding: 15px;
    }
    
    .modal-content {
        padding: 20px;
        border-radius: 8px;
        width: 100%;
        max-width: none;
    }
    
    .header {
        padding: 6px 10px;
    }
    
    .logo {
        font-size: 16px;
    }
    
    .nav {
        font-size: 12px;
    }
}

.close {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    color: var(--text-meta);
    padding: 4px;
    min-height: 32px;
    min-width: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.close:hover {
    color: var(--text-main);
    background-color: rgba(0, 0, 0, 0.05);
}

.close:active {
    background-color: rgba(0, 0, 0, 0.1);
}

/* Mobile close button improvements */
@media (max-width: 768px) {
    .close {
        top: 10px;
        right: 10px;
        font-size: 28px;
        padding: 6px;
        min-height: 40px;
        min-width: 40px;
    }
}

#login-form h2,
#signup-form h2 {
    margin-bottom: 20px;
    text-align: center;
    color: var(--text-main);
}

#login-form form,
#signup-form form {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 20px;
}

#login-form input,
#signup-form input {
    padding: 14px 16px;
    border: 2px solid var(--border-light);
    border-radius: 8px;
    font-family: inherit;
    font-size: 16px; /* Prevents zoom on iOS */
    background: #FFF;
    transition: all 0.3s ease;
    -webkit-appearance: none; /* Remove iOS styling */
    appearance: none;
    width: 100%;
    box-sizing: border-box;
    min-height: 48px; /* Better touch target */
    /* Fix iOS input handling */
    -webkit-user-select: text;
    user-select: text;
}

#login-form input:focus,
#signup-form input:focus {
    outline: none;
    border-color: var(--accent-red);
    box-shadow: 0 0 0 3px rgba(220, 20, 60, 0.1);
}

#login-form button,
#signup-form button {
    padding: 14px 12px;
    background: linear-gradient(135deg, var(--accent-red), #B91C3C);
    color: white;
    border: none;
    border-radius: 8px;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
    font-size: 16px;
    min-height: 44px; /* iOS touch target recommendation */
    -webkit-appearance: none;
    appearance: none;
}

#login-form button:hover,
#signup-form button:hover {
    background: linear-gradient(135deg, #B91C3C, var(--accent-red));
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(220, 20, 60, 0.3);
}

.auth-divider {
    text-align: center;
    margin: 15px 0;
    position: relative;
    color: var(--text-meta);
}

.auth-divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--border-light);
}

.auth-divider span {
    background: var(--bg-main);
    padding: 0 15px;
}

.google-btn {
    width: 100%;
    padding: 12px;
    background: #4285f4;
    color: white;
    border: none;
    border-radius: 8px;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    margin-bottom: 15px;
    transition: background 0.3s ease;
}

.google-btn:hover {
    background: #3367d6;
}

.auth-switch {
    text-align: center;
    color: var(--text-meta);
    margin: 0;
}

.auth-switch a {
    color: var(--link-color);
    text-decoration: none;
}

.auth-switch a:hover {
    color: var(--link-hover);
}

html {
    height: 100%;
    width: 100%;
}
