/* リセットとベース設定 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Yu Gothic', 'Meiryo', sans-serif;
    background: linear-gradient(180deg, #001122 0%, #003366 50%, #000033 100%);
    color: #ffffff;
    overflow-x: hidden;
    min-height: 100vh;
}

/* 画面切り替えシステム */
.screen {
    display: none;
    min-height: 100vh;
    padding: 20px;
    position: relative;
}

.screen.active {
    display: block;
}

/* タイトル画面 */
#title-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.title-container {
    text-align: center;
    z-index: 10;
    position: relative;
}

.game-title {
    font-size: 2.8rem;
    font-weight: 900;
    margin-bottom: 20px;
    text-shadow: 
        0 0 20px rgba(0, 255, 255, 0.8),
        0 0 40px rgba(0, 255, 255, 0.6),
        0 0 60px rgba(0, 255, 255, 0.4);
    animation: titleGlow 3s ease-in-out infinite alternate;
}

.aqua {
    color: #00ffff;
}

.king {
    color: #ffdd00;
}

.subtitle {
    font-size: 1.05rem;
    color: #88ccff;
    margin-bottom: 40px;
    opacity: 0.9;
}

@keyframes titleGlow {
    0% {
        text-shadow: 
            0 0 20px rgba(0, 255, 255, 0.8),
            0 0 40px rgba(0, 255, 255, 0.6);
    }
    100% {
        text-shadow: 
            0 0 30px rgba(0, 255, 255, 1),
            0 0 60px rgba(0, 255, 255, 0.8),
            0 0 80px rgba(0, 255, 255, 0.6);
    }
}

/* 深海背景エフェクト */
.deep-sea-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.bubble {
    position: absolute;
    background: radial-gradient(circle, rgba(255,255,255,0.3) 0%, rgba(0,255,255,0.1) 100%);
    border-radius: 50%;
    animation: bubbleFloat 8s ease-in-out infinite;
}

.bubble-1 {
    width: 60px;
    height: 60px;
    left: 10%;
    animation-delay: 0s;
}

.bubble-2 {
    width: 40px;
    height: 40px;
    left: 80%;
    animation-delay: 2s;
}

.bubble-3 {
    width: 80px;
    height: 80px;
    left: 50%;
    animation-delay: 4s;
}

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

.current-1, .current-2 {
    position: absolute;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, transparent 0%, rgba(0,255,255,0.3) 50%, transparent 100%);
}

.current-1 {
    top: 30%;
    animation: currentFlow 10s linear infinite;
}

.current-2 {
    top: 70%;
    animation: currentFlow 15s linear infinite reverse;
}

@keyframes currentFlow {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

/* メニューボタン */
.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
}

.menu-btn {
    padding: 12px 32px;
    font-size: 0.84rem;
    font-weight: 700;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: linear-gradient(145deg, #004466, #002244);
    color: #ffffff;
    box-shadow: 
        0 4px 15px rgba(0, 100, 200, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    min-width: 175px;
}

.menu-btn:hover {
    transform: translateY(-3px);
    box-shadow: 
        0 8px 25px rgba(0, 100, 200, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    background: linear-gradient(145deg, #005577, #003355);
}

.menu-btn.primary {
    background: linear-gradient(145deg, #ff6600, #cc4400);
    box-shadow: 
        0 4px 15px rgba(255, 100, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.menu-btn.primary:hover {
    background: linear-gradient(145deg, #ff7720, #dd5500);
    box-shadow: 
        0 8px 25px rgba(255, 100, 0, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* 共通画面ヘッダー */
.screen-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid rgba(0, 255, 255, 0.3);
}

.screen-header h2 {
    font-size: 1.4rem;
    color: #00ffff;
    text-shadow: 0 0 10px rgba(0, 255, 255, 0.5);
}

.back-btn {
    padding: 8px 16px;
    font-size: 0.7rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    background: linear-gradient(145deg, #666666, #444444);
    color: #ffffff;
    transition: all 0.3s ease;
}

.back-btn:hover {
    background: linear-gradient(145deg, #777777, #555555);
    transform: translateY(-2px);
}

/* カードコレクション */
.collection-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
    max-width: 1200px;
    margin: 0 auto;
}

.card-display {
    background: linear-gradient(145deg, #003366, #001144);
    border-radius: 15px;
    padding: 20px;
    text-align: center;
    box-shadow: 
        0 8px 25px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
    border: 2px solid rgba(0, 255, 255, 0.2);
}

.card-display:hover {
    transform: translateY(-10px) scale(1.05);
    box-shadow: 
        0 15px 40px rgba(0, 0, 0, 0.5),
        0 0 30px rgba(0, 255, 255, 0.3);
    border-color: rgba(0, 255, 255, 0.5);
}

.card-display img {
    width: 100%;
    height: 450px;
    object-fit: cover;
    border-radius: 10px;
    margin-bottom: 15px;
}

.card-info h3 {
    font-size: 1.05rem;
    margin-bottom: 10px;
    color: #ffdd00;
}

.card-type {
    display: inline-block;
    padding: 5px 15px;
    border-radius: 20px;
    font-weight: 700;
    margin-bottom: 15px;
    text-transform: uppercase;
}

.card-type.power {
    background: linear-gradient(145deg, #ff4444, #cc2222);
    color: white;
}

.card-type.speed {
    background: linear-gradient(145deg, #44ff44, #22cc22);
    color: white;
}

.card-type.technique {
    background: linear-gradient(145deg, #4444ff, #2222cc);
    color: white;
}

.card-type.legend {
    background: linear-gradient(145deg, #ffaa00, #cc8800);
    color: white;
}

.stats {
    display: flex;
    justify-content: space-around;
    font-weight: 600;
}

.stats span {
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    backdrop-filter: blur(5px);
}

/* 遊び方画面 */
.howto-content {
    max-width: 800px;
    margin: 0 auto;
}

.rule-section {
    background: linear-gradient(145deg, #003366, #001144);
    border-radius: 15px;
    padding: 30px;
    margin-bottom: 30px;
    border: 2px solid rgba(0, 255, 255, 0.2);
}

.rule-section h3 {
    font-size: 1.26rem;
    color: #00ffff;
    margin-bottom: 15px;
}

.type-advantages {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.advantage-item {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    font-size: 0.84rem;
    font-weight: 600;
}

.type {
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 700;
    text-transform: uppercase;
    min-width: 120px;
    text-align: center;
}

/* バトル画面 */
.battle-header {
    text-align: center;
    margin-bottom: 30px;
}

/* レジェンドカード特別スタイル */
.legend-card {
    border: 3px solid #ffaa00 !important;
    box-shadow: 
        0 0 20px rgba(255, 170, 0, 0.5),
        0 5px 15px rgba(0, 0, 0, 0.3) !important;
    position: relative;
}

.legend-card::before {
    content: '👑';
    position: absolute;
    top: -3px;
    right: -3px;
    font-size: 1rem;
    background: radial-gradient(circle, #ffaa00, #cc8800);
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

.legend-card:hover {
    border-color: #ffdd00 !important;
    box-shadow: 
        0 0 30px rgba(255, 221, 0, 0.8),
        0 8px 25px rgba(255, 170, 0, 0.5) !important;
    transform: translateY(-8px) scale(1.1);
}

.battle-header h2 {
    font-size: 1.75rem;
    color: #00ffff;
    text-shadow: 0 0 20px rgba(0, 255, 255, 0.8);
    margin-bottom: 15px;
}

.battle-info {
    display: flex;
    justify-content: center;
    gap: 40px;
    font-size: 0.84rem;
    font-weight: 600;
}

.battle-arena {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 30px;
    align-items: start;
    max-width: 1400px;
    margin: 0 auto 30px;
}

.player-area, .cpu-area {
    text-align: center;
}

.player-area h3, .cpu-area h3 {
    font-size: 1.05rem;
    color: #ffdd00;
    margin-bottom: 20px;
}

.card-selection {
    display: flex;
    flex-direction: row;
    gap: 15px;
    justify-content: center;
    align-items: flex-start;
    flex-wrap: wrap;
}

.battle-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 12px;
    background: linear-gradient(145deg, #003366, #001144);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid rgba(0, 255, 255, 0.2);
    text-align: center;
    max-width: 120px;
    flex: 0 0 auto;
}

.battle-card .card-stats {
    display: flex;
    gap: 4px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 8px;
    order: -1; /* 最上部に表示 */
}

.battle-card .card-stats div {
    background: rgba(0, 255, 255, 0.2);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.6rem;
    font-weight: 600;
    color: #00ffff;
}

.battle-card:hover {
    transform: translateY(-5px) scale(1.05);
    border-color: rgba(0, 255, 255, 0.5);
    box-shadow: 0 10px 25px rgba(0, 255, 255, 0.3);
}

.battle-card.selected {
    border-color: #ffdd00;
    background: linear-gradient(145deg, #554400, #332200);
    box-shadow: 0 0 25px rgba(255, 221, 0, 0.5);
}

.battle-card img {
    width: 80px;
    height: 100px;
    object-fit: cover;
    border-radius: 8px;
}

.card-name {
    font-weight: 700;
    color: #ffffff;
}

/* 手札カードのテキストサイズ調整 */
.battle-card .card-name {
    font-size: 0.75rem;
    line-height: 1.2;
}

.battle-card .card-type {
    font-size: 0.65rem;
    padding: 4px 8px;
}

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

.battle-result {
    background: linear-gradient(145deg, #003366, #001144);
    padding: 30px;
    border-radius: 15px;
    text-align: center;
    border: 2px solid rgba(0, 255, 255, 0.2);
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.battle-button {
    padding: 12px 32px;
    font-size: 0.91rem;
    font-weight: 700;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    background: linear-gradient(145deg, #ff6600, #cc4400);
    color: white;
    transition: all 0.3s ease;
    box-shadow: 0 5px 20px rgba(255, 100, 0, 0.3);
}

.battle-button:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(255, 100, 0, 0.5);
}

.battle-button:disabled {
    background: linear-gradient(145deg, #666666, #444444);
    cursor: not-allowed;
    box-shadow: none;
}

.selected-card-area {
    background: linear-gradient(145deg, #003366, #001144);
    border-radius: 15px;
    padding: 25px;
    min-height: 280px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(0, 255, 255, 0.2);
    margin-bottom: 20px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.card-back {
    text-align: center;
    opacity: 0.7;
}

.card-back i {
    font-size: 3rem;
    margin-bottom: 10px;
    color: #666666;
}

.selected-card {
    text-align: center;
    position: relative;
}

.selected-card img {
    width: 220px;
    height: 275px;
    object-fit: cover;
    border-radius: 12px;
    margin-bottom: 15px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}

.selected-card .card-name {
    font-size: 1.4rem;
    font-weight: 700;
    color: #ffdd00;
    margin-bottom: 8px;
    text-shadow: 0 0 10px rgba(255, 221, 0, 0.5);
}

.selected-card .card-type {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 25px;
    font-weight: 700;
    margin-bottom: 12px;
}

.selected-card .card-stats {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.selected-card .card-stats div {
    background: rgba(0, 255, 255, 0.3);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 700;
    color: #ffffff;
}

/* 手札セクション */
.hand-section {
    border-top: 2px solid rgba(0, 255, 255, 0.2);
    padding-top: 15px;
}

.hand-section h4 {
    font-size: 1rem;
    color: #88ccff;
    margin-bottom: 15px;
    text-align: center;
    opacity: 0.9;
}

/* レジェンドカード選択時の特別エフェクト */
.legend-selected {
    position: relative;
}

.legend-selected::before {
    content: '👑';
    position: absolute;
    top: -10px;
    right: -10px;
    font-size: 2rem;
    z-index: 1;
    animation: crownGlow 2s ease-in-out infinite alternate;
}

.legend-selected img {
    border: 3px solid #ffaa00;
    box-shadow: 
        0 0 25px rgba(255, 170, 0, 0.8),
        0 8px 20px rgba(0, 0, 0, 0.4);
}

@keyframes crownGlow {
    0% {
        transform: scale(1);
        filter: drop-shadow(0 0 10px rgba(255, 170, 0, 0.8));
    }
    100% {
        transform: scale(1.1);
        filter: drop-shadow(0 0 20px rgba(255, 221, 0, 1));
    }
}

.battle-controls {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 30px;
}

/* 結果画面 */
#result-screen {
    display: flex;
    align-items: center;
    justify-content: center;
}

.result-container {
    text-align: center;
    max-width: 600px;
}

.final-result {
    font-size: 2.1rem;
    font-weight: 900;
    margin-bottom: 20px;
    text-shadow: 0 0 20px currentColor;
}

.final-result.victory {
    color: #ffdd00;
}

.final-result.defeat {
    color: #ff4444;
}

.final-score {
    font-size: 1.26rem;
    margin-bottom: 40px;
    color: #88ccff;
}

.result-buttons {
    display: flex;
    gap: 20px;
    justify-content: center;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    .game-title {
        font-size: 1.75rem;
    }
    
    .subtitle {
        font-size: 0.84rem;
    }
    
    .battle-arena {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .battle-info {
        flex-direction: column;
        gap: 10px;
    }
    
    .card-selection {
        flex-direction: row;
        overflow-x: auto;
        padding: 10px;
        gap: 10px;
    }
    
    .battle-card {
        flex-direction: column;
        min-width: 100px;
        max-width: 100px;
        text-align: center;
        padding: 8px;
    }
    
    .battle-card img {
        width: 70px;
        height: 85px;
    }
    
    .battle-card .card-stats {
        gap: 4px;
    }
    
    .battle-card .card-stats div {
        font-size: 0.6rem;
        padding: 2px 6px;
    }
    
    .selected-card img {
        width: 180px;
        height: 225px;
    }
    
    .hand-section h4 {
        font-size: 0.9rem;
    }
    
    .selected-card-area {
        min-height: 240px;
        padding: 20px;
    }
    
    .collection-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .result-buttons {
        flex-direction: column;
        align-items: center;
    }
}

/* アニメーション効果 */
@keyframes cardGlow {
    0% {
        box-shadow: 0 0 5px rgba(0, 255, 255, 0.3);
    }
    50% {
        box-shadow: 0 0 25px rgba(0, 255, 255, 0.8), 0 0 35px rgba(0, 255, 255, 0.5);
    }
    100% {
        box-shadow: 0 0 5px rgba(0, 255, 255, 0.3);
    }
}

.battle-card.selected {
    animation: cardGlow 2s ease-in-out infinite;
}

@keyframes resultPulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

.battle-result.animated {
    animation: resultPulse 0.6s ease-in-out;
}