/* CSS Reset / Base Setup */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: #0f0f0f;
    color: #e0e0e0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    padding: 2rem 1rem;
}

.container {
    width: 100%;
    max-width: 720px;
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
}

header {
    text-align: center;
}

header h1 {
    font-size: 2.2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: #ffffff;
}

header p {
    color: #a0a0a0;
    font-size: 0.95rem;
}

.input-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

#wordForm {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

#wordInput {
    flex: 1;
    padding: 0.9rem 1rem;
    border-radius: 8px;
    border: 1px solid #333;
    background-color: #1a1a1a;
    color: #fff;
    font-size: 1rem;
    outline: none;
    transition: all 0.2s;
}

#wordInput:focus {
    border-color: #888;
    background-color: #222;
}

#wordForm button {
    padding: 0.9rem 1.5rem;
    border-radius: 8px;
    border: none;
    background-color: #ffffff;
    color: #0f0f0f;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}

#wordForm button:hover {
    background-color: #cccccc;
}

#wordForm button:active {
    transform: scale(0.97);
}

.message-box {
    padding: 0.8rem;
    border-radius: 8px;
    font-size: 0.9rem;
    text-align: center;
    transition: opacity 0.3s;
}

.message-box.hidden {
    display: none;
    opacity: 0;
}

.message-box.success {
    background-color: rgba(76, 175, 80, 0.15);
    color: #a5d6a7;
    border: 1px solid rgba(76, 175, 80, 0.3);
}

.message-box.error {
    background-color: rgba(244, 67, 54, 0.15);
    color: #ef9a9a;
    border: 1px solid rgba(244, 67, 54, 0.3);
}

.message-box.warning {
    background-color: rgba(255, 193, 7, 0.15);
    color: #ffe082;
    border: 1px solid rgba(255, 193, 7, 0.3);
}

#wordForm button:disabled {
    background-color: #333;
    color: #666;
    cursor: not-allowed;
    transform: none;
}

.ranking-section {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.ranking-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.8rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #333;
}

.ranking-header h2 {
    font-size: 1.2rem;
    color: #e0e0e0;
}

.download-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.8rem;
    border-radius: 6px;
    background-color: #222;
    color: #bbb;
    text-decoration: none;
    font-size: 0.85rem;
    transition: background-color 0.2s, color 0.2s;
}

.download-btn:hover {
    background-color: #333;
    color: #fff;
}

.download-buttons {
    position: relative;
    display: flex;
    align-items: center;
}

.download-buttons::before {
    content: "\21E9";
    position: absolute;
    left: 0.68rem;
    color: #9a9a9a;
    pointer-events: none;
    font-size: 0.84rem;
}

.download-select {
    appearance: none;
    padding: 0.56rem 2.2rem 0.56rem 1.75rem;
    border-radius: 8px;
    border: 1px solid #3a3a3a;
    background-color: #1b1d23;
    background-image: linear-gradient(45deg, transparent 50%, #a5a5a5 50%), linear-gradient(135deg, #a5a5a5 50%, transparent 50%);
    background-position: calc(100% - 14px) calc(50% + 1px), calc(100% - 9px) calc(50% + 1px);
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    color: #e0e0e0;
    font-size: 0.86rem;
    font-weight: 600;
    min-width: 170px;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s, background-color 0.2s, transform 0.1s;
}

.download-select:hover {
    background-color: #222633;
    border-color: #4a4a4a;
}

.download-select:focus {
    border-color: #7a7a7a;
    box-shadow: 0 0 0 2px rgba(180, 180, 180, 0.2);
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.word-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.word-item {
    display: flex;
    align-items: center;
    background-color: #1a1a1a;
    padding: 1rem 1.2rem;
    border-radius: 8px;
    border: 1px solid #2a2a2a;
    gap: 1rem;
}

.word-rank {
    min-width: 3rem;
    color: #9a9a9a;
    font-size: 0.92rem;
    font-weight: 700;
}

.word-content {
    flex: 1;
    font-size: 1.15rem;
    font-weight: 500;
    word-break: break-word;
}

.word-actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background-color: #222;
    padding: 0.3rem 0.6rem;
    border-radius: 20px;
}

.score {
    min-width: 2rem;
    text-align: center;
    font-weight: 700;
    color: #e0e0e0;
    font-size: 0.95rem;
}

.vote-btn {
    background: transparent;
    border: none;
    color: #666;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.35rem;
    transition: color 0.2s, transform 0.1s;
    font-size: 1.4rem;
    min-width: 44px;
    min-height: 44px;
}

.vote-btn:hover {
    color: #fff;
}

.vote-btn:active {
    transform: scale(0.9);
}

.vote-btn.upvote:hover {
    color: #ff4500;
}

.vote-btn.voted,
.vote-btn.voted:hover {
    color: #ff4500;
    opacity: 0.7;
    cursor: not-allowed;
}

.delete-btn {
    background: transparent;
    border: none;
    color: #ef9a9a;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.2rem;
    transition: color 0.2s, transform 0.1s;
    font-size: 1.2rem;
    margin-right: 0.5rem;
    min-width: 44px;
    min-height: 44px;
}

.delete-btn:hover {
    color: #ff5252;
}

.delete-btn:active {
    transform: scale(0.9);
}

/* Footer Styles */
footer {
    text-align: center;
    margin-top: 2rem;
    padding-bottom: 2rem;
}

.about-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: #888;
    text-decoration: none;
    font-size: 0.95rem;
    transition: color 0.2s;
}

.about-link:hover {
    color: #e0e0e0;
}

/* About Page Styles */
.about-container {
    max-width: 600px;
}

.about-content {
    background-color: #1a1a1a;
    padding: 2rem;
    border-radius: 8px;
    border: 1px solid #2a2a2a;
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    line-height: 1.6;
    color: #cccccc;
}

.about-content strong {
    color: #ffffff;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.8rem 1.2rem;
    margin-top: 1rem;
    border-radius: 6px;
    background-color: #ffffff;
    color: #0f0f0f;
    text-decoration: none;
    font-weight: 600;
    align-self: flex-start;
    transition: background-color 0.2s;
}

.back-link:hover {
    background-color: #cccccc;
}

@media (max-width: 768px) {
    body {
        padding: 1.25rem 0.85rem;
    }

    .container {
        gap: 1.6rem;
    }

    .word-item {
        padding: 0.85rem;
        gap: 0.65rem;
    }

    .word-content {
        font-size: 1rem;
    }

    .ranking-header {
        align-items: center;
    }
}

@media (max-width: 520px) {
    header h1 {
        font-size: 1.72rem;
    }

    #wordForm {
        flex-direction: column;
    }

    #wordForm button {
        width: 100%;
    }

    .ranking-header h2 {
        font-size: 1.05rem;
    }

    .download-select {
        min-width: 148px;
        padding-left: 1.58rem;
    }

    .word-item {
        flex-wrap: wrap;
    }

    .word-rank {
        min-width: auto;
    }

    .word-content {
        width: calc(100% - 2.8rem);
    }

    .word-actions {
        margin-left: auto;
    }
}