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

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

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

h1 {
    text-align: center;
    color: #333;
    margin-bottom: 20px;
    font-size: 2em;
}

.game-title {
    font-size: 2.5em;
    font-weight: 900;
    letter-spacing: 0.05em;
    margin-bottom: 25px;
    padding: 10px;
    position: relative;
    display: inline-block;
    white-space: nowrap;
}

.game-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    height: 4px;
    background: linear-gradient(90deg, transparent, #667eea, #764ba2, #f093fb, transparent);
    border-radius: 2px;
}

.title-blocks {
    display: inline-flex;
    gap: 8px;
    vertical-align: middle;
}

.title-block {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    font-size: 1.4em;
    font-weight: 900;
    color: white;
    text-shadow: 
        2px 2px 4px rgba(0, 0, 0, 0.5),
        -1px -1px 2px rgba(255, 255, 255, 0.3),
        0 0 10px rgba(0, 0, 0, 0.2);
    font-family: 'Arial', 'Hiragino Sans', 'Yu Gothic', sans-serif;
}

.title-block::before {
    content: '';
    position: absolute;
    top: 8%;
    left: 8%;
    width: 35%;
    height: 35%;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    filter: blur(4px);
    z-index: 1;
}

.title-block::after {
    content: '';
    position: absolute;
    inset: 4px;
    border-radius: 6px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    z-index: 0;
}

.game-info {
    display: flex;
    justify-content: space-around;
    margin-bottom: 20px;
    gap: 15px;
}

.score-display, .stage-display {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px;
    border-radius: 10px;
    flex: 1;
    text-align: center;
}

.target-display {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    padding: 15px;
    border-radius: 10px;
    flex: 1;
    text-align: center;
}

.score-display .label,
.stage-display .label,
.target-display .label {
    font-size: 0.9em;
    margin-bottom: 5px;
    opacity: 0.9;
}

.score-display .value,
.stage-display .value,
.target-display .value {
    font-size: 1.8em;
    font-weight: bold;
}

#game-board {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 4px;
    background: #ddd;
    padding: 4px;
    border-radius: 10px;
    margin-bottom: 20px;
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
}

.cell {
    aspect-ratio: 1;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    min-width: 50px;
    min-height: 50px;
}

.cell::before {
    content: '';
    position: absolute;
    top: 10%;
    left: 10%;
    width: 30%;
    height: 30%;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    filter: blur(5px);
}

.cell:hover {
    transform: scale(1.1);
    filter: brightness(1.2);
}

.cell.selectable {
    animation: pulse 1s infinite;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.8);
}

.cell.hint-highlight {
    animation: hintPulse 0.8s ease-in-out infinite;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.9), 0 0 40px rgba(255, 215, 0, 0.6);
    position: relative;
    z-index: 100;
    filter: brightness(1.3);
}

@keyframes hintPulse {
    0%, 100% {
        box-shadow: 0 0 15px rgba(255, 215, 0, 0.8), 0 0 30px rgba(255, 215, 0, 0.5);
        transform: scale(1);
        filter: brightness(1.3);
    }
    50% {
        box-shadow: 0 0 25px rgba(255, 215, 0, 1), 0 0 50px rgba(255, 215, 0, 0.8);
        transform: scale(1.05);
        filter: brightness(1.5);
    }
}

.cell.highlighted {
    transform: scale(1.15);
    filter: brightness(1.3);
    box-shadow: 0 0 20px rgba(255, 255, 0, 0.8);
}

.cell.selected {
    transform: scale(1.05);
    filter: brightness(1.2);
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.8), 0 0 30px rgba(255, 215, 0, 0.4);
    border: 2px solid rgba(255, 255, 255, 0.6);
    z-index: 10;
}

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

.cell.removing {
    animation: removeAnimation 0.5s ease-out forwards;
}

@keyframes removeAnimation {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.3) rotate(180deg);
    }
    100% {
        transform: scale(0) rotate(360deg);
        opacity: 0;
    }
}

.color-1 { 
    background: linear-gradient(135deg, #ff6b6b, #ee5a6f);
}
.color-1::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image: radial-gradient(circle, rgba(0,0,0,0.15) 1px, transparent 1px);
    background-size: 8px 8px;
    opacity: 0.5;
}

.color-2 { 
    background: linear-gradient(135deg, #4ecdc4, #44a08d);
}
.color-2::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image: repeating-linear-gradient(45deg, transparent, transparent 4px, rgba(0,0,0,0.1) 4px, rgba(0,0,0,0.1) 8px);
    opacity: 0.4;
}

.color-3 { 
    background: linear-gradient(135deg, #ffe66d, #ffd93d);
}
.color-3::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image: repeating-linear-gradient(-45deg, transparent, transparent 5px, rgba(0,0,0,0.1) 5px, rgba(0,0,0,0.1) 6px);
    opacity: 0.4;
}

.color-4 { 
    background: linear-gradient(135deg, #a8e6cf, #7bc67e);
}
.color-4::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image: 
        repeating-linear-gradient(0deg, transparent, transparent 6px, rgba(0,0,0,0.08) 6px, rgba(0,0,0,0.08) 7px),
        repeating-linear-gradient(90deg, transparent, transparent 6px, rgba(0,0,0,0.08) 6px, rgba(0,0,0,0.08) 7px);
    opacity: 0.5;
}

.color-5 { 
    background: linear-gradient(135deg, #95a5f4, #6b7ce0);
}
.color-5::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image: 
        repeating-linear-gradient(0deg, transparent 40%, rgba(0,0,0,0.1) 40%, rgba(0,0,0,0.1) 60%, transparent 60%),
        repeating-linear-gradient(90deg, transparent 40%, rgba(0,0,0,0.1) 40%, rgba(0,0,0,0.1) 60%, transparent 60%);
    background-size: 10px 10px;
    opacity: 0.4;
}
.color-6 { 
    background: linear-gradient(135deg, #ffffff, #f0f0f0);
    display: flex;
    align-items: center;
    justify-content: center;
}

.white-block-icon {
    font-size: 1.5em;
    color: #ffd700;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.8);
    animation: sparkle 1.5s infinite;
}

@keyframes sparkle {
    0%, 100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
    50% {
        transform: scale(1.2) rotate(180deg);
        opacity: 0.8;
    }
}

.white-transform {
    animation: transformAnimation 0.3s ease-out;
}

@keyframes transformAnimation {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.5) rotate(360deg);
        filter: brightness(2);
    }
    100% {
        transform: scale(1);
    }
}

.controls {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.btn {
    flex: 1;
    padding: 15px;
    font-size: 1em;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: bold;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-secondary {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.btn:active {
    transform: translateY(0);
}

.instructions {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
    color: #555;
}

.instructions h3 {
    margin-bottom: 10px;
    color: #333;
}

.instructions ul {
    list-style-position: inside;
    line-height: 1.8;
}

.instructions li {
    margin-bottom: 5px;
}

.game-over-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    overflow-y: auto;
    padding: 20px;
}

.game-over-modal {
    background: white;
    padding: 30px;
    border-radius: 20px;
    text-align: center;
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    margin: auto;
}

.game-over-modal h2 {
    color: #333;
    margin-bottom: 15px;
    font-size: 1.8em;
}

.game-over-modal .final-score {
    font-size: 2.5em;
    color: #667eea;
    font-weight: bold;
    margin-bottom: 15px;
}

.game-over-modal .stats {
    margin-bottom: 15px;
    color: #666;
    line-height: 1.6;
    font-size: 0.95em;
}

.comment-box {
    background: linear-gradient(135deg, #fff9e6, #ffe6cc);
    border-left: 4px solid #ffa500;
    padding: 12px 15px;
    margin: 15px 0;
    border-radius: 8px;
    font-size: 1em;
    color: #333;
    font-weight: 500;
    text-align: left;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.button-group {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.button-group .btn {
    flex: 1;
}

.share-buttons {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    justify-content: center;
}

.btn-share {
    flex: 1;
    padding: 10px 15px;
    font-size: 0.9em;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.3s ease;
}

.btn-twitter {
    background: #000000;
    color: white;
}

.btn-twitter:hover {
    background: #333333;
}

.btn-line {
    background: #06C755;
    color: white;
}

.btn-line:hover {
    background: #05b04b;
}

.share-icon {
    font-size: 1.2em;
}

/* フッター */
.footer {
    text-align: center;
    padding: 20px;
    color: white;
    font-size: 0.9em;
    margin-top: 30px;
}

.footer a {
    color: white;
    text-decoration: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.5);
    transition: all 0.2s;
}

.footer a:hover {
    border-bottom-color: white;
    opacity: 0.8;
}

.footer .copyright {
    margin-top: 10px;
    opacity: 0.7;
}

.footer-fixed {
    margin-top: 20px;
    padding: 15px;
    font-size: 0.85em;
}

.stage-stats {
    margin: 20px 0;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
    color: #555;
    line-height: 2;
}

.stage-stats strong {
    color: #667eea;
    font-size: 1.2em;
}

.stage-clear h2 {
    color: #28a745 !important;
}

.ranking {
    margin: 15px 0;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
    text-align: left;
}

.ranking h3 {
    text-align: center;
    margin-bottom: 10px;
    color: #333;
    font-size: 1.1em;
}

.ranking ol {
    list-style: none;
    padding: 0;
    counter-reset: ranking;
}

.ranking li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px;
    margin-bottom: 6px;
    background: white;
    border-radius: 5px;
    position: relative;
    font-size: 0.9em;
}

.ranking li::before {
    counter-increment: ranking;
    content: counter(ranking);
    position: absolute;
    left: 10px;
    width: 25px;
    height: 25px;
    background: #667eea;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.9em;
}

.ranking li.current {
    background: linear-gradient(135deg, #fff9c4, #fff59d);
    font-weight: bold;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.rank-score {
    margin-left: 40px;
    font-size: 1.1em;
    color: #667eea;
}

.rank-stage {
    font-size: 0.9em;
    color: #999;
}

.progress-info {
    margin-bottom: 20px;
}

.progress-container {
    width: 100%;
    height: 25px;
    background: #e0e0e0;
    border-radius: 15px;
    overflow: hidden;
    position: relative;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    transition: width 0.5s ease;
    border-radius: 15px;
    box-shadow: 0 0 10px rgba(102, 126, 234, 0.5);
}

@media (max-width: 600px) {
    .container {
        padding: 10px;
    }

    h1 {
        font-size: 1.3em;
    }
    
    .game-title {
        font-size: 1.5em;
        white-space: nowrap;
    }
    
    .title-block {
        width: 38px;
        height: 38px;
        font-size: 1.1em;
        gap: 5px;
    }
    
    .title-blocks {
        gap: 5px;
    }

    .game-info {
        flex-direction: row;
    }

    #game-board {
        grid-template-columns: repeat(10, 1fr);
        max-width: 100%;
        gap: 2px;
        padding: 2px;
    }
    
    .cell {
        min-width: 0;
        min-height: 0;
        border-radius: 4px;
    }
    
    .game-header {
        flex-wrap: wrap;
        gap: 5px;
    }
    
    .btn-back {
        padding: 6px 10px;
        font-size: 0.8em;
    }
}

/* トップページスタイル */
.top-page {
    max-width: 700px;
}

.container:not(.top-page) {
    max-width: 800px;
}

.menu-buttons {
    display: flex;
    justify-content: center;
    margin-bottom: 30px;
}

.btn-large {
    padding: 20px 40px;
    font-size: 1.3em;
    min-width: 250px;
}

.ranking-section {
    margin-bottom: 30px;
    background: #f8f9fa;
    padding: 25px;
    border-radius: 15px;
}

.ranking-section h2 {
    text-align: center;
    color: #333;
    margin-bottom: 20px;
    font-size: 1.8em;
}

.ranking-list {
    margin-bottom: 15px;
}

.ranking-ol {
    list-style: none;
    padding: 0;
    margin: 0;
}

.ranking-item {
    display: flex;
    align-items: flex-start;
    padding: 15px;
    margin-bottom: 10px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s;
}

.ranking-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

.ranking-item.top-three {
    background: linear-gradient(135deg, #fff9e6, #ffffff);
    font-weight: bold;
}

.rank-medal {
    font-size: 2em;
    margin-right: 15px;
    min-width: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rank-number {
    font-size: 1.5rem;
    font-weight: bold;
    color: #667eea;
}

.rank-info {
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 8px;
}

.rank-header {
    display: flex;
    flex-direction: column;
}

.rank-score {
    font-size: 1.4em;
    color: #667eea;
    font-weight: bold;
    margin-bottom: 5px;
}

.rank-details {
    font-size: 0.9em;
    color: #999;
}

.rank-memo-container {
    width: 100%;
}

.rank-memo-input {
    width: 100%;
    padding: 5px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.85em;
    color: #666;
    background: #fafafa;
    transition: all 0.2s;
}

.rank-memo-input:focus {
    outline: none;
    border-color: #667eea;
    background: white;
    box-shadow: 0 0 3px rgba(102, 126, 234, 0.2);
}

.rank-memo-input::placeholder {
    color: #ccc;
}

.no-records {
    text-align: center;
    color: #999;
    padding: 30px;
    font-size: 1.1em;
    line-height: 1.8;
}

.color-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-top: 15px;
    justify-content: flex-start;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.legend-block {
    width: 40px;
    height: 40px;
    border-radius: 5px;
    position: relative;
    overflow: hidden;
}

.legend-block::before {
    content: '';
    position: absolute;
    top: 10%;
    left: 10%;
    width: 30%;
    height: 30%;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    filter: blur(3px);
}

/* ゲームページスタイル */
.game-header {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
    gap: 10px;
    justify-content: center;
}

.game-header h1 {
    flex: 1;
    margin: 0;
    text-align: center;
}

.btn-back {
    padding: 8px 15px;
    font-size: 0.9em;
    flex-shrink: 0;
}

.btn-small {
    flex: none;
    width: auto;
}

.highscore-display {
    text-align: center;
    margin-bottom: 10px;
    padding: 5px;
    background: linear-gradient(135deg, #ffd89b, #19547b);
    border-radius: 8px;
    color: white;
    font-size: 0.85em;
    font-weight: bold;
}

/* スコアポップアップエフェクト */
.score-popup {
    position: fixed;
    font-size: 2em;
    font-weight: bold;
    color: #ffd700;
    text-shadow: 
        0 0 10px rgba(255, 215, 0, 0.8),
        0 0 20px rgba(255, 215, 0, 0.6),
        2px 2px 4px rgba(0, 0, 0, 0.5);
    pointer-events: none;
    z-index: 9999;
    animation: popupAnimation 1.5s ease-out forwards;
    transform: translate(-50%, -50%);
}

.score-popup.medium {
    font-size: 2.5em;
    animation: popupAnimationMedium 1.5s ease-out forwards;
}

.score-popup.big {
    font-size: 3em;
    animation: popupAnimationBig 1.5s ease-out forwards;
}

.score-popup.huge {
    font-size: 4em;
    color: #ff6b6b;
    text-shadow: 
        0 0 15px rgba(255, 107, 107, 1),
        0 0 30px rgba(255, 107, 107, 0.8),
        0 0 45px rgba(255, 107, 107, 0.6),
        3px 3px 6px rgba(0, 0, 0, 0.7);
    animation: popupAnimationHuge 1.8s ease-out forwards;
}

@keyframes popupAnimation {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }
    20% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.2);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -150%) scale(1);
    }
}

@keyframes popupAnimationMedium {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.3) rotate(-10deg);
    }
    20% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.3) rotate(5deg);
    }
    40% {
        transform: translate(-50%, -50%) scale(1.2) rotate(-2deg);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -180%) scale(1.1) rotate(0deg);
    }
}

@keyframes popupAnimationBig {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.2) rotate(-15deg);
    }
    15% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.5) rotate(10deg);
    }
    30% {
        transform: translate(-50%, -50%) scale(1.3) rotate(-5deg);
    }
    45% {
        transform: translate(-50%, -50%) scale(1.4) rotate(2deg);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -200%) scale(1.2) rotate(0deg);
    }
}

@keyframes popupAnimationHuge {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.1) rotate(-20deg);
    }
    10% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.8) rotate(15deg);
    }
    20% {
        transform: translate(-50%, -50%) scale(1.5) rotate(-10deg);
    }
    30% {
        transform: translate(-50%, -50%) scale(1.7) rotate(5deg);
    }
    40% {
        transform: translate(-50%, -50%) scale(1.6) rotate(-3deg);
    }
    50% {
        transform: translate(-50%, -50%) scale(1.65) rotate(0deg);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -250%) scale(1.4) rotate(0deg);
    }
}
