@charset "UTF-8";

/* ===== 待機画面 (#wait-modal) の詳細スタイル ===== */
#wait-modal .modal-content { display: flex; flex-direction: column; }
#wait-modal h2 { font-weight: bold; color: var(--primary-color); }

#player-list-area { margin-top: 1.5rem; text-align: left; }
#player-list { background-color: #f8f9fa; border: 1px solid var(--border-color); border-radius: 0.5rem; padding: 1rem; min-height: 100px; max-height: 150px; overflow-y: auto; }
#player-list li { padding: 0.5rem; border-bottom: 1px solid var(--border-color); transition: all 0.2s; }
#player-list li:last-child { border-bottom: none; }
#player-list li.active { color: var(--dark-color); }
#player-list li.current-player {
    background-color: #e3f2fd;
    border-left: 4px solid var(--primary-color);
    font-weight: 600;
    margin: 0 -0.5rem;
    padding-left: 1rem;
}
.player-points { color: var(--secondary-color); font-size: 0.9em; margin-left: 0.5rem; }
.ready-text { color: var(--success-color); font-weight: 600; font-size: 0.8rem; margin-left: 0.5rem; }

/* Ranking Area Styles */
#ranking-area { margin-top: 1.5rem; text-align: left; }
.ranking-tabs { display: flex; border-bottom: 2px solid var(--border-color); margin-bottom: 0.5rem; }
.ranking-tab-button { background: none; border: none; padding: 0.5rem 1rem; cursor: pointer; font-size: 1rem; color: var(--secondary-color); border-bottom: 2px solid transparent; margin-bottom: -2px; }
.ranking-tab-button.active { color: var(--primary-color); border-color: var(--primary-color); font-weight: 600; }
.ranking-content { display: none; padding: 0.5rem; max-height: 150px; overflow-y: auto; }
.ranking-content.active { display: block; }
.ranking-content ol { list-style-position: inside; padding-left: 0; }
.ranking-content li { padding: 0.25rem 0; border-bottom: 1px solid #f1f1f1; }
.ranking-content li:last-child { border-bottom: none; }
.ranking-content .role-ranking { margin-top: 1rem; }
.ranking-content .role-ranking h4 { font-size: 1rem; margin-bottom: 0.5rem; }

.waiting-message { margin-top: 1rem; font-weight: 500; color: var(--secondary-color); }
.attention-text { color: var(--secondary-color); font-size: 0.85rem; margin-top: 0.5rem;}


/* ===== お絵かき画面 (#drawing-phase-ui) のレイアウト ===== */
#drawing-phase-ui {
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 0.5rem;
    overflow: hidden; /* スクロールを防ぐ */
}

#game-header { display: flex; justify-content: space-between; align-items: center; padding: 0.5rem; background-color: var(--white-color); border-radius: 0.5rem; box-shadow: 0 2px 4px rgba(0,0,0,0.05); flex-shrink: 0; }
#topic-area { font-weight: bold; font-size: 1.1rem; }
#info-area { font-size: 0.9rem; color: var(--secondary-color); }
#timer-display { font-weight: bold; color: var(--danger-color); }

#my-canvas-container {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0.5rem 0;
    min-height: 0;
    width: 100%;
    height: 100%;
}
#my-canvas {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain; /* アスペクト比を維持 */
    max-width: 512px; /* 最大サイズは維持 */
    max-height: 512px;
    background-color: var(--white-color);
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    touch-action: none;
    transition: opacity 0.3s;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}
#my-canvas.locked { opacity: 0.7; cursor: not-allowed; }


/* ===== 操作パネル & ボタン ===== */
.drawing-actions { display: flex; gap: 1rem; padding: 0.5rem; flex-shrink: 0; }
.drawing-actions button { flex-grow: 1; }
.secondary-button { background-color: var(--secondary-color); border-color: var(--secondary-color); }

#drawing-controls {
    display: flex;
    justify-content: space-around;
    align-items: center; /* 縦方向中央揃え */
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    padding: 0.75rem 0.5rem;
    background-color: var(--white-color);
    border-radius: 0.5rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    flex-shrink: 0;
}
.control-group { display: flex; align-items: center; gap: 0.75rem; }
.tool-wrapper { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.tool-label { font-size: 0.7rem; color: var(--secondary-color); font-weight: 500; }

#drawing-controls .control-button { width: 44px; height: 44px; padding: 0; display: flex; justify-content: center; align-items: center; font-size: 1.2rem; background-color: var(--light-color); color: var(--dark-color); border: 1px solid var(--border-color); transition: all 0.2s; }
#drawing-controls .control-button.active { background-color: var(--primary-color); color: var(--white-color); border-color: var(--primary-color); box-shadow: 0 0 8px rgba(13, 110, 253, 0.5); }
#drawing-controls .control-button img { width: 28px; height: 28px; }

.size-selector-group { display: flex; gap: 0.5rem; }
.size-selector-group .control-button { width: 38px; height: 38px; font-size: 1rem; }
#pencil-button::before { content: '✏️'; font-size: 1.4rem; }
#bucket-button img { width: 24px; height: 24px; }
#clear-canvas-button::before { content: '🗑️'; font-size: 1.4rem; }


/* ===== 他のプレイヤーのキャンバス ===== */
#other-players-canvas-area { padding: 0.5rem; flex-shrink: 0; min-height: 140px; }
.area-title { font-size: 0.9rem; font-weight: 500; margin-bottom: 0.5rem; color: var(--secondary-color); }
#other-players-grid { display: flex; gap: 0.75rem; overflow-x: auto; padding-bottom: 0.75rem; }
.other-player-canvas-wrapper { flex-shrink: 0; text-align: center;}
.other-player-canvas-wrapper .player-info { font-size: 0.8rem; margin-bottom: 0.25rem; }
.other-canvas {
    width: 100px;
    height: 100px;
    background-color: #e9ecef;
    border: 1px solid var(--border-color);
    border-radius: 0.25rem;
    /* 画像コピー防止 */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-user-drag: none;
    -khtml-user-drag: none;
    -moz-user-drag: none;
    -o-user-drag: none;
    user-drag: none;
    pointer-events: none; /* クリック・タッチ操作を無効化 */
}

/* モザイク処理はJavaScript側で実装済み + ぼかし */
.other-canvas.mosaic {
    filter: blur(5px);
    image-rendering: pixelated; /* ピクセル感を強調 */
}
.other-canvas.mosaic.reveal-1 { opacity: 0.9; }
.other-canvas.mosaic.reveal-2 { opacity: 0.95; }


/* ===== ギャラリー画面 (#gallery-phase-ui) ===== */
#gallery-phase-ui { padding: 0.5rem; display: flex; flex-direction: column; height: 100vh; }
#gallery-header { text-align: center; padding: 0.5rem; flex-shrink: 0; }
#gallery-title { font-size: 1.5rem; margin-bottom: 0.25rem; }
#gallery-info-area { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 1rem; margin-top: 0.5rem; background-color: var(--white-color); padding: 0.5rem; border-radius: 0.5rem; }

#vote-status-container, #final-result-display { flex-grow: 1; }
#voted-players-area { margin-bottom: 0.5rem; }
#voted-players-list { font-weight: 500; color: var(--primary-color); }

#final-result-display .result-info-box {
    background-color: #f8f9fa;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 0.75rem;
    margin-bottom: 0.75rem;
}
#final-result-display h4 {
    margin-top: 0;
    margin-bottom: 0.5rem;
    color: var(--dark-color);
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 0.25rem;
}
#final-result-wolf-name {
    font-weight: bold;
    color: var(--danger-color);
}

#timer-wrapper { flex-shrink: 0; font-size: 0.9rem; font-weight: 500; padding-top: 0.25rem;}
#gallery-timer-display { font-weight: bold; color: var(--danger-color); }

#gallery-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 1rem; padding: 1rem; overflow-y: auto; flex-grow: 1; }
.gallery-item { position: relative; border: 3px solid transparent; border-radius: 0.5rem; box-shadow: 0 4px 8px rgba(0,0,0,0.1); transition: all 0.2s ease-in-out; cursor: pointer; aspect-ratio: 1 / 1; }
.gallery-item .image-wrapper { width: 100%; height: 100%; display: flex; justify-content: center; align-items: center; background-color: #f0f0f0; border-radius: 0.25rem; }
.gallery-item .image-wrapper .loader { width: 30px; height: 30px; margin: 0; }
.gallery-item img { width: 100%; height: 100%; object-fit: cover; border-radius: 0.25rem; display: block; }
.gallery-item .player-info { position: absolute; top: 0; left: 0; background-color: rgba(0, 0, 0, 0.5); color: var(--white-color); padding: 0.25rem 0.5rem; border-radius: 0.5rem 0 0.5rem 0; font-size: 0.8rem; z-index: 1; }

.gallery-item.votable:hover { transform: translateY(-5px); }
.gallery-item.selected { border-color: var(--primary-color); box-shadow: 0 0 15px var(--primary-color); }
.gallery-item.wolf { border-color: var(--danger-color); box-shadow: 0 0 15px var(--danger-color); }

.vote-action-area { display: flex; flex-direction: column; align-items: center; gap: 0.75rem; padding: 0.75rem; background-color: var(--white-color); text-align: center; border-radius: 0.5rem; box-shadow: 0 0 8px rgba(0,0,0,0.1); flex-shrink: 0; }
.vote-form { display: flex; flex-direction: column; width: 100%; gap: 0.75rem; }
.vote-selection-area, .guess-input-area { width: 100%; }
.vote-action-area .submit-vote-button { width: 80%; max-width: 300px; margin-top: 0.5rem; }


/* ===== 最終結果のスタイル ===== */
#final-result-display {
    padding: 1rem;
    background: linear-gradient(135deg, #f0f8ff 0%, #e6f3ff 100%);
    border-radius: 0.75rem;
    border: 2px solid var(--primary-color);
    overflow-y: auto;
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
    animation: resultSlideIn 0.8s ease-out;
}

@keyframes resultSlideIn {
    from {
        opacity: 0;
        transform: translateY(50px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.execution-message {
    text-align: center;
    font-weight: bold;
    margin-bottom: 1rem;
    font-size: 1.3rem;
    padding: 1rem;
    background: rgba(255,255,255,0.8);
    border-radius: 0.5rem;
    border-left: 4px solid var(--primary-color);
    animation: fadeInUp 0.6s ease-out 0.2s both;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#final-result-details {
    margin-bottom: 0.75rem;
    text-align: left;
    animation: fadeInUp 0.6s ease-out 0.4s both;
}

.outcome-message {
    font-size: 1.4rem;
    font-weight: bold;
    text-align: center;
    padding: 1rem;
    border-radius: 0.75rem;
    margin: 1rem 0;
    animation: bounceIn 0.8s ease-out 0.6s both;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.outcome-win {
    color: #0f5132;
    background: linear-gradient(135deg, #d1e7dd 0%, #a3d4a8 100%);
    border: 2px solid #198754;
}
.outcome-lose {
    color: #721c24;
    background: linear-gradient(135deg, #f8d7da 0%, #f1a7a7 100%);
    border: 2px solid #dc3545;
}

/* --- 結果詳細テーブル --- */
.result-details-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    font-size: 0.85rem;
    background: white;
    border-radius: 0.5rem;
    overflow: hidden;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    animation: fadeInUp 0.6s ease-out 0.8s both;
}
.result-details-table th, .result-details-table td {
    border: 1px solid #e1e5e9;
    padding: 0.6rem 0.4rem;
    text-align: center;
}
.result-details-table th {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    font-weight: 600;
    color: var(--dark-color);
}
.result-details-table .player-name { font-weight: bold; }
.result-details-table .points-plus {
    color: var(--success-color);
    font-weight: bold;
    font-size: 1.1em;
}

/* ===== 結果発表画面の詳細セクション ===== */
.topic-reveal-section {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background-color: #f8f9fa;
    border-radius: 0.5rem;
    border: 1px solid #e9ecef;
}

.topic-info {
    margin-bottom: 1rem;
    padding: 0.75rem;
    background-color: #e3f2fd;
    border-radius: 0.25rem;
    border-left: 4px solid #2196f3;
}

.topic-info h4 {
    margin: 0 0 0.5rem 0;
    color: #1976d2;
    font-size: 1.1rem;
}

.topic-info p {
    margin: 0.25rem 0;
    font-size: 0.95rem;
}

.guess-section {
    padding: 0.75rem;
    background-color: #fff3e0;
    border-radius: 0.25rem;
    border-left: 4px solid #ff9800;
}

.guess-section h4 {
    margin: 0 0 0.5rem 0;
    color: #f57c00;
    font-size: 1.1rem;
}

.guess-section p {
    margin: 0.25rem 0;
    font-size: 0.9rem;
}

.result-details-table .wolf-row {
    background-color: #ffebee;
}

.result-details-table .citizen-row {
    background-color: #e8f5e8;
}

/* ===== タブレット向けレスポンシブ対応（iPad等） ===== */
@media (min-width: 769px) and (max-width: 1024px) {
    #drawing-phase-ui {
        padding: 0.75rem;
    }

    #my-canvas {
        width: 60vmin; /* タブレットでは少し小さめに */
        height: 60vmin;
    }

    #my-canvas-container {
        padding: 1rem 0;
    }

    #drawing-controls {
        padding: 1rem 0.75rem;
        gap: 0.5rem 1rem;
    }

    #drawing-controls .control-button {
        width: 48px;
        height: 48px;
        font-size: 1.3rem;
    }

    .size-selector-group .control-button {
        width: 42px;
        height: 42px;
    }

    #other-players-canvas-area {
        padding: 0.75rem;
        min-height: 160px;
    }

    .other-canvas {
        width: 120px;
        height: 120px;
    }
}

/* ===== モバイル・タブレット向けレスポンシブ対応 ===== */
@media (max-width: 768px) {
    #drawing-phase-ui {
        padding: 0.25rem;
    }

    #game-header {
        padding: 0.25rem 0.5rem;
        font-size: 0.9rem;
    }

    #topic-area {
        font-size: 1rem;
    }

    #info-area {
        font-size: 0.8rem;
    }

    #my-canvas-container {
        padding: 0.25rem 0;
    }

    #drawing-controls {
        padding: 0.5rem 0.25rem;
        gap: 0.25rem 0.5rem;
    }

    .control-group {
        gap: 0.5rem;
    }

    #drawing-controls .control-button {
        width: 40px;
        height: 40px;
        font-size: 1.1rem;
    }

    .size-selector-group .control-button {
        width: 36px;
        height: 36px;
        font-size: 0.9rem;
    }

    .tool-label {
        font-size: 0.65rem;
    }

    #other-players-canvas-area {
        padding: 0.25rem;
        min-height: 120px;
    }

    #other-players-grid {
        gap: 0.5rem;
    }

    .other-canvas {
        width: 80px;
        height: 80px;
    }

    .drawing-actions {
        padding: 0.25rem;
        gap: 0.5rem;
    }
}

@media (max-width: 480px) {
    #drawing-phase-ui {
        padding: 0.125rem;
    }

    #game-header {
        flex-direction: column;
        gap: 0.25rem;
        text-align: center;
    }

    #drawing-controls {
        justify-content: center;
        flex-wrap: wrap;
    }

    #drawing-controls .control-button {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }

    .size-selector-group .control-button {
        width: 32px;
        height: 32px;
        font-size: 0.8rem;
    }

    .tool-label {
        font-size: 0.6rem;
    }

    .other-canvas {
        width: 70px;
        height: 70px;
    }
}

/* ===== ポイント更新通知 ===== */
.point-update-notification {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2000;
    background: linear-gradient(135deg, #fff 0%, #f8f9fa 100%);
    border: 3px solid var(--primary-color);
    border-radius: 1rem;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    animation: pointNotificationSlideIn 0.6s ease-out;
    transition: opacity 0.5s ease-out;
}

@keyframes pointNotificationSlideIn {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5) rotate(5deg);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1) rotate(0deg);
    }
}

.point-update-content {
    padding: 1.5rem 2rem;
    text-align: center;
    font-family: inherit;
}

.point-update-content h3 {
    margin: 0 0 1rem 0;
    font-size: 1.4rem;
    color: var(--primary-color);
    font-weight: bold;
}

.round-points {
    font-size: 1.2rem;
    font-weight: bold;
    margin: 0.5rem 0;
    padding: 0.5rem;
    border-radius: 0.5rem;
}

.round-points.positive {
    color: #0f5132;
    background-color: #d1e7dd;
    border: 1px solid #198754;
}

.round-points.neutral {
    color: #495057;
    background-color: #e9ecef;
    border: 1px solid #6c757d;
}

.total-points {
    font-size: 1rem;
    color: var(--dark-color);
    margin: 0.5rem 0 0 0;
    font-weight: 600;
}

@media (max-width: 480px) {
    .point-update-notification {
        width: 90%;
        max-width: 320px;
    }

    .point-update-content {
        padding: 1rem 1.5rem;
    }

    .point-update-content h3 {
        font-size: 1.2rem;
    }

    .round-points {
        font-size: 1.1rem;
    }
}

/* Reconnect Modal Styles */
#reconnect-modal {
    z-index: 3000; /* Make sure it's on top of everything */
}

#reconnect-modal .modal-content {
    background-color: #ffc107; /* A warning color */
    color: #333;
    text-align: center;
}

.loader {
    border: 4px solid #f3f3f3;
    border-radius: 50%;
    border-top: 4px solid #3498db;
    width: 40px;
    height: 40px;
    -webkit-animation: spin 2s linear infinite; /* Safari */
    animation: spin 2s linear infinite;
    margin: 20px auto;
}

/* Safari */
@-webkit-keyframes spin {
    0% { -webkit-transform: rotate(0deg); }
    100% { -webkit-transform: rotate(360deg); }
}

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

#reconnect-modal.hidden {
    display: none;
}

/* Inactive Player Styles */
#player-list li.inactive-player {
    color: #888;
    font-style: italic;
    background-color: #f8f9fa; /* Ensure it overrides current-player highlight */
}

#player-list li.inactive-player.current-player {
    border-left-color: #aaa;
}

#player-list li.inactive-player .player-points {
    color: #aaa;
}

.status-text {
    color: var(--danger-color);
    font-weight: 600;
    font-size: 0.8rem;
    margin-left: 0.5rem;
}