/* ============================================
   Solution Viewer — 「解き方の一例」専用UI
   ============================================ */

.solution-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(5, 10, 20, 0.98);
    backdrop-filter: blur(12px);
    z-index: 4000;
    display: none;
    padding: 20px;
    box-sizing: border-box;
    overflow: hidden;
}

.solution-overlay.active {
    display: flex;
    flex-direction: column;
}

/* Loading Overlay */
.solution-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 15, 28, 0.85);
    backdrop-filter: blur(8px);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    color: var(--blue-neon);
}



.loading-text {
    font-size: 1.2rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 2px;
    text-shadow: 0 0 10px var(--blue-glow);
}



.solution-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    border-bottom: 1px solid rgba(24, 255, 255, 0.2);
    margin-bottom: 20px;
}

.solution-title {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.4rem;
    color: var(--blue-neon, #00e5ff);
    text-shadow: 0 0 10px rgba(0, 229, 255, 0.5);
    letter-spacing: 2px;
}

.solution-close-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.solution-close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: #fff;
}

/* 2-Column Layout */
.solution-content {
    display: flex;
    gap: 30px;
    flex: 1;
    min-height: 0;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* Left Column: Board (with Clues) & Pieces */
.solution-left {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    min-width: 500px;
}

/* Board Wrapper with Skyscraper Clues */
.solution-board-container {
    display: grid;
    grid-template-areas:
        ". top ."
        "left board right"
        ". bottom .";
    grid-template-columns: 40px auto 40px;
    grid-template-rows: 40px auto 40px;
    gap: 5px;
    background: rgba(0, 0, 0, 0.4);
    padding: 15px;
    border-radius: 12px;
    border: 1px solid rgba(24, 255, 255, 0.2);
}

.solution-board-wrapper {
    grid-area: board;
}

.clue-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Orbitron', sans-serif;
    color: var(--blue-neon);
    font-size: 1.2rem;
    font-weight: bold;
    text-shadow: 0 0 8px rgba(0, 229, 255, 0.5);
}

.clues-top { grid-area: top; display: flex; gap: 2px; }
.clues-bottom { grid-area: bottom; display: flex; gap: 2px; }
.clues-left { grid-area: left; display: flex; flex-direction: column; gap: 2px; }
.clues-right { grid-area: right; display: flex; flex-direction: column; gap: 2px; }

/* Piece Inventory Styling */
.solution-piece-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr); /* 3列に変更 */
    gap: 8px; /* 間隔を少し詰める */
    width: 100%;
    max-height: 380px; /* 少し高さを確保 */
    overflow-y: auto;
    padding: 10px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    border: 1px solid rgba(24, 255, 255, 0.1);
}

.solution-piece-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    padding: 6px; /* 余白を詰める */
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px; /* 間隔を詰める */
    transition: all 0.2s;
}

.piece-mini-grid {
    display: grid;
    gap: 1px;
    background: rgba(255,255,255,0.03);
    padding: 2px;
    border-radius: 4px;
}

.mini-cell {
    width: 18px; /* 24px -> 18px に縮小 */
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem; /* フォントサイズも合わせて縮小 */
    font-weight: bold;
    border-radius: 2px;
}

/* Right Column: Steps List */
.solution-right {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.solution-steps-list {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow-y: auto;
    flex: 1;
    padding-right: 15px;
}

/* Step Item - Title with Background Color */
.solution-step-item {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 15px;
    border-radius: 6px;
    overflow: hidden; /* Title background needs this */
    cursor: pointer;
    transition: all 0.2s;
    animation: slideIn 0.3s ease-out;
}

.solution-step-item:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateX(5px);
}

.solution-step-item.active {
    border-color: var(--blue-neon, #00e5ff) !important;
    box-shadow: 0 0 15px rgba(0, 229, 255, 0.4), inset 0 0 10px rgba(0, 229, 255, 0.1);
    background: rgba(0, 229, 255, 0.08) !important;
    transform: translateX(10px); /* 少し右にずらして強調 */
}

.solution-step-title {
    padding: 6px 12px;
    color: #000;
    font-size: 0.85rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.solution-step-message {
    padding: 12px;
    font-size: 1rem;
    line-height: 1.5;
    color: #e0e0e0;
}

/* Specific background colors for types (Inference logic) */
.type-single .solution-step-title { background-color: #ffffff; color: #000; }
.type-hidden .solution-step-title { background-color: #ffab00; color: #000; }
.type-piece .solution-step-title { background-color: #00e676; color: #000; }
.type-visibility .solution-step-title { background-color: #d1c4e9; color: #000; }

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

/* Cell Highlighting & Silhouette */
.cell.silhouette {
    background: rgba(255, 255, 255, 0.05) !important;
    border: 1px dashed rgba(255, 255, 255, 0.2) !important;
}

.cell.solution-highlight {
    background: rgba(255, 82, 82, 0.3) !important;
    box-shadow: inset 0 0 10px #ff5252, 0 0 10px #ff5252;
}
