@charset "UTF-8";

/* --- Base --- */
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; padding: 0; font-family: 'Noto Sans JP', sans-serif; overflow: hidden; }

/* 背景 */
.app-bg {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    z-index: -1;
}

.ui-layer { position: relative; width: 100%; height: 100vh; overflow: hidden; display: flex; flex-direction: column; }
.hidden { display: none !important; }

/* ヘッダー */
.header-bar {
    height: 50px; padding: 0 15px; display: flex; justify-content: space-between; align-items: center;
    background: rgba(255, 255, 255, 0.95); box-shadow: 0 2px 5px rgba(0,0,0,0.1); z-index: 20;
}
.header-title { font-weight: bold; color: #1565c0; font-size: 1.1rem; }
.game-status { display: flex; align-items: baseline; gap: 5px; }
.game-status .label { font-size: 0.7rem; color: #666; font-weight: bold; }
.game-status .value { font-family: 'Orbitron', sans-serif; font-size: 1.2rem; color: #333; font-weight: 700; }
.btn-menu {
    background: #fff; border: 1px solid #ccc; padding: 4px 10px; border-radius: 20px;
    display: flex; align-items: center; gap: 4px; cursor: pointer; color: #555; font-size: 0.8rem;
}

/* --- ゲーム画面レイアウト --- */
.game-container {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
    padding: 10px; overflow-y: auto;
}

/* 数独盤面 */
.sudoku-board {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    width: 100%; max-width: 450px;
    aspect-ratio: 1;
    background: #333;
    border: 2px solid #333;
    gap: 1px;
    margin-bottom: 10px;
}

.cell {
    background: #fff;
    display: flex; justify-content: center; align-items: center;
    font-size: 1.5rem; font-weight: bold; color: #333;
    cursor: pointer; position: relative;
    user-select: none;
}

/* 3x3の太枠 */
.cell:nth-child(3n) { border-right: 2px solid #333; }
.cell:nth-child(9n) { border-right: none; }
.cell.border-bottom { border-bottom: 2px solid #333; }

/* セルの状態 */
.cell.fixed { color: #000; background: #f0f0f0; }
.cell.selected { background: #bbdefb !important; }
.cell.highlight { background: #e3f2fd; }
.cell.error { color: #d32f2f; background: #ffcdd2; }
.cell.hint-assist { background: #fff9c4; }

/* メモ表示 */
.memo-grid {
    display: grid; grid-template-columns: repeat(3, 1fr);
    width: 100%; height: 100%; pointer-events: none;
}
.memo-num {
    font-size: 0.5rem; color: #666; display: flex; justify-content: center; align-items: center;
    line-height: 1;
}

/* --- 操作パネル --- */
.sub-controls {
    display: flex; gap: 10px; margin-bottom: 10px; width: 100%; max-width: 450px; justify-content: space-around;
}
.btn-tool {
    background: #fff; border: 1px solid #ccc; border-radius: 8px; padding: 5px 10px;
    font-size: 0.8rem; display: flex; flex-direction: column; align-items: center; gap: 2px;
    cursor: pointer; color: #555; flex: 1;
}
.btn-tool:active { background: #eee; }

/* 数字キーパッドエリア */
.numpad-container {
    width: 100%; max-width: 450px; background: rgba(255,255,255,0.8);
    padding: 10px; border-radius: 12px; box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}

.mode-toggles { display: flex; justify-content: space-between; margin-bottom: 8px; gap: 10px; }
.btn-toggle {
    flex: 1; padding: 8px; border: 1px solid #ccc; border-radius: 20px; background: #fff;
    font-size: 0.85rem; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 5px;
    transition: all 0.2s;
}
.btn-toggle.active { background: #1976d2; color: white; border-color: #1976d2; }

.numpad {
    display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px;
}
.btn-num {
    aspect-ratio: 1.5; background: #fff; border: 1px solid #bbb; border-radius: 8px;
    font-size: 1.5rem; font-weight: bold; color: #1565c0; cursor: pointer;
    display: flex; justify-content: center; align-items: center;
    box-shadow: 0 2px 0 #999;
}
.btn-num:active { transform: translateY(2px); box-shadow: none; }
.btn-num.delete { color: #d32f2f; }
.btn-num.highlighted { background: #bbdefb; border-color: #1976d2; }

/* --- 共通オーバーレイ (設定・結果) --- */
.overlay-screen {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6); display: flex; justify-content: center; align-items: center; padding: 15px; z-index: 50;
}
.setup-card {
    background: white; width: 100%; max-width: 400px;
    border-radius: 20px; padding: 25px; text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}
.card-header { position: relative; margin-bottom: 20px; display: flex; justify-content: center; align-items: center; }
.btn-icon-back { position: absolute; left: 0; background: none; border: none; cursor: pointer; color: #555; }
.card-title { font-size: 1.4rem; color: #1565c0; margin: 0; font-weight: 800; }
.card-desc { font-size: 0.9rem; color: #555; margin-bottom: 20px; background: #e3f2fd; padding: 10px; border-radius: 8px; text-align: left; }

.settings-grid { margin-bottom: 20px; text-align: left; }
.s-item label { display: block; font-weight: bold; font-size: 0.9rem; margin-bottom: 5px; }
select { width: 100%; padding: 10px; border-radius: 8px; border: 1px solid #ccc; font-size: 1rem; }
.hint-text { font-size: 0.8rem; color: #ff9800; margin-top: 5px; }

.start-btn {
    width: 100%; padding: 14px; background: linear-gradient(135deg, #42a5f5, #1976d2);
    color: white; border: none; border-radius: 50px; font-size: 1.1rem; font-weight: bold;
    cursor: pointer; box-shadow: 0 4px 10px rgba(33,150,243,0.3); margin-bottom: 10px;
}
.btn-sub { width: 100%; padding: 10px; background: #fff; border: 1px solid #ccc; border-radius: 30px; color: #666; cursor: pointer; }

/* 結果 */
.result-stats { background: #f5f5f5; padding: 15px; border-radius: 10px; margin-bottom: 20px; }
.res-main { font-size: 1.5rem; font-weight: bold; color: #1565c0; margin-bottom: 10px; }
.res-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.res-row { background: white; padding: 8px; border-radius: 8px; border: 1px solid #eee; }
.res-label { display: block; font-size: 0.7rem; color: #666; }
.res-val { font-size: 1.2rem; font-weight: bold; }
.res-desc { font-size: 0.85rem; text-align: left; margin-top: 10px; color: #555; }

/* ★修正: 結果画面のボタンレイアウト */
.result-actions {
    display: flex; gap: 10px; width: 100%; margin-bottom: 15px;
}
.btn-res-copy, .btn-res-new {
    flex: 1; padding: 12px; border-radius: 30px; border: none;
    font-weight: bold; font-size: 0.95rem; cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 5px;
}
/* コピーボタン */
.btn-res-copy {
    background: #fff; border: 1px solid #bbb; color: #555;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}
.btn-res-copy:active { background: #eee; }

/* 新しい問題ボタン */
.btn-res-new {
    background: linear-gradient(135deg, #42a5f5, #1976d2); color: white;
    box-shadow: 0 4px 10px rgba(33,150,243,0.3);
}
.btn-res-new:active { transform: scale(0.98); }

/* メニューに戻るテキストボタン */
.btn-text-back {
    background: none; border: none; color: #777; text-decoration: underline;
    font-size: 0.9rem; cursor: pointer; padding: 5px;
}

/* レスポンス対応 */
@media (min-width: 768px) {
    .sudoku-board { max-width: 600px; margin-bottom: 20px; }
    .cell { font-size: 2rem; }
    .numpad-container { max-width: 600px; }
    .btn-num { font-size: 2rem; }
}