:root {
    --magic-purple: #9b59b6;
    --magic-glow: #be90d4;
    --bg-color: #f4f0f9;
    --panel-bg: #ffffff;
    --header-bg: #1a1a2e;
    --editor-bg: #1e1e1e;
    /* カテゴリ別カラー */
    --block-input-color: #4cbfe1;
    --block-print-color: #9966ff;
    --block-calc-color: #59c059;
    --block-text-color: #40bf4a;
    --block-control-color: #e6ab22; /* オレンジ */
    --block-list-color: #c96d05; /* 濃いオレンジ */
}

body {
    font-family: 'Hiragino Kaku Gothic ProN', 'Meiryo', sans-serif;
    background-color: var(--bg-color);
    margin: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    color: #333;
    overflow: hidden;
}

/* --- ヘッダー --- */
.game-header {
    width: 100%;
    background-color: var(--header-bg);
    background-image: url('images/magic_icon.jpg');
    background-size: cover;
    background-position: center;
    color: white;
    position: relative;
    box-shadow: 0 5px 20px rgba(0,0,0,0.3);
    border-bottom: 4px solid var(--magic-purple);
    z-index: 10;
}

.game-header::before {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: radial-gradient(circle at left, rgba(155, 89, 182, 0.2) 0%, rgba(26, 26, 46, 0.9) 100%);
}

.header-content {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 15px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 75px; 
}

.home-banner-link {
    display: block;
    height: 65px;
    transition: transform 0.2s, filter 0.2s;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid #f1c40f;
    box-shadow: 0 0 15px rgba(155, 89, 182, 0.6), 
                inset 0 0 5px rgba(241, 196, 15, 0.3);
}

.home-banner-link:hover {
    transform: scale(1.03);
    border-color: #fff;
    box-shadow: 0 0 20px rgba(155, 89, 182, 0.9), 
                inset 0 0 10px rgba(241, 196, 15, 0.5);
}

.home-banner-img {
    height: 100%;
    width: auto;
    object-fit: contain;
}

.player-status-area {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    text-align: right;
    justify-content: center;
}

.main-title-text {
    font-size: 1.15rem;
    font-weight: bold;
    color: white;
    line-height: 1.2;
    letter-spacing: 1px;
    text-shadow: 0 0 10px var(--magic-glow);
    margin: 0;
}

.player-rank {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
}

.lvl-badge {
    background: #f1c40f;
    color: #1a1a2e;
    padding: 1px 8px;
    border-radius: 4px;
    font-weight: bold;
    font-size: 0.75rem;
    box-shadow: 0 0 8px rgba(241, 196, 15, 0.4);
}

.rank-name {
    font-size: 0.9rem;
    font-weight: bold;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

/* --- レイアウト --- */
.game-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
    width: 100%;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 15px;
    background: #f0f0f7;
    overflow-y: auto;
    align-items: center; 
}

.content-container {
    width: 100%;
    max-width: 1000px;
    display: flex;
    flex-direction: row; 
    align-items: flex-start;
    gap: 20px;
    flex: 1;
}

.practice-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0; 
}

/* --- サイドバー（テンプレート） --- */
.sidebar {
    width: 280px;
    background: #1a1a2e;
    color: #ecf0f1;
    display: flex;
    flex-direction: column;
    border-radius: 12px;
    border: 2px solid var(--magic-purple);
    height: calc(100vh - 120px);
    position: sticky;
    top: 0;
}

.sidebar-header { 
    height: 50px; 
    flex-shrink: 0;
    background-color: #111122; 
    background-image: url('images/magic_kata.jpg');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    border-bottom: 1px solid rgba(155, 89, 182, 0.3);
    border-radius: 10px 10px 0 0;
    text-indent: -9999px;
    overflow: hidden;
}

.sidebar-sub-heading {
    font-size: 0.85rem;
    margin: 25px 0 8px 5px;
    font-weight: bold;
    padding-left: 8px;
    background: transparent !important;
}
.sidebar-sub-heading.block-input { border-left: 3px solid var(--block-input-color); color: var(--block-input-color); }
.sidebar-sub-heading.block-print { border-left: 3px solid var(--block-print-color); color: var(--block-print-color); }
.sidebar-sub-heading.block-calc { border-left: 3px solid var(--block-calc-color); color: var(--block-calc-color); }
.sidebar-sub-heading.block-control { 
    border-left: 3px solid var(--block-control-color); 
    color: var(--block-control-color); 
}
.sidebar-sub-heading.block-list { 
    border-left: 3px solid var(--block-list-color); 
    color: var(--block-list-color); 
}

.template-list {
    flex: 1;
    overflow-y: auto;
    padding: 5px 10px 10px 10px;
}
.template-list::-webkit-scrollbar { width: 6px; }
.template-list::-webkit-scrollbar-thumb { background: var(--magic-purple); border-radius: 3px; }
.template-list .sidebar-sub-heading:first-child {
    margin-top: 0 !important;
}

/* 🔯 型ボタン */
.template-item { margin-bottom: 10px; }
.template-full-btn {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(155, 89, 182, 0.2);
    border-radius: 6px;
    padding: 5px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-sizing: border-box;
}
.template-full-btn:hover { background: rgba(155, 89, 182, 0.15); border-color: var(--magic-purple); }

.scratch-block {
    padding: 6px 14px;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: bold;
    color: white;
    position: relative;
    display: inline-block;
    box-shadow: inset 0 -2px 0 rgba(0,0,0,0.2);
    width: fit-content;
    z-index: 1;
}
.block-input { background: var(--block-input-color); }
.block-print { background: var(--block-print-color); }
.block-calc { background: var(--block-calc-color); }
.block-text { background: var(--block-text-color); }
.block-control { background: var(--block-control-color); }
.block-list { background: var(--block-list-color); }

.scratch-block::before {
    content: ''; position: absolute; top: -1px; left: 14px; width: 16px; height: 5px;
    background: #1a1a2e; border-radius: 0 0 3px 3px;
}
.scratch-block::after {
    content: ''; position: absolute; bottom: -4px; left: 14px; width: 16px; height: 4px;
    background: inherit; border-radius: 0 0 3px 3px;
}

.scratch-block.round-block {
    border-radius: 20px;
    padding: 6px 16px;
    box-shadow: inset 0 -2px 0 rgba(0,0,0,0.2);
}

.scratch-block.round-block::before {
    display: none !important;
}

.scratch-block.round-block::after {
    display: none !important;
}

.code-label { 
    font-size: 0.75rem; 
    color: #bbb; 
    font-family: 'Consolas', monospace; 
    display: flex; 
    align-items: center; 
    justify-content: flex-start;
    gap: 6px; 
    width: 100%; 
}
.code-label code {
    color: #00ffcc; 
    background: rgba(0,0,0,0.5); 
    padding: 4px 8px; 
    border-radius: 3px;
    flex: 1; 
    white-space: nowrap; 
    overflow: hidden; 
    text-overflow: ellipsis; 
    display: block;
    text-align: left;
}

/* --- メインコンテンツの修行エリア --- */
.chapter-container {
    width: 100%;
    background: linear-gradient(to bottom, #4e342e 0%, #3e2723 100%);
    border: 3px solid #3e2723;
    border-bottom: none; 
    border-radius: 12px 12px 0 0;
    padding: 8px 20px 8px;
    margin-bottom: 0;
    flex-shrink: 0;
    box-sizing: border-box;
    box-shadow: none; 
    position: relative;
    z-index: 5;
    overflow: visible;
}

.chapter-container::before {
    content: '';
    position: absolute;
    bottom: 2px;
    left: 5%;
    width: 90%;
    height: 1px;
    background: linear-gradient(to right, transparent, #d2b48c, transparent);
    opacity: 0.5;
}

.chapter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
    border-bottom: 1px solid rgba(210, 180, 140, 0.2);
    padding-bottom: 4px;
}

.chapter-content-row {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    padding-top: 3px;
}

.chapter-title-text {
    font-size: 0.9rem;
    color: #e1c699;
    margin: 0;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
    white-space: nowrap;
}

.chapter-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
    border-bottom: 1px solid rgba(210, 180, 140, 0.2);
    padding-bottom: 4px;
    overflow-x: auto;
    white-space: nowrap;
}
.chapter-tabs::-webkit-scrollbar { height: 4px; }
.chapter-tabs::-webkit-scrollbar-thumb { background: #795548; border-radius: 2px; }

.chapter-tab {
    color: #a1887f;
    font-size: 0.9rem;
    font-weight: bold;
    cursor: pointer;
    transition: 0.3s;
    padding: 2px 6px;
    position: relative;
    flex-shrink: 0;
}

.chapter-tab.active {
    color: #f1c40f;
}

.chapter-tab.active::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 100%;
    height: 2px;
    background: #f1c40f;
    box-shadow: 0 0 5px #f1c40f;
}

.chapter-tab:hover:not(.active) {
    background: #795548;
    color: #fff;
}

.sugoroku-steps {
    display: flex;
    align-items: center;
    padding: 0;
}

.step-wrapper {
    display: flex;
    align-items: center;
}

.step-line {
    width: 15px;
    height: 2px;
    background: rgba(244, 232, 209, 0.6);
    margin: 0 3px; 
    border-radius: 1px;
}

.step-node {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    background: #1a1a1a;
    border: 1px solid rgba(244, 232, 209, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.7rem;
    color: rgba(244, 232, 209, 0.8);
    cursor: pointer;
    transition: all 0.2s ease-out;
    box-shadow: 1px 1px 2px rgba(0,0,0,0.5), inset 0 1px 3px rgba(0,0,0,0.8);
}

.step-node.active {
    border-color: #f1c40f;
    background: radial-gradient(circle, #795548, #3e2723); 
    color: #fff;
    transform: scale(1.1) translateY(-1px);
    box-shadow: 0 2px 8px rgba(241, 196, 15, 0.5);
}

.step-node.type-summon {
    background: #2e1a3d;
    border-color: #9b59b6;
    color: #9b59b6;
    box-shadow: 0 0 5px rgba(155, 89, 182, 0.4), inset 0 1px 3px rgba(0,0,0,0.8);
}

.step-node.type-summon.active {
    background: radial-gradient(circle, #b22222, #3e2723);
    border-color: #f1c40f;
    color: #fff;
    box-shadow: 0 0 10px rgba(241, 196, 15, 0.6), inset 0 0 5px rgba(241, 196, 15, 0.3);
}

.step-node.type-summon span {
    transform: none;
    font-size: 1rem;
}

.problem-card { 
    background-color: #f4e8d1; 
    background-image: url('https://www.transparenttextures.com/patterns/parian.png');
    border: 3px solid #3e2723;
    border-top: none; 
    padding: 10px 15px 4px 15px; 
    border-radius: 0 0 12px 12px;
    box-shadow: none; 
    margin-bottom: 5px;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
}
.problem-title { 
    font-weight: bold; 
    margin-bottom: 10px; 
    color: #3e2723; 
    font-size: 1.1rem; 
    border-bottom: 2px solid #d2b48c;
    padding-bottom: 5px;
    font-family: 'serif';
}

#p-text { 
    color: #5d4037 !important;
    font-weight: 500;
}

#p-examples > div strong { 
    color: #8b4513 !important;
}

.editor-container {
    padding-top: 25px !important;
    position: relative;
    background: #1a1a2e !important;
    border: 2px solid #3e2723 !important;
    border-radius: 10px;
    overflow: hidden;
}

.editor-container::before {
    content: "─── ✦ Python STARS 召喚魔法陣 ✦ ───  ";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 25px;
    background: linear-gradient(90deg, #1a1a2e 0%, #2e1a3d 100%);
    color: #e1c699;
    font-family: 'Yu Mincho', serif;
    font-size: 0.8rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    border-bottom: 1.5px solid rgba(225, 198, 153, 0.3);
    z-index: 10;
}

#editor {
    width: 100%;
}

.result-box { 
    background: white; 
    padding: 15px; 
    border-radius: 10px; 
    border-left: 8px solid #cbd5e0; 
    margin-top: 10px; 
    margin-bottom: 20px; 
    min-height: 87px;
    flex-shrink: 0; 
}
.output-text {
     font-family: 'Consolas', monospace; font-size: 0.85rem; white-space: pre-wrap; margin: 0; 
}

.ACCEPTED { border-left-color: var(--magic-purple) !important; background: #f9f5ff; }
.WRONG { border-left-color: #e74c3c !important; background: #fff5f5; }

/* 🔯 魔法陣演出 */
#magic-overlay {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    display: none; justify-content: center; align-items: center; 
    z-index: 2100;
    pointer-events: none;
}
.summoning { display: flex !important; animation: fadeOutEffect 0.8s ease-in forwards 1.4s; }
.magic-circle {
    width: 350px; height: 350px;
    border: 10px double var(--magic-purple); border-radius: 50%;
    position: relative;
    box-shadow: 0 0 50px var(--magic-purple), inset 0 0 50px var(--magic-purple);
    opacity: 0;
}
.magic-circle::before, .magic-circle::after {
    content: ''; position: absolute; top: 50%; left: 50%; width: 100%; height: 100%;
    border: 5px solid var(--magic-purple); transform: translate(-50%, -50%) rotate(30deg);
}
.magic-circle::after { transform: translate(-50%, -50%) rotate(60deg); }
.summoning .magic-circle { animation: circleIn 0.7s ease-out forwards, circleRotate 10s linear infinite 0.7s; }

.success-text {
    position: absolute; font-size: 5rem; color: white; font-weight: bold;
    text-shadow: 0 0 20px var(--magic-purple), 0 0 40px #fff;
    opacity: 0; z-index: 1001;
}
.summoning .success-text { animation: textIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards 0.2s; }

@keyframes circleIn { from { opacity: 0; transform: scale(0.5) rotate(-180deg); } to { opacity: 1; transform: scale(1) rotate(0deg); } }
@keyframes circleRotate { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes textIn { from { opacity: 0; transform: scale(0.5); } to { opacity: 1; transform: scale(1); } }
@keyframes fadeOutEffect { from { opacity: 1; } to { opacity: 0; } }

.example-row {
    margin-bottom: 6px;
    padding: 0;
}

.example-flex-container {
    display: flex;
    align-items: stretch;
    gap: 6px;
}

.example-number-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    color: #8b4513;
    font-weight: bold;
    font-family: 'serif';
    min-width: 40px;
    border-right: 1px dashed rgba(139, 69, 19, 0.3);
    margin-right: 4px;
    opacity: 0.8;
    padding-bottom: 2px;
}

.example-block {
    flex: 1;
    display: flex;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid rgba(139, 69, 19, 0.2);
    min-height: 2rem; 
}

.block-label {
    width: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: bold;
    color: white;
    flex-shrink: 0;
}

.input-block .block-label { background: var(--block-input-color); }
.output-block .block-label { background: var(--block-print-color); }

.block-value {
    flex: 1;
    padding: 3px 10px 2px 10px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.85rem;
    color: #3e2723;
    white-space: pre-wrap;
    word-break: break-all;
    display: flex;
    align-items: center;
    line-height: 1.3;
}

.example-arrow {
    display: flex;
    align-items: center;
    font-size: 1rem;
    color: #8b4513;
    font-weight: bold;
    opacity: 0.8;
    user-select: none;
    padding: 0 2px;
}

#answer-area {
    animation: fadeInAnswer 0.5s ease-out;
}

@keyframes fadeInAnswer {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

#answer-text {
    position: relative;
    overflow: hidden;
}

#answer-text::before {
    content: 'answer';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-15deg);
    font-size: 3rem;
    font-weight: bold;
    color: rgba(155, 89, 182, 0.05);
    pointer-events: none;
}

.action-area {
    display: flex;
    gap: 10px;
    width: 100%;
    margin-top: 5px;
    margin-bottom: 5px;
}

.run-btn {
    flex: 2;
    width: auto;
    padding: 16px 14px 12px;
    background: var(--magic-purple);
    color: white;
    border: none;
    cursor: pointer;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: bold;
    box-shadow: 0 4px 0 #8e44ad;
    transition: all 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.answer-btn {
    flex: 1;
    padding: 16px 14px 12px;
    background: #5d4037;
    color: #e1c699;
    border: none;
    cursor: pointer;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: bold;
    box-shadow: 0 4px 0 rgba(0, 0, 0, 0.3); 
    transition: all 0.1s;
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.answer-btn:hover {
    filter: brightness(1.1);
}

.run-btn:active, .answer-btn:active {
    transform: translateY(2px);
    box-shadow: none;
    padding: 14px; 
}

/* --- 召喚モーダル（実体化フィールド） --- */
.summon-field-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex; justify-content: center; align-items: center;
    z-index: 2000;
    cursor: pointer;
    opacity: 0;
    animation: fadeInField 0.3s forwards;
    backdrop-filter: blur(5px);
}

.summon-field-content {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 40px;
    z-index: 3000 !important;
    pointer-events: none;
}

.summon-monster-name {
    font-family: 'Klee One', cursive; 
    font-size: 2.5rem; 
    color: #fff;
    text-shadow: 0 0 15px #9b59b6, 0 0 25px #9b59b6;
    font-weight: bold; 
    letter-spacing: 0.15em;
    opacity: 0;
    animation: slamIn 0.4s 1.6s forwards cubic-bezier(0.215, 0.610, 0.355, 1.000);
}

#summon-monster-img {
    position: relative;
    z-index: 10;
    max-height: 65vh; 
    width: auto;
    filter: drop-shadow(0 0 30px rgba(155, 89, 182, 1.0));
    opacity: 0;
    animation: slamIn 0.5s 0.8s forwards cubic-bezier(0.215, 0.610, 0.355, 1.000);
}

.monster-container {
    position: relative;
    display: flex; 
    justify-content: center; 
    align-items: center;
    animation: shakeContainer 0.3s 1.1s ease-out;
}

.star-effect-container { 
    position: absolute; 
    top: 50%; 
    left: 50%; 
    width: 1px; 
    height: 1px; 
    z-index: 1; 
}

.summon-star { 
    position: absolute; 
    top: 50%; 
    left: 50%; 
    width: 15px;
    height: 15px; 
    background: white; 
    clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%); 
    opacity: 0; 
    transform: translate(-50%, -50%); 
}

.summon-guide-message {
    font-size: 1rem; 
    color: rgba(255, 255, 255, 0.7);
    letter-spacing: 0.1em;
    opacity: 0; 
    pointer-events: auto;
    animation: 
        fadeInField 1s 2.3s forwards,
        messageBlink 2.5s 3.3s infinite ease-in-out;
}

@keyframes fadeInField { to { opacity: 1; } }

@keyframes slamIn {
    0% {
        opacity: 0;
        transform: scale(2) translateY(-150px);
        filter: blur(10px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
        filter: blur(0);
    }
}

@keyframes shakeContainer {
    0% { transform: translate(0, 0); }
    20% { transform: translate(-10px, 10px); }
    40% { transform: translate(10px, -10px); }
    60% { transform: translate(-5px, 5px); }
    80% { transform: translate(5px, -5px); }
    100% { transform: translate(0, 0); }
}

@keyframes star-burst {
    0% { 
        transform: translate(-50%, -50%) scale(0) rotate(0deg); 
        opacity: 1; 
    }
    100% { 
        transform: translate(calc(-50% + var(--tx)), calc(-50% + var(--ty))) scale(1.2) rotate(360deg); 
        opacity: 0; 
    }
}

@keyframes messageBlink {
    0% {
        opacity: 0.7;
        transform: scale(1);
    }
    50% {
        opacity: 0.2;
        transform: scale(0.98);
    }
    100% {
        opacity: 0.7;
        transform: scale(1);
    }
}

.no-shake,
.no-shake * {
    animation: none !important;
    transform: none !important;
    opacity: 1 !important;
}

.keyboard-btn {
    width: 100%;
    padding: 8px;
    margin-bottom: 8px;
    background: linear-gradient(180deg, #b7950b 0%, #9a7d0a 100%);
    color: #ffffff;
    border: 1px solid #7d6608;
    border-radius: 6px;
    font-family: 'Klee One', cursive;
    font-size: 0.95rem;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.4);
    transition: all 0.2s ease;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}

.keyboard-btn:hover {
    background: linear-gradient(180deg, #c5a10c 0%, #b7950b 100%);
    box-shadow: 0 3px 6px rgba(0,0,0,0.5);
}

.keyboard-btn:active {
    background: #7d6608;
    transform: translateY(1px);
    box-shadow: 0 1px 2px rgba(0,0,0,0.4);
}

.keyboard-help-content {
    height: 0;
    overflow: hidden;
    transition: height 0.3s ease-out;
    background: transparent;
    border: none;
    padding: 0;
    margin: 0;
    text-align: center;
}

.keyboard-help-content.open {
    height: auto;
    padding: 5px 0;
}

.keyboard-img {
    max-width: 95%; 
    height: auto;
    border: none;
    box-shadow: none;
}

#p-image-container {
    text-align: left;
    margin-bottom: 15px;
    padding-left: 5px;
}

#p-image {
    border: none !important;
    border-radius: 6px;
    display: block;
}

/* --- Ace Editor スクロールバー --- */
#editor .ace_scrollbar {
    width: 12px !important;
    background-color: rgba(0, 0, 0, 0.2);
}

#editor ::-webkit-scrollbar {
    width: 12px;
}

#editor ::-webkit-scrollbar-track {
    background: rgba(26, 26, 46, 0.5);
    border-radius: 10px;
}

#editor ::-webkit-scrollbar-thumb {
    background: #804796; 
    border-radius: 10px;
    border: 2px solid #272822; 
    transition: background 0.3s ease;
}

#editor ::-webkit-scrollbar-thumb:hover {
    background: #9b59b6; 
    box-shadow: 0 0 10px rgba(155, 89, 182, 0.8);
    cursor: pointer;
}

#editor .ace_scrollbar-v, 
#editor .ace_scrollbar-h {
    cursor: pointer;
}

#editor .ace_scrollbar-h {
    height: 12px !important;
    background-color: rgba(0, 0, 0, 0.2);
}

#editor ::-webkit-scrollbar:horizontal {
    height: 12px;
}

#editor ::-webkit-scrollbar-track:horizontal {
    background: rgba(26, 26, 46, 0.5);
    border-radius: 10px;
}

#editor ::-webkit-scrollbar-thumb:horizontal {
    background: #6c3483; 
    border-radius: 10px;
    border: 2px solid #272822; 
}

#editor ::-webkit-scrollbar-thumb:horizontal:hover {
    background: #9b59b6; 
    box-shadow: 0 0 10px rgba(155, 89, 182, 0.8);
}

/* --- Ace Editor Python STARS 配色 --- */
div#editor.ace_editor {
    background-color: #0d0d15 !important;
    line-height: 1.15 !important;
}

div#editor.ace_editor .ace_content,
div#editor.ace_editor .ace_constant.ace_numeric,
div#editor.ace_editor .ace_string,
div#editor.ace_editor .ace_text {
    color: #ffffff !important;
}

div#editor.ace_editor .ace_identifier,
div#editor.ace_editor .ace_variable,
div#editor.ace_editor .ace_magic.ace_assign {
    color: #FF8C1A !important;
}

div#editor.ace_editor .ace_magic.ace_control {
    color: #e6ab22 !important;
    font-weight: bold !important;
}

div#editor.ace_editor .ace_magic.ace_compare {
    color: #59c059 !important;
}

div#editor.ace_editor .ace_magic.ace_data,
div#editor.ace_editor .ace_paren {
    color: #ffff9c !important;
}

div#editor.ace_editor .ace_magic.ace_print {
    color: #c6aaff !important;
}

div#editor.ace_editor .ace_magic.ace_input {
    color: #4cbfe1 !important;
}

div#editor.ace_editor .ace_comment {
    color: #aaaaaa !important;
    font-style: italic !important;
}

div#editor.ace_editor .ace_gutter {
    background: #272822 !important;
    color: #8F908A !important;
    line-height: 1.1 !important;
    width: 35px !important;
}

div#editor.ace_editor .ace_marker-layer .ace_active-line {
    background: rgba(255, 255, 255, 0.05) !important;
}

div#editor.ace_editor .ace_placeholder {
    color: #e0e0e0 !important;
    font-family: 'Consolas', 'Monaco', monospace !important;
}

div#editor.ace_editor .ace_gutter-cell {
    padding-left: 0 !important;
    padding-right: 10px !important;
    text-align: right !important;
}

div#editor.ace_editor .ace_gutter-layer {
    width: 35px !important;
}

@keyframes text-glow-flash {
    0% { text-shadow: 0 0 10px #fff, 0 0 20px #870c7e; }
    100% { text-shadow: 0 0 0px transparent; }
}

@keyframes magic-glow-burst {
    0% { box-shadow: 0 0 10px 5px #870c7e, inset 0 0 10px 5px #870c7e; filter: brightness(1.2); }
    100% { box-shadow: 0 0 0px transparent; filter: brightness(1); }
}

.success-glow {
    animation: magic-glow-burst 3s ease-out forwards !important;
}

.success-glow .ace_content {
    animation: text-glow-flash 1.5s ease-out forwards !important;
}

/* --- 未解放タブのスタイル --- */
.chapter-tab.locked {
    opacity: 0.35;
    cursor: not-allowed !important;
    filter: grayscale(80%);
    pointer-events: auto; /* hover等のカーソル制御のため */
}
.chapter-tab.locked:hover {
    background: transparent !important;
    color: #a1887f !important;
}

/* --- オールクリアボタンのスタイル --- */
.answer-btn.all-clear-btn {
    background: linear-gradient(135deg, #f1c40f 0%, #d4ac0d 100%) !important;
    color: #1a1a2e !important;
    box-shadow: 0 0 15px rgba(241, 196, 15, 0.6) !important;
    cursor: default !important;
    transform: none !important;
    opacity: 0.95;
    font-size: 1.05rem !important;
    letter-spacing: 1px;
}

/* --- 聖典（模範解答）のコピー禁止設定 --- */
#answer-area,
#answer-text {
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    user-select: none !important;
}

/* 管理者モード中は選択・コピー可能 */
body.admin-mode #answer-area,
body.admin-mode #answer-text {
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
    -ms-user-select: text !important;
    user-select: text !important;
}