/**
 * 21ゲーム WordPress プラグイン スタイル（シンプル版）
 * Version: 1.0.0
 */

/* CSS カスタムプロパティ */
:root {
    --game21-primary: #3498db;
    --game21-primary-dark: #2980b9;
    --game21-secondary: #e67e22;
    --game21-secondary-dark: #d35400;
    --game21-success: #27ae60;
    --game21-success-dark: #2ecc71;
    --game21-danger: #e74c3c;
    --game21-danger-dark: #c0392b;
    --game21-purple: #8e44ad;
    --game21-purple-dark: #9b59b6;
    --game21-text: #2c3e50;
    --game21-text-light: #7f8c8d;
    --game21-bg: #ffffff;
    --game21-bg-secondary: #ecf0f1;
    --game21-shadow: rgba(0,0,0,0.1);
    --game21-border-radius: 12px;
    --game21-transition: all 0.3s ease;
}

/* 基本コンテナ */
.game21-container {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    max-width: 600px;
    margin: 20px auto;
    padding: 0;
    box-sizing: border-box;
    position: relative;
}

.game21-wrapper {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.08) 0%, rgba(118, 75, 162, 0.08) 100%);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 10px 30px var(--game21-shadow);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    text-align: center;
    color: var(--game21-text);
    position: relative;
    overflow: hidden;
}

/* タイトル */
.game21-title {
    margin: 0 0 30px 0;
    font-size: clamp(2rem, 5vw, 2.5rem);
    font-weight: 700;
    color: var(--game21-text);
    text-shadow: 2px 2px 4px var(--game21-shadow);
}

/* ゲーム情報パネル */
.game21-game-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
    padding: 20px;
    background: linear-gradient(135deg, rgba(52, 152, 219, 0.1), rgba(52, 152, 219, 0.05));
    border-radius: var(--game21-border-radius);
    border: 2px solid var(--game21-primary);
}

.game21-score-item {
    text-align: center;
}

.game21-score-label {
    font-size: 0.85rem;
    color: var(--game21-text-light);
    margin-bottom: 8px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.game21-score-value {
    font-size: 1.4rem;
    font-weight: bold;
    color: var(--game21-text);
    transition: var(--game21-transition);
}

/* 現在の数字表示 */
.game21-current-number {
    font-size: clamp(2.5rem, 8vw, 3.5rem);
    font-weight: bold;
    margin: 25px 0;
    color: var(--game21-danger);
    text-shadow: 2px 2px 4px var(--game21-shadow);
    transition: var(--game21-transition);
}

/* プログレスバー */
.game21-progress-container {
    width: 100%;
    height: 8px;
    background: var(--game21-bg-secondary);
    border-radius: 4px;
    margin: 20px 0;
    overflow: hidden;
    position: relative;
}

.game21-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--game21-success), var(--game21-danger));
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 4px;
}

/* 数字グリッド */
.game21-number-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(50px, 1fr));
    gap: 8px;
    margin: 25px 0;
    padding: 25px;
    background: linear-gradient(135deg, rgba(236, 240, 241, 0.6), rgba(236, 240, 241, 0.3));
    border-radius: var(--game21-border-radius);
    backdrop-filter: blur(5px);
}

.game21-number-cell {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-weight: bold;
    font-size: 1.1rem;
    transition: var(--game21-transition);
    border: 2px solid transparent;
    cursor: default;
    position: relative;
}

.game21-number-cell.empty {
    background: var(--game21-bg-secondary);
    color: var(--game21-text-light);
    border-color: rgba(127, 140, 141, 0.2);
}

.game21-number-cell.player {
    background: linear-gradient(135deg, var(--game21-primary), var(--game21-primary-dark));
    color: white;
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.3);
    transform: scale(1.05);
    border-color: var(--game21-primary);
}

.game21-number-cell.computer {
    background: linear-gradient(135deg, var(--game21-secondary), var(--game21-secondary-dark));
    color: white;
    box-shadow: 0 4px 15px rgba(230, 126, 34, 0.3);
    transform: scale(1.05);
    border-color: var(--game21-secondary);
}

/* アニメーション */
.game21-animate-select {
    animation: game21-select 0.3s ease-out;
}

@keyframes game21-select {
    0% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1.05);
        opacity: 1;
    }
}

/* ターン表示 */
.game21-turn-indicator {
    font-size: 1.2rem;
    margin: 25px 0;
    padding: 20px;
    border-radius: var(--game21-border-radius);
    font-weight: 600;
    transition: var(--game21-transition);
    backdrop-filter: blur(5px);
}

.game21-turn-indicator.player-turn {
    background: linear-gradient(135deg, var(--game21-primary), var(--game21-primary-dark));
    color: white;
    box-shadow: 0 4px 20px rgba(52, 152, 219, 0.3);
}

.game21-turn-indicator.computer-turn {
    background: linear-gradient(135deg, var(--game21-secondary), var(--game21-secondary-dark));
    color: white;
    box-shadow: 0 4px 20px rgba(230, 126, 34, 0.3);
}

/* ボタン共通スタイル */
.game21-buttons {
    margin: 25px 0;
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.game21-wrapper button {
    padding: 15px 25px;
    font-size: 1.1rem;
    font-weight: 600;
    border: none;
    border-radius: var(--game21-border-radius);
    cursor: pointer;
    transition: var(--game21-transition);
    min-width: 140px;
    box-shadow: 0 4px 15px var(--game21-shadow);
    background: none;
    position: relative;
    overflow: hidden;
    font-family: inherit;
}

/* ホバーエフェクト */
.game21-wrapper button::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.6s ease, height 0.6s ease;
}

.game21-wrapper button:hover::before {
    width: 300px;
    height: 300px;
}

/* アクションボタン */
.game21-action-btn {
    background: linear-gradient(135deg, var(--game21-success), var(--game21-success-dark)) !important;
    color: white !important;
    position: relative;
}

.game21-action-btn:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(39, 174, 96, 0.4);
}

.game21-action-btn:active:not(:disabled) {
    transform: translateY(-1px);
}

.game21-action-btn:disabled {
    background: linear-gradient(135deg, #bdc3c7, #95a5a6) !important;
    cursor: not-allowed !important;
    transform: none !important;
    opacity: 0.6;
}

/* ボタンヒント */
.game21-btn-hint {
    font-size: 0.85rem;
    opacity: 0.8;
    font-weight: 400;
    display: block;
    margin-top: 2px;
}

/* コントロールボタン */
.game21-control-btn {
    background: linear-gradient(135deg, var(--game21-purple), var(--game21-purple-dark)) !important;
    color: white !important;
}

.game21-control-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(142, 68, 173, 0.4);
}

/* スタートボタン */
.game21-start-btn {
    background: linear-gradient(135deg, var(--game21-secondary), var(--game21-secondary-dark)) !important;
    color: white !important;
    font-size: 1.3rem !important;
    padding: 20px 35px !important;
    min-width: 180px !important;
}

.game21-start-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(243, 156, 18, 0.4);
}

/* ルール選択 */
.game21-rule-selector {
    margin: 25px 0;
    padding: 25px;
    background: linear-gradient(135deg, rgba(142, 68, 173, 0.08), rgba(142, 68, 173, 0.04));
    border-radius: var(--game21-border-radius);
    border: 2px solid var(--game21-purple);
}

.game21-rule-selector h3 {
    margin-top: 0;
    margin-bottom: 20px;
    color: var(--game21-purple);
    font-size: 1.3rem;
}

.game21-rule-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    justify-content: center;
}

.game21-rule-btn {
    background: linear-gradient(135deg, var(--game21-purple-dark), var(--game21-purple)) !important;
    color: white !important;
    padding: 25px 20px !important;
    font-size: 1rem !important;
    border-radius: var(--game21-border-radius) !important;
    text-align: center;
    transition: var(--game21-transition);
    border: 3px solid transparent !important;
    min-width: 200px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.game21-rule-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(155, 89, 182, 0.4);
}

.game21-rule-btn.selected {
    background: linear-gradient(135deg, var(--game21-secondary), var(--game21-secondary-dark)) !important;
    border-color: #f39c12 !important;
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(243, 156, 18, 0.3);
}

.game21-rule-title {
    font-weight: bold;
    font-size: 1.2rem;
    margin-bottom: 8px;
}

.game21-rule-desc {
    font-size: 0.9rem;
    opacity: 0.9;
    line-height: 1.4;
}

.game21-rule-description {
    margin-top: 15px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    font-style: italic;
    color: var(--game21-text-light);
}

/* 難易度選択 */
.game21-difficulty-selector {
    margin: 20px 0;
    padding: 20px;
    background: linear-gradient(135deg, rgba(39, 174, 96, 0.08), rgba(39, 174, 96, 0.04));
    border-radius: var(--game21-border-radius);
    border: 2px solid var(--game21-success);
}

.game21-difficulty-selector h4 {
    margin-top: 0;
    margin-bottom: 15px;
    color: var(--game21-success);
    font-size: 1.2rem;
}

.game21-difficulty-options {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.game21-difficulty-btn {
    background: linear-gradient(135deg, var(--game21-success), var(--game21-success-dark)) !important;
    color: white !important;
    padding: 15px 20px !important;
    font-size: 0.9rem !important;
    border-radius: var(--game21-border-radius) !important;
    text-align: center;
    transition: var(--game21-transition);
    border: 2px solid transparent !important;
    min-width: 100px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.game21-difficulty-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(39, 174, 96, 0.4);
}

.game21-difficulty-btn.selected {
    background: linear-gradient(135deg, var(--game21-primary), var(--game21-primary-dark)) !important;
    border-color: var(--game21-primary) !important;
    transform: scale(1.05);
}

.game21-difficulty-icon {
    font-size: 1.5rem;
}

.game21-difficulty-name {
    font-size: 0.85rem;
    font-weight: 600;
}

/* 結果表示 */
.game21-result {
    font-size: 1.8rem;
    margin: 25px 0;
    font-weight: bold;
    padding: 25px;
    border-radius: var(--game21-border-radius);
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    line-height: 1.4;
    transition: var(--game21-transition);
}

.game21-result.win {
    background: linear-gradient(135deg, var(--game21-success), var(--game21-success-dark));
    color: white;
    animation: game21-celebration 0.6s ease-out;
    box-shadow: 0 6px 25px rgba(39, 174, 96, 0.4);
}

.game21-result.lose {
    background: linear-gradient(135deg, var(--game21-danger), var(--game21-danger-dark));
    color: white;
    animation: game21-shake 0.6s ease-out;
    box-shadow: 0 6px 25px rgba(231, 76, 60, 0.4);
}

/* メッセージ */
.game21-message {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 20px;
    border-radius: 8px;
    font-weight: 600;
    z-index: 9999;
    max-width: 300px;
    box-shadow: 0 4px 20px var(--game21-shadow);
    backdrop-filter: blur(10px);
}

.game21-message-success {
    background: linear-gradient(135deg, var(--game21-success), var(--game21-success-dark));
    color: white;
}

.game21-message-error {
    background: linear-gradient(135deg, var(--game21-danger), var(--game21-danger-dark));
    color: white;
}

.game21-message-info {
    background: linear-gradient(135deg, var(--game21-primary), var(--game21-primary-dark));
    color: white;
}

/* 履歴表示 */
.game21-history {
    margin: 20px 0;
    padding: 20px;
    background: linear-gradient(135deg, rgba(127, 140, 141, 0.05), rgba(127, 140, 141, 0.02));
    border-radius: var(--game21-border-radius);
    border: 1px solid rgba(127, 140, 141, 0.2);
}

.game21-history h5 {
    margin-top: 0;
    margin-bottom: 15px;
    color: var(--game21-text);
    font-size: 1.1rem;
}

.game21-history-list {
    display: none;
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 15px;
}

.game21-history-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    margin: 5px 0;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 6px;
    font-size: 0.9rem;
}

.game21-history-turn {
    font-weight: bold;
    color: var(--game21-text-light);
    min-width: 20px;
}

.game21-history-player {
    font-weight: 600;
    min-width: 100px;
}

.game21-history-move {
    color: var(--game21-text-light);
}

.game21-toggle-history {
    background: linear-gradient(135deg, var(--game21-text-light), #95a5a6) !important;
    color: white !important;
    padding: 10px 20px !important;
    font-size: 0.9rem !important;
    min-width: auto !important;
}

.game21-toggle-history:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(127, 140, 141, 0.4);
}

/* アニメーション */
@keyframes game21-celebration {
    0% { transform: scale(0.8) rotate(-5deg); }
    25% { transform: scale(1.1) rotate(2deg); }
    50% { transform: scale(0.95) rotate(-1deg); }
    75% { transform: scale(1.05) rotate(1deg); }
    100% { transform: scale(1) rotate(0deg); }
}

@keyframes game21-shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-8px); }
    20%, 40%, 60%, 80% { transform: translateX(8px); }
}

/* テーマバリエーション */

/* ダークテーマ */
.game21-container.theme-dark {
    --game21-text: #ecf0f1;
    --game21-text-light: #bdc3c7;
    --game21-bg: #2c3e50;
    --game21-bg-secondary: #34495e;
    --game21-shadow: rgba(0,0,0,0.3);
}

.game21-container.theme-dark .game21-wrapper {
    background: linear-gradient(135deg, rgba(44, 62, 80, 0.9) 0%, rgba(52, 73, 94, 0.9) 100%);
    border-color: rgba(255, 255, 255, 0.1);
}

.game21-container.theme-dark .game21-number-cell.empty {
    background: var(--game21-bg-secondary);
    color: var(--game21-text-light);
}

/* ミニマルテーマ */
.game21-container.theme-minimal {
    --game21-border-radius: 4px;
}

.game21-container.theme-minimal .game21-wrapper {
    background: var(--game21-bg);
    border: 1px solid #e0e0e0;
    box-shadow: 0 2px 10px var(--game21-shadow);
    border-radius: 8px;
}

.game21-container.theme-minimal .game21-wrapper button {
    border-radius: 4px;
    box-shadow: 0 1px 3px var(--game21-shadow);
}

.game21-container.theme-minimal .game21-number-cell {
    border-radius: 4px;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    .game21-container {
        margin: 10px;
        padding: 0;
    }
    
    .game21-wrapper {
        padding: 20px;
    }
    
    .game21-title {
        font-size: 1.8rem;
        margin-bottom: 20px;
    }
    
    .game21-current-number {
        font-size: 2.5rem;
    }
    
    .game21-number-grid {
        grid-template-columns: repeat(auto-fit, minmax(45px, 1fr));
        gap: 6px;
        padding: 15px;
    }
    
    .game21-number-cell {
        font-size: 1rem;
    }
    
    .game21-buttons {
        flex-direction: column;
        align-items: center;
    }
    
    .game21-wrapper button {
        width: 100%;
        max-width: 280px;
        margin: 5px 0;
    }
    
    .game21-rule-options {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .game21-rule-btn {
        width: 100%;
        max-width: 300px;
    }
    
    .game21-difficulty-options {
        justify-content: space-around;
    }
    
    .game21-difficulty-btn {
        min-width: 80px;
        padding: 12px 15px !important;
    }
    
    .game21-game-info {
        grid-template-columns: 1fr;
        gap: 10px;
        text-align: center;
    }
    
    .game21-score-item {
        margin: 5px 0;
    }
    
    .game21-message {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
    }
}

@media (max-width: 480px) {
    .game21-wrapper {
        padding: 15px;
    }
    
    .game21-title {
        font-size: 1.6rem;
    }
    
    .game21-current-number {
        font-size: 2rem;
    }
    
    .game21-number-grid {
        grid-template-columns: repeat(auto-fit, minmax(40px, 1fr));
        gap: 4px;
        padding: 10px;
    }
    
    .game21-number-cell {
        font-size: 0.9rem;
    }
    
    .game21-result {
        font-size: 1.4rem;
        padding: 20px;
        min-height: 60px;
    }
    
    .game21-wrapper button {
        padding: 12px 20px;
        font-size: 1rem;
        min-width: 120px;
    }
    
    .game21-start-btn {
        font-size: 1.1rem !important;
        padding: 15px 25px !important;
        min-width: 160px !important;
    }
    
    .game21-difficulty-btn {
        min-width: 70px;
        padding: 10px 12px !important;
    }
    
    .game21-difficulty-icon {
        font-size: 1.2rem;
    }
    
    .game21-difficulty-name {
        font-size: 0.75rem;
    }
}

/* アクセシビリティ */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ハイコントラストモード */
@media (prefers-contrast: high) {
    .game21-container {
        --game21-shadow: rgba(0,0,0,0.8);
    }
    
    .game21-wrapper {
        border: 2px solid #000;
    }
    
    .game21-number-cell {
        border: 2px solid #000;
    }
}

/* フォーカス表示 */
.game21-wrapper button:focus {
    outline: 3px solid var(--game21-primary);
    outline-offset: 2px;
}

.game21-wrapper button:focus:not(:focus-visible) {
    outline: none;
}

/* ホバー効果の無効化（タッチデバイス） */
@media (hover: none) {
    .game21-wrapper button:hover {
        transform: none;
        box-shadow: 0 4px 15px var(--game21-shadow);
    }
}

/* プリント用スタイル */
@media print {
    .game21-container {
        box-shadow: none;
        background: white;
    }
    
    .game21-wrapper {
        box-shadow: none;
        background: white;
        border: 1px solid #000;
    }
    
    .game21-wrapper button {
        display: none;
    }
    
    .game21-message {
        display: none;
    }
}