/* Fantasy RPG Initiative Tracker Styles */

/* Import fantasy-style fonts */
@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;700&family=Crimson+Text:ital,wght@0,400;0,600;1,400&display=swap');

/* CSS Variables for theming */
:root {
    /* Light mode colors */
    --bg-primary: #f5f0e6;
    --bg-secondary: #e8e0d0;
    --bg-card: #fff8f0;
    --text-primary: #2c1810;
    --text-secondary: #5c4030;
    --accent-gold: #c9a227;
    --accent-red: #8b0000;
    --accent-green: #2e5a1c;
    --accent-blue: #1e3a5f;
    --border-color: #8b7355;
    --shadow-color: rgba(0, 0, 0, 0.2);
    --player-color: #1e3a5f;
    --enemy-color: #8b0000;
    --npc-color: #2e5a1c;
    --delayed-bg: #f0e6d8;
    --lightbox-bg: rgba(0, 0, 0, 0.7);
    --input-bg: #fff;
    --button-bg: #5c4030;
    --button-text: #f5f0e6;
    --active-turn-bg: #fff3cd;
    --active-turn-border: #c9a227;
    --header-bg-start: #eadfc9;
    --header-bg-end: #d8c4a3;
    --header-kicker: #6f4c32;
    --header-title: #381d13;
    --header-control-bg: rgba(255, 252, 244, 0.72);
}

[data-theme="dark"] {
    /* Dark mode colors */
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-card: #0f3460;
    --text-primary: #e8e0d0;
    --text-secondary: #a89880;
    --accent-gold: #ffd700;
    --accent-red: #dc3545;
    --accent-green: #28a745;
    --accent-blue: #17a2b8;
    --border-color: #4a4a6a;
    --shadow-color: rgba(0, 0, 0, 0.5);
    --player-color: #17a2b8;
    --enemy-color: #dc3545;
    --npc-color: #28a745;
    --delayed-bg: #1a1a3e;
    --input-bg: #2a2a4e;
    --button-bg: #4a4a6a;
    --button-text: #e8e0d0;
    --active-turn-bg: #3d3d1a;
    --active-turn-border: #ffd700;
    --header-bg-start: #121c33;
    --header-bg-end: #1a2a49;
    --header-kicker: #d6b65f;
    --header-title: #fff2cf;
    --header-control-bg: rgba(7, 15, 30, 0.48);
}

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

body {
    font-family: 'Crimson Text', Georgia, serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    transition: background-color 0.3s, color 0.3s;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Cinzel', 'Times New Roman', serif;
    font-weight: 600;
}

/* Main container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    min-height: 76px;
    padding: 10px 24px;
    background:
        radial-gradient(circle at 18% -90%, rgba(255, 255, 255, 0.2), transparent 46%),
        linear-gradient(115deg, var(--header-bg-start), var(--header-bg-end));
    border-bottom: 1px solid var(--accent-gold);
    box-shadow: 0 4px 16px var(--shadow-color);
    margin-bottom: 14px;
    position: relative;
    z-index: 100;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.header-emblem {
    width: 48px;
    height: 48px;
    padding: 2px;
    color: var(--header-title);
    background: var(--header-control-bg);
    border: 1px solid color-mix(in srgb, var(--accent-gold) 70%, transparent);
    border-radius: 12px;
    box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--accent-gold) 16%, transparent);
    flex: 0 0 auto;
}

.header-emblem-image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.header-emblem-dark {
    display: none;
}

[data-theme="dark"] .header-emblem-light {
    display: none;
}

[data-theme="dark"] .header-emblem-dark {
    display: block;
}

.site-title {
    display: flex;
    flex-direction: column;
    gap: 0;
    min-width: 0;
    margin: 0;
    line-height: 1;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.22);
}

.site-title-kicker {
    color: var(--header-kicker);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.18em;
    line-height: 1.1;
    text-transform: uppercase;
}

.site-title-table {
    margin-top: 2px;
    color: var(--header-title);
    font-size: 1.65rem;
    font-weight: 700;
    letter-spacing: 0.015em;
    line-height: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.header-right {
    display: flex;
    align-items: flex-start;
    gap: 15px;
}

/* Theme toggle */
.theme-toggle {
    align-self: flex-start;
    width: 40px;
    min-height: 40px;
    margin-top: 5px;
    padding: 8px;
    background: var(--header-control-bg);
    border: 1px solid color-mix(in srgb, var(--header-title) 32%, transparent);
    cursor: pointer;
    color: var(--header-title);
    border-radius: 999px;
    transition: border-color 0.2s, background 0.2s, transform 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle:hover {
    background: var(--bg-card);
    border-color: var(--accent-gold);
    transform: translateY(-1px);
}

.theme-toggle:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--accent-gold) 45%, transparent);
    outline-offset: 2px;
}

.theme-icon {
    display: block;
    flex: 0 0 auto;
}

/* Header button */
.header-btn {
    font-size: 0.8rem;
    padding: 6px 12px;
}

/* Profile picture */
.profile-container {
    position: relative;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
}

/* Always in flow (reserving its line) even when empty, so picking or
   dropping a character doesn't resize the header - just its visibility
   toggles, via the .visible class. */
.profile-name {
    font-family: 'Cinzel', serif;
    font-size: 0.7rem;
    line-height: 1;
    height: 1em;
    color: var(--text-secondary);
    max-width: 90px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    visibility: hidden;
}

.profile-name.visible {
    visibility: visible;
}

.profile-pic {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 3px solid var(--border-color);
    object-fit: cover;
    background: var(--bg-card);
    transition: border-color 0.3s;
}

.profile-pic:hover {
    border-color: var(--accent-gold);
}

.profile-pic.placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: var(--text-secondary);
}

/* Profile context menu */
.context-menu {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 220px;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: 10px;
    box-shadow: 0 8px 20px var(--shadow-color);
    overflow: hidden;
    z-index: 500;
}

.context-menu.active {
    display: flex;
    flex-direction: column;
}

.context-menu-item {
    display: block;
    width: 100%;
    padding: 12px 16px;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    font-family: 'Crimson Text', serif;
    font-size: 0.95rem;
    text-align: left;
    cursor: pointer;
    transition: background 0.2s;
}

.context-menu-item:last-child {
    border-bottom: none;
}

.context-menu-item:hover {
    background: var(--bg-secondary);
    color: var(--accent-gold);
}

/* Round counter */
.round-counter {
    text-align: center;
    padding: 8px 15px;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 12px;
    display: none;
}

.round-counter.visible {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.round-counter h2 {
    font-size: 1.1rem;
    color: var(--accent-gold);
    margin: 0;
}

.round-number {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* Initiative list */
.initiative-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

/* Character card */
.character-card {
    --type-color: var(--border-color);
    display: flex;
    align-items: center;
    padding: 8px 15px 8px 18px;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: 10px;
    box-shadow: 0 4px 6px var(--shadow-color);
    transition: all 0.3s;
    cursor: pointer;
    position: relative;
}

.character-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px var(--shadow-color);
}

.character-card.active-turn {
    background: var(--active-turn-bg);
    border-color: var(--active-turn-border);
    box-shadow: 0 0 15px var(--accent-gold);
    animation: active-turn-glow 3.2s ease-in-out infinite;
}

@keyframes active-turn-glow {
    0%, 100% {
        box-shadow: 0 0 12px color-mix(in srgb, var(--accent-gold) 72%, transparent);
    }
    50% {
        box-shadow: 0 0 27px var(--accent-gold);
    }
}

.character-card.delayed {
    margin-left: 40px;
    opacity: 0.7;
    background: var(--delayed-bg);
    border-style: dashed;
}

.character-card.no-initiative {
    opacity: 0.6;
    filter: grayscale(40%);
}

.character-card.player {
    --type-color: var(--player-color);
}

.character-card.enemy {
    --type-color: var(--enemy-color);
}

.character-card.npc {
    --type-color: var(--npc-color);
}

.character-card.player,
.character-card.enemy,
.character-card.npc {
    border-left: 12px solid var(--type-color);
}

/* Turn arrow */
.turn-arrow {
    position: absolute;
    left: -35px;
    font-size: 1.5rem;
    color: var(--accent-gold);
    animation: turn-arrow-pulse 3.2s ease-in-out infinite;
    display: none;
}

.character-card.active-turn .turn-arrow {
    display: block;
}

@keyframes turn-arrow-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.8; }
}

@media (prefers-reduced-motion: reduce) {
    .character-card.active-turn,
    .turn-arrow {
        animation: none;
    }
}

/* Card content - the portrait is sized to fill the row's own height with
   just a little breathing room, rather than bleeding past the card edge
   (which fought with the row's own flex sizing and clipped badly). */
.card-photo {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    border: 4px solid var(--type-color, var(--border-color));
    object-fit: cover;
    margin-right: 16px;
    background: var(--bg-secondary);
    flex-shrink: 0;
}

.card-photo.placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 34px;
    color: var(--text-secondary);
}

.card-info {
    flex: 1;
    min-width: 0;
}

.card-name {
    font-family: 'Cinzel', serif;
    font-size: 1.6rem;
    font-weight: 600;
    line-height: 1.05;
    margin-bottom: 1px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Minor now - the name carries the visual weight this used to share with it. */
.card-type {
    font-size: 0.7rem;
    line-height: 1.1;
    color: var(--type-color, var(--text-secondary));
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
    opacity: 1;
}

.card-initiative {
    font-family: 'Cinzel', serif;
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--accent-gold);
    min-width: 50px;
    text-align: center;
}

/* Buttons */
.btn {
    font-family: 'Cinzel', serif;
    font-size: 1rem;
    padding: 10px 20px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    background: var(--button-bg);
    color: var(--button-text);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px var(--shadow-color);
}

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

.btn:disabled {
    opacity: 0.48;
    cursor: not-allowed;
    filter: grayscale(35%);
    transform: none;
    box-shadow: none;
}

.btn:disabled:hover {
    transform: none;
    box-shadow: none;
}

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

.btn-primary:hover {
    background: #d4af37;
}

.btn-danger {
    background: var(--accent-red);
    color: #fff;
    border-color: var(--accent-red);
}

.btn-danger:hover {
    opacity: 0.9;
}

.btn-success {
    background: var(--accent-green);
    color: #fff;
    border-color: var(--accent-green);
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.85rem;
}

/* Action buttons container */
.action-buttons {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    margin: 20px 0;
}

.action-buttons .button-row {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

/* "Who are you?" box - same idea as the GM panel, much lighter */
.identity-box {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
}

.identity-box h3 {
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 15px;
}

/* GM Panel */
.gm-panel {
    background: var(--bg-secondary);
    border: 3px solid var(--accent-gold);
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 20px;
}

.gm-panel h2 {
    color: var(--accent-gold);
    margin-bottom: 15px;
    text-align: center;
    font-size: 1.4rem;
}

.command-palette {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--border-color);
}

.combat-dock {
    position: fixed;
    left: 50%;
    bottom: max(16px, env(safe-area-inset-bottom));
    z-index: 900;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    background: color-mix(in srgb, var(--bg-card) 90%, transparent);
    box-shadow: 0 10px 32px rgba(0, 0, 0, 0.3), 0 2px 8px rgba(0, 0, 0, 0.18);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translate(-50%, calc(100% + 32px));
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0s linear 0.2s;
}

.combat-dock.visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translate(-50%, 0);
    transition-delay: 0s;
}

.combat-dock-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    min-width: 48px;
    height: 48px;
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: 50%;
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    touch-action: manipulation;
    transition: transform 0.15s ease, border-color 0.15s ease, filter 0.15s ease;
}

.combat-dock-button:hover {
    border-color: var(--accent-gold);
    filter: brightness(1.08);
    transform: translateY(-1px);
}

.combat-dock-button:active {
    transform: translateY(1px) scale(0.96);
}

.combat-dock-button:focus-visible {
    outline: 3px solid var(--accent-blue);
    outline-offset: 2px;
}

.combat-dock-button svg {
    width: 24px;
    height: 24px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.4;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.combat-dock-scroll {
    border-color: var(--accent-gold);
    background: var(--accent-gold);
    color: #2c1810;
}

.combat-dock-end {
    border-color: var(--accent-red);
    background: var(--accent-red);
    color: #fff;
}

/* Stable section */
.stable-section {
    margin-top: 20px;
}

.stable-section h3 {
    color: var(--text-primary);
    margin-bottom: 15px;
    font-size: 1.2rem;
}

.collapsible-section {
    margin-top: 20px;
}

.collapsible-heading {
    margin: 0;
}

.section-toggle-button {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 4px 0 10px;
    border: 0;
    background: transparent;
    color: var(--text-primary);
    font: inherit;
    text-align: left;
    cursor: pointer;
    user-select: none;
}

.section-toggle-button:hover {
    color: var(--accent-gold);
}

.section-toggle-button:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--accent-gold) 45%, transparent);
    outline-offset: 3px;
    border-radius: 4px;
}

.section-chevron {
    width: 20px;
    height: 20px;
    flex: 0 0 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.4;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform 0.2s ease;
}

.section-toggle-button[aria-expanded="true"] .section-chevron {
    transform: rotate(90deg);
}

.character-subsection h4 {
    margin-bottom: 15px;
    color: var(--text-primary);
    font-size: 1.05rem;
}

[hidden] {
    display: none !important;
}

.roster-subgroup {
    margin-top: 14px;
}

.generic-baddie-group {
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border-color);
}

.stable-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.stable-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.stable-creature {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.stable-creature:hover {
    border-color: var(--accent-gold);
}

.stable-creature.enemy {
    border-left: 4px solid var(--enemy-color);
}

.stable-creature.npc {
    border-left: 4px solid var(--npc-color);
}

.stable-creature.player {
    border-left: 4px solid var(--player-color);
}

.roster-badge {
    margin-left: 12px;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-family: 'Cinzel', serif;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    white-space: nowrap;
}

.roster-badge.on-board {
    color: #fff;
    background: var(--accent-green);
    font-weight: 600;
}

.stable-creature img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 10px;
    object-fit: cover;
}

.stable-creature .placeholder-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 10px;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

/* Lightbox */
.lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--lightbox-bg);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.lightbox.active {
    display: flex;
}

.lightbox-content {
    background: var(--bg-card);
    border: 3px solid var(--border-color);
    border-radius: 15px;
    padding: 30px;
    max-width: 450px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 10px 30px var(--shadow-color);
}

.lightbox-content h2 {
    text-align: center;
    margin-bottom: 20px;
    color: var(--accent-gold);
    font-size: 1.5rem;
}

.lightbox-close {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 28px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: color 0.3s;
}

.lightbox-close:hover {
    color: var(--accent-red);
}

/* Form styles */
.form-group {
    margin-bottom: 20px;
}

.clear-board-divider {
    height: 0;
    margin: 2px 0 18px;
    border: 0;
    border-top: 1px solid var(--border-color);
    opacity: 0.7;
}

.form-group > label,
.form-label {
    display: block;
    margin-bottom: 8px;
    font-family: 'Cinzel', serif;
    font-weight: 600;
    color: var(--text-primary);
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group select {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    font-family: 'Crimson Text', serif;
    background: var(--input-bg);
    color: var(--text-primary);
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent-gold);
}

.photo-drop-target {
    position: relative;
}

form.is-saving {
    position: relative;
}

.form-save-status {
    display: none;
}

form.is-saving .form-save-status {
    position: absolute;
    inset: -10px;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    border: 3px solid var(--accent-gold);
    border-radius: 12px;
    background: color-mix(in srgb, var(--bg-card) 88%, transparent);
    color: var(--text-primary);
    font-family: 'Cinzel', serif;
    font-size: 1.1rem;
    font-weight: 700;
    text-align: center;
}

.form-save-status::before {
    content: '';
    width: 20px;
    height: 20px;
    margin-right: 10px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-gold);
    border-radius: 50%;
    animation: save-spinner 0.8s linear infinite;
}

@keyframes save-spinner {
    to { transform: rotate(360deg); }
}

.photo-drop-target::after {
    content: "Drop photo here";
    position: absolute;
    inset: -10px;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px dashed var(--accent-gold);
    border-radius: 12px;
    background: color-mix(in srgb, var(--bg-card) 92%, transparent);
    color: var(--text-primary);
    font-family: 'Cinzel', serif;
    font-size: 1.1rem;
    font-weight: 700;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s;
}

.photo-drop-target.photo-drop-active::after {
    opacity: 1;
}

.photo-picker {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

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

.form-group .photo-picker-button {
    display: inline-flex;
    align-items: center;
    width: auto;
    margin: 0;
}

.photo-file-input:focus-visible + .photo-picker-button {
    outline: 3px solid color-mix(in srgb, var(--accent-gold) 45%, transparent);
    outline-offset: 2px;
}

.photo-file-name {
    width: 100%;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-style: italic;
    overflow-wrap: anywhere;
}

/* Initiative is never more than a couple digits - a wide text-style input
   looks odd for it, so this is deliberately small and square-ish. */
.initiative-input-square {
    width: 90px !important;
    height: 70px;
    padding: 0 !important;
    text-align: center;
    font-size: 2rem !important;
    font-family: 'Cinzel', serif;
    font-weight: 700;
}

/* Hide the native up/down spinner - it sits inside the box on one side,
   which throws off the centering of the digits themselves. The -1/-5/+5/+1
   buttons already cover everything the spinner would do. */
.initiative-input-square::-webkit-outer-spin-button,
.initiative-input-square::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.initiative-input-square {
    -moz-appearance: textfield;
}

/* Label sits above the whole row so it doesn't add extra height to just
   the box's flex item - that extra height is what used to throw off the
   speed buttons' vertical centering against the box. */
.initiative-group {
    text-align: center;
    margin: 10px 0;
}

.initiative-label {
    display: block;
    margin-bottom: 8px;
    font-family: 'Cinzel', serif;
    font-weight: 600;
    color: var(--text-primary);
}

/* Speed buttons flanking an initiative box: -1 -5 [box] +5 +1 */
.initiative-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.speed-btn {
    width: 44px;
    height: 44px;
    padding: 0;
    font-size: 0.95rem;
    flex-shrink: 0;
}

.form-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 20px;
}

.compact-lightbox {
    max-width: 380px;
}

#gm-password-form .form-group {
    max-width: 280px;
    margin: 0 auto 20px;
    text-align: center;
}

#gm-password {
    text-align: center;
    font-family: inherit;
    font-size: 1.1rem;
    letter-spacing: 0.12em;
    box-shadow: inset 0 1px 3px var(--shadow-color);
}

.form-error {
    margin: 10px 0 0;
    color: var(--accent-red);
    font-weight: 700;
    text-align: center;
}

/* Photo preview */
.photo-preview {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    border: 3px solid var(--border-color);
    object-fit: cover;
    margin: 10px auto;
    display: block;
    background: var(--bg-secondary);
}

/* Toggle switch for delay */
.toggle-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.toggle-switch {
    position: relative;
    width: 60px;
    height: 30px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 30px;
    transition: 0.3s;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 2px;
    bottom: 2px;
    background-color: var(--text-secondary);
    border-radius: 50%;
    transition: 0.3s;
}

input:checked + .toggle-slider {
    background-color: var(--accent-gold);
}

input:checked + .toggle-slider:before {
    transform: translateX(30px);
    background-color: var(--bg-primary);
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

.empty-state p {
    font-size: 1.2rem;
    margin-bottom: 10px;
}

/* Drag handle */
.drag-handle {
    position: absolute;
    left: 4px;
    top: 50%;
    transform: translateY(-50%);
    padding: 4px;
    color: var(--text-secondary);
    opacity: 0;
    transition: opacity 0.2s, color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: none;
}

.drag-handle.active {
    opacity: 0.5;
    cursor: grab;
}

.drag-handle.active:hover {
    opacity: 1;
    color: var(--accent-gold);
}

.drag-handle.active:active {
    cursor: grabbing;
}

/* SortableJS styles */
.sortable-ghost {
    opacity: 0.4;
    background: var(--accent-gold) !important;
}

.sortable-chosen {
    box-shadow: 0 8px 20px var(--shadow-color);
    transform: scale(1.02);
}

.sortable-drag {
    opacity: 1;
}

/* GM mode indicator */
.gm-badge {
    position: absolute;
    bottom: 0;
    left: 50%;
    z-index: 2;
    transform: translate(-50%, 50%);
    background: var(--accent-gold);
    color: #2c1810;
    padding: 3px 13px 2px;
    border: 2px solid var(--header-bg-end);
    border-radius: 999px;
    box-shadow: 0 2px 6px var(--shadow-color);
    font-family: 'Cinzel', serif;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    line-height: 1.2;
}

/* Responsive design */
@media (max-width: 768px) {
    .header {
        gap: 8px;
        min-height: 66px;
        padding: 8px 12px;
        text-align: left;
    }

    .header-brand {
        gap: 8px;
    }

    .header-emblem {
        width: 40px;
        height: 40px;
        border-radius: 10px;
    }

    .site-title-kicker {
        font-size: 0.56rem;
    }

    .site-title-table {
        font-size: 1.25rem;
    }

    .header-right {
        gap: 8px;
        flex: 0 0 auto;
    }

    .character-card {
        flex-wrap: wrap;
    }

    .card-photo {
        width: 64px;
        height: 64px;
        margin: 0 12px 0 0;
    }

    .card-photo.placeholder {
        font-size: 30px;
    }

    .card-name {
        font-size: 1.3rem;
    }

    .card-initiative {
        font-size: 1.5rem;
    }

    .command-palette {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }

    .btn.speed-btn {
        width: 44px;
    }

    .character-card.delayed {
        margin-left: 20px;
    }

    .turn-arrow {
        left: -25px;
        font-size: 1.2rem;
    }

    .lightbox-content .delete-character-container {
        position: static;
        bottom: auto;
        right: auto;
        text-align: center;
        margin-top: 20px;
    }

    /* The numeric keyboard consumes the lower half of a phone screen. Keep
       Set Initiative near the upper third instead of vertically centering it
       into the newly reduced visual viewport. */
    #edit-entry-lightbox {
        align-items: flex-start;
        height: 100dvh;
        padding-top: clamp(16px, 10dvh, 72px);
    }

    #edit-entry-lightbox .lightbox-content {
        max-height: calc(100dvh - clamp(32px, 20dvh, 144px));
    }
}

@media (max-width: 420px) {
    .header-emblem {
        display: none;
    }

    .site-title-table {
        max-width: 130px;
    }
}

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

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

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

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-gold);
}


/* Status messages */
.status-message {
    text-align: center;
    padding: 15px;
    margin-bottom: 15px;
    border-radius: 8px;
    font-family: 'Cinzel', serif;
}

.status-message.info {
    background: var(--accent-blue);
    color: #fff;
}

.status-message.warning {
    background: var(--accent-gold);
    color: var(--bg-primary);
}

/* Delete character button */
.delete-character-container {
    position: absolute;
    bottom: 15px;
    right: 15px;
}

.btn-delete-character {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.3s, transform 0.3s;
    padding: 5px;
}

.btn-delete-character:hover {
    opacity: 1;
    transform: scale(1.2);
}

/* Subtle Become GM footer button */
.become-gm-footer {
    text-align: center;
    padding: 30px 0 10px;
    margin-top: 20px;
}

.become-gm-footer a {
    display: inline-block;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.85rem;
    font-family: 'Cinzel', serif;
    padding: 6px 14px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-secondary);
    opacity: 0.6;
    transition: opacity 0.2s, background 0.2s;
}

.become-gm-footer a:hover {
    opacity: 1;
    background: var(--button-bg);
    color: var(--button-text);
}
