/* ============================================================
   トーナメント表専用スタイル
   ============================================================ */

/* 優勝バナー */
.champion-banner {
    background: linear-gradient(135deg, #ffd700 0%, #ffed4e 100%);
    border-radius: 15px;
    padding: 30px 20px;
    margin-bottom: 30px;
    margin-left: 0;
    margin-right: 0;
    text-align: center;
    box-shadow: 0 8px 25px rgba(255, 215, 0, 0.4);
    animation: shine 2s ease-in-out infinite;
}

@keyframes shine {

    0%,
    100% {
        box-shadow: 0 8px 25px rgba(255, 215, 0, 0.4);
    }

    50% {
        box-shadow: 0 12px 35px rgba(255, 215, 0, 0.6);
    }
}

.champion-trophy {
    font-size: 4em;
    margin-bottom: 10px;
}

.champion-label {
    font-size: 1.3em;
    color: #856404;
    font-weight: bold;
    margin-bottom: 10px;
}

.champion-name {
    font-size: 2em;
    font-weight: bold;
    color: #333;
}

/* ズームコントロール */
.zoom-control {
    display: none;
    background: white;
    padding: 15px;
    margin: 15px 20px 0 20px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border: 2px solid #003366;
}

.zoom-label {
    font-size: 0.9em;
    font-weight: bold;
    color: #003366;
    margin-bottom: 10px;
    text-align: center;
}

.zoom-buttons {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.zoom-btn {
    flex: 1;
    padding: 10px 15px;
    background: #f5f5f5;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 0.9em;
    font-weight: bold;
    color: #333;
    cursor: pointer;
    transition: all 0.3s;
}

.zoom-btn:active {
    transform: scale(0.95);
}

.zoom-btn.active {
    background: #003366;
    color: white;
    border-color: #003366;
}

/* 情報パネル */
.info-panel {
    background: #e3f2fd;
    padding: 15px;
    margin: 20px 0 0 0;
    border-radius: 4px;
    border-left: 4px solid #1976d2;
    font-size: 0.95em;
}

/* トーナメントページ専用 - パディングを完全に削除 */
.app-container.tournament-page {
    padding: 0 !important;
    max-width: 100% !important;
}

/* トーナメント全体のラッパー */
.tournament-wrapper {
    background: #f5f5f5;
    padding: 0;
    margin: 0;
    box-shadow: none;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    position: relative;
    width: 100%;
    touch-action: pan-x pan-y;
    overscroll-behavior-x: contain;
    overscroll-behavior-y: none;
    height: 600px;
    /* 1000px × 0.6 = 600px */
}

.tournament-area {
    position: relative;
    width: 1600px;
    height: 1000px;
    background: #f5f5f5;
    margin: 0;
    transition: transform 0.3s ease;
    touch-action: inherit;
    transform: scale(0.6);
    transform-origin: top left;
    border: none
}

/* ============================================================
   チームカード（課題1対応：シードチームを通常表示に）
   ============================================================ */
.team-card {
    position: absolute;
    width: 120px;
    height: 80px;
    background: white;
    border: 2px solid #003366;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: default;
    transition: transform 0.2s ease;
    transform: translate(-50%, -50%);
    z-index: 10;
}

.team-card:hover {
    transform: translate(-50%, -50%) scale(1.05);
}

/* シードチームも通常表示（金色背景を削除） */
.team-card.seed {
    background: white;
    border: 2px solid #003366;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* 優勝カード */
.team-card.champion-card {
    background: linear-gradient(135deg, #ffd700 0%, #ffed4e 100%);
    border: 4px solid #ffa000;
    box-shadow: 0 8px 16px rgba(255, 215, 0, 0.5);
    animation: champion-glow 2s ease-in-out infinite;
}

@keyframes champion-glow {

    0%,
    100% {
        box-shadow: 0 8px 16px rgba(255, 215, 0, 0.5);
    }

    50% {
        box-shadow: 0 12px 24px rgba(255, 215, 0, 0.8);
    }
}

.team-icon {
    font-size: 24px;
    margin-bottom: 5px;
}

/* シードチームのアイコンも通常色に */
.team-card.seed .team-icon {
    color: inherit;
}

.team-name {
    font-size: 14px;
    font-weight: bold;
    color: #003366;
    text-align: center;
}

/* シードチームの名前も通常色に */
.team-card.seed .team-name {
    color: #003366;
    font-size: 14px;
}

/* 星マークを非表示 */
.seed-mark {
    display: none;
}

/* ============================================================
   試合ブロック
   ============================================================ */
.match-block {
    position: absolute;
    width: 180px;
    height: 80px;
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    cursor: pointer;
    transition: all 0.2s ease;
    transform: translate(-50%, -50%);
    padding: 10px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    z-index: 10;
}

.match-block:hover {
    transform: translate(-50%, -50%) scale(1.02);
}

.match-block:active {
    transform: translate(-50%, -50%) scale(0.98);
    background: #f5f5f5;
}

.match-block.playing {
    background: #fff3cd;
    border: 3px solid #ff6b6b;
    animation: pulse 2s infinite;
}

.match-block.playing:active {
    background: #ffe8a3;
}

.match-block.finished {
    background: #e8f5e9;
    border: 2px solid #388e3c;
}

.match-block.finished:active {
    background: #c8e6c9;
}

.match-block.final {
    background: linear-gradient(135deg, #fff8e1 0%, #ffe082 100%);
    border: 3px solid #ffa000;
    box-shadow: 0 4px 12px rgba(255, 160, 0, 0.3);
}

.match-block.final:active {
    background: #ffd54f;
}

.match-block.third-place {
    background: linear-gradient(135deg, #fff3e0 0%, #ffcc80 100%);
    border: 2px solid #ff9800;
    box-shadow: 0 4px 12px rgba(255, 152, 0, 0.3);
}

.match-block.third-place:active {
    background: #ffb74d;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.8;
    }
}

.match-label {
    font-size: 11px;
    font-weight: bold;
    color: #666;
    text-align: center;
    margin-bottom: 8px;
}

.match-block.final .match-label {
    color: #ffa000;
    font-size: 12px;
}

.match-block.third-place .match-label {
    color: #ff9800;
}

.match-score-line {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #333;
    text-align: center;
    line-height: 1.4;
}

.match-team-name {
    font-size: 13px;
    font-weight: 600;
    color: #333;
}

.match-team-name.placeholder {
    color: #999;
    font-style: italic;
    font-size: 12px;
}

/* ============================================================
   課題2対応：勝者チーム名の強調表示
   ============================================================ */
.match-team-name.winner {
    color: #d32f2f;
    font-weight: bold;
    font-size: 14px;
}

.match-team-name.winner::before {
    content: '👑 ';
    font-size: 12px;
}

.match-team-score {
    font-size: 16px;
    font-weight: bold;
    color: #003366;
    min-width: 20px;
    text-align: center;
}

.match-team-score.winner {
    color: #d32f2f;
    font-size: 18px;
}

.match-score-separator {
    color: #999;
    font-size: 14px;
    font-weight: normal;
}

/* ============================================================
   試合ステータス表示
   ============================================================ */
.match-time {
    font-size: 10px;
    color: #999;
    text-align: center;
    margin-top: 8px;
}

/* 試合中の表示 */
.match-time.status-playing {
    color: #ff6b6b;
    font-weight: bold;
    font-size: 11px;
}

/* 試合終了の表示 */
.match-time.status-finished {
    color: #388e3c;
    font-weight: bold;
    font-size: 11px;
}

/* 待機中の表示 */
.match-time.status-waiting {
    color: #999;
    font-size: 10px;
}

/* ============================================================
   接続線
   ============================================================ */
.connector-line {
    position: absolute;
    background: #003366;
    z-index: 1;
}

.connector-line.vertical {
    width: 2px;
}

.connector-line.horizontal {
    height: 2px;
}

.connector-line.has-result {
    width: 3px;
}

/* 優勝への線（金色・太め） */
.connector-line.champion-line {
    background: #ffa000;
    width: 3px;
}

/* ============================================================
   グリッド線（開発用）
   ============================================================ */
.grid-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
}

.grid-line-major {
    position: absolute;
    background: rgba(0, 0, 0, 0.3);
}

.grid-line-major.vertical {
    width: 1px;
    height: 100%;
}

.grid-line-major.horizontal {
    width: 100%;
    height: 1px;
}

.grid-line-minor {
    position: absolute;
    background: rgba(0, 0, 0, 0.15);
}

.grid-line-minor.vertical {
    width: 1px;
    height: 100%;
}

.grid-line-minor.horizontal {
    width: 100%;
    height: 1px;
}

.grid-label {
    position: absolute;
    font-size: 10px;
    color: #666;
    font-weight: bold;
    background: rgba(255, 255, 255, 0.9);
    padding: 2px 4px;
    border-radius: 2px;
}

.grid-label.x {
    top: 2px;
}

.grid-label.y {
    left: 2px;
}

/* マウス座標表示 */
.mouse-coords {
    position: fixed;
    top: 200px;
    right: 20px;
    background: #333;
    color: white;
    padding: 15px 20px;
    border-radius: 8px;
    font-family: monospace;
    font-size: 14px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 2000;
}

.mouse-coords div {
    margin: 5px 0;
}

/* 段のガイド */
.stage-guide {
    position: absolute;
    width: 150px;
    background: #fff3cd;
    padding: 8px;
    border-radius: 4px;
    border: 1px solid #ffc107;
    font-size: 11px;
    line-height: 1.6;
    pointer-events: none;
    left: 10px;
    z-index: 100;
}

.stage-guide div {
    margin: 3px 0;
    padding: 4px;
    background: white;
    border-radius: 3px;
}

/* ページ全体の横スクロール防止 */
body {
    overflow-x: hidden;
}

.app-main {
    overflow-x: hidden;
}

/* ローディング */
.loading {
    text-align: center;
    padding: 60px 20px;
    color: #666;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f0f0f0;
    border-top: 4px solid #003366;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* ============================================================
   レスポンシブ対応
   ============================================================ */

@media (max-width: 768px) {
    .zoom-control {
        display: block;
    }

    .tournament-wrapper {
        /* ボーダーとマージンを削除して画面幅いっぱいに */
        border: none;
        border-radius: 0;
        margin: 0;
        overflow-y: hidden;
    }

    .champion-banner {
        padding: 20px 15px;
        margin-left: 0;
        margin-right: 0;
    }

    .champion-trophy {
        font-size: 3em;
    }

    .champion-name {
        font-size: 1.5em;
    }

    .info-panel {
        font-size: 0.85em;
        padding: 12px;
        margin-left: 0;
        margin-right: 0;
    }

    .mouse-coords {
        display: none;
    }

    .stage-guide {
        display: none;
    }

    .team-icon {
        font-size: 20px;
    }

    .team-name {
        font-size: 12px;
    }

    .match-label {
        font-size: 10px;
    }

    .match-team-name {
        font-size: 11px;
    }

    .match-team-score {
        font-size: 14px;
    }

    .match-time {
        font-size: 9px;
    }

    .match-time.status-playing,
    .match-time.status-finished {
        font-size: 10px;
    }

    .match-block:active {
        transform: translate(-50%, -50%) scale(0.96);
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .stage-guide {
        font-size: 10px;
        width: 130px;
    }
}

/* アクセシビリティ */
.team-card:focus,
.match-block:focus {
    outline: 3px solid #1976d2;
    outline-offset: 2px;
}

/* ハイコントラストモード対応 */
@media (prefers-contrast: high) {

    .team-card,
    .match-block {
        border-width: 3px;
    }

    .connector-line {
        width: 3px;
    }
}

/* 印刷対応 */
@media print {
    .tournament-wrapper {
        box-shadow: none;
        border: 1px solid #ddd;
    }

    .champion-banner {
        box-shadow: none;
        border: 2px solid #ffd700;
    }

    .grid-overlay,
    .mouse-coords,
    .stage-guide,
    .zoom-control,
    .info-panel {
        display: none !important;
    }
}

/* パフォーマンス最適化 */
.tournament-area {
    will-change: transform;
}

.team-card,
.match-block {
    will-change: transform;
}

/* ============================================================
   3位決定戦関連スタイル（tournament.cssに追加）
   ============================================================ */

/* 3位カード */
.team-card.third-place-card {
    background: linear-gradient(135deg, #ffecb3 0%, #ffb74d 100%);
    border: 4px solid #cd7f32;
    /* 銅色 */
    box-shadow: 0 8px 16px rgba(205, 127, 50, 0.5);
    animation: third-place-glow 2s ease-in-out infinite;
}

@keyframes third-place-glow {

    0%,
    100% {
        box-shadow: 0 8px 16px rgba(205, 127, 50, 0.5);
    }

    50% {
        box-shadow: 0 12px 24px rgba(205, 127, 50, 0.8);
    }
}

/* 3位への接続線（銅色） */
.connector-line.third-place-line {
    background: #cd7f32;
    width: 3px;
}

/* 3位決定戦エリアの視覚的分離（オプション） */
.third-place-area {
    position: absolute;
    left: 1050px;
    top: 250px;
    width: 400px;
    height: 500px;
    border: 2px dashed #cd7f32;
    border-radius: 12px;
    background: rgba(205, 127, 50, 0.05);
    pointer-events: none;
    z-index: 0;
}

.third-place-area::before {
    content: '3位決定戦';
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    background: #cd7f32;
    color: white;
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: bold;
}

/* 3位バナー（tournament.htmlに追加する場合） */
.third-place-banner {
    background: linear-gradient(135deg, #ffecb3 0%, #ffb74d 100%);
    border-radius: 12px;
    padding: 20px 15px;
    margin-bottom: 15px;
    margin-left: 0;
    margin-right: 0;
    text-align: center;
    box-shadow: 0 6px 20px rgba(205, 127, 50, 0.3);
}

.third-place-medal {
    font-size: 3em;
    margin-bottom: 8px;
}

.third-place-label {
    font-size: 1.1em;
    color: #8d6e63;
    font-weight: bold;
    margin-bottom: 8px;
}

.third-place-name {
    font-size: 1.5em;
    font-weight: bold;
    color: #333;
}

.grid-overlay {
    display: none !important;
}

@media (min-width: 769px) {

    .team-card,
    .match-block {
        transform: translate(-50%, -50%) translateZ(0);
    }
}