/* ========================================
   パスダンジョン - RPG風ゲームスタイル
   ======================================== */

/* リセット＆基本設定 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* カラーパレット - ファンタジーRPG風 */
    --bg-primary: linear-gradient(135deg, #1e3a8a 0%, #312e81 100%);
    --bg-secondary: #1f2937;
    --bg-panel: rgba(31, 41, 55, 0.95);
    --border-main: #fbbf24;
    --text-primary: #f9fafb;
    --text-secondary: #d1d5db;
    --accent-gold: #fbbf24;
    --accent-green: #10b981;
    --accent-red: #ef4444;
    --accent-blue: #3b82f6;

    /* シャドウ */
    --shadow-panel: 0 10px 30px rgba(0, 0, 0, 0.5);
    --shadow-button: 0 4px 6px rgba(0, 0, 0, 0.3);
}

body {
    font-family: 'Segoe UI', 'Hiragino Kaku Gothic ProN', 'メイリオ', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ========================================
   画面切り替えシステム
   ======================================== */
.screen {
    display: none;
    min-height: 100vh;
    animation: fadeIn 0.5s ease-in;
}

.screen.active {
    display: flex;
    flex-direction: column;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ========================================
   タイトル画面
   ======================================== */
#title-screen {
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #312e81 100%);
    position: relative;
    overflow: hidden;
}

#title-screen::before {
    content: '⭐';
    position: absolute;
    font-size: 20px;
    animation: twinkle 3s infinite;
    opacity: 0;
}

@keyframes twinkle {
    0%, 100% { opacity: 0; }
    50% { opacity: 1; }
}

.title-container {
    text-align: center;
    padding: 2rem;
    background: rgba(0, 0, 0, 0.5);
    border: 4px solid var(--border-main);
    border-radius: 20px;
    box-shadow: var(--shadow-panel);
    max-width: 600px;
}

.game-title {
    font-size: 3.5rem;
    font-weight: bold;
    color: var(--accent-gold);
    text-shadow: 3px 3px 0 #000,
                 -1px -1px 0 #000,
                 1px -1px 0 #000,
                 -1px 1px 0 #000;
    margin-bottom: 1rem;
    animation: titleBounce 2s ease-in-out infinite;
}

@keyframes titleBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.game-subtitle {
    font-size: 1.3rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.title-description {
    background: rgba(255, 255, 255, 0.1);
    padding: 1rem;
    border-radius: 10px;
    margin-bottom: 2rem;
}

.title-description p {
    margin: 0.5rem 0;
    color: var(--text-secondary);
}

/* ========================================
   ボタンスタイル - ドット絵風
   ======================================== */
.pixel-button {
    background: linear-gradient(180deg, #fbbf24 0%, #f59e0b 100%);
    color: #000;
    border: 3px solid #fff;
    padding: 15px 30px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    border-radius: 10px;
    box-shadow: var(--shadow-button);
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.pixel-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.4);
    background: linear-gradient(180deg, #fcd34d 0%, #fbbf24 100%);
}

.pixel-button:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: var(--shadow-button);
}

.pixel-button:disabled {
    background: #4b5563;
    cursor: not-allowed;
    opacity: 0.5;
}

.pixel-button.primary {
    background: linear-gradient(180deg, #10b981 0%, #059669 100%);
    color: #fff;
}

.pixel-button.secondary {
    background: linear-gradient(180deg, #60a5fa 0%, #3b82f6 100%);
    color: #fff;
    font-size: 0.9rem;
    padding: 10px 20px;
}

.pixel-button.large {
    font-size: 1.5rem;
    padding: 20px 50px;
}

/* ========================================
   ゲーム画面 - レイアウト
   ======================================== */
#game-screen {
    height: 100vh;
}

.game-header {
    background: var(--bg-secondary);
    border-bottom: 3px solid var(--border-main);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.stage-info, .score-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.2rem;
}

.stage-label, .score-label {
    color: var(--text-secondary);
}

.stage-number, .score-number {
    color: var(--accent-gold);
    font-weight: bold;
    font-size: 1.5rem;
}

.game-main {
    display: grid;
    grid-template-columns: 300px 1fr 350px;
    gap: 1rem;
    padding: 1rem;
    height: calc(100vh - 80px);
    overflow: hidden;
}

/* ========================================
   パネル共通スタイル
   ======================================== */
.folder-panel, .content-panel, .preview-panel {
    background: var(--bg-panel);
    border: 3px solid var(--border-main);
    border-radius: 15px;
    box-shadow: var(--shadow-panel);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.panel-header {
    background: linear-gradient(180deg, #1f2937 0%, #111827 100%);
    border-bottom: 2px solid var(--border-main);
    padding: 1rem;
}

.panel-header h2 {
    font-size: 1.2rem;
    color: var(--accent-gold);
    text-align: center;
}

/* ========================================
   左パネル - フォルダツリー
   ======================================== */
.folder-tree {
    padding: 1rem;
    overflow-y: auto;
    flex: 1;
}

.tree-node {
    margin: 0.5rem 0;
}

.tree-item {
    display: flex;
    align-items: center;
    padding: 0.7rem;
    margin: 0.3rem 0;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.tree-item:hover {
    background: rgba(251, 191, 36, 0.2);
    border-color: var(--accent-gold);
    transform: translateX(5px);
}

.tree-item.active {
    background: linear-gradient(90deg, rgba(251, 191, 36, 0.3) 0%, transparent 100%);
    border-color: var(--accent-gold);
}

.tree-item.file {
    cursor: default;
    opacity: 0.7;
}

.tree-item.file:hover {
    transform: none;
    border-color: transparent;
}

.tree-children {
    margin-left: 1.5rem;
    border-left: 2px solid rgba(251, 191, 36, 0.3);
    padding-left: 0.5rem;
}

/* ========================================
   中央パネル - コンテンツエリア
   ======================================== */
.content-panel {
    overflow-y: auto;
    padding: 1rem;
}

.breadcrumb-container {
    background: rgba(0, 0, 0, 0.3);
    padding: 1rem;
    border-radius: 10px;
    margin-bottom: 1rem;
    border: 2px solid var(--accent-blue);
}

.breadcrumb-label {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.breadcrumb {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    font-family: 'Courier New', monospace;
    font-size: 1.1rem;
    color: var(--accent-gold);
}

.breadcrumb-item {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.breadcrumb-separator {
    color: var(--text-secondary);
}

/* キャラクター表示 */
.character-area {
    text-align: center;
    padding: 2rem;
    position: relative;
}

.character {
    font-size: 4rem;
    display: inline-block;
    animation: characterIdle 2s ease-in-out infinite;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.5));
}

@keyframes characterIdle {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.character.moving {
    animation: characterMove 0.5s ease;
}

@keyframes characterMove {
    0% { transform: translateX(0) scale(1); }
    50% { transform: translateX(20px) scale(1.1); }
    100% { transform: translateX(0) scale(1); }
}

/* フォルダ内容 */
.folder-contents {
    background: rgba(0, 0, 0, 0.3);
    padding: 1rem;
    border-radius: 10px;
    margin-bottom: 1rem;
}

.folder-contents h3 {
    color: var(--accent-gold);
    margin-bottom: 0.5rem;
}

.contents-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.content-item {
    background: rgba(255, 255, 255, 0.1);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.content-item.folder {
    border-color: var(--accent-blue);
}

.content-item.file {
    border-color: var(--accent-green);
}

/* パス入力エリア */
.path-input-area {
    background: rgba(0, 0, 0, 0.5);
    padding: 1.5rem;
    border-radius: 10px;
    border: 3px solid var(--accent-gold);
}

.path-input-area h3 {
    color: var(--accent-gold);
    margin-bottom: 0.5rem;
}

.quest-text {
    color: var(--text-secondary);
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.code-display {
    background: #1a1a1a;
    padding: 1rem;
    border-radius: 8px;
    border: 2px solid #333;
    font-family: 'Courier New', monospace;
    font-size: 1.1rem;
}

.code-display code {
    color: #a5d6ff;
}

.path-highlight {
    color: var(--accent-gold);
    background: rgba(251, 191, 36, 0.2);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-weight: bold;
}

/* ========================================
   右パネル - プレビューとコントロール
   ======================================== */
.preview-panel {
    padding: 0;
}

.preview-area {
    flex: 1;
    padding: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.3);
    margin: 1rem;
    border-radius: 10px;
    border: 2px dashed var(--text-secondary);
    min-height: 200px;
}

.preview-placeholder {
    color: var(--text-secondary);
    text-align: center;
    font-style: italic;
}

.preview-image {
    max-width: 100%;
    max-height: 100%;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    animation: imageAppear 0.5s ease;
}

@keyframes imageAppear {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ヒントボックス */
.hint-box {
    background: rgba(59, 130, 246, 0.1);
    border: 2px solid var(--accent-blue);
    margin: 1rem;
    padding: 1rem;
    border-radius: 10px;
}

.hint-box h3 {
    color: var(--accent-blue);
    margin-bottom: 0.5rem;
}

.hint-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
}

/* アクションボタン */
.action-buttons {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* ========================================
   ステージクリア画面
   ======================================== */
#clear-screen {
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #065f46 0%, #047857 100%);
}

.clear-container {
    text-align: center;
    padding: 3rem;
    background: rgba(0, 0, 0, 0.7);
    border: 4px solid var(--accent-gold);
    border-radius: 20px;
    box-shadow: var(--shadow-panel);
    max-width: 600px;
    animation: popIn 0.5s ease;
}

@keyframes popIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.clear-title {
    font-size: 3rem;
    color: var(--accent-gold);
    margin-bottom: 1rem;
    animation: clearPulse 1s ease-in-out infinite;
}

@keyframes clearPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.clear-stats {
    background: rgba(255, 255, 255, 0.1);
    padding: 1.5rem;
    border-radius: 10px;
    margin-bottom: 2rem;
}

.clear-message {
    font-size: 1.2rem;
    margin-bottom: 1rem;
}

.earned-points {
    font-size: 1.5rem;
}

.points-label {
    color: var(--text-secondary);
}

.points-number {
    color: var(--accent-gold);
    font-weight: bold;
    font-size: 2rem;
}

.learning-summary {
    background: rgba(59, 130, 246, 0.2);
    border: 2px solid var(--accent-blue);
    padding: 1.5rem;
    border-radius: 10px;
    margin-bottom: 2rem;
    text-align: left;
}

.learning-summary h3 {
    color: var(--accent-blue);
    text-align: center;
    margin-bottom: 1rem;
}

.learning-text {
    color: var(--text-primary);
    line-height: 1.8;
}

/* ========================================
   完了画面
   ======================================== */
#complete-screen {
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #7c2d12 0%, #991b1b 100%);
}

.complete-container {
    text-align: center;
    padding: 3rem;
    background: rgba(0, 0, 0, 0.8);
    border: 5px solid var(--accent-gold);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
    max-width: 700px;
}

.complete-title {
    font-size: 3.5rem;
    color: var(--accent-gold);
    margin-bottom: 1rem;
    text-shadow: 3px 3px 0 #000;
}

.complete-message {
    font-size: 1.3rem;
    margin-bottom: 2rem;
}

.final-score {
    background: rgba(251, 191, 36, 0.2);
    border: 3px solid var(--accent-gold);
    padding: 1.5rem;
    border-radius: 10px;
    margin-bottom: 2rem;
}

.final-score-label {
    font-size: 1.2rem;
    color: var(--text-secondary);
    display: block;
    margin-bottom: 0.5rem;
}

.final-score-number {
    font-size: 3rem;
    color: var(--accent-gold);
    font-weight: bold;
}

.achievement-summary {
    background: rgba(255, 255, 255, 0.1);
    padding: 2rem;
    border-radius: 10px;
    margin-bottom: 2rem;
    text-align: left;
}

.achievement-summary h3 {
    color: var(--accent-gold);
    text-align: center;
    margin-bottom: 1rem;
}

.achievement-list {
    list-style: none;
    padding: 0;
}

.achievement-list li {
    padding: 0.7rem;
    margin: 0.5rem 0;
    background: rgba(16, 185, 129, 0.2);
    border-left: 4px solid var(--accent-green);
    border-radius: 5px;
    font-size: 1.1rem;
}

/* ========================================
   通知バナー
   ======================================== */
.notification {
    position: fixed;
    top: -100px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(180deg, #10b981 0%, #059669 100%);
    color: #fff;
    padding: 1rem 2rem;
    border-radius: 10px;
    border: 3px solid #fff;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
    font-size: 1.2rem;
    font-weight: bold;
    z-index: 1000;
    transition: top 0.5s ease;
}

.notification.show {
    top: 20px;
}

.notification.error {
    background: linear-gradient(180deg, #ef4444 0%, #dc2626 100%);
}

/* ========================================
   レスポンシブ対応
   ======================================== */
@media (max-width: 1200px) {
    .game-main {
        grid-template-columns: 250px 1fr 300px;
    }
}

@media (max-width: 900px) {
    .game-main {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto 1fr;
        height: auto;
    }

    .folder-panel, .preview-panel {
        height: 300px;
    }
}

/* ========================================
   スクロールバーカスタマイズ
   ======================================== */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb {
    background: var(--accent-gold);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: #fcd34d;
}

/* ========================================
   チュートリアル画面
   ======================================== */
#tutorial-screen {
    justify-content: center;
    align-items: center;
    padding: 2rem;
}

.tutorial-container {
    background: rgba(0, 0, 0, 0.8);
    border: 4px solid var(--border-main);
    border-radius: 20px;
    padding: 3rem;
    max-width: 900px;
    width: 100%;
    box-shadow: var(--shadow-panel);
}

.tutorial-title {
    text-align: center;
    color: var(--accent-gold);
    font-size: 2.5rem;
    margin-bottom: 2rem;
}

.tutorial-content {
    min-height: 400px;
}

.tutorial-step {
    animation: fadeIn 0.5s ease;
}

.tutorial-step h2 {
    color: var(--accent-gold);
    font-size: 2rem;
    margin-bottom: 1.5rem;
    text-align: center;
}

.tutorial-text {
    color: var(--text-primary);
    line-height: 1.8;
}

.tutorial-text h3 {
    color: var(--accent-blue);
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.tutorial-text p {
    margin: 1rem 0;
    font-size: 1.1rem;
}

.example-box,
.folder-structure-example,
.path-pattern,
.comparison-box,
.summary-box {
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid var(--accent-blue);
    border-radius: 10px;
    padding: 1.5rem;
    margin: 1.5rem 0;
}

.path-pattern {
    border-color: var(--accent-green);
}

.path-pattern h4 {
    color: var(--accent-green);
    margin-bottom: 0.5rem;
}

.path-pattern code {
    background: #1a1a1a;
    padding: 0.5rem 1rem;
    border-radius: 5px;
    display: inline-block;
    margin: 0.5rem 0;
    color: var(--accent-gold);
    font-size: 1.2rem;
}

.path-pattern p {
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

.folder-structure-example pre {
    background: #1a1a1a;
    padding: 1rem;
    border-radius: 5px;
    color: var(--text-primary);
    font-size: 1rem;
    line-height: 1.6;
}

.comparison-box table {
    margin-top: 1rem;
    border-collapse: collapse;
}

.comparison-box th,
.comparison-box td {
    padding: 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.comparison-box th {
    background: rgba(251, 191, 36, 0.2);
    color: var(--accent-gold);
}

.summary-box h4 {
    color: var(--accent-gold);
    margin-bottom: 1rem;
}

.summary-box ul {
    list-style: none;
    padding: 0;
}

.summary-box li {
    padding: 0.5rem;
    margin: 0.5rem 0;
    background: rgba(16, 185, 129, 0.1);
    border-left: 3px solid var(--accent-green);
    border-radius: 5px;
}

.summary-box code {
    background: #1a1a1a;
    padding: 0.2rem 0.5rem;
    border-radius: 3px;
    color: var(--accent-gold);
}

.tutorial-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 3rem;
    gap: 1rem;
}

.tutorial-page {
    font-size: 1.2rem;
    color: var(--text-secondary);
    min-width: 80px;
    text-align: center;
}

/* ========================================
   新しい問題エリアスタイル
   ======================================== */
.question-area {
    background: rgba(239, 68, 68, 0.1);
    border: 3px solid var(--accent-red);
    border-radius: 15px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.question-header h2 {
    color: var(--accent-red);
    font-size: 1.5rem;
    margin-bottom: 1rem;
    text-align: center;
}

.question-content {
    background: rgba(0, 0, 0, 0.3);
    padding: 1.5rem;
    border-radius: 10px;
}

.quest-details {
    margin-top: 1.5rem;
}

.quest-item {
    margin: 1rem 0;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}

.quest-label {
    display: block;
    color: var(--accent-gold);
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.target-file {
    color: var(--accent-green);
    font-family: 'Courier New', monospace;
    font-size: 1.2rem;
    font-weight: bold;
}

/* ========================================
   答え入力エリアスタイル
   ======================================== */
.answer-area {
    background: rgba(16, 185, 129, 0.1);
    border: 3px solid var(--accent-green);
    border-radius: 15px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.answer-header h2 {
    color: var(--accent-green);
    font-size: 1.5rem;
    margin-bottom: 1rem;
    text-align: center;
}

.answer-content {
    background: rgba(0, 0, 0, 0.3);
    padding: 1.5rem;
    border-radius: 10px;
}

.path-input {
    background: rgba(251, 191, 36, 0.2);
    border: 2px solid var(--accent-gold);
    color: var(--accent-gold);
    font-family: 'Courier New', monospace;
    font-size: 1.2rem;
    padding: 0.5rem 1rem;
    border-radius: 5px;
    outline: none;
    width: 300px;
    font-weight: bold;
}

.path-input:focus {
    background: rgba(251, 191, 36, 0.3);
    border-color: #fcd34d;
    box-shadow: 0 0 10px rgba(251, 191, 36, 0.5);
}

.path-input::placeholder {
    color: rgba(251, 191, 36, 0.5);
}

.input-examples {
    margin-top: 1.5rem;
    padding: 1rem;
    background: rgba(59, 130, 246, 0.1);
    border: 2px solid var(--accent-blue);
    border-radius: 8px;
}

.input-hint-label {
    color: var(--accent-blue);
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.input-examples-list {
    list-style: none;
    padding: 0;
    margin: 0.5rem 0;
}

.input-examples-list li {
    padding: 0.5rem;
    margin: 0.3rem 0;
    color: var(--text-secondary);
}

.input-examples-list code {
    background: #1a1a1a;
    padding: 0.2rem 0.5rem;
    border-radius: 3px;
    color: var(--accent-gold);
    margin-right: 0.5rem;
}

.answer-content .pixel-button {
    width: 100%;
    margin-top: 1.5rem;
}

/* ========================================
   ビジュアルエリア
   ======================================== */
.visual-area {
    background: rgba(59, 130, 246, 0.1);
    border: 2px solid var(--accent-blue);
    border-radius: 10px;
    padding: 1rem;
}

.visual-area h3 {
    color: var(--accent-blue);
    text-align: center;
    margin-bottom: 1rem;
}

.character-location {
    color: var(--text-secondary);
    margin-top: 0.5rem;
    font-size: 0.9rem;
}
