/* --- Global & Login Page --- */
body {
    font-family: 'Helvetica Neue', Arial, 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background-color: #f0f2f5;
    color: #333;
    margin: 0;
    padding: 20px;
    -webkit-font-smoothing: antialiased;
}

.login-container {
    background: white;
    padding: 2rem 3rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    text-align: center;
    width: 350px;
    margin: 10vh auto;
}

.login-container h1 {
    color: #333;
    margin-bottom: 1.5rem;
}

.login-container form {
    display: flex;
    flex-direction: column;
}

.login-container label {
    text-align: left;
    margin-bottom: 0.5rem;
    color: #555;
    font-size: 0.9rem;
}

.login-container input[type="text"],
.login-container input[type="password"] {
    padding: 0.8rem;
    margin-bottom: 1rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

/* --- Buttons --- */
button, .button {
    padding: 0.8rem 1rem;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.3s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    white-space: nowrap;
}

button:hover, .button:hover {
    background-color: #0056b3;
}

.button-delete {
    background-color: #dc3545;
}

.button-delete:hover {
    background-color: #c82333;
}

.button.button-secondary {
    background-color: #6c757d;
}
.button.button-secondary:hover {
    background-color: #5a6268;
}

/* --- Messages --- */
.success-message {
    color: #155724;
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.error-message {
    color: #721c24;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
}

a {
    color: #007bff;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}


/* --- Admin Panel Styles --- */
.admin-container {
    max-width: 800px;
    margin: 2rem auto;
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #eee;
    padding-bottom: 1rem;
    margin-bottom: 2rem;
}

.admin-header h1 {
    margin: 0;
}

.admin-section {
    margin-bottom: 2rem;
    border-bottom: 1px solid #eee;
    padding-bottom: 1.5rem;
}

.admin-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.admin-section h2 {
    color: #333;
    margin-top: 0;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: bold;
}

.form-group input {
    box-sizing: border-box;
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

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

.account-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem;
    border: 1px solid #eee;
    margin-bottom: 0.5rem;
    border-radius: 4px;
    background-color: #fafafa;
}

.account-list .account-info {
    display: flex;
    flex-direction: column;
}

.account-list .account-info small {
    font-size: 0.8rem;
    color: #666;
    margin-top: 4px;
}

.account-list form {
    margin: 0;
}

/* --- Character Selection & Game World --- */
.character-select-container, .game-world-container {
    max-width: 900px;
    margin: 2rem auto;
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.character-select-header, .game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #eee;
    padding-bottom: 1rem;
    margin-bottom: 2rem;
}

.character-select-header h1 {
    margin: 0;
    font-size: 1.5rem;
}

.characters-list {
    margin-bottom: 2rem;
}

.character-card {
    display: flex;
    align-items: center;
    background: #f9f9f9;
    padding: 1rem;
    border: 1px solid #eee;
    border-radius: 6px;
    margin-bottom: 1rem;
}

.character-card .avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    margin-right: 1rem;
    background-color: #ddd; /* Placeholder color */
    object-fit: cover;
}

.character-card .char-info {
    flex-grow: 1;
}

.char-info h3, .char-info p {
    margin: 0;
}

.char-info h3 {
    margin-bottom: 0.25rem;
}

.char-info p {
    color: #666;
    font-size: 0.9rem;
}

.char-actions {
    display: flex;
    gap: 0.5rem;
}

.char-actions form {
    margin: 0;
}

.creation-section {
    border-top: 1px solid #eee;
    padding-top: 2rem;
}

.creation-section h2 {
    margin-top: 0;
}

.creation-form {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.creation-form input[type="text"],
.creation-form select {
    padding: 0.8rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    font-family: inherit;
    background-color: white;
}
.creation-form input[type="text"]{
    flex-grow: 2;
}
.creation-form select{
    flex-grow: 1;
}

.game-header .character-info-short {
    font-size: 1.1rem;
}

.game-main {
    padding: 1rem 0;
}

.game-main h1 {
    margin-top: 0;
}

.actions-panel {
    margin-top: 2rem;
    display: flex;
    gap: 1rem;
}

.actions-panel form {
    margin: 0;
}

.actions-panel button[disabled] {
    background-color: #ccc;
    cursor: not-allowed;
}

/* --- Event Display Panel --- */
.event-display {
    background: #fffbe6;
    border-left: 5px solid #ffeeba;
    padding: 1rem 1.5rem;
    margin-bottom: 2rem;
    border-radius: 4px;
}

.event-display h3 {
    margin-top: 0;
    color: #856404;
}

.event-display p {
    margin-bottom: 0;
    line-height: 1.6;
}

/* --- Game World Dashboard --- */
.character-dashboard {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin-bottom: 2rem;
    background: #f8f9fa;
    padding: 1.5rem;
    border-radius: 8px;
    border: 1px solid #dee2e6;
}

.stat-panel, .xp-panel {
    flex: 1;
    min-width: 250px;
}

.stat-panel h4, .xp-panel h4 {
    margin-top: 0;
    margin-bottom: 1rem;
    color: #495057;
    border-bottom: 1px solid #e9ecef;
    padding-bottom: 0.75rem;
}

.stat-panel ul {
    list-style: none;
    padding: 0;
    margin: 0 0 1rem 0;
}

.stat-panel li {
    margin-bottom: 0.6rem;
    color: #6c757d;
    font-size: 0.95rem;
}

.stat-panel li strong {
    color: #343a40;
    float: right;
    font-size: 1rem;
}

.talent-points {
    font-weight: bold;
    color: #007bff;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #e9ecef;
}

.talent-points strong {
    font-size: 1.5rem;
    color: #dc3545;
}

.xp-bar-container {
    width: 100%;
    height: 22px;
    background-color: #e9ecef;
    border-radius: 11px;
    overflow: hidden;
    margin-bottom: 0.5rem;
    border: 1px solid #ced4da;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
}

.xp-bar {
    height: 100%;
    background-color: #28a745;
    transition: width 0.5s ease-in-out;
    background-image: linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);
    background-size: 40px 40px;
}

.xp-text {
    text-align: center;
    color: #495057;
    font-size: 0.9rem;
}

.level-up-message {
    padding: 1rem 1.5rem;
    margin-bottom: 1.5rem;
    border-radius: 5px;
    background-color: #e7f5ff;
    border-left: 5px solid #007bff;
    color: #004085;
    text-align: center;
    animation: fadeIn 0.5s ease;
}

.event-display .reward-text {
    margin-top: 1rem;
    font-style: italic;
    color: #1a7431;
    font-weight: bold;
    border-top: 1px dashed #c3e6cb;
    padding-top: 0.75rem;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Attribute Point System & Messages --- */

/* Modify existing stat panel li for flexbox layout */
.stat-panel ul li {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Modify existing strong tag style */
.stat-panel ul li strong {
    float: none; /* Remove float from previous style */
    margin-left: 0.5rem;
}

.add-point-form {
    margin: 0;
}

.button-add-point {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    padding: 0;
    font-size: 1.2rem;
    line-height: 26px; /* Adjust for vertical centering */
    text-align: center;
    background-color: #28a745;
    flex-shrink: 0; /* Prevents button from shrinking on smaller screens */
    margin-left: 1rem;
}

.button-add-point:hover {
    background-color: #218838;
}

.system-message {
    padding: 0.75rem 1.25rem;
    margin-bottom: 1rem;
    border-radius: .25rem;
    color: #0c5460;
    background-color: #d1ecf1;
    border: 1px solid #bee5eb;
    text-align: center;
    animation: fadeIn 0.5s ease;
}

/* --- Inventory System --- */
.inventory-container {
    max-width: 1200px;
    margin: 2rem auto;
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.inventory-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #eee;
    padding-bottom: 1rem;
    margin-bottom: 2rem;
}

.inventory-header h1 {
    margin: 0;
}

.inventory-layout {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
}

.equipped-panel {
    flex: 1;
    min-width: 300px;
}

.backpack-panel {
    flex: 2;
    min-width: 400px;
}

.equipped-panel h2, .backpack-panel h2 {
    margin-top: 0;
    border-bottom: 1px solid #eee;
    padding-bottom: 0.75rem;
}

.equipment-slots .slot {
    display: flex;
    align-items: center;
    margin-bottom: 1rem;
    background: #f8f9fa;
    padding: 0.5rem;
    border-radius: 4px;
}

.slot-name {
    width: 60px;
    font-weight: bold;
    color: #495057;
    flex-shrink: 0;
}

.slot-item {
    flex-grow: 1;
}

.slot-item .item-card {
    margin-bottom: 0;
}

.slot-empty {
    color: #6c757d;
    font-style: italic;
}

.backpack-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
}

.item-card {
    background: #fff;
    border: 1px solid #dee2e6;
    padding: 1rem;
    border-radius: 5px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.quality-border-白 { border-left: 5px solid #bdbdbd; }
.quality-border-蓝 { border-left: 5px solid #2196f3; }
.quality-border-紫 { border-left: 5px solid #9c27b0; }
.quality-border-橙 { border-left: 5px solid #ff9800; }
.quality-border-红 { border-left: 5px solid #f44336; }

.item-name {
    font-size: 1.1rem;
    margin-bottom: 0.25rem;
}

.item-type {
    color: #6c757d;
    margin-bottom: 0.5rem;
    font-style: italic;
}

.item-stats {
    color: #1a7431;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
    font-weight: bold;
    min-height: 1.2em; /* Reserve space */
}

.item-desc {
    font-size: 0.85rem;
    color: #495057;
    flex-grow: 1;
    margin: 0 0 1rem 0;
}

.button-small {
    padding: 0.4rem 0.8rem;
    font-size: 0.9rem;
}

.button-equip {
    background-color: #28a745;
}
.button-equip:hover {
    background-color: #218838;
}

.button-unequip {
    background-color: #ffc107;
    color: #212529;
}
.button-unequip:hover {
    background-color: #e0a800;
}

/* --- Stat bonus display --- */
.stat-bonus {
    font-size: 0.85em;
    font-weight: normal;
    color: #28a745; /* Green color for bonus */
    margin-left: 8px;
}

/* --- Boss Encounter & Battle System --- */
.boss-encounter-panel {
    background-color: #fff3cd;
    border-left: 5px solid #ffc107;
    padding: 2rem;
    text-align: center;
    border-radius: 8px;
    animation: fadeIn 0.5s ease;
}
.boss-encounter-panel h2 {
    color: #856404;
    margin-top: 0;
    font-size: 2rem;
}
.boss-encounter-panel h3 {
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
}
.boss-encounter-panel .encounter-text {
    font-size: 1.1rem;
    line-height: 1.7;
    margin-bottom: 2rem;
}
.button-danger, .button-fight {
    background-color: #dc3545;
    padding: 1rem 2rem;
    font-size: 1.2rem;
    box-shadow: 0 4px 10px rgba(220, 53, 69, 0.4);
}
.button-danger:hover, .button-fight:hover {
    background-color: #c82333;
}

.battle-container {
    max-width: 900px;
    margin: 2rem auto;
    background: #212529;
    color: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
.battle-container h1 {
    text-align: center;
    margin-bottom: 2rem;
    color: #ffc107;
}

.battle-arena {
    display: flex;
    justify-content: space-around;
    align-items: stretch;
    gap: 1.5rem;
    margin-bottom: 3rem;
    flex-wrap: wrap;
}

.combatant-panel {
    flex: 1;
    min-width: 300px;
    background: rgba(255,255,255,0.05);
    padding: 1.5rem;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.1);
}

.combatant-panel h2 {
    margin-top: 0;
    font-size: 1.6rem;
    color: #fff;
}
.player-panel h2 { color: #00bfff; }
.boss-panel h2 { color: #dc3545; }
.combatant-panel p { color: #ced4da; }
.combatant-panel ul { list-style: none; padding: 0; color: #ced4da; }
.combatant-panel li { margin-bottom: 0.5rem; }

.vs-separator {
    display: flex;
    align-items: center;
    font-size: 3rem;
    font-weight: bold;
    color: #ffc107;
}

.weakness {
    color: #ffc107 !important;
    font-style: italic;
}

.battle-actions {
    text-align: center;
}

/* --- Battle Result & Cooldown --- */
.result-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    color: white;
    text-align: center;
    box-sizing: border-box;
}
.victory-bg {
    background: linear-gradient(135deg, #283c86, #45a247);
}
.defeat-bg {
    background: linear-gradient(135deg, #4c4c4c, #1e1e1e);
}

.result-content {
    background: rgba(0, 0, 0, 0.5);
    padding: 3rem;
    border-radius: 10px;
    max-width: 700px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}
.result-content h1 {
    font-size: 2.5rem;
    margin-top: 0;
    margin-bottom: 1.5rem;
}
.result-content .story-text {
    font-size: 1.1rem;
    line-height: 1.8;
    margin-bottom: 2rem;
    text-align: left;
}
.rewards-panel {
    background: rgba(0, 0, 0, 0.3);
    padding: 1.5rem;
    border-radius: 5px;
    margin-bottom: 2rem;
}
.rewards-panel h3 {
    margin-top: 0;
}
.rewards-panel ul {
    list-style: none;
    padding: 0;
    margin: 0;
}
.rewards-panel li {
    margin-bottom: 0.5rem;
}

.cooldown-container {
    max-width: 600px;
    margin: 15vh auto;
    text-align: center;
    background: #fff;
    padding: 3rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.cooldown-container h1 {
    color: #007bff;
}
.cooldown-container p {
    line-height: 1.7;
    font-size: 1.1rem;
}
.cooldown-container strong {
    color: #dc3545;
    font-size: 1.2rem;
}

/* --- Quest System (Admin) --- */
.account-list li {
    flex-wrap: wrap; /* Allow wrapping for smaller screens */
}
.account-actions {
    display: flex;
    gap: 0.5rem;
    margin-left: auto; /* Push actions to the right */
    align-items: center;
}
.account-actions form {
    margin: 0;
}
.admin-section textarea {
    box-sizing: border-box;
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-family: inherit;
}
.character-quest-list {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 5px;
}
.character-quest-list h3 {
    margin-top: 0;
}
.quest-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid #e9ecef;
}
.quest-item:last-child {
    border-bottom: none;
}
.quest-info p {
    margin: 0.25rem 0 0 0;
    font-size: 0.9rem;
    color: #6c757d;
}
.quest-actions .button-complete {
    background-color: #28a745;
}
.quest-actions .button-complete:hover {
    background-color: #218838;
}
.quest-completed-tag {
    font-size: 0.9rem;
    color: #6c757d;
    font-style: italic;
}

/* --- Quest Log (Child) --- */
.quest-log-container {
    max-width: 800px;
    margin: 2rem auto;
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.quest-log-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #eee;
    padding-bottom: 1rem;
    margin-bottom: 2rem;
}
.quest-log-header h1 { margin: 0; }
.quest-section { margin-bottom: 2rem; }
.quest-card {
    background: #fffbe6;
    border-left: 5px solid #ffeeba;
    padding: 1rem 1.5rem;
    margin-bottom: 1rem;
    border-radius: 4px;
}
.quest-card h3 { margin: 0 0 0.5rem 0; color: #856404; }
.quest-card p { margin: 0 0 0.5rem 0; }
.quest-reward { font-style: italic; }
.quest-card.completed {
    background: #e9ecef;
    border-left-color: #6c757d;
}
.quest-card.completed h3 {
    color: #495057;
    text-decoration: line-through;
}


/* --- Event Display Enhancements --- */
.event-display h3 {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    color: white;
    font-size: 1rem;
    margin-bottom: 1rem;
}

.event-display h3:empty {
    display: none;
}

/* Default story color */
.event-display h3 { background-color: #007bff; } 

/* This part is a bit tricky without changing HTML, but we can target titles */
/* For a more robust solution, we would add classes to the h3 tag */
/* Let's keep it simple for now, the title text itself provides variety. */
/* The background color will be consistent for all events for now. */

/* Let's refine the reward text */
.event-display .reward-text {
    margin-top: 1rem;
    font-style: italic;
    color: #1a7431;
    font-weight: bold;
    border-top: 1px dashed #c3e6cb;
    padding-top: 0.75rem;
}

/* --- UI/UX Enhancements --- */

/* Loading Overlay */
#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    display: none; /* Initially hidden */
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    font-size: 1.2rem;
}
.loading-spinner {
    border: 8px solid #f3f3f3;
    border-top: 8px solid #007bff;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Win Rate Display */
.win-rate {
    font-size: 1.1rem;
    color: #ffc107 !important;
}
.win-rate strong {
    font-size: 1.5rem;
}

/* Encounter Buttons */
.encounter-actions {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-top: 2rem;
}
.encounter-actions form {
    margin: 0;
}
.button-escape {
    background-color: #007bff;
    padding: 1rem 2rem;
    font-size: 1.2rem;
    box-shadow: 0 4px 10px rgba(0, 123, 255, 0.4);
}
.button-escape:hover {
    background-color: #0056b3;
}


/* Win rate on encounter panel */
.encounter-win-rate {
    font-size: 1.2rem;
    color: #ffc107;
    background: rgba(0,0,0,0.2);
    padding: 0.75rem;
    border-radius: 5px;
    margin-top: 1.5rem;
    margin-bottom: 2rem;
}
.encounter-win-rate strong {
    font-size: 1.8rem;
    vertical-align: middle;
}

/* Item actions in inventory */
.item-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: auto;
    padding-top: 1rem;
}
.item-actions form {
    margin: 0;
}
.button-delete-item {
    background-color: #6c757d;
}
.button-delete-item:hover {
    background-color: #5a6268;
}

/* --- Content Generator --- */
.button-generate {
    background: linear-gradient(45deg, #ff6b6b, #feca57);
    color: white;
    font-size: 1.2rem;
    padding: 1rem 2rem;
    border: none;
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.4);
    transition: all 0.3s ease;
}
.button-generate:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 107, 107, 0.6);
}
.button-generate:disabled {
    background: #ccc;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

/* --- Badge & Exchange System --- */
.badge-display {
    font-size: 1.1rem;
    color: #6c757d;
    margin-top: 0.5rem;
}
.badge-display strong {
    color: #ffc107;
    font-size: 1.3rem;
}
.button-deconstruct {
    background-color: #007bff;
}
.button-deconstruct:hover {
    background-color: #0056b3;
}
.button-exchange {
    background-color: #ffc107;
    color: #212529;
    font-weight: bold;
}
.button-exchange:hover {
    background-color: #e0a800;
}
.button-redeem {
    background-color: #28a745;
    width: 100%;
}
.button-redeem:hover {
    background-color: #218838;
}
.button-redeem:disabled {
    background-color: #6c757d;
    cursor: not-allowed;
    opacity: 0.7;
}
