/* The HUD over the map, after Baldur's Gate 3: the hotbar (portrait, economy, tabbed slots, End Turn), the party's portraits at the
 * left edge, and the initiative row at the top. Gold on dark glass; square slots at least 44px so they work with a finger. */

/* --- Progress bars (hit points, movement) ------------------------------------------------------------------------------------ */

.tt-root progress {
    appearance: none;
    -webkit-appearance: none;
    display: block;
    width: 100%;
    height: 8px;
    border: 0;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.6);
    overflow: hidden;
}

.tt-root progress::-webkit-progress-bar {
    background: rgba(0, 0, 0, 0.6);
}

.tt-hp::-webkit-progress-value { background: var(--tt-green); transition: width 0.3s; }
.tt-hp::-moz-progress-bar { background: var(--tt-green); }
.tt-hp[data-tone="mid"]::-webkit-progress-value { background: #e0c341; }
.tt-hp[data-tone="mid"]::-moz-progress-bar { background: #e0c341; }
.tt-hp[data-tone="low"]::-webkit-progress-value { background: var(--tt-red); }
.tt-hp[data-tone="low"]::-moz-progress-bar { background: var(--tt-red); }

.tt-move-track::-webkit-progress-value { background: linear-gradient(90deg, #b88d34, var(--tt-gold-hi)); }
.tt-move-track::-moz-progress-bar { background: linear-gradient(90deg, #b88d34, var(--tt-gold-hi)); }

/* --- The hotbar ------------------------------------------------------------------------------------------------------------ */

.tt-hotbar {
    position: absolute;
    z-index: 14;
    left: 96px;
    width: fit-content;
    max-width: calc(100% - 96px - 150px);
    bottom: 10px;
    display: flex;
    align-items: flex-end;
    gap: 14px;
    padding: 10px 14px 10px 12px;
    border: 1px solid var(--tt-gold-dim);
    border-radius: 16px;
    background: linear-gradient(180deg, rgba(30, 32, 42, 0.9), rgba(10, 11, 16, 0.94));
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 235, 180, 0.12), inset 0 0 0 1px rgba(0, 0, 0, 0.6);
}

.tt-hotbar.is-locked .tt-slot {
    opacity: 0.7;
}

.tt-hero {
    display: flex;
    flex: none;
    gap: 10px;
    align-items: flex-end;
}

.tt-hero-face {
    width: 86px;
    height: 86px;
    overflow: hidden;
    border: 2px solid var(--tt-gold);
    border-radius: 12px;
    background: #14161c;
    box-shadow: 0 0 0 2px #000, 0 0 16px rgba(226, 185, 90, 0.25);
}

.tt-hero-face img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: 50% 12%;
}

.tt-hero-meta {
    width: 118px;
    min-width: 0;
}

.tt-hero-name {
    overflow: hidden;
    font-family: var(--tt-serif);
    font-size: 0.98rem;
    color: var(--tt-gold-hi);
    white-space: nowrap;
    text-overflow: ellipsis;
}

.tt-hero-class {
    margin-bottom: 4px;
    color: var(--tt-muted);
    font-size: 0.75rem;
}

.tt-hero-hp {
    margin-top: 2px;
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
}

.tt-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    min-height: 4px;
    margin-top: 3px;
}

.tt-badge {
    display: inline-grid;
    place-items: center;
    min-width: 20px;
    height: 18px;
    padding: 0 3px;
    border-radius: 9px;
    background: #6b6150;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
}

.tt-bar {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.tt-bar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

/* the action economy */

.tt-economy {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.tt-pips {
    display: flex;
    gap: 7px;
}

.tt-pip {
    display: inline-block;
    width: 15px;
    height: 15px;
    background: var(--tt-green);
    box-shadow: 0 0 6px rgba(88, 194, 107, 0.6);
}

.tt-pip-action { border-radius: 50%; }
.tt-pip-bonus { background: var(--tt-orange); box-shadow: none; filter: drop-shadow(0 0 4px rgba(240, 138, 46, 0.7)); clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.tt-pip-reaction { background: var(--tt-blue); box-shadow: none; clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); }
.tt-pip.is-spent { background: #2c2f38; box-shadow: none; filter: none; }

.tt-attacks-left {
    color: var(--tt-green);
    font-size: 0.78rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.tt-move {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tt-move-track {
    width: 120px;
}

.tt-move-text {
    color: var(--tt-gold-hi);
    font-size: 0.78rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.tt-resources {
    display: flex;
    gap: 10px;
}

.tt-resource {
    display: flex;
    align-items: center;
    gap: 3px;
}

.tt-resource-mark {
    margin-right: 2px;
    color: var(--tt-muted);
    font-family: var(--tt-serif);
    font-size: 0.7rem;
}

.tt-pip-slot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--tt-blue);
    box-shadow: 0 0 5px rgba(90, 160, 224, 0.6);
}

/* tabs */

.tt-tabs {
    display: flex;
    gap: 4px;
}

.tt-tab,
.tt-level {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 28px;
    padding: 0 10px;
    border: 1px solid transparent;
    border-radius: 14px;
    background: transparent;
    color: var(--tt-muted);
    font-size: 0.78rem;
    cursor: pointer;
}

.tt-tab:hover,
.tt-level:hover {
    color: var(--tt-text);
}

.tt-tab.is-active,
.tt-level.is-active {
    border-color: var(--tt-gold-dim);
    background: rgba(226, 185, 90, 0.16);
    color: var(--tt-gold-hi);
}

.tt-levels {
    display: flex;
    gap: 4px;
}

.tt-levels.is-off {
    visibility: hidden;
}

.tt-level {
    min-height: 24px;
    padding: 0 9px;
    font-size: 0.72rem;
}

/* panels of slots */

.tt-slots-wrap {
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: thin;
    scrollbar-color: var(--tt-gold-dim) transparent;
}

.tt-slots {
    display: flex;
    gap: 8px;
    width: max-content;
}

.tt-panel {
    padding: 3px 6px 6px;
    border: 1px solid rgba(226, 185, 90, 0.2);
    border-radius: 9px;
    background: rgba(0, 0, 0, 0.32);
}

.tt-panel-title {
    margin-bottom: 3px;
    color: var(--tt-muted);
    font-size: 0.62rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.tt-panel[data-economy="action"] .tt-panel-title { color: #86d796; }
.tt-panel[data-economy="bonus"] .tt-panel-title { color: #f3a65e; }
.tt-panel[data-economy="reaction"] .tt-panel-title { color: #86b9e8; }

.tt-panel-slots {
    display: flex;
    gap: 5px;
}

.tt-slot {
    position: relative;
    flex: none;
    width: var(--tt-slot);
    height: var(--tt-slot);
    padding: 0;
    overflow: hidden;
    border: 1px solid rgba(226, 185, 90, 0.5);
    border-radius: 7px;
    background: linear-gradient(160deg, #272a37, #0f1118);
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.7), inset 0 2px 8px rgba(0, 0, 0, 0.6);
    color: var(--tt-gold-hi);
    cursor: pointer;
    transition: transform 0.12s, border-color 0.12s, box-shadow 0.12s;
}

.tt-slot.is-empty {
    cursor: default;
    border-color: rgba(226, 185, 90, 0.14);
    background: rgba(0, 0, 0, 0.28);
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.7);
}

.tt-panel-empty {
    background: transparent;
    border-color: transparent;
}

.tt-slot-icon {
    position: absolute;
    inset: 2px;
    width: calc(100% - 4px);
    height: calc(100% - 4px);
    border-radius: 5px;
    object-fit: cover;
}

.tt-slot-glyph {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-family: var(--tt-serif);
    font-size: 1.5rem;
    color: var(--tt-gold);
}

.tt-slot:hover:not(.is-unavailable):not(.is-empty),
.tt-slot:focus-visible {
    border-color: var(--tt-gold-hi);
    box-shadow: inset 0 0 0 1px #000, 0 0 12px rgba(246, 220, 146, 0.45);
    transform: translateY(-3px);
}

.tt-slot.is-armed {
    border-color: #fff4d2;
    box-shadow: inset 0 0 0 1px #000, 0 0 0 2px rgba(255, 244, 210, 0.55), 0 0 20px rgba(246, 220, 146, 0.9);
    transform: translateY(-4px);
    animation: tt-armed 1.1s ease-in-out infinite;
}

@keyframes tt-armed {
    50% { box-shadow: inset 0 0 0 1px #000, 0 0 0 3px rgba(255, 244, 210, 0.2), 0 0 10px rgba(246, 220, 146, 0.5); }
}

.tt-slot.is-unavailable {
    border-color: rgba(120, 118, 110, 0.5);
    cursor: not-allowed;
}

.tt-slot.is-unavailable .tt-slot-icon {
    filter: grayscale(1) brightness(0.42);
}

.tt-slot.is-unavailable::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, transparent 46%, rgba(217, 72, 63, 0.75) 47%, rgba(217, 72, 63, 0.75) 53%, transparent 54%);
}

.tt-slot-key {
    position: absolute;
    left: 3px;
    top: 1px;
    color: #fff4d2;
    font-size: 11px;
    font-weight: 700;
    text-shadow: 0 0 3px #000, 0 1px 2px #000;
}

.tt-eco {
    position: absolute;
    right: 3px;
    top: 3px;
    width: 10px;
    height: 10px;
    filter: drop-shadow(0 0 2px #000);
}

.tt-eco-action { border-radius: 50%; background: var(--tt-green); }
.tt-eco-bonus { background: var(--tt-orange); clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.tt-eco-reaction { background: var(--tt-blue); clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); }
.tt-eco-free { display: none; }

.tt-slot-cost {
    position: absolute;
    right: 3px;
    bottom: 2px;
    padding: 0 3px;
    border-radius: 3px;
    background: rgba(8, 20, 40, 0.85);
    color: #9ccdf5;
    font-size: 10px;
    font-weight: 700;
}

/* End Turn */

.tt-endturn {
    position: absolute;
    right: -92px;
    bottom: 0;
    flex: none;
    width: 88px;
    height: 88px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: none;
    cursor: pointer;
}

.tt-endturn-ring {
    position: relative;
    display: grid;
    place-items: center;
    width: 100%;
    height: 100%;
    border: 3px solid #f6dc92;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #f3d98c, #c19a3e 60%, #8a6a22);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.7), inset 0 0 0 3px rgba(60, 40, 8, 0.55), inset 0 3px 6px rgba(255, 255, 255, 0.35);
    transition: transform 0.12s, filter 0.2s;
}

.tt-endturn-text {
    color: #2a1d07;
    font-family: var(--tt-serif);
    font-size: 0.95rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    line-height: 1.1;
    text-align: center;
    text-transform: uppercase;
}

.tt-endturn:hover:not(:disabled) .tt-endturn-ring {
    transform: scale(1.06);
}

.tt-endturn:active:not(:disabled) .tt-endturn-ring {
    transform: scale(0.96);
}

/* the glow of a turn that is done breathes on a layer of its own: only its opacity changes, which the compositor plays without painting anything
 * again (an animated shadow would be painted anew every frame, on the page's thread when there is no graphics card) */
.tt-endturn.is-ready .tt-endturn-ring::after {
    content: "";
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    box-shadow: 0 0 24px rgba(246, 220, 146, 0.85);
    opacity: 0;
    pointer-events: none;
    animation: tt-ready 1.8s ease-in-out infinite;
}

@keyframes tt-ready {
    50% { opacity: 1; }
}

.tt-endturn:disabled {
    cursor: default;
}

.tt-endturn:disabled .tt-endturn-ring {
    filter: grayscale(0.85) brightness(0.55);
}

/* --- The party at the left edge ----------------------------------------------------------------------------------------------- */

.tt-party {
    position: absolute;
    z-index: 13;
    left: 10px;
    top: 50%;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transform: translateY(-58%);
}

.tt-member {
    position: relative;
    display: block;
    width: 70px;
    padding: 0;
    border: 0;
    background: none;
    cursor: pointer;
}

.tt-member-face {
    display: block;
    width: 70px;
    height: 70px;
    overflow: hidden;
    border: 2px solid rgba(226, 185, 90, 0.5);
    border-radius: 12px;
    background: #14161c;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}

.tt-member-face img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: 50% 12%;
}

.tt-member .tt-hp {
    height: 6px;
    margin-top: 3px;
    border: 1px solid #000;
}

.tt-member:hover .tt-member-face {
    border-color: var(--tt-gold-hi);
}

.tt-member.is-selected .tt-member-face {
    border-color: #fff4d2;
    box-shadow: 0 0 0 2px var(--tt-gold), 0 0 16px rgba(246, 220, 146, 0.7);
    transform: translateX(4px);
}

.tt-member.is-acting::after {
    content: "";
    position: absolute;
    left: -7px;
    top: 24px;
    border: 7px solid transparent;
    border-left: 9px solid var(--tt-gold-hi);
    filter: drop-shadow(0 0 4px var(--tt-gold));
}

.tt-member.is-down .tt-member-face {
    filter: grayscale(1) brightness(0.6);
}

.tt-member-cond {
    position: absolute;
    right: -4px;
    top: -4px;
    display: flex;
    gap: 2px;
}

/* --- Initiative --------------------------------------------------------------------------------------------------------------- */

.tt-initiative {
    position: absolute;
    z-index: 13;
    top: 8px;
    left: 0;
    right: 0;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 12px;
    width: fit-content;
    max-width: calc(100% - 2 * var(--tt-top-reserve));
    margin: 0 auto;
    padding: 5px 12px 6px;
    border: 1px solid var(--tt-line);
    border-radius: 14px;
    background: var(--tt-glass);
}

/* a fight with more creatures than fit between the place's name and the toolbar (tabletop.js `placeOrder`): the bar has a row of its own under them,
 * as wide as the map left of the docked thread */
.tt-root[data-layout="dock"] .tt-initiative.is-low {
    top: 64px;
    max-width: calc(100% - 2 * (var(--tt-thread-width) + 24px));
}

.tt-root[data-layout="dock"]:not(.is-trading):not(:has(.tt-card)):has(.tt-initiative.is-low) .tt-toasts {
    top: 172px;
}

.tt-round {
    align-self: center;
    text-align: center;
    line-height: 1;
}

.tt-round-label {
    display: block;
    color: var(--tt-muted);
    font-size: 0.6rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

.tt-round-number {
    font-family: var(--tt-serif);
    font-size: 1.6rem;
    color: var(--tt-gold-hi);
}

.tt-turns {
    display: flex;
    align-items: center;
    gap: 6px;
    overflow-x: auto;
    padding: 4px 2px;
    scrollbar-width: none;
}

.tt-turn {
    position: relative;
    flex: none;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 2px solid var(--tt-gold-dim);
    border-radius: 50%;
    background: #14161c;
    cursor: pointer;
    transition: width 0.2s, height 0.2s, border-color 0.2s;
}

.tt-turn.tt-side-foe { border-color: #a83a33; }
.tt-turn.tt-side-neutral { border-color: #6f8a74; }

.tt-turn-face {
    display: block;
    width: 100%;
    height: 100%;
    overflow: hidden;
    border-radius: 50%;
}

.tt-turn-face img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: 50% 12%;
}

.tt-turn.is-acting {
    width: 62px;
    height: 62px;
    border-color: var(--tt-gold-hi);
    box-shadow: 0 0 0 2px #000, 0 0 16px rgba(246, 220, 146, 0.7);
}

.tt-turn.is-acting.tt-side-foe {
    border-color: #ff7a6a;
    box-shadow: 0 0 0 2px #000, 0 0 16px rgba(255, 90, 70, 0.6);
}

.tt-turn-slot {
    display: flex;
    flex: none;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    width: 54px;
}

.tt-turn-slot.is-acting { width: 68px; }

.tt-turn.is-defeated { opacity: 0.5; filter: grayscale(1); }

.tt-turn.is-defeated::after {
    content: "\2715";
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: #ff9a8a;
    font-size: 1.4rem;
    font-weight: 800;
    text-shadow: 0 0 3px #000;
}

/* the state of a creature: its health word and its conditions, as badges (the bar's, and the list's) */
.tt-turn-state {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 2px;
    max-width: 100%;
}

.tt-health {
    display: inline-block;
    padding: 0 6px;
    border-radius: 8px;
    background: #3a3f4d;
    color: #e9e4d6;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.03em;
    line-height: 15px;
    text-transform: uppercase;
    white-space: nowrap;
}

.tt-health-healthy { background: rgba(88, 194, 107, 0.3); color: #9ae6a8; }
.tt-health-wounded { background: rgba(224, 195, 65, 0.3); color: #f0dc7a; }
.tt-health-bloodied { background: rgba(232, 120, 60, 0.35); color: #ffb48a; }
.tt-health-down { background: rgba(217, 72, 63, 0.4); color: #ffb0a2; }
.tt-health-defeated { background: rgba(120, 120, 130, 0.4); color: #c4c4cc; }

.tt-cond {
    display: inline-grid;
    place-items: center;
    min-width: 19px;
    height: 15px;
    padding: 0 3px;
    border-radius: 8px;
    background: #6b6150;
    color: #fff;
    font-size: 9px;
    font-weight: 700;
}

.tt-cond.is-named {
    height: auto;
    padding: 1px 8px;
    font-size: 0.72rem;
    line-height: 1.25;
}

/* the turn order as a list, opened from the bar */
.tt-order-toggle {
    align-self: center;
    flex: none;
    width: 32px;
    height: 32px;
    border: 1px solid var(--tt-line);
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.35);
    color: var(--tt-gold-hi);
    cursor: pointer;
}

.tt-order-list {
    position: absolute;
    z-index: 2;
    top: calc(100% + 6px);
    left: 50%;
    display: flex;
    flex-direction: column;
    gap: 3px;
    width: max(100%, min(380px, calc(100vw - 20px)));
    max-height: min(56vh, 460px);
    margin: 0;
    padding: 6px;
    overflow-y: auto;
    border: 1px solid var(--tt-line);
    border-radius: 12px;
    background: rgba(12, 14, 20, 0.94);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
    list-style: none;
    transform: translateX(-50%);
}

.tt-order-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "who init" "state state";
    align-items: center;
    gap: 2px 8px;
    padding: 3px 8px 3px 6px;
    border-left: 4px solid var(--tt-gold-dim);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
}

.tt-order-row.tt-side-foe { border-left-color: #a83a33; }
.tt-order-row.tt-side-neutral { border-left-color: #6f8a74; }
.tt-order-row.is-acting { background: rgba(246, 220, 146, 0.18); box-shadow: inset 0 0 0 1px var(--tt-gold-hi); }
.tt-order-row.is-defeated .tt-order-name { text-decoration: line-through; opacity: 0.6; }
.tt-order-row.is-defeated .tt-order-face { filter: grayscale(1); opacity: 0.6; }

.tt-order-focus {
    grid-area: who;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    padding: 0;
    border: 0;
    background: none;
    color: var(--tt-text);
    text-align: left;
    cursor: pointer;
}

.tt-order-rank { flex: none; width: 1.2em; color: var(--tt-muted); font-size: 0.8rem; text-align: right; }

.tt-order-face {
    display: block;
    flex: none;
    width: 28px;
    height: 28px;
    overflow: hidden;
    border-radius: 50%;
}

.tt-order-face .tt-face-glyph { font-size: 0.62rem; }
.tt-order-face img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: 50% 12%; }
.tt-order-name { overflow: hidden; font-size: 0.9rem; text-overflow: ellipsis; white-space: nowrap; }
.tt-order-state { grid-area: state; display: flex; flex-wrap: wrap; gap: 3px; padding-left: 38px; }
.tt-order-init { grid-area: init; color: var(--tt-gold-hi); font-family: var(--tt-serif); font-size: 1.05rem; font-weight: 700; }

@media (min-width: 560px) {
    .tt-order-row { grid-template-columns: minmax(0, 1fr) auto auto; grid-template-areas: "who state init"; }
    .tt-order-state { padding-left: 0; justify-content: flex-end; }
}

.tt-turn-init {
    position: absolute;
    right: -3px;
    bottom: -3px;
    min-width: 18px;
    padding: 0 3px;
    border-radius: 9px;
    background: #000;
    color: var(--tt-gold-hi);
    font-size: 10px;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
}

/* --- Dock layout at less than very wide: the thread stops above the hotbar (see tabletop_thread.css) -------------------------------- */

/* --- Portrait screens: phone and tablet, the hotbar is a strip across the bottom -------------------------------------------------- */

.tt-root[data-layout="sheet"] .tt-hotbar {
    left: 0;
    right: 0;
    width: auto;
    max-width: none;
    bottom: 0;
    gap: 8px;
    padding: 6px 76px 8px 8px;
    border-width: 1px 0 0;
    border-radius: 14px 14px 0 0;
}

.tt-root[data-layout="sheet"] .tt-hero {
    flex-direction: column;
    gap: 3px;
    align-items: center;
}

.tt-root[data-layout="sheet"] .tt-hero-face {
    width: 54px;
    height: 54px;
    border-radius: 10px;
}

.tt-root[data-layout="sheet"] .tt-hero-meta {
    width: 62px;
}

.tt-root[data-layout="sheet"] .tt-hero-name,
.tt-root[data-layout="sheet"] .tt-hero-class,
.tt-root[data-layout="sheet"] .tt-badges {
    display: none;
}

.tt-root[data-layout="sheet"] .tt-hero-hp {
    font-size: 0.7rem;
    text-align: center;
}

.tt-root[data-layout="sheet"] .tt-bar-head {
    flex-wrap: wrap;
    gap: 2px 8px;
}

.tt-root[data-layout="sheet"] .tt-economy {
    flex: 1 1 100%;
}

.tt-root[data-layout="sheet"] .tt-tabs {
    flex: 1 1 100%;
}

.tt-root[data-layout="sheet"] .tt-economy {
    gap: 8px;
}

.tt-root[data-layout="sheet"] .tt-move-track {
    width: 56px;
}

.tt-root[data-layout="sheet"] .tt-resources {
    display: none;
}

.tt-root[data-layout="sheet"] .tt-tab {
    min-height: 32px;
    padding: 0 9px;
    gap: 5px;
}

.tt-root[data-layout="sheet"] .tt-tab-label {
    font-size: 0.72rem;
}

.tt-root[data-layout="sheet"] .tt-endturn {
    right: 6px;
    bottom: 10px;
    width: 64px;
    height: 64px;
}

.tt-root[data-layout="sheet"] .tt-endturn-text {
    font-size: 0.7rem;
}

.tt-root[data-layout="sheet"] .tt-party {
    top: 64px;
    transform: none;
    gap: 6px;
}

.tt-root[data-layout="sheet"] .tt-member,
.tt-root[data-layout="sheet"] .tt-member-face {
    width: 48px;
}

.tt-root[data-layout="sheet"] .tt-member-face {
    height: 48px;
    border-radius: 10px;
}

.tt-root[data-layout="sheet"] .tt-initiative {
    max-width: calc(100% - 20px);
    top: calc(var(--tt-toolbar-bottom, 52px) + 4px);
    padding: 3px 8px 4px;
}

.tt-root[data-layout="sheet"]:has(.tt-initiative:not([hidden])) .tt-party {
    top: calc(var(--tt-top-band, 132px) + 8px);
}

.tt-root[data-layout="sheet"] .tt-turn { width: 38px; height: 38px; }
.tt-root[data-layout="sheet"] .tt-turn.is-acting { width: 50px; height: 50px; }
/* a phone: the health word is whole under every portrait (a slot is as wide as the longest word, "bloodied"), and a fight with more
 * creatures than fit the width scrolls along the row (the acting one is brought into view by the row itself) */
.tt-root[data-layout="sheet"] .tt-turn-slot { width: 54px; }
.tt-root[data-layout="sheet"] .tt-turn-slot.is-acting { width: 62px; }
.tt-root[data-layout="sheet"] .tt-turns { min-width: 0; gap: 4px; scrollbar-width: thin; scrollbar-color: var(--tt-gold-dim) transparent; }
.tt-root[data-layout="sheet"] .tt-health { padding: 0 3px; font-size: 8px; letter-spacing: 0; }
.tt-root[data-layout="sheet"] .tt-round-number { font-size: 1.2rem; }
/* the camera buttons stay clear of the bottom sheet, which may be opened over the lower half of the map */
.tt-root[data-layout="sheet"] .tt-camera {
    top: calc(var(--tt-top-band, 130px) + 8px);
    right: 8px;
    bottom: auto;
    left: auto;
}

.tt-root[data-layout="sheet"]:has(.tt-initiative[hidden]) .tt-camera {
    top: calc(var(--tt-top-band, 62px) + 8px);
}
.tt-root[data-layout="sheet"] .tt-skip { bottom: calc(var(--tt-hotbar-h) + 66px); }
/* the button stands above the bottom sheet whatever its height (the sheet's own heights are in tabletop_thread.css), never over the lines of
 * the thread: when the sheet is open over most of the map it stands at the top of it, at the right, where the sheet's head has room */
/* a folded sheet with the "Your turn" cue above its strip (a pill and a line of what is left, about 64px high from 64px over the hotbar): the
 * button stands above the cue */
.tt-root[data-layout="sheet"]:has(.tt-thread[data-sheet="collapsed"]):has(.tt-turncue:not([hidden])) .tt-skip { bottom: calc(var(--tt-hotbar-h) + 136px); }
.tt-root[data-layout="sheet"]:has(.tt-thread[data-sheet="half"]) .tt-skip { bottom: calc(var(--tt-hotbar-h) + min(40%, 380px) + 10px); }
.tt-root[data-layout="sheet"]:has(.tt-thread[data-sheet="full"]) .tt-skip {
    top: calc(var(--tt-top-band, 62px) + 4px);
    right: 12px;
    bottom: auto;
    left: auto;
    margin: 0;
}

@media (max-width: 520px) {
    .tt-topleft { max-width: calc(100% - 240px); }
    .tt-back-label { display: none; }
    .tt-back { width: 40px; padding: 0; justify-content: center; }
    .tt-scene-name { font-size: 0.85rem; }
}

/* --- A wide screen that is not tall (a laptop): a slimmer hotbar leaves the map more of the height ---------------------------------- */

@media (max-height: 820px) and (min-aspect-ratio: 1/1) {
    .tt-root[data-layout="dock"] {
        --tt-hotbar-h: 160px;
        --tt-slot: 56px;
    }

    .tt-root[data-layout="dock"]:has(.tt-levels:not([hidden])) {
        --tt-hotbar-h: 188px;
    }

    .tt-root[data-layout="dock"] .tt-hotbar {
        bottom: 6px;
        padding-top: 6px;
        padding-bottom: 6px;
    }

    .tt-root[data-layout="dock"] .tt-hero-face {
        width: 68px;
        height: 68px;
    }

    .tt-root[data-layout="dock"] .tt-endturn {
        width: 76px;
        height: 76px;
        right: -82px;
    }
}


/* --- A wide screen: Tod's thread takes the full height at the right, so the bar and End Turn stop short of it ---------------------------- */

@media (min-width: 1700px) {
    .tt-root[data-layout="dock"]:has(.tt-thread[data-open="true"]) .tt-hotbar {
        max-width: calc(100% - 96px - var(--tt-thread-width) - 130px);
    }
}

/* experience under the hit points */
.tt-xp {
    height: 4px;
    margin-top: 4px;
}

.tt-xp::-webkit-progress-value { background: #5aa0e0; }
.tt-xp::-moz-progress-bar { background: #5aa0e0; }

/* a phone has room for few toolbar buttons: the rarely used ones (every name, fullscreen) are left to the keyboard and larger screens */
@media (max-width: 700px) {
    .tt-toolbar { gap: 2px; }
    .tt-toolbar .tt-names,
    .tt-toolbar .tt-fullscreen,
    .tt-scene-name { display: none; }
}

.tt-panel[data-economy=""] .tt-slot-glyph .fa-solid {
    font-size: 1.3rem;
}


/* --- Touch targets: nothing the finger must hit is smaller than 44px (40px with a mouse) -------------------------------------------- */

.tt-btn-small { min-height: 40px; }
.tt-tab { min-height: 40px; }
.tt-chip { min-height: 40px; }
.tt-convo-leave { min-height: 40px; }
.tt-back { min-height: 40px; }

@media (pointer: coarse) {
    .tt-btn-small,
    .tt-tab,
    .tt-level,
    .tt-chip,
    .tt-convo-leave,
    .tt-back,
    .tt-world-place,
    .tt-journal-tab,
    .tt-buyer { min-height: 44px; }
    .tt-back { min-width: 44px; }
    .tt-turn { width: 44px; height: 44px; }
    .tt-turn.is-acting { width: 56px; height: 56px; }
    .tt-root[data-layout="sheet"] .tt-turn { width: 44px; height: 44px; }
    .tt-root[data-layout="sheet"] .tt-turn.is-acting { width: 54px; height: 54px; }
    .tt-root[data-layout="sheet"] .tt-tab { min-width: 44px; }
}

/* --- A phone held sideways (844 x 390): its own compact layout: one top row that never overlaps, a slim hotbar, a narrow thread ------- */

@media (orientation: landscape) and (max-height: 500px) {
    .tt-root[data-layout="dock"] {
        --tt-hotbar-h: 98px;
        --tt-slot: 44px;
    }

    .tt-root[data-layout="dock"] .tt-scene-name,
    .tt-root[data-layout="dock"] .tt-clock,
    .tt-root[data-layout="dock"] .tt-back-label { display: none; }

    .tt-root[data-layout="dock"] .tt-back { width: 44px; padding: 0; justify-content: center; }

    .tt-root[data-layout="dock"] .tt-initiative {
        left: 62px;
        right: auto;
        top: 6px;
        margin: 0;
        padding: 2px 8px;
        max-width: calc(100% - 62px - 330px);
    }

    .tt-root[data-layout="dock"] .tt-round-label { display: none; }
    .tt-root[data-layout="dock"] .tt-turns { max-width: 100%; }

    .tt-root[data-layout="dock"] .tt-hotbar {
        bottom: 4px;
        left: 84px;
        max-width: calc(100% - 84px - 96px);
        padding: 4px 8px;
        gap: 8px;
    }

    .tt-root[data-layout="dock"] .tt-hero-face { width: 52px; height: 52px; }
    .tt-root[data-layout="dock"] .tt-hero-meta { width: 70px; }
    .tt-root[data-layout="dock"] .tt-hero-name,
    .tt-root[data-layout="dock"] .tt-hero-class,
    .tt-root[data-layout="dock"] .tt-badges,
    .tt-root[data-layout="dock"] .tt-xp { display: none; }
    .tt-root[data-layout="dock"] .tt-bar-head { gap: 6px; }
    .tt-root[data-layout="dock"] .tt-move-text,
    .tt-root[data-layout="dock"] .tt-resources { display: none; }
    .tt-root[data-layout="dock"] .tt-panel-title { display: none; }
    .tt-root[data-layout="dock"] .tt-tab-label { display: none; }
    .tt-root[data-layout="dock"] .tt-tab { min-width: 44px; justify-content: center; }
    .tt-root[data-layout="dock"] .tt-endturn { width: 60px; height: 60px; right: -66px; }
    .tt-root[data-layout="dock"] .tt-endturn-text { font-size: 0.62rem; }

    .tt-root[data-layout="dock"] .tt-thread { top: 56px; width: 270px; bottom: calc(var(--tt-hotbar-h) + 14px); }
    .tt-root[data-layout="dock"] .tt-party { transform: translateY(-50%); }
    .tt-root[data-layout="dock"] .tt-member,
    .tt-root[data-layout="dock"] .tt-member-face { width: 52px; }
    .tt-root[data-layout="dock"] .tt-member-face { height: 52px; }
    .tt-root[data-layout="dock"] .tt-camera { bottom: calc(var(--tt-hotbar-h) + 10px); }
    .tt-root[data-layout="dock"] .tt-world-head { left: 70px; top: 56px; }
    .tt-root[data-layout="dock"] .tt-world-places { top: 108px; left: 70px; max-height: calc(100% - 220px); width: 190px; }
}

@media (orientation: landscape) and (max-height: 500px) {
    .tt-root[data-layout="dock"] .tt-camera { left: 72px; }
}

/* --- Every control a finger must hit is at least 44 x 44 on a touch screen (checked by a script that measures every button) ----------------- */

.tt-root.is-touch .tt-icon-btn,
.tt-root.is-touch .tt-camera .tt-icon-btn { width: 44px; height: 44px; }
.tt-root.is-touch .tt-toolbar { padding: 2px; }
.tt-root.is-touch[data-layout] .tt-tab,
.tt-root.is-touch[data-layout] .tt-level,
.tt-root.is-touch .tt-chip,
.tt-root.is-touch .tt-btn-small,
.tt-root.is-touch .tt-convo-leave,
.tt-root.is-touch .tt-convo-option,
.tt-root.is-touch .tt-journal-tab,
.tt-root.is-touch .tt-world-place,
.tt-root.is-touch .tt-back,
.tt-root.is-touch .tt-send,
.tt-root.is-touch .tt-input { min-height: 44px; min-width: 44px; }
.tt-root.is-touch[data-layout] .tt-tab { padding: 0 12px; }
.tt-root.is-touch .tt-turn { width: 44px; height: 44px; }
.tt-root.is-touch .tt-turn.is-acting { width: 56px; height: 56px; }
.tt-root.is-touch .tt-member,
.tt-root.is-touch .tt-member-face { min-width: 44px; }
.tt-root.is-touch .tt-thread-tab { min-width: 52px; min-height: 52px; }
.tt-root.is-touch[data-layout="sheet"] { --tt-hotbar-h: 160px; }
.tt-root.is-touch[data-layout="sheet"]:has(.tt-levels:not([hidden])) { --tt-hotbar-h: 192px; }

/* --- Faces that have no portrait: a creature's silhouette by side, with the initial small -------------------------------------------- */

.tt-face-glyph {
    position: relative;
    display: grid;
    place-items: center;
    width: 100%;
    height: 100%;
    color: #f6efdc;
    background: radial-gradient(circle at 50% 30%, #6b7392, #2a2f44);
}

.tt-face-glyph.tt-side-foe { background: radial-gradient(circle at 50% 30%, #a8463f, #4a1815); }
.tt-face-glyph.tt-side-neutral { background: radial-gradient(circle at 50% 30%, #5f7b66, #243329); }
.tt-face-glyph .tt-face-letters { font-family: var(--tt-serif); font-size: 1em; font-weight: 700; text-shadow: 0 1px 2px #000; }

@media (orientation: landscape) and (max-height: 500px) {
    .tt-root[data-layout="dock"] .tt-skip { left: 84px; right: auto; margin: 0; bottom: calc(var(--tt-hotbar-h) + 12px); }
}

@media (max-width: 520px) {
    .tt-clock { display: none; }
}

/* --- The "Your turn" cue: a pill over the hotbar, and what is left of the turn; it takes no clicks and covers no square of the map ---------- */

.tt-turncue {
    position: absolute;
    left: 0;
    bottom: calc(100% + 8px);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    max-width: min(100%, 460px);
    pointer-events: none;
}

.tt-turncue[hidden] { display: none; }

.tt-turncue-pill {
    padding: 4px 16px;
    border: 1px solid var(--tt-gold-hi);
    border-radius: 16px;
    background: rgba(40, 32, 12, 0.92);
    box-shadow: 0 0 14px rgba(246, 220, 146, 0.45);
    color: var(--tt-gold-hi);
    font-family: var(--tt-serif);
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.06em;
}

.tt-turncue-prompt {
    padding: 3px 12px;
    border-radius: 10px;
    background: rgba(10, 11, 16, 0.85);
    color: var(--tt-text);
    font-size: 0.82rem;
}

.tt-turncue-prompt[hidden] { display: none; }

/* the opened list is over the party column and the camera buttons */
.tt-initiative:has(.tt-order-list) { z-index: 16; }

/* on a portrait screen the folded thread's strip lies over the hotbar's top edge: the cue stands above the strip */
.tt-root[data-layout="sheet"]:has(.tt-thread[data-sheet="collapsed"]) .tt-turncue { bottom: calc(100% + 64px); }
.tt-root[data-layout="sheet"]:not(:has(.tt-thread[data-sheet="collapsed"])) .tt-turncue { display: none; }

/* --- What a free player has of Tod (tt/free_play): a counter of the day's requests beside the place's name --- */

.tt-freeplay {
    display: inline-flex;
    flex: none;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border: 1px solid var(--tt-line);
    border-radius: 14px;
    background: var(--tt-glass);
    color: var(--tt-gold-hi);
    font-size: 0.78rem;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.tt-freeplay[hidden] { display: none; }

.tt-freeplay.is-low {
    border-color: var(--tt-red);
    color: #fff;
}

/* a phone has no room for it in the top row (the toolbar fills it): it hangs under the top band, beside the party's portraits */
.tt-root[data-layout="sheet"] .tt-freeplay {
    position: absolute;
    top: calc(var(--tt-top-band, 56px) - 4px);
    left: 58px;
}
