/* RL Dungeon - Styles */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-tertiary: #0f3460;
    --accent: #e94560;
    --text-primary: #eee;
    --text-secondary: #aaa;
    --success: #4ade80;
    --warning: #fbbf24;
    --danger: #ef4444;
    --heal: #f472b6;
}

body {
    font-family: 'Segoe UI', system-ui, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 30px;
}

header h1 {
    font-size: 2.5rem;
    color: var(--accent);
    text-shadow: 0 0 20px rgba(233, 69, 96, 0.5);
}

.subtitle {
    color: var(--text-secondary);
    margin-top: 5px;
}

/* Main Layout */
main {
    display: flex;
    gap: 30px;
    flex-wrap: wrap;
    justify-content: center;
}

/* Game Area */
.game-area {
    position: relative;
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

#game-canvas {
    display: block;
    background: #000;
    border-radius: 8px;
}

/* Game UI */
.game-ui {
    margin-top: 15px;
}

.stats {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    align-items: center;
}

.stat {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* B-204: mobile-only toggle for extra stats (Run / Reward / Clear Rate).
   Desktop: button hidden, all stats shown. Mobile: only core stats
   (HP / Gold / Steps / Food) shown by default; button reveals the rest.
   W6 (2026-05-17): Food 가 extra → core 격상 (사용자 보고 "식량이 안 보임"). */
.stats-toggle {
    display: none;
    padding: 4px 10px;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.85rem;
    cursor: pointer;
}
.stats-toggle:hover { color: var(--text-primary); }

.stat-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    min-width: 50px;
}

.stat-value {
    font-weight: bold;
    font-family: monospace;
    font-size: 1.1rem;
}

/* HP Bar */
.hp-bar {
    width: 100px;
    height: 12px;
    background: var(--bg-primary);
    border-radius: 6px;
    overflow: hidden;
}

.hp-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, var(--danger), var(--success));
    transition: width 0.3s ease;
}

/* Message */
.message {
    margin-top: 10px;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border-radius: 6px;
    font-size: 0.95rem;
    min-height: 36px;
    display: flex;
    align-items: center;
}

.message.success {
    background: rgba(74, 222, 128, 0.2);
    color: var(--success);
}

.message.danger {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
}

.message.warning {
    background: rgba(251, 191, 36, 0.2);
    color: var(--warning);
}

/* Controls Panel */
.controls {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 20px;
    min-width: 200px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.control-section {
    margin-bottom: 20px;
}

.control-section:last-child {
    margin-bottom: 0;
}

.control-section h3 {
    color: var(--accent);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
}

/* Select & Button */
select, button {
    width: 100%;
    padding: 10px 12px;
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    cursor: pointer;
    margin-bottom: 8px;
}

select {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

select option:disabled {
    color: #666;
    font-style: italic;
}

select option {
    padding: 8px;
}

button {
    background: var(--accent);
    color: white;
    font-weight: bold;
    transition: transform 0.1s, box-shadow 0.1s;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(233, 69, 96, 0.4);
}

button:active {
    transform: translateY(0);
}

.btn-train {
    background: #3b82f6;
}

.btn-train:hover {
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-secondary:hover:not(:disabled) {
    background: #1e3a5f;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.btn-secondary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Training Progress */
.train-progress {
    margin-top: 10px;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--bg-primary);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #3b82f6, #22c55e);
    transition: width 0.2s;
}

.progress-text {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 4px;
    text-align: center;
}

.train-stats {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 8px;
    line-height: 1.5;
}

/* Checkbox */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 6px 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.checkbox-label:hover {
    color: var(--text-primary);
}

/* Key Hints */
.key-hints {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.key {
    display: inline-block;
    background: var(--bg-tertiary);
    padding: 4px 8px;
    border-radius: 4px;
    font-family: monospace;
    margin-right: 5px;
}

/* Legend */
.legend {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.tile-preview {
    width: 20px;
    height: 20px;
    border-radius: 4px;
}

.tile-preview.start { background: #3b82f6; }
.tile-preview.goal { background: #22c55e; }
.tile-preview.trap { background: #ef4444; }
.tile-preview.heal { background: #f472b6; }
.tile-preview.pit { background: #18181b; border: 1px solid #333; }
.tile-preview.gold { background: #fbbf24; }
.tile-preview.monster { background: #9333ea; }
.tile-preview.wall { background: #374151; }

/* Character Grid */
.character-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
}

.char-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 6px 4px;
    font-size: 0.75rem;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    margin-bottom: 0;
    border: 2px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    min-height: 44px;
}

.char-card .char-name {
    font-weight: bold;
    font-size: 0.8rem;
    line-height: 1.2;
}

.char-card .char-algo {
    font-size: 0.65rem;
    opacity: 0.7;
    margin-top: 1px;
}

.char-card.active {
    background: var(--accent);
    color: white;
    border-color: #ff6b81;
}

.char-card.active .char-algo {
    opacity: 0.9;
}

.char-card:hover {
    transform: none;
    box-shadow: none;
    background: #1e3a5f;
    color: var(--text-primary);
}

.char-card.active:hover {
    background: #d63851;
}

.character-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 8px;
    line-height: 1.4;
    font-style: italic;
}

/* Gold display */
.gold-value {
    color: #fbbf24 !important;
    text-shadow: 0 0 8px rgba(251, 191, 36, 0.5);
}

/* Footer */
footer {
    text-align: center;
    margin-top: 30px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Speed Buttons */
.speed-buttons {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.speed-label {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-right: 4px;
}

.btn-speed {
    width: auto;
    padding: 5px 10px;
    font-size: 0.8rem;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    margin-bottom: 0;
    border: 1px solid transparent;
}

.btn-speed.active {
    background: #3b82f6;
    color: white;
    border-color: #60a5fa;
}

.btn-speed:hover {
    transform: none;
    box-shadow: none;
    background: #1e3a5f;
    color: var(--text-primary);
}

.btn-speed.active:hover {
    background: #2563eb;
}

/* Train Mode Select */
.train-mode-select {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 8px;
}

.train-mode-select select {
    flex: 1;
    margin-bottom: 0;
    padding: 5px 8px;
    font-size: 0.85rem;
}

/* Train Buttons */
.train-buttons {
    display: flex;
    gap: 6px;
}

.train-buttons button {
    flex: 1;
    margin-bottom: 0;
}

.btn-stop {
    background: #dc2626;
    color: white;
    font-weight: bold;
}

.btn-stop:hover:not(:disabled) {
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.4);
}

.btn-stop:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* D-Pad */
.dpad-container {
    display: none;
    justify-content: center;
    margin-top: 12px;
}

.dpad {
    display: grid;
    grid-template-columns: 50px 50px 50px;
    grid-template-rows: 50px 50px 50px;
    gap: 4px;
}

.dpad-btn {
    width: 50px;
    height: 50px;
    padding: 0;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid #334155;
    border-radius: 8px;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

.dpad-btn:hover {
    transform: none;
    box-shadow: none;
}

.dpad-btn:active {
    background: var(--accent);
    transform: scale(0.95);
}

.dpad-center {
    background: transparent;
    border: none;
    cursor: default;
}

.dpad-center:active {
    background: transparent;
    transform: none;
}

.dpad-up    { grid-column: 2; grid-row: 1; }
.dpad-left  { grid-column: 1; grid-row: 2; }
.dpad-center{ grid-column: 2; grid-row: 2; }
.dpad-right { grid-column: 3; grid-row: 2; }
.dpad-down  { grid-column: 2; grid-row: 3; }

/* Responsive */
@media (max-width: 700px) {
    main {
        flex-direction: column;
        align-items: center;
    }

    .controls {
        width: 100%;
        max-width: 400px;
    }

    .dpad-container {
        display: flex;
    }

    /* B-204: collapse extra stats by default on mobile */
    .stats:not(.expanded) .stat[data-priority="extra"] { display: none; }
    .stats-toggle { display: inline-block; }

    /* B-201: fit canvas to viewport. min-width:0 unlocks flex shrink past
       canvas intrinsic width; box-sizing keeps padding inside max-width. */
    .game-area {
        max-width: 100%;
        min-width: 0;
        box-sizing: border-box;
    }
    #game-canvas {
        max-width: 100%;
        height: auto;
    }

    /* B-201: minimap revealed when JS marks the wrap active (large dungeons) */
    .minimap-wrap[data-active="true"] { display: inline-flex; }

    /* B-202: mobile bottom tab bar (fixed) + body bottom padding so it doesn't
       cover content (incl. minimap which sits right under the canvas). */
    .bottom-tabs { display: flex; }
    body { padding-bottom: 60px; }
}

/* B-202: bottom tab bar default state (hidden on desktop, revealed in mobile
   media query). Fixed to viewport bottom. */
.bottom-tabs {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    padding: 6px;
    gap: 4px;
    background: var(--bg-secondary, #1a1a1a);
    border-top: 1px solid var(--border-color, #333);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3);
}
.bottom-tab {
    flex: 1;
    padding: 10px 4px;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid transparent;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
}
.bottom-tab:hover, .bottom-tab.active {
    color: var(--text-primary);
    border-color: var(--border-color, #333);
    background: var(--bg-tertiary, #222);
}

/* B-201: minimap default state (hidden on desktop and small dungeons) */
.minimap-wrap {
    display: none;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    padding: 6px 10px;
    background: var(--bg-tertiary, #1a1a1a);
    border-radius: 6px;
}
.minimap-label {
    color: var(--text-secondary);
    font-size: 0.85rem;
}
#minimap-canvas {
    display: block;
    background: #000;
    border-radius: 4px;
    image-rendering: pixelated;
}

/* Also show D-pad on touch devices */
@media (pointer: coarse) {
    .dpad-container {
        display: flex;
    }
}

/* ========== Mode Tabs ========== */
.mode-tabs {
    display: flex;
    justify-content: center;
    gap: 0;
    margin-bottom: 20px;
}

.mode-tab {
    width: auto;
    padding: 10px 32px;
    font-size: 1rem;
    font-weight: bold;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 2px solid #334155;
    margin-bottom: 0;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.mode-tab:first-child {
    border-radius: 8px 0 0 8px;
    border-right: 1px solid #334155;
}

.mode-tab:last-child {
    border-radius: 0 8px 8px 0;
    border-left: 1px solid #334155;
}

.mode-tab.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.mode-tab:hover {
    transform: none;
    box-shadow: none;
    background: #1e3a5f;
    color: var(--text-primary);
}

.mode-tab.active:hover {
    background: #d63851;
}

/* ========== Editor Mode Toggle ========== */
body.editor-mode .game-ui,
body.editor-mode .dpad-container {
    display: none !important;
}

/* ========== Editor Controls ========== */
.editor-controls .control-section {
    margin-bottom: 16px;
}

/* Grid Size */
.size-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.size-label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.size-input {
    width: 54px;
    padding: 5px 6px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid #334155;
    border-radius: 4px;
    font-size: 0.9rem;
    text-align: center;
}

.size-input:focus {
    outline: none;
    border-color: var(--accent);
}

/* Tile Palette */
.tile-palette {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 4px;
}

.palette-tile {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    background: var(--bg-tertiary);
    border: 2px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.72rem;
    color: var(--text-secondary);
    margin-bottom: 0;
    min-height: 36px;
    transition: border-color 0.15s, background 0.15s;
}

.palette-tile:hover {
    transform: none;
    box-shadow: none;
    background: #1e3a5f;
    color: var(--text-primary);
}

.palette-tile.active {
    border-color: var(--accent);
    background: rgba(233, 69, 96, 0.15);
    color: var(--text-primary);
}

.palette-color {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    flex-shrink: 0;
}

.palette-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Tool Buttons */
.tool-buttons {
    display: flex;
    gap: 4px;
}

.btn-tool {
    flex: 1;
    padding: 7px 6px;
    font-size: 0.8rem;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    margin-bottom: 0;
    border: 1px solid transparent;
}

.btn-tool.active {
    background: #3b82f6;
    color: white;
    border-color: #60a5fa;
}

.btn-tool:hover {
    transform: none;
    box-shadow: none;
    background: #1e3a5f;
    color: var(--text-primary);
}

.btn-tool.active:hover {
    background: #2563eb;
}

/* Action Buttons */
.action-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
}

.btn-small {
    width: auto;
    padding: 6px 10px;
    font-size: 0.8rem;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    margin-bottom: 0;
    border: 1px solid #334155;
}

.btn-small:hover {
    transform: none;
    box-shadow: none;
    background: #1e3a5f;
    color: var(--text-primary);
}

.btn-validate {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
}

.btn-validate:hover {
    background: #2563eb;
}

/* Save / Load */
.save-controls {
    display: flex;
    gap: 4px;
    margin-bottom: 8px;
}

.dungeon-name-input {
    flex: 1;
    padding: 6px 8px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid #334155;
    border-radius: 4px;
    font-size: 0.85rem;
}

.dungeon-name-input:focus {
    outline: none;
    border-color: var(--accent);
}

.btn-save {
    background: var(--success);
    color: #000;
    border-color: var(--success);
    font-weight: bold;
}

.btn-save:hover {
    background: #22b060;
    box-shadow: none;
    transform: none;
}

.load-controls select {
    margin-bottom: 6px;
}

.load-buttons {
    display: flex;
    gap: 4px;
}

.load-buttons button {
    flex: 1;
}

.btn-danger-small {
    background: var(--danger) !important;
    color: white !important;
    border-color: var(--danger) !important;
}

.btn-danger-small:hover {
    background: #dc2626 !important;
    transform: none;
    box-shadow: none;
}

/* Play Dungeon Button */
.btn-play-dungeon {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: white;
    font-weight: bold;
    font-size: 1rem;
    padding: 12px;
    border: none;
    border-radius: 8px;
    width: 100%;
    letter-spacing: 0.5px;
}

.btn-play-dungeon:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(34, 197, 94, 0.4);
}

/* Editor Message */
.editor-message {
    min-height: 20px;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.85rem;
    line-height: 1.4;
}

.editor-message.success {
    background: rgba(74, 222, 128, 0.15);
    color: var(--success);
}

.editor-message.danger {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}

.editor-message.warning {
    background: rgba(251, 191, 36, 0.15);
    color: var(--warning);
}

.editor-message.info {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
}

/* Quick Test */
.quick-test-char-select, .quick-test-episodes { display: flex; align-items: center; gap: 4px; margin-bottom: 8px; }
.quick-test-char-select select, .quick-test-episodes select { flex: 1; margin-bottom: 0; padding: 5px 8px; font-size: 0.85rem; }
.quick-test-buttons { display: flex; gap: 6px; }
.quick-test-buttons button { flex: 1; margin-bottom: 0; }
.quick-test-progress { margin-top: 8px; }
.quick-test-results { font-size: 0.85rem; margin-top: 8px; line-height: 1.4; }
.quick-test-results.success { color: var(--success); }
.quick-test-results.warning { color: var(--warning); }
.quick-test-results.danger { color: var(--danger); }

/* ========== Editor Sub-tabs ========== */
.editor-subtabs {
    display: flex;
    gap: 0;
    margin-bottom: 12px;
}

.editor-subtab {
    flex: 1;
    padding: 7px 0;
    font-size: 0.85rem;
    font-weight: bold;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid #334155;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    margin-bottom: 0;
}

.editor-subtab:first-child {
    border-radius: 6px 0 0 6px;
    border-right: none;
}

.editor-subtab:last-child {
    border-radius: 0 6px 6px 0;
}

.editor-subtab.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.editor-subtab:hover {
    transform: none;
    box-shadow: none;
    background: #1e3a5f;
    color: var(--text-primary);
}

.editor-subtab.active:hover {
    background: #d63851;
}

/* ========== Dungeon Composer ========== */
.dungeon-floor-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 8px;
}

.floor-slot {
    background: var(--bg-tertiary);
    border: 1px solid #334155;
    border-radius: 6px;
    padding: 8px;
    cursor: pointer;
    transition: border-color 0.15s;
}

.floor-slot:hover {
    border-color: #4a6380;
}

.floor-slot.selected {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
}

.floor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.floor-label {
    font-size: 0.8rem;
    font-weight: bold;
    color: var(--text-secondary);
}

.btn-remove-floor {
    background: none;
    border: none;
    color: var(--danger);
    font-size: 1rem;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    opacity: 0.6;
}

.btn-remove-floor:hover {
    opacity: 1;
    transform: none;
    box-shadow: none;
}

.floor-stage-select {
    width: 100%;
    padding: 4px 6px;
    font-size: 0.8rem;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid #334155;
    border-radius: 4px;
}

.btn-add-floor {
    width: 100%;
    padding: 6px;
    font-size: 0.8rem;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px dashed #4a6380;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.btn-add-floor:hover {
    background: #1e3a5f;
    color: var(--text-primary);
    border-color: var(--accent);
    transform: none;
    box-shadow: none;
}

/* Variant system */
.floor-variant-row {
    display: flex;
    gap: 4px;
    align-items: center;
    margin-top: 4px;
}
.floor-variant-row .floor-stage-select {
    flex: 1;
}
.btn-remove-variant {
    width: 24px;
    height: 24px;
    padding: 0;
    font-size: 0.9rem;
    line-height: 1;
    background: transparent;
    color: #ef4444;
    border: 1px solid #ef4444;
    border-radius: 4px;
    cursor: pointer;
    flex-shrink: 0;
}
.btn-remove-variant:hover {
    background: rgba(239, 68, 68, 0.2);
    transform: none;
    box-shadow: none;
}
.btn-add-variant {
    width: 100%;
    padding: 3px;
    font-size: 0.7rem;
    background: transparent;
    color: #a78bfa;
    border: 1px dashed #a78bfa;
    border-radius: 4px;
    cursor: pointer;
    margin-top: 4px;
}
.btn-add-variant:hover {
    background: rgba(167, 139, 250, 0.1);
    transform: none;
    box-shadow: none;
}
.variant-badge {
    font-size: 0.65rem;
    background: #a78bfa;
    color: #1a1a2e;
    padding: 1px 5px;
    border-radius: 8px;
    margin-left: 4px;
    font-weight: bold;
}

.dungeon-floor-empty {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.8rem;
    padding: 12px;
    opacity: 0.6;
}

/* ========== Roguelike: Game Over Overlay ========== */
.game-over-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    border-radius: 12px;
}

.game-over-box {
    text-align: center;
    padding: 30px 40px;
    max-width: 360px;
}

.game-over-title {
    font-size: 2.2rem;
    font-weight: bold;
    color: var(--danger);
    text-shadow: 0 0 20px rgba(239, 68, 68, 0.6);
    margin-bottom: 16px;
}

.game-over-cause {
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.game-over-stats {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 16px;
}

.game-over-note {
    font-size: 0.75rem;
    color: var(--text-secondary);
    opacity: 0.7;
    font-style: italic;
    margin-bottom: 20px;
}

.btn-new-run {
    background: var(--accent);
    color: white;
    font-weight: bold;
    font-size: 1.1rem;
    padding: 12px 32px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    width: auto;
}

.btn-new-run:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(233, 69, 96, 0.5);
}

/* ========== Roguelike: Character Lock/Hidden ========== */
.char-card.locked {
    opacity: 0.45;
    position: relative;
}

.char-card.locked .char-name::before {
    content: '\1F512 ';
    font-size: 0.7rem;
}

.char-card.locked:hover {
    opacity: 0.7;
    background: #1e3a5f;
}

.char-card.char-hidden {
    display: none;
}

/* ========== Roguelike: Food & Run Display ========== */
.food-value {
    color: #a3e635 !important;
    text-shadow: 0 0 8px rgba(163, 230, 53, 0.4);
    transition: color 0.3s ease;
}

/* F2: 식량 임계 색 (사용자 보고: 줄어든 거가 눈에 안 띈다) */
.food-value.food-low {
    color: #facc15 !important;
    text-shadow: 0 0 10px rgba(250, 204, 21, 0.5);
}
.food-value.food-critical {
    color: #ef4444 !important;
    text-shadow: 0 0 12px rgba(239, 68, 68, 0.7);
    animation: food-pulse 1.2s ease-in-out infinite;
}
@keyframes food-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* F1: 식량 변화 floating "-2" (매 스텝 가시화) */
#food-stat { position: relative; }
.food-delta {
    position: absolute;
    right: 8px;
    top: 0;
    pointer-events: none;
    font-weight: 700;
    font-size: 0.95rem;
    animation: food-delta-float 1s ease-out forwards;
}
.food-delta-down { color: #ef4444; }
.food-delta-up { color: #a3e635; }
@keyframes food-delta-float {
    0%   { opacity: 0; transform: translateY(0); }
    20%  { opacity: 1; }
    100% { opacity: 0; transform: translateY(-24px); }
}

.run-value {
    color: #c084fc !important;
    text-shadow: 0 0 8px rgba(192, 132, 252, 0.3);
}

/* ========== Roguelike: Provisions ========== */
.provisions-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.provisions-controls .size-input {
    width: 60px;
}

.provisions-cost {
    font-size: 0.8rem;
    color: var(--warning);
    min-width: 40px;
}

.btn-buy-food {
    background: #65a30d !important;
    color: white !important;
    border-color: #65a30d !important;
    font-weight: bold;
}

.btn-buy-food:hover {
    background: #4d7c0f !important;
    transform: none;
    box-shadow: none;
}

.provisions-info {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 6px;
    line-height: 1.4;
}

/* ========== B-5: Map Choice Overlay ========== */
.map-choice-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.88);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    border-radius: 12px;
}

.map-choice-box {
    text-align: center;
    padding: 28px 36px;
    max-width: 380px;
}

.map-choice-title {
    font-size: 2rem;
    font-weight: bold;
    color: var(--success);
    text-shadow: 0 0 20px rgba(74, 222, 128, 0.6);
    margin-bottom: 12px;
}

.map-choice-dungeon {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.map-choice-details {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 18px;
}

.map-unlock-msg {
    color: #a78bfa;
    font-weight: bold;
    margin-bottom: 6px;
}

.map-choice-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.btn-sell-map {
    background: var(--warning);
    color: #000;
    font-weight: bold;
    font-size: 1rem;
    padding: 10px 24px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    width: auto;
}

.btn-sell-map:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(251, 191, 36, 0.5);
}

.btn-keep-map {
    background: #3b82f6;
    color: white;
    font-weight: bold;
    font-size: 1rem;
    padding: 10px 24px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    width: auto;
}

.btn-keep-map:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.5);
}

/* ========== B-3: Serpa Stats ========== */
.stats-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    font-size: 0.78rem;
    flex-wrap: wrap;
}

.stat-char-name {
    font-weight: bold;
    color: var(--text-primary);
    min-width: 80px;
}

.stat-char-details {
    color: var(--text-secondary);
    flex: 1;
}

.stat-max {
    color: var(--success);
    font-weight: bold;
    font-size: 0.7rem;
}

.farming-tag {
    color: #a3e635;
    font-size: 0.7rem;
}

.btn-upgrade {
    background: #7c3aed !important;
    color: white !important;
    border-color: #7c3aed !important;
    font-weight: bold;
    font-size: 0.7rem;
    padding: 3px 8px;
}

.btn-upgrade:hover:not(:disabled) {
    background: #6d28d9 !important;
    transform: none;
    box-shadow: none;
}

.btn-upgrade:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

/* ========== B-4: Farming ========== */
.farming-empty {
    font-size: 0.8rem;
    color: var(--text-secondary);
    opacity: 0.6;
    padding: 4px;
}

.farming-row {
    padding: 6px;
    background: var(--bg-tertiary);
    border-radius: 6px;
    margin-bottom: 6px;
}

.farming-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.farming-dungeon {
    font-size: 0.8rem;
    font-weight: bold;
    color: var(--text-primary);
}

.farming-steps {
    font-size: 0.72rem;
    color: var(--text-secondary);
}

.farming-controls {
    display: flex;
    gap: 4px;
    align-items: center;
}

.farming-char-select {
    flex: 1;
    padding: 4px 6px;
    font-size: 0.78rem;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid #334155;
    border-radius: 4px;
    margin-bottom: 0;
}

.btn-farm {
    background: #65a30d !important;
    color: white !important;
    border-color: #65a30d !important;
    font-weight: bold;
    font-size: 0.72rem;
    padding: 4px 8px;
    white-space: nowrap;
}

.btn-farm:hover:not(:disabled) {
    background: #4d7c0f !important;
    transform: none;
    box-shadow: none;
}

.btn-farm:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.btn-unassign {
    background: var(--danger) !important;
    color: white !important;
    font-weight: bold;
    font-size: 0.72rem;
    padding: 4px 6px;
    width: auto;
}

.btn-unassign:hover {
    background: #dc2626 !important;
    transform: none;
    box-shadow: none;
}

/* ========== B-6: Hints ========== */
.hint-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 0;
    font-size: 0.82rem;
}

.hint-text {
    color: #a78bfa;
    font-style: italic;
}

.hint-hidden {
    color: var(--text-secondary);
    opacity: 0.5;
}

.btn-hint {
    background: #7c3aed !important;
    color: white !important;
    font-size: 0.72rem;
    padding: 3px 8px;
    width: auto;
    margin-bottom: 0;
}

.btn-hint:hover:not(:disabled) {
    background: #6d28d9 !important;
    transform: none;
    box-shadow: none;
}

.btn-hint:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

/* ========== C-3: Ending Overlay ========== */
.ending-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    border-radius: 12px;
}

.ending-box {
    text-align: center;
    padding: 30px 40px;
    max-width: 400px;
}

.ending-title {
    font-size: 2rem;
    font-weight: bold;
    color: #fbbf24;
    text-shadow: 0 0 20px rgba(251, 191, 36, 0.6);
    margin-bottom: 16px;
}

.ending-stats {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.8;
    margin-bottom: 16px;
}

.ending-note {
    font-size: 0.75rem;
    color: var(--text-secondary);
    opacity: 0.7;
    font-style: italic;
    margin-bottom: 20px;
}

.btn-new-game-plus {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: #000;
    font-weight: bold;
    font-size: 1.1rem;
    padding: 12px 32px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    width: auto;
}

.btn-new-game-plus:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(251, 191, 36, 0.5);
}

/* ========== C-2: Chapter Join Message ========== */
.chapter-join-msg {
    color: #a78bfa;
    font-weight: bold;
    margin-top: 4px;
}

/* ========== C-5: Item Shop ========== */
.item-shop {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.btn-buy-item {
    background: #7c3aed !important;
    color: white !important;
    border-color: #7c3aed !important;
    font-weight: bold;
    font-size: 0.72rem;
    padding: 4px 8px;
}

.btn-buy-item:hover:not(:disabled) {
    background: #6d28d9 !important;
    transform: none;
    box-shadow: none;
}

.btn-buy-item:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.inventory-display {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-top: 6px;
    line-height: 1.4;
}

.inventory-item {
    color: #a78bfa;
}

.active-contract {
    color: #4ade80;
    font-weight: bold;
}

/* ========== Character Farming Badge ========== */
.char-card.char-farming {
    border: 2px solid #a3e635;
    opacity: 0.7;
}

.char-card.char-farming .char-name::after {
    content: ' \1F33E';
    font-size: 0.65rem;
}

/* ========== Responsive for Editor ========== */
@media (max-width: 700px) {
    .tile-palette {
        grid-template-columns: 1fr 1fr;
    }

    .editor-controls {
        width: 100%;
        max-width: 400px;
    }

    .mode-tab {
        padding: 8px 20px;
        font-size: 0.9rem;
    }
}

/* ========== Step 1: Toast Notifications ========== */
.toast-container {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 6px;
    pointer-events: none;
    width: 90%;
    max-width: 360px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    background: rgba(22, 33, 62, 0.95);
    color: var(--text-primary);
    border: 1px solid #334155;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
    opacity: 0;
    transform: translateY(-12px);
    transition: opacity 0.25s ease, transform 0.25s ease;
    pointer-events: auto;
}

.toast.toast-show {
    opacity: 1;
    transform: translateY(0);
}

.toast.toast-hide {
    animation: toast-fade-out 0.3s ease forwards;
}

@keyframes toast-fade-out {
    to { opacity: 0; transform: translateY(-12px); }
}

.toast-icon { font-size: 1rem; flex-shrink: 0; }
.toast-text { flex: 1; }

.toast-gold { border-color: #fbbf24; background: rgba(251, 191, 36, 0.15); color: #fbbf24; }
.toast-damage { border-color: #ef4444; background: rgba(239, 68, 68, 0.15); color: #ef4444; }
.toast-success { border-color: #4ade80; background: rgba(74, 222, 128, 0.15); color: #4ade80; }
.toast-warning { border-color: #fbbf24; background: rgba(251, 191, 36, 0.1); color: #fbbf24; }
.toast-info { border-color: #60a5fa; background: rgba(59, 130, 246, 0.1); color: #93c5fd; }

/* ========== Step 2: Resource Warnings ========== */
.hp-high .hp-fill { background: linear-gradient(90deg, #22c55e, #4ade80); }
.hp-medium .hp-fill { background: linear-gradient(90deg, #eab308, #fbbf24); }
.hp-low .hp-fill { background: linear-gradient(90deg, #dc2626, #ef4444); }
.hp-critical .hp-fill { background: #ef4444; animation: hp-pulse 0.6s ease-in-out infinite alternate; }

@keyframes hp-pulse {
    from { opacity: 1; }
    to { opacity: 0.4; }
}

.gold-flash {
    animation: gold-blink 0.8s ease-in-out infinite alternate;
}

@keyframes gold-blink {
    from { color: #fbbf24; text-shadow: 0 0 8px rgba(251, 191, 36, 0.5); }
    to { color: #ef4444; text-shadow: 0 0 12px rgba(239, 68, 68, 0.6); }
}

.food-warning {
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid #ef4444;
    color: #ef4444;
    font-size: 0.82rem;
    font-weight: bold;
    padding: 6px 12px;
    border-radius: 6px;
    text-align: center;
    margin-bottom: 8px;
    animation: food-pulse 1s ease-in-out infinite alternate;
}

@keyframes food-pulse {
    from { opacity: 1; }
    to { opacity: 0.6; }
}

/* ========== Step 3: Dungeon Map ========== */
.dungeon-map-container {
    max-height: 340px;
    overflow-y: auto;
    margin-bottom: 8px;
    scrollbar-width: thin;
    scrollbar-color: #334155 transparent;
}

.dungeon-map-container::-webkit-scrollbar { width: 6px; }
.dungeon-map-container::-webkit-scrollbar-track { background: transparent; }
.dungeon-map-container::-webkit-scrollbar-thumb { background: #334155; border-radius: 3px; }

.dm-chapter {
    font-size: 0.78rem;
    font-weight: bold;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 6px 4px 3px;
    border-bottom: 1px solid rgba(233, 69, 96, 0.3);
    margin-top: 8px;
}

.dm-chapter:first-child { margin-top: 0; }

.dm-chapter-locked {
    color: #555;
    border-bottom-color: #333;
}

.dm-chapter-icon { margin-right: 4px; }

.dm-nodes {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 4px 0;
}

.dm-node {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    background: var(--bg-tertiary);
    border: 1px solid transparent;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-align: left;
    margin-bottom: 0;
    transition: background 0.15s, border-color 0.15s;
    width: 100%;
    position: relative;
}

.dm-node:hover:not(:disabled) {
    background: #1e3a5f;
    color: var(--text-primary);
    transform: none;
    box-shadow: none;
}

.dm-node.dm-current {
    border-color: var(--accent);
    background: rgba(233, 69, 96, 0.15);
    color: var(--text-primary);
}

.dm-node.dm-cleared {
    color: var(--text-secondary);
}

.dm-node.dm-locked {
    opacity: 0.4;
    cursor: not-allowed;
}

.dm-node.dm-locked:hover {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.dm-level {
    font-weight: bold;
    font-family: monospace;
    min-width: 20px;
    color: var(--text-primary);
}

.dm-node.dm-locked .dm-level { color: #555; }

.dm-name { flex: 1; }

.dm-check {
    color: var(--success);
    font-weight: bold;
    font-size: 0.75rem;
    margin-right: 2px;
}

.dm-hint-badge {
    background: #7c3aed;
    color: white;
    font-size: 0.6rem;
    font-weight: bold;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* ========== Step 4: Hint UI Polish ========== */
.hint-area {
    margin-top: 8px;
    background: rgba(124, 58, 237, 0.08);
    border: 1px solid rgba(124, 58, 237, 0.2);
    border-radius: 6px;
    padding: 6px 8px;
}

.hint-area:empty {
    display: none !important;
    padding: 0;
    border: none;
    background: none;
}

/* ========== Step 5: Briefing Overlay ========== */
.briefing-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    border-radius: 12px;
}

.briefing-box {
    text-align: center;
    padding: 24px 32px;
    max-width: 380px;
    width: 100%;
}

.briefing-title {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.briefing-chapter {
    font-size: 0.8rem;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 16px;
}

.brief-row {
    display: flex;
    justify-content: space-between;
    padding: 3px 0;
    font-size: 0.85rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.brief-label { color: var(--text-secondary); }
.brief-val { font-weight: bold; color: var(--text-primary); }
.brief-gold { color: #fbbf24; }
.brief-reward { color: #4ade80; }
.brief-warn { color: #fbbf24; font-size: 0.78rem; }
.brief-danger { color: #ef4444; }

.brief-status { margin-top: 8px; border-top: 1px solid rgba(255, 255, 255, 0.1); padding-top: 6px; }

.brief-section-title {
    font-size: 0.75rem;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 12px;
    margin-bottom: 4px;
    text-align: left;
}

.brief-hint {
    font-size: 0.8rem;
    text-align: left;
    padding: 2px 0;
}

.brief-hint-owned { color: #a78bfa; font-style: italic; }
.brief-hint-locked { color: #555; }

.brief-provisions-row {
    display: flex;
    gap: 6px;
    margin-top: 4px;
}

.btn-brief-food {
    flex: 1;
    background: #065f46 !important;
    color: #4ade80 !important;
    border-color: #065f46 !important;
    font-size: 0.72rem;
    padding: 5px 6px;
}

.btn-brief-food:hover {
    background: #047857 !important;
    transform: none;
    box-shadow: none;
}

.briefing-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 18px;
}

.btn-briefing-back {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-weight: bold;
    font-size: 1rem;
    padding: 10px 24px;
    border: 1px solid #334155;
    border-radius: 8px;
    cursor: pointer;
    width: auto;
}

.btn-briefing-back:hover {
    background: #1e3a5f;
    color: var(--text-primary);
    transform: none;
    box-shadow: none;
}

.btn-briefing-deploy {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: white;
    font-weight: bold;
    font-size: 1rem;
    padding: 10px 28px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    width: auto;
}

.btn-briefing-deploy:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(34, 197, 94, 0.4);
}

.btn-briefing-deploy:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ========== Step 6: Tutorial + Progressive Disclosure ========== */
.tutorial-tip {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: rgba(22, 33, 62, 0.97);
    border: 1px solid var(--accent);
    border-radius: 10px;
    padding: 14px 20px;
    max-width: 400px;
    z-index: 1000;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.tutorial-tip.tutorial-show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.tutorial-tip.tutorial-hide {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
}

.tutorial-text {
    font-size: 0.88rem;
    color: var(--text-primary);
    line-height: 1.5;
    margin-bottom: 10px;
}

.tutorial-dismiss {
    background: var(--accent);
    color: white;
    font-weight: bold;
    font-size: 0.82rem;
    padding: 6px 18px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    width: auto;
    display: block;
    margin: 0 auto;
}

.tutorial-dismiss:hover {
    transform: none;
    box-shadow: none;
    background: #d63851;
}

/* NEW badge */
.badge-new {
    display: inline-block;
    background: var(--accent);
    color: white;
    font-size: 0.6rem;
    font-weight: bold;
    padding: 1px 5px;
    border-radius: 8px;
    margin-left: 6px;
    vertical-align: middle;
    animation: badge-pulse 1.5s ease-in-out infinite;
}

@keyframes badge-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Progressive disclosure: hidden sections */
.section-hidden {
    display: none !important;
}

/* ========================================
   Screen System
   ======================================== */

.screen {
    display: none;
}

.screen.active {
    display: block;
}

/* ========================================
   Title Screen
   ======================================== */

.title-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: linear-gradient(180deg, #0d0d1a 0%, var(--bg-primary) 40%, var(--bg-secondary) 100%);
}

.title-logo {
    font-size: 3.5rem;
    font-weight: 900;
    letter-spacing: 6px;
    color: var(--accent);
    text-shadow: 0 0 30px rgba(233, 69, 96, 0.6), 0 0 60px rgba(233, 69, 96, 0.3);
    text-align: center;
    max-width: 100%;
}

/* 모바일: 로고 overflow 방지 (420px viewport 에서 "RL DUNGEON" 10글자 잘림) */
@media (max-width: 700px) {
    .title-logo {
        font-size: 2.2rem;
        letter-spacing: 3px;
    }
}

.title-subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin-bottom: 32px;
}

.title-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 220px;
}

.title-btn {
    padding: 14px 24px;
    font-size: 1.1rem;
    font-weight: 600;
    border: 2px solid var(--bg-tertiary);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
}

.title-btn:hover:not(:disabled) {
    background: var(--bg-tertiary);
    border-color: var(--accent);
}

.title-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.title-btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.title-btn-primary:hover {
    background: #d63851;
    border-color: #d63851;
}

.title-btn-dev {
    margin-top: 40px;
    padding: 8px 16px;
    font-size: 0.8rem;
    border: 1px solid #333;
    border-radius: 4px;
    background: transparent;
    color: #666;
    cursor: pointer;
    transition: all 0.2s;
}

.title-btn-dev:hover {
    color: var(--text-secondary);
    border-color: #555;
}

/* ========================================
   Dev Mode Back Bar
   ======================================== */

.dev-back-bar {
    margin-bottom: 16px;
}

.btn-back {
    padding: 8px 16px;
    font-size: 0.9rem;
    border: 1px solid var(--bg-tertiary);
    border-radius: 6px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-back:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* ========================================
   Guild Hall
   ======================================== */

.guild-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
}

.guild-header {
    background: var(--bg-secondary);
    border-radius: 10px;
    padding: 16px 20px;
    margin-bottom: 16px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

.guild-header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.guild-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--accent);
}

.guild-run {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.guild-resources {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.guild-res {
    font-size: 0.95rem;
    font-weight: 600;
    font-family: monospace;
    padding: 4px 10px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.05);
}

.guild-gold { color: #f0c040; }
.guild-food { color: #8bc34a; }
.guild-hp { color: #4ade80; }
.guild-deaths { color: #94a3b8; }
/* B-203: warn color when deaths >= LIMIT-1 (3/4 or higher) */
.guild-deaths.guild-res-warn { color: #ef4444; background: rgba(239, 68, 68, 0.15); }

/* Guild Tabs */
.guild-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
}

.guild-tab {
    flex: 1;
    padding: 10px 8px;
    font-size: 0.95rem;
    font-weight: 600;
    border: 2px solid transparent;
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.guild-tab:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.guild-tab.active {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--bg-tertiary);
}

/* Guild Tab Panels */
.guild-tab-panel {
    display: none;
    background: var(--bg-secondary);
    border-radius: 0 0 10px 10px;
    padding: 20px;
    min-height: 400px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

.guild-tab-panel.active {
    display: block;
}

/* Quest List */
.quest-section-title {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin: 16px 0 8px;
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.quest-section-title:first-child {
    margin-top: 0;
}

.quest-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 14px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.quest-card:hover {
    border-color: var(--accent);
    background: rgba(233, 69, 96, 0.05);
}

.quest-card.cleared {
    border-color: rgba(74, 222, 128, 0.2);
}

.quest-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.quest-card-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.quest-card-badge {
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
}

.quest-card-badge.cleared {
    background: rgba(74, 222, 128, 0.15);
    color: var(--success);
}

.quest-card-badge.new {
    background: rgba(233, 69, 96, 0.15);
    color: var(--accent);
}

.quest-card-badge.locked {
    background: rgba(255, 255, 255, 0.05);
    color: #666;
}

.quest-card-info {
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.quest-card-reward {
    font-size: 0.82rem;
    color: #f0c040;
    margin-top: 4px;
}

/* Serpa Cards (Party tab) */
.serpa-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
}

.serpa-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 12px;
    text-align: center;
    transition: all 0.2s;
}

.serpa-card.hired {
    border-color: rgba(74, 222, 128, 0.3);
}

.serpa-card.locked {
    opacity: 0.5;
}

.serpa-card-name {
    font-weight: 700;
    font-size: 0.95rem;
    margin-bottom: 2px;
}

.serpa-card-algo {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.serpa-card-cost {
    font-size: 0.8rem;
    color: #f0c040;
    margin-bottom: 4px;
}

.serpa-card-stats {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.btn-hire {
    margin-top: 8px;
    padding: 6px 12px;
    font-size: 0.8rem;
    border: 1px solid var(--accent);
    border-radius: 4px;
    background: transparent;
    color: var(--accent);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-hire:hover {
    background: var(--accent);
    color: white;
}

.btn-hire:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Shop Tab */
.shop-section {
    margin-bottom: 20px;
}

.shop-section h4 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.shop-food-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.shop-food-row input {
    width: 70px;
    padding: 6px 8px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.9rem;
}

.shop-food-row .shop-cost {
    color: #f0c040;
    font-size: 0.85rem;
    min-width: 50px;
}

.btn-shop {
    padding: 6px 14px;
    font-size: 0.85rem;
    border: 1px solid var(--bg-tertiary);
    border-radius: 4px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-shop:hover {
    background: var(--accent);
    border-color: var(--accent);
}

.shop-item-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    margin-bottom: 6px;
}

.shop-item-info {
    font-size: 0.85rem;
}

.shop-item-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.shop-item-cost {
    color: #f0c040;
    font-size: 0.85rem;
    font-weight: 600;
}

/* Guild footer */
.guild-footer {
    margin-top: 20px;
    text-align: center;
}

.btn-guild-dev {
    padding: 6px 12px;
    font-size: 0.75rem;
    border: 1px solid #333;
    border-radius: 4px;
    background: transparent;
    color: #555;
    cursor: pointer;
}

.btn-guild-dev:hover {
    color: var(--text-secondary);
    border-color: #555;
}

/* B-106: success-rate sparkline (always visible — RL 양념의 시각 시그니처) */
.sparkline-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    padding: 6px 10px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    font-size: 0.85rem;
}
.sparkline-wrap canvas {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 2px;
    flex: 0 0 auto;
}
.sparkline-label {
    color: var(--text-muted, #9ca3af);
    flex: 0 0 auto;
}
.sparkline-value {
    font-family: monospace;
    color: #4ade80;
    margin-left: auto;
    min-width: 4ch;
    text-align: right;
}

/* M5 i18n: 언어 토글 — 우측 컨트롤 상단, 작은 outline 버튼 */
.lang-toggle-wrap {
    display: flex;
    justify-content: flex-end;
    padding: 8px 12px 0;
}
.lang-toggle {
    background: transparent;
    color: var(--text-secondary, #cbd5e1);
    border: 1px solid #444;
    border-radius: 4px;
    padding: 4px 10px;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}
.lang-toggle:hover {
    border-color: #888;
    color: #fff;
}

/* B-207: silent_q modifier placeholder — sparkline-wrap 톤 매칭 + 회색조 (시각화 차단 상태 명시) */
.silent-q-placeholder {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    padding: 6px 10px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px dashed rgba(156, 163, 175, 0.35);
    border-radius: 4px;
    font-size: 0.85rem;
    color: var(--text-muted, #9ca3af);
}
.silent-q-label {
    color: #cbd5e1;
    font-weight: 600;
    flex: 0 0 auto;
}
.silent-q-desc {
    color: var(--text-muted, #9ca3af);
    font-style: italic;
}

/* B-004: Step-0 inline hint (canvas overlay) */
.step0-hint {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.72);
    color: #fff;
    font-size: 0.9rem;
    padding: 8px 14px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    pointer-events: none;
    z-index: 50;
    max-width: 90%;
    text-align: center;
    animation: step0-hint-pulse 2.4s ease-in-out infinite;
}

@keyframes step0-hint-pulse {
    0%, 100% { opacity: 0.92; }
    50%      { opacity: 0.65; }
}

/* ========== T2B-1: Daily Mode ========== */
.daily-controls .daily-intro h3,
.daily-controls .daily-actions h3,
.daily-controls .daily-yesterday h3,
.daily-controls .daily-today h3,
.daily-controls .daily-week h3 {
    margin-top: 0;
}

.daily-meta {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 8px 0 12px;
    background: rgba(15, 23, 42, 0.6);
    border-radius: 6px;
    padding: 10px 12px;
}

.daily-date-row,
.daily-seed-row,
.daily-modifiers-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
}

.daily-label {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.daily-date {
    color: var(--text-primary);
    font-family: monospace;
    font-weight: 600;
}

.daily-seed {
    color: var(--accent);
    font-family: monospace;
    font-weight: 600;
}

.daily-modifiers {
    color: #fbbf24;
    font-weight: 500;
}

.daily-desc {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin: 4px 0 0;
}

.daily-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.btn-daily-start,
.btn-daily-retry {
    width: 100%;
    padding: 12px;
    font-size: 1rem;
    font-weight: bold;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-daily-start:hover,
.btn-daily-retry:hover {
    background: #d63851;
}

.btn-daily-retry {
    background: #475569;
}

.btn-daily-retry:hover {
    background: #64748b;
}

.daily-yesterday-content,
.daily-today-content {
    font-size: 0.9rem;
    color: var(--text-primary);
    line-height: 1.5;
}

.daily-today-content .row,
.daily-yesterday-content .row {
    display: flex;
    justify-content: space-between;
    padding: 2px 0;
}

.daily-today-content .row .label,
.daily-yesterday-content .row .label {
    color: var(--text-secondary);
}

.daily-result-toast {
    background: rgba(34, 197, 94, 0.18);
    border: 1px solid rgba(34, 197, 94, 0.5);
    border-radius: 6px;
    padding: 10px 12px;
    margin-top: 8px;
    color: #86efac;
    font-size: 0.9rem;
}

.daily-result-toast.fail {
    background: rgba(239, 68, 68, 0.18);
    border-color: rgba(239, 68, 68, 0.5);
    color: #fca5a5;
}

.daily-week-content {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.daily-week-cell {
    width: 36px;
    height: 36px;
    border-radius: 4px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid #334155;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-family: monospace;
    flex-direction: column;
    line-height: 1.1;
}

.daily-week-cell.cleared {
    background: rgba(34, 197, 94, 0.18);
    border-color: rgba(34, 197, 94, 0.5);
    color: #86efac;
}

.daily-week-cell.attempted {
    background: rgba(239, 68, 68, 0.18);
    border-color: rgba(239, 68, 68, 0.5);
    color: #fca5a5;
}

.daily-week-cell.today {
    box-shadow: 0 0 0 2px var(--accent);
}

.daily-week-cell .day-num {
    font-weight: 700;
}

/* T2B-2 — Modifier band (above game canvas in daily mode) */
.modifier-band {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 12px;
    padding: 10px 14px;
    background: linear-gradient(90deg, rgba(99, 102, 241, 0.18), rgba(168, 85, 247, 0.18));
    border: 1px solid rgba(168, 85, 247, 0.45);
    border-radius: 8px;
    font-size: 13px;
}

.modifier-band .modifier-label {
    font-weight: 700;
    color: #c4b5fd;
    letter-spacing: 0.02em;
}

.modifier-band .modifier-chip {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    padding: 4px 10px;
    background: rgba(30, 27, 75, 0.55);
    border: 1px solid rgba(168, 85, 247, 0.5);
    border-radius: 999px;
    color: #ede9fe;
}

.modifier-band .modifier-chip .modifier-name {
    font-weight: 700;
}

.modifier-band .modifier-chip .modifier-desc {
    font-weight: 400;
    color: #c7d2fe;
    opacity: 0.85;
    font-size: 12px;
}

/* T2B-2 — Daily-panel modifier chips (smaller variant inside daily-controls) */
.daily-modifiers .modifier-chip {
    display: inline-block;
    padding: 2px 8px;
    margin: 2px 4px 2px 0;
    background: rgba(30, 27, 75, 0.55);
    border: 1px solid rgba(168, 85, 247, 0.5);
    border-radius: 999px;
    color: #ede9fe;
    font-size: 12px;
}

/* T2B-2 — two_only character pool inside daily intro */
.daily-pool-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 6px;
}

.daily-character-pool {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.daily-char-btn {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    padding: 6px 10px;
    background: var(--bg-tertiary, rgba(15, 23, 42, 0.6));
    border: 1px solid rgba(99, 102, 241, 0.5);
    border-radius: 8px;
    color: var(--text-primary, #e2e8f0);
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s, border-color 0.15s;
}

.daily-char-btn:hover {
    background: rgba(99, 102, 241, 0.18);
}

.daily-char-btn.active {
    background: rgba(99, 102, 241, 0.3);
    border-color: var(--accent, #818cf8);
    box-shadow: 0 0 0 2px rgba(129, 140, 248, 0.35);
}

.daily-char-btn .daily-char-name {
    font-weight: 700;
    font-size: 13px;
}

.daily-char-btn .daily-char-personality {
    font-size: 11px;
    opacity: 0.75;
}

/* === W7.1 Opening Card === */
.opening-overlay {
    position: fixed;
    inset: 0;
    background: rgba(8, 8, 14, 0.98);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    overflow-y: auto;
}

.opening-box {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    max-width: 640px;
    width: 100%;
    padding: 36px 40px;
    color: var(--text-primary);
    line-height: 1.7;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

.opening-heading {
    margin: 0 0 24px;
    color: var(--accent);
    text-align: center;
    font-size: 1.6rem;
    letter-spacing: 1px;
}

.opening-box p {
    margin: 0 0 16px;
    word-break: keep-all;
    overflow-wrap: break-word;
    color: var(--text-secondary);
}

.opening-box p:last-of-type {
    color: var(--text-primary);
    font-weight: 500;
}

.opening-start {
    display: block;
    margin: 28px auto 0;
    padding: 12px 36px;
    background: var(--accent);
    color: white;
    border: 0;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    letter-spacing: 1px;
}

.opening-start:hover {
    filter: brightness(1.15);
}

@media (max-width: 700px) {
    .opening-box {
        padding: 24px 22px;
        line-height: 1.6;
    }
    .opening-heading {
        font-size: 1.35rem;
        margin-bottom: 18px;
    }
    .opening-box p {
        font-size: 0.94rem;
    }
}
