/* battle.css - グリッド戦場 */

#battle-screen.hidden {
    display: none;
}

#battle-screen {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #bbdefb;
}

.game-header {
    flex-shrink: 0;
    padding: 8px 16px;
    background: rgba(255,255,255,0.5);
    font-weight: bold;
    color: #004d40;
}

#phase-label {
    font-size: 1.1em;
}

.battle-container {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: row;
    padding: 12px;
    gap: 12px;
    align-items: stretch;
}

.stage-area {
    flex: 1;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.battle-grid {
    flex: 1;
    min-height: 200px;
    display: grid;
    gap: 2px;
    background: #90a4ae;
    padding: 8px;
    border-radius: 12px;
    aspect-ratio: 1;
    max-width: min(70vmin, 480px);
    max-height: min(70vmin, 480px);
    margin: 0 auto;
}

.grid-cell {
    background: #eceff1;
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    min-height: 40px;
}

.grid-cell.occupied {
    background: #fff;
    box-shadow: inset 0 0 0 2px rgba(0,0,0,0.1);
}

.grid-cell.player-occupied {
    border: 2px solid #4db6ac;
}

.grid-cell.enemy-occupied {
    border: 2px solid #e57373;
}

.grid-cell.current-turn {
    box-shadow: 0 0 0 3px #ffc107;
    z-index: 1;
}

.grid-cell.move-target {
    background: rgba(77, 182, 172, 0.4);
    cursor: pointer;
}

.grid-cell.move-target:hover {
    background: rgba(77, 182, 172, 0.7);
}

.grid-cell.skill-target {
    background: rgba(255, 152, 0, 0.4);
    cursor: pointer;
}

.grid-cell.skill-target:hover {
    background: rgba(255, 152, 0, 0.7);
}

.grid-cell.placement-target {
    background: rgba(77, 182, 172, 0.35);
    cursor: pointer;
    border: 2px dashed #00897b;
}

.grid-cell.placement-target:hover {
    background: rgba(77, 182, 172, 0.6);
}

.grid-char-icon {
    width: 32px;
    height: 32px;
    object-fit: cover;
    border-radius: 50%;
}

.grid-char-name {
    font-size: 0.6em;
    color: #333;
}

.grid-char-hp-wrap {
    width: 100%;
    height: 4px;
    background: rgba(0,0,0,0.2);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 2px;
}

.grid-char-hp-bar {
    height: 100%;
    border-radius: 2px;
    transition: width 0.2s ease;
}

.grid-cell.player-occupied .grid-char-hp-bar {
    background: #4db6ac;
}

.grid-cell.enemy-occupied .grid-char-hp-bar {
    background: #e57373;
}


.command-box {
    flex-shrink: 0;
    width: 200px;
    padding: 12px;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
}

.command-box.hidden {
    display: none !important;
}

.command-button {
    padding: 10px;
    background: #4db6ac;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95em;
}

.command-button:hover {
    background: #00897b;
}

.command-button.action-instance {
    background: #7e57c2;
}

.command-button.action-instance:hover {
    background: #5e35b1;
}

.command-button.action-skip-step {
    background: #78909c;
}

.command-button.action-skip-step:hover {
    background: #546e7a;
}

.command-step-label {
    font-size: 0.85em;
    color: #5d4037;
    margin: 6px 0 2px 0;
    font-weight: bold;
}

.view-only-hint {
    color: #546e7a;
    font-size: 0.95em;
    padding: 12px;
    text-align: center;
    margin: 0;
}

/* 右側キャラ詳細パネル */
.battle-detail-panel {
    flex-shrink: 0;
    width: 220px;
    padding: 12px;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    overflow-y: auto;
    font-size: 0.9em;
}

.battle-detail-panel .placeholder {
    color: #999;
    font-style: italic;
}

.battle-detail-panel .char-image {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: 50%;
    margin-bottom: 8px;
}

.battle-detail-panel .status-list {
    margin: 8px 0;
}

.battle-detail-panel .status-list p {
    margin: 4px 0;
}

.battle-detail-panel .detail-status p {
    margin: 2px 0;
}

.battle-detail-panel .detail-skill-list {
    list-style: none;
    padding-left: 0;
    margin: 4px 0 0 0;
}

.battle-detail-panel .detail-skill-item {
    margin-bottom: 10px;
}

.battle-detail-panel .detail-skill-timing {
    font-weight: bold;
    color: #5d4037;
}

.battle-detail-panel .detail-skill-desc {
    font-size: 0.85em;
    color: #333;
}

/* スキル射程・範囲プレビュー（薄く表示） */
.grid-cell.range-preview {
    background: rgba(77, 182, 172, 0.25) !important;
    pointer-events: none;
}

.grid-cell.range-preview.skill-range {
    background: rgba(255, 152, 0, 0.25) !important;
}

/* ログ内スキルツールチップ */
.log-skill-name {
    cursor: help;
    text-decoration: underline;
    text-decoration-style: dotted;
}

/* ダイスロールオーバーレイ */
.dice-roll-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.dice-roll-overlay.hidden {
    display: none;
}

.dice-roll-box {
    background: #fff;
    padding: 20px 28px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

.dice-roll-label {
    font-weight: bold;
    color: #004d40;
    margin-bottom: 12px;
}

.dice-roll-dice {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-bottom: 8px;
    min-height: 48px;
}

.dice-roll-dice .dice-face {
    width: 44px;
    height: 44px;
    background: #e0f7fa;
    border: 2px solid #4db6ac;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: bold;
    color: #00695c;
}

.dice-roll-result {
    font-size: 1.1rem;
    color: #333;
}

.log-skill-tooltip {
    position: fixed;
    z-index: 9999;
    max-width: 300px;
    padding: 12px 14px;
    background: linear-gradient(145deg, #37474f 0%, #263238 100%);
    color: #eceff1;
    border-radius: 10px;
    font-size: 0.9em;
    line-height: 1.5;
    box-shadow: 0 6px 20px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.1);
}

.log-skill-tooltip strong {
    color: #4db6ac;
    font-size: 1.05em;
}

.log-skill-tooltip > div {
    margin: 6px 0;
    padding: 2px 0;
}

.log-skill-tooltip .log-skill-flavor {
    color: #b0bec5;
    font-size: 0.9em;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

/* 配置パネル（D&D） */
.placement-wrapper {
    display: flex;
    flex: 1;
    min-width: 0;
    min-height: 0;
    gap: 16px;
    align-items: flex-start;
    justify-content: center;
}

.placement-panel {
    flex-shrink: 0;
    padding: 12px;
    background: rgba(255,255,255,0.95);
    border-radius: 10px;
    border: 2px solid #4db6ac;
}

.placement-panel.hidden {
    display: none !important;
}

.placement-confirm-button {
    display: block;
    width: 100%;
    margin-top: 12px;
    padding: 12px 20px;
    background: #4db6ac;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
}

.placement-confirm-button:hover {
    background: #00897b;
}

.placement-panel h4 {
    margin: 0 0 10px 0;
    font-size: 0.95em;
    color: #004d40;
}

.placement-chars {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.placement-char-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 12px;
    background: #e0f7fa;
    border: 2px solid #4db6ac;
    border-radius: 8px;
    cursor: grab;
    min-width: 80px;
}

.placement-char-card.placed {
    background: #e8eaf6;
    border-color: #9e9e9e;
    cursor: default;
    opacity: 0.85;
}

.placement-char-icon {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 50%;
}

.placement-char-name {
    font-size: 0.8em;
    margin-top: 4px;
}

.placement-pos {
    font-size: 0.75em;
    color: #666;
}

.grid-cell.drop-target {
    background: rgba(126, 87, 194, 0.5) !important;
    border: 2px dashed #5e35b1;
}

.log-box {
    flex-shrink: 0;
    height: 120px;
    background: #e3f2fd;
    border-radius: 10px;
    padding: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    overflow-y: auto;
}

.log-box p {
    margin: 0 0 4px 0;
    font-size: 0.9em;
}

.log-message.damage { color: #d32f2f; }
.log-message.heal { color: #43a047; }
.log-message.status-effect { color: #1976d2; }
.log-message.character-turn { font-weight: bold; color: #004d40; }
.log-message.turn-start { color: #004d40; font-weight: bold; }
.log-message.system { color: #5d4037; font-style: italic; }
.log-message.win { color: #2e7d32; font-weight: bold; }
.log-message.lose { color: #c62828; font-weight: bold; }

/* ルーレットオーバーレイ */
#roulette-overlay .roulette-box {
    background: #fff;
    padding: 24px;
    border-radius: 16px;
    text-align: center;
}

#roulette-overlay .roulette-chars {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin: 16px 0;
    flex-wrap: wrap;
}

#roulette-overlay .roulette-char {
    padding: 8px 16px;
    background: #e0f7fa;
    border-radius: 8px;
}

#roulette-overlay .roulette-spin {
    margin-top: 12px;
    padding: 12px 24px;
    background: #81c784;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}

#roulette-overlay .roulette-spin:hover {
    background: #66bb6a;
}

#roulette-overlay .roulette-result-desc {
    margin: 12px 0;
    color: #555;
    font-size: 0.95em;
}

#roulette-overlay .roulette-result-order {
    text-align: left;
    margin: 16px 0;
    padding: 12px 16px;
    background: #f5f5f5;
    border-radius: 8px;
    max-width: 280px;
    margin-left: auto;
    margin-right: auto;
}

#roulette-overlay .roulette-result-row {
    padding: 6px 0;
    font-size: 1em;
}

#roulette-overlay .roulette-first-label {
    color: #2e7d32;
    font-weight: bold;
}

#roulette-overlay .roulette-confirm {
    margin-top: 16px;
    padding: 12px 32px;
    background: #1976d2;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1em;
}

#roulette-overlay .roulette-confirm:hover {
    background: #1565c0;
}

/* 戦闘結果 */
.battle-result-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.5s;
}

.battle-result-overlay.show {
    opacity: 1;
}

.battle-result-container {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 40px;
    border-radius: 20px;
    text-align: center;
}

.battle-result-title {
    font-size: 3em;
    color: #fff;
    margin: 0 0 20px 0;
}

.battle-result-button {
    padding: 15px 40px;
    background: #ff9800;
    color: white;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    font-size: 1.2em;
}

.battle-result-button:hover {
    background: #f57c00;
}
