* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: radial-gradient(ellipse at bottom, #0d1b2a 0%, #1b263b 50%, #0f172a 100%);
    padding: 20px;
    color: white;
    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 {
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(12px);
    padding: 30px;
    border-radius: 20px;
    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);
    border: 1px solid rgba(59, 130, 246, 0.2);
    position: relative;
    z-index: 1;
    margin-top: 70px;
}

h1 {
    text-align: center;
    color: #f1f5f9;
    margin-bottom: 20px;
    font-size: 28px;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.3), 0 4px 6px rgba(0, 0, 0, 0.5);
}

.info {
    display: flex;
    justify-content: space-around;
    margin-bottom: 20px;
    gap: 20px;
}

.info-item {
    text-align: center;
    padding: 10px 20px;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 10px;
    backdrop-filter: blur(8px);
}

.info-label {
    font-size: 12px;
    color: #cbd5e1;
    margin-bottom: 5px;
}

.info-value {
    font-size: 24px;
    font-weight: bold;
    color: #60a5fa;
    text-shadow: 0 0 10px rgba(96, 165, 250, 0.5);
}

.grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    margin-bottom: 20px;
    max-width: 400px;
}

.cell {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: bold;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.6) 0%, rgba(99, 102, 241, 0.6) 100%);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3), 0 0 20px rgba(59, 130, 246, 0.3);
    backdrop-filter: blur(8px);
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.cell:hover:not(.clicked) {
    transform: translateY(-5px);
    box-shadow: 0 8px 12px rgba(0, 0, 0, 0.4), 0 0 30px rgba(59, 130, 246, 0.6);
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.8) 0%, rgba(99, 102, 241, 0.8) 100%);
}

.cell:active:not(.clicked) {
    transform: translateY(-2px);
}

.cell.clicked {
    background: rgba(71, 85, 105, 0.5);
    color: #94a3b8;
    cursor: default;
    transform: scale(0.9);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(148, 163, 184, 0.3);
}

.cell.error {
    animation: shake 0.5s;
    background: #ff4757;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

.button-container {
    display: flex;
    justify-content: center;
    gap: 10px;
}

button.control-btn {
    padding: 12px 30px;
    font-size: 16px;
    font-weight: bold;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    color: white;
}

button.start-btn {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.8) 0%, rgba(22, 163, 74, 0.8) 100%);
    border: 1px solid rgba(34, 197, 94, 0.5);
    box-shadow: 0 0 20px rgba(34, 197, 94, 0.3);
}

button.start-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(34, 197, 94, 0.4), 0 0 30px rgba(34, 197, 94, 0.5);
    background: linear-gradient(135deg, rgba(34, 197, 94, 1) 0%, rgba(22, 163, 74, 1) 100%);
}

button.reset-btn {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.8) 0%, rgba(217, 119, 6, 0.8) 100%);
    border: 1px solid rgba(245, 158, 11, 0.5);
    box-shadow: 0 0 20px rgba(245, 158, 11, 0.3);
}

button.reset-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(245, 158, 11, 0.4), 0 0 30px rgba(245, 158, 11, 0.5);
    background: linear-gradient(135deg, rgba(245, 158, 11, 1) 0%, rgba(217, 119, 6, 1) 100%);
}

.message {
    text-align: center;
    margin-top: 20px;
    font-size: 18px;
    font-weight: bold;
    color: #6ee7b7;
    text-shadow: 0 0 10px rgba(110, 231, 183, 0.5);
    min-height: 30px;
}

/* クリア演出のスタイル */
.clear-animation {
    animation: bounceIn 0.6s ease-out;
}

.clear-title {
    font-size: 48px;
    font-weight: bold;
    background: linear-gradient(45deg, #ff6b6b, #4ecdc4, #45b7d1, #f9ca24, #6c5ce7);
    background-size: 300% 300%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientShift 2s ease infinite;
    margin-bottom: 15px;
    text-shadow: 0 0 30px rgba(255, 255, 255, 0.8);
    filter: drop-shadow(0 0 20px rgba(255, 255, 255, 0.5));
}

.clear-time {
    font-size: 36px;
    color: #ffd700;
    text-shadow: 
        0 0 10px rgba(255, 215, 0, 0.8),
        0 0 20px rgba(255, 215, 0, 0.6),
        0 0 30px rgba(255, 215, 0, 0.4);
    margin-bottom: 15px;
    font-weight: bold;
    animation: pulse 1s ease-in-out infinite;
}

.clear-stars {
    font-size: 32px;
    animation: sparkle 1.5s ease-in-out infinite;
}

/* 星評価スタイル */
.star-rating {
    margin: 20px 0;
    padding: 20px;
    border-radius: 15px;
    background: rgba(59, 130, 246, 0.1);
    border: 2px solid rgba(59, 130, 246, 0.3);
}

.star-display {
    font-size: 48px;
    margin-bottom: 10px;
    animation: starBounce 0.6s ease-out;
    filter: drop-shadow(0 0 10px rgba(255, 215, 0, 0.8));
}

.star-message {
    font-size: 24px;
    font-weight: bold;
    text-shadow: 0 0 10px currentColor;
    animation: fadeInUp 0.8s ease-out;
}

.bonus-star {
    background: linear-gradient(135deg, rgba(255, 107, 107, 0.2) 0%, rgba(255, 215, 0, 0.2) 100%);
    border-color: rgba(255, 107, 107, 0.5);
    animation: bonusGlow 2s ease-in-out infinite;
}

.bonus-star .star-display {
    animation: starBounce 0.6s ease-out, bonusSpin 3s ease-in-out infinite;
    font-size: 52px;
}

@keyframes starBounce {
    0% {
        transform: scale(0) rotate(-180deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.2) rotate(10deg);
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

@keyframes fadeInUp {
    0% {
        transform: translateY(20px);
        opacity: 0;
    }
    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes bonusGlow {
    0%, 100% {
        box-shadow: 0 0 20px rgba(255, 107, 107, 0.5);
    }
    50% {
        box-shadow: 0 0 40px rgba(255, 215, 0, 0.8), 0 0 60px rgba(255, 107, 107, 0.6);
    }
}

@keyframes bonusSpin {
    0%, 100% {
        transform: scale(1) rotate(0deg);
    }
    25% {
        transform: scale(1.1) rotate(5deg);
    }
    75% {
        transform: scale(1.1) rotate(-5deg);
    }
}

@keyframes bounceIn {
    0% {
        transform: scale(0.3);
        opacity: 0;
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes gradientShift {
    0%, 100% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

@keyframes sparkle {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.6;
        transform: scale(1.2);
    }
}

/* 紙吹雪のスタイル */
.confetti {
    position: fixed;
    width: 10px;
    height: 10px;
    top: -10px;
    z-index: 9999;
    animation: confettiFall linear forwards;
}

@keyframes confettiFall {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

/* モーダルのスタイル */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease-out;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.95) 0%, rgba(30, 41, 59, 0.95) 100%);
    padding: 40px;
    border-radius: 24px;
    text-align: center;
    box-shadow: 
        0 0 0 1px rgba(255, 255, 255, 0.1),
        0 25px 50px -12px rgba(0, 0, 0, 0.5),
        0 0 100px rgba(59, 130, 246, 0.3);
    border: 2px solid rgba(59, 130, 246, 0.3);
    max-width: 500px;
    animation: modalSlideIn 0.5s ease-out;
    position: relative;
    overflow: hidden;
}

.modal-content::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.1) 0%, transparent 70%);
    animation: rotate 10s linear infinite;
}

.modal-body {
    position: relative;
    z-index: 1;
    margin-bottom: 30px;
}

.modal-close-btn {
    padding: 15px 40px;
    font-size: 18px;
    font-weight: bold;
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.9) 0%, rgba(22, 163, 74, 0.9) 100%);
    color: white;
    border: 2px solid rgba(34, 197, 94, 0.5);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 0 20px rgba(34, 197, 94, 0.4);
    position: relative;
    z-index: 1;
}

.modal-close-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 16px rgba(34, 197, 94, 0.5), 0 0 30px rgba(34, 197, 94, 0.6);
    background: linear-gradient(135deg, rgba(34, 197, 94, 1) 0%, rgba(22, 163, 74, 1) 100%);
}

.modal-close-btn:active {
    transform: translateY(-1px);
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes modalSlideIn {
    from {
        transform: scale(0.7) translateY(-50px);
        opacity: 0;
    }
    to {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

@keyframes rotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* クリア指標セクション */
.clear-criteria {
    margin-top: 30px;
    padding: 20px;
    background: rgba(59, 130, 246, 0.05);
    border-radius: 15px;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.criteria-title {
    text-align: center;
    font-size: 20px;
    color: #60a5fa;
    margin-bottom: 15px;
    text-shadow: 0 0 10px rgba(96, 165, 250, 0.5);
}

.criteria-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.criteria-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 15px;
    background: rgba(15, 23, 42, 0.5);
    border-radius: 10px;
    border: 1px solid rgba(59, 130, 246, 0.2);
    transition: all 0.3s ease;
}

.criteria-item:hover {
    transform: translateX(5px);
    border-color: rgba(59, 130, 246, 0.4);
}

.criteria-item.legendary {
    background: linear-gradient(135deg, rgba(255, 107, 107, 0.2) 0%, rgba(255, 215, 0, 0.2) 100%);
    border-color: rgba(255, 107, 107, 0.5);
}

.criteria-item.star3 {
    background: rgba(255, 215, 0, 0.1);
    border-color: rgba(255, 215, 0, 0.3);
}

.criteria-item.star2 {
    background: rgba(96, 165, 250, 0.1);
    border-color: rgba(96, 165, 250, 0.3);
}

.criteria-item.star1 {
    background: rgba(110, 231, 183, 0.1);
    border-color: rgba(110, 231, 183, 0.3);
}

.criteria-star {
    font-size: 20px;
    min-width: 120px;
}

.criteria-time {
    font-size: 16px;
    font-weight: bold;
    color: #fcd34d;
    min-width: 80px;
    text-align: center;
}

.criteria-label {
    font-size: 14px;
    color: #cbd5e1;
    font-weight: bold;
    min-width: 100px;
    text-align: right;
}

.criteria-item.legendary .criteria-label {
    color: #ff6b6b;
    text-shadow: 0 0 10px rgba(255, 107, 107, 0.5);
}

.criteria-item.star3 .criteria-label {
    color: #ffd700;
}

.criteria-item.star2 .criteria-label {
    color: #60a5fa;
}

.criteria-item.star1 .criteria-label {
    color: #6ee7b7;
}

/* ランキングセクション */
.ranking-section {
    margin-top: 30px;
    padding-top: 30px;
    border-top: 1px solid rgba(59, 130, 246, 0.3);
}

.ranking-title {
    text-align: center;
    font-size: 24px;
    color: #fcd34d;
    margin-bottom: 15px;
    text-shadow: 0 0 15px rgba(252, 211, 77, 0.5);
}

.ranking-list {
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 15px;
}

.ranking-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 15px;
    margin-bottom: 8px;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 10px;
    transition: all 0.3s ease;
}

.ranking-item:hover {
    background: rgba(59, 130, 246, 0.2);
    transform: translateX(5px);
}

.ranking-item.top3 {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.2) 0%, rgba(245, 158, 11, 0.2) 100%);
    border-color: rgba(251, 191, 36, 0.5);
}

.ranking-left {
    display: flex;
    align-items: center;
    gap: 15px;
    flex: 1;
}

.ranking-stars {
    font-size: 16px;
    margin-left: auto;
    opacity: 0.9;
}

.ranking-rank {
    font-size: 20px;
    font-weight: bold;
    color: #60a5fa;
    min-width: 40px;
    text-align: center;
}

.ranking-item.top3 .ranking-rank {
    font-size: 24px;
}

.ranking-rank.rank-1 {
    color: #ffd700;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.8);
}

.ranking-rank.rank-2 {
    color: #c0c0c0;
    text-shadow: 0 0 10px rgba(192, 192, 192, 0.8);
}

.ranking-rank.rank-3 {
    color: #cd7f32;
    text-shadow: 0 0 10px rgba(205, 127, 50, 0.8);
}

.ranking-time {
    font-size: 22px;
    font-weight: bold;
    color: #6ee7b7;
    text-shadow: 0 0 10px rgba(110, 231, 183, 0.5);
}

.ranking-date {
    font-size: 12px;
    color: #94a3b8;
}

.no-records {
    text-align: center;
    padding: 40px 20px;
    color: #64748b;
    font-size: 16px;
}

.clear-records-btn {
    width: 100%;
    padding: 10px;
    font-size: 14px;
    font-weight: bold;
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.4);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.clear-records-btn:hover {
    background: rgba(239, 68, 68, 0.3);
    border-color: rgba(239, 68, 68, 0.6);
    transform: translateY(-2px);
}

/* ランキングリストのスクロールバー */
.ranking-list::-webkit-scrollbar {
    width: 8px;
}

.ranking-list::-webkit-scrollbar-track {
    background: rgba(15, 23, 42, 0.5);
    border-radius: 10px;
}

.ranking-list::-webkit-scrollbar-thumb {
    background: rgba(59, 130, 246, 0.5);
    border-radius: 10px;
}

.ranking-list::-webkit-scrollbar-thumb:hover {
    background: rgba(59, 130, 246, 0.7);
}

/* スマホ向けレスポンシブデザイン */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .container {
        padding: 15px;
        margin-top: 60px;
        width: 100%;
        max-width: 100%;
    }

    h1 {
        font-size: 22px;
        margin-bottom: 15px;
    }

    .header-link {
        font-size: 0.95rem;
        gap: 8px;
        padding: 0 15px;
    }

    .header-logo {
        width: 28px;
        height: 28px;
    }

    .info {
        gap: 10px;
        margin-bottom: 15px;
    }

    .info-item {
        padding: 8px 15px;
        flex: 1;
    }

    .info-label {
        font-size: 11px;
    }

    .info-value {
        font-size: 20px;
    }

    .grid {
        gap: 8px;
        max-width: 100%;
        width: 100%;
    }

    .cell {
        font-size: 20px;
        border-radius: 8px;
    }

    button.control-btn {
        padding: 10px 20px;
        font-size: 14px;
    }

    .message {
        font-size: 16px;
        margin-top: 15px;
    }

    /* モーダルのレスポンシブ */
    .modal-content {
        width: 95%;
        max-width: 350px;
        padding: 20px;
    }

    .clear-title {
        font-size: 36px;
    }

    .clear-time {
        font-size: 28px;
    }

    .star-display {
        font-size: 36px;
    }

    .star-message {
        font-size: 18px;
    }

    .modal-close-btn {
        padding: 12px 30px;
        font-size: 14px;
    }

    /* ランキングセクション */
    .ranking-title {
        font-size: 20px;
        margin-bottom: 15px;
    }

    .ranking-item {
        padding: 12px;
        gap: 10px;
    }

    .ranking-rank {
        font-size: 18px;
        min-width: 35px;
    }

    .ranking-time {
        font-size: 18px;
    }

    .ranking-stars {
        font-size: 16px;
    }

    .ranking-date {
        font-size: 11px;
    }

    /* クリア指標 */
    .criteria-title {
        font-size: 18px;
        margin-bottom: 12px;
    }

    .criteria-item {
        padding: 8px 10px;
        gap: 8px;
        flex-wrap: nowrap;
    }

    .criteria-star {
        font-size: 16px;
        min-width: 55px;
        flex-shrink: 0;
    }

    .criteria-time {
        font-size: 12px;
        min-width: 60px;
        flex-shrink: 0;
    }

    .criteria-label {
        font-size: 10px;
        min-width: 70px;
        flex-shrink: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

/* 小さいスマホ向け */
@media (max-width: 400px) {
    .container {
        padding: 10px;
    }

    h1 {
        font-size: 20px;
    }

    .grid {
        gap: 6px;
    }

    .cell {
        font-size: 18px;
    }

    .info-value {
        font-size: 18px;
    }

    .clear-title {
        font-size: 30px;
    }

    .clear-time {
        font-size: 24px;
    }

    .star-display {
        font-size: 32px;
    }

    .star-message {
        font-size: 16px;
    }

    .ranking-time {
        font-size: 16px;
    }

    .ranking-rank {
        font-size: 16px;
        min-width: 30px;
    }

    /* クリア指標をさらに小さく */
    .criteria-item {
        padding: 6px 8px;
        gap: 6px;
    }

    .criteria-star {
        font-size: 14px;
        min-width: 50px;
    }

    .criteria-time {
        font-size: 11px;
        min-width: 50px;
    }

    .criteria-label {
        font-size: 9px;
        min-width: 60px;
    }
}
