/* 共通スタイル */
body {
    font-family: Arial, sans-serif;
    margin: 0 auto;
    padding: 20px;
    background-color: #f5f5f5;
    overflow-x: hidden;
    touch-action: manipulation;
}

/* index.html 用スタイル */
.index-page body {
    max-width: 800px;
}

.header {
    text-align: center;
    background: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 30px;
}

.title {
    font-size: 32px;
    font-weight: bold;
    color: #333;
    margin-bottom: 10px;
}

.subtitle {
    color: #666;
    font-size: 18px;
}

.games-list {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.game-item {
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.game-item:hover {
    background-color: #f8f9fa;
    border-color: #0066cc;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.game-description {
    color: #555;
    line-height: 1.6;
}

.opening-tag {
    display: inline-block;
    background-color: #0066cc;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    margin-bottom: 8px;
}

.game-meta {
    margin: 8px 0;
    font-size: 14px;
    font-weight: 500;
}

.game-info {
    margin: 8px 0;
    font-size: 13px;
    color: #666;
}

.player-white {
    display: inline-block;
    background-color: white;
    color: black;
    padding: 3px 6px;
    border-radius: 3px;
    border: 1px solid #ccc;
    font-weight: bold;
    margin: 0 2px;
}

.player-black {
    display: inline-block;
    background-color: black;
    color: white;
    padding: 3px 6px;
    border-radius: 3px;
    font-weight: bold;
    margin: 0 2px;
}

.footer {
    text-align: center;
    margin-top: 30px;
    color: #666;
    font-size: 14px;
}

.view-toggle {
    text-align: center;
    margin-bottom: 20px;
    border-bottom: 1px solid #ddd;
    padding-bottom: 10px;
}

.toggle-btn {
    margin: 0 10px;
    padding: 8px 16px;
    background-color: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    color: #666;
    transition: all 0.3s ease;
}

.toggle-btn:hover {
    background-color: #e9ecef;
}

.toggle-btn.active {
    background-color: #0066cc;
    color: white;
    border-color: #0066cc;
}

.player-section {
    margin-bottom: 30px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
}

.player-header {
    background: linear-gradient(135deg, #0066cc, #004499);
    color: white;
    padding: 20px;
    cursor: pointer;
    transition: background 0.3s ease;
}

.player-header:hover {
    background: linear-gradient(135deg, #0052a3, #003366);
}

.player-name {
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 8px;
}

.player-info {
    font-size: 14px;
    opacity: 0.9;
    margin-bottom: 10px;
}

.player-description {
    font-size: 16px;
    line-height: 1.5;
    opacity: 0.95;
}

.player-games {
    padding: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.5s ease;
}

.player-games.expanded {
    max-height: 1000px;
    padding: 20px;
}

.expand-indicator {
    float: right;
    font-size: 18px;
    transition: transform 0.3s ease;
}

.player-section.expanded .expand-indicator {
    transform: rotate(180deg);
}

/* chess_game_viewer.html 用スタイル */
.viewer-page body {
    max-width: min(1200px, 100vw);
    overflow-x: hidden;
}

.container {
    display: flex;
    gap: 30px;
    align-items: flex-start;
}

.board-container {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    max-width: 100%;
    box-sizing: border-box;
    text-align: center;
}

.board-wrapper {
    position: relative;
    display: inline-block;
    margin: 20px;
}

.chessboard {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    width: min(480px, calc(100vw - 80px));
    height: min(480px, calc(100vw - 80px));
    max-width: calc(100vw - 80px);
    border: 2px solid #333;
    position: relative;
    box-sizing: border-box;
    margin: 0 auto;
}

.square {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.move-highlight {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.move-from {
    background-color: rgba(144, 238, 144, 0.6);
    border: 2px solid #90EE90;
}

.move-to {
    background-color: rgba(144, 238, 144, 0.6);
    border: 2px solid #90EE90;
}

.move-arrow {
    position: absolute;
    pointer-events: none;
    z-index: 4;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
}

.arrow-line {
    stroke: rgba(255, 165, 0, 0.5);
    stroke-width: 6;
    marker-end: url(#arrowhead);
}

.piece {
    width: 50px;
    height: 50px;
    cursor: pointer;
    z-index: 3;
    position: relative;
}

.white-square {
    background-color: #f0d9b5;
}

.dark-square {
    background-color: #b58863;
}

#coordinates-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
}

.coordinates {
    position: absolute;
    font-size: 12px;
    color: #666;
    font-weight: bold;
    pointer-events: none;
}

/* .rank-label と .file-label のスタイルはJavaScriptで動的に設定 */

.controls {
    margin-top: 20px;
    text-align: center;
}

button, .nav-btn {
    margin: 5px;
    padding: 10px 20px;
    font-size: 16px;
    cursor: pointer;
    background-color: #4CAF50;
    color: white;
    border: none;
    border-radius: 4px;
    transition: background-color 0.3s;
}

button:hover, .nav-btn:hover {
    background-color: #45a049;
}

.nav-btn.primary:hover {
    background-color: #2e7d32;
    transform: scale(1.02);
}

button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

.info {
    flex: 1;
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    box-sizing: border-box;
}

.game-header {
    text-align: center;
    margin-bottom: 20px;
}

.game-title {
    font-size: 24px;
    font-weight: bold;
    color: #333;
    margin-bottom: 5px;
}

.game-subtitle {
    color: #666;
    margin-bottom: 10px;
}

.game-details {
    margin-bottom: 10px;
    font-size: 14px;
    color: #555;
}

.player-info {
    margin: 8px 0;
    font-size: 16px;
    font-weight: 500;
}

.match-info {
    margin: 8px 0;
    font-size: 13px;
    color: #666;
}

.match-info span {
    margin-right: 15px;
}

.game-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    padding: 15px 20px;
    background: white;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.nav-link {
    color: #0066cc;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    padding: 10px 16px;
    border-radius: 4px;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 100px;
    justify-content: center;
    text-align: center;
    border: 1px solid #ddd;
    background: #f8f9fa;
}

.nav-link:hover:not(.disabled) {
    background-color: #0066cc;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 102, 204, 0.2);
    border-color: #0066cc;
}

.nav-link.home {
    font-size: 16px;
    font-weight: bold;
    background-color: #0066cc;
    color: white;
    border-color: #0066cc;
    min-width: 120px;
}

.nav-link.home:hover {
    background-color: #004d99;
    border-color: #004d99;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 77, 153, 0.3);
}

.nav-link.disabled {
    color: #999;
    cursor: not-allowed;
    pointer-events: none;
    background: #f5f5f5;
    border-color: #ddd;
}

.move-info {
    background: #f0f0f0;
    padding: 15px;
    margin: 10px 0;
    border-radius: 5px;
}

.current-move {
    font-weight: bold;
    font-size: 20px;
    color: #0066cc;
    margin-bottom: 10px;
}

.explanation {
    line-height: 1.8;
    color: #333;
}

.notation {
    font-family: monospace;
    background: #e0e0e0;
    padding: 10px;
    border-radius: 5px;
    word-wrap: break-word;
    margin-top: 20px;
    line-height: 1.6;
}

.move-notation {
    display: inline;
    padding: 2px 4px;
    margin: 1px;
    border-radius: 3px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.move-notation:hover {
    background-color: #ccc;
}

.move-notation.current.white-move {
    background-color: #f0f0f0;
    color: #333;
    border: 2px solid #333;
    font-weight: bold;
}

.move-notation.current.black-move {
    background-color: #333;
    color: white;
    border: 2px solid #333;
    font-weight: bold;
}

.loading {
    text-align: center;
    padding: 50px;
    color: #666;
}

.error {
    text-align: center;
    padding: 50px;
    color: #cc0000;
}

/* タブレット・iPad用レスポンシブデザイン */
@media (max-width: 1024px) {
    /* chess_game_viewer.html */
    .container {
        flex-direction: column;
        gap: 20px;
    }
    
    .info {
        width: 100%;
        max-width: 100%;
    }
    
    .board-container {
        width: 100%;
        max-width: 100%;
    }
}

/* スマートフォン用レスポンシブデザイン */
@media (max-width: 768px) {
    /* 共通 */
    body {
        padding: 10px;
        overflow-x: hidden;
    }
    
    /* index.html */
    .header {
        padding: 20px 15px;
        margin-bottom: 20px;
    }
    
    .title {
        font-size: 24px;
    }
    
    .subtitle {
        font-size: 16px;
    }
    
    .games-list {
        padding: 15px;
    }
    
    .game-item {
        padding: 15px;
        margin-bottom: 10px;
    }
    
    .game-title {
        font-size: 16px;
    }
    
    .game-details {
        font-size: 12px;
        flex-wrap: wrap;
    }
    
    .game-meta {
        font-size: 12px;
    }
    
    .game-info {
        font-size: 11px;
    }
    
    .game-description {
        font-size: 14px;
    }
    
    .opening-tag {
        font-size: 11px;
        padding: 3px 6px;
    }
    
    .toggle-btn {
        font-size: 13px;
        padding: 6px 12px;
        margin: 0 5px;
    }
    
    .player-header {
        padding: 15px;
    }
    
    .player-name {
        font-size: 20px;
    }
    
    .player-description {
        font-size: 14px;
        line-height: 1.4;
    }
    
    /* chess_game_viewer.html */
    .container {
        flex-direction: column;
        gap: 20px;
    }
    
    /* モバイル用ナビゲーション調整 */
    .game-navigation {
        padding: 12px 8px;
        margin-top: 15px;
        flex-wrap: nowrap;
        gap: 6px;
    }
    
    .nav-link {
        font-size: 11px;
        padding: 8px 6px;
        min-width: 0;
        flex: 1;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .nav-link.home {
        font-size: 12px;
        font-weight: bold;
        flex: 1.2;
    }
    
    .board-container {
        padding: 15px;
        width: 100%;
        max-width: 100vw;
        box-sizing: border-box;
        overflow: hidden;
    }
    
    .board-wrapper {
        margin: 10px;
    }
    
    /* チェス盤をレスポンシブに */
    .chessboard {
        width: calc(100vw - 60px) !important;
        height: calc(100vw - 60px) !important;
        max-width: 350px !important;
        max-height: 350px !important;
        margin: 0 auto;
        aspect-ratio: 1;
        display: grid;
        grid-template-columns: repeat(8, 1fr);
        grid-template-rows: repeat(8, 1fr);
        box-sizing: border-box;
    }
    
    .square {
        width: 100%;
        height: 100%;
        aspect-ratio: 1;
    }
    
    .piece {
        width: 80%;
        height: 80%;
    }
    
    .coordinates {
        font-size: 11px;
    }
    
    .controls {
        margin-top: 15px;
        display: flex;
        justify-content: center;
        align-items: center;
        gap: 8px;
        flex-wrap: nowrap;
    }
    
    .nav-btn {
        font-size: 14px;
        padding: 8px 12px;
        margin: 0;
        flex: 0 0 auto;
        white-space: nowrap;
    }
    
    .nav-btn.primary {
        font-size: 16px;
        padding: 12px 18px;
        font-weight: bold;
        flex: 1;
        max-width: 120px;
    }
    
    .nav-btn.secondary {
        font-size: 12px;
        padding: 8px 12px;
        flex: 0 0 auto;
        min-width: 60px;
    }
    
    .info {
        padding: 15px;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    .game-header {
        margin-bottom: 15px;
    }
    
    .game-title {
        font-size: 20px;
    }
    
    .game-subtitle {
        font-size: 14px;
    }
    
    .game-details {
        font-size: 12px;
    }
    
    .player-info {
        font-size: 14px;
    }
    
    .match-info {
        font-size: 11px;
    }
    
    .move-info {
        padding: 12px;
        margin: 8px 0;
    }
    
    .current-move {
        font-size: 18px;
    }
    
    .explanation {
        font-size: 14px;
        line-height: 1.5;
    }
    
    .notation {
        font-size: 12px;
        padding: 8px;
    }
    
    .move-notation {
        padding: 1px 3px;
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    /* より小さい画面用の追加調整 */
    body {
        padding: 5px;
        overflow-x: hidden;
    }
    
    .title {
        font-size: 20px;
    }
    
    .subtitle {
        font-size: 14px;
    }
    
    .chessboard {
        width: calc(100vw - 40px) !important;
        height: calc(100vw - 40px) !important;
        max-width: 280px !important;
        max-height: 280px !important;
    }
    
    .controls {
        width: 100%;
        display: flex;
        justify-content: center;
        align-items: center;
        gap: 6px;
        flex-wrap: nowrap;
    }
    
    .nav-btn {
        font-size: 11px;
        padding: 8px 10px;
        flex: 0 0 auto;
        white-space: nowrap;
        min-width: 50px;
    }
    
    .nav-btn.primary {
        font-size: 14px;
        padding: 12px 16px;
        font-weight: bold;
        flex: 1;
        max-width: 100px;
        min-height: 44px;
    }
    
    .nav-btn.secondary {
        font-size: 10px;
        padding: 8px 8px;
        flex: 0 0 auto;
        min-width: 45px;
    }
    
    /* 超小画面でのナビゲーション */
    .game-navigation {
        padding: 8px 4px;
        gap: 4px;
    }
    
    .nav-link {
        font-size: 10px;
        padding: 6px 4px;
        min-width: 0;
        flex: 1;
    }
    
    .nav-link.home {
        font-size: 11px;
        flex: 1.1;
    }
    
    .player-description {
        display: -webkit-box;
        -webkit-line-clamp: 3;
        -webkit-box-orient: vertical;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .player-section.expanded .player-description {
        display: block;
        -webkit-line-clamp: unset;
    }
    
    .coordinates {
        font-size: 10px;
    }
    
    .board-wrapper {
        margin: 5px;
    }
    
    .game-meta {
        font-size: 11px;
    }
    
    .game-info {
        font-size: 10px;
    }
    
    .player-info {
        font-size: 12px;
    }
    
    .match-info {
        font-size: 10px;
    }
}

