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

body {
    font-family: var(--ember-ui-font, "Trebuchet MS", "Segoe UI", "Gill Sans", sans-serif);
    line-height: 1.6;
    color: var(--ember-text, #eadfcf);
    background: transparent;
    padding: clamp(0.75rem, 2vw, 2rem);
}

.container {
    max-width: 1800px;
    margin: 0 auto;
}

.nav-back {
    margin-bottom: 2rem;
}

.nav-back a {
    color: var(--ember-accent-strong);
    text-decoration: none;
    font-weight: 500;
}

.nav-back a:hover {
    opacity: 0.85;
}

header {
    text-align: left;
    margin-bottom: 1.25rem;
}

.page-generator-title {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--ember-text, #eadfcf);
    margin: 1.5rem 0 1rem;
    letter-spacing: 0.02em;
}

.subtitle {
    color: #a0a0a0;
}

.card {
    background: #252525;
    border: 1px solid #333;
    border-radius: 10px;
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.card h2 {
    font-size: 1.1rem;
    color: #f0f0f0;
    margin-bottom: 0.75rem;
}

.tracker-layout {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.left-column {
    display: grid;
    grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
    gap: 1rem;
    align-items: stretch;
}

.left-column .card,
.encounter-column {
    margin-bottom: 0;
}

.left-column > .card {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.status-panel {
    grid-column: 1;
}

.status-panel h2 {
    font-size: 1.25rem;
    margin-bottom: 0.75rem;
    color: #f3eee6;
}

.status-panel .status-grid p {
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
    margin: 0;
    font-size: 1rem;
    line-height: 1.5;
}

.status-panel .status-grid .label {
    min-width: 4.7rem;
    display: inline-block;
    color: #d9d0c3;
}

.status-panel .nav-group {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-top: 0.9rem;
    flex-wrap: nowrap;
}

.status-panel .nav-label {
    min-width: 5.4rem;
    font-size: 1rem;
    font-weight: 700;
    color: #f0ebe2;
}

.status-panel .combatant-controls,
.status-panel .turn-controls {
    display: flex;
    gap: 0.55rem;
    align-items: center;
    flex-wrap: nowrap;
}

.status-panel .combatant-controls button,
.status-panel .turn-controls button {
    min-width: 5.1rem;
    padding: 0.38rem 0.68rem;
    font-size: 0.92rem;
    border: 1px solid rgba(189, 160, 116, 0.9);
    background: rgba(180, 150, 102, 0.18);
    color: #f2e9dc;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
    font-weight: 600;
}

.status-panel .auto-round-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.45rem;
    margin-bottom: 0.85rem;
    margin-left: 0;
    width: 100%;
    color: #f0ebe2;
    font-size: 0.96rem;
}

.status-panel .auto-round-toggle input {
    width: 1rem;
    height: 1rem;
    margin: 0;
    accent-color: #d6bf8e;
}

.status-panel .tie-break-note {
    margin-top: 0.9rem;
    color: #d7c8b6;
    font-size: 0.9rem;
    line-height: 1.4;
}

.left-column > .card:not(.status-panel) {
    grid-column: 2;
}

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

.nav-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.75rem;
    flex-wrap: wrap;
}

.nav-group-turn {
    margin-top: 0.75rem;
}

.nav-label {
    min-width: 4.25rem;
    color: #d8d8d8;
    font-size: 0.95rem;
    font-weight: 600;
}

.combatant-controls,
.turn-controls {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.combatant-controls button,
.turn-controls button {
    min-width: 5.5rem;
    flex: 0 0 auto;
}

.auto-round-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.3rem;
    margin-left: 0;
    width: 100%;
    color: #d8d8d8;
    font-size: 0.9rem;
}

.auto-round-toggle input {
    width: 1rem;
    height: 1rem;
    accent-color: var(--ember-accent-strong, #d6bf8e);
    margin: 0;
}

.tie-break-note {
    margin-top: 0.9rem;
    color: #b7b7b7;
    font-size: 0.9rem;
}

.encounter-saves-block {
    margin-bottom: 0.9rem;
    padding-bottom: 0.7rem;
    border-bottom: 2px solid #4a4a4a;
}

.encounter-saves {
    margin-bottom: 0.3rem;
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
    font-size: 0.9rem;
}

.encounter-saves-title {
    font-size: 0.88rem;
    font-weight: 600;
    color: #ededed;
    white-space: nowrap;
}

.encounter-saves #encounter-save-name {
    flex: 1 1 220px;
    min-width: 170px;
}

.encounter-saves #encounter-save-select {
    flex: 1 1 220px;
    min-width: 170px;
}

.encounter-saves button {
    flex: 0 0 auto;
    min-width: 4.5rem;
}

.encounter-saves input,
.encounter-saves select,
.encounter-saves button {
    font-size: 0.9rem;
}

.save-feedback {
    margin-bottom: 0;
    color: #b7b7b7;
    min-height: 1.2rem;
    font-size: 0.9rem;
}

.save-feedback.is-error {
    color: #ff9f9f;
}

.label {
    color: #a0a0a0;
}

#active-display {
    font-weight: 600;
    color: #f5f5f5;
}

.form-grid {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.75rem;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 120px;
    flex: 1 1 140px;
}

.field-full {
    flex: 2 1 220px;
}

.field-compact {
    flex: 0 1 96px;
    min-width: 88px;
}

.field-submit {
    flex: 0 0 auto;
    min-width: auto;
    align-self: flex-end;
}

.field-submit button {
    min-height: 2.4rem;
    white-space: nowrap;
}

label {
    font-size: 0.9rem;
    color: #d1d1d1;
    min-height: 1.35rem;
    display: flex;
    align-items: center;
}

input,
select,
button {
    font: inherit;
}

input,
select {
    background: #1b1b1b;
    color: #efefef;
    border: 1px solid #444;
    border-radius: 6px;
    padding: 0.5rem 0.65rem;
    min-height: 2.4rem;
}

input[type="color"] {
    width: 100%;
    max-width: 160px;
    min-height: 2.7rem;
    padding: 0.2rem;
    background: #1b1b1b;
    cursor: pointer;
    border-radius: 6px;
}

input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

input[type="color"]::-webkit-color-swatch {
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 6px;
}

input:focus,
select:focus,
button:focus {
    outline: 2px solid var(--ember-accent-strong);
    outline-offset: 1px;
}

.form-actions {
    margin-top: 0.5rem;
    display: flex;
    gap: 0.5rem;
}

button {
    border: 1px solid #4d4d4d;
    background: #2f2f2f;
    color: #f2f2f2;
    padding: 0.45rem 0.8rem;
    border-radius: 6px;
    cursor: pointer;
}

button:hover {
    background: #3a3a3a;
}

button:disabled {
    cursor: default;
    opacity: 1;
}

.active-action-button {
    border-color: var(--ember-accent-strong);
    background: rgba(107, 155, 209, 0.26);
    color: #d9ecff;
    box-shadow: 0 0 0 1px rgba(107, 155, 209, 0.3);
}

.error-message {
    color: #ff9f9f;
    margin-top: 0.6rem;
}

.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 0.35rem;
    table-layout: auto;
}

th,
td {
    border: 0;
    padding: 0.35rem;
    text-align: left;
    vertical-align: middle;
    white-space: normal;
    overflow-wrap: anywhere;
}

th {
    color: #d8d8d8;
    font-weight: 600;
}

.order-cell {
    width: 2.75rem;
    min-width: 2.75rem;
    text-align: center;
    font-weight: 700;
    color: #cfd8e3;
}

tbody tr.active-row td {
    background: rgba(107, 155, 209, 0.22);
}

tbody tr.active-row .order-cell {
    background: rgba(107, 155, 209, 0.34);
    color: #d9ecff;
    text-shadow: 0 0 8px rgba(107, 155, 209, 0.35);
}

tbody tr.dragging-row {
    opacity: 0.48;
    transform: scale(1.01);
}

tbody tr.dragging-row td {
    box-shadow: 0 16px 48px rgba(107, 155, 209, 0.35);
}

tbody tr.drag-over-row td {
    background: #2a2a2a;
    box-shadow: 0 0 0 3px rgba(107, 155, 209, 0.15);
}

tbody tr.drag-over-row td:first-child,
tbody tr.drag-over-row td:last-child {
    position: relative;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    align-items: center;
    width: 100%;
}

.actions .danger-icon-button {
    margin-left: auto;
}

.move-controls {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.3rem;
    align-items: center;
}

.row-input {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    padding: 0.3rem 0.45rem;
}

.row-initiative,
.row-hp {
    width: 58px;
    min-width: 58px;
}

.row-color-select {
    min-width: 96px;
    font-size: 0.85rem;
    padding: 0.2rem 0.35rem;
    letter-spacing: 0;
    font-weight: 700;
}

.icon-button {
    padding: 0.15rem 0.35rem;
    min-width: 1.6rem;
}

.drag-handle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.7rem;
    padding: 0.1rem 0.25rem;
    border: 1px solid #4b5c71;
    border-radius: 6px;
    background: rgba(107, 155, 209, 0.12);
    color: #90ceff;
    font-size: 1rem;
    line-height: 1;
    letter-spacing: -0.08em;
    user-select: none;
    cursor: grab;
    transition: background 0.2s, border-color 0.2s, transform 0.2s;
}

tbody tr:hover .drag-handle {
    background: rgba(107, 155, 209, 0.2);
    border-color: var(--ember-accent-strong);
}

tbody tr.dragging-row .drag-handle {
    cursor: grabbing;
    background: rgba(107, 155, 209, 0.26);
    border-color: #90ceff;
    transform: scale(1.04);
}

.danger-icon-button {
    padding: 0.1rem 0.35rem;
    min-width: 1.4rem;
    border-color: #6a3a3a;
}

.danger-icon-button:hover {
    background: #4a2b2b;
}

#color {
    width: 100%;
    max-width: 100%;
    padding: 0.2rem;
    letter-spacing: 0;
    font-weight: 700;
}

.empty-row td {
    color: #a8a8a8;
    text-align: center;
}

@media (max-width: 680px) {
    .tracker-layout {
        grid-template-columns: 1fr;
    }

    .left-column {
        grid-template-columns: 1fr;
    }

    .status-panel,
    .left-column > .card:not(.status-panel) {
        grid-column: 1;
    }

    .form-grid {
        align-items: stretch;
    }

    .encounter-saves {
        flex-wrap: wrap;
    }

    .field,
    .field-full,
    .field-compact,
    .field-submit {
        min-width: 100%;
        flex: 1 1 100%;
    }

    .field-submit {
        align-self: stretch;
    }

    .field-submit button {
        width: 100%;
    }

    .table-wrap {
        overflow-x: auto;
    }

    table {
        min-width: 760px;
    }

    th,
    td {
        padding: 0.3rem;
    }

    body {
        padding: 1rem;
    }
}

@media (max-width: 1100px) {
    body {
        padding: 1rem;
    }

    .left-column {
        grid-template-columns: 1fr;
    }

    .status-panel,
    .left-column > .card:not(.status-panel) {
        grid-column: 1;
    }

    .status-panel .nav-group {
        flex-wrap: wrap;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .status-panel .nav-label {
        width: 100%;
        min-width: 0;
    }

    .encounter-saves {
        align-items: stretch;
    }

    .encounter-saves-title {
        flex: 1 1 100%;
    }

    .encounter-saves #encounter-save-name,
    .encounter-saves #encounter-save-select {
        flex: 1 1 calc(50% - 0.225rem);
        min-width: 210px;
    }

    .encounter-saves button {
        flex: 1 1 calc(33.333% - 0.3rem);
        min-width: 0;
    }
}

@media (max-width: 820px) {
    .encounter-saves #encounter-save-name,
    .encounter-saves #encounter-save-select {
        flex: 1 1 100%;
        min-width: 0;
    }

    .encounter-saves button {
        flex: 1 1 calc(50% - 0.225rem);
    }
}
