body {
    font-family: 'Segoe UI', 'Hiragino Sans', 'Noto Sans JP', sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    color: #0f172a;
    background: linear-gradient(120deg, #e0f2fe 0%, #ede9fe 45%, #f5f3ff 100%);
    min-height: 100vh;
    margin: 0;
    padding: 24px;
    line-height: 1.6;
}

.site-header {
    width: 100%;
    max-width: 980px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    padding: 18px 24px;
    margin-bottom: 20px;
    background: rgba(255, 255, 255, 0.88);
    border-radius: 18px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    box-shadow: 0 20px 44px rgba(148, 163, 184, 0.25);
}

.site-header h1 {
    margin: 0;
    font-size: 28px;
    letter-spacing: 0.04em;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.header-link-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 14px;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(59,130,246,0.18), rgba(37,99,235,0.28));
    color: #1e3a8a;
    font-weight: 600;
    font-size: 0.9rem;
    text-decoration: none;
    border: 1px solid rgba(59, 130, 246, 0.25);
    box-shadow: 0 6px 18px rgba(37, 99, 235, 0.22);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.header-link-button:hover,
.header-link-button:focus-visible {
    transform: translateY(-1px);
    box-shadow: 0 10px 24px rgba(37, 99, 235, 0.28);
}

.header-link-button:focus-visible {
    outline: 2px solid rgba(59, 130, 246, 0.5);
    outline-offset: 2px;
}

.language-switcher {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.95rem;
    color: #334155;
}

.language-switcher label {
    font-weight: 600;
}

.language-switcher select {
    appearance: none;
    background: #f8fafc;
    border: 1px solid #cbd5f5;
    border-radius: 10px;
    padding: 6px 12px;
    color: #0f172a;
    font-size: 0.95rem;
    box-shadow: 0 6px 18px rgba(148, 163, 184, 0.2);
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* 探索画面レイアウト（全画面・スクロール抑止） */
body.in-game {
    overflow: hidden; /* ページの縦横スクロールを無効化 */
    padding: 0;       /* 余白を消して100vw/100vhにフィット */
}
/* モーダル表示中は一時的にスクロールを許可 */
body.in-game.modal-open { overflow: auto; }
body.in-game h1 { display: none; }
body.in-game #game-screen { width: 100vw; max-width: 100vw; padding-top: var(--toolbar-height, 0px); }
body.in-game #dungeontoolbar { position: fixed; top: 0; left: 0; right: 0; z-index: 100; }
body.in-game #game-container { 
    width: 100vw; 
    max-width: 100vw; 
    height: calc(100vh - var(--toolbar-height, 0px)); 
    box-sizing: border-box; 
    overflow: hidden;
}
/* ステータス右側の常時空白スペース（ポップアップ用） */
#popup-spacer { flex: 0 0 var(--popup-space, 160px); pointer-events: none; }

#selection-screen {
    width: 100%;
    display: flex;
    justify-content: center;
    margin-bottom: 12px;
    background: linear-gradient(135deg, rgba(224,242,254,0.65), rgba(237,233,254,0.6));
    min-height: 100vh;
    align-items: center;
    padding-bottom: var(--selection-footer-h, 140px); /* フッター分の余白を確保 */
}

.selection-card { 
    background: rgba(255,255,255,0.95); 
    backdrop-filter: blur(10px);
    padding: 24px; 
    border-radius: 20px; 
    box-shadow: 0 8px 32px rgba(0,0,0,0.3); 
    width: 800px; 
    border: 1px solid rgba(255,255,255,0.2);
}

.selection-card-footer {
    margin-top: 24px;
    padding-top: 12px;
    border-top: 1px solid rgba(102,126,234,0.3);
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    font-size: 0.9rem;
    color: #4c566a;
}

.selection-card-footer .game-brand {
    font-weight: 700;
    color: #2c3e50;
}

.selection-card-footer .game-version {
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.04em;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 6px;
    margin: 8px 0 0 0;
    border-bottom: 2px solid rgba(102,126,234,0.35);
    align-items: flex-end;
}
/* Increase specificity to override .selection-card button */
.selection-card .tab-button {
    appearance: none;
    background: #eef2ff;
    background-image: none;
    color: #2c3e50;
    font-weight: 700;
    border: 1px solid rgba(102,126,234,0.5);
    border-bottom: none;
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    padding: 10px 16px;
    margin: 0;
    box-shadow: none;
    cursor: pointer;
    transform: none;
    position: relative;
    top: 2px; /* sit on the border */
}
.selection-card .tab-button:hover {
    background: #e5e9ff;
}
.selection-card .tab-button.active {
    background: #ffffff;
    color: #2c3e50;
    border-color: rgba(102,126,234,0.6);
    box-shadow: 0 -2px 8px rgba(0,0,0,0.06);
    z-index: 1;
}
.tab-content {
    background: #ffffff;
    border: 1px solid rgba(102,126,234,0.6);
    border-top: none;
    border-radius: 0 12px 12px 12px;
    padding: 10px;
    margin-top: -1px; /* connect to tab */
}

/* BlockDim UI */
.bdim-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    width: 100%;
}

/* Achievements & Statistics */
.achievement-layout {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
}

.achievement-subtabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.subtab-button {
    appearance: none;
    border: 1px solid rgba(102,126,234,0.4);
    border-radius: 20px;
    background: #eef2ff;
    color: #2c3e50;
    font-weight: 600;
    padding: 6px 14px;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
}

.subtab-button:hover {
    background: #e0e7ff;
    transform: translateY(-1px);
}

.subtab-button.active {
    background: #ffffff;
    border-color: rgba(102,126,234,0.8);
    box-shadow: 0 2px 8px rgba(102,126,234,0.2);
}

.achievement-subtab {
    display: none;
}

.achievement-subtab.active {
    display: block;
}

.achievement-list {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.achievement-category {
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: rgba(102,126,234,0.08);
    border: 1px solid rgba(102,126,234,0.2);
    border-radius: 12px;
    padding: 12px;
}

.achievement-category__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    color: #2c3e50;
}

.achievements-fallback {
    padding: 16px;
    border-radius: 12px;
    border: 1px dashed rgba(102,126,234,0.35);
    background: rgba(102,126,234,0.12);
    color: #2c3e50;
    font-weight: 600;
    text-align: center;
}

.achievements-fallback--error {
    border-color: rgba(220, 53, 69, 0.45);
    background: rgba(220, 53, 69, 0.12);
    color: #8a1c2b;
}

.achievements-fallback--info {
    border-color: rgba(102,126,234,0.35);
}

.achievement-card-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.achievement-card {
    background: #ffffff;
    border: 1px solid rgba(102,126,234,0.2);
    border-radius: 12px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(102,126,234,0.12);
}

.achievement-card--unlocked {
    border-color: #4dabf7;
    box-shadow: 0 4px 16px rgba(77,171,247,0.2);
}

.achievement-card--locked {
    opacity: 0.9;
}

.achievement-card__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.achievement-card__header h5 {
    margin: 0;
    color: #2c3e50;
    font-size: 1.05rem;
}

.achievement-card__status {
    font-size: 0.75rem;
    padding: 2px 10px;
    border-radius: 999px;
    background: rgba(102,126,234,0.16);
    color: #2c3e50;
}

.achievement-card--unlocked .achievement-card__status {
    background: #d3f9d8;
    color: #2b8a3e;
}

.achievement-card--locked .achievement-card__status {
    background: #ffe3e3;
    color: #c92a2a;
}

.achievement-card__description,
.achievement-card__reward,
.achievement-card__meta {
    margin: 0;
    color: #4c566a;
    font-size: 0.9rem;
}

.achievement-card__reward {
    font-style: italic;
}

.achievement-card__progress {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.85rem;
    color: #36415c;
}

.achievement-progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(102,126,234,0.18);
    border-radius: 999px;
    overflow: hidden;
}

.achievement-progress-bar__fill {
    height: 100%;
    background: linear-gradient(135deg, #51cf66, #2f9e44);
    border-radius: 999px;
}

.achievement-coming-soon,
.achievement-empty {
    margin: 0;
    color: #4c566a;
    font-size: 0.9rem;
}

.achievement-category-summary {
    background: #f4f6ff;
    border: 1px solid rgba(102,126,234,0.3);
    border-radius: 10px;
    padding: 10px 14px;
    color: #2c3e50;
}

.achievement-category-summary__list {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.achievement-category-summary__item {
    display: flex;
    gap: 6px;
    align-items: center;
}

.custom-achievement-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.custom-achievement-header h4 {
    margin: 0;
    color: #2c3e50;
}

.custom-achievement-header p {
    margin: 0;
    color: #4c566a;
    font-size: 0.9rem;
}

.custom-achievement-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.custom-achievement-empty {
    margin: 0;
    color: #4c566a;
    font-style: italic;
}

.custom-achievement-form fieldset {
    border: 1px solid rgba(102,126,234,0.3);
    border-radius: 12px;
    background: #ffffff;
    padding: 12px;
}

.custom-achievement-form legend {
    font-weight: 700;
    color: #2c3e50;
}

.custom-achievement-form .form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}

.custom-achievement-form label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    color: #36415c;
    font-size: 0.9rem;
}

.custom-achievement-form button {
    padding: 8px 18px;
    font-weight: 600;
    border-radius: 8px;
    border: 1px solid rgba(102,126,234,0.4);
    background: linear-gradient(135deg, #7f8ff4, #91a7ff);
    color: #ffffff;
    cursor: pointer;
}

.custom-achievement-card {
    background: #ffffff;
    border: 1px solid rgba(102,126,234,0.2);
    border-radius: 12px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-shadow: 0 2px 8px rgba(102,126,234,0.12);
}

.custom-achievement-controls {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.custom-achievement-controls button {
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid rgba(102,126,234,0.3);
    background: #eef2ff;
    color: #2c3e50;
    cursor: pointer;
}

.custom-achievement-info,
.custom-achievement-status {
    margin: 0;
    color: #4c566a;
    font-size: 0.9rem;
}

.custom-achievement-card .achievement-card__actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.custom-achievement-card .achievement-card__actions .danger {
    background: #ffc9c9;
    border: 1px solid #ffa8a8;
    color: #c92a2a;
}

.statistics-summary {
    background: #f4f6ff;
    border: 1px solid rgba(102,126,234,0.3);
    border-radius: 10px;
    padding: 10px 14px;
}

.statistics-summary__list {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.statistics-summary__item {
    display: flex;
    flex-direction: column;
    min-width: 140px;
    color: #2c3e50;
}

.statistics-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.summary-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #5c6c8c;
}

.summary-value {
    font-weight: 700;
    font-size: 1.05rem;
}

.statistics-section {
    background: #ffffff;
    border: 1px solid rgba(102,126,234,0.2);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 16px;
    box-shadow: 0 2px 8px rgba(102,126,234,0.12);
}

.statistics-section h4 {
    margin-top: 0;
    color: #2c3e50;
}

.statistics-table {
    width: 100%;
    border-collapse: collapse;
}

.statistics-table th,
.statistics-table td {
    border-bottom: 1px solid rgba(102,126,234,0.15);
    padding: 8px;
    text-align: left;
}

.statistics-table tr:last-child th,
.statistics-table tr:last-child td {
    border-bottom: none;
}

.statistics-table td:nth-child(2) {
    font-weight: 700;
    color: #2c3e50;
}

.statistics-table td:nth-child(3) {
    color: #4c566a;
    font-size: 0.85rem;
}
.bdim-field label { display: block; font-weight: bold; color: #2c3e50; margin-bottom: 6px; }
.bdim-field select {
    width: 100%;
    padding: 8px 12px;
    border: 2px solid #667eea;
    border-radius: 8px;
    background: white;
    font-weight: bold;
    cursor: pointer;
}
.bdim-field input[type="number"] {
    width: 100%;
    padding: 8px 12px;
    border: 2px solid #667eea;
    border-radius: 8px;
    background: white;
    font-weight: bold;
}
.bdim-list {
    width: 100%;
    max-height: 220px;
    overflow: auto;
    padding: 6px;
    border: 2px solid #667eea;
    border-radius: 8px;
    background: white;
}
.bdim-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
}
.bdim-option:hover { background: #eef2ff; }
.bdim-option.selected { background: #c7d2fe; font-weight: 700; }
.bdim-tag { font-size: 11px; color: #4b5563; background: #e5e7eb; padding: 2px 6px; border-radius: 999px; }
.bdim-card { 
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 15px;
    padding: 16px;
    width: 100%;
    color: #fff;
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
    border: 1px solid rgba(255,255,255,0.2);
}
.bdim-card h3 { margin: 0 0 12px 0; text-align: center; }
.bdim-card-row { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid rgba(255,255,255,0.2); }
.bdim-card-row:last-of-type { border-bottom: none; }
.bdim-card-row .label { font-weight: bold; opacity: 0.9; }
.bdim-note { display: block; margin-top: 8px; opacity: 0.9; }

.bdim-test-card {
    background: linear-gradient(135deg, #1e3a8a 0%, #312e81 100%);
    border: 1px solid rgba(148, 163, 184, 0.4);
}

.bdim-test-desc {
    margin: 0;
    font-size: 14px;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.88);
}

.bdim-test-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 12px;
}

.bdim-test-status {
    font-size: 13px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.78);
}

.bdim-test-status.info { color: #a5d8ff; }
.bdim-test-status.success { color: #b2f2bb; }
.bdim-test-status.error { color: #ffa8a8; }
.bdim-test-status.warning { color: #ffe066; }

.bdim-test-log {
    margin-top: 12px;
    max-height: 220px;
    overflow-y: auto;
    background: rgba(15, 23, 42, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    padding: 10px;
    color: #e0eaff;
    font-family: "SFMono-Regular", Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 12px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

.selection-card h2 {
    text-align: center;
    color: #2c3e50;
    font-size: 32px;
    margin-bottom: 24px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* MiniExp UI */
.miniexp-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    grid-template-rows: auto auto 1fr;
    gap: 12px;
    width: 100%;
    align-items: start;
}
.miniexp-cat-list { grid-column: 1; grid-row: 1; }
.miniexp-display-toolbar { grid-column: 1; grid-row: 2; }
.miniexp-list { grid-column: 1; grid-row: 3; }
.miniexp-panel { grid-column: 2; grid-row: 1 / span 3; width: 100%; }
.miniexp-cat-list {
    width: 100%;
    padding: 6px;
    border: 2px solid #667eea;
    border-radius: 8px;
    background: white;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.miniexp-cat-list .cat-btn {
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid rgba(102,126,234,0.45);
    background: #eef2ff;
    color: #1f2937;
    font-weight: 700;
    cursor: pointer;
}
.miniexp-cat-list .cat-btn.active {
    background: linear-gradient(135deg,#667eea,#764ba2);
    color: #fff;
    border-color: transparent;
}
.miniexp-display-toolbar {
    width: 100%;
    padding: 6px;
    border: 2px solid #667eea;
    border-radius: 8px;
    background: white;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}
.miniexp-display-toolbar .display-btn {
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid rgba(102,126,234,0.45);
    background: #f5f7ff;
    color: #1f2937;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.1s ease, box-shadow 0.2s ease;
}
.miniexp-display-toolbar .display-btn:hover {
    background: #e0e7ff;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(102,126,234,0.25);
}
.miniexp-display-toolbar .display-btn.active {
    background: linear-gradient(135deg,#4338ca,#6366f1);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 6px 18px rgba(99,102,241,0.35);
}
.miniexp-list {
    width: 100%;
    max-height: 420px;
    overflow: auto;
    padding: 6px;
    border: 2px solid #667eea;
    border-radius: 8px;
    background: white;
}
.miniexp-list.mode-detail {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.miniexp-list.mode-tile {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 8px;
}
.miniexp-list.mode-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.miniexp-list.mode-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: flex-start;
}
.miniexp-entry {
    appearance: none;
    border: 1px solid rgba(102,126,234,0.45);
    border-radius: 12px;
    background: #eef2ff;
    color: #1f2937;
    font-weight: 700;
    padding: 10px 12px;
    cursor: pointer;
    transition: transform 0.1s ease, box-shadow 0.2s ease, background 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    text-decoration: none;
}
.miniexp-entry:hover {
    background: #e0e7ff;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(102,126,234,0.25);
}
.miniexp-entry.selected {
    background: linear-gradient(135deg,#4338ca,#6366f1);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 8px 20px rgba(79,70,229,0.35);
}
.miniexp-list.mode-tile .miniexp-entry { min-height: 72px; }
.miniexp-list.mode-list .miniexp-entry {
    width: 100%;
    justify-content: flex-start;
    text-align: left;
    padding-left: 16px;
}
.miniexp-list.mode-wrap .miniexp-entry {
    flex: 0 1 auto;
    min-width: 120px;
}
.miniexp-card {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px;
    border: 1px solid rgba(102,126,234,0.35);
    border-radius: 8px;
    background: #f8f9ff;
}
.miniexp-card.selected {
    border-color: rgba(99,102,241,0.9);
    background: #eef2ff;
    box-shadow: 0 6px 18px rgba(99,102,241,0.25);
}
.miniexp-card h4 { margin: 0; font-size: 14px; color: #2c3e50; }
.miniexp-card .desc { font-size: 12px; color: #4b5563; }
.miniexp-card .meta { font-size: 11px; color: #6b7280; }
.miniexp-card button { align-self: flex-start; }
.miniexp-panel { background: #ffffff; border: 1px solid rgba(102,126,234,0.35); border-radius: 8px; padding: 10px; min-height: 200px; }
.miniexp-placeholder { color: #6b7280; font-size: 12px; }

.miniexp-toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
#miniexp-difficulty { padding: 6px 10px; border: 2px solid #667eea; border-radius: 8px; background: white; font-weight: bold; }
#miniexp-start, #miniexp-pause, #miniexp-restart, #miniexp-quit { padding: 8px 12px; border-radius: 8px; border: none; color: #fff; font-weight: bold; cursor: pointer; white-space: nowrap; }
#miniexp-start { background: linear-gradient(135deg, #22c55e, #16a34a); }
#miniexp-pause { background: linear-gradient(135deg, #f59e0b, #d97706); }
#miniexp-restart { background: linear-gradient(135deg, #3b82f6, #2563eb); }
#miniexp-quit { background: linear-gradient(135deg, #ef4444, #dc2626); }
.miniexp-container { position: relative; min-height: 360px; background: #0f172a0d; border: 1px dashed rgba(102,126,234,0.35); border-radius: 8px; }
.miniexp-hud { position: absolute; right: 8px; bottom: 8px; display: flex; flex-direction: column; gap: 4px; pointer-events: none; transform: translateX(calc(100% + 8px)); }
.exp-badge { background: rgba(34,197,94,0.95); color: #fff; padding: 4px 8px; border-radius: 999px; box-shadow: 0 4px 12px rgba(0,0,0,0.2); animation: fadeUp 1.2s ease forwards; font-weight: 700; font-size: 12px; }
/* Combo-styled badges (for chain popups) */
.exp-badge.combo { font-size: 14px; padding: 6px 10px; box-shadow: 0 6px 18px rgba(0,0,0,0.25); }
.exp-badge.combo.c1 { background: linear-gradient(135deg, #f59e0b, #fbbf24); }
.exp-badge.combo.c2 { background: linear-gradient(135deg, #06b6d4, #3b82f6); font-size: 16px; }
.exp-badge.combo.c3 { background: linear-gradient(135deg, #a21caf, #f43f5e); font-size: 18px; }
/* Floating variant (positioned at cursor) */
.exp-badge.float { position: absolute; transform: translate(-50%, -100%); animation: floatRise 1.25s ease forwards; pointer-events: none; white-space: nowrap; }
@keyframes floatRise {
  0% { opacity: 0; transform: translate(-50%, -6px) scale(0.92); }
  12% { opacity: 1; transform: translate(-50%, -12px) scale(1); }
  85% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -28px) scale(1); }
}
@keyframes fadeUp { 0% { opacity: 0; transform: translateY(6px); } 10% { opacity: 1; transform: translateY(0); } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-6px); } }
.miniexp-player-hud { position: absolute; right: 8px; bottom: 8px; min-width: 200px; padding: 8px; background: rgba(255,255,255,0.9); border: 1px solid rgba(102,126,234,0.35); border-radius: 10px; box-shadow: 0 6px 16px rgba(0,0,0,0.15); }
.mini-stat-line { display: flex; justify-content: space-between; font-weight: 800; color: #111827; }
.mini-bar-label { font-size: 12px; color: #334155; margin-bottom: 2px; }
.mini-bar-track { width: 100%; height: 8px; background: #e5e7eb; border-radius: 999px; overflow: hidden; }
.mini-bar-fill { height: 100%; width: 0%; background: linear-gradient(90deg,#22c55e,#86efac); transition: width 0.25s ease; }

.miniexp-records { margin-top: 10px; display: grid; grid-template-columns: repeat(3, minmax(120px, 1fr)); gap: 8px; }
.miniexp-records .rec-card { background: #f8fafc; border: 1px solid rgba(100,116,139,0.25); border-radius: 8px; padding: 8px 10px; }
.miniexp-records .rec-title { font-size: 12px; color: #475569; }
.miniexp-records .rec-value { font-weight: 800; font-size: 16px; color: #0f172a; }

.selection-card .row { 
    display: flex; 
    align-items: center; 
    gap: 16px; 
    margin: 16px 0; 
    padding: 12px;
    background: rgba(255,255,255,0.7);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

#world-buttons, #dungeon-buttons { 
    display: flex; 
    flex-wrap: wrap; 
    gap: 8px; 
}

.selection-card button { 
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.selection-card button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.selection-card .selected { 
    background: linear-gradient(135deg, #ff6b6b, #ee5a24) !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(238, 90, 36, 0.4);
}

#difficulty-select {
    padding: 8px 12px;
    border: 2px solid #667eea;
    border-radius: 8px;
    background: white;
    font-weight: bold;
    cursor: pointer;
}

label {
    font-weight: bold;
    color: #2c3e50;
    font-size: 16px;
}

/* Player Status Card */
.player-status-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 16px;
    padding: 20px;
    margin: 16px 0;
    color: white;
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
    border: 1px solid rgba(255,255,255,0.2);
}

/* 選択画面用固定フッター（プレイヤーステータス） */
#player-summary {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 900;
    padding: 10px 16px;
    display: flex;
    justify-content: center;
    pointer-events: none; /* 背景操作を邪魔しない */
}
#player-summary .player-status-card {
    pointer-events: auto; /* カード自体の操作は可能に */
    width: min(1000px, 95vw);
    margin: 0 auto;
    transition: transform 0.25s ease, opacity 0.25s ease;
}
/* 折りたたみトグルボタン */
#player-summary .summary-toggle {
    position: absolute;
    left: 50%;
    bottom: 8px;
    transform: translateX(-50%);
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid rgba(102,126,234,0.4);
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    pointer-events: auto;
}
#player-summary .summary-toggle:hover { filter: brightness(1.05); }

/* 折りたたみ状態（下方向に隠す） */
#player-summary.collapsed .player-status-card {
    transform: translateY(120%);
    opacity: 0.6;
    pointer-events: none;
}
#player-summary.collapsed .summary-toggle { bottom: 10px; }
/* 探索画面中は選択フッターを非表示 */
body.in-game #player-summary { display: none; }

.player-status-card h3 {
    margin: 0 0 16px 0;
    text-align: center;
    font-size: 20px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.status-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: rgba(255,255,255,0.1);
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.2);
}

.stat-label {
    font-weight: bold;
    opacity: 0.9;
    font-size: 14px;
}

.stat-value {
    font-weight: bold;
    font-size: 16px;
}

.stat-value.level {
    color: #ffd700;
}

.stat-value.hp {
    color: #ff6b6b;
}

.stat-value.attack {
    color: #ff8c42;
}

.stat-value.defense {
    color: #74c0fc;
}

/* ダンジョン詳細カード */
.dungeon-detail-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 15px;
    padding: 20px;
    margin: 16px 0;
    color: white;
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
    border: 1px solid rgba(255,255,255,0.2);
}

.dungeon-detail-card h3 {
    margin: 0 0 16px 0;
    font-size: 24px;
    font-weight: bold;
    text-align: center;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.detail-row {
    display: flex;
    justify-content: space-between;
    margin: 12px 0;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255,255,255,0.2);
}

.detail-row:last-of-type {
    border-bottom: none;
}

.detail-row .label {
    font-weight: bold;
    opacity: 0.9;
}

.start-btn {
    background: linear-gradient(45deg, #ff6b6b, #ee5a24);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 25px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    margin-top: 16px;
    width: 100%;
    box-shadow: 0 4px 15px rgba(238, 90, 36, 0.4);
    transition: all 0.3s ease;
}

.start-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(238, 90, 36, 0.6);
}

.start-btn:active {
    transform: translateY(0);
}

/* 敵情報モーダル */
.enemy-modal {
    width: 400px;
    max-width: 90vw;
}

.enemy-stats {
    background: rgba(255,255,255,0.1);
    border-radius: 8px;
    padding: 16px;
    margin: 16px 0;
}

.stat-row, .damage-row, .hit-rate-row {
    display: flex;
    justify-content: space-between;
    margin: 8px 0;
    padding: 4px 0;
}

.damage-simulation {
    background: rgba(255,255,255,0.1);
    border-radius: 8px;
    padding: 16px;
    margin: 16px 0;
}

.damage-simulation h4 {
    margin: 0 0 12px 0;
    color: #ffd700;
    text-align: center;
}

.damage-deal {
    border-left: 4px solid #4CAF50;
    padding-left: 8px;
}

.damage-take {
    border-left: 4px solid #f44336;
    padding-left: 8px;
}

.hit-rate-info {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(255,255,255,0.2);
}

.stat-row .label, .damage-row .label, .hit-rate-row .label {
    font-weight: bold;
    opacity: 0.9;
}

#enemy-modal-level {
    color: #ffd700;
    font-weight: bold;
}

#damage-deal-range {
    color: #4CAF50;
    font-weight: bold;
}

#damage-take-range {
    color: #f44336;
    font-weight: bold;
}

#hit-rate, #enemy-hit-rate {
    color: #2196F3;
    font-weight: bold;
}

#dungeontoolbar {
    position: sticky;
    top: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(10px);
    padding: 12px 16px;
    border-radius: 12px;
    margin-bottom: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    border: 1px solid rgba(255,255,255,0.2);
}

.toolbar-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #1f2937;
    font-weight: 600;
    user-select: none;
}

.toolbar-toggle input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #6366f1;
}

#dungeontoolbar button {
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    font-size: 14px;
}

#dungeontoolbar button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    background: linear-gradient(135deg, #5a6fd8, #6a4190);
}

.sandbox-menu-button[aria-expanded="true"] {
    background: linear-gradient(135deg, #22d3ee, #3b82f6);
    box-shadow: 0 4px 14px rgba(56,189,248,0.4);
}

.god-console-button {
    background: linear-gradient(135deg, #f97316, #facc15);
}

.god-console-button[aria-expanded="true"] {
    background: linear-gradient(135deg, #fb923c, #fde047);
    box-shadow: 0 4px 14px rgba(251,191,36,0.45);
}

.sandbox-interactive-panel {
    position: fixed;
    top: calc(var(--toolbar-height, 72px) + 16px);
    right: 24px;
    width: min(340px, 90vw);
    max-height: calc(100vh - 120px);
    display: none;
    flex-direction: column;
    background: rgba(15, 23, 42, 0.92);
    color: #f8fafc;
    border-radius: 18px;
    box-shadow: 0 18px 36px rgba(15, 23, 42, 0.55);
    border: 1px solid rgba(148, 163, 184, 0.35);
    z-index: 160;
    overflow: hidden;
    backdrop-filter: blur(12px);
}

.sandbox-interactive-panel[aria-hidden="false"] {
    display: flex;
}

.god-console-panel {
    position: fixed;
    right: 24px;
    bottom: 24px;
    width: min(420px, 92vw);
    max-height: calc(100vh - 160px);
    display: none;
    flex-direction: column;
    gap: 0;
    background: rgba(17, 24, 39, 0.94);
    color: #f8fafc;
    border-radius: 18px;
    box-shadow: 0 18px 36px rgba(15, 23, 42, 0.5);
    border: 1px solid rgba(148, 163, 184, 0.35);
    z-index: 170;
    backdrop-filter: blur(14px);
}

.god-console-panel[aria-hidden="false"] {
    display: flex;
}

.god-console-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.28);
}

.god-console-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
}

#god-console-close {
    background: transparent;
    border: none;
    color: #f8fafc;
    font-size: 20px;
    cursor: pointer;
    transition: transform 0.2s ease;
}

#god-console-close:hover {
    transform: scale(1.1);
}

.god-console-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 18px 20px 20px;
    overflow-y: auto;
}

.god-console-hint {
    margin: 0;
    font-size: 13px;
    line-height: 1.6;
    background: rgba(30, 41, 59, 0.7);
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid rgba(148, 163, 184, 0.25);
}

.god-console-mode {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

#god-console-toggle-sandbox {
    padding: 8px 14px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    background: linear-gradient(135deg, #22d3ee, #3b82f6);
    color: #0f172a;
    transition: all 0.2s ease;
}

#god-console-toggle-sandbox:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(56,189,248,0.35);
}

#god-console-mode-label {
    font-size: 13px;
    font-weight: 600;
    color: rgba(241, 245, 249, 0.9);
}

.god-console-label {
    font-weight: 600;
    font-size: 14px;
}

#god-console-input {
    min-height: 160px;
    width: 100%;
    resize: vertical;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: rgba(15, 23, 42, 0.85);
    color: #e2e8f0;
    font-family: 'Fira Code', 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    padding: 12px;
    line-height: 1.5;
    font-size: 13px;
}

#god-console-input:focus {
    outline: none;
    border-color: rgba(129, 140, 248, 0.8);
    box-shadow: 0 0 0 2px rgba(129, 140, 248, 0.25);
}

.god-console-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.god-console-actions button {
    padding: 10px 18px;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    font-weight: 700;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #f8fafc;
}

.god-console-actions button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99,102,241,0.35);
}

.god-console-actions button:nth-child(2) {
    background: linear-gradient(135deg, #64748b, #475569);
}

.god-console-status {
    min-height: 20px;
    font-size: 13px;
    padding: 10px 12px;
    border-radius: 10px;
    background: rgba(30, 41, 59, 0.65);
    border: 1px solid rgba(148, 163, 184, 0.22);
}

.god-console-status[data-tone="success"] {
    border-color: rgba(74, 222, 128, 0.55);
    background: rgba(22, 163, 74, 0.25);
    color: #bbf7d0;
}

.god-console-status[data-tone="error"] {
    border-color: rgba(248, 113, 113, 0.6);
    background: rgba(248, 113, 113, 0.25);
    color: #fecaca;
}

.god-console-status[data-tone="warning"] {
    border-color: rgba(251, 191, 36, 0.6);
    background: rgba(251, 191, 36, 0.22);
    color: #fef3c7;
}

.god-console-status[data-tone="info"] {
    border-color: rgba(129, 140, 248, 0.45);
    background: rgba(99, 102, 241, 0.25);
    color: #e0e7ff;
}

.sandbox-interactive-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.3);
}

.sandbox-interactive-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
}

#sandbox-interactive-close {
    background: transparent;
    border: none;
    color: #f8fafc;
    font-size: 20px;
    cursor: pointer;
}

.sandbox-interactive-body {
    padding: 16px 18px 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.sandbox-interactive-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: rgba(30, 41, 59, 0.75);
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: 12px;
    padding: 12px 14px;
}

.sandbox-interactive-section h4 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: #bae6fd;
}

.sandbox-interactive-section .sandbox-toggle {
    color: #e2e8f0;
    font-weight: 500;
    flex-direction: row;
}

.sandbox-interactive-section label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    color: #cbd5f5;
}

.sandbox-interactive-section input,
.sandbox-interactive-section select {
    padding: 6px 8px;
    border-radius: 6px;
    border: 1px solid rgba(148, 163, 184, 0.4);
    background: rgba(15, 23, 42, 0.8);
    color: #f8fafc;
}

.sandbox-interactive-section input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #38bdf8;
}

.sandbox-stat-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 12px;
}

.sandbox-interactive-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.sandbox-interactive-actions button {
    flex: 1 1 auto;
    min-width: 120px;
    padding: 8px 12px;
    border-radius: 8px;
    border: none;
    background: linear-gradient(135deg, #22d3ee, #3b82f6);
    color: #0f172a;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.sandbox-interactive-actions button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 18px rgba(56, 189, 248, 0.35);
}

.sandbox-interactive-section .sandbox-note {
    background: rgba(59, 130, 246, 0.15);
    color: #e0f2fe;
}

@media (max-width: 1024px) {
    .sandbox-interactive-panel {
        right: 12px;
        width: min(320px, 92vw);
    }
}

#game-container {
    display: flex;
    gap: 24px;
    width: min(1200px, 95vw);
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    border: 1px solid rgba(255,255,255,0.3);
}

#game-stage { 
    width: 100%; 
    aspect-ratio: 4 / 3; 
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

#game-canvas { 
    border: 2px solid rgba(102, 126, 234, 0.3); 
    background-color: #f8f9fa; 
    width: 100%; 
    height: 100%; 
    display: block;
    border-radius: 10px;
}

#ui-container {
    width: clamp(220px, 22vw, 300px);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

#player-stats .card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
    border: 1px solid rgba(255,255,255,0.2);
    color: white;
}

.stat-line { 
    display: flex; 
    justify-content: space-between; 
    margin-bottom: 8px;
    padding: 4px 0;
    font-weight: bold;
}

.stat-line span:first-child {
    opacity: 0.9;
}

.stat-line span:last-child {
    color: #ffd700;
}
.bar { margin: 12px 0; }

.bar-label { 
    font-size: 13px; 
    color: rgba(255,255,255,0.9); 
    margin-bottom: 6px;
    font-weight: bold;
}

.bar-track { 
    width: 100%; 
    height: 14px; 
    background: rgba(255,255,255,0.2); 
    border-radius: 8px; 
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.3);
}

.bar-fill { 
    height: 100%; 
    width: 0%; 
    transition: width 0.3s ease;
    border-radius: 7px;
}

.auto-item-status {
    margin-top: 12px;
    padding: 10px 12px;
    background: rgba(255,255,255,0.15);
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    color: #ffe066;
    border: 1px solid rgba(255,255,255,0.25);
    text-align: center;
}

.bar.hp .bar-fill { 
    background: linear-gradient(90deg, #ff6b6b, #fa5252);
    box-shadow: 0 0 10px rgba(255, 107, 107, 0.5);
}

.bar.exp .bar-fill {
    background: linear-gradient(90deg, #74c0fc, #4dabf7);
    box-shadow: 0 0 10px rgba(116, 192, 252, 0.5);
}

.bar.sp .bar-fill {
    background: linear-gradient(90deg, #e599f7, #be4bdb);
    box-shadow: 0 0 10px rgba(190, 75, 219, 0.45);
}

.bar.satiety .bar-fill {
    background: linear-gradient(90deg, #ff922b, #f76707);
    box-shadow: 0 0 10px rgba(255, 146, 43, 0.45);
}

.status-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
    min-height: 20px;
}

.status-badges--domain {
    gap: 4px;
    margin-top: 6px;
}

.status-badges--domain .status-badge {
    background: rgba(99, 102, 241, 0.18);
    border-color: rgba(99, 102, 241, 0.35);
    color: #e0e7ff;
}

.status-badge {
    font-size: 12px;
    font-weight: 600;
    padding: 2px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #f8f9fa;
    letter-spacing: 0.05em;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.status-badge--poison {
    background: rgba(148, 216, 45, 0.3);
    border-color: rgba(148, 216, 45, 0.45);
    color: #e9ffb3;
}

.status-badge--paralysis {
    background: rgba(255, 200, 87, 0.3);
    border-color: rgba(255, 200, 87, 0.5);
    color: #fff4d1;
}

.status-badge--ability {
    background: rgba(173, 216, 230, 0.3);
    border-color: rgba(173, 216, 230, 0.45);
    color: #e6f7ff;
}

.status-badge--level {
    background: rgba(255, 107, 107, 0.3);
    border-color: rgba(255, 107, 107, 0.5);
    color: #ffe3e3;
}

.status-badge--skill {
    background: rgba(190, 75, 219, 0.25);
    border-color: rgba(190, 75, 219, 0.45);
    color: #f8f0fc;
}

.status-badge--skill-gimmick {
    background: rgba(96, 165, 250, 0.25);
    border-color: rgba(96, 165, 250, 0.45);
    color: #eff6ff;
}

.status-badge--skill-status {
    background: rgba(16, 185, 129, 0.25);
    border-color: rgba(16, 185, 129, 0.45);
    color: #ecfdf5;
}

.status-badge--skill-enemy {
    background: rgba(250, 204, 21, 0.25);
    border-color: rgba(250, 204, 21, 0.45);
    color: #fef3c7;
}

.status-badge--skill-surehit {
    background: rgba(244, 114, 182, 0.25);
    border-color: rgba(244, 114, 182, 0.45);
    color: #fdf2f8;
}

.status-item.status-effects .status-value {
    display: block;
    font-size: 13px;
    line-height: 1.6;
}

#modal-status-effects {
    white-space: pre-line;
}

.enemy-type-description {
    margin-top: 16px;
    padding: 12px 14px;
    background: rgba(102, 126, 234, 0.12);
    border-left: 4px solid rgba(102, 126, 234, 0.45);
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.6;
    color: #2c3e50;
}

.enemy-type-description strong {
    color: #4c6ef5;
}

.popup-text {
    position: absolute;
    pointer-events: none;
}

#floor-indicator {
    margin-left: auto;
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 20px 24px;
    min-width: clamp(200px, 28vw, 260px);
    border-radius: 22px;
    background: linear-gradient(160deg, rgba(248, 250, 252, 0.92), rgba(226, 232, 240, 0.85));
    border: 1px solid rgba(148, 163, 184, 0.35);
    box-shadow: 0 18px 35px rgba(15, 23, 42, 0.18);
    position: relative;
    overflow: hidden;
    color: #0f172a;
    isolation: isolate;
}

#floor-indicator::before {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 20% 20%, rgba(59, 130, 246, 0.25), transparent 55%);
    opacity: 0.9;
    pointer-events: none;
    z-index: -1;
}

#floor-indicator::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.12), transparent 60%);
    pointer-events: none;
    z-index: -1;
}

.floor-indicator__heading {
    font-size: 13px;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    font-weight: 700;
    color: rgba(15, 23, 42, 0.6);
}

.floor-indicator__value {
    font-size: clamp(36px, 6vw, 48px);
    line-height: 1;
    font-weight: 800;
    letter-spacing: 0.04em;
    color: #0f172a;
    text-shadow: 0 10px 25px rgba(15, 23, 42, 0.18);
}

.floor-indicator__label {
    font-size: 11px;
    letter-spacing: 0.4em;
    text-transform: uppercase;
    color: rgba(15, 23, 42, 0.45);
    font-weight: 600;
}

#dungeon-type-overlay {
    position: absolute;
    top: 24px;
    left: 24px;
    z-index: 5;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 22px 24px;
    max-width: min(360px, 45vw);
    border-radius: 20px;
    background: rgba(15, 23, 42, 0.62);
    border: 1px solid rgba(148, 163, 184, 0.45);
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.35);
    color: #e2e8f0;
    backdrop-filter: blur(20px);
    pointer-events: none;
    isolation: isolate;
    opacity: 1;
    transition: opacity 160ms ease-in-out;
}

#dungeon-type-overlay::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(140deg, rgba(59, 130, 246, 0.25), rgba(14, 116, 144, 0.15) 45%, transparent 75%);
    pointer-events: none;
    z-index: -1;
}

#dungeon-type-overlay.dungeon-overlay--dimmed {
    opacity: 0.5;
}

.dungeon-overlay__label {
    font-size: 12px;
    letter-spacing: 0.28em;
    text-transform: uppercase;
    font-weight: 700;
    color: rgba(226, 232, 240, 0.7);
}

.dungeon-overlay__type {
    font-size: clamp(22px, 3.1vw, 30px);
    font-weight: 800;
    letter-spacing: 0.05em;
    text-shadow: 0 4px 20px rgba(59, 130, 246, 0.55);
}

.dungeon-overlay__divider {
    width: 100%;
    height: 1px;
    background: linear-gradient(90deg, rgba(148, 163, 184, 0), rgba(226, 232, 240, 0.5), rgba(148, 163, 184, 0));
}

.dungeon-overlay__features {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.dungeon-overlay__badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.05em;
    background: rgba(226, 232, 240, 0.18);
    border: 1px solid rgba(226, 232, 240, 0.35);
    color: #f8fafc;
    text-shadow: none;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.25);
}

.dungeon-overlay__badge--hazard-dark {
    background: linear-gradient(135deg, rgba(30, 64, 175, 0.55), rgba(17, 24, 39, 0.7));
    border-color: rgba(99, 102, 241, 0.5);
}

.dungeon-overlay__badge--hazard-poison {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.55), rgba(22, 101, 52, 0.65));
    border-color: rgba(74, 222, 128, 0.45);
}

.dungeon-overlay__badge--hazard-noise {
    background: linear-gradient(135deg, rgba(125, 211, 252, 0.55), rgba(99, 102, 241, 0.6));
    border-color: rgba(129, 140, 248, 0.55);
    box-shadow: 0 0 18px rgba(96, 165, 250, 0.35);
}

.dungeon-overlay__badge--type {
    background: linear-gradient(135deg, rgba(14, 116, 144, 0.55), rgba(8, 47, 73, 0.65));
    border-color: rgba(125, 211, 252, 0.45);
}

.dungeon-overlay__badge--neutral {
    background: rgba(226, 232, 240, 0.18);
    color: #f1f5f9;
    border-color: rgba(226, 232, 240, 0.35);
}

.dungeon-overlay__badge--suppressed {
    opacity: 0.6;
    filter: saturate(0.65);
}

.dungeon-overlay__description {
    margin: 0;
    font-size: 13px;
    line-height: 1.6;
    color: rgba(226, 232, 240, 0.82);
}

#dungeon-type-overlay.noise-glitch-card {
    animation: noise-glitch-card 0.18s steps(2) 1;
    filter: hue-rotate(-6deg) saturate(1.25);
}

#dungeon-type-overlay.noise-glitch-card::after {
    content: "";
    position: absolute;
    inset: -4px;
    pointer-events: none;
    background: repeating-linear-gradient(
        180deg,
        rgba(59, 130, 246, 0.12) 0px,
        rgba(59, 130, 246, 0.12) 2px,
        rgba(15, 23, 42, 0) 4px,
        rgba(15, 23, 42, 0) 6px
    );
    mix-blend-mode: screen;
    opacity: 0.55;
    border-radius: inherit;
    animation: noise-glitch-scan 0.18s steps(3) 1;
}

#game-canvas.noise-glitch-canvas {
    animation: noise-glitch-canvas 0.18s steps(2) 1;
    filter: contrast(1.2) saturate(1.25);
}

@keyframes noise-glitch-card {
    0% {
        transform: translate3d(0, 0, 0) skewX(0deg);
        clip-path: inset(0% 0 0 0);
    }
    25% {
        transform: translate3d(-3px, 1px, 0) skewX(-4deg);
        clip-path: inset(4% 0 55% 0);
    }
    50% {
        transform: translate3d(3px, -1px, 0) skewX(3deg);
        clip-path: inset(45% 0 8% 0);
    }
    75% {
        transform: translate3d(-2px, -1px, 0) skewX(2deg);
        clip-path: inset(12% 0 28% 0);
    }
    100% {
        transform: translate3d(0, 0, 0) skewX(0deg);
        clip-path: inset(0% 0 0 0);
    }
}

@keyframes noise-glitch-scan {
    0% {
        opacity: 0.7;
        transform: translate3d(0, -6px, 0);
    }
    50% {
        opacity: 0.4;
        transform: translate3d(0, 4px, 0);
    }
    100% {
        opacity: 0.6;
        transform: translate3d(0, -2px, 0);
    }
}

@keyframes noise-glitch-canvas {
    0% {
        clip-path: inset(0 0 0 0);
        transform: translate3d(0, 0, 0);
    }
    30% {
        clip-path: inset(0 0 68% 0);
        transform: translate3d(-2px, 1px, 0);
    }
    60% {
        clip-path: inset(60% 0 0 0);
        transform: translate3d(3px, -1px, 0);
    }
    80% {
        clip-path: inset(10% 0 36% 0);
        transform: translate3d(-1px, 0, 0);
    }
    100% {
        clip-path: inset(0 0 0 0);
        transform: translate3d(0, 0, 0);
    }
}

.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    overflow: auto; /* 内容がはみ出す場合にスクロール可 */
}

.modal.modal--open {
    display: flex;
}

.modal-content {
    background: linear-gradient(135deg, rgba(255,255,255,0.95) 0%, rgba(255,255,255,0.9) 100%);
    backdrop-filter: blur(15px);
    border-radius: 20px;
    padding: 24px;
    width: 400px;
    max-width: 90vw;
    box-shadow: 0 12px 40px rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.3);
    color: #2c3e50;
    max-height: 90vh;        /* 画面内に収める */
    overflow: auto;          /* モーダル内スクロール */
}

.modal--rare-chest .rare-chest-modal__content {
    width: min(420px, 92vw);
    text-align: center;
    background: radial-gradient(circle at top, rgba(255, 236, 179, 0.95), rgba(255, 215, 128, 0.92));
    border: 2px solid rgba(255, 200, 0, 0.6);
    box-shadow: 0 18px 48px rgba(255, 180, 0, 0.35);
    color: #4d2d00;
}

.rare-chest-status {
    margin: 8px 0 20px;
    font-weight: 600;
    letter-spacing: 0.03em;
}

.rare-chest-bar {
    position: relative;
    width: min(320px, 80vw);
    height: 24px;
    margin: 0 auto 18px;
    border-radius: 999px;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.35), rgba(255, 232, 166, 0.75));
    border: 1px solid rgba(255, 214, 102, 0.8);
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.12), 0 12px 22px rgba(255, 193, 7, 0.25);
    overflow: hidden;
}

.rare-chest-bar__target {
    position: absolute;
    top: 0;
    left: 50%;
    width: 18%;
    height: 100%;
    transform: translateX(-50%);
    background: linear-gradient(180deg, rgba(255, 245, 157, 0.8), rgba(255, 213, 79, 0.6));
    border: 1px solid rgba(255, 213, 79, 0.9);
    box-shadow: inset 0 0 8px rgba(255, 255, 255, 0.6);
    pointer-events: none;
}

.rare-chest-bar__pointer {
    position: absolute;
    top: 0;
    left: 50%;
    width: 6%;
    min-width: 14px;
    height: 100%;
    transform: translateX(-50%);
    border-radius: 6px;
    background: linear-gradient(180deg, #ffd43b, #f08c00);
    box-shadow: 0 0 10px rgba(255, 196, 0, 0.8), 0 0 18px rgba(255, 140, 0, 0.6);
    pointer-events: none;
}

.rare-chest-stop-btn {
    padding: 10px 20px;
    border-radius: 999px;
    border: none;
    background: linear-gradient(135deg, #ff922b, #ffc078);
    color: #4d2d00;
    font-weight: 700;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.rare-chest-stop-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 24px rgba(255, 153, 0, 0.32);
}

.rare-chest-hint {
    margin-top: 10px;
    font-size: 13px;
    color: rgba(77, 45, 0, 0.7);
}

.modal-content.skills-modal {
    width: min(560px, 92vw);
}

.skills-current-sp {
    position: sticky;
    top: 24px;
    z-index: 2;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px 18px;
    margin: 12px 0 20px;
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(255,255,255,0.95), rgba(236,241,255,0.9));
    border: 1px solid rgba(102, 126, 234, 0.3);
    box-shadow: 0 14px 32px rgba(102, 126, 234, 0.18);
    color: rgba(44, 62, 80, 0.85);
    backdrop-filter: blur(12px);
}

.skills-sp-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.skills-sp-label {
    text-transform: uppercase;
    font-size: 13px;
    color: rgba(44, 62, 80, 0.6);
    letter-spacing: 0.08em;
}

.skills-sp-value {
    font-size: 16px;
    font-weight: 700;
    color: rgba(44, 62, 80, 0.9);
}

.skills-sp-bar {
    position: relative;
    width: 100%;
    height: 12px;
    border-radius: 999px;
    background: rgba(102, 126, 234, 0.15);
    overflow: hidden;
}

.skills-sp-bar-fill {
    position: absolute;
    inset: 0;
    width: 0%;
    border-radius: inherit;
    background: linear-gradient(90deg, #667eea, #764ba2);
    box-shadow: 0 0 20px rgba(102, 126, 234, 0.45);
    transition: width 0.25s ease-out;
}

.skills-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 0 0 16px;
}

.skills-list .skill-entry {
    display: flex;
    gap: 12px;
    justify-content: space-between;
    align-items: flex-start;
    padding: 12px 16px;
    border-radius: 12px;
    background: rgba(255,255,255,0.6);
    border: 1px solid rgba(102, 126, 234, 0.25);
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.15);
    color: #2c3e50;
}

.skills-list .skill-entry.locked {
    opacity: 0.65;
}

.skills-list .skill-info {
    flex: 1;
}

.skills-list .skill-name {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 4px;
}

.skills-list .skill-meta {
    font-size: 12px;
    color: rgba(44, 62, 80, 0.7);
    margin-bottom: 4px;
}

.skills-list .skill-desc {
    font-size: 13px;
    line-height: 1.5;
}

.skills-list .skill-entry button {
    align-self: center;
    min-width: 96px;
}

.modal-content h3 {
    margin: 0 0 20px 0;
    text-align: center;
    font-size: 24px;
    color: #2c3e50;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.item-row {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: space-between;
    padding: 12px;
    margin: 8px 0;
    background: rgba(255,255,255,0.6);
    border-radius: 10px;
    border: 1px solid rgba(102, 126, 234, 0.2);
}

.item-row--potion {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
}

.item-row__header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    width: 100%;
}

.item-row__label {
    font-weight: 600;
}

.item-row__count {
    font-weight: 600;
    color: #364fc7;
}

.item-row .item-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.item-row__actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
}

.item-row button {
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.item-row button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.item-row--toggle {
    align-items: flex-start;
    gap: 16px;
}

.item-row__info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    color: #1f2937;
    font-weight: 600;
    flex: 1 1 auto;
}

.item-row__info small {
    font-size: 12px;
    color: #64748b;
    font-weight: 500;
}

.item-row__toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 600;
    color: #4338ca;
    user-select: none;
}

.item-row__toggle input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: #6366f1;
}

.item-section {
    margin: 12px 0 0;
    padding: 12px;
    border-radius: 10px;
    background: rgba(255,255,255,0.65);
    border: 1px solid rgba(102, 126, 234, 0.2);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.item-section__header {
    font-weight: 700;
    font-size: 15px;
    color: #2c3e50;
}

.item-section--passive-orbs {
    gap: 10px;
}

.passive-orb-summary {
    font-size: 13px;
    color: #475569;
    font-weight: 600;
}

.passive-orb-aggregate {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 8px;
}

.passive-orb-aggregate__item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px;
    border-radius: 8px;
    background: rgba(255,255,255,0.85);
    border: 1px solid rgba(102, 126, 234, 0.2);
}

.passive-orb-aggregate__label {
    font-size: 12px;
    color: #475569;
}

.passive-orb-aggregate__value {
    font-weight: 700;
    color: #4338ca;
    font-size: 14px;
}

.passive-orb-aggregate--compact {
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    width: 100%;
}

.passive-orb-aggregate--compact .passive-orb-aggregate__item {
    padding: 8px;
    gap: 2px;
}

.passive-orb-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.passive-orb-row {
    margin: 0;
}

.passive-orb-row + .passive-orb-row {
    margin-top: 8px;
}

.passive-orb-row__info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1 1 auto;
}

.passive-orb-name {
    font-weight: 600;
    color: #1f2937;
}

.passive-orb-effect {
    font-size: 12px;
    color: #64748b;
    font-weight: 500;
}

.passive-orb-count {
    font-weight: 700;
    color: #4338ca;
}

.passive-orb-empty {
    padding: 12px;
    text-align: center;
    color: #64748b;
    background: rgba(255,255,255,0.8);
    border-radius: 8px;
    border: 1px dashed rgba(102, 126, 234, 0.35);
    font-size: 13px;
}

.passive-orb-inventory {
    gap: 8px;
}

.passive-orb-inventory__top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    gap: 8px;
}

.passive-orb-inventory__top .item-name {
    margin-right: auto;
}

@media (max-width: 520px) {
    .passive-orb-aggregate {
        grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    }

    .passive-orb-aggregate--compact {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    }
}

.skill-charm-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.skill-charm-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    border-radius: 8px;
    background: rgba(255,255,255,0.8);
    border: 1px solid rgba(102, 126, 234, 0.2);
    gap: 12px;
}

.skill-charm-item__info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
}

.skill-charm-name {
    font-weight: 700;
    color: #2c3e50;
}

.skill-charm-count {
    font-size: 13px;
    color: #667eea;
}

.skill-charm-use {
    padding: 6px 14px;
    border-radius: 999px;
    border: none;
    background: linear-gradient(135deg, #51cf66, #2f9e44);
    color: white;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 3px 10px rgba(47, 158, 68, 0.3);
}

.skill-charm-use:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(47, 158, 68, 0.35);
}

.skill-charm-empty {
    text-align: center;
    color: rgba(44, 62, 80, 0.6);
    font-size: 13px;
    font-style: italic;
}

.close-modal { 
    margin-top: 16px;
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
    color: white;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.close-modal:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(238, 90, 36, 0.4);
}

/* Game Screen Styling */
#game-screen {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

h1 {
    color: white;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
    font-size: 2.5rem;
    margin-bottom: 20px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Status Modal Styling */
.status-modal {
    width: 500px;
    max-width: 95vw;
}

.status-section {
    margin: 20px 0;
    padding: 16px;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 12px;
    border: 1px solid rgba(102, 126, 234, 0.2);
}

.status-section h4 {
    margin: 0 0 16px 0;
    color: #667eea;
    font-size: 18px;
    font-weight: bold;
    text-align: center;
}

.status-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.status-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: rgba(255,255,255,0.8);
    border-radius: 8px;
    border: 1px solid rgba(102, 126, 234, 0.2);
}

.status-label {
    font-weight: bold;
    color: #2c3e50;
    font-size: 14px;
}

.status-value {
    font-weight: bold;
    font-size: 16px;
    color: #667eea;
}

.status-value.hp {
    color: #ff6b6b;
}

.status-value.attack {
    color: #ff8c42;
}

.status-value.defense {
    color: #74c0fc;
}

.inventory-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.inventory-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: rgba(255,255,255,0.8);
    border-radius: 8px;
    border: 1px solid rgba(102, 126, 234, 0.2);
}

.inventory-item--wide {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
}

.inventory-item--wide .item-count {
    align-self: flex-end;
}

.item-name {
    font-weight: bold;
    color: #2c3e50;
    font-size: 14px;
}

.item-count {
    font-weight: bold;
    color: #667eea;
    font-size: 14px;
}

.settings-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: rgba(255,255,255,0.8);
    border-radius: 8px;
    border: 1px solid rgba(102, 126, 234, 0.2);
}

.setting-label {
    font-weight: bold;
    color: #2c3e50;
    font-size: 14px;
}

.setting-value {
    font-weight: bold;
    color: #667eea;
    font-size: 14px;
}

#message-log {
    margin-top: 12px;
    height: clamp(160px, 24vh, 280px);
    overflow-y: auto;
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(102, 126, 234, 0.2);
    border-radius: 12px;
    padding: 12px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
    line-height: 1.5;
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
}

.log-line { 
    white-space: pre-wrap; 
    color: #2c3e50;
    padding: 2px 0;
    border-radius: 4px;
    margin: 1px 0;
}

.log-sep { 
    color: #667eea; 
    text-align: center;
    font-weight: bold;
    margin: 4px 0;
}

@keyframes gameOverPulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
}

/* ---------------- Tools Tab / Mod Maker ---------------- */
.tools-layout {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 16px;
    width: 100%;
}

.tools-sidebar {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tools-sidebar .tool-item {
    appearance: none;
    border: 1px solid rgba(102,126,234,0.35);
    background: #eef2ff;
    color: #1f2937;
    border-radius: 10px;
    padding: 10px 12px;
    font-weight: 700;
    cursor: pointer;
    text-align: left;
    transition: background 0.2s ease, box-shadow 0.2s ease;
}

.tools-sidebar .tool-item:hover {
    background: #e0e7ff;
    box-shadow: 0 2px 8px rgba(102,126,234,0.25);
}

.tools-sidebar .tool-item.active {
    background: linear-gradient(135deg,#667eea,#764ba2);
    color: #fff;
    box-shadow: 0 4px 14px rgba(102,126,234,0.35);
}

.tool-hint {
    font-size: 12px;
    color: #475569;
    margin: 0;
    line-height: 1.4;
}

.state-manager-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 12px 4px 4px;
}

.state-manager-description {
    margin: 0;
    color: #374151;
    line-height: 1.6;
}

.state-manager-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.state-manager-actions button {
    padding: 10px 18px;
    border-radius: 8px;
    border: none;
    background: linear-gradient(135deg, rgba(99,102,241,0.2), rgba(129,140,248,0.35));
    color: #1e1b4b;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.state-manager-actions button:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(99,102,241,0.25);
}

.state-manager-actions button:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(79,70,229,0.2);
}

.state-manager-status {
    min-height: 1.4em;
    font-size: 14px;
    color: #1f2937;
}

.state-manager-status.success {
    color: #166534;
}

.state-manager-status.error {
    color: #b91c1c;
}

.state-manager-summary {
    margin: 0;
    padding: 12px 14px;
    border-radius: 10px;
    background: rgba(226,232,240,0.6);
    border: 1px solid rgba(148,163,184,0.4);
    color: #1f2937;
    font-size: 13px;
    line-height: 1.5;
    max-height: 260px;
    overflow: auto;
    white-space: pre-wrap;
}

.tool-panel {
    background: rgba(255,255,255,0.92);
    border: 1px solid rgba(102,126,234,0.25);
    border-radius: 16px;
    padding: 16px;
    display: none;
    flex-direction: column;
    gap: 16px;
}

.blockdata-editor {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 16px;
    min-height: 520px;
}

.tool-panel[data-tool-panel="blockdata-editor"] {
    max-height: min(820px, 75vh);
    overflow-y: auto;
}

.sandbox-layout {
    display: grid;
    grid-template-columns: minmax(260px, 320px) 1fr;
    gap: 16px;
    align-items: start;
}

.sandbox-config {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.sandbox-section {
    background: #f8faff;
    border: 1px solid rgba(102,126,234,0.2);
    border-radius: 12px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sandbox-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.sandbox-section-header h4 {
    margin: 0;
    font-size: 18px;
    color: #1f2937;
}

.sandbox-map-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.sandbox-map-actions button,
#sandbox-add-enemy,
.sandbox-start-button,
.sandbox-secondary-button {
    appearance: none;
    border: none;
    border-radius: 8px;
    padding: 8px 12px;
    background: linear-gradient(135deg,#667eea,#764ba2);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(102,126,234,0.35);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.sandbox-map-actions button:hover,
#sandbox-add-enemy:hover,
.sandbox-start-button:hover,
.sandbox-secondary-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102,126,234,0.35);
}

.sandbox-map-actions button:disabled,
.sandbox-start-button:disabled,
.sandbox-secondary-button:disabled {
    background: #cbd5f5;
    box-shadow: none;
    color: #475569;
    cursor: not-allowed;
}

.sandbox-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
}

.sandbox-form-grid label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 13px;
    color: #475569;
}

.sandbox-inline-field {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #475569;
}

.sandbox-inline-field select {
    border: 1px solid rgba(148,163,184,0.5);
    border-radius: 8px;
    padding: 4px 8px;
    font-size: 13px;
    background: #fff;
}

.sandbox-gimmick-layout {
    display: grid;
    grid-template-columns: minmax(180px, 240px) minmax(260px, 320px) 1fr;
    gap: 16px;
    align-items: stretch;
    min-height: 320px;
}

.sandbox-gimmick-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.sandbox-gimmick-list {
    background: rgba(255,255,255,0.96);
    border: 1px solid rgba(148,163,184,0.3);
    border-radius: 12px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 360px;
    overflow-y: auto;
}

.sandbox-gimmick-item {
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 8px;
    background: rgba(241,245,249,0.7);
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
    text-align: left;
}

.sandbox-gimmick-item:hover {
    background: rgba(102,126,234,0.08);
    transform: translateY(-1px);
}

.sandbox-gimmick-item.selected {
    border-color: rgba(99,102,241,0.65);
    background: rgba(99,102,241,0.16);
    box-shadow: 0 6px 16px rgba(99,102,241,0.15);
}

.sandbox-gimmick-item-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    color: #1f2937;
    font-size: 13px;
    margin-bottom: 2px;
}

.sandbox-gimmick-item-main {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.sandbox-gimmick-item-icon {
    font-size: 16px;
    line-height: 1;
}

.sandbox-gimmick-item-name {
    font-size: 13px;
    font-weight: 600;
    color: #1f2937;
}

.sandbox-gimmick-item-type {
    font-size: 11px;
    color: #63748b;
}

.sandbox-gimmick-item-tags {
    font-size: 11px;
    color: #64748b;
}

.sandbox-gimmick-detail {
    background: rgba(255,255,255,0.98);
    border: 1px solid rgba(148,163,184,0.3);
    border-radius: 12px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 360px;
    overflow-y: auto;
}

#sandbox-gimmick-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sandbox-gimmick-tile {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.sandbox-gimmick-tile-actions {
    display: flex;
    gap: 6px;
    align-items: center;
    justify-content: flex-start;
    grid-column: span 2;
}

.sandbox-checkbox {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #475569;
}

.sandbox-checkbox input {
    width: 16px;
    height: 16px;
}

.sandbox-gimmick-config {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sandbox-subheader {
    margin: 0;
    font-size: 13px;
    font-weight: 700;
    color: #1f2937;
}

.sandbox-gimmick-config-fields {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
}

.sandbox-gimmick-config-fields .sandbox-config-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
    color: #475569;
}

.sandbox-gimmick-config-fields input,
.sandbox-gimmick-config-fields select,
.sandbox-gimmick-config-fields textarea {
    border: 1px solid rgba(148,163,184,0.5);
    border-radius: 8px;
    padding: 6px 8px;
    font-size: 13px;
    resize: vertical;
    min-height: 32px;
}

.sandbox-config-control {
    width: 100%;
    box-sizing: border-box;
}

.sandbox-gimmick-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.sandbox-danger-button {
    background: linear-gradient(135deg,#ef4444,#f97316);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 8px 12px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(239,68,68,0.25);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.sandbox-danger-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(239,68,68,0.3);
}

.sandbox-wire-list-wrapper {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sandbox-wire-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 140px;
    overflow-y: auto;
}

.sandbox-wire-item {
    border: 1px solid rgba(148,163,184,0.35);
    border-radius: 10px;
    padding: 6px 8px;
    background: rgba(241,245,249,0.8);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #334155;
}

.sandbox-wire-item.selected {
    border-color: rgba(99,102,241,0.6);
    background: rgba(129,140,248,0.18);
}

.sandbox-wire-item button {
    appearance: none;
    border: none;
    border-radius: 6px;
    padding: 4px 8px;
    background: rgba(239,68,68,0.85);
    color: #fff;
    cursor: pointer;
    font-size: 12px;
}

.sandbox-wire-editor {
    position: relative;
    min-height: 320px;
    border-radius: 16px;
    border: 1px solid rgba(148,163,184,0.4);
    background: linear-gradient(135deg, rgba(148,163,184,0.15), rgba(99,102,241,0.2));
    overflow: hidden;
}

.sandbox-wire-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.sandbox-wire-nodes {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.sandbox-wire-node {
    position: absolute;
    min-width: 140px;
    max-width: 220px;
    background: rgba(255,255,255,0.96);
    border: 1px solid rgba(99,102,241,0.25);
    border-radius: 12px;
    box-shadow: 0 10px 24px rgba(15,23,42,0.18);
    padding: 10px 12px;
    pointer-events: auto;
    cursor: grab;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sandbox-wire-node-header {
    display: flex;
    align-items: center;
    gap: 6px;
}

.sandbox-wire-node-icon {
    font-size: 18px;
    line-height: 1;
}

.sandbox-wire-node-name {
    font-size: 13px;
    font-weight: 600;
    color: #1f2937;
    line-height: 1.2;
}

.sandbox-wire-node.sandbox-wire-node-dragging {
    cursor: grabbing;
    opacity: 0.92;
}

.sandbox-wire-node.selected {
    border-color: rgba(99,102,241,0.9);
    box-shadow: 0 16px 36px rgba(99,102,241,0.25);
}

.sandbox-wire-node h6 {
    margin: 0;
    font-size: 13px;
    color: #1f2937;
}

.sandbox-wire-node .sandbox-wire-node-type {
    font-size: 11px;
    color: #6366f1;
}

.sandbox-wire-ports {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sandbox-wire-ports-wrapper {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.sandbox-wire-ports.inputs,
.sandbox-wire-ports.outputs {
    flex: 1 1 0;
}

.sandbox-wire-port {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #1e293b;
    cursor: pointer;
    transition: transform 0.15s ease;
}

.sandbox-wire-port:hover {
    transform: translateX(2px);
}

.sandbox-wire-port-button {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid rgba(99,102,241,0.5);
    background: #fff;
    flex-shrink: 0;
    position: relative;
}

.sandbox-wire-port-button.output {
    border-color: rgba(234,88,12,0.65);
}

.sandbox-wire-port-button.pending,
.sandbox-wire-port-button.active {
    background: rgba(99,102,241,0.9);
    border-color: rgba(99,102,241,0.95);
}

.sandbox-wire-path {
    fill: none;
    stroke: rgba(99,102,241,0.82);
    stroke-width: 2.5;
    stroke-linecap: round;
    opacity: 0.9;
    transition: stroke-width 0.15s ease, opacity 0.15s ease;
}

.sandbox-wire-path.signal-pulse {
    stroke-dasharray: 8 6;
}

.sandbox-wire-path.signal-value {
    stroke: rgba(234,179,8,0.85);
}

.sandbox-wire-path.selected {
    stroke-width: 3.6;
    opacity: 1;
}

.sandbox-wire-statusbar {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: linear-gradient(180deg, rgba(15,23,42,0), rgba(15,23,42,0.65));
    color: #f8fafc;
    font-size: 12px;
}

.sandbox-wire-statusbar .sandbox-secondary-button {
    background: rgba(255,255,255,0.15);
    box-shadow: none;
    border: 1px solid rgba(255,255,255,0.25);
    color: #f8fafc;
}

.sandbox-wire-statusbar .sandbox-secondary-button:hover {
    background: rgba(255,255,255,0.25);
}

.sandbox-wire-empty {
    font-size: 12px;
    color: #94a3b8;
}

.sandbox-wire-node-dragging {
    cursor: grabbing;
}

.sandbox-wire-editor::after {
    content: "";
    position: absolute;
    inset: 16px;
    border: 2px dashed rgba(148,163,184,0.25);
    border-radius: 12px;
    pointer-events: none;
}

@media (max-width: 1200px) {
    .sandbox-gimmick-layout {
        grid-template-columns: minmax(180px, 240px) minmax(220px, 300px);
        grid-template-rows: auto auto;
    }

    .sandbox-wire-editor {
        grid-column: span 2;
    }
}

.sandbox-form-grid input {
    border: 1px solid rgba(148,163,184,0.5);
    border-radius: 8px;
    padding: 6px 8px;
    font-size: 14px;
}

.sandbox-brush-select {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.sandbox-brush {
    appearance: none;
    border: 1px solid rgba(102,126,234,0.35);
    background: #f8fafc;
    color: #1f2937;
    border-radius: 999px;
    padding: 6px 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.15s ease;
}

.sandbox-brush.active {
    background: linear-gradient(135deg,#5563d7,#7c5bd5);
    color: #fff;
    border-color: rgba(91,109,211,0.8);
    box-shadow: 0 0 0 3px rgba(102,126,234,0.2);
}

.sandbox-brush[aria-pressed="true"],
.sandbox-brush:hover {
    background: linear-gradient(135deg,#667eea,#764ba2);
    color: #fff;
    border-color: transparent;
    transform: translateY(-1px);
}

.sandbox-brush-options {
    margin-top: 12px;
    background: rgba(226,232,240,0.4);
    border-radius: 12px;
    padding: 12px 16px;
}

.sandbox-brush-options h5 {
    margin: 0 0 8px;
    font-size: 14px;
    color: #334155;
}

.sandbox-brush-option-grid {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(auto-fit,minmax(160px,1fr));
}

.sandbox-field-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    color: #1f2937;
}

.sandbox-subsection {
    margin-top: 12px;
    padding: 12px;
    background: rgba(226,232,240,0.45);
    border-radius: 12px;
}

.sandbox-subsection-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.sandbox-maplist {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.sandbox-map-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 220px;
    overflow-y: auto;
    min-width: 180px;
}

.sandbox-map-item {
    appearance: none;
    border: 1px solid rgba(99,102,241,0.25);
    background: #fff;
    border-radius: 10px;
    padding: 8px 12px;
    text-align: left;
    font-size: 13px;
    color: #1f2937;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease;
    position: relative;
}

.sandbox-map-item.entry::before {
    content: '★';
    color: #f59f00;
    margin-right: 6px;
}

.sandbox-map-item:hover {
    box-shadow: 0 6px 12px rgba(99,102,241,0.2);
}

.sandbox-map-item.active {
    background: linear-gradient(135deg,#667eea,#764ba2);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 8px 16px rgba(118,75,162,0.25);
}

.sandbox-map-detail {
    flex: 1;
    display: grid;
    gap: 10px 14px;
    grid-template-columns: repeat(auto-fit,minmax(160px,1fr));
    align-items: end;
}

.sandbox-map-detail input {
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid rgba(148,163,184,0.6);
    background: #fff;
}

.sandbox-maplist-actions {
    display: flex;
    gap: 8px;
}

.sandbox-maplist-actions button {
    appearance: none;
    border: none;
    background: rgba(102,126,234,0.16);
    color: #4338ca;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
}

.sandbox-maplist-actions button:hover {
    background: rgba(102,126,234,0.26);
}

.sandbox-palette-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sandbox-color-palette {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 32px;
}

.sandbox-palette-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(248,250,252,0.8);
    border: 1px solid rgba(148,163,184,0.45);
    border-radius: 10px;
    padding: 4px 6px;
}

.sandbox-palette-apply {
    border: none;
    background: transparent;
    padding: 0;
    cursor: pointer;
}

.sandbox-palette-swatch {
    display: block;
    width: 40px;
    height: 24px;
    border-radius: 6px;
    box-shadow: inset 0 0 0 1px rgba(148,163,184,0.5);
}

.sandbox-palette-remove {
    border: none;
    background: transparent;
    color: #ef4444;
    font-size: 14px;
    cursor: pointer;
}

.sandbox-palette-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.sandbox-palette-actions button {
    appearance: none;
    border: none;
    background: rgba(102,126,234,0.16);
    color: #4338ca;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
}

.sandbox-palette-actions button:hover {
    background: rgba(102,126,234,0.26);
}

.sandbox-palette-actions .sandbox-secondary-button {
    background: rgba(148,163,184,0.18);
    color: #334155;
}

.sandbox-palette-actions .sandbox-secondary-button:hover {
    background: rgba(148,163,184,0.28);
}

.sandbox-portal-card {
    background: rgba(236,233,252,0.6);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 10px;
    border: 1px solid transparent;
    box-shadow: 0 4px 12px rgba(102,126,234,0.14);
}

.sandbox-portal-card.selected {
    border-color: rgba(102,126,234,0.55);
    box-shadow: 0 6px 18px rgba(102,126,234,0.22);
}

.sandbox-portal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.sandbox-portal-actions {
    display: flex;
    gap: 6px;
}

.sandbox-portal-actions button {
    appearance: none;
    border: none;
    background: rgba(76,110,245,0.16);
    color: #3b5bdb;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
}

.sandbox-portal-actions button.delete {
    background: rgba(248,113,113,0.18);
    color: #e03131;
}

.sandbox-portal-actions button:hover {
    background: rgba(76,110,245,0.28);
}

.sandbox-portal-grid {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(auto-fit,minmax(160px,1fr));
}

.sandbox-portal-grid label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
    color: #1f2937;
}

.sandbox-portal-grid input,
.sandbox-portal-grid select {
    padding: 6px 8px;
    border-radius: 6px;
    border: 1px solid rgba(148,163,184,0.5);
    background: #fff;
    font-size: 13px;
}

.sandbox-node-map-dialog {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,0.45);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 80;
    padding: 20px;
}

.sandbox-node-map-dialog.open {
    display: flex;
}

.sandbox-node-map-content {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 50px rgba(15,23,42,0.35);
    padding: 20px;
    width: min(720px, 100%);
    max-height: min(520px, 100%);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sandbox-node-map-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sandbox-modal-close {
    appearance: none;
    border: none;
    background: transparent;
    font-size: 20px;
    cursor: pointer;
    color: #4c51bf;
}

.sandbox-node-map-canvas {
    background: #f8fafc;
    border-radius: 12px;
    padding: 16px;
    overflow: auto;
    min-height: 260px;
}

.node-map-svg {
    width: 100%;
    height: auto;
}

.node-map-edge {
    stroke-width: 2.5;
    stroke: rgba(99,102,241,0.5);
}

.node-map-edge.gate {
    stroke-dasharray: 6 4;
    stroke: rgba(248,148,31,0.65);
}

.node-map-node {
    cursor: pointer;
}

.node-map-node circle {
    fill: #ffffff;
    stroke: rgba(99,102,241,0.35);
    stroke-width: 3;
}

.node-map-node.active circle {
    fill: #667eea;
    stroke: #4338ca;
    stroke-width: 3.5;
}

.node-map-node.entry circle {
    stroke: #f59f00;
    stroke-width: 3.5;
}

.node-map-node text {
    font-size: 15px;
    fill: #1f2937;
    font-weight: 600;
}

.node-map-label {
    font-size: 12px;
    fill: #475569;
}

.sandbox-portal-list .sandbox-note,
.sandbox-map-list .sandbox-note,
.sandbox-color-palette .sandbox-note {
    background: rgba(241,245,249,0.85);
    color: #475569;
    border-radius: 8px;
    padding: 6px 8px;
}

.sandbox-portal-actions .select {
    background: rgba(102,126,234,0.18);
    color: #3b5bdb;
}

.sandbox-portal-actions .select:hover {
    background: rgba(102,126,234,0.28);
}

.sandbox-portal-actions .delete:hover {
    background: rgba(248,113,113,0.28);
}

.sandbox-subsection button:disabled,
.sandbox-map-detail input:disabled,
.sandbox-map-detail select:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.sandbox-palette-actions button:hover {
    transform: translateY(-1px);
}

.sandbox-brush.sandbox-eyedropper-active,
#sandbox-eyedropper-button.active {
    background: linear-gradient(135deg,#22d3ee,#3b82f6);
    color: #fff;
}

.sandbox-field-group select {
    padding: 6px 8px;
    border-radius: 6px;
    border: 1px solid rgba(148,163,184,0.6);
    background: #fff;
    color: #1f2937;
}

.sandbox-field-group.disabled {
    opacity: 0.6;
}

.sandbox-field-group.disabled select {
    pointer-events: none;
    background: #f1f5f9;
}

.sandbox-hint {
    font-size: 11px;
    color: #64748b;
}

.sandbox-color-control {
    display: flex;
    gap: 6px;
    align-items: center;
}

.sandbox-color-control input[type="color"] {
    width: 42px;
    height: 28px;
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 0;
    border-radius: 6px;
    box-shadow: 0 0 0 1px rgba(148,163,184,0.6);
}

.sandbox-color-control input[type="color"][data-has-custom="false"] {
    box-shadow: 0 0 0 1px rgba(148,163,184,0.35);
}

.sandbox-color-clear {
    appearance: none;
    border: none;
    background: rgba(99,102,241,0.12);
    color: #4338ca;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.sandbox-color-clear:hover {
    background: rgba(99,102,241,0.22);
}

.sandbox-color-hint {
    font-size: 12px;
    color: #475569;
}

.sandbox-note.small {
    font-size: 12px;
    color: #64748b;
    margin-top: 10px;
}

.sandbox-selected-cell {
    margin: 0;
    font-size: 13px;
    color: #1f2937;
}

.sandbox-player-preview {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 13px;
    color: #1f2937;
}

.sandbox-player-preview .label {
    font-weight: 600;
    color: #4c51bf;
}

.sandbox-note {
    margin: 0;
    font-size: 12px;
    color: #4b5563;
    background: rgba(102,126,234,0.12);
    border-radius: 8px;
    padding: 6px 8px;
}

.sandbox-interactive-toggle {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid rgba(148, 163, 184, 0.4);
}

.sandbox-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: #1f2937;
}

.sandbox-toggle input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

.sandbox-map-wrapper {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sandbox-map-header h4 {
    margin: 0;
    font-size: 18px;
    color: #1f2937;
}

.sandbox-grid {
    --sandbox-cell-size: 28px;
    background: #f1f5f9;
    border: 1px solid rgba(102,126,234,0.2);
    border-radius: 12px;
    padding: 12px;
    max-height: 480px;
    overflow: auto;
    user-select: none;
    touch-action: none;
}

.sandbox-grid canvas {
    display: block;
    cursor: pointer;
    image-rendering: pixelated;
}

.sandbox-cell {
    width: var(--sandbox-cell-size);
    height: var(--sandbox-cell-size);
    border: none;
    border-radius: 6px;
    --sandbox-cell-bg: #e2e8f0;
    --sandbox-cell-fg: #1f2937;
    background: var(--sandbox-cell-bg);
    color: var(--sandbox-cell-fg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.sandbox-cell:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(148,163,184,0.35);
}

.sandbox-cell.wall {
    --sandbox-cell-bg: var(--sandbox-wall-color, #1f2937);
    --sandbox-cell-fg: #f8fafc;
}

.sandbox-cell.floor {
    --sandbox-cell-bg: var(--sandbox-floor-color, #e5edff);
}

.sandbox-cell.floor-ice {
    --sandbox-floor-color: #74c0fc;
}

.sandbox-cell.floor-poison {
    --sandbox-floor-color: #94d82d;
}

.sandbox-cell.start {
    background: linear-gradient(135deg,#22d3ee,#6366f1);
    color: #fff;
}

.sandbox-cell.stairs {
    background: linear-gradient(135deg,#fbbf24,#f97316);
    color: #1f2937;
}

.sandbox-cell.enemy {
    box-shadow: inset 0 0 0 2px rgba(99,102,241,0.8);
    color: #312e81;
}

.sandbox-cell.enemy.selected-enemy {
    box-shadow: inset 0 0 0 3px rgba(245,158,11,0.85);
    color: #b45309;
}

.sandbox-cell.selected {
    outline: 2px solid #f59e0b;
    outline-offset: 1px;
}

.sandbox-legend {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 8px;
    margin: 0;
}

.sandbox-legend div {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #475569;
}

.sandbox-legend dt {
    margin: 0;
    font-weight: 700;
    font-size: 14px;
}

.sandbox-legend dt.legend-ice {
    color: #1d4ed8;
}

.sandbox-legend dt.legend-poison {
    color: #3f6212;
}

.sandbox-legend dt.legend-bomb {
    color: #b91c1c;
}

.sandbox-legend dt.legend-conveyor {
    color: #b7791f;
}

.sandbox-legend dt.legend-oneway {
    color: #6b21a8;
}

.sandbox-legend dt.legend-vertical {
    color: #0f766e;
}

.sandbox-legend dt.legend-horizontal {
    color: #b45309;
}

.sandbox-legend dd {
    margin: 0;
}

.sandbox-enemy-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 320px;
    overflow: auto;
}

.sandbox-enemy-card {
    border: 1px solid rgba(148,163,184,0.5);
    border-radius: 10px;
    padding: 10px;
    background: #fff;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sandbox-enemy-card.selected {
    border-color: #6366f1;
    box-shadow: 0 0 0 2px rgba(99,102,241,0.25);
}

.sandbox-enemy-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.sandbox-enemy-header h5 {
    margin: 0;
    font-size: 15px;
    color: #1f2937;
}

.sandbox-enemy-actions {
    display: flex;
    gap: 8px;
}

.sandbox-enemy-actions button {
    appearance: none;
    border: none;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
}

.sandbox-enemy-actions button.select {
    background: rgba(99,102,241,0.12);
    color: #4338ca;
}

.sandbox-enemy-actions button.delete {
    background: rgba(248,113,113,0.2);
    color: #b91c1c;
}

.sandbox-enemy-actions button:hover {
    filter: brightness(0.95);
}

.sandbox-enemy-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 8px;
    font-size: 12px;
}

.sandbox-enemy-grid label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    color: #475569;
}

.sandbox-domain-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 320px;
    overflow: auto;
}

.sandbox-domain-card {
    border: 1px solid rgba(129, 140, 248, 0.4);
    border-radius: 10px;
    padding: 10px;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sandbox-domain-card.selected {
    border-color: #4f46e5;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.sandbox-domain-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.sandbox-domain-header h5 {
    margin: 0;
    font-size: 15px;
    color: #312e81;
}

.sandbox-domain-actions {
    display: flex;
    gap: 8px;
}

.sandbox-domain-actions button {
    appearance: none;
    border: none;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
}

.sandbox-domain-actions button.select {
    background: rgba(79, 70, 229, 0.12);
    color: #4338ca;
}

.sandbox-domain-actions button.select:hover {
    background: rgba(79, 70, 229, 0.22);
}

.sandbox-domain-actions button.delete {
    background: rgba(248, 113, 113, 0.2);
    color: #b91c1c;
}

.sandbox-domain-actions button.delete:hover {
    background: rgba(248, 113, 113, 0.35);
}

.sandbox-domain-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 8px;
}

.sandbox-domain-grid label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
    color: #1f2937;
}

.sandbox-domain-grid input,
.sandbox-domain-grid select {
    padding: 4px 6px;
    border-radius: 6px;
    border: 1px solid rgba(148, 163, 184, 0.6);
    font-size: 12px;
}

.sandbox-enemy-grid input,
.sandbox-enemy-grid textarea {
    border: 1px solid rgba(148,163,184,0.5);
    border-radius: 6px;
    padding: 6px 8px;
    font-size: 13px;
}

.sandbox-enemy-grid label.checkbox {
    flex-direction: row;
    align-items: center;
    gap: 6px;
}

.sandbox-validation {
    min-height: 24px;
    font-size: 13px;
    color: #b91c1c;
}

.sandbox-start {
    gap: 16px;
}

.sandbox-start-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.sandbox-primary-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.sandbox-secondary-button {
    background: linear-gradient(135deg,#1f2937,#334155);
    box-shadow: 0 2px 8px rgba(51,65,85,0.35);
}

.sandbox-secondary-button:hover {
    box-shadow: 0 4px 12px rgba(51,65,85,0.35);
}

.sandbox-warning {
    font-size: 12px;
    color: #b45309;
    background: rgba(251,191,36,0.2);
    padding: 6px 8px;
    border-radius: 6px;
}

.sandbox-io-status {
    font-size: 13px;
    margin-top: 8px;
    min-height: 18px;
}

.sandbox-io-status[data-tone="success"] {
    color: #15803d;
}

.sandbox-io-status[data-tone="error"] {
    color: #b91c1c;
}

.sandbox-io-status[data-tone="info"] {
    color: #1d4ed8;
}

@media (max-width: 980px) {
    .sandbox-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .sandbox-grid {
        --sandbox-cell-size: 24px;
    }
    .sandbox-enemy-grid {
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    }
}

.blockdata-sidebar {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.blockdata-group {
    background: linear-gradient(135deg, rgba(102,126,234,0.12), rgba(118,75,162,0.12));
    border: 1px solid rgba(102,126,234,0.25);
    border-radius: 12px;
    padding: 12px;
}

.blockdata-group-label {
    font-size: 13px;
    font-weight: 700;
    color: #4c51bf;
}

.blockdata-group-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
}

.blockdata-group-button {
    appearance: none;
    border: 1px solid rgba(102,126,234,0.35);
    background: #f8fafc;
    color: #1f2937;
    border-radius: 10px;
    padding: 10px 12px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.2s ease, transform 0.2s ease;
}

.blockdata-group-button .count {
    font-size: 12px;
    color: #6366f1;
}

.blockdata-group-button:hover {
    background: #e0e7ff;
    transform: translateY(-1px);
}

.blockdata-group-button.active {
    background: linear-gradient(135deg,#667eea,#764ba2);
    color: #fff;
    border-color: transparent;
}

.blockdata-group-button.active .count {
    color: rgba(255,255,255,0.85);
}

.blockdata-search {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    color: #475569;
}

.blockdata-search input {
    border: 1px solid rgba(148,163,184,0.5);
    border-radius: 10px;
    padding: 8px 10px;
    font-size: 14px;
}

.blockdata-sidebar-actions {
    display: flex;
    gap: 8px;
}

.blockdata-primary,
.blockdata-danger,
.blockdata-file-actions button {
    appearance: none;
    border: none;
    border-radius: 10px;
    padding: 10px 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.blockdata-primary {
    background: linear-gradient(135deg,#667eea,#764ba2);
    color: #fff;
    box-shadow: 0 4px 12px rgba(102,126,234,0.35);
}

.blockdata-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(102,126,234,0.4);
}

.blockdata-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}

.blockdata-danger {
    background: linear-gradient(135deg,#f87171,#fbb6b6);
    color: #fff;
    box-shadow: 0 4px 12px rgba(248,113,113,0.3);
}

.blockdata-danger:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(248,113,113,0.35);
}

.blockdata-danger:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    box-shadow: none;
}

.blockdata-list {
    flex: 1;
    background: rgba(255,255,255,0.8);
    border: 1px solid rgba(148,163,184,0.35);
    border-radius: 12px;
    padding: 8px;
    overflow: auto;
    min-height: 220px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.blockdata-item {
    appearance: none;
    border: 1px solid rgba(148,163,184,0.35);
    border-radius: 10px;
    padding: 10px 12px;
    background: #f8fafc;
    text-align: left;
    cursor: pointer;
    display: grid;
    grid-template-columns: minmax(0,1fr) auto;
    gap: 8px;
    font-size: 14px;
    transition: background 0.2s ease, box-shadow 0.2s ease;
}

.blockdata-item strong {
    color: #1f2937;
}

.blockdata-item span.meta {
    font-size: 12px;
    color: #475569;
}

.blockdata-item:hover {
    background: #e0e7ff;
    box-shadow: 0 2px 8px rgba(102,126,234,0.25);
}

.blockdata-item.active {
    background: linear-gradient(135deg,#667eea,#764ba2);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 4px 14px rgba(102,126,234,0.35);
}

.blockdata-item.active span.meta {
    color: rgba(255,255,255,0.9);
}

.blockdata-empty {
    font-size: 13px;
    color: #64748b;
    text-align: center;
    padding: 24px 8px;
}

.blockdata-main {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.blockdata-filebar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.blockdata-version {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    color: #475569;
}

#blockdata-version {
    width: 120px;
    border: 1px solid rgba(148,163,184,0.5);
    border-radius: 10px;
    padding: 8px 10px;
    font-size: 14px;
}

.blockdata-file-actions {
    margin-left: auto;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.blockdata-file-actions button {
    background: #e0e7ff;
    color: #1f2937;
    border: 1px solid rgba(102,126,234,0.2);
    box-shadow: 0 2px 6px rgba(102,126,234,0.2);
}

.blockdata-file-actions button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102,126,234,0.25);
}

.blockdata-dirty {
    font-size: 13px;
    color: #475569;
    margin: 0;
}

.blockdata-dirty.is-dirty {
    color: #be123c;
    font-weight: 600;
}

.blockdata-status {
    min-height: 20px;
    font-size: 13px;
    color: #475569;
    margin: 0;
}

.blockdata-status.error {
    color: #b91c1c;
}

.blockdata-status.success {
    color: #15803d;
}

.blockdata-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.blockdata-form-grid label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    color: #475569;
}

.blockdata-form-grid label.full {
    grid-column: 1 / -1;
}

.blockdata-form-grid input,
.blockdata-form-grid select,
.blockdata-form-grid textarea {
    border: 1px solid rgba(148,163,184,0.5);
    border-radius: 10px;
    padding: 8px 10px;
    font-size: 14px;
}

.blockdata-form-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.blockdata-preview-section {
    background: rgba(248,250,252,0.95);
    border: 1px solid rgba(148,163,184,0.35);
    border-radius: 12px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.blockdata-preview-section header {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.blockdata-preview-section h4 {
    margin: 0;
    font-size: 16px;
}

.blockdata-preview-size {
    font-size: 12px;
    color: #64748b;
}

#blockdata-json-preview {
    width: 100%;
    min-height: 220px;
    border: 1px solid rgba(148,163,184,0.45);
    border-radius: 10px;
    padding: 12px;
    font-family: 'Fira Code', 'SFMono-Regular', Consolas, 'Courier New', monospace;
    font-size: 13px;
    background: rgba(255,255,255,0.92);
    color: #1f2937;
    resize: vertical;
}

.blockdata-main fieldset[disabled] {
    opacity: 0.6;
    pointer-events: none;
}

@media (max-width: 1200px) {
    .blockdata-editor {
        grid-template-columns: 1fr;
    }
    .blockdata-sidebar {
        flex-direction: row;
        flex-wrap: wrap;
    }
    .blockdata-group,
    .blockdata-search,
    .blockdata-sidebar-actions {
        flex: 1 1 260px;
    }
    .blockdata-list {
        flex: 1 1 100%;
        max-height: 260px;
    }
}

@media (max-width: 768px) {
    .blockdata-form-grid {
        grid-template-columns: 1fr;
    }
    .blockdata-filebar {
        flex-direction: column;
        align-items: flex-start;
    }
    .blockdata-file-actions {
        margin-left: 0;
    }
}

.tool-panel.active { display: flex; }

.tool-panel-header h3 {
    margin: 0 0 4px 0;
    font-size: 20px;
    color: #1f2937;
}

.tool-panel-header p {
    margin: 0;
    font-size: 13px;
    color: #4b5563;
}

.modmaker-section {
    background: #f8f9ff;
    border: 1px solid rgba(102,126,234,0.2);
    border-radius: 12px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.section-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.section-title-row h4 {
    margin: 0;
    font-size: 18px;
    color: #1f2937;
}

.section-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.section-actions button,
.modmaker-template-bar button,
.modmaker-grid-toolbar .toolbar-buttons button,
.modmaker-output-actions button,
.modmaker-add-block {
    appearance: none;
    border: none;
    border-radius: 8px;
    padding: 8px 12px;
    background: linear-gradient(135deg,#667eea,#764ba2);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(102,126,234,0.35);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.section-actions button:hover,
.modmaker-template-bar button:hover,
.modmaker-grid-toolbar .toolbar-buttons button:hover,
.modmaker-output-actions button:hover,
.modmaker-add-block:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102,126,234,0.35);
}

.section-actions button:disabled,
.modmaker-output-actions button:disabled {
    background: #cbd5f5;
    box-shadow: none;
    cursor: not-allowed;
    color: #475569;
}

.modmaker-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.modmaker-form-grid label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 13px;
}

.modmaker-form-grid label.checkbox-row {
    flex-direction: row;
    align-items: center;
    gap: 6px;
}

.modmaker-form-grid label.full {
    grid-column: 1 / -1;
}

.modmaker-form-grid input,
.modmaker-form-grid textarea,
.modmaker-template-bar select,
.modmaker-template-bar label {
    font-weight: normal;
}

.modmaker-form-grid input,
.modmaker-form-grid textarea,
.modmaker-template-bar select {
    padding: 8px 10px;
    border: 1px solid rgba(102,126,234,0.4);
    border-radius: 8px;
    font-size: 14px;
    background: #fff;
}

.modmaker-form-grid textarea,
.modmaker-output textarea,
#modmaker-generator-code,
#modmaker-pattern-preview,
#modmaker-output {
    font-family: "Fira Code", "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

.modmaker-form-grid textarea { resize: vertical; }

.modmaker-structures,
.modmaker-generators {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 12px;
}

.modmaker-list {
    background: #fff;
    border: 1px solid rgba(102,126,234,0.3);
    border-radius: 10px;
    padding: 6px;
    max-height: 320px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.modmaker-list button {
    appearance: none;
    border: 1px solid rgba(102,126,234,0.2);
    border-radius: 8px;
    padding: 8px 10px;
    background: #eef2ff;
    color: #1f2937;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
}

.modmaker-list button.active {
    background: linear-gradient(135deg,#667eea,#764ba2);
    color: #fff;
}

.modmaker-grid-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 12px;
    color: #475569;
}

.modmaker-grid {
    position: relative;
    background: #fff;
    border: 1px solid rgba(102,126,234,0.3);
    border-radius: 10px;
    padding: 8px;
    overflow: auto;
    max-width: 100%;
    min-height: 140px;
}

.modmaker-grid canvas {
    display: block;
    background: #f8fafc;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.2);
}

.modmaker-grid.placeholder canvas {
    display: none;
}

.modmaker-grid-placeholder {
    position: absolute;
    inset: 8px;
    display: none;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 13px;
    color: #6b7280;
    pointer-events: none;
    padding: 8px;
    border-radius: 8px;
}

.modmaker-grid.placeholder .modmaker-grid-placeholder {
    display: flex;
}

.modmaker-fixed {
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: opacity 0.2s ease;
}

.modmaker-fixed.disabled {
    opacity: 0.5;
    pointer-events: none;
}

.modmaker-fixed-note {
    font-size: 12px;
    color: #4b5563;
    margin: 0;
}

.modmaker-fixed-editor {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

@media (min-width: 960px) {
    .modmaker-fixed-editor {
        flex-direction: row;
        align-items: flex-start;
    }
}

.fixed-floor-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.fixed-floor-list button {
    min-width: 56px;
}

.modmaker-fixed-grid-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.modmaker-fixed-sizebar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.modmaker-fixed-sizebar label {
    display: flex;
    flex-direction: column;
    font-size: 13px;
    color: #1f2937;
}

.modmaker-fixed-sizebar input {
    width: 88px;
}

#modmaker-fixed-copy-prev {
    margin-left: auto;
}

.modmaker-cell {
    width: 22px;
    height: 22px;
    border: 1px solid rgba(148,163,184,0.4);
    border-radius: 4px;
    background: #f8fafc;
    color: #0f172a;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
}

.modmaker-cell.state-floor {
    background: #bbf7d0;
    border-color: #4ade80;
}

.modmaker-cell.state-wall {
    background: #fecaca;
    border-color: #f87171;
}

.modmaker-cell.state-void {
    background: #e2e8f0;
    border-color: #94a3b8;
    box-shadow: inset 0 0 0 1px rgba(148,163,184,0.35);
}

.modmaker-cell.anchor::after {
    content: '';
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #312e81;
    box-shadow: 0 0 0 2px rgba(99,102,241,0.35);
}

.modmaker-structure-editor,
.modmaker-generator-editor {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.modmaker-template-bar {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    font-size: 13px;
    color: #1f2937;
}

.modmaker-template-bar select {
    min-width: 180px;
}

.modmaker-generator-editor textarea,
.modmaker-structure-editor textarea,
.modmaker-output textarea {
    width: 100%;
    box-sizing: border-box;
    background: #0f172a;
    color: #e2e8f0;
    border: 1px solid rgba(148,163,184,0.4);
    border-radius: 10px;
    padding: 10px;
}

.modmaker-output textarea { min-height: 220px; }

.modmaker-blocks {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

.modmaker-block-tier {
    background: #fff;
    border: 1px solid rgba(102,126,234,0.25);
    border-radius: 10px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.modmaker-block-tier h5 {
    margin: 0;
    font-size: 15px;
    color: #1f2937;
}

.modmaker-block-card {
    border: 1px solid rgba(148,163,184,0.4);
    border-radius: 10px;
    padding: 8px;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.modmaker-block-card header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 700;
}

.modmaker-block-card header button {
    appearance: none;
    border: none;
    background: transparent;
    color: #ef4444;
    font-weight: 700;
    cursor: pointer;
}

.modmaker-block-card header button:hover {
    text-decoration: underline;
}

.modmaker-block-card label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
}

.modmaker-block-card input,
.modmaker-block-card select,
.modmaker-block-card textarea {
    padding: 6px 8px;
    border: 1px solid rgba(148,163,184,0.5);
    border-radius: 8px;
    font-size: 13px;
    background: #fff;
}

.modmaker-block-card textarea { resize: vertical; min-height: 60px; }

.modmaker-errors {
    color: #dc2626;
    font-size: 13px;
    line-height: 1.6;
    min-height: 20px;
}

.modmaker-errors ul {
    margin: 4px 0 0 16px;
    padding: 0;
}

.modmaker-errors li { margin-bottom: 2px; }

.modmaker-output-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.run-result {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(8, 10, 24, 0.8);
    backdrop-filter: blur(4px);
    z-index: 4000;
}

.run-result.run-result--visible {
    display: flex !important;
}

.run-result__card {
    background: linear-gradient(155deg, #0b1024, #161a33);
    color: #f8fafc;
    width: min(520px, 100%);
    border-radius: 24px;
    padding: 32px 36px;
    box-shadow: 0 28px 60px rgba(5, 8, 24, 0.5);
    border: 1px solid rgba(148, 163, 184, 0.2);
}

.run-result__badge {
    display: inline-block;
    font-size: 14px;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: #74c0fc;
    background: rgba(116, 192, 252, 0.12);
    padding: 6px 14px;
    border-radius: 999px;
    margin-bottom: 14px;
    font-weight: 700;
}

.run-result__title {
    margin: 0 0 24px;
    font-size: 32px;
    letter-spacing: 0.16em;
    text-align: center;
}

.run-result__cause {
    margin: 0 0 24px;
    font-size: 14px;
    line-height: 1.6;
    color: #cbd5f5;
    text-align: center;
}

.run-result__list {
    margin: 0 0 28px;
    padding: 0;
}

.run-result__row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 16px;
    padding: 12px 0;
    border-bottom: 1px solid rgba(148, 163, 184, 0.18);
}

.run-result__row:first-of-type {
    border-top: 1px solid rgba(148, 163, 184, 0.18);
}

.run-result__row dt {
    margin: 0;
    font-size: 16px;
    color: #94a3c8;
    letter-spacing: 0.08em;
}

.run-result__row dd {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: #f1f5ff;
}

.run-result__row--level dd {
    font-size: 36px;
    letter-spacing: 0.08em;
}

.run-result__actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    flex-wrap: wrap;
}

.run-result__btn {
    border: none;
    border-radius: 999px;
    padding: 12px 24px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.run-result__btn:focus {
    outline: 2px solid rgba(116, 192, 252, 0.6);
    outline-offset: 2px;
}

.run-result__btn--primary {
    background: linear-gradient(135deg, #4dabf7, #74c0fc);
    color: #071022;
    box-shadow: 0 12px 26px rgba(73, 167, 246, 0.4);
}

.run-result__btn--primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 18px 32px rgba(73, 167, 246, 0.48);
}

.run-result__btn--retry {
    background: rgba(148, 163, 184, 0.18);
    color: #e2e8f0;
    border: 1px solid rgba(148, 163, 184, 0.32);
}

.run-result__btn--retry:hover {
    transform: translateY(-1px);
    background: rgba(148, 163, 184, 0.28);
}

@media (max-width: 520px) {
    .run-result__card {
        padding: 28px 24px;
    }
    .run-result__row {
        flex-direction: column;
        align-items: flex-start;
    }
    .run-result__row dd {
        font-size: 22px;
    }
    .run-result__row--level dd {
        font-size: 32px;
    }
    .run-result__actions {
        justify-content: center;
    }
}

@media (max-width: 980px) {
    .tools-layout { grid-template-columns: 1fr; }
    .tools-sidebar { flex-direction: row; flex-wrap: wrap; }
    .tools-sidebar .tool-item { flex: 1 1 160px; text-align: center; }
    .tool-hint { width: 100%; }
    .modmaker-structures,
    .modmaker-generators { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
    .modmaker-blocks { grid-template-columns: 1fr; }
}
