/* Devin's Dungeon — Dark Fantasy Theme */

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

:root {
    --bg-dark: #1a1a2e;
    --bg-medium: #16213e;
    --bg-light: #0f3460;
    --bg-card: #1e2a4a;
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0b0;
    --text-dim: #6a6a7a;
    --accent: #e94560;
    --accent-gold: #d4a017;
    --accent-green: #2ecc71;
    --accent-blue: #3498db;
    --border: #2a2a4a;
    --success: #2ecc71;
    --failure: #e74c3c;
    --crit: #f39c12;
}

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

/* Screens */
.screen {
    display: none;
    height: 100vh;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
}
.screen.active {
    display: flex;
}

/* Login */
#login-screen {
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, var(--bg-dark) 0%, #0a0a1a 100%);
}

.login-box {
    text-align: center;
    padding: 3rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    min-width: 360px;
}

.login-box h1 {
    font-size: 2.5rem;
    color: var(--accent);
    margin-bottom: 0.5rem;
    font-weight: 700;
    letter-spacing: 1px;
}

.subtitle {
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

#login-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

input[type="password"],
input[type="text"] {
    padding: 0.75rem 1rem;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
}

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

button {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s;
}

.btn-primary, #login-form button, #action-form button {
    background: var(--accent);
    color: white;
}

.btn-primary:hover, #login-form button:hover, #action-form button:hover {
    background: #c0392b;
}

.btn-primary:disabled, #action-form button:disabled {
    background: var(--text-dim);
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--bg-light);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--accent-blue);
}

.error {
    color: var(--failure);
    margin-top: 0.5rem;
    font-size: 0.9rem;
}

/* Character Creation */
#creation-screen {
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, var(--bg-dark) 0%, #0a0a1a 100%);
}

.creation-box {
    padding: 2.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    min-width: 420px;
    max-width: 500px;
}

.creation-box h1 {
    color: var(--accent-gold);
    margin-bottom: 1.5rem;
    font-size: 1.8rem;
}

.creation-step {
    margin-bottom: 1.5rem;
}

.creation-step label {
    display: block;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
    font-size: 0.9rem;
}

.creation-step select,
.creation-step input {
    width: 100%;
    padding: 0.6rem 0.8rem;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 1rem;
    margin-bottom: 0.8rem;
}

.hint {
    color: var(--text-dim);
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin-top: 0.8rem;
}

.stat-grid .stat-box {
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.6rem;
    text-align: center;
}

.stat-box .stat-label {
    font-size: 0.75rem;
    color: var(--text-dim);
    text-transform: uppercase;
}

.stat-box .stat-val {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--accent-gold);
}

.stat-box .stat-mod {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.stat-summary {
    background: var(--bg-dark);
    border-radius: 6px;
    padding: 1rem;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    line-height: 1.6;
    white-space: pre-line;
    display: none;
}

#create-char-btn {
    width: 100%;
    padding: 1rem;
    font-size: 1.1rem;
    margin-top: 0.5rem;
}

/* Game Layout */
.game-layout {
    display: flex;
    height: 100vh;
    width: 100%;
}

/* Chat Panel */
.chat-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
    position: relative;
}

.chat-header {
    padding: 1rem 1.5rem;
    background: var(--bg-medium);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header h2 {
    font-size: 1.2rem;
    color: var(--accent);
}

.chat-header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-tts {
    padding: 0.25rem 0.6rem;
    font-size: 0.8rem;
    font-weight: 600;
    background: var(--bg-dark);
    color: var(--text-dim);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-tts.active {
    background: var(--accent-green);
    color: #fff;
    border-color: var(--accent-green);
    box-shadow: 0 0 6px rgba(46, 204, 113, 0.4);
}

.btn-tts:hover {
    border-color: var(--accent-green);
}

.audio-slider {
    width: 60px;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--border);
    border-radius: 2px;
    cursor: pointer;
    vertical-align: middle;
}
.audio-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent-green);
    cursor: pointer;
}
.audio-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent-green);
    border: none;
    cursor: pointer;
}

/* Settings Section (in sidebar) */
.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border);
}

.settings-row:last-child {
    border-bottom: none;
}

.settings-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
}

.settings-control {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.location-badge {
    background: var(--bg-light);
    color: var(--accent-gold);
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.85rem;
}
.weather-badge {
    color: var(--text-secondary);
    font-size: 0.75rem;
    margin-left: 0.3rem;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.message {
    max-width: 90%;
    padding: 1rem;
    border-radius: 10px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.message.dm {
    background: var(--bg-card);
    border-left: 3px solid var(--accent);
    align-self: flex-start;
    position: relative;
}

.tts-replay-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    opacity: 0.4;
    padding: 4px;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s;
}

.tts-replay-btn:hover,
.tts-replay-btn:active {
    opacity: 1;
}

.message.player {
    background: var(--bg-light);
    border-left: 3px solid var(--accent-blue);
    align-self: flex-end;
}

.message.system {
    background: transparent;
    color: var(--text-dim);
    font-style: italic;
    text-align: center;
    align-self: center;
    font-size: 0.9rem;
    border: none;
    padding: 0.5rem;
}

/* Typewriter cursor */
@keyframes blink-cursor {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

.typing-cursor {
    display: inline-block;
    width: 2px;
    height: 1.1em;
    background: var(--accent);
    margin-left: 2px;
    vertical-align: text-bottom;
    animation: blink-cursor 0.7s step-end infinite;
}

.typewriter-active {
    cursor: pointer;
}

/* Death Memorial Card */
.death-memorial {
    background: linear-gradient(135deg, #1a0a0a, #2a1010);
    border: 1px solid #4a1a1a;
    border-radius: 10px;
    padding: 1.2rem;
    margin: 1rem 0;
    text-align: center;
    align-self: center;
    max-width: 350px;
    width: 100%;
}
.memorial-header {
    font-size: 1.3rem;
    font-weight: 700;
    color: #c0392b;
    margin-bottom: 0.4rem;
}
.memorial-info {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}
.memorial-stats {
    display: flex;
    justify-content: center;
    gap: 1rem;
    font-size: 0.8rem;
    color: var(--text-dim);
    margin-bottom: 0.6rem;
}
.memorial-epitaph {
    font-style: italic;
    font-size: 0.85rem;
    color: var(--text-dim);
    border-top: 1px solid #4a1a1a;
    padding-top: 0.5rem;
    margin-top: 0.3rem;
}

.dice-result {
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.8rem 1rem;
    margin-top: 0.8rem;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
}

.dice-result .roll-success {
    color: var(--success);
    font-weight: 700;
}

.dice-result .roll-failure {
    color: var(--failure);
    font-weight: 700;
}

.dice-result .roll-crit {
    color: var(--crit);
    font-weight: 700;
}

.dmg-mod {
    font-weight: 700;
    font-size: 0.85em;
}
.dmg-mod-immune { color: #9b59b6; }
.dmg-mod-resistant { color: #e67e22; }
.dmg-mod-vulnerable { color: #e74c3c; }

.action-bar {
    display: flex;
    padding: 1rem;
    gap: 0.5rem;
    background: var(--bg-medium);
    border-top: 1px solid var(--border);
}

.action-bar input {
    flex: 1;
    padding: 0.75rem 1rem;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
}

.action-bar button {
    min-width: 80px;
}

#clear-chat-btn {
    min-width: auto;
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
}

.chat-separator {
    text-align: center;
    color: #888;
    padding: 8px;
    font-style: italic;
    border-bottom: 1px solid #333;
    margin: 4px 0;
}

.show-earlier {
    display: block;
    text-align: center;
    color: #c8a96e;
    padding: 8px;
    cursor: pointer;
    text-decoration: underline;
}

/* Suggested Action Buttons */
.action-suggestions {
    display: none;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    background: var(--bg-medium);
    border-top: 1px solid var(--border);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.suggestion-btn {
    padding: 0.35rem 0.75rem;
    font-size: 0.82rem;
    border-radius: 16px;
    border: 1px solid var(--accent-gold);
    background: rgba(212, 160, 23, 0.1);
    color: var(--text-primary);
    cursor: pointer;
    white-space: nowrap;
    min-height: 36px;
    transition: transform 0.15s, filter 0.15s, background 0.15s;
    font-family: inherit;
}

.suggestion-btn:hover {
    transform: scale(1.05);
    filter: brightness(1.2);
    background: rgba(212, 160, 23, 0.2);
}

.suggestion-btn:active {
    transform: scale(0.97);
}

/* Combat actions — red/danger tint */
.suggestion-combat {
    border-color: var(--accent);
    background: rgba(233, 69, 96, 0.1);
}
.suggestion-combat:hover {
    background: rgba(233, 69, 96, 0.2);
}

/* Explore actions — blue tint */
.suggestion-explore {
    border-color: var(--accent-blue);
    background: rgba(52, 152, 219, 0.1);
}
.suggestion-explore:hover {
    background: rgba(52, 152, 219, 0.2);
}

/* Shop actions — gold tint */
.suggestion-shop {
    border-color: var(--accent-gold);
    background: rgba(212, 160, 23, 0.15);
}
.suggestion-shop:hover {
    background: rgba(212, 160, 23, 0.25);
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: var(--bg-medium);
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.sidebar-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
}

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

.stat-line {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.3rem 0;
    font-size: 0.9rem;
}

.stat-value {
    color: var(--accent-gold);
    font-weight: 700;
}

/* HP Bar */
.hp-bar {
    flex: 1;
    margin-left: 0.5rem;
    height: 22px;
    background: var(--bg-dark);
    border-radius: 4px;
    position: relative;
    overflow: hidden;
}

.hp-fill {
    height: 100%;
    background: var(--success);
    border-radius: 4px;
    transition: width 0.5s ease;
}

.hp-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.8rem;
    font-weight: 700;
    text-shadow: 0 0 3px rgba(0,0,0,0.8);
}

.hp-bar-label {
    min-width: 25px;
}

/* XP Bar */
.xp-bar {
    flex: 1;
    margin-left: 0.5rem;
    height: 22px;
    background: var(--bg-dark);
    border-radius: 4px;
    position: relative;
    overflow: hidden;
}

.xp-fill {
    height: 100%;
    background: var(--accent-gold);
    border-radius: 4px;
    transition: width 0.5s ease;
}

.xp-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.75rem;
    font-weight: 700;
    text-shadow: 0 0 3px rgba(0,0,0,0.8);
}

.xp-bar-label {
    min-width: 25px;
}

.xp-bar.level-up {
    animation: xpGlow 1.5s ease-in-out;
}

@keyframes xpGlow {
    0% { box-shadow: 0 0 5px rgba(212, 160, 23, 0.3); }
    50% { box-shadow: 0 0 20px rgba(212, 160, 23, 0.8), 0 0 40px rgba(212, 160, 23, 0.4); }
    100% { box-shadow: 0 0 5px rgba(212, 160, 23, 0.3); }
}

/* Ability Grid */
.ability-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.4rem;
}

.ability {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    padding: 0.2rem 0.4rem;
    background: var(--bg-dark);
    border-radius: 4px;
}

.ability-label {
    color: var(--text-dim);
    font-weight: 600;
}

.ability-value {
    color: var(--text-primary);
    font-weight: 700;
}

/* Location Map */
#map-container {
    display: flex;
    justify-content: center;
}

#map-container svg {
    max-width: 100%;
}

.map-connection {
    stroke: var(--border);
    stroke-width: 2;
}

.map-node-current {
    fill: var(--accent-gold);
    stroke: var(--accent-gold);
    stroke-width: 2;
    filter: drop-shadow(0 0 4px rgba(212, 160, 23, 0.6));
}

.map-node-visited {
    fill: var(--bg-light);
    stroke: var(--accent-blue);
    stroke-width: 2;
}

.map-node-unvisited {
    fill: var(--bg-dark);
    stroke: var(--border);
    stroke-width: 2;
}

.map-label-current {
    fill: var(--accent-gold);
    font-weight: 700;
}

.map-label-visited {
    fill: var(--text-primary);
}

.map-label-unvisited {
    fill: var(--text-dim);
}

/* Inventory Count */
.inventory-count {
    font-size: 0.8rem;
    font-weight: 400;
    color: var(--text-dim);
    margin-left: 0.3rem;
}

.inventory-full {
    color: var(--failure);
    font-weight: 700;
}

/* Clickable map nodes */
[data-location-id] {
    cursor: pointer;
}
[data-location-id]:hover {
    filter: brightness(1.4);
}

/* Class feature bonus tags — surprise/cover */
.cf-surprise {
    color: #4ec9b0;
    font-weight: 700;
}
.cf-cover {
    color: #6b9bd2;
    font-weight: 700;
}
.cf-ally {
    color: #ffd700;
    font-weight: 700;
}
.cf-flee {
    color: #f39c12;
    font-weight: 700;
    font-style: italic;
}
.cf-legendary { color: #ff6b6b; }
.cf-lair { color: #e67e22; }
.cf-phase { color: #e74c3c; }

/* Conditions display (below HP bar) */
.conditions-display {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    padding: 0.3rem 0;
}
.condition-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    position: relative;
    cursor: help;
}
.condition-badge[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-card);
    color: var(--text-primary);
    padding: 0.4rem 0.6rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 400;
    text-transform: none;
    white-space: nowrap;
    z-index: 100;
    border: 1px solid var(--border);
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
    margin-bottom: 0.25rem;
}
.condition-badge.condition-negative {
    background: rgba(231, 76, 60, 0.2);
    color: #e74c3c;
    border: 1px solid rgba(231, 76, 60, 0.4);
}
.condition-badge.condition-positive {
    background: rgba(46, 204, 113, 0.2);
    color: #2ecc71;
    border: 1px solid rgba(46, 204, 113, 0.4);
}
.condition-badge.condition-neutral {
    background: rgba(52, 152, 219, 0.2);
    color: #3498db;
    border: 1px solid rgba(52, 152, 219, 0.4);
}

/* Cover indicator */
.cover-display {
    padding: 0.25rem 0.5rem;
    margin: 0.2rem 0;
    border-radius: 3px;
    font-size: 0.8rem;
    font-weight: 600;
    background: rgba(107, 155, 210, 0.15);
    color: #6b9bd2;
    border: 1px solid rgba(107, 155, 210, 0.3);
}

/* Weather badge tooltip */
.weather-badge {
    position: relative;
    cursor: help;
}
.weather-badge[title]:hover::after {
    content: attr(data-effects);
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--bg-card);
    color: var(--text-primary);
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    font-size: 0.8rem;
    white-space: nowrap;
    z-index: 100;
    border: 1px solid var(--border);
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
    margin-top: 0.25rem;
}

/* Inventory */
#inventory-text {
    font-family: 'Segoe UI', system-ui, sans-serif;
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--text-secondary);
}

.inv-item-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1px 0;
}

.inv-item-label {
    flex: 1;
}

.btn-equip {
    font-size: 0.7rem;
    padding: 1px 6px;
    background: var(--accent-blue);
    color: #fff;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    margin-left: 4px;
}

.btn-equip:hover {
    background: var(--accent);
}

.btn-equip:disabled {
    opacity: 0.5;
    cursor: default;
}

#combat-text {
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    line-height: 1.4;
    color: var(--text-secondary);
    white-space: pre-wrap;
}

/* Spell Sidebar */
.slot-row {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    margin-bottom: 0.4rem;
}

.slot-label {
    font-size: 0.75rem;
    color: var(--text-dim);
    min-width: 30px;
    font-weight: 600;
}

.slot-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid var(--accent-blue);
    background: transparent;
    transition: background 0.3s, box-shadow 0.3s;
}

.slot-dot.filled {
    background: var(--accent-blue);
    box-shadow: 0 0 4px rgba(52, 152, 219, 0.5);
}

.spell-group {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.3rem;
    line-height: 1.4;
}

/* Death Saves */
.ds-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.5rem;
}

.ds-label {
    font-size: 0.75rem;
    color: var(--text-dim);
    min-width: 48px;
    font-weight: 600;
}

.ds-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: transparent;
    transition: background 0.3s, border-color 0.3s, box-shadow 0.3s;
}

.ds-dot.success.filled {
    background: var(--success);
    border-color: var(--success);
    box-shadow: 0 0 6px rgba(46, 204, 113, 0.6);
}

.ds-dot.failure.filled {
    background: var(--failure);
    border-color: var(--failure);
    box-shadow: 0 0 6px rgba(231, 76, 60, 0.6);
}

@keyframes reviveGlow {
    0% { box-shadow: 0 0 5px rgba(46, 204, 113, 0.3); }
    50% { box-shadow: 0 0 25px rgba(46, 204, 113, 0.9), 0 0 50px rgba(46, 204, 113, 0.4); }
    100% { box-shadow: 0 0 5px rgba(46, 204, 113, 0.3); }
}

@keyframes failFlash {
    0% { box-shadow: 0 0 5px rgba(231, 76, 60, 0.3); }
    50% { box-shadow: 0 0 25px rgba(231, 76, 60, 0.9), 0 0 50px rgba(231, 76, 60, 0.4); }
    100% { box-shadow: 0 0 5px rgba(231, 76, 60, 0.3); }
}

#death-saves-section.revive-glow {
    animation: reviveGlow 1.5s ease-in-out;
}

#death-saves-section.fail-flash {
    animation: failFlash 0.8s ease-in-out;
}

/* Dice Display */
.dice-display {
    text-align: center;
    padding: 0.5rem;
}

.dice-display .die {
    display: inline-block;
    width: 50px;
    height: 50px;
    background: var(--bg-dark);
    border: 2px solid var(--accent-gold);
    border-radius: 8px;
    line-height: 50px;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--accent-gold);
    margin: 0.2rem;
}

.dice-display .die.crit {
    border-color: var(--crit);
    color: var(--crit);
    box-shadow: 0 0 10px rgba(243, 156, 18, 0.4);
}

.dice-display .die.fumble {
    border-color: var(--failure);
    color: var(--failure);
}

.dice-display .roll-detail {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

/* --- Roll Button & Dice Animation --- */
.roll-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.8rem;
    padding: 1.5rem;
    margin: 0.5rem 0;
    background: linear-gradient(135deg, var(--bg-card) 0%, #1a1a3e 100%);
    border: 2px solid var(--accent-gold);
    border-radius: 12px;
    align-self: center;
    max-width: 300px;
    width: 100%;
}

.die-preview {
    width: 80px;
    height: 80px;
    background: var(--bg-dark);
    border: 3px solid var(--accent-gold);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--accent-gold);
    font-family: 'Courier New', monospace;
    user-select: none;
}

.die-preview.tumbling {
    animation: diceShake 0.15s ease-in-out infinite;
    border-color: var(--accent-blue);
    color: var(--text-secondary);
}

.die-preview.revealed {
    animation: diceReveal 0.4s ease-out forwards;
    font-size: 2.8rem;
}

.die-preview.result-crit {
    border-color: var(--crit);
    color: var(--crit);
    box-shadow: 0 0 20px rgba(243, 156, 18, 0.6), 0 0 40px rgba(243, 156, 18, 0.3);
}

.die-preview.result-fumble {
    border-color: var(--failure);
    color: var(--failure);
    box-shadow: 0 0 20px rgba(231, 76, 60, 0.5);
}

.die-preview.result-success {
    border-color: var(--success);
    color: var(--success);
    box-shadow: 0 0 15px rgba(46, 204, 113, 0.4);
}

.die-preview.result-failure {
    border-color: var(--failure);
    color: var(--failure);
}

.roll-container.result-crit {
    border-color: var(--crit);
    background: linear-gradient(135deg, #2a2010 0%, #1a1a2e 100%);
}

.roll-container.result-fumble {
    border-color: var(--failure);
}

.roll-btn {
    padding: 0.8rem 2rem;
    background: linear-gradient(135deg, var(--accent) 0%, #c0392b 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: 2px;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
}

.roll-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(233, 69, 96, 0.4);
}

.roll-btn:active {
    transform: scale(0.98);
}

.roll-btn:disabled {
    background: var(--text-dim);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.roll-info {
    font-size: 0.85rem;
    color: var(--text-dim);
    text-align: center;
}

.roll-result-text {
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    color: var(--text-primary);
    text-align: center;
    margin-top: 0.3rem;
    font-weight: 600;
}

.roll-prompt-msg {
    text-align: center;
    font-weight: 600;
    color: var(--accent-gold);
    border-left-color: var(--accent-gold);
}

@keyframes diceShake {
    0% { transform: rotate(0deg) scale(1); }
    25% { transform: rotate(-8deg) scale(1.05); }
    50% { transform: rotate(8deg) scale(1); }
    75% { transform: rotate(-4deg) scale(1.03); }
    100% { transform: rotate(0deg) scale(1); }
}

@keyframes diceReveal {
    0% { transform: scale(1.3); }
    50% { transform: scale(0.9); }
    100% { transform: scale(1); }
}

/* Loading indicator */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--text-dim);
    border-radius: 50%;
    border-top-color: var(--accent);
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-dim);
}

/* Gold Display */
.gold-value {
    color: var(--accent-gold) !important;
}

/* Quest Selection Screen */
#quest-screen {
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, var(--bg-dark) 0%, #0a0a1a 100%);
    overflow-y: auto;
    padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom) 0;
}

.quest-select-box {
    text-align: center;
    padding: 2.5rem;
    max-width: 800px;
    width: 90%;
    max-height: 100%;
}

.quest-select-box h1 {
    font-size: 2rem;
    color: var(--accent-gold);
    margin-bottom: 0.5rem;
}

.difficulty-selector {
    margin-top: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

.difficulty-selector label {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.difficulty-selector select {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.4rem 0.8rem;
    font-size: 0.95rem;
    cursor: pointer;
}

.difficulty-selector select:focus {
    border-color: var(--accent-gold);
    outline: none;
}

.quest-cards {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1.5rem;
}

.quest-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.5rem;
    text-align: left;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.quest-card:hover {
    border-color: var(--accent-gold);
    box-shadow: 0 0 10px rgba(212, 160, 23, 0.2);
}

.quest-card h3 {
    color: var(--accent);
    font-size: 1.2rem;
    margin-bottom: 0.4rem;
}

.quest-level {
    display: inline-block;
    background: var(--bg-light);
    color: var(--accent-gold);
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.quest-card p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 1rem;
    line-height: 1.4;
}

.quest-start-btn {
    float: right;
}

/* Quest Complete Actions */
.quest-complete-actions {
    display: flex;
    justify-content: center;
    padding: 1rem;
    margin: 0.5rem 0;
}

.quest-complete-actions .btn-primary {
    padding: 0.8rem 2rem;
    font-size: 1.1rem;
    background: linear-gradient(135deg, var(--accent-gold) 0%, #b8860b 100%);
    color: #1a1a2e;
}

.quest-complete-actions .btn-primary:hover {
    box-shadow: 0 0 15px rgba(212, 160, 23, 0.5);
}

/* Loot Flash — highlight new rare+ items */
@keyframes lootFlash {
    0% { background: transparent; box-shadow: none; }
    15% { background: rgba(218, 165, 32, 0.2); box-shadow: 0 0 8px rgba(218, 165, 32, 0.4); }
    100% { background: transparent; box-shadow: none; }
}
.loot-flash { animation: lootFlash 3s ease-out; border-radius: 4px; }

/* Quest Celebration Card */
.quest-celebration {
    text-align: center; padding: 1.5rem; margin: 1rem 0;
    border: 2px solid var(--accent-gold); border-radius: 12px;
    background: linear-gradient(135deg, rgba(218, 165, 32, 0.08) 0%, rgba(184, 134, 11, 0.04) 100%);
    animation: celebrationAppear 0.5s ease-out;
}
@keyframes celebrationAppear {
    0% { opacity: 0; transform: scale(0.9); }
    100% { opacity: 1; transform: scale(1); }
}
.qc-header {
    font-size: 1.3rem; font-weight: 700; color: var(--accent-gold);
    letter-spacing: 0.15em; margin-bottom: 0.3rem;
    text-shadow: 0 0 10px rgba(218, 165, 32, 0.4);
}
.qc-name { font-size: 1.1rem; color: var(--text-primary); margin-bottom: 1rem; }
.qc-rewards { display: flex; justify-content: center; gap: 2rem; margin-bottom: 0.8rem; }
.qc-reward {
    font-size: 1.2rem; font-weight: 700; color: var(--accent-gold);
    padding: 0.3rem 1rem; border: 1px solid rgba(218, 165, 32, 0.3);
    border-radius: 6px; background: rgba(218, 165, 32, 0.08);
}
.qc-stats { color: var(--text-dim); font-size: 0.85rem; margin-bottom: 1rem; }
.quest-celebration .btn-primary {
    padding: 0.8rem 2rem; font-size: 1.1rem;
    background: linear-gradient(135deg, var(--accent-gold) 0%, #b8860b 100%);
    color: #1a1a2e;
}
.quest-celebration .btn-primary:hover {
    box-shadow: 0 0 15px rgba(212, 160, 23, 0.5);
}

/* Shop Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
}

.shop-panel {
    background: var(--bg-medium);
    border: 1px solid var(--accent-gold);
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.shop-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
}

.shop-header h2 {
    color: var(--accent-gold);
    font-size: 1.2rem;
}

.shop-close {
    padding: 0.3rem 0.6rem;
    font-size: 0.9rem;
    min-width: auto;
}

.shop-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
}

.shop-tab {
    flex: 1;
    padding: 0.6rem;
    background: var(--bg-dark);
    color: var(--text-secondary);
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-weight: 600;
    transition: color 0.2s, border-color 0.2s;
}

.shop-tab.active {
    color: var(--accent-gold);
    border-bottom-color: var(--accent-gold);
}

.shop-tab:hover {
    color: var(--text-primary);
}

.shop-view {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.shop-items {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.shop-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    transition: border-color 0.2s;
}

.shop-item:hover {
    border-color: var(--accent-gold);
}

.shop-item-info {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.shop-item-name {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.95rem;
}

.shop-item-desc {
    color: var(--text-dim);
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.shop-item-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: 0.8rem;
}

.shop-item-price {
    color: var(--accent-gold);
    font-weight: 700;
    font-size: 0.9rem;
    min-width: 45px;
    text-align: right;
}

.shop-item-stock {
    color: var(--text-dim);
    font-size: 0.8rem;
    min-width: 25px;
}

.shop-buy-btn, .shop-sell-btn {
    padding: 0.3rem 0.8rem;
    font-size: 0.85rem;
}

.shop-message {
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
    text-align: center;
    min-height: 2rem;
}

.shop-msg-success {
    color: var(--success);
}

.shop-msg-error {
    color: var(--failure);
}

.shop-empty {
    color: var(--text-dim);
    text-align: center;
    padding: 1.5rem;
    font-style: italic;
}

.shop-btn {
    padding: 0.3rem 0.8rem;
    font-size: 0.85rem;
    margin-left: 0.5rem;
    background: linear-gradient(135deg, var(--accent-gold) 0%, #b8860b 100%);
    color: var(--bg-dark);
    border: none;
    font-weight: 700;
}

.shop-btn:hover {
    box-shadow: 0 0 10px rgba(212, 160, 23, 0.4);
}

/* ========== Mobile Responsive ========== */

/* Mobile tab bar — hidden on desktop */
.mobile-tabs {
    display: none;
}

/* Mobile-hidden utility — only active on mobile via media query */

@media (max-width: 768px) {
    /* --- Mobile Tab Bar --- */
    .mobile-tabs {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 50;
        background: var(--bg-medium);
        border-top: 1px solid var(--border);
    }

    .mobile-tab {
        flex: 1;
        padding: 0.75rem;
        height: 48px;
        background: var(--bg-medium);
        color: var(--text-secondary);
        border: none;
        font-size: 1rem;
        font-weight: 600;
        cursor: pointer;
        transition: color 0.2s, background 0.2s;
    }

    .mobile-tab.active {
        color: var(--accent-gold);
        background: var(--bg-card);
        border-top: 2px solid var(--accent-gold);
    }

    /* Hide settings section on Character tab — only show via Settings tab */
    .sidebar #settings-section {
        display: none !important;
    }

    /* When Settings tab is active, hide all sidebar sections except settings */
    .sidebar.settings-only .sidebar-section:not(#settings-section) {
        display: none !important;
    }

    .sidebar.settings-only #settings-section {
        display: block !important;
        max-width: 400px;
        width: 100%;
        margin: 0 auto;
    }

    /* Settings panel — comfortable layout on mobile */
    .sidebar.settings-only {
        justify-content: flex-start;
        padding-top: 1.5rem;
    }

    /* Stack settings rows vertically on mobile for easier thumb reach */
    .settings-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
        padding: 0.8rem 0;
    }

    .settings-label {
        font-size: 1rem;
    }

    .settings-control {
        width: 100%;
        gap: 0.75rem;
    }

    /* Wider sliders for thumb targeting */
    .settings-control .audio-slider {
        flex: 1;
        width: auto;
        min-width: 100px;
        height: 8px;
    }

    .settings-control .audio-slider::-webkit-slider-thumb {
        width: 24px;
        height: 24px;
    }

    .settings-control .audio-slider::-moz-range-thumb {
        width: 24px;
        height: 24px;
    }

    .settings-control .btn-tts {
        min-width: 110px;
        text-align: center;
    }

    /* --- Game Layout --- */
    .game-layout {
        flex-direction: column;
        height: 100vh;
        padding-bottom: 48px; /* space for tab bar */
    }

    .chat-panel {
        flex: 1;
        border-right: none;
        min-height: 0;
    }

    .sidebar {
        width: 100%;
        flex: 1;
        overflow-y: auto;
        overscroll-behavior: contain;
        flex-direction: column;
        padding-bottom: 1rem;
    }

    /* Toggle visibility via JS-added class */
    .mobile-hidden {
        display: none !important;
    }

    /* --- Typography --- */
    .login-box h1 {
        font-size: 1.8rem;
    }

    .creation-box h1 {
        font-size: 1.4rem;
    }

    .quest-select-box h1 {
        font-size: 1.5rem;
    }

    .chat-header h2 {
        font-size: 1rem;
    }

    .sidebar-section h3 {
        font-size: 0.8rem;
    }

    /* --- Touch Targets --- */
    button {
        min-height: 44px;
    }

    .btn-equip {
        min-height: 44px;
        padding: 6px 12px;
        font-size: 0.8rem;
    }

    .action-bar input {
        font-size: 16px; /* prevents iOS zoom */
    }

    .action-bar button {
        min-width: 70px;
    }

    .action-suggestions {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding: 0.4rem 0.75rem;
    }

    .suggestion-btn {
        font-size: 0.78rem;
        padding: 0.3rem 0.65rem;
    }

    .roll-btn {
        width: 100%;
        padding: 1rem;
    }

    .roll-container {
        max-width: 100%;
    }

    /* --- Login/Register Screen --- */
    .login-box {
        min-width: unset;
        width: 90%;
        max-width: 360px;
        padding: 2rem 1.5rem;
    }

    /* --- Character Select --- */
    .charselect-box {
        width: 95%;
        padding: 1.5rem;
    }

    .charselect-box h1 {
        font-size: 1.5rem;
    }

    .character-grid {
        grid-template-columns: 1fr;
    }

    /* --- Character Creation --- */
    .creation-box {
        min-width: unset;
        width: 95%;
        max-width: 500px;
        padding: 1.5rem;
        max-height: 90vh;
        overflow-y: auto;
    }

    #create-char-btn {
        font-size: 1rem;
    }

    /* --- Quest Selection --- */
    .quest-select-box {
        width: 95%;
        padding: 1.5rem;
    }

    .quest-card {
        padding: 1rem;
    }

    .quest-start-btn {
        float: none;
        width: 100%;
        margin-top: 0.5rem;
    }

    /* --- Shop Modal --- */
    .shop-panel {
        width: 95%;
        max-width: 95vw;
        max-height: 85vh;
    }

    .shop-buy-btn, .shop-sell-btn {
        min-height: 44px;
        padding: 0.5rem 0.8rem;
    }

    /* --- Mobile Sidebar Map --- */
    #map-container {
        touch-action: manipulation;
    }

    #map-container svg text {
        font-size: 11px !important;
    }

    .map-expand-hint {
        display: block;
        text-align: center;
        font-size: 0.75rem;
        color: var(--text-dim);
        padding: 0.3rem 0;
        cursor: pointer;
    }

    /* --- Chat Messages --- */
    .message {
        max-width: 95%;
    }

    .chat-messages {
        padding: 1rem;
    }

    /* --- Location badge + shop button in header --- */
    .chat-header {
        padding: 0.6rem 1rem;
        padding-top: calc(0.6rem + env(safe-area-inset-top));
        flex-wrap: wrap;
        gap: 0.4rem;
    }

    .chat-header-right {
        flex-wrap: wrap;
        gap: 0.3rem;
    }

    .location-badge {
        font-size: 0.75rem;
    }

    .shop-btn {
        font-size: 0.8rem;
        padding: 0.3rem 0.7rem;
        min-height: 44px;
    }
}

/* Level-Up Modal */
.levelup-panel {
    background: var(--bg-medium);
    border: 2px solid var(--accent-gold);
    border-radius: 12px;
    width: 90%;
    max-width: 420px;
    padding: 1.5rem;
    text-align: center;
}

.levelup-panel h2 {
    color: var(--accent-gold);
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.levelup-info {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.levelup-options {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.levelup-btn {
    display: flex;
    flex-direction: column;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-card);
    cursor: pointer;
    text-align: left;
    transition: border-color 0.2s, background 0.2s;
}

.levelup-btn:hover {
    border-color: var(--accent-gold);
    background: var(--bg-dark);
}

.levelup-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.levelup-btn-primary {
    border-color: var(--accent-gold);
}

.levelup-btn-label {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.95rem;
}

.levelup-btn-desc {
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-top: 0.2rem;
}

/* ASI Modal */
.asi-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    justify-content: center;
}

.asi-tab {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.85rem;
    transition: border-color 0.2s, color 0.2s;
}

.asi-tab.active {
    border-color: var(--accent-gold);
    color: var(--accent-gold);
}

.asi-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.asi-ability-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.6rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-card);
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.asi-ability-btn:hover:not(:disabled) {
    border-color: var(--accent-gold);
    background: var(--bg-dark);
}

.asi-ability-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.asi-ability-btn.selected {
    border-color: var(--accent-gold);
    background: rgba(218, 165, 32, 0.15);
}

.asi-ability-name {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
}

.asi-ability-score {
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-top: 0.15rem;
}

/* Very small screens — stack stat grid to 2 cols */
@media (max-width: 360px) {
    .stat-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .login-box h1 {
        font-size: 1.5rem;
    }

    .creation-box {
        padding: 1rem;
    }
}

/* Magic Item Rarity Colors */
.rarity-common { color: #e0e0e0; }
.rarity-uncommon { color: #2ecc71; }
.rarity-rare { color: #3498db; }
.rarity-very-rare { color: #9b59b6; }
.rarity-legendary {
    color: #f39c12;
    animation: legendaryGlow 2s ease-in-out infinite;
}

@keyframes legendaryGlow {
    0% { text-shadow: 0 0 4px rgba(243, 156, 18, 0.3); }
    50% { text-shadow: 0 0 12px rgba(243, 156, 18, 0.7), 0 0 20px rgba(243, 156, 18, 0.3); }
    100% { text-shadow: 0 0 4px rgba(243, 156, 18, 0.3); }
}

.attunement-indicator {
    font-size: 0.7rem;
    color: var(--accent-gold);
    margin-left: 4px;
}

.shop-item-rarity {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.shop-attunement-label {
    font-size: 0.7rem;
    color: var(--accent-gold);
    font-style: italic;
}

.proficiency-warning {
    display: inline-block;
    background: #8b0000;
    color: #ffd700;
    font-size: 0.7rem;
    padding: 1px 6px;
    border-radius: 3px;
    margin-left: 4px;
    font-weight: bold;
    text-transform: uppercase;
}

/* Inspiration */
.has-inspiration {
    color: var(--accent-gold);
    font-weight: bold;
}

.inspiration-btn {
    display: block;
    width: 100%;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    background: transparent;
    border: 2px solid var(--accent-gold);
    color: var(--accent-gold);
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    font-size: 0.85rem;
}

.inspiration-btn:hover {
    background: rgba(212, 160, 23, 0.15);
}

.inspiration-btn.active {
    background: var(--accent-gold);
    color: var(--bg-dark);
}

/* Class Features */
.cf-line {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.3rem 0;
    font-size: 0.9rem;
}

.cf-value {
    color: var(--accent-gold);
    font-weight: 700;
}

.cf-raging {
    text-align: center;
    font-weight: 800;
    font-size: 0.85rem;
    letter-spacing: 2px;
    color: #e74c3c;
    background: rgba(231, 76, 60, 0.15);
    border: 1px solid rgba(231, 76, 60, 0.4);
    border-radius: 4px;
    padding: 0.3rem;
    margin-bottom: 0.4rem;
    animation: ragePulse 1.5s ease-in-out infinite;
}

@keyframes ragePulse {
    0% { box-shadow: 0 0 4px rgba(231, 76, 60, 0.3); }
    50% { box-shadow: 0 0 12px rgba(231, 76, 60, 0.7); }
    100% { box-shadow: 0 0 4px rgba(231, 76, 60, 0.3); }
}

/* Class feature bonus damage tags in dice roll */
.cf-bonus {
    font-weight: 700;
    font-size: 0.85em;
}

.cf-sneak { color: #9b59b6; }
.cf-smite { color: #f1c40f; }
.cf-rage { color: #e74c3c; }
.cf-stun { color: #e67e22; }
.cf-colossus { color: #27ae60; }
.cf-flourish { color: #e91e63; }
.cf-blessing { color: #ff9800; }
.cf-sacred { color: #29b6f6; }
.cf-potent { color: #ab47bc; }
.cf-life { color: #66bb6a; }
.cf-gwm { color: #e74c3c; }
.cf-sharpshooter { color: #3498db; }
.cf-savage { color: #e67e22; }

/* Feat toggle buttons in sidebar */
.cf-toggle { cursor: pointer; }
.cf-toggle:hover { background: rgba(255,255,255,0.05); border-radius: 4px; }
.cf-toggle-btn {
    font-weight: 700; font-size: 0.8rem; padding: 0.15rem 0.5rem;
    border-radius: 4px; border: 1px solid var(--border);
    color: var(--text-dim); background: transparent;
}
.cf-toggle-btn.active {
    color: #2ecc71; border-color: #2ecc71;
    background: rgba(46, 204, 113, 0.15);
}
.cf-toggle-btn.inactive {
    color: #e74c3c; border-color: rgba(231, 76, 60, 0.4);
    background: rgba(231, 76, 60, 0.08);
}
.cf-hint { color: var(--text-dim); font-size: 0.7rem; }
.cf-lucky-has { color: var(--accent-gold); font-weight: 700; }
.cf-lucky-empty { color: var(--text-dim); }

/* Feat cards in ASI modal */
.feat-card {
    padding: 0.6rem; margin-bottom: 0.5rem;
    border: 1px solid var(--border); border-radius: 8px;
    background: var(--bg-card); cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}
.feat-card:hover { border-color: var(--accent-gold); background: var(--bg-dark); }
.feat-card.selected { border-color: var(--accent-gold); background: rgba(218, 165, 32, 0.15); }
.feat-card-name { color: var(--accent-gold); font-weight: 700; margin-bottom: 0.3rem; }
.feat-card-desc { color: var(--text-secondary); font-size: 0.8rem; line-height: 1.3; }

/* Resilient ability sub-selector */
.resilient-selector { padding: 0.5rem 0; display: flex; flex-wrap: wrap; gap: 0.3rem; align-items: center; }
.resilient-selector p { width: 100%; color: var(--text-secondary); font-size: 0.8rem; margin-bottom: 0.2rem; }
.resilient-ability-btn {
    padding: 0.3rem 0.5rem; font-size: 0.75rem;
    border: 1px solid var(--border); border-radius: 4px;
    background: var(--bg-card); color: var(--text-primary);
    cursor: pointer;
}
.resilient-ability-btn:hover:not(:disabled) { border-color: var(--accent-gold); }
.resilient-ability-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.resilient-ability-btn.selected { border-color: var(--accent-gold); background: rgba(218, 165, 32, 0.15); }

/* Subclass Modal */
.subclass-panel {
    background: var(--bg-medium);
    border: 2px solid var(--accent-gold);
    border-radius: 12px;
    width: 90%;
    max-width: 440px;
    padding: 1.5rem;
    text-align: center;
    animation: subclassReveal 0.4s ease-out;
}

@keyframes subclassReveal {
    0% { transform: scale(0.8); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.subclass-panel h2 {
    color: var(--accent-gold);
    font-size: 1.5rem;
    margin-bottom: 0.3rem;
    text-shadow: 0 0 12px rgba(212, 160, 23, 0.5);
}

.subclass-info {
    color: var(--text-secondary);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.subclass-card {
    background: var(--bg-card);
    border: 1px solid var(--accent-gold);
    border-radius: 10px;
    padding: 1.2rem;
    text-align: left;
    margin-bottom: 1rem;
}

.subclass-name {
    color: var(--accent);
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
}

.subclass-desc {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 0.8rem;
}

.subclass-features {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.subclass-feature {
    background: var(--bg-dark);
    border-radius: 6px;
    padding: 0.6rem 0.8rem;
}

.subclass-feature-name {
    color: var(--accent-gold);
    font-weight: 700;
    font-size: 0.85rem;
}

.subclass-feature-desc {
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-top: 0.2rem;
    line-height: 1.3;
}

.subclass-accept {
    width: 100%;
    padding: 0.8rem;
    font-size: 1.1rem;
    background: linear-gradient(135deg, var(--accent-gold) 0%, #b8860b 100%);
    color: var(--bg-dark);
    font-weight: 700;
}

.subclass-accept:hover {
    box-shadow: 0 0 15px rgba(212, 160, 23, 0.5);
}

/* Subclass display in sidebar */
.subclass-badge {
    color: var(--text-dim);
    font-size: 0.85em;
    font-weight: 400;
}

/* Divine Smite toggle button */
.smite-btn {
    display: block;
    width: 100%;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    background: transparent;
    border: 2px solid #f1c40f;
    color: #f1c40f;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    font-size: 0.85rem;
}

.smite-btn:hover {
    background: rgba(241, 196, 15, 0.15);
}

.smite-btn.active {
    background: #f1c40f;
    color: var(--bg-dark);
}

/* Lucky toggle button */
.lucky-btn {
    display: block;
    width: 100%;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    background: transparent;
    border: 2px solid #1abc9c;
    color: #1abc9c;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    font-size: 0.85rem;
}

.lucky-btn:hover {
    background: rgba(26, 188, 156, 0.15);
}

.lucky-btn.active {
    background: #1abc9c;
    color: var(--bg-dark);
}

/* Auth Links */
.auth-link {
    margin-top: 1.2rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.auth-link a {
    color: var(--accent-blue);
    text-decoration: none;
    font-weight: 600;
}

.auth-link a:hover {
    text-decoration: underline;
}

/* Register Screen */
#register-screen {
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, var(--bg-dark) 0%, #0a0a1a 100%);
}

#register-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

input[type="email"] {
    padding: 0.75rem 1rem;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
}

/* Character Select Screen */
#charselect-screen {
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, var(--bg-dark) 0%, #0a0a1a 100%);
    overflow-y: auto;
}

.charselect-box {
    text-align: center;
    padding: 2.5rem;
    max-width: 700px;
    width: 90%;
}

.charselect-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.charselect-box h1 {
    font-size: 2rem;
    color: var(--accent-gold);
}

.btn-logout {
    padding: 0.4rem 1rem;
    font-size: 0.85rem;
}

.character-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
    margin-bottom: 1.5rem;
}

.char-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.2rem;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.1s;
    position: relative;
}
.btn-delete-char {
    position: absolute;
    top: 6px;
    right: 8px;
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-size: 1rem;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    line-height: 1;
    opacity: 0;
    transition: opacity 0.2s, color 0.2s, background 0.2s;
}
.char-card:hover .btn-delete-char {
    opacity: 1;
}
.btn-delete-char:hover {
    color: #ff4444;
    background: rgba(255, 68, 68, 0.1);
}

.char-card:hover {
    border-color: var(--accent-gold);
    box-shadow: 0 0 12px rgba(212, 160, 23, 0.2);
    transform: translateY(-2px);
}

.char-card.has-campaign {
    border-left: 3px solid var(--accent-green);
}

.char-card-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.3rem;
}

.char-card-info {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
}

.char-card-quest {
    font-size: 0.8rem;
    color: var(--accent-green);
    font-style: italic;
}

.char-card-no-quest {
    color: var(--text-dim);
}

.char-card.char-dead {
    opacity: 0.5;
    border-left: 3px solid #8b0000;
    cursor: default;
}
.char-card.char-dead:hover {
    transform: none;
    box-shadow: none;
    border-color: #8b0000;
}
.char-card-fallen {
    color: #8b0000 !important;
    font-style: italic;
}
.skull-icon {
    font-size: 0.9em;
}

.charselect-empty {
    color: var(--text-secondary);
    font-size: 1.1rem;
    padding: 2rem;
}

.btn-new-char {
    padding: 0.8rem 2rem;
    font-size: 1rem;
}

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

.btn-account {
    padding: 0.4rem 1rem;
    font-size: 0.85rem;
}

.btn-graveyard {
    padding: 0.6rem 1.5rem;
    font-size: 0.9rem;
    color: #8b0000;
    border-color: #8b0000;
}
.btn-graveyard:hover {
    background: rgba(139, 0, 0, 0.15);
}

/* Graveyard Modal */
.graveyard-panel {
    background: var(--bg-dark);
    border: 1px solid #4a1a1a;
    border-radius: 12px;
    max-width: 600px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    padding: 1.5rem;
}
.graveyard-subtitle {
    color: var(--text-dim);
    font-style: italic;
    margin-bottom: 1rem;
    text-align: center;
}
.graveyard-entries {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.graveyard-card {
    background: var(--bg-card);
    border: 1px solid #4a1a1a;
    border-left: 3px solid #8b0000;
    border-radius: 8px;
    padding: 1rem;
}
.graveyard-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: #c0392b;
    margin-bottom: 0.3rem;
}
.graveyard-info {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.3rem;
}
.graveyard-quest {
    font-size: 0.8rem;
    color: var(--text-dim);
    font-style: italic;
    margin-bottom: 0.5rem;
}
.graveyard-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Account Modal */
.account-panel {
    background: var(--bg-medium);
    border: 1px solid var(--border);
    border-radius: 12px;
    max-width: 550px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    padding: 1.5rem;
}

.account-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.account-header h2 {
    color: var(--accent-gold);
    font-size: 1.4rem;
}

.account-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.account-tab {
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 0.6rem 1.2rem;
    cursor: pointer;
    font-size: 0.95rem;
    border-bottom: 2px solid transparent;
    transition: color 0.2s, border-color 0.2s;
}

.account-tab:hover {
    color: var(--text-primary);
}

.account-tab.active {
    color: var(--accent-gold);
    border-bottom-color: var(--accent-gold);
}

/* Stats Grid */
.stats-grid {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.stats-category {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 1rem;
}

.stats-category h4 {
    color: var(--accent-gold);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.6rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.4rem;
}

.stats-entries {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.3rem 1rem;
}

.stat-entry {
    display: flex;
    justify-content: space-between;
    padding: 0.2rem 0;
    font-size: 0.85rem;
}

.stat-entry-label {
    color: var(--text-secondary);
}

.stat-entry-value {
    color: var(--text-primary);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* Account Settings Forms */
.account-form-section {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.account-form-section h3 {
    color: var(--text-primary);
    font-size: 1rem;
    margin-bottom: 0.8rem;
}

.account-form-section form {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.account-form-section input {
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.btn-sm {
    padding: 0.45rem 1rem;
    font-size: 0.85rem;
    align-self: flex-start;
    margin-top: 0.25rem;
}

.account-message {
    font-size: 0.85rem;
    margin-top: 0.4rem;
    min-height: 1.2em;
}

.account-message.success {
    color: var(--accent-green);
}

.account-message.error {
    color: var(--failure);
}

/* QoL Header Buttons */
.btn-qol {
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
}
.btn-qol:hover {
    color: var(--accent-gold);
    border-color: var(--accent-gold);
}

/* Journal */
.journal-quest {
    padding: 1rem;
}
.journal-quest-name {
    color: var(--accent-gold);
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}
.journal-objective {
    color: var(--text-primary);
    font-size: 0.9rem;
    margin-bottom: 1rem;
    line-height: 1.4;
}
.journal-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}
.journal-stat {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    display: flex;
    flex-direction: column;
}
.journal-stat-label {
    color: var(--text-dim);
    font-size: 0.75rem;
    text-transform: uppercase;
}
.journal-stat-value {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.95rem;
}

/* Journal flags */
.journal-flags-title {
    color: var(--accent);
    font-size: 0.85rem;
    text-transform: uppercase;
    margin: 0.75rem 0 0.4rem;
    letter-spacing: 0.05em;
}
.journal-flags-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}
.journal-flag {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 3px;
    font-size: 0.8rem;
    font-weight: 600;
}
.journal-flag.flag-complete {
    background: rgba(46, 204, 113, 0.15);
    color: #2ecc71;
    border: 1px solid rgba(46, 204, 113, 0.3);
}
.journal-flag.flag-incomplete {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-dim);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Bestiary */
.bestiary-panel {
    max-width: 550px;
}
.bestiary-encountered {
    opacity: 0.6;
}
.bestiary-defeated {
    border-left: 3px solid var(--accent-green);
}
.bestiary-details {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    margin-top: 0.4rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}
.bestiary-desc {
    color: var(--text-dim);
    font-style: italic;
    margin-top: 0.2rem;
}

/* How to Play Slideshow */
.howto-panel {
    max-width: 600px;
}
.howto-body {
    padding: 1.5rem;
    min-height: 200px;
    overflow-y: auto;
    max-height: 50vh;
}
.howto-body h3 {
    color: var(--accent-gold);
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
}
.howto-body p {
    color: var(--text-primary);
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 0.6rem;
}
.howto-highlight {
    color: var(--accent);
    font-weight: 600;
}
.howto-key {
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.1rem 0.4rem;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    color: var(--accent-gold);
}
.howto-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.5rem;
    border-top: 1px solid var(--border);
    background: var(--bg-card);
}
.howto-nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.howto-indicator {
    color: var(--text-dim);
    font-size: 0.8rem;
    margin-right: 0.5rem;
}
.howto-dismiss-label {
    color: var(--text-secondary);
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
}
.howto-dismiss-label input {
    cursor: pointer;
}

@media (max-width: 768px) {
    .howto-panel {
        max-width: 95vw;
        max-height: 90vh;
    }
    .howto-footer {
        flex-direction: column;
        gap: 0.5rem;
    }
}

/* Tutorial Toast */
.tutorial-toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 2000;
    display: none;
    animation: slideInRight 0.3s ease-out;
}
.tutorial-content {
    background: var(--bg-medium);
    border: 1px solid var(--accent-gold);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    max-width: 320px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}
.tutorial-content h4 {
    color: var(--accent-gold);
    font-size: 0.95rem;
    margin-bottom: 0.4rem;
}
.tutorial-content p {
    color: var(--text-primary);
    font-size: 0.85rem;
    line-height: 1.4;
    margin-bottom: 0.6rem;
}
@keyframes slideInRight {
    from { transform: translateX(100px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Fullscreen Quest Map */
.fullmap-panel {
    background: var(--bg-dark);
    border: 1px solid var(--accent-gold);
    border-radius: 12px;
    width: 90vw;
    max-width: 800px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.fullmap-viewport {
    flex: 1;
    overflow: auto;
    position: relative;
    cursor: grab;
    min-height: 300px;
    max-height: calc(90vh - 120px);
    touch-action: none;
}

.fullmap-viewport:active {
    cursor: grabbing;
}

#fullmap-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-width: 100%;
    min-height: 100%;
    transform-origin: 0 0;
}

#fullmap-container svg {
    display: block;
}

.fullmap-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem 1.2rem;
    padding: 0.6rem 1rem;
    border-top: 1px solid var(--border);
    background: var(--bg-medium);
    justify-content: center;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.fullmap-legend-item {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.fullmap-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.fullmap-dot-current {
    background: var(--accent-gold);
    box-shadow: 0 0 6px rgba(212, 160, 23, 0.6);
}

.fullmap-dot-adjacent {
    background: var(--bg-dark);
    border: 2px dashed var(--accent-gold);
}

.fullmap-dot-visited {
    background: var(--accent-blue);
}

.fullmap-dot-unvisited {
    background: var(--text-dim);
    opacity: 0.5;
}

.fullmap-poi-icon {
    font-weight: 700;
    font-size: 0.95rem;
}

/* Pulsing glow for current position on fullscreen map */
@keyframes mapPulse {
    0% { filter: drop-shadow(0 0 4px rgba(212, 160, 23, 0.4)); }
    50% { filter: drop-shadow(0 0 12px rgba(212, 160, 23, 0.9)); }
    100% { filter: drop-shadow(0 0 4px rgba(212, 160, 23, 0.4)); }
}

.fullmap-node-current {
    fill: var(--accent-gold);
    stroke: var(--accent-gold);
    stroke-width: 3;
    animation: mapPulse 2s ease-in-out infinite;
}

.fullmap-node-adjacent {
    stroke: var(--accent-gold);
    stroke-width: 2;
    stroke-dasharray: 4 3;
}

/* Sidebar map heading — clickable expand */
.map-heading {
    cursor: pointer;
    transition: color 0.2s;
}

.map-heading:hover {
    color: var(--accent-gold);
}

.map-expand-icon {
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-left: 0.3rem;
}

.map-heading:hover .map-expand-icon {
    color: var(--accent-gold);
}

/* --- World Map --- */
#worldmap-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-width: 100%;
    min-height: 100%;
    transform-origin: 0 0;
}

#worldmap-container svg {
    display: block;
    width: 100%;
    height: auto;
}

.wm-node-completed {
    stroke: #2ecc71;
    stroke-width: 2.5;
}

.wm-node-available {
    stroke: #8b7d6b;
    stroke-width: 1.5;
}

.wm-node-locked {
    stroke: #555;
    stroke-width: 1;
}

.wm-legend-check {
    color: #2ecc71;
    font-weight: 700;
    font-size: 0.9rem;
}

.btn-world-map {
    margin-bottom: 1rem;
    font-size: 0.95rem;
}

.btn-world-map-sidebar {
    width: 100%;
    margin-top: 0.5rem;
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem;
}

/* World Map Tooltip */
.wm-tooltip {
    position: absolute;
    background: var(--bg-dark);
    border: 1px solid var(--accent-gold);
    border-radius: 8px;
    padding: 0.8rem 1rem;
    max-width: 250px;
    z-index: 1001;
    pointer-events: none;
}

.wm-tooltip h4 {
    color: var(--accent-gold);
    margin-bottom: 0.2rem;
    font-size: 1rem;
}

.wm-tooltip-quest {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-style: italic;
    margin-bottom: 0.3rem;
}

.wm-tooltip-level {
    color: var(--text-dim);
    font-size: 0.8rem;
    margin-bottom: 0.4rem;
}

.wm-tooltip p:last-of-type {
    color: var(--text-primary);
    font-size: 0.85rem;
    line-height: 1.4;
    margin-bottom: 0.4rem;
}

.wm-tooltip-status {
    font-size: 0.8rem;
    font-weight: 600;
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
}

.wm-status-completed { background: rgba(46, 204, 113, 0.2); color: #2ecc71; }
.wm-status-active { background: rgba(212, 160, 23, 0.2); color: var(--accent-gold); }
.wm-status-available { background: rgba(139, 125, 107, 0.2); color: #8b7d6b; }
.wm-status-locked { background: rgba(100, 100, 100, 0.2); color: #666; }

.map-expand-hint {
    display: none;
}

@media (max-width: 768px) {
    .fullmap-panel {
        width: 98vw;
        max-width: 98vw;
        max-height: 94vh;
        border-radius: 8px;
    }

    .fullmap-viewport {
        max-height: calc(94vh - 100px);
        min-height: 250px;
    }

    .fullmap-legend {
        gap: 0.4rem 0.8rem;
        font-size: 0.7rem;
        padding: 0.5rem 0.6rem;
    }

    .fullmap-legend-item {
        min-height: 32px;
        align-items: center;
    }
}

/* Services weapon input */
.svc-weapon-input {
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.3rem 0.5rem;
    color: var(--text-primary);
    font-size: 0.8rem;
}

/* Group Play */
#group-screen {
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, var(--bg-dark) 0%, #0a0a1a 100%);
    overflow-y: auto;
}

.group-box {
    text-align: center;
    padding: 2.5rem;
    max-width: 700px;
    width: 90%;
}

.group-box h1 {
    font-size: 2rem;
    color: var(--accent-gold);
}

.btn-group-play {
    margin-top: 0.5rem;
    background: var(--bg-light);
    color: var(--accent-gold);
    border: 1px solid var(--accent-gold);
}

.btn-group-play:hover:not(:disabled) {
    background: rgba(212, 160, 23, 0.15);
}
.btn-group-play.btn-disabled {
    opacity: 0.4;
    cursor: not-allowed;
    border-color: var(--text-dim);
    color: var(--text-dim);
}

.group-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    text-align: left;
}

.group-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem 1.2rem;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.group-card:hover {
    border-color: var(--accent-gold);
    box-shadow: 0 0 10px rgba(212, 160, 23, 0.2);
}

.group-card-name {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text-primary);
    margin-bottom: 0.2rem;
}

.group-card-info {
    color: var(--text-dim);
    font-size: 0.85rem;
    margin-bottom: 0.4rem;
}

.group-card-members {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
}

.group-member-tag {
    background: var(--bg-dark);
    color: var(--text-secondary);
    padding: 0.15rem 0.5rem;
    border-radius: 12px;
    font-size: 0.8rem;
}

.group-detail {
    text-align: left;
    margin-top: 1rem;
}

.group-member-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0.8rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 0.4rem;
    font-size: 0.9rem;
}

.btn-danger {
    color: var(--failure) !important;
    border-color: var(--failure) !important;
}

.btn-danger:hover {
    background: rgba(231, 76, 60, 0.15) !important;
}

/* Party Sidebar */
.party-member {
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.5rem 0.6rem;
    margin-bottom: 0.4rem;
    transition: border-color 0.2s;
}

.party-member-active {
    border-color: var(--accent-gold);
    box-shadow: 0 0 6px rgba(212, 160, 23, 0.3);
}

.party-member-down {
    opacity: 0.5;
}

.party-member-swappable {
    cursor: pointer;
}

.party-member-swappable:hover {
    border-color: var(--accent-gold);
    background: rgba(212, 160, 23, 0.08);
}

.party-swap-hint {
    font-size: 0.7rem;
    color: var(--text-dim);
    text-align: center;
    margin-top: 0.15rem;
}

.party-member-name {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-primary);
}

.party-member-info {
    font-size: 0.75rem;
    color: var(--text-dim);
}

.party-hp-bar {
    height: 14px;
    background: var(--bg-medium);
    border-radius: 3px;
    position: relative;
    overflow: hidden;
    margin-top: 0.2rem;
}

.party-hp-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease;
}

.party-hp-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.65rem;
    font-weight: 700;
    text-shadow: 0 0 3px rgba(0,0,0,0.8);
}

.party-member-conditions {
    font-size: 0.7rem;
    color: var(--failure);
    margin-top: 0.15rem;
    font-style: italic;
}

.btn-end-turn {
    width: 100%;
    margin-top: 0.5rem;
    padding: 0.6rem;
    background: var(--accent-blue);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-end-turn:hover {
    background: #2980b9;
}

.btn-end-turn:disabled {
    background: var(--text-dim);
    cursor: not-allowed;
}

/* Heal Target Picker */
.heal-target-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.heal-target-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem;
    cursor: pointer;
    transition: border-color 0.2s;
}

.heal-target-card:hover {
    border-color: var(--accent-green);
    box-shadow: 0 0 8px rgba(46, 204, 113, 0.2);
}

.heal-target-name {
    font-weight: 600;
    color: var(--text-primary);
}

.heal-target-info {
    font-size: 0.8rem;
    color: var(--text-dim);
    margin-bottom: 0.3rem;
}

/* Mobile QoL adjustments */
@media (max-width: 768px) {
    .btn-qol {
        padding: 0.2rem 0.4rem;
        font-size: 0.7rem;
    }
    .tutorial-toast {
        bottom: 5rem;
        right: 0.5rem;
        left: 0.5rem;
    }
    .tutorial-content {
        max-width: none;
    }
    .bestiary-panel {
        max-width: 95%;
    }
}

/* --- Combat HP Bars --- */
.combatant-row {
    padding: 4px 6px;
    margin-bottom: 3px;
    border-radius: 4px;
    background: rgba(255,255,255,0.03);
}
.combatant-player {
    border-left: 3px solid var(--accent-blue);
}
.combatant-monster {
    border-left: 3px solid var(--accent);
}
.combatant-dead {
    opacity: 0.4;
}
.combatant-fled {
    opacity: 0.5;
}
.combatant-dying {
    border-left-color: var(--failure);
    animation: dying-pulse 1.5s ease-in-out infinite;
}
@keyframes dying-pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}
.combatant-name {
    font-size: 0.82em;
    font-weight: 600;
    margin-bottom: 2px;
    color: var(--text-primary);
}
.combatant-hp {
    display: flex;
    align-items: center;
    gap: 6px;
}
.hp-bar-track {
    flex: 1;
    height: 8px;
    background: rgba(255,255,255,0.08);
    border-radius: 4px;
    overflow: hidden;
}
.hp-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.4s ease;
}
.hp-green { background: var(--accent-green); }
.hp-yellow { background: #f39c12; }
.hp-red { background: var(--failure); }
.hp-bar-text {
    font-size: 0.72em;
    color: var(--text-secondary);
    min-width: 48px;
    text-align: right;
}
.combatant-status-text {
    font-size: 0.72em;
    color: var(--text-dim);
    font-style: italic;
}
.combatant-conds {
    margin-top: 2px;
}
.cond-mini {
    display: inline-block;
    font-size: 0.65em;
    padding: 1px 4px;
    border-radius: 3px;
    background: rgba(233,69,96,0.2);
    color: var(--accent);
    margin-right: 3px;
    text-transform: uppercase;
}
.combat-round-label {
    text-align: center;
    font-size: 0.75em;
    color: var(--text-dim);
    margin-top: 4px;
}

/* --- Spell Tooltip --- */
.spell-tooltip {
    position: fixed;
    z-index: 9999;
    background: var(--bg-card);
    border: 1px solid var(--accent-gold);
    border-radius: 8px;
    padding: 10px 14px;
    max-width: 320px;
    min-width: 200px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.6);
}
.spell-tooltip-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 4px;
}
.spell-tooltip-header span:first-child {
    font-weight: 700;
    color: var(--accent-gold);
    font-size: 0.95em;
}
.spell-tooltip-level {
    font-size: 0.75em;
    color: var(--text-secondary);
    background: rgba(212,160,23,0.15);
    padding: 2px 6px;
    border-radius: 3px;
}
.spell-tooltip-stats {
    font-size: 0.78em;
    color: var(--accent-blue);
    margin-bottom: 6px;
    line-height: 1.4;
}
.spell-tooltip-desc {
    font-size: 0.75em;
    color: var(--text-secondary);
    line-height: 1.4;
}
.spell-name-link {
    cursor: pointer;
    color: var(--accent-blue);
    border-bottom: 1px dotted var(--accent-blue);
    transition: color 0.2s;
}
.spell-name-link:hover {
    color: var(--accent-gold);
}

/* --- Combat Recap Card --- */
.combat-recap-card {
    background: linear-gradient(135deg, rgba(46,204,113,0.1) 0%, rgba(52,152,219,0.1) 100%);
    border: 1px solid var(--accent-green);
    border-radius: 8px;
    padding: 12px 16px;
    margin: 8px 0;
    text-align: center;
}
.recap-header {
    font-size: 1.1em;
    font-weight: 700;
    color: var(--accent-green);
    margin-bottom: 8px;
}
.recap-stats {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
}
.recap-stat {
    display: inline-block;
    font-size: 0.82em;
    padding: 3px 8px;
    border-radius: 4px;
    background: rgba(255,255,255,0.06);
}
.recap-dealt { color: var(--accent-green); }
.recap-taken { color: var(--failure); }
.recap-slain { color: var(--accent); }
.recap-fled { color: var(--text-dim); }
.recap-crit { color: var(--crit); }
.recap-rounds { color: var(--accent-blue); }

/* ---- Level-Up Celebration Overlay ---- */
.level-up-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
}
.level-up-content {
    text-align: center;
    animation: levelUpEntrance 0.6s ease-out;
}
.level-up-text {
    font-size: 3rem;
    font-weight: 900;
    color: var(--accent-gold);
    letter-spacing: 0.2em;
    text-shadow: 0 0 10px rgba(212, 160, 23, 0.6), 0 0 30px rgba(212, 160, 23, 0.3);
    animation: levelUpGlow 1.2s ease-in-out infinite;
}
.level-up-number {
    font-size: 5rem;
    font-weight: 900;
    color: var(--accent-gold);
    text-shadow: 0 0 15px rgba(212, 160, 23, 0.7), 0 0 40px rgba(212, 160, 23, 0.4);
    animation: levelUpGlow 1.2s ease-in-out infinite 0.15s;
}
@keyframes levelUpEntrance {
    0% { transform: scale(0.3); opacity: 0; }
    70% { transform: scale(1.05); opacity: 1; }
    100% { transform: scale(1.0); opacity: 1; }
}
@keyframes levelUpGlow {
    0% { text-shadow: 0 0 10px rgba(212, 160, 23, 0.4), 0 0 30px rgba(212, 160, 23, 0.2); }
    50% { text-shadow: 0 0 20px rgba(212, 160, 23, 0.8), 0 0 50px rgba(212, 160, 23, 0.5), 0 0 80px rgba(212, 160, 23, 0.2); }
    100% { text-shadow: 0 0 10px rgba(212, 160, 23, 0.4), 0 0 30px rgba(212, 160, 23, 0.2); }
}

/* ---- Location Transition Animation ---- */
.location-transition {
    position: absolute;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    background: transparent;
}
.location-transition.fade-in {
    animation: locationFadeIn 300ms ease-out forwards;
}
.location-transition.fade-out {
    animation: locationFadeOut 300ms ease-in forwards;
}
.location-transition-name {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--accent-gold);
    letter-spacing: 0.15em;
    text-shadow: 0 0 10px rgba(212, 160, 23, 0.5), 0 0 25px rgba(212, 160, 23, 0.3);
    opacity: 0;
}
.location-transition-name.reveal {
    animation: locationNameReveal 500ms ease-out forwards;
}
@keyframes locationFadeIn {
    0% { background: transparent; }
    100% { background: rgba(0, 0, 0, 0.6); }
}
@keyframes locationFadeOut {
    0% { background: rgba(0, 0, 0, 0.6); }
    100% { background: transparent; }
}
@keyframes locationNameReveal {
    0% { transform: scale(0.8); opacity: 0; }
    100% { transform: scale(1.0); opacity: 1; }
}

/* === Puzzle Panel === */
.puzzle-panel {
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    border: 1px solid #c9a84c;
    border-radius: 8px;
    padding: 12px 16px;
    margin: 8px 0;
    display: none;
}
.puzzle-header {
    color: #c9a84c;
    font-weight: bold;
    font-size: 1.05em;
    margin-bottom: 6px;
}
.puzzle-riddle {
    color: #e0d8c8;
    font-style: italic;
    font-size: 1.1em;
    margin: 8px 0;
    padding: 8px 12px;
    background: rgba(0,0,0,0.3);
    border-left: 3px solid #c9a84c;
    border-radius: 4px;
}
.puzzle-info {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-top: 6px;
}
.puzzle-hints {
    color: #8899aa;
    font-size: 0.9em;
}
.puzzle-close {
    color: #4caf50;
    font-size: 0.9em;
    font-weight: bold;
}

/* === Skill Challenge Panel === */
.challenge-panel {
    background: linear-gradient(135deg, #1a1a2e, #1e2a1e);
    border: 1px solid #4caf50;
    border-radius: 8px;
    padding: 12px 16px;
    margin: 8px 0;
    display: none;
}
.challenge-header {
    color: #4caf50;
    font-weight: bold;
    font-size: 1.05em;
    margin-bottom: 4px;
}
.challenge-obstacle {
    color: #e0d8c8;
    font-size: 0.95em;
    margin-bottom: 8px;
}
.challenge-progress {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.challenge-bar {
    position: relative;
    height: 20px;
    background: rgba(0,0,0,0.4);
    border-radius: 4px;
    overflow: hidden;
}
.challenge-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s ease;
}
.success-fill { background: #4caf50; }
.failure-fill { background: #c0392b; }
.challenge-label {
    position: absolute;
    top: 50%;
    left: 8px;
    transform: translateY(-50%);
    color: #fff;
    font-size: 0.8em;
    font-weight: bold;
    text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}
.challenge-options {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}
.challenge-option {
    background: rgba(76, 175, 80, 0.15);
    border: 1px solid rgba(76, 175, 80, 0.4);
    color: #8bbb8b;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.85em;
}

/* === Combat Objective Banner === */
.objective-banner {
    background: linear-gradient(90deg, rgba(201, 168, 76, 0.15), rgba(201, 168, 76, 0.05));
    border: 1px solid rgba(201, 168, 76, 0.4);
    color: #c9a84c;
    font-weight: bold;
    text-align: center;
    padding: 6px 12px;
    margin: 6px 0;
    border-radius: 4px;
    font-size: 0.95em;
    display: none;
}

/* --- Spellbook Modal --- */
.spellbook-panel {
    background: #1a1a2e;
    border: 2px solid #c8a96e;
    border-radius: 12px;
    padding: 20px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    color: #e0d6c2;
}
.spellbook-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}
.spellbook-header h2 {
    margin: 0;
    color: #c8a96e;
}
.sb-header {
    display: flex;
    gap: 16px;
    padding: 8px 12px;
    background: #252545;
    border-radius: 6px;
    margin-bottom: 12px;
    font-size: 0.9em;
}
.sb-section { margin-bottom: 16px; }
.sb-section h4 {
    color: #c8a96e;
    margin: 8px 0 4px;
    border-bottom: 1px solid #333;
    padding-bottom: 4px;
}
.sb-slots { display: flex; flex-direction: column; gap: 4px; }
.sb-slot-row { display: flex; align-items: center; gap: 6px; }
.sb-slot-label { font-size: 0.85em; min-width: 60px; color: #aaa; }
.sb-dot {
    width: 12px; height: 12px;
    border-radius: 50%;
    display: inline-block;
}
.sb-dot.available { background: #4a9; }
.sb-dot.used { background: #444; border: 1px solid #666; }
.sb-card {
    background: #252545;
    border-radius: 6px;
    padding: 8px 12px;
    margin: 4px 0;
    cursor: pointer;
    transition: background 0.2s;
}
.sb-card:hover { background: #303060; }
.sb-card.no-slots { opacity: 0.6; }
.sb-card-header { display: flex; justify-content: space-between; align-items: center; }
.sb-spell-name { font-weight: bold; color: #e0d6c2; }
.sb-badge.no-slots {
    background: #633;
    color: #faa;
    font-size: 0.75em;
    padding: 2px 6px;
    border-radius: 4px;
}
.sb-card-meta { font-size: 0.8em; color: #aaa; margin-top: 2px; }
.sb-card-desc {
    font-size: 0.85em;
    color: #ccc;
    margin-top: 4px;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s;
}
.sb-card.expanded .sb-card-desc { max-height: 200px; }
.btn-sm {
    font-size: 0.7em;
    padding: 2px 8px;
    margin-left: 8px;
    vertical-align: middle;
}

/* NPC Portraits */
.npc-portrait {
    border-radius: 50%;
    border: 2px solid var(--accent-gold);
    object-fit: cover;
    flex-shrink: 0;
}
.npc-portrait-sm { width: 40px; height: 40px; }
.npc-portrait-md { width: 64px; height: 64px; }
.npc-portrait-chat {
    width: 48px;
    height: 48px;
}
.message-with-portrait {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}
.npc-dialogue-text { flex: 1; }
.shop-header .npc-portrait { margin-right: 0.75rem; }

@media (max-width: 768px) {
    .npc-portrait-chat { width: 36px; height: 36px; }
    .npc-portrait-sm { width: 32px; height: 32px; }
}
