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

body {
    font-family: 'Segoe UI', 'Yu Gothic UI', 'Meiryo', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.container {
    background: white;
    border-radius: 20px;
    padding: 40px;
    max-width: 600px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    text-align: center;
}

.title {
    font-size: 2rem;
    color: #667eea;
    margin-bottom: 10px;
    font-weight: bold;
}

.subtitle {
    font-size: 1.2rem;
    color: #764ba2;
    margin-bottom: 20px;
}

.description {
    margin: 20px 0;
    padding: 20px;
    background: linear-gradient(135deg, #e3f2fd 0%, #f3e5f5 100%);
    border-radius: 12px;
}

.description p {
    color: #2d3436;
    font-size: 1rem;
    margin: 8px 0;
    line-height: 1.6;
}

.encouragement {
    font-weight: bold;
    font-size: 1.1rem !important;
    color: #667eea !important;
    margin-top: 12px !important;
}

.spin-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 20px 40px;
    font-size: 1.3rem;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 20px 0;
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.spin-button:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.spin-button:active {
    transform: scale(0.95);
}

.spin-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: scale(1);
    font-size: 1rem;
    padding: 15px 30px;
}

.override-link {
    margin-top: 10px;
    font-size: 0.85rem;
}

.override-link a {
    color: #636e72;
    text-decoration: underline;
    cursor: pointer;
    transition: color 0.3s ease;
}

.override-link a:hover {
    color: #d63031;
}

.override-link.hidden {
    display: none;
}

.result-container {
    margin: 30px 0;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.result-container.hidden {
    display: none;
}

.result-container.show {
    animation: fadeIn 0.5s ease;
}

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

.result-header {
    font-size: 2rem;
    font-weight: bold;
    color: #667eea;
    margin-bottom: 15px;
}

.result-box {
    background: linear-gradient(135deg, #ffeaa7 0%, #fdcb6e 100%);
    border-radius: 15px;
    padding: 30px;
    margin: 20px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

.result-box.perfect {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%);
    animation: perfectPulse 1s infinite;
}

@keyframes perfectPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.sparkles {
    font-size: 2rem;
    animation: sparkle 1s infinite alternate;
}

@keyframes sparkle {
    from {
        opacity: 0.5;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1.2);
    }
}

.result-text {
    font-size: 1.8rem;
    font-weight: bold;
    color: #2d3436;
}

.result-box.perfect .result-text {
    color: white;
}

.result-message {
    font-size: 1.2rem;
    color: #636e72;
    line-height: 1.6;
}

.result-message.perfect {
    color: #d63031;
    font-weight: bold;
    font-size: 1.4rem;
}

.tweet-button {
    background: #1da1f2;
    color: white;
    border: none;
    padding: 12px 30px;
    font-size: 1.1rem;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(29, 161, 242, 0.4);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 200px;
    height: 50px;
}

.tweet-button:hover {
    background: #1a8cd8;
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(29, 161, 242, 0.6);
}

.tweet-button:active {
    transform: scale(0.95);
}

.tweet-button.hidden {
    display: none;
}

.tweet-icon {
    font-size: 1.3rem;
}

.history-section {
    margin-top: 40px;
    padding-top: 30px;
    border-top: 2px solid #dfe6e9;
}

.history-section h2 {
    font-size: 1.3rem;
    color: #667eea;
    margin-bottom: 15px;
}

.history-container {
    max-height: 200px;
    overflow-y: auto;
    text-align: left;
}

.history-item {
    background: #f8f9fa;
    padding: 10px 15px;
    margin: 8px 0;
    border-radius: 8px;
    border-left: 4px solid #dfe6e9;
}

.history-item.perfect {
    border-left-color: #d63031;
    background: #ffe0e0;
}

.history-item-result {
    font-weight: bold;
    color: #2d3436;
}

.history-item-time {
    font-size: 0.85rem;
    color: #636e72;
    margin-top: 5px;
}

.no-history {
    color: #b2bec3;
    font-style: italic;
}

.spinning {
    animation: spin 0.1s infinite;
}

@keyframes spin {
    0% { opacity: 0.3; }
    50% { opacity: 1; }
    100% { opacity: 0.3; }
}

.ranking-section {
    margin-top: 40px;
    padding-top: 30px;
    border-top: 2px solid #dfe6e9;
}

.ranking-section h2 {
    font-size: 1.3rem;
    color: #667eea;
    margin-bottom: 15px;
}

.ranking-container {
    max-height: 300px;
    overflow-y: auto;
    text-align: left;
}

.ranking-item {
    background: #f8f9fa;
    padding: 10px 15px;
    margin: 8px 0;
    border-radius: 8px;
    border-left: 4px solid #b2bec3;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ranking-item.rank-perfect {
    border-left-color: #d63031;
    background: #ffe0e0;
}

.ranking-item.rank-close {
    border-left-color: #e17055;
    background: #fff3e0;
}

.ranking-item.rank-medium {
    border-left-color: #667eea;
    background: #f8f9fa;
}

.ranking-item.rank-far {
    border-left-color: #b2bec3;
    background: #f8f9fa;
}

.ranking-item-text {
    font-weight: bold;
    color: #2d3436;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
}

.modal:not(.hidden) {
    display: flex;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background-color: white;
    padding: 30px;
    border-radius: 15px;
    width: 90%;
    max-width: 400px;
    position: relative;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    text-align: center;
}

.close-modal {
    position: absolute;
    top: 10px;
    right: 15px;
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s;
}

.close-modal:hover {
    color: #2d3436;
}

.modal h2 {
    color: #667eea;
    margin-bottom: 10px;
}

.modal p {
    color: #636e72;
    margin-bottom: 20px;
    font-size: 0.9rem;
}

.modal-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
}

.form-group {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.result-actions {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
    margin-top: 20px;
}

.ranking-button {
    background: #fdcb6e;
    color: #2d3436;
    border: none;
    padding: 12px 30px;
    font-size: 1.1rem;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(253, 203, 110, 0.4);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 200px;
    height: 50px;
}

.ranking-button:hover {
    background: #ffeaa7;
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(253, 203, 110, 0.6);
}

.ranking-button:active {
    transform: scale(0.95);
}

.ranking-button.hidden {
    display: none;
}

.submit-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 40px;
    font-size: 1.1rem;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: bold;
    width: 100%;
}

.submit-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.submit-button:not(:disabled):hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}


.loading-ranking {
    color: #b2bec3;
    font-style: italic;
    text-align: center;
}

.username-section {
    margin: 20px 0;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

.username-section label {
    color: #636e72;
    font-weight: bold;
}

.username-input {
    padding: 8px 12px;
    border: 2px solid #dfe6e9;
    border-radius: 8px;
    font-size: 1rem;
    width: 200px;
    transition: border-color 0.3s ease;
}

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

.ranking-item-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ranking-item-name {
    font-size: 0.85rem;
    color: #636e72;
}

.ranking-item-score {
    font-size: 0.9rem;
    color: #636e72;
    background: #dfe6e9;
    padding: 2px 8px;
    border-radius: 12px;
}

/* Mobile Responsive Styles */
@media (max-width: 480px) {
    .container {
        padding: 20px;
    }

    .title {
        font-size: 1.5rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    .result-box {
        padding: 20px;
        flex-direction: column;
        gap: 10px;
    }

    .result-text {
        font-size: 1.4rem;
        word-break: break-all;
    }

    .result-actions {
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }

    .tweet-button,
    .ranking-button {
        width: 100%;
        min-width: unset;
    }

    .username-section {
        flex-direction: column;
        align-items: center;
    }
    
    .username-input {
        width: 100%;
        max-width: 300px;
    }
}


