/* ベース設定 */
@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700&family=Rajdhani:wght@500;700&family=Zen+Kaku+Gothic+New:wght@400;700&display=swap');

:root {
    --color-cyan: #22d3ee;
    --color-cyan-dark: #083344;
    --color-bg: #030712;
    --color-pink: #f472b6;
}

body {
    background-color: var(--color-bg);
    overscroll-behavior: none;
}

/* Hidden utility class: elements with this class are not displayed.  We use this to show/hide modals and panels via JS. */
.hidden {
    display: none !important;
}

/* Control the visibility of the intro overlay using a hidden checkbox (#introToggle).
   When the checkbox is checked, the adjacent intro modal (#introModal) is hidden.
   The main menu remains visible underneath the overlay, so once the modal is
   hidden the home screen becomes accessible. */
#introToggle:checked + #introModal {
    display: none !important;
}

/* カスタムスクロールバー */
.custom-scrollbar::-webkit-scrollbar { width: 4px; }
.custom-scrollbar::-webkit-scrollbar-track { background: transparent; }
.custom-scrollbar::-webkit-scrollbar-thumb { background: #1e293b; border-radius: 2px; }
.custom-scrollbar::-webkit-scrollbar-thumb:hover { background: var(--color-cyan); }

/* パネルスタイル */
.panel-box {
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(34, 211, 238, 0.2);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

/* HUDボタン */
.hud-btn {
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 4px;
    color: #94a3b8;
    transition: all 0.2s;
    cursor: pointer;
}
.hud-btn:hover {
    background: rgba(34, 211, 238, 0.1);
    color: var(--color-cyan);
    text-shadow: 0 0 8px var(--color-cyan);
}

/* パーツボタン */
.comp-btn {
    background: linear-gradient(145deg, rgba(30, 41, 59, 0.6), rgba(15, 23, 42, 0.8));
    border: 1px solid rgba(71, 85, 105, 0.5);
    border-radius: 6px;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
    cursor: grab;
    user-select: none;
}
.comp-btn:active { cursor: grabbing; }
.comp-btn:hover:not(:disabled) {
    border-color: var(--color-cyan);
    box-shadow: 0 0 15px rgba(34, 211, 238, 0.2) inset;
    transform: translateY(-1px);
}
.comp-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    filter: grayscale(100%);
}
.comp-btn .count-badge {
    background: rgba(8, 51, 68, 0.9);
    border: 1px solid var(--color-cyan);
    color: var(--color-cyan);
    font-family: 'Orbitron', sans-serif;
    font-size: 9px;
    padding: 1px 4px;
    border-radius: 3px;
}

/* ツールボタン */
.tool-btn {
    background: rgba(30, 41, 59, 0.5);
    border: 1px solid rgba(71, 85, 105, 0.5);
    color: #cbd5e1;
    font-family: 'Rajdhani', sans-serif;
    font-weight: bold;
    font-size: 12px;
    padding: 8px;
    border-radius: 4px;
    transition: all 0.2s;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    cursor: pointer;
}
.tool-btn:hover:not(:disabled) {
    background: rgba(34, 211, 238, 0.1);
    border-color: var(--color-cyan);
    color: #fff;
}
.tool-btn.active {
    background: rgba(34, 211, 238, 0.2);
    border-color: var(--color-cyan);
    color: var(--color-cyan);
    box-shadow: 0 0 10px rgba(34, 211, 238, 0.3);
}

/* メニューボタン */
.menu-btn {
    position: relative;
    padding: 1.5rem;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid rgba(34, 211, 238, 0.3);
    color: white;
    font-family: 'Orbitron', sans-serif;
    font-weight: bold;
    font-size: 1.25rem;
    border-radius: 0.5rem;
    overflow: hidden;
    transition: all 0.3s;
    text-align: left;
    cursor: pointer;
}
.menu-btn:hover {
    border-color: var(--color-cyan);
    box-shadow: 0 0 20px rgba(34, 211, 238, 0.3);
    transform: scale(1.02);
}

/* ステージカード */
.stage-card {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(56, 189, 248, 0.2);
    border-radius: 8px;
    padding: 1.5rem;
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
    display: flex; flex-direction: column;
    min-height: 140px;
}
.stage-card::before {
    content: ''; position: absolute; top:0; left:0; width: 4px; height: 100%;
    background: #334155; transition: all 0.3s;
}
.stage-card.unlocked {
    cursor: pointer;
    background: linear-gradient(145deg, rgba(15, 23, 42, 0.8), rgba(8, 51, 68, 0.4));
}
.stage-card.unlocked:hover {
    border-color: var(--color-cyan);
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
.stage-card.unlocked:hover::before { background: var(--color-cyan); box-shadow: 0 0 10px var(--color-cyan); }
.stage-card.cleared::before { background: #34d399; box-shadow: 0 0 10px #34d399; }
.stage-card.locked { opacity: 0.5; filter: grayscale(1); cursor: not-allowed; }

/* アニメーション */
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
.animate-float { animation: float 3s ease-in-out infinite; }

@keyframes bounce-slight { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
.animate-bounce-slight { animation: bounce-slight 2s ease-in-out infinite; }

@keyframes pan { from { background-position: 0 0; } to { background-position: 100px 100px; } }
.animate-pan { animation: pan 20s linear infinite; }

.typing-effect {
    border-right: 2px solid var(--color-pink);
    animation: blink 0.75s step-end infinite;
}
@keyframes blink { 0%, 100% { border-color: transparent; } 50% { border-color: var(--color-pink); } }

/* --- Sparky 修正箇所 --- */
#sparkyFace {
    font-family: "Zen Kaku Gothic New", sans-serif;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 0 10px var(--color-pink);
    /* フォントサイズを小さく調整し、行間を詰める */
    font-size: 3rem; 
    line-height: 1;
    width: 100%;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    white-space: nowrap;
    /* Ensure the face is not flipped vertically when entering sandbox mode. */
    transform: scaleY(1) !important;
}

#sparkyContainer .panel-box {
    border-color: rgba(244, 114, 182, 0.3);
}
#sparkyContainer .bg-cyan-500 {
    background-color: var(--color-pink);
}
/* ===== Inventory sidebar collapse ===== */
#inventoryPanel {
    transition: width 0.2s ease;
}

#inventoryPanel.collapsed {
    width: 3.25rem;
}

/* 畳んだときはパーツ一覧を非表示に */
#inventoryPanel.collapsed #inventoryGrid {
    display: none;
}

/* ゴミ箱の文字だけ消してアイコンだけにする */
#inventoryPanel.collapsed #trashZone span:nth-child(2) {
    display: none;
}
#inventoryPanel.collapsed .panel-box > .flex {
    justify-content: center;
}

/* パーツボタンのレイアウト調整 */
.comp-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.comp-btn .icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
}

/* ラベル用クラス（複数行になってもOK） */
.comp-label {
    font-size: 11px;
    font-weight: 700;
    color: #e5e7eb;
    letter-spacing: 0.14em;
    line-height: 1.2;
    white-space: normal;
}

/* 少しリッチなホバー表現 */
.comp-btn:hover:not(:disabled) {
    box-shadow: 0 0 15px rgba(34, 211, 238, 0.3) inset, 0 0 12px rgba(34, 211, 238, 0.35);
    transform: translateY(-1px);
}

/* Highlight Sparky container when a level is cleared. Turns border and glow to success green */
#sparkyContainer.cleared .panel-box {
    border-color: rgba(52, 211, 153, 0.5); /* green border */
    box-shadow: 0 0 20px rgba(52, 211, 153, 0.4);
}
#sparkyContainer.cleared #sparkyFace {
    text-shadow: 0 0 10px #34d399;
    color: #34d399;
}


