/* CSS Reset & Basic Styles */
#fade-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: #000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease-in-out;
    z-index: 9999;
}

#fade-overlay.active {
    opacity: 1;
    pointer-events: all;
}

/* Retro PC Game Style */
:root {
    --bg-color: #000000;
    --text-color: #e0e0e0;
    --accent-color: #ffffff;
    --border-color: #ffffff;
    --font-family: 'Noto Sans JP', sans-serif;
    --font-serif: 'RocknRoll One', sans-serif;
    --font-mono: 'Roboto Mono', monospace;

    /* Theme Colors */
    --gold-primary: #d4af37;
    --gold-dim: #b8860b;
    --gold-pale: #dec674;
    --bronze-dark: #3a2e1d;
    --bronze-outline: #5e4b32;
    --amber-glow: rgba(184, 134, 11, 0.15);
    --success-green: #00ff88;
    --hp-green: #28e038;
    --blue-primary: #00d2ff;
    --blue-accent: #00aaff;

    color-scheme: dark;
}

/* Global Autofill & Focus Fixes */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 100px #000 inset !important;
    -webkit-text-fill-color: #dec674 !important;
    transition: background-color 5000s ease-in-out 0s;
}

input:focus,
select:focus,
textarea:focus {
    background-color: #000 !important;
    color: #dec674 !important;
}

/* Global Scrollbar Utility & Base Application */
.retro-scroll,
.log-container,
.status-container,
.char-list,
#inv-item-list {
    scrollbar-width: thin;
    scrollbar-color: #CCC #111;
}

.retro-scroll::-webkit-scrollbar,
.log-container::-webkit-scrollbar,
.status-container::-webkit-scrollbar,
.char-list::-webkit-scrollbar,
#inv-item-list::-webkit-scrollbar {
    width: 6px;
}

.retro-scroll::-webkit-scrollbar-track,
.log-container::-webkit-scrollbar-track,
.status-container::-webkit-scrollbar-track,
.char-list::-webkit-scrollbar-track,
#inv-item-list::-webkit-scrollbar-track {
    background: #111;
}

.retro-scroll::-webkit-scrollbar-thumb,
.log-container::-webkit-scrollbar-thumb,
.status-container::-webkit-scrollbar-thumb,
.char-list::-webkit-scrollbar-thumb,
#inv-item-list::-webkit-scrollbar-thumb {
    background: #CCC;
    border-radius: 3px;
    border: 1px solid #111;
}

.retro-scroll::-webkit-scrollbar-thumb:hover,
.log-container::-webkit-scrollbar-thumb:hover,
.status-container::-webkit-scrollbar-thumb:hover,
.char-list::-webkit-scrollbar-thumb:hover,
#inv-item-list::-webkit-scrollbar-thumb:hover {
    background: #CCC;
}

/* Ensure no horizontal scroll by default in these containers */
.retro-scroll {
    overflow-x: hidden;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-family);
    margin: 0;
    padding: 0;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    /* Prevent scrolling */
    display: flex;
    justify-content: center;
    align-items: center;
    box-sizing: border-box;
}

#game-container {
    width: 99vw;
    height: 99vh;
    max-width: 1920px;
    max-height: 1080px;
    min-height: 500px;
    /* Reduced to avoid overflow on small screens */
    border: 2px solid var(--border-color);
    display: flex;
    /* Changed from grid to flex for main container to handle different views */
    flex-direction: column;
    padding: 0;
    box-sizing: border-box;
    background: #050505;
    box-shadow: 0 0 20px rgba(0, 255, 0, 0.15);
}


/***********************************************************
 * 3. DUNGEON DASHBOARD (Game Play View)
 ***********************************************************/

/* Dashboard Layout (Full Screen) */
.dungeon-dashboard {
    display: grid;
    grid-template-columns: 1fr 320px 320px;
    /* Left (1fr) | Center (320px) | Right (320px) */
    gap: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #000;
    position: relative;
}

.dungeon-col-left {
    display: flex;
    flex-direction: column;
    height: 100%;
    border-right: 1px solid #333;
    overflow: hidden;
    position: relative;
    /* Added to anchor overlays like inventory */
}

.dungeon-main {
    flex: 0 0 500px;
    position: relative;
    background: #000;
    border-bottom: 1px solid #333;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

.dungeon-col-center {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: #050505;
    border-right: 1px solid #333;
    overflow: hidden;
}

.dungeon-col-right {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: #000;
    overflow: hidden;
}

/* Components */
.mm-container {
    flex: 0 0 320px;
    height: 320px;
    border-bottom: 1px solid #333;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.command-container {
    flex: 1;
    /* Center Column Bottom */
    background: #111;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px;
}

.status-container {
    flex: 1;
    /* 右カラム - ミニマップのグリッド上端と高さを揃えるための上部余白 */
    padding: 20px 2px 2px 2px;
    background: #050505;
    font-size: 0.85em;
    overflow-y: auto;
}

/* Sub-elements */
.log-container {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    font-family: var(--font-mono);
    font-size: 1em;
    color: #ccc;
    background: #000;
    line-height: 1.5;
}

#map-canvas {
    width: 280px !important;
    height: 280px !important;
    object-fit: contain;
    background: #000;
    border: 1px solid #222;
}


/* CRT Scanline Effect (Overlay) */
.crt-overlay {
    background: linear-gradient(rgba(18, 16, 16, 0) 50%,
            rgba(0, 0, 0, 0.25) 50%);
    background-size: 100% 4px;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 1000;
}


header {
    background: linear-gradient(135deg, #000428 0%, #004e92 50%, #000428 100%);
    background-size: 400% 400%;
    animation: headerGradientShift 15s ease infinite;
    box-shadow: 0 4px 15px rgba(0, 210, 255, 0.4);
    height: 30px;
    /* Reduced to save game screen space */
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

header::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at center, transparent 0%, rgba(0, 0, 0, 0.5) 100%);
    pointer-events: none;
}

@keyframes headerGradientShift {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

h1 {
    font-size: 18px;
    margin: 0;
    color: #fff;
    text-transform: none;
    letter-spacing: 5px;
    font-weight: 400;
    /* RocknRoll One は 400 が標準 */
    text-shadow: 0 0 10px rgba(0, 210, 255, 1), 0 0 20px rgba(0, 210, 255, 0.6);
    z-index: 1;
    font-family: var(--font-serif);
}

/***********************************************************
 * 4. GENERIC UI COMPONENTS (Menus, Panels, Modals)
 ***********************************************************/

#main-display {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    padding: 0;
    /* Clear global padding to allow full-bleed views */
}

/* Generic UI Panel (for Tavern, Character Creation, etc.) */
.ui-panel-overlay {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    /* Semi-transparent background */
}

/* Auth screen specific */
.auth-background {
    background: url('../images/login_bg.png') no-repeat center center;
    background-size: cover !important;
}

.auth-overlay {
    background: rgba(0, 0, 0, 0.5) !important;
}

.auth-overlay .ui-panel-body {
    background: transparent !important;
}

.ui-panel-body {
    width: 98%;
    height: 98%;
    max-width: 1600px;
    padding: 10px 25px 25px;
    /* Reduced top padding */
    display: flex;
    flex-direction: column;
    position: relative;
    border: 1px solid var(--bronze-outline);
    background: #000;
    box-shadow: 0 0 30px var(--amber-glow);
    box-sizing: border-box;
    overflow: hidden;
    /* Prevent panel itself from scrolling */
}

/* Common Layout Helpers */
.panel-title {
    margin-top: 0;
    text-align: center;
    border-bottom: 1px solid var(--bronze-outline);
    padding-bottom: 7px;
    margin-bottom: 20px;
    color: var(--gold-pale);
    text-transform: none;
    font-size: 1.5em;
    letter-spacing: 3px;
    font-weight: 400;
    font-family: var(--font-serif);
}

.bottom-button-area {
    margin-top: 20px;
    border-top: 1px solid #333;
    padding-top: 20px;
    text-align: center;
    display: flex;
    justify-content: center;
    gap: 20px;
}

/* Card Style for Selection */
.selection-grid {
    display: flex;
    gap: 20px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    padding: 10px;
}

.selection-card {
    width: 220px;
    height: 180px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border: 1px solid var(--bronze-outline);
    color: var(--gold-pale);
    background: rgba(0, 0, 0, 0.5);
    cursor: pointer;
    transition: all 0.2s;
    padding: 15px;
    text-align: center;
    box-sizing: border-box;
}

.selection-card:hover {
    background: #0a0a0a;
    border-color: #dec674;
    color: #fff;
    box-shadow: 0 0 10px rgba(184, 134, 11, 0.2);
}

.selection-card.selected {
    background: #1a1200;
    border-color: #d4af37 !important;
    border-width: 2px !important;
    color: #fff;
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.4), inset 0 0 10px rgba(212, 175, 55, 0.2);
}

.selection-card .icon {
    font-size: 2.5em;
    margin-bottom: 10px;
}

.selection-card .name {
    font-size: 1.2em;
    padding-bottom: 5px;
    margin-bottom: 5px;
}

.selection-card .desc {
    font-size: 0.8em;
    color: #CCC;
}

/* Town Buttons (Cinematic Cards) */
.town-btn {
    width: 240px;
    height: 180px;
    padding: 0;
    overflow: hidden;
    position: relative;
    border: 1px solid var(--bronze-outline);
    background: #000;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    font-family: inherit;
    border-radius: 4px;
}

.town-btn:disabled {
    opacity: 0.4;
    filter: grayscale(100%);
    cursor: not-allowed;
    pointer-events: none;
}

.town-btn:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 20px rgba(212, 175, 55, 0.3);
    border-color: #fff !important;
}

.town-btn img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.5;
    transition: opacity 0.3s, transform 0.5s;
    z-index: 1;
}

.town-btn:hover img {
    opacity: 0.9;
    transform: scale(1.05);
}

.town-btn-info {
    position: relative;
    z-index: 2;
    width: 100%;
    padding: 15px 10px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.9) 60%);
    text-align: center;
    box-sizing: border-box;
}

.town-btn-label {
    display: block;
    font-size: 1.5em;
    font-weight: 400;
    /* 擬似ボールドを解除して潰れを改善 */
    text-shadow: 0 0 5px #000, 1px 1px 2px #000;
    margin-bottom: 4px;
    color: inherit;
    font-family: var(--font-serif);
    text-transform: none !important;
    letter-spacing: 1px;
}

.town-btn-desc {
    display: block;
    font-size: 0.9em;
    color: #e0e0e0;
    text-shadow: 1px 1px 3px #000, 0 0 5px #000;
    line-height: 1.2;
}

#command-area {
    background: linear-gradient(135deg, #000428 0%, #004e92 50%, #000428 100%);
    background-size: 400% 400%;
    animation: headerGradientShift 15s ease infinite;
    height: 30px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    position: relative;
    overflow: hidden;
}

#command-area::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at center, transparent 0%, rgba(0, 0, 0, 0.3) 100%);
    pointer-events: none;
}

#command-area a {
    color: #fff;
    text-decoration: none;
    font-size: 0.85em;
    letter-spacing: 1px;
    text-shadow: 0 0 8px rgba(0, 210, 255, 0.8);
    transition: all 0.3s ease;
    z-index: 1;
}

#command-area a:hover {
    color: var(--blue-primary);
    text-shadow: 0 0 12px rgba(0, 210, 255, 1);
}

#command-area span {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.8em;
    letter-spacing: 1px;
    z-index: 1;
}

/* Form Styles */
.panel {
    border: 1px solid var(--border-color);
    padding: 20px;
    width: 60%;
    background-color: #111;
}

.form-group {
    margin-bottom: 10px;
    text-align: left;
}

label {
    display: inline-block;
    width: auto;
    min-width: 100px;
}

input,
select {
    background: black;
    color: white;
    border: 1px solid white;
    padding: 5px;
    font-family: inherit;
    width: 200px;
}

button {
    background: black;
    color: white;
    border: 1px solid white;
    padding: 10px 20px;
    cursor: pointer;
    font-family: inherit;
    text-transform: none;
    transition: all 0.2s;
    outline: none;
    /* 全てのボタンからデフォルトの白枠を除去 */
}

button:hover,
button:focus {
    background: #222;
    color: var(--gold-primary);
    border-color: var(--gold-primary);
    box-shadow: 0 0 10px var(--gold-primary);
    outline: none;
}

/* 戦闘コマンドボタン専用のフォーカススタイル */
#btn-atk:focus {
    border-color: #f55 !important;
    box-shadow: 0 0 15px rgba(255, 85, 85, 0.6) !important;
    color: #f55 !important;
}

#btn-mag:focus {
    border-color: #5af !important;
    box-shadow: 0 0 15px rgba(0, 170, 255, 0.6) !important;
    color: #5af !important;
}

#btn-def:focus {
    border-color: #888 !important;
    box-shadow: 0 0 15px rgba(136, 136, 136, 0.6) !important;
    color: #fff !important;
}

#btn-item:focus {
    border-color: #fb0 !important;
    box-shadow: 0 0 15px rgba(255, 187, 0, 0.6) !important;
    color: #fb0 !important;
}

#btn-flee:focus {
    border-color: #f55 !important;
    box-shadow: 0 0 10px rgba(255, 85, 85, 0.4) !important;
}

#btn-turn-start:focus {
    border-color: #fff !important;
    box-shadow: 0 0 20px #f00 !important;
    background: #500 !important;
}

/* Hide scrollbars for specific areas but still allow scroll if needed (though we aim for no scroll) */
#stats-area,
#class-grid {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

#stats-area::-webkit-scrollbar,
#class-grid::-webkit-scrollbar {
    display: none;
}

/* Entry Theme (Dark Green) */
.entry-theme .ui-panel-body {
    border-color: #006400;
    box-shadow: 0 0 30px rgba(0, 100, 0, 0.2);
}

.entry-theme .panel-title {
    color: #008800;
    border-bottom: 1px solid #006400;
}

.entry-theme .selection-card {
    border-color: #006400;
    color: #008800;
}

.entry-theme .selection-card:hover {
    box-shadow: 0 0 15px rgba(0, 100, 0, 0.4);
}

.entry-theme button:hover {
    color: #00cc00;
    border-color: #00cc00;
    box-shadow: 0 0 5px #00cc00;
}

/* Common Entry Button with Hover Effect */
.entry-btn {
    background: rgba(0, 17, 0, 0.85);
    border: 2px solid #008800 !important;
    color: #008800;
    font-size: 1.1em;
    letter-spacing: 2px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 0 15px rgba(0, 100, 0, 0.3);
    transition: all 0.3s;
    text-align: center;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 20px;
    box-sizing: border-box;
    white-space: nowrap;
}

.entry-btn:hover {
    background: #006400 !important;
    color: #000 !important;
    box-shadow: 0 0 30px #006400 !important;
}

.error-msg {
    color: #ff5555;
    margin-bottom: 10px;
    min-height: 1.2em;
}

/* Story Crawl Animation */
.story-crawl-container {
    height: 280px;
    /* Enlarge to prevent clipping */
    overflow: hidden;
    position: relative;
    border-top: 1px solid #321;
    border-bottom: 1px solid #321;
    margin-bottom: 25px;
    background: rgba(0, 0, 0, 0.6);
}

/* Fade effects for top and bottom */
.story-crawl-container::before,
.story-crawl-container::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    height: 60px;
    /* Slightly taller fades */
    z-index: 2;
    pointer-events: none;
}

.story-crawl-container::before {
    top: 0;
    background: linear-gradient(to bottom, rgba(0, 0, 7, 1) 0%, rgba(0, 0, 0, 0) 100%);
}

.story-crawl-container::after {
    bottom: 0;
    background: linear-gradient(to top, rgba(0, 0, 7, 1) 0%, rgba(0, 0, 0, 0) 100%);
}

.story-crawl-content {
    position: absolute;
    width: 100%;
    text-align: center;
    color: #f1c40f;
    font-size: 1.25em;
    font-style: italic;
    line-height: 2.5;
    /* Increased for Furigana */
    white-space: pre-wrap;
    animation: story-crawl 100s linear forwards;
    top: 100%;
    margin-bottom: 200px;
    text-shadow: 0 0 10px rgba(241, 196, 15, 0.4);
}

#story-title-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    z-index: 5;
    animation: story-fade-in 5s ease-in-out 80s forwards;
    /* Adjusted for slower speed from 60s to 80s */
    pointer-events: none;
    width: 90%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.story-title-img-wide,
.login-title-img {
    max-width: 100%;
    max-height: 240px;
    height: auto;
    object-fit: contain;
}

.login-title-img {
    display: block;
    margin: 0 auto 15px;
    width: 400px;
}

rt {
    font-size: 0.5em;
    font-style: normal;
    color: #ffd700;
}

@keyframes story-crawl {
    0% {
        top: 70%;
    }

    100% {
        top: -380%;
    }
}

@keyframes story-fade-in {
    0% {
        opacity: 0;
        filter: blur(20px) brightness(0);
    }

    100% {
        opacity: 1;
        filter: blur(0) brightness(1.1);
    }
}

.links {
    margin-top: 20px;
    font-size: 0.8em;
}

a {
    color: var(--text-color);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* Menu List */
.menu-list {
    list-style: none;
    padding: 0;
}

.menu-list li {
    margin: 10px 0;
}

.menu-list button {
    width: 100%;
    text-align: left;
}

/* Character List */
.char-list {
    border: 1px solid #333;
    padding: 10px;
    height: 300px;
    overflow-y: auto;
    text-align: left;
}

.char-item {
    padding: 10px;
    border: 1px solid #333;
    background-color: #050505;
    transition: all 0.2s ease;
    cursor: pointer;
}

.char-item:hover {
    background-color: rgba(212, 175, 55, 0.08);
    border-color: rgba(212, 175, 55, 0.4);
}

.char-item.selected {
    background-color: rgba(212, 175, 55, 0.12) !important;
    border-color: #d4af37 !important;
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.1);
}

/* Custom Modal Dialog */
.custom-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease-in-out;
}

.custom-modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.custom-modal-box {
    background-color: #000;
    border: 3px double var(--gold-primary);
    padding: 30px;
    min-width: 400px;
    max-width: 80%;
    color: #ccc;
    font-family: inherit;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.9), 0 0 20px var(--amber-glow);
    text-align: center;
    position: relative;
    overflow: hidden;
}

.custom-modal-content {
    margin-bottom: 25px;
    font-size: 1.2em;
    line-height: 1.5;
    white-space: pre-wrap;
}

.custom-modal-buttons {
    display: flex;
    justify-content: center;
    gap: 20px;
}

.custom-modal-btn {
    padding: 10px 30px;
    background: #000;
    color: #aaa;
    border: 1px solid #555;
    cursor: pointer;
    font-family: inherit;
    font-size: 1.0em;
    transition: all 0.2s;
}

.custom-modal-btn:hover {
    background: #111;
    color: var(--gold-pale);
    border-color: var(--gold-primary);
    box-shadow: 0 0 10px var(--amber-glow);
}

.custom-modal-btn:focus {
    outline: none;
    border-color: var(--gold-primary);
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.4);
    color: var(--gold-pale);
}

.custom-modal-btn.primary {
    border-color: #00cc88;
    color: #00cc88;
}

.custom-modal-btn.primary:hover {
    background: rgba(0, 204, 136, 0.1);
    color: #fff;
    border-color: #00cc88;
    box-shadow: 0 0 15px rgba(0, 204, 136, 0.5);
}

.custom-modal-btn.primary:focus {
    outline: none;
    border-color: #00cc88;
    box-shadow: 0 0 20px rgba(0, 204, 136, 0.6);
    color: #fff;
}

.custom-modal-btn.secondary {
    border-color: #777;
    color: #888;
}

.custom-modal-btn.secondary:hover {
    background: #222;
    color: #fff;
    border-color: #fff;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.4);
}

.custom-modal-btn.secondary:focus {
    outline: none;
    border-color: #fff;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.5);
    color: #fff;
}

/* Portrait and Visual Styles */
.char-portrait {
    width: 100%;
    max-width: 256px;
    height: auto;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.8), inset 0 0 10px rgba(0, 210, 255, 0.1);
    background: #000;
    transition: transform 0.3s ease;
    display: block;
    margin: 0 auto;
}

.char-portrait-small {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border: 1px solid #444;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
    background: #000;
}

.visual-container {
    position: relative;
    border: 1px solid #333;
    background: #050505;
    overflow: hidden;
    margin-bottom: 15px;
}

.visual-container::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.8);
}

.enemy-visual-box {
    width: 100%;
    max-width: 300px;
    height: auto;
    border: 2px solid #555;
    box-shadow: 0 0 20px rgba(255, 0, 0, 0.2);
    background: #000;
    margin: 10px auto;
    display: block;
}

.portrait-glow-gold {
    border-color: var(--gold-primary);
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.5);
}

.portrait-glow-blue {
    border-color: var(--blue-primary);
    box-shadow: 0 0 15px rgba(0, 210, 255, 0.5);
}

/* Combat VFX */
.vfx-shake {
    animation: shake 0.4s cubic-bezier(.36, .07, .19, .97) both;
}

.vfx-flash-red {
    animation: flash-red 0.4s ease-out both;
}

.vfx-flash-white {
    animation: flash-white 0.3s ease-out both;
}

@keyframes shake {

    10%,
    90% {
        transform: translate3d(-1px, 0, 0);
    }

    20%,
    80% {
        transform: translate3d(2px, 0, 0);
    }

    30%,
    50%,
    70% {
        transform: translate3d(-4px, 0, 0);
    }

    40%,
    60% {
        transform: translate3d(4px, 0, 0);
    }
}

@keyframes flash-red {
    0% {
        background-color: rgba(255, 0, 0, 0);
    }

    20% {
        background-color: rgba(255, 0, 0, 0.6);
    }

    100% {
        background-color: rgba(255, 0, 0, 0);
    }
}

@keyframes flash-white {
    0% {
        filter: brightness(1);
    }

    30% {
        filter: brightness(3);
    }

    100% {
        filter: brightness(1);
    }
}

@keyframes flash-purple {
    0% {
        background-color: rgba(160, 0, 255, 0);
    }

    20% {
        background-color: rgba(160, 0, 255, 0.6);
    }

    100% {
        background-color: rgba(160, 0, 255, 0);
    }
}

.vfx-flash-purple {
    animation: flash-purple 0.6s ease-out both;
}

@keyframes flash-green {
    0% {
        background-color: rgba(0, 255, 0, 0);
        box-shadow: 0 0 0px rgba(0, 255, 0, 0);
    }

    30% {
        background-color: rgba(0, 255, 0, 0.4);
        box-shadow: 0 0 40px 10px rgba(0, 255, 0, 0.7);
        border-color: var(--gold-primary);
    }

    100% {
        background-color: rgba(0, 255, 0, 0);
        box-shadow: 0 0 0px rgba(0, 255, 0, 0);
    }
}

.vfx-flash-green {
    animation: flash-green 0.8s ease-out both;
}

.portrait-glow-purple {
    border-color: #a0f;
    box-shadow: 0 0 15px rgba(160, 0, 255, 0.5);
}

/* List Item Hover Effects */
.list-item-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 10px;
    border-bottom: 1px solid #1a1a1a;
    background-color: #050505;
    transition: all 0.2s ease;
    cursor: default;
}

.list-item-row:hover {
    background-color: rgba(212, 175, 55, 0.15);
    border-bottom-color: rgba(212, 175, 55, 0.6);
    box-shadow: inset 5px 0 0 var(--gold-primary);
}

/* Gender Restriction Badges */
.gender-badge {
    display: inline-block;
    font-size: 0.7em;
    border: 1px solid;
    padding: 1px 4px;
    border-radius: 3px;
    line-height: 1.1;
    vertical-align: middle;
    font-weight: normal;
    margin-left: 5px;
}

.gender-badge.male {
    color: var(--blue-accent);
    border-color: var(--blue-accent);
}

.gender-badge.female {
    color: #f5a;
    border-color: #f5a;
}

.inn-card {
    display: flex;
    gap: 15px;
    padding: 15px;
    background-color: #050505;
    border: 1px solid #333;
    margin-bottom: 10px;
    transition: all 0.2s ease;
    cursor: default;
}

.inn-card:hover {
    background-color: rgba(212, 175, 55, 0.08);
    border-color: rgba(212, 175, 55, 0.4);
    box-shadow: inset 0 0 15px rgba(212, 175, 55, 0.03);
}

.inn-card.poisoned {
    border-color: #a0f;
}

.inn-card.needs-recovery {
    border-color: #444;
}

@keyframes pulse-border {
    0% {
        border-color: #f55;
        box-shadow: 0 0 5px rgba(255, 85, 85, 0.4);
    }

    50% {
        border-color: #fff;
        box-shadow: 0 0 20px rgba(255, 255, 255, 0.6);
    }

    100% {
        border-color: #f55;
        box-shadow: 0 0 5px rgba(255, 85, 85, 0.4);
    }
}

/* Unified Tab Button Style */
.btn-tab {
    flex: 1;
    padding: 10px;
    background: transparent;
    border: 1px solid #444;
    color: #aaa;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.btn-tab:hover {
    background-color: rgba(212, 175, 55, 0.08) !important;
    border-color: var(--gold-primary) !important;
    color: var(--gold-primary) !important;
    box-shadow: inset 0 0 10px rgba(212, 175, 55, 0.05) !important;
}

.btn-tab.active {
    background-color: rgba(212, 175, 55, 0.1) !important;
    border-color: var(--gold-primary) !important;
    color: var(--gold-primary) !important;
}

/* Cinematic Ending Panel Adjustments */
.ui-panel-overlay.ending-panel {
    background-image: url('../images/login_bg.png');
    background-size: cover;
    background-position: center;
}

.ui-panel-overlay.ending-panel .ui-panel-body {
    background: rgba(0, 0, 0, 0.4);
    /* Make it more cinematic */
    backdrop-filter: blur(5px);
}

/* Cinematic Ending Styles */
.ending-view-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #000;
    z-index: 9999;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    align-items: center !important;
    overflow: hidden;
    color: #fff;
    text-align: center;
}

.ending-bg-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover !important;
    background-position: center !important;
    opacity: 0;
    transition: opacity 3s ease-in-out;
    z-index: 1;
}

.ending-overlay-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, transparent 0%, rgba(0, 0, 0, 0.8) 100%), rgba(0, 0, 0, 0.4);
    z-index: 2;
}

.ending-content-area {
    position: relative;
    z-index: 10;
    max-width: 900px;
    width: 90%;
    text-align: center;
    padding: 20px;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
}

.cinematic-message {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 2s ease-in-out, transform 2s ease-out;
    margin: 25px 0;
    color: #fff;
    font-size: 1.8em;
    line-height: 1.8;
    text-shadow: 0 0 15px rgba(0, 0, 0, 1), 0 0 5px rgba(255, 255, 255, 0.2);
    width: 100%;
}

.cinematic-message.active {
    opacity: 1;
    transform: translateY(0);
}

.ending-footer {
    position: relative;
    z-index: 10;
    margin-top: 50px;
    opacity: 0;
    transition: opacity 1.5s ease-in-out;
    width: 100%;
    display: flex !important;
    justify-content: center !important;
}