/* Override cinematic fixed-positioning for any panel wrapped in fwin */
.fwin #story-panel,
.fwin #character-panel,
.fwin .panel {
    position: static !important;
    transform: none !important;
    width: auto !important;
    max-width: none !important;
    max-height: none !important;
    bottom: auto !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    background: transparent !important;
    backdrop-filter: none !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    padding: 12px 14px !important;
    z-index: auto !important;
}

/* ===== Generic floating windows (WindowManager) ===== */
.fwin {
    position: fixed;
    background: rgba(8, 12, 30, 0.92);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(100, 200, 255, 0.25);
    border-radius: 10px;
    box-shadow: 0 12px 36px rgba(0,0,0,0.55), 0 0 0 1px rgba(255,255,255,0.04) inset;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    color: #d8e2f0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.fwin.dragging,
.fwin.resizing { box-shadow: 0 18px 48px rgba(0,0,0,0.7), 0 0 0 1px #6acaff inset; }
.fwin-header {
    flex: 0 0 auto;
    height: 32px;
    padding: 0 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(180deg, rgba(40,60,100,0.6), rgba(20,30,55,0.6));
    border-bottom: 1px solid rgba(100,200,255,0.15);
    cursor: grab;
    font-size: 0.85em;
    color: #b8c4d6;
    user-select: none;
}
.fwin-header:active { cursor: grabbing; }
.fwin-title { font-weight: 600; letter-spacing: 0.3px; }
.fwin-controls { display: flex; gap: 4px; }
.fwin-btn {
    background: transparent;
    border: 1px solid rgba(100,200,255,0.2);
    color: #b8c4d6;
    width: 22px; height: 22px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.95em;
    line-height: 1;
    padding: 0;
}
.fwin-btn:hover { background: rgba(100,200,255,0.15); color: #6acaff; }
.fwin-body {
    flex: 1 1 auto;
    overflow: auto;
    position: relative;
}
.fwin.minimized .fwin-body,
.fwin.minimized .fwin-resize { display: none; }
.fwin.minimized { height: auto !important; }
.fwin-resize {
    position: absolute; bottom: 0; right: 0;
    width: 16px; height: 16px;
    cursor: nwse-resize;
    background:
        linear-gradient(135deg, transparent 0 50%, rgba(100,200,255,0.4) 50% 60%, transparent 60% 70%, rgba(100,200,255,0.4) 70% 80%, transparent 80%);
}

/* ===== Toolbar ===== */
#fwin-toolbar {
    position: fixed;
    bottom: 18px;
    right: 18px;
    z-index: 200;
    display: flex;
    gap: 6px;
    background: rgba(8, 12, 30, 0.85);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(100, 200, 255, 0.25);
    border-radius: 999px;
    padding: 6px;
    box-shadow: 0 6px 18px rgba(0,0,0,0.5);
}
#fwin-toolbar button {
    background: transparent;
    border: none;
    color: #d8e2f0;
    width: 36px; height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.05em;
    transition: background 0.15s;
}
#fwin-toolbar button:hover { background: rgba(100,200,255,0.18); }

/* ===== Inventory ===== */
.inv-host { padding: 10px 12px 14px; font-size: 0.9em; }
.inv-empty { padding: 18px; text-align: center; color: #8e9dac; font-style: italic; }
.inv-currency {
    display: flex; gap: 12px; align-items: center;
    padding: 8px 10px; margin-bottom: 10px;
    background: rgba(255,255,255,0.04); border-radius: 6px;
    flex-wrap: wrap;
}
.inv-currency .coin { font-weight: 600; }
.inv-currency .coin.gp { color: #ffcd55; }
.inv-currency .coin.sp { color: #c8d8e8; }
.inv-currency .coin.cp { color: #c98a55; }
.inv-currency .coin em { font-style: normal; opacity: 0.7; font-weight: 400; font-size: 0.85em; }
.inv-currency .inv-weight { margin-left: auto; font-size: 0.85em; color: #8e9dac; }
.inv-currency .inv-overweight { color: #ff8a55; margin-left: 8px; }
.inv-section { margin-bottom: 10px; }
.inv-section h4 { margin: 4px 0; font-size: 0.85em; color: #6acaff; letter-spacing: 0.5px; }
.inv-section ul { list-style: none; padding: 0; margin: 0; }
.inv-row {
    padding: 6px 8px; border-radius: 5px; margin-bottom: 3px;
    background: rgba(255,255,255,0.025);
    display: flex; flex-direction: column; gap: 3px;
}
.inv-row.equipped { border-left: 3px solid #6acaff; background: rgba(106,202,255,0.1); }
.inv-row-main { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.inv-name { font-weight: 500; }
.inv-tag {
    font-size: 0.75em;
    padding: 1px 6px; border-radius: 8px;
    background: rgba(106,202,255,0.18); color: #b8d8ec;
}
.inv-tag.attune { background: rgba(255,180,80,0.18); color: #ffd599; }
.inv-desc { font-size: 0.8em; color: #98a4b8; opacity: 0.9; }
.inv-row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.inv-row-actions button {
    background: rgba(100,200,255,0.1);
    border: 1px solid rgba(100,200,255,0.25);
    color: #d8e2f0;
    padding: 2px 8px; border-radius: 4px; font-size: 0.8em;
    cursor: pointer;
}
.inv-row-actions button:hover { background: rgba(100,200,255,0.2); }
.inv-actions { margin-top: 12px; text-align: center; }
.inv-btn {
    background: rgba(100,200,255,0.15);
    border: 1px solid rgba(100,200,255,0.35);
    color: #d8e2f0; padding: 6px 14px;
    border-radius: 5px; cursor: pointer;
}
.inv-btn:hover { background: rgba(100,200,255,0.25); }

/* ===== Dungeon Map ===== */
.map-host { display: flex; flex-direction: column; height: 100%; }
.map-toolbar {
    flex: 0 0 auto;
    display: flex; gap: 6px; align-items: center;
    padding: 6px 8px;
    background: rgba(255,255,255,0.04);
    border-bottom: 1px solid rgba(100,200,255,0.15);
    font-size: 0.85em;
    flex-wrap: wrap;
}
.map-toolbar select, .map-toolbar button {
    background: rgba(100,200,255,0.1);
    border: 1px solid rgba(100,200,255,0.25);
    color: #d8e2f0;
    padding: 3px 8px; border-radius: 4px; cursor: pointer;
    font-size: 0.9em;
}
.map-toolbar button:hover, .map-toolbar select:hover { background: rgba(100,200,255,0.2); }
.map-turn { margin-left: auto; color: #7cff7c; font-weight: 500; font-size: 0.85em; }
.map-canvas-wrap {
    flex: 1 1 auto;
    overflow: auto;
    background: #000;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 6px;
}
.map-canvas { display: block; image-rendering: pixelated; }
.map-legend {
    flex: 0 0 auto;
    padding: 6px 10px;
    background: rgba(0,0,0,0.4);
    border-top: 1px solid rgba(100,200,255,0.15);
    font-size: 0.8em;
}
.legend-tokens { display: flex; gap: 12px; flex-wrap: wrap; }
.legend-item { display: inline-flex; align-items: center; gap: 4px; }
.legend-item em { font-style: normal; opacity: 0.8; }
.legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }
.legend-init { margin-top: 4px; color: #b8c4d6; }
