/* 宝石マッチング - Gem Matching Puzzle */

:root {
    --bg-dark: #1a0d2e;
    --bg-light: #2d1b57;
    --primary: #ff6b9d;
    --secondary: #4ecdc4;
    --accent: #ffe66d;
    --success: #06ffa5;
    --danger: #ff3838;
    --white: #ffffff;
    --shadow: rgba(0, 0, 0, 0.3);
    --glow: rgba(255, 107, 157, 0.6);
    
    /* 宝石カラー */
    --gem-red: #ff4757;
    --gem-blue: #3742fa;
    --gem-green: #2ed573;
    --gem-yellow: #ffa502;
    --gem-purple: #a55eea;
    --gem-orange: #ff6348;
    --gem-pink: #ff3838;
    --gem-cyan: #1dd1a1;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--bg-dark) 0%, var(--bg-light) 100%);
    color: var(--white);
    min-height: 100vh;
    overflow-x: hidden;
    user-select: none;
}

/* 背景アニメーション */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 20% 20%, rgba(255, 107, 157, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(78, 205, 196, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 50% 50%, rgba(255, 230, 109, 0.05) 0%, transparent 70%);
    animation: backgroundPulse 15s ease-in-out infinite;
    z-index: -1;
}

@keyframes backgroundPulse {
    0%, 100% { opacity: 0.4; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.1); }
}

.game-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

/* ヘッダー */
.header {
    text-align: center;
    margin-bottom: 30px;
}

.header h1 {
    font-size: 2.8rem;
    background: linear-gradient(45deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 30px var(--glow);
    margin-bottom: 20px;
    animation: titleShine 3s ease-in-out infinite;
}

@keyframes titleShine {
    0%, 100% { 
        text-shadow: 0 0 30px var(--glow);
        transform: scale(1);
    }
    50% { 
        text-shadow: 0 0 50px var(--glow), 0 0 80px rgba(255, 107, 157, 0.4);
        transform: scale(1.02);
    }
}

.game-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 15px;
    max-width: 600px;
    margin: 0 auto;
}

.info-item {
    background: rgba(45, 27, 87, 0.8);
    border: 2px solid var(--primary);
    border-radius: 12px;
    padding: 12px;
    text-align: center;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
    box-shadow: 0 0 20px rgba(255, 107, 157, 0.2);
}

.info-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 25px rgba(255, 107, 157, 0.4);
}

.info-item .label {
    display: block;
    font-size: 0.8rem;
    color: var(--secondary);
    margin-bottom: 5px;
    font-weight: bold;
}

.info-item .value {
    display: block;
    font-size: 1.4rem;
    font-weight: bold;
    color: var(--white);
    text-shadow: 0 0 10px var(--glow);
}

/* ゲームボード */
.game-board-container {
    position: relative;
    display: flex;
    justify-content: center;
    margin: 30px 0;
}

.game-board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    gap: 3px;
    width: 320px;
    height: 320px;
    background: rgba(26, 13, 46, 0.9);
    border: 3px solid var(--primary);
    border-radius: 15px;
    padding: 10px;
    box-shadow: 
        0 0 30px rgba(255, 107, 157, 0.3),
        inset 0 0 20px rgba(0, 0, 0, 0.5);
}

.gem {
    width: 100%;
    height: 100%;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: bold;
    border: 2px solid rgba(255, 255, 255, 0.2);
    box-shadow: 
        inset 0 0 10px rgba(255, 255, 255, 0.1),
        0 2px 8px rgba(0, 0, 0, 0.3);
}

.gem:hover {
    transform: scale(1.1);
    z-index: 10;
    box-shadow: 
        0 0 20px currentColor,
        inset 0 0 15px rgba(255, 255, 255, 0.2);
}

.gem.selected {
    transform: scale(1.15);
    box-shadow: 
        0 0 25px currentColor,
        0 0 40px rgba(255, 255, 255, 0.5);
    animation: gemPulse 0.5s ease-in-out infinite alternate;
}

@keyframes gemPulse {
    0% { transform: scale(1.15); }
    100% { transform: scale(1.2); }
}

.gem.matching {
    animation: matchingGlow 0.8s ease-in-out;
}

@keyframes matchingGlow {
    0%, 100% { 
        transform: scale(1);
        box-shadow: 0 0 10px currentColor;
    }
    50% { 
        transform: scale(1.3);
        box-shadow: 0 0 30px currentColor, 0 0 50px rgba(255, 255, 255, 0.8);
    }
}

.gem.falling {
    animation: gemFall 0.5s ease-in-out;
}

@keyframes gemFall {
    0% { transform: translateY(-100px) rotate(0deg); opacity: 0; }
    100% { transform: translateY(0) rotate(360deg); opacity: 1; }
}

/* 宝石の色 */
.gem.red { background: linear-gradient(135deg, var(--gem-red), #ff6b6b); color: var(--white); }
.gem.blue { background: linear-gradient(135deg, var(--gem-blue), #5352ed); color: var(--white); }
.gem.green { background: linear-gradient(135deg, var(--gem-green), #20bf6b); color: var(--white); }
.gem.yellow { background: linear-gradient(135deg, var(--gem-yellow), #f39c12); color: var(--white); }
.gem.purple { background: linear-gradient(135deg, var(--gem-purple), #8e44ad); color: var(--white); }
.gem.orange { background: linear-gradient(135deg, var(--gem-orange), #e67e22); color: var(--white); }
.gem.pink { background: linear-gradient(135deg, var(--gem-pink), #fd79a8); color: var(--white); }
.gem.cyan { background: linear-gradient(135deg, var(--gem-cyan), #00cec9); color: var(--white); }

/* エフェクトコンテナ */
.effects-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
}

.score-popup {
    position: absolute;
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--accent);
    text-shadow: 0 0 10px var(--accent);
    animation: scorePopup 1s ease-out forwards;
    pointer-events: none;
}

@keyframes scorePopup {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-50px) scale(1.5);
    }
}

.explosion-effect {
    position: absolute;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--accent), transparent);
    animation: explosion 0.6s ease-out forwards;
    pointer-events: none;
}

@keyframes explosion {
    0% {
        opacity: 1;
        transform: scale(0);
    }
    50% {
        opacity: 0.8;
        transform: scale(1.5);
    }
    100% {
        opacity: 0;
        transform: scale(3);
    }
}

/* パワーアップ */
.power-ups {
    background: rgba(45, 27, 87, 0.6);
    border: 2px solid var(--secondary);
    border-radius: 15px;
    padding: 20px;
    margin: 30px 0;
    backdrop-filter: blur(10px);
}

.power-ups h3 {
    text-align: center;
    margin-bottom: 15px;
    color: var(--secondary);
}

.power-up-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 15px;
}

.power-up {
    background: rgba(26, 13, 46, 0.8);
    border: 2px solid var(--accent);
    border-radius: 10px;
    padding: 15px 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    color: var(--white);
    position: relative;
    overflow: hidden;
}

.power-up:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(255, 230, 109, 0.4);
}

.power-up:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.power-up .icon {
    display: block;
    font-size: 1.5rem;
    margin-bottom: 5px;
}

.power-up .name {
    display: block;
    font-size: 0.8rem;
    margin-bottom: 3px;
}

.power-up .count {
    display: block;
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--accent);
}

/* コンボ表示 */
.combo-display {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
}

.combo-display.active {
    animation: comboShow 2s ease-out forwards;
}

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

.combo-text {
    font-size: 3rem;
    font-weight: bold;
    color: var(--accent);
    text-shadow: 0 0 20px var(--accent);
    margin-bottom: 10px;
}

.combo-count {
    font-size: 4rem;
    font-weight: bold;
    color: var(--white);
    text-shadow: 0 0 30px var(--glow);
}

.combo-multiplier {
    font-size: 2rem;
    color: var(--success);
    text-shadow: 0 0 15px var(--success);
}

/* コントロール */
.controls {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
    margin: 30px 0;
}

.btn {
    padding: 12px 20px;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    background: rgba(45, 27, 87, 0.8);
    color: var(--white);
    border: 2px solid var(--primary);
    backdrop-filter: blur(10px);
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: radial-gradient(circle, var(--glow) 0%, transparent 70%);
    transform: translate(-50%, -50%);
    transition: width 0.3s, height 0.3s;
}

.btn:hover::before {
    width: 100%;
    height: 100%;
}

.btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(255, 107, 157, 0.4);
}

.btn.primary {
    background: linear-gradient(45deg, var(--primary), var(--accent));
    border: none;
    color: var(--white);
}

/* モーダル */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(10px);
}

.modal.active {
    display: flex;
    animation: modalFadeIn 0.3s ease-out;
}

@keyframes modalFadeIn {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

.modal-content {
    background: linear-gradient(135deg, var(--bg-light), var(--bg-dark));
    border: 3px solid var(--primary);
    border-radius: 20px;
    padding: 30px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 0 50px rgba(255, 107, 157, 0.5);
}

.modal-content h2 {
    color: var(--accent);
    margin-bottom: 20px;
    font-size: 2rem;
}

.modal-stats {
    margin: 20px 0;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    margin: 10px 0;
    font-size: 1.1rem;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 20px;
}

.modal-buttons .btn {
    flex: 1;
    min-width: 100px;
}

/* 設定パネル */
.settings-panel {
    position: fixed;
    top: 0;
    right: -300px;
    width: 300px;
    height: 100%;
    background: linear-gradient(135deg, var(--bg-light), var(--bg-dark));
    border-left: 3px solid var(--secondary);
    padding: 20px;
    transition: right 0.3s ease;
    z-index: 1500;
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5);
}

.settings-panel.active {
    right: 0;
}

.settings-content h3 {
    color: var(--secondary);
    margin-bottom: 20px;
    text-align: center;
}

.setting-item {
    margin: 20px 0;
}

.setting-item label {
    display: block;
    color: var(--white);
    margin-bottom: 8px;
    font-weight: bold;
}

.setting-item select,
.setting-item input[type="checkbox"] {
    width: 100%;
    padding: 8px;
    border: 2px solid var(--primary);
    border-radius: 5px;
    background: var(--bg-dark);
    color: var(--white);
}

.setting-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

/* ヒント表示 */
.hint-overlay {
    position: absolute;
    display: none;
    z-index: 500;
    pointer-events: none;
}

.hint-overlay.active {
    display: block;
    animation: hintPulse 1.5s ease-in-out infinite;
}

@keyframes hintPulse {
    0%, 100% { opacity: 0.7; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.1); }
}

.hint-arrow {
    width: 0;
    height: 0;
    border-left: 15px solid transparent;
    border-right: 15px solid transparent;
    border-bottom: 20px solid var(--accent);
    margin: 0 auto 10px;
    filter: drop-shadow(0 0 10px var(--accent));
}

.hint-text {
    background: var(--accent);
    color: var(--bg-dark);
    padding: 8px 15px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 0.9rem;
    white-space: nowrap;
    box-shadow: 0 0 15px var(--accent);
}

/* ゲーム説明 */
.instructions {
    background: rgba(45, 27, 87, 0.6);
    border: 2px solid var(--secondary);
    border-radius: 15px;
    padding: 20px;
    margin-top: 30px;
    backdrop-filter: blur(10px);
}

.instructions h3 {
    text-align: center;
    color: var(--secondary);
    margin-bottom: 20px;
}

.instruction-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.instruction-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: rgba(26, 13, 46, 0.6);
    border-radius: 8px;
    border: 1px solid var(--primary);
}

.instruction-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.instruction-text {
    font-size: 0.9rem;
    color: var(--white);
}

/* レスポンシブ */
@media (max-width: 768px) {
    .game-container {
        padding: 10px;
    }
    
    .header h1 {
        font-size: 2rem;
    }
    
    .game-info {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .game-board {
        width: 280px;
        height: 280px;
    }
    
    .power-up-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .controls {
        flex-direction: column;
        align-items: center;
    }
    
    .btn {
        width: 200px;
    }
    
    .instruction-grid {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        padding: 20px;
    }
    
    .modal-buttons {
        flex-direction: column;
    }
}