/* 天の川線形回帰チャレンジ - スタイルシート */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    min-height: 100vh;
    background: radial-gradient(ellipse at bottom, #0d1b2a 0%, #1b263b 50%, #0f172a 100%);
    display: block;
    padding: 20px;
    position: relative;
}

/* Background stars animation */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(2px 2px at 20px 30px, rgba(255,255,255,0.3), transparent),
        radial-gradient(2px 2px at 40px 70px, rgba(255,255,255,0.2), transparent),
        radial-gradient(1px 1px at 90px 40px, rgba(255,255,255,0.5), transparent),
        radial-gradient(1px 1px at 130px 80px, rgba(255,255,255,0.3), transparent),
        radial-gradient(2px 2px at 160px 30px, rgba(255,255,255,0.4), transparent);
    background-repeat: repeat;
    background-size: 200px 100px;
    animation: twinkle 3s infinite;
    pointer-events: none;
    z-index: 0;
}

@keyframes twinkle {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 0.4; }
}

/* ヘッダースタイル */
.main-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding: 12px 0;
    z-index: 1000;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.header-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 20px;
    font-weight: 600;
    color: white;
    text-decoration: none;
    font-size: 1.1rem;
    transition: color 0.3s ease;
}

.header-link:hover {
    color: #60a5fa;
}

.header-logo {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.container {
    width: 100%;
    max-width: 900px;
    position: relative;
    z-index: 1;
    margin: 0 auto;
    padding-top: 60px; /* ヘッダーの高さ分の余白 */
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: calc(100vh - 40px);
}

.header {
    text-align: center;
    margin-bottom: 32px;
}

h1 {
    font-size: 48px;
    font-weight: bold;
    color: #f1f5f9;
    margin-bottom: 8px;
    letter-spacing: -0.5px;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.3), 0 4px 6px rgba(0, 0, 0, 0.5);
    background: linear-gradient(45deg, #fbbf24, #f59e0b, #fbbf24);
    background-size: 200% 200%;
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: starGlow 2s ease-in-out infinite alternate;
}

@keyframes starGlow {
    0% { background-position: 0% 50%; }
    100% { background-position: 100% 50%; }
}

.subtitle {
    color: rgba(241, 245, 249, 0.8);
    font-size: 18px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.game-card {
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(12px);
    border-radius: 24px;
    box-shadow: 
        0 0 0 1px rgba(255, 255, 255, 0.05),
        0 25px 50px -12px rgba(0, 0, 0, 0.25),
        0 10px 10px -5px rgba(0, 0, 0, 0.04);
    padding: 32px;
    border: 1px solid rgba(59, 130, 246, 0.2);
    margin-bottom: 20px;
    width: 100%;
}

.canvas-container {
    position: relative;
    margin-bottom: 24px;
}

#stage {
    width: 100%;
    border-radius: 16px;
    box-shadow: 
        0 0 0 1px rgba(255, 255, 255, 0.05),
        0 25px 50px -12px rgba(0, 0, 0, 0.25),
        0 10px 15px -3px rgba(0, 0, 0, 0.3);
    background: radial-gradient(ellipse at center, #0f172a 0%, #020617 100%);
}

.loading-overlay {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 16px;
    color: white;
    font-size: 20px;
}

#hud {
    display: flex;
    gap: 15px;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    color: white;
    font-weight: 500;
}

#timer {
    font-weight: bold;
    color: rgba(255, 255, 255, 0.9);
    background: rgba(15, 23, 42, 0.8);
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.stage {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.main-content {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 20px;
}

canvas {
    border: 2px solid rgba(255, 255, 255, 0.1);
    background: transparent;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    cursor: crosshair;
}

.panel {
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(59, 130, 246, 0.2);
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.panel h3 {
    color: #ffffff;
    margin-bottom: 15px;
    font-size: 1.2em;
    border-bottom: 2px solid rgba(59, 130, 246, 0.2);
    padding-bottom: 8px;
}

.result-card {
    background: rgba(15, 23, 42, 0.8);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 24px;
    display: none;
    animation: fadeIn 0.5s ease-out;
    border: 1px solid rgba(59, 130, 246, 0.2);
    box-shadow: 0 0 30px rgba(59, 130, 246, 0.1);
}

.result-card.show {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 16px;
}

.result-item {
    text-align: center;
}

.result-label {
    color: rgba(255, 255, 255, 0.6);
    font-size: 14px;
    margin-bottom: 4px;
}

.result-value {
    font-size: 28px;
    font-weight: bold;
}

.result-value.green {
    color: #10b981;
}

.result-value.yellow {
    color: #fbbf24;
}

.score-display {
    text-align: center;
}

.score-value {
    font-size: 36px;
    font-weight: bold;
    color: white;
}

#score {
    font-size: 2.5em;
    font-weight: bold;
    text-align: center;
    margin: 15px 0;
    color: #10b981;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

#metrics {
    list-style: none;
    margin-bottom: 25px;
}

#metrics li {
    padding: 8px 0;
    border-bottom: 1px solid rgba(59, 130, 246, 0.1);
    display: flex;
    justify-content: space-between;
    color: rgba(255, 255, 255, 0.8);
}

#leaderboard {
    list-style: none;
    margin-bottom: 20px;
}

#leaderboard li {
    padding: 8px 12px;
    margin-bottom: 5px;
    background: rgba(15, 23, 42, 0.6);
    border-radius: 6px;
    border-left: 4px solid #3b82f6;
    display: flex;
    justify-content: space-between;
    color: rgba(255, 255, 255, 0.9);
}

.settings {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 15px;
}

.settings label {
    cursor: pointer;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.8);
}

.submit-btn {
    width: 100%;
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 50%, #1e40af 100%);
    color: white;
    font-weight: bold;
    font-size: 18px;
    padding: 16px 24px;
    border-radius: 16px;
    border: none;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 
        0 0 20px rgba(59, 130, 246, 0.4),
        0 10px 15px -3px rgba(59, 130, 246, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 20px 0;
}

.submit-btn:hover {
    transform: scale(1.05);
    box-shadow: 
        0 0 30px rgba(59, 130, 246, 0.6),
        0 15px 20px -5px rgba(59, 130, 246, 0.3);
}

.submit-btn:active {
    transform: scale(0.98);
}

.submit-btn .icon {
    width: 20px;
    height: 20px;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    z-index: 1000;
}

.modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.95), rgba(30, 41, 59, 0.95));
    padding: 30px;
    border-radius: 16px;
    border: 1px solid rgba(59, 130, 246, 0.3);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5), 0 0 50px rgba(59, 130, 246, 0.2);
    text-align: center;
    max-width: 400px;
    width: 90%;
}

.modal-content h2 {
    color: #ffffff;
    margin-bottom: 20px;
    background: linear-gradient(45deg, #3b82f6, #60a5fa, #fbbf24);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.modal-content .score-big {
    font-size: 3em;
    font-weight: bold;
    color: #10b981;
    margin: 15px 0;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
}

.modal-buttons button {
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 120px;
}

.modal-buttons .primary {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: white;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
}

.modal-buttons .primary:hover {
    background: linear-gradient(135deg, #1d4ed8, #1e40af);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    h1 {
        font-size: 36px;
    }
    
    .game-card {
        padding: 20px;
    }

    #stage {
        width: 100%;
        height: auto;
    }

    .submit-btn {
        font-size: 16px;
        padding: 14px 20px;
    }

    .container {
        padding-top: 80px;
        padding-left: 10px;
        padding-right: 10px;
    }

    .ranking-panel {
        margin-top: 30px;
        padding: 20px;
    }

    .ranking-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .ranking-title {
        font-size: 1.3rem;
    }
}

/* ランキングパネルスタイル */
.ranking-panel {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 25px;
    margin-top: 40px;
    margin-bottom: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 900px;
}

.ranking-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.ranking-title {
    color: #ffffff;
    font-size: 1.5rem;
    margin: 0;
    font-weight: 600;
}

.ranking-period {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
}

.ranking-loading {
    text-align: center;
    color: rgba(255, 255, 255, 0.7);
    padding: 30px;
    font-size: 1.1rem;
}

.ranking-empty {
    text-align: center;
    color: rgba(255, 255, 255, 0.7);
    padding: 30px;
    font-size: 1.1rem;
}

.ranking-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    margin-bottom: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    border-left: 3px solid transparent;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
}

.ranking-item:hover {
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.ranking-item.top-three:nth-child(1) {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.1), rgba(255, 255, 255, 0.05));
    border-left-color: #ffd700;
}

.ranking-item.top-three:nth-child(2) {
    background: linear-gradient(135deg, rgba(192, 192, 192, 0.1), rgba(255, 255, 255, 0.05));
    border-left-color: #c0c0c0;
}

.ranking-item.top-three:nth-child(3) {
    background: linear-gradient(135deg, rgba(205, 127, 50, 0.1), rgba(255, 255, 255, 0.05));
    border-left-color: #cd7f32;
}

.ranking-rank {
    font-weight: bold;
    color: #ffffff;
    min-width: 40px;
}

.ranking-nickname {
    color: #ffffff;
    font-weight: 500;
    flex: 1;
    margin: 0 15px;
}

.ranking-score {
    color: #60a5fa;
    font-weight: 600;
    font-size: 0.9rem;
}

.my-best-record {
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.my-best-record h4 {
    color: #ffffff;
    margin-bottom: 15px;
    font-size: 1.1rem;
}

.my-best-empty {
    text-align: center;
    color: rgba(255, 255, 255, 0.7);
    padding: 20px;
    font-style: italic;
}

.my-best-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: rgba(59, 130, 246, 0.1);
    border-radius: 10px;
    border-left: 3px solid #3b82f6;
}

.my-best-score {
    color: #60a5fa;
    font-weight: 600;
}

.my-best-date {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.9rem;
}

/* モーダル内のランキング登録セクション */
.modal-ranking-section {
    margin-top: 20px;
}

.ranking-separator {
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    margin: 20px 0;
}

.ranking-modal-title {
    color: #ffffff;
    text-align: center;
    margin-bottom: 15px;
    font-size: 1.2rem;
}

.modal-nickname-container {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.modal-nickname-input {
    flex: 1;
    padding: 12px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    font-size: 16px;
}

.modal-nickname-input::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

.modal-register-btn {
    padding: 12px 20px;
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.modal-register-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #059669, #047857);
    transform: translateY(-1px);
}

.modal-register-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.modal-ranking-status {
    text-align: center;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.9rem;
}