/* ===== 棋譜暗記改 スタイル ===== */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
    margin: 0; padding: 0;
    font-family: 'Hiragino Kaku Gothic ProN','Yu Gothic',sans-serif;
    background: linear-gradient(135deg,#1f2933,#3b4252);
    color: #f0f4f8;
    overflow: hidden;
    height: 100%;
    /* ダブルタップ拡大防止 */
    touch-action: manipulation;
}
.hidden { display: none !important; }

/* ---- メインナビゲーション ---- */
.main-nav {
    display: flex;
    background: #1a2332;
    border-bottom: 2px solid #334155;
    overflow-x: auto;
    overflow-y: hidden;
    flex-shrink: 0;
}
.main-nav .nav-item {
    padding: 8px 16px;
    color: #94a3b8;
    text-decoration: none;
    font-size: 0.83rem;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.15s;
}
.main-nav .nav-item:hover { color: #e2e8f0; }
.main-nav .nav-item.active { color: #fbbf24; border-bottom-color: #fbbf24; }

/* ---- ボタン ---- */
.btn {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: #fff;
    padding: 7px 12px;
    font-size: 0.82rem;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
    min-height: 34px;
    touch-action: manipulation;
}
.btn:hover, .btn:active { background: rgba(255,255,255,0.22); }
.btn.primary { background: linear-gradient(135deg,#d97706,#b45309); border-color:#92400e; }
.btn.primary:hover { background: linear-gradient(135deg,#f59e0b,#d97706); }
.btn.danger { background: #b91c1c; border-color:#991b1b; }
.btn.danger:hover { background: #dc2626; }
.btn:disabled { opacity:0.4; cursor:not-allowed; }
.btn-sm { padding:3px 8px; font-size:0.72rem; min-height:24px; }
.btn.active { background: #16a34a; border-color: #15803d; }
.nav-btns { display: flex; gap: 5px; }
#back-btn, #forward-btn { min-height: 51px; }

/* ---- レイアウト ---- */
.app { display:flex; flex-direction:column; height:100vh; }
.topbar { display:flex; align-items:center; gap:16px; padding:6px 14px; background:rgba(0,0,0,0.3); }
.topbar h1 { margin:0; font-size:1.05rem; font-weight:600; color:#fbbf24; }
.status { font-size:0.8rem; color:#cbd5e1; flex:1; }
.topbar-right { display:flex; align-items:center; gap:6px; margin-left:auto; }

.main { flex:1; display:flex; gap:10px; padding:8px; overflow:hidden; }
.left { display:flex; flex-direction:column; align-items:center; gap:4px; --bs: min(450px, calc(100vh - 160px)); }
.right { flex:1; display:flex; flex-direction:column; gap:6px; min-width:260px; min-height:0; overflow:hidden; }

/* ---- 盤面 ---- */
.board-wrap { position:relative; }
.hint-arrow {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 5;
    overflow: visible;
}
.board {
    width: var(--bs); height: var(--bs);
    display:grid;
    grid-template-columns: repeat(9, 1fr);
    grid-template-rows: repeat(9, 1fr);
    background: #d2a374;
    border:2px solid #5b3a1a;
    box-shadow: 0 4px 16px rgba(0,0,0,0.5);
    overflow: hidden;
}
.cell {
    position: relative;
    border: 1px solid rgba(80,40,10,0.5);
    display:flex; align-items:center; justify-content:center;
    cursor: pointer;
    user-select: none;
    touch-action: manipulation;
}
.cell.selected { background: rgba(255,215,0,0.4); }
.cell.valid-move::after {
    content:''; position:absolute;
    width:14px; height:14px; border-radius:50%;
    background: rgba(34,197,94,0.6);
}
.cell.last-move { background: rgba(37,99,235,0.55); }
.cell.hint-from {
    background: rgba(251,146,60,0.80) !important;
    box-shadow: inset 0 0 0 2px rgba(251,146,60,1);
    animation: hint-pulse 0.65s ease-in-out infinite alternate;
}
.cell.hint-to {
    background: rgba(251,191,36,0.80) !important;
    box-shadow: inset 0 0 0 2px rgba(251,191,36,1);
    animation: hint-pulse 0.65s ease-in-out infinite alternate;
}
@keyframes hint-pulse {
    from { opacity: 0.65; }
    to   { opacity: 1; }
}
.piece {
    font-size: calc(var(--bs) / 9 * 0.52); font-weight:700;
    color: #1a1a1a;
    background: #f5deb3;
    width: calc(var(--bs) / 9 * 0.84); height: calc(var(--bs) / 9 * 0.84);
    display:flex; align-items:center; justify-content:center;
    border-radius:3px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.3);
    line-height: 1;
}
.piece.gote { transform: rotate(180deg); }

/* ---- 盤面反転 ---- */
.left.board-flipped .board .piece { transform: rotate(180deg); }
.left.board-flipped .board .piece.gote { transform: none; }
.left.board-flipped .hand-sente { order: -1; }
.left.board-flipped .hand-gote { order: 3; }
.left.board-flipped .hand-piece { transform: rotate(180deg); }
.left.board-flipped .hand-piece .count { transform: rotate(180deg); }
.left.board-flipped .hand-piece.gote { transform: none; }
.left.board-flipped .hand-piece.gote .count { transform: none; }
.piece.promoted { color: #b91c1c; }

/* ---- 正解マーク ---- */
.correct-mark {
    position: absolute;
    top: -8px; right: -36px;
    font-size: 32px;
    color: #16a34a;
    font-weight: bold;
    text-shadow: 0 1px 4px rgba(0,0,0,0.4);
    z-index: 10;
    animation: correctPop 0.4s ease-out;
    pointer-events: none;
}
@keyframes correctPop {
    0% { transform: scale(0.3); opacity:0; }
    50% { transform: scale(1.3); opacity:1; }
    100% { transform: scale(1); opacity:1; }
}

/* ---- 持ち駒 ---- */
.hand {
    width: var(--bs, 450px);
    height: 44px;
    display:flex; flex-wrap:wrap; gap:4px;
    padding: 4px 6px;
    background: rgba(0,0,0,0.25);
    border-radius:4px;
}
.hand-piece {
    position: relative;
    background: #f5deb3; color:#1a1a1a;
    width: 36px; height:36px;
    display:flex; align-items:center; justify-content:center;
    border-radius:3px;
    font-size: 22px; font-weight:700;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0,0,0,0.4);
    touch-action: manipulation;
}
.hand-piece.gote { transform: rotate(180deg); }
.hand-piece .count {
    position:absolute; right:-2px; bottom:-2px;
    background:#dc2626; color:#fff;
    font-size:11px; padding:1px 4px;
    border-radius:8px; line-height:1;
    transform: rotate(0);
}
.hand-piece.gote .count { transform: rotate(180deg); }
.hand-piece.selected { box-shadow: 0 0 0 3px rgba(255,215,0,0.8); }

/* ---- 情報 / コントロール ---- */
.controls { display:flex; flex-wrap:wrap; gap:5px; }
.controls-nav { display:flex; flex-wrap:wrap; gap:5px; align-items:center; }
.info {
    display:none;
}
.mode-badge {
    background: #4f46e5; color:#fff;
    padding:2px 8px; border-radius:10px;
    font-size:0.72rem; font-weight:600;
}
.mode-badge.edit { background: #dc2626; }
.mode-badge.memorize { background: #d97706; }
#memorize-info { color:#fbbf24; font-weight:600; font-size:0.8rem; padding:2px 0; }

/* ---- コメント欄 ---- */
.comment-area {
    padding: 4px 2px;
    border-bottom: 1px solid #333;
    margin-bottom: 4px;
}
.comment-label {
    font-size: 0.7rem;
    color: #94a3b8;
    margin-bottom: 3px;
}
.comment-input {
    width: 100%;
    box-sizing: border-box;
    background: #1a1a2e;
    color: #e0e0e0;
    border: 1px solid #444;
    border-radius: 4px;
    padding: 4px 6px;
    font-size: 0.82rem;
    resize: vertical;
    min-height: 38px;
    font-family: inherit;
    line-height: 1.4;
}
.comment-input:focus {
    outline: none;
    border-color: #7aa2d4;
    background: #1e2240;
}

/* ---- 棋譜ツリー ---- */
.tree-zoom-bar { display:flex; align-items:center; gap:4px; margin-bottom:4px; }
.tree-zoom-label { font-size:0.7rem; color:#94a3b8; min-width:34px; text-align:center; }
.tree-panel {
    flex: 1 1 0;
    min-height: 200px;
    background: rgba(0,0,0,0.3);
    border-radius: 6px;
    padding: 6px;
    display:flex; flex-direction:column; overflow:hidden;
}
.tree-panel h3 { margin:0 0 4px 0; font-size:0.8rem; color:#fbbf24; }
.tip { color:#94a3b8; font-weight:normal; font-size:0.65rem; }
.tree-list {
    flex:1;
    background: #f4f4f4;
    color: #222;
    border-radius:4px;
    overflow:auto;
    position:relative;
    cursor: grab;
}
.tree-graph .tree-col-header {
    position:absolute; top:4px; height:18px;
    text-align:center; font-size:0.68rem; color:#555;
    pointer-events:none; user-select:none;
}
.tree-graph .tree-lines {
    position:absolute; left:0; top:0; pointer-events:none;
}
.tree-line { stroke:#888; stroke-width:1.4; fill:none; }
.tree-graph .tree-node-box {
    position:absolute;
    box-sizing:border-box;
    border:1px solid #6b6b6b;
    border-radius:3px;
    text-align:center;
    line-height:1;
    font-size:1.05rem;
    font-weight:700;
    display:flex; align-items:center; justify-content:center;
    background:#fff; color:#111;
    cursor:pointer; user-select:none;
    overflow:visible; white-space:nowrap;
    padding:0 4px;
    z-index:1;
}
.tree-graph .tree-node-box.root { background:#d9e7f5; border-color:#6e8aaa; font-weight:bold; }
.tree-graph .tree-node-box.odd-move { background:#cfe2f7; border-color:#4f7ba8; }
.tree-graph .tree-node-box.even-move { background:#fde9b8; border-color:#b89244; color:#5a4720; }
.tree-graph .tree-node-box.current { border:2px solid #d9352b; z-index:2; }

/* 分岐数バッジ（右上） */
.tree-badge-branch {
    position:absolute;
    top:-6px; right:-6px;
    background:#dc2626; color:#fff;
    font-size:9px; font-weight:bold;
    padding:1px 4px;
    border-radius:8px;
    line-height:1.2;
    z-index:3;
    pointer-events:none;
}
.tree-badge-branch.done { background:#16a34a; }
/* コメントバッジ（左下） */
.tree-badge-comment {
    position:absolute;
    bottom:-10px; left:-6px;
    font-size:18px;
    line-height:1;
    z-index:3;
    pointer-events:none;
}
/* 最終手マーク（左上） */
.tree-badge-leaf {
    position:absolute;
    top:-6px; left:-6px;
    background:#facc15; color:#3b2c00;
    font-size:10px; font-weight:bold;
    width:14px; height:14px;
    border-radius:50%;
    display:flex; align-items:center; justify-content:center;
    z-index:3;
    pointer-events:none;
}

/* 暗記開始点マーク */
.tree-graph .tree-node-box.memo-start {
    box-shadow: 0 0 0 2px #fbbf24;
}

.tree-transpose-line { stroke: #22c55e; stroke-width: 2; fill: none; stroke-dasharray: 4 3; }
/* 合流エントリーバッジ（右下） */
.tree-badge-transpose-entry {
    position:absolute;
    bottom:-8px; right:-6px;
    background:#16a34a; color:#fff;
    font-size:9px; font-weight:bold;
    padding:1px 4px;
    border-radius:8px;
    line-height:1.2;
    z-index:3;
    pointer-events:none;
}

/* ---- 暗記中ナビボタン ---- */
.memo-nav-btns { display:flex; gap:4px; align-items:center; }

/* ---- 暗記コメント表示 ---- */
.memo-comment-display {
    background: rgba(251,191,36,0.12);
    border: 1px solid #fbbf24;
    border-radius: 6px;
    color: #fde68a;
    font-size: 0.82rem;
    padding: 6px 10px;
    margin-top: 4px;
    white-space: pre-wrap;
    line-height: 1.5;
    width: 100%;
    box-sizing: border-box;
    display: flex; align-items: flex-start; flex-wrap: wrap; gap: 6px;
}

/* ---- 棋譜Box ---- */
.kif-box-panel {
    background: rgba(0,0,0,0.3);
    border-radius: 6px;
    padding: 6px;
    overflow: hidden;
    display: flex; flex-direction: column;
    flex-shrink: 0;
    min-height: 60px;
}
.kif-box-panel h3 {
    margin:0 0 4px 0; font-size:0.8rem; color:#fbbf24;
    display:flex; align-items:center; gap:8px;
}
.kif-box-list {
    display:flex; flex-direction:column; gap:2px;
    flex: 1;
    min-height: 30px;
    overflow-y: auto;
}
.kif-box-item {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 0.75rem;
    cursor: pointer;
    display: flex; justify-content: space-between; align-items:center;
    transition: background 0.15s;
}
.kif-box-item:hover { background: rgba(255,255,255,0.18); }
.kif-box-item.active { background: rgba(251,191,36,0.2); border-color:#fbbf24; }
.kif-box-joseki-header {
    font-size: 0.7rem; font-weight: 600;
    color: #fbbf24; padding: 3px 2px 2px;
    letter-spacing: 0.03em;
}
.kif-box-joseki-item {
    background: rgba(251,191,36,0.08);
    border: 1px solid rgba(251,191,36,0.25);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 0.75rem;
    cursor: pointer;
    display: flex; align-items: center;
    transition: background 0.15s;
    color: #fde68a;
}
.kif-box-joseki-item:hover { background: rgba(251,191,36,0.2); }
.kif-box-joseki-item.active { background: rgba(251,191,36,0.3); border-color:#fbbf24; }
.kif-box-joseki-item.locked {
    opacity: 0.6; cursor: default;
    border-style: dashed;
    color: #a78a4a;
}
.kif-box-joseki-item.locked:hover { background: rgba(251,191,36,0.08); }
.kif-box-joseki-sep {
    font-size: 0.7rem; font-weight: 600;
    color: #94a3b8; padding: 6px 2px 2px;
    letter-spacing: 0.03em;
}
.kif-box-rename {
    background: none; border: none; color: #94a3b8; cursor: pointer;
    font-size: 0.8rem; padding: 2px 4px;
}
.hint-hand {
    outline: 2px solid #ef4444 !important;
    background: rgba(239,68,68,0.25) !important;
    animation: hint-pulse 0.65s ease-in-out infinite alternate;
}
.kif-box-rename:hover { color: #fbbf24; }
.kif-box-item .kif-box-delete {
    background: none; border:none; color:#ef4444; cursor:pointer;
    font-size:0.8rem; padding:2px 4px;
}

.mobile-correct-ind {
    font-size: 2.8rem;
    color: #16a34a;
    font-weight: bold;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    display: none;
    opacity: 0;
    transition: opacity 0.25s;
    pointer-events: none;
    flex-shrink: 0;
}
.mobile-correct-ind.show { opacity: 1; }

/* ---- 暗記完了ダイアログ ---- */
.memorize-complete-content { text-align:center; min-width:260px; }
.complete-emoji { font-size:3rem; margin-bottom:6px; }
.complete-title { color:#fbbf24; margin:0 0 6px; font-size:1.3rem; }
.complete-sub { color:#cbd5e1; font-size:0.85rem; margin:0 0 10px; }
.complete-cheat { font-size:0.9rem; margin:0 0 4px; }

/* ---- 暗記モード（全画面）: 不要要素非表示 ---- */
body[data-mode="memorize-all"] .controls > *:not(.memorize-group):not(#cheat-btn):not(.mobile-correct-ind):not(#memo-comment-display):not(#memo-nav-btns),
body[data-mode="memorize-game"] .controls > *:not(.memorize-group):not(#cheat-btn):not(.mobile-correct-ind):not(#memo-comment-display):not(#memo-nav-btns) { display: none !important; }
body[data-mode="memorize-all"] #memorize-game-btn,
body[data-mode="memorize-game"] #memorize-all-btn { display: none !important; }
body[data-mode="memorize-all"] .controls-nav > *:not(#mode-info):not(#flip-board-btn),
body[data-mode="memorize-game"] .controls-nav > *:not(#mode-info):not(#flip-board-btn) { display: none !important; }
body[data-mode="memorize-all"] #correct-mark,
body[data-mode="memorize-game"] #correct-mark { display: none !important; }
body[data-mode="memorize-all"] #focus-view-btn,
body[data-mode="memorize-game"] #focus-view-btn { display: none !important; }
body[data-mode="memorize-all"] #autoplay-btn,
body[data-mode="memorize-game"] #autoplay-btn { display: none !important; }
body[data-mode="memorize-all"] .mobile-correct-ind,
body[data-mode="memorize-game"] .mobile-correct-ind { display: flex !important; }

/* ---- 自動再生モード ---- */
#autoplay-speed { display: none; width: 90px; cursor: pointer; vertical-align: middle; transform: scaleX(-1); appearance: none; -webkit-appearance: none; background: transparent; }
#autoplay-speed::-webkit-slider-runnable-track { background: #555; height: 4px; border-radius: 2px; }
#autoplay-speed::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: #fbbf24; margin-top: -5px; border: none; }
#autoplay-speed::-moz-range-track { background: #555; height: 4px; border-radius: 2px; }
#autoplay-speed::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #fbbf24; border: none; }
body[data-mode="autoplay"] #autoplay-speed { display: inline-block !important; }
body[data-mode="autoplay"] #autoplay-speed-label { display: inline !important; }
body[data-mode="autoplay"] #autoplay-speed-label2 { display: inline !important; }
body[data-mode="autoplay"] .controls > *:not(.memorize-group):not(#memo-comment-display) { display: none !important; }
body[data-mode="autoplay"] #memorize-all-btn,
body[data-mode="autoplay"] #memorize-game-btn,
body[data-mode="autoplay"] #focus-view-btn { display: none !important; }
body[data-mode="autoplay"] .controls-nav > *:not(#mode-info):not(#flip-board-btn) { display: none !important; }
#autoplay-nav { display: none; }
body[data-mode="autoplay"] #autoplay-nav { display: flex !important; gap: 4px; }
.autoplay-nav .btn-sm { min-width: 36px; font-size: 1rem; }
.memorize-group #memorize-all-btn.active { background: #16a34a !important; border-color: #16a34a !important; }
body[data-mode="autoplay"] .right,
body[data-mode="memorize-all"] .right,
body[data-mode="memorize-game"] .right { flex-direction: row; flex-wrap: wrap; align-items: center; }
body[data-mode="autoplay"] .controls,
body[data-mode="memorize-all"] .controls,
body[data-mode="memorize-game"] .controls { flex-wrap: nowrap; flex: 0 0 auto; }
body[data-mode="autoplay"] .controls-nav,
body[data-mode="memorize-all"] .controls-nav,
body[data-mode="memorize-game"] .controls-nav { flex: 0 0 auto; }
body[data-mode="autoplay"] .tree-panel, body[data-mode="autoplay"] #memorize-info, body[data-mode="autoplay"] .comment-area,
body[data-mode="memorize-all"] .tree-panel, body[data-mode="memorize-all"] #memorize-info, body[data-mode="memorize-all"] .comment-area,
body[data-mode="memorize-game"] .tree-panel, body[data-mode="memorize-game"] #memorize-info, body[data-mode="memorize-game"] .comment-area { flex: 1 1 100%; }
body[data-mode="autoplay"] .memorize-group,
body[data-mode="memorize-all"] .memorize-group,
body[data-mode="memorize-game"] .memorize-group { flex-wrap: nowrap; flex: 0 0 auto; align-items: center; }
body[data-mode="autoplay"] .controls .btn, body[data-mode="autoplay"] .controls-nav .btn,
body[data-mode="memorize-all"] .controls .btn, body[data-mode="memorize-all"] .controls-nav .btn,
body[data-mode="memorize-game"] .controls .btn, body[data-mode="memorize-game"] .controls-nav .btn { min-height: 0 !important; padding-top: 4px !important; padding-bottom: 4px !important; font-size: 0.8rem !important; }

/* ---- モバイル暗記モード ---- */
@media (max-width: 480px) {
    body[data-mode="memorize-all"] .controls-nav > *:not(#mode-info),
    body[data-mode="memorize-game"] .controls-nav > *:not(#mode-info) { display: none !important; }
    body[data-mode="memorize-all"] #memorize-info,
    body[data-mode="memorize-game"] #memorize-info { display: none !important; }
    body[data-mode="memorize-all"] #cheat-btn,
    body[data-mode="memorize-game"] #cheat-btn { font-size: 1.0rem !important; min-height: 26px !important; padding: 4px 10px !important; }
    body[data-mode="memorize-all"] .mobile-correct-ind,
    body[data-mode="memorize-game"] .mobile-correct-ind { display: flex; }
    #correct-mark { display: none !important; }
}

/* ---- リサイズハンドル ---- */
.resize-handle-v {
    width: 10px; flex-shrink: 0; cursor: col-resize;
    background: transparent; transition: background 0.4s 0.4s;
    border-radius: 3px; z-index: 10; position: relative;
}
.resize-handle-v::after {
    content: '↔';
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-size: 11px; color: rgba(251,191,36,0.85);
    pointer-events: none; user-select: none;
    line-height: 1;
}
.resize-handle-v:hover, .resize-handle-v.dragging {
    background: rgba(251,191,36,0.9); transition: background 0s;
}
.resize-handle-v:hover::after, .resize-handle-v.dragging::after {
    color: #fff;
}
.resize-handle-h {
    height: 10px; flex-shrink: 0; cursor: row-resize;
    background: transparent; transition: background 0.4s 0.4s;
    border-radius: 3px; z-index: 10; align-self: stretch; position: relative;
}
.resize-handle-h::after {
    content: '↕';
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-size: 11px; color: rgba(251,191,36,0.85);
    pointer-events: none; user-select: none;
    line-height: 1;
}
.resize-handle-h:hover, .resize-handle-h.dragging {
    background: rgba(251,191,36,0.9); transition: background 0s;
}
.resize-handle-h:hover::after, .resize-handle-h.dragging::after {
    color: #fff;
}
@media (max-width: 900px) {
    .resize-handle-v, .resize-handle-h { display: none; }
}

/* ---- ダイアログ ---- */
.dialog {
    position:fixed; inset:0;
    background: rgba(0,0,0,0.6);
    display:flex; align-items:center; justify-content:center;
    z-index:100;
}
#kifbox-modal {
    align-items: stretch;
    justify-content: stretch;
    padding: 0;
    background: #0f172a;
}
.dialog-content {
    background:#1f2933; padding:20px;
    border-radius:8px; min-width:240px;
    text-align:center;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.dialog-buttons { display:flex; gap:10px; justify-content:center; margin-top:14px; }
.paste-dialog-content { min-width:320px; }
.paste-dialog-content textarea {
    width:100%; resize:vertical;
    background:#111; color:#f0f4f8;
    border:1px solid rgba(255,255,255,0.2);
    border-radius:4px; padding:8px;
    font-size:0.8rem; font-family:monospace;
    margin-top:8px;
}

/* ---- プランバッジ ---- */
.plan-badge {
    font-size:0.68rem; font-weight:600;
    padding:2px 8px; border-radius:10px;
    white-space:nowrap;
}
.plan-badge.free { background:#374151; color:#9ca3af; }
.plan-badge.premium { background:linear-gradient(135deg,#d97706,#b45309); color:#fff; }

/* ---- 認証ダイアログ ---- */
.auth-dialog-content { min-width:280px; }
.auth-dialog-content h3 { margin:0 0 12px 0; color:#fbbf24; }
.auth-dialog-content input {
    display:block; width:100%; margin-bottom:8px;
    padding:8px; border-radius:4px;
    border:1px solid rgba(255,255,255,0.2);
    background:#111; color:#f0f4f8; font-size:0.85rem;
}
.auth-error { color:#ef4444; font-size:0.75rem; min-height:18px; }
.auth-toggle-wrap { margin-top:10px; }
.auth-toggle { color:#60a5fa; cursor:pointer; font-size:0.78rem; }
.auth-toggle:hover { text-decoration:underline; }

/* ---- ×オーバーレイ ---- */
.cross-overlay {
    position:fixed; inset:0;
    display:flex; align-items:center; justify-content:center;
    font-size: 240px; color:#dc2626; font-weight:bold;
    pointer-events:none;
    text-shadow: 0 4px 16px rgba(0,0,0,0.6);
    z-index:200;
    animation: crossPop 0.5s ease-out;
}
@keyframes crossPop {
    0% { transform: scale(0.3); opacity:0; }
    30% { transform: scale(1.2); opacity:1; }
    100% { transform: scale(1); opacity:1; }
}

.memorize-group {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    flex: 1 1 100%;
}
.memorize-group .btn { flex: 0 0 auto; }

/* ---- タブレット対応 ---- */
@media (max-width: 900px) {
    html, body { overflow:auto; }
    .app { height:auto; min-height:100vh; }
    .main { flex-direction:column; padding: 6px; gap: 6px; overflow:visible; }
    .left { width: 100%; align-items:center; }
    .right { width: 100%; min-width: 0; }
    .board {
        width: 360px; height:360px;
        grid-template-columns: repeat(9, 1fr);
        grid-template-rows: repeat(9, 1fr);
    }
    .hand { width: 360px; }
    .piece { width:34px; height:34px; font-size:22px; }
    .hand-piece { width:30px; height:30px; font-size:18px; }
    .topbar { flex-wrap:wrap; gap:6px; }
    .topbar h1 { font-size:0.9rem; }
    .status { display:none; }
    .topbar-right { margin-left:auto; gap:4px; }
    .tree-panel { flex: none; height: 45dvh; min-height:150px; }
}

/* ---- スマホ対応 ---- */
@media (max-width: 480px) {
    .topbar { padding:4px 8px; gap:4px; }
    .topbar h1 { font-size:0.82rem; }
    .topbar-right { width:auto; }
    .plan-badge { font-size:0.6rem; padding:1px 6px; }
    #subscribe-btn { font-size:0.65rem; padding:2px 6px; }
    #account-btn { font-size:0.65rem; padding:2px 6px; }
    .board {
        --cell: min(calc((100vw - 16px) / 9), 40px);
        width: calc(var(--cell) * 9); height: calc(var(--cell) * 9);
        grid-template-columns: repeat(9, 1fr);
        grid-template-rows: repeat(9, 1fr);
    }
    .hand { width: calc(min(calc((100vw - 16px) / 9), 40px) * 9); }
    .piece { width:calc(var(--cell, 35px) - 5px); height:calc(var(--cell, 35px) - 5px); font-size:18px; }
    .hand-piece { width:28px; height:28px; font-size:16px; }
    .controls { gap:3px; }
    .controls .btn { padding:4px 7px; font-size:0.7rem; min-height:28px; }
    .memorize-group .btn { font-size:0.6rem !important; padding:3px 3px !important; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
    .controls-nav { justify-content: center; }
    .controls-nav .btn { padding:4px 7px; font-size:0.7rem; min-height:28px; }
    #back-btn, #forward-btn { min-height: 42px !important; }
    .info { padding:3px 6px; font-size:0.75rem; gap:6px; }
    .tree-panel { flex: none; height: 35dvh; min-height:120px; }
    footer { display: none; }
    .dialog-content { min-width:auto; width:90vw; max-width:320px; }
    .paste-dialog-content { min-width:auto; }
    .auth-dialog-content { min-width:auto; }
}
