/* ============================================
   UI Cells — 盤面・セル・メモ・ヒント数字
   ============================================ */

.grid {
    display: grid;
    grid-template-columns: repeat(9, var(--cell-size));
    grid-template-rows: repeat(9, var(--cell-size));
    gap: var(--gap);
    background: var(--border);
    border: 3px solid var(--green-dark);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    position: relative;
    border-radius: 4px;
}

.cell {
    width: var(--cell-size);
    height: var(--cell-size);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    font-family: var(--font-title);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    cursor: pointer;
    transition: background var(--transition-fast), box-shadow var(--transition-fast);
    position: relative;
}

.cell.empty {
    background: var(--bg-tertiary);
}

.cell.given {
    color: var(--green-neon);
    text-shadow: 0 0 6px var(--green-glow);
}

.cell.fixed {
    color: var(--green-neon) !important;
    text-shadow: 0 0 10px var(--green-glow);
    font-weight: 900;
}

.cell.error {
    color: var(--danger) !important;
    text-shadow: 0 0 10px rgba(255, 82, 82, 0.5) !important;
    animation: cell-error 0.3s ease;
}

.cell.selected {
    box-shadow: inset 0 0 0 4px #ffff00, 0 0 25px rgba(255, 255, 0, 0.6);
    background: rgba(255, 255, 0, 0.3) !important;
    z-index: 50;
    transform: scale(1.05);
}

/* Semi-confirmed numbers (TowerFill) */
.cell.semi-confirmed .val-container {
    color: #448aff; /* pseudo-confirmed */
    font-weight: 500;
}

/* --- 3x3 block borders (Overlaid via pseudo-elements to stay on top of pieces) --- */
.cell.border-right::before {
    content: '';
    position: absolute;
    top: 0;
    right: -1.5px; /* Adjust to align with grid gap */
    width: 2px;
    height: 100%;
    background-color: var(--green-neon);
    z-index: 20; /* Keep above piece background and numbers */
    pointer-events: none;
}

.cell.border-bottom::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: -1.5px; /* Adjust to align with grid gap */
    width: 100%;
    height: 2px;
    background-color: var(--green-neon);
    z-index: 20; /* Keep above piece background and numbers */
    pointer-events: none;
}

/* --- Skyscraper Clues --- */
.clues {
    display: flex;
    gap: var(--gap);
}

.clues-top,
.clues-bottom {
    margin-left: calc(var(--clue-size) + var(--gap));
    margin-right: calc(var(--clue-size) + var(--gap));
}

.clues-left,
.clues-right {
    flex-direction: column;
}

.clue-cell {
    width: var(--clue-size);
    height: var(--clue-size);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-title);
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--cyan);
    text-shadow: 0 0 8px var(--cyan-glow);
}

.clue-cell.match {
    color: #39ff14 !important;
    text-shadow: 0 0 8px rgba(57, 255, 20, 0.8) !important;
}

.clue-cell.over {
    color: var(--danger) !important;
    text-shadow: 0 0 8px rgba(255, 82, 82, 0.8) !important;
}

.clues-top .clue-cell,
.clues-bottom .clue-cell {
    width: var(--cell-size);
    height: var(--clue-size);
}

.clues-left .clue-cell,
.clues-right .clue-cell {
    width: var(--clue-size);
    height: var(--cell-size);
}

/* --- Memos --- */
.memo-grid {
    position: absolute;
    inset: 2px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    pointer-events: none;
    z-index: 10;
}

.memo-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1;
    font-family: var(--font-body);
}

.memo-color-1 {
    color: var(--text-primary);
}

.memo-color-2 {
    color: var(--danger); /* 赤色 */
}

/* --- Laser Highlight --- */
.cell.laser-highlight {
    background: rgba(0, 230, 118, 0.06) !important;
    box-shadow: inset 0 0 8px rgba(0, 230, 118, 0.1);
    outline: 1px dashed rgba(0, 230, 118, 0.25);
    outline-offset: -1px;
}

/* Hint Cell Highlight */
.cell.hint-highlight {
    animation: hint-pulse 1.5s ease-in-out infinite;
    position: relative;
    z-index: 10;
}

@keyframes hint-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(0, 172, 193, 0.7); }
    50%  { box-shadow: 0 0 12px 4px rgba(0, 172, 193, 0.5), inset 0 0 8px rgba(0, 172, 193, 0.2); }
    100% { box-shadow: 0 0 0 0 rgba(0, 172, 193, 0.7); }
}

/* Error Cell Highlight */
.cell.error-highlight {
    animation: error-pulse 1.5s ease-in-out infinite;
    position: relative;
    z-index: 10;
}

@keyframes error-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(255, 82, 82, 0.7); }
    50%  { box-shadow: 0 0 12px 4px rgba(255, 82, 82, 0.5), inset 0 0 8px rgba(255, 82, 82, 0.2); }
    100% { box-shadow: 0 0 0 0 rgba(255, 82, 82, 0.7); }
}

/* --- Number Highlight (Desktop/Common) --- */
.cell.highlight-match {
    background: rgba(255, 235, 59, 0.2) !important;
    box-shadow: inset 0 0 8px rgba(255, 235, 59, 0.3);
    border: 1px solid rgba(255, 235, 59, 0.45);
}

/* ピース上にハイライトが重なる場合（ゴールド発光と太いインセット枠線で干渉防止） */
.cell.placed.highlight-match {
    background: rgba(255, 215, 0, 0.12) !important;
    box-shadow: inset 0 0 0 3px rgba(255, 215, 0, 0.7) !important;
    border: 1px solid rgba(255, 215, 0, 0.8) !important;
}

.cell.placed.highlight-match .val-container {
    color: #ffd700 !important;
    text-shadow: 0 0 4px rgba(255, 215, 0, 0.6), 0 0 8px rgba(255, 215, 0, 0.4), 0 0 3px rgba(0,0,0,0.9) !important;
}

.cell.highlight-match-memo {
    background: rgba(255, 235, 59, 0.1) !important;
    box-shadow: inset 0 0 4px rgba(255, 235, 59, 0.2);
}
