* {
    font-size: 100%;
    font-family: Roboto Mono;
    margin: 2px;
    text-align: center;
    color: white;
}

body {
    background-color: rgb(0, 0, 0);
}

button {
    background-color: black;

    border: 2px solid #4CAF50;
    cursor: pointer;
}

button:disabled {
    background-color: rgb(70, 69, 69);
    cursor: auto;
}

button:disabled:hover {
    cursor: not-allowed;
}

button:enabled:hover {
    background-color: rgba(61, 58, 58, 0.6);
    cursor: pointer;
}


button, button>* {
    color: white;
}

#energy_container {
    position: relative; /* anchors #engine_info */
    padding: 10px;
    border: 2px dotted;
    margin: auto;
    width: 50%;
    min-width: max-content; /* grow rather than clip the buttons on narrower windows */
    overflow: hidden;
    min-height: 100px;
}


#energy_container > * {
    margin: auto;
}

#energy_container > #engine_info {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 6;
    width: 18px;
    height: 18px;
    border: 1px solid gray;
    border-radius: 50%;
    font-size: 12px;
    line-height: 18px;
    text-align: center;
    color: gray;
    cursor: help;
}

#engine_info:hover,
#engine_info:focus {
    border-color: #4CAF50;
    color: #4CAF50;
    outline: none;
}

/* opens down and to the left: #energy_container clips anything that pokes out of it */
#engine_info > .hover_hint {
    top: calc(100% + 4px);
    bottom: auto;
    left: auto;
    right: 0;
    transform: none;
    width: max-content;
    max-width: 440px;
    padding: 4px 8px;
    white-space: normal;
    text-align: left;
    font-size: 13px;
    line-height: 1.4;
    color: white;
}

#engine_info:hover > .hover_hint,
#engine_info:focus > .hover_hint {
    display: block;
}

#main_buttons {
    display: table;
}

/* 3 columns; the equal side columns keep the middle one dead centre:
   row 1: _ | Energy | _
   row 2: _ | Focus Engine | power label
   row 3: +1 max ticks/sec | ticks/sec | power upgrade button
   row 4: +0.1 min ticks/sec | _ | Buy max */
#generator {
    display: grid;
    grid-template-columns: 1fr auto 1fr; /* intrinsic width: both sides take the power group's width */
    align-items: center;
    column-gap: 16px;
}

#energy_number {
    grid-column: 2;
    grid-row: 1;
}

#farm_button {
    grid-column: 2;
    grid-row: 2;
    justify-self: center;
}

/* top of its row, not centred against the two-line power buttons beside it */
#speed {
    grid-column: 2;
    grid-row: 3;
    align-self: start;
}

/* column 1, rows 3-4 (subgrid): level with the power upgrade button and Buy max */
#speed_upgrades {
    grid-column: 1;
    grid-row: 3 / 5;
    justify-self: end;
    display: grid;
    grid-template-rows: subgrid;
    justify-items: center;
    align-items: center;
    column-gap: 10px;
}

/* smaller buttons; fixed width, so a growing cost never resizes them */
.speed_upgrade {
    font-size: 0.85em;
    width: 20ch;
    box-sizing: content-box;
    position: relative;
}

#generator button {
    white-space: nowrap;
}

/* column 3, rows 2-4, sharing the outer rows (subgrid) so it lines up with Focus Engine / ticks/sec and the tick upgrades */
#increment_section {
    grid-column: 3;
    grid-row: 2 / 5;
    justify-self: start;
    display: grid;
    grid-template-rows: subgrid;
    align-items: center;
    position: relative;
}

/* absolute with a grid area: placed against those rows, so it moves nothing */
.auto_buy_toggle {
    position: absolute;
    top: 0;
    bottom: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
    font-size: 0.8em;
    letter-spacing: 0.15em;
    white-space: nowrap;
    user-select: none;
    cursor: pointer;
}

.speed_upgrade {
    grid-column: 2;
}

#max_speed_auto_buy_toggle, #min_speed_auto_buy_toggle {
    position: relative;
    grid-column: 1;
}

/* AUTO above the switch, out of the flow, so the switch itself is centred on its button(s) */
.auto_buy_caption {
    position: absolute;
    bottom: calc(50% + 10px);
    left: 50%;
    transform: translateX(-50%);
    margin: 0;
}

#max_speed_auto_buy_toggle {
    grid-row: 1;
}

#min_speed_auto_buy_toggle {
    grid-row: 2;
}

#all_auto_buy_toggle {
    position: static;
    grid-column: 2;
    grid-row: 4;
    gap: 2px;
}

#crystals_auto_buy_toggle {
    position: static;
    grid-column: 2;
    flex-direction: row;
    gap: 6px;
    margin-top: 6px;
}

#power_auto_buy_toggle {
    grid-row: 2 / 3; /* both lines: an absolute item's missing end line means the section's edge */
    grid-column: 1;
    left: 100%;
    margin-left: 12px;
}

.auto_buy_toggle_inline {
    position: static;
    flex-direction: row;
    gap: 6px;
}

#upgrades_auto_buy_toggle {
    width: fit-content;
    margin: 14px auto 12px;
}

/* display: flex from .auto_buy_toggle would beat the hidden attribute */
.unleash_auto_toggle {
    width: fit-content;
    margin: 6px auto 0;
}

.unleash_auto_toggle[hidden],
.auto_unleash_percents[hidden] {
    display: none;
}

#infusions_auto_buy_toggle {
    width: fit-content;
    margin: 0 auto 8px;
    cursor: default;
}

.auto_buy_modes {
    display: flex;
    margin: 0;
}

.auto_buy_mode {
    margin: 0;
    padding: 1px 6px;
    font-size: 1em;
    letter-spacing: inherit;
    border: 1px solid #555;
    background-color: #222;
    transition: background-color 0.2s, border-color 0.2s, color 0.2s;
}

/* overlapped by the border's width, so neighbours share one line; the selected one is lifted to show its green on all sides */
.auto_buy_mode + .auto_buy_mode {
    margin-left: -1px;
}

/* beats the global "button, button>* { color: white }" */
button.auto_buy_mode {
    color: #888;
}

.auto_buy_mode:enabled:hover {
    background-color: #333;
    color: #ccc;
}

button.auto_buy_mode.is_selected {
    background-color: rgba(47, 82, 49, 0.441);
    border-color: #7ddc81;
    color: #7ddc81;
    position: relative;
    z-index: 1;
}

.auto_buy_mode:focus-visible {
    outline: 1px solid white;
    outline-offset: 1px;
}

/* invisible but still keyboard-focusable */
.auto_buy_toggle input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    margin: 0;
}

.auto_buy_switch {
    position: relative;
    width: 28px;
    height: 14px;
    margin: 0;
    border: 1px solid #555;
    background-color: #222;
    transition: background-color 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.auto_buy_switch::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 10px;
    height: 10px;
    background-color: #888;
    transition: left 0.2s, background-color 0.2s;
}

.auto_buy_toggle:hover .auto_buy_switch {
    border-color: #888;
}

.auto_buy_toggle input:checked + .auto_buy_switch {
    background-color: rgba(47, 82, 49, 0.441);
    border-color: #7ddc81;
}

.auto_buy_toggle input:checked + .auto_buy_switch::after {
    left: 16px;
    background-color: #7ddc81;
}

.auto_buy_toggle input:focus-visible + .auto_buy_switch {
    outline: 1px solid white;
    outline-offset: 2px;
}

#increment_upgrade_button {
    position: relative;
}

.hover_hint {
    display: none;
    position: absolute;
    bottom: calc(100% + 4px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 5;
    padding: 2px 8px;
    border: 1px solid #4CAF50;
    background-color: black;
    white-space: nowrap;
    pointer-events: none;
}

button:hover > .hover_hint,
#core_frame_holder:hover > .hover_hint,
.tribute.is_open:hover > .hover_hint,
.tribute.has_scaling_hint:hover > .hover_hint,
.shard_bonus:hover > .hover_hint {
    display: block;
}

#core_formula {
    border-color: var(--core_bright);
}

#power_upgrades_bought {
    margin: 0;
}

#power_production {
    grid-column: 1;
    grid-row: 1;
    justify-self: center;
}

#production_value {
    margin: 0;
}

#power_upgrade_buttons {
    display: contents;
}

/* fixed: fits the longest lines, "+9999.99 power" / "9999.99 Energy" (monospace), so growing numbers don't resize it */
#increment_upgrade_button {
    grid-column: 1;
    width: 19ch;
    box-sizing: content-box;
}

/* no global 2px margin on the number spans: it would read "Buy 37 : 52.0M" */
#power_buy_max_count, #power_buy_max_cost {
    margin: 0;
}

#power_buy_max_button {
    grid-column: 1;
    grid-row: 3;
    width: 19ch;
    box-sizing: content-box;
}

/* 3 columns: count | button | timer. The equal side columns keep the button dead centre, and they're sized by the box,
   not their text, so a longer count or timer never pushes the button */
#crystals_shop {
    padding-top: 20px;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    column-gap: 8px;
}

#crystals_amount {
    justify-self: end;
    text-align: right;
}

#crystals_amount, #crystal_timer {
    line-height: 35px;
}

/* fixed: fits the longest label, "Form A Crystal: 9999.99 Energy" (monospace), so the cost never resizes it */
#crystals_buy {
    width: 30ch;
    box-sizing: content-box;
    white-space: nowrap;
}

/* min-width: room for "Recharging: 10.00", so the side columns don't change as the countdown changes length */
#crystal_timer {
    justify-self: start;
    min-width: 18ch;
    text-align: left;
}

/* shrink-wrapped, so it moves when its text changes width and set_text_gliding can glide it */
.glide_line {
    display: block;
    width: fit-content;
    margin: 0 auto;
}

#extra_tabs {
    padding: 10px;
    margin: auto;
    margin-top: 5px;
    width: 70%;
}

.goal_text {
    color: green;
}

.object_non_clickabale>*{
    color:gray;
}

.object_non_clickabale:hover{
    cursor: not-allowed;
}

.object_clickable {
    cursor: pointer;
}


#current_goal {
    border: solid thick darkgray;
    margin: auto;
    margin-bottom: 1%;
    width: 50%;
    padding: 10px;
    /* fits the tallest goal, so the content below doesn't move between goals */
    min-height: 4.75em;
    display: flex;
    flex-direction: column;
    justify-content: center;
    transition: border-color 0.5s;
}

#current_goal.goal_completed {
    border-color: green;
}

.tabs {
    display: flex;
    flex-direction: row;
    background-color: rgb(22, 21, 21);
    outline: 3px solid darkgray;
    padding: 5px;

}

.tabs button {
    float: left;
    display: block;
    padding: 15px 15px;
    margin: 5px;
    min-width: 12%;
    text-align: middle;
    cursor: pointer;
    position: relative;
}

.tabs button.is_active {
    background-color: rgba(47, 82, 49, 0.441);
    border-color: #7ddc81;
}

.tabs button.has_notification::after {
    content: "";
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #e53935;
}


.sticky {
    position: fixed;
    top: 0;
    width: 98.5%
}

/* top bar: above all page content (incl. Condense particles, 10), below popups (20, 30) and the Cataclysm animation (40+) */
#main_tabs {
    z-index: 15;
}

/* --status_space: the resources status line's height while it shows, so nothing slides under it */
:root {
    --status_space: 0px;
}

.content {
    padding-top: calc(80px + var(--status_space));
}

#resources_panel {
    position: fixed;
    top: 86px;
    z-index: 15;
    width: 98.5%;
    box-sizing: border-box;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 4px 14px;
    padding: 4px 10px;
    background-color: rgb(22, 21, 21);
    outline: 3px solid darkgray;
    white-space: nowrap;
}

#resources_panel > * {
    margin: 0;
}

.resources_separator {
    color: darkgray;
}

.resources_row {
    display: inline-flex;
    gap: 14px;
}

.resources_item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.resources_item > * {
    margin: 0;
}

.resources_item {
    position: relative;
}

.resources_detail {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    width: max-content;
    padding: 6px 8px;
    border: 1px solid darkgray;
    background-color: rgb(16, 16, 16);
    white-space: nowrap;
    font-size: 14px;
    pointer-events: none;
}

.resources_item:hover .resources_detail {
    display: block;
}

.resources_item .elemental_shard_icon {
    width: 1em;
    height: 1em;
}

#actives_panel {
    position: absolute;
    top: calc(84px + var(--status_space)); /* the goal box's top: .content padding */
    right: 1.5vw;
    /* left: set by fit_actives_list */
    box-sizing: border-box;
    padding: 8px;
    border: 2px dotted;
    font-size: 0.85em; /* text and buttons inherit it (global * { font-size: 100% }), so rows fit beside their button */
}

#actives_tabs {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-bottom: 8px;
}

.actives_tab_button {
    width: 40px;
    height: 40px;
    padding: 0;
    font-size: 22px; /* icon size: .rune_icon is 1em */
}

.actives_tab_button.is_active {
    background-color: rgba(47, 82, 49, 0.441);
    border-color: #7ddc81;
}

.infusion_icon { stroke: rgb(200, 200, 200); }

/* height set by fit_actives_list, so the panel always ends just above the sub-tab bar */
#actives_list {
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: darkgray transparent;
}

.actives_row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
}

.actives_row_text {
    flex: 1;
    min-width: 0;
    text-align: left;
    margin: 0;
}

.actives_row .rune_effect_button {
    flex: none;
}

.actives_row + .actives_row {
    border-top: 2px solid darkgray;
}

.actives_core {
    padding: 2px 0 0;
}

.actives_core_bar {
    position: relative;
    height: 8px;
    margin: 2px 2px 6px;
    outline: 2px solid darkgray;
}

.actives_core_fill {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    background: linear-gradient(to right, var(--core_dark), var(--core_bright));
}

.actives_core > p {
    margin: 0;
}

.actives_core_rate {
    opacity: 0.8;
}

/* right: set by fit_cataclysm_panel */
#cataclysm_panel {
    position: absolute;
    top: calc(84px + var(--status_space));
    left: 1.5vw;
    box-sizing: border-box;
    padding: 8px;
    border: 2px dotted;
}

#cataclysm_panel_tabs {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-bottom: 8px;
}

.cataclysm_panel_pane > .condense_button, .cataclysm_panel_pane > .cataclysm_button {
    width: fit-content;
    margin: 0 auto;
}

/* gutters too thin: stack under the goal box instead */
@media (max-width: 1100px) {
    #actives_panel, #cataclysm_panel {
        position: static;
        width: 50%;
        margin: 0 auto 1%;
    }
}

#extra_tab_buttons {
    width: 69%;
    margin: auto;
    margin-top: 15px;

}

#goals_grid > * {
    border: 1px dotted white;
    width: 70%;
    margin: auto;
    padding: 10px;
    margin-top: 5px;
}

/* 4 per row: realm feats on the first, the rest below */
#feats_grid {
    display: grid;
    grid-template-columns: repeat(4, max-content);
    justify-content: center;
    gap: 16px;
    margin-top: 20px;
}

.feat {
    position: relative;
    width: 150px;
    border: 1px dotted gray;
    transition: border-color 1s;
}

.feat p {
    margin: 0;
}

/* scanlines (::after) over the image, sparkle (::before) on top */
.feat_art {
    margin: 0;
    position: relative;
    aspect-ratio: 1;
    overflow: hidden;
}

.feat_image {
    margin: 0;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: grayscale(1) brightness(0.6);
    opacity: 0.5;
    transition: filter 1s, opacity 1s;
}

/* a wide image drawn 120% wide instead of cover's ~139%: a little narrower, so less of its sides is cut */
.feat_image.is_squeezed {
    object-fit: fill;
    width: 120%;
    margin-left: -10%;
}

.feat_art::after {
    content: "";
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(to bottom, transparent 0 2px, rgba(0, 0, 0, 0.35) 2px 3px);
    pointer-events: none;
}

.feat_art::before {
    content: "";
    position: absolute;
    bottom: 2px;
    right: 2px;
    z-index: 1;
    width: 28px;
    height: 28px;
    background: url("assets/icons/feats/trophy_sparkle.svg") center / contain no-repeat;
    opacity: 0;
    transition: opacity 1s;
}

/* two lines tall so every card is the same height */
.feat_title {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 2.6em;
    padding: 2px 4px;
    border-top: 1px dotted gray;
    text-align: center;
    font-size: 0.85em;
    line-height: 1.2;
    transition: border-color 1s, color 1s;
}

.feat_title_text {
    margin: 0;
    color: inherit;
}

.feat_reward_icon {
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.6s;
}

.feat > .hover_hint {
    top: calc(100% + 4px);
    bottom: auto;
    width: max-content;
    min-width: 100%;
    max-width: 280px;
    z-index: 4;
    white-space: normal;
    text-align: center;
}

.feat:hover > .hover_hint {
    display: block;
}

.feat .alignment_icon {
    width: 1.5em;
    height: 1.5em;
    vertical-align: -0.4em;
}

.feat.is_unlocked {
    border: 1px solid #4CAF50;
}

.feat.is_unlocked .feat_title {
    border-top: 1px solid #4CAF50;
    color: #4CAF50;
}

.feat.is_unlocked .feat_image {
    filter: grayscale(1) sepia(1) hue-rotate(65deg) saturate(1.8) brightness(0.75);
    opacity: 1;
}

.feat.is_unlocked:hover .feat_image {
    filter: grayscale(0.5) sepia(0.5) hue-rotate(32deg) saturate(1.4) brightness(0.87);
    transition-duration: 0.3s;
}

.feat.is_unlocked .feat_art::before {
    opacity: 1;
}

.feat.no_star .feat_art::before {
    display: none;
}

.feat.is_revealed .feat_reward_icon {
    visibility: visible;
    opacity: 1;
}


#upgrades_grid {  
  list-style: none;
  display: grid;
  line-height: auto;
  overflow: hidden;
  gap: 10px;
  padding: 10px;
  border: dotted white 1px;
  
}

.upgrade {
    outline: 2px solid;
    font-size: 14px;
    position: relative;
    padding: 4px 10px;
    display: flex;
    flex-direction: column;
}

.upgrade_header {
    font-weight: bold;
    font-size: 16px;
    margin-bottom: 4px;
}

.upgrade_effect:empty {
    display: none;
}

/* auto margins: centred between the name and the bottom part, which they push to the bottom */
.upgrade_description {
    margin-top: auto;
    margin-bottom: auto;
}

.upgrade_cost,
.upgrade_effect {
    margin-top: 4px;
}

.upgrade_cost > p {
    color: inherit; /* grey with the card when unaffordable (the * rule sets white) */
}

/* keeps a formula like +[10% × ▲] on one line */
.nowrap {
    white-space: nowrap;
    color: inherit; /* follow the card's grey when unaffordable (the * rule sets white) */
}

/* fixed, so the upgrades box doesn't clip it; grey border, as green reads like a bought card */
#upgrade_tooltip {
    display: block;
    position: fixed;
    left: 0;
    top: 0;
    bottom: auto;
    margin: 0;
    max-width: 280px;
    white-space: normal;
    border-color: darkgray;
    z-index: 20;
}

#upgrade_tooltip[hidden] {
    display: none;
}

.upgrade.object_clickable {
    outline-color: #4CAF50;
    box-shadow: 0 0 8px rgba(76, 175, 80, 0.6);
}

.upgrade.object_clickable:hover {
    box-shadow: 0 0 8px rgba(76, 175, 80, 0.6), inset 0 0 30px rgba(22, 123, 29);
}

.upgrade.object_non_clickabale {
    outline-color: gray;
}

/* no outer glow, so it doesn't read as a button */
.upgrade_bought {
    outline: 1px solid rgba(76, 175, 80, 0.6);
    box-shadow: inset 0 0 12px rgba(76, 175, 80, 0.25);
}

.upgrade_bought > .upgrade_effect,
.upgrade_bought > .upgrade_effect * {
    color: #7ddc81; /* the * rule sets white on nested text too */
}

.upgrade_corner {
    position: absolute;
    font-size: 16px;
    line-height: 0;
    pointer-events: none;
}
.upgrade_corner .alignment_icon { display: block; margin: 0; }
.upgrade_corner_top_left     { top: 4px; left: 6px; }
.upgrade_corner_top_right    { top: 4px; right: 6px; }
.object_non_clickabale .upgrade_corner { opacity: 0.4; }

@media (min-width: 800px) {
    #upgrades_grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 800px) {
    #upgrades_grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 400px) {
    #upgrades_grid { grid-template-columns: repeat(1, 1fr); }
}

#runes_blocks {
    display: grid;
    /* left lanes | the diamond's 3 tile columns (shared with #runes_grid) | right lanes */
    grid-template-columns: minmax(0, 1fr) repeat(3, auto) minmax(0, 1fr);
    grid-template-rows: repeat(3, auto);
    gap: 10px 0;
    align-items: center;
    padding: 10px;
    /* no overflow: hidden, so hover details on the bottom lane aren't cut off */
    /* break out of #extra_tabs (70%) to 90% of the screen, centred */
    box-sizing: border-box;
    width: 90vw;
    margin-left: calc(50% - 45vw);
}

.rune_effect {
    --lane: darkgray;
    position: relative; /* paints over the diamond's backdrop where the air / earth lanes cross it */
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    row-gap: 8px;
    min-width: 0;
    margin: 0;
}

#air_rune_effect { --lane: rgb(160, 205, 235); grid-column: 4 / 6; grid-row: 1; }
#fire_rune_effect { --lane: rgb(235, 110, 40); grid-column: 1; grid-row: 2; }
#water_rune_effect { --lane: rgb(70, 140, 230); grid-column: 5; grid-row: 2; }
#earth_rune_effect { --lane: rgb(123, 169, 62); grid-column: 1 / 3; grid-row: 3; }

.rune_lane_left {
    flex-direction: row-reverse;
}

.rune_effect::after {
    content: "";
    flex: 1 1 60px;
    min-width: 40px;
    height: 0;
    border-top: 2px dashed var(--lane);
    -webkit-mask-image: linear-gradient(to right, #000, transparent);
    mask-image: linear-gradient(to right, #000, transparent);
}

.rune_lane_left::after {
    -webkit-mask-image: linear-gradient(to left, #000, transparent);
    mask-image: linear-gradient(to left, #000, transparent);
}

@media (max-width: 1100px) {
    #runes_blocks {
        grid-template-rows: repeat(7, auto);
        width: auto;
        margin: auto;
    }
    #air_rune_effect { grid-column: 1 / -1; grid-row: 4; }
    #fire_rune_effect { grid-column: 1 / -1; grid-row: 5; }
    #water_rune_effect { grid-column: 1 / -1; grid-row: 6; }
    #earth_rune_effect { grid-column: 1 / -1; grid-row: 7; }
    .rune_lane_left { flex-direction: row; }
    .rune_lane_left::after {
        -webkit-mask-image: linear-gradient(to right, #000, transparent);
        mask-image: linear-gradient(to right, #000, transparent);
    }
}

/* level | text | optional Activate section */
.rune_effect_row {
    position: relative;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    column-gap: 8px;
    padding: 4px 8px;
    margin: 0 0 0 22px; /* room for the connector back toward the tile */
    max-width: calc(100% - 22px); /* as wide as its text; only wraps inside when the lane is narrower */
    box-sizing: border-box;
    border: 1px solid color-mix(in srgb, var(--lane) 55%, transparent);
    background-color: rgb(16, 16, 16);
    font-size: 14px;
}

.rune_lane_left .rune_effect_row {
    margin: 0 22px 0 0;
}

.rune_effect_row > .rune_effect_action { /* beats the margin reset in .rune_effect_row > * */
    align-self: stretch;
    display: flex;
    align-items: center;
    margin: -4px 0; /* through the chip's vertical padding */
    padding: 4px 0 4px 8px;
    border-left: 1px solid color-mix(in srgb, var(--lane) 55%, transparent);
}

.rune_effect_row::before {
    content: "";
    position: absolute;
    right: calc(100% + 1px);
    top: calc(50% - 1px);
    width: 22px;
    height: 0;
    border-top: 2px solid var(--lane);
}

.rune_lane_left .rune_effect_row::before {
    right: auto;
    left: calc(100% + 1px);
}

#fire_rune_effect .rune_effect_row::before { box-shadow: 0 0 6px var(--lane); }
#air_rune_effect .rune_effect_row::before { border-top-style: dotted; }
#earth_rune_effect .rune_effect_row::before { top: calc(50% - 2.5px); border-top: 5px double var(--lane); }
#water_rune_effect .rune_effect_row::before {
    top: calc(50% - 4px);
    height: 8px;
    border: 0;
    background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8'><path d='M0 4 Q3 0 6 4 T12 4' fill='none' stroke='rgb(70,140,230)' stroke-width='2'/></svg>") repeat-x center;
}

.rune_effect_row.is_active {
    border-color: var(--lane);
    box-shadow: 0 0 10px -2px var(--lane);
}

.rune_effect_row.is_locked {
    border-style: dashed;
}

.rune_effect_row.is_locked .rune_effect_text {
    opacity: 0.6;
}

.rune_effect_row.is_off {
    border-style: dashed;
}

.rune_effect_row.is_off .rune_effect_text {
    opacity: 0.6;
}

.rune_effect_row > * {
    margin: 0;
    font-size: 14px;
}

.rune_effect_level {
    white-space: nowrap; /* scrambled glyphs are wider than letters; don't wrap "Lv 1" */
}

.rune_effect_row > .rune_effect_level { /* beats the margin reset in .rune_effect_row > * */
    align-self: stretch;
    display: flex;
    align-items: center;
    gap: 1ch; /* the space between icon and number, which flex drops */
    margin: -4px 0; /* through the chip's vertical padding */
    padding: 4px 8px 4px 0;
    border-right: 1px solid color-mix(in srgb, var(--lane) 55%, transparent);
}

.rune_effect_detail {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: -1px;
    z-index: 5;
    width: max-content;
    max-width: 40ch;
    padding: 6px 8px;
    border: 1px solid var(--lane);
    background-color: rgb(16, 16, 16);
    text-align: left;
    pointer-events: none;
}

.rune_lane_left .rune_effect_detail {
    left: auto;
    right: -1px;
}

.rune_effect_row.detail_above .rune_effect_detail {
    top: auto;
    bottom: calc(100% + 6px);
}

.rune_effect_row.has_detail:hover .rune_effect_detail {
    display: block;
}

@media (max-width: 1100px) {
    .rune_lane_left .rune_effect_row { margin: 0 0 0 22px; }
    .rune_lane_left .rune_effect_row::before { left: auto; right: calc(100% + 1px); }
    .rune_lane_left .rune_effect_detail { left: -1px; right: auto; }
}

.rune_effect_level .rune_icon {
    stroke: var(--lane);
}

.rune_effect_text {
    text-align: left;
    min-width: 0;
}

.rune_effect_button {
    white-space: nowrap;
    /* fixed: fits the longest label, "Active[×2]: 10s" (monospace font), so a countdown never resizes the row */
    width: 15ch;
    box-sizing: content-box;
}

/* cooling down: let right-clicks reach the wrapper, which sets Learn 2's auto-activate */
.rune_effect_button:disabled {
    pointer-events: none;
}

.rune_effect_button {
    position: relative;
}

.rune_effect_button.is_auto {
    border-color: #8a7330;
}

.auto_active_orbit {
    display: none;
    position: absolute;
    inset: -1px; /* the rect's edge on the middle of the 2px border */
    margin: 0; /* the global * margin would push it 2px down and right */
    width: calc(100% + 2px);
    height: calc(100% + 2px);
    overflow: visible;
    pointer-events: none;
}

.rune_effect_button.is_auto > .auto_active_orbit {
    display: block;
}

.auto_active_orbit rect {
    fill: none;
    stroke: #ffd75e;
    stroke-width: 2;
    stroke-dasharray: 18 82; /* pathLength 100: the light is 18% of the edge */
    filter: drop-shadow(0 0 2px #ffd75e);
    animation: auto_active_orbit 2.5s linear infinite;
}

@keyframes auto_active_orbit {
    to { stroke-dashoffset: -100; }
}

@media (prefers-reduced-motion: reduce) {
    .rune_effect_button.is_auto {
        border-color: #ffd75e;
        box-shadow: 0 0 6px #ffd75e;
    }

    .rune_effect_button.is_auto > .auto_active_orbit {
        display: none;
    }
}

/* shares #runes_blocks' rows and middle columns, so each lane lines up with its tile */
#runes_grid {
    grid-column: 2 / 5;
    grid-row: 1 / 4;
    align-self: stretch;
    display: grid;
    grid-template-columns: subgrid;
    grid-template-rows: subgrid;
    gap: 10px;
    margin: 0;
    isolation: isolate; /* keeps the backdrop below behind the tiles */
}

#runes_grid::before {
    content: "";
    position: absolute;
    inset: -20px;
    z-index: -1;
    pointer-events: none;
    -webkit-mask-image: radial-gradient(closest-side, #000 55%, transparent);
    mask-image: radial-gradient(closest-side, #000 55%, transparent);
    background: radial-gradient(circle at left, rgba(255,0,0,.3), rgba(255,0,0,0) 70.71%), 
    radial-gradient(circle at right, rgba(0,0,255,.3), rgba(0,0,255,0) 70.71%), 
    radial-gradient(circle at bottom, rgba(0,255,0,.3), rgba(0,255,0,0) 70.71%),
    radial-gradient(circle at top, rgba(79, 118, 184, .3), rgba(0,255,0,0) 70.71%);
    
}


.rune {
    font-size: 18px;
    padding: 4px;
    text-align: center;
    aspect-ratio: 1 / 1;
    align-self: center; /* stays square when a wrapped lane makes its row taller */
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    -webkit-user-select: none;
    user-select: none;
    position: relative;
}

/* an overlay, so each tile's own inset shadows stay as they are */
.rune.is_empowered::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    box-shadow: inset 0 0 22px var(--rune_glow), 0 0 18px var(--rune_glow);
    pointer-events: none;
    animation: rune_empowered 3s ease-in-out infinite alternate;
}

@keyframes rune_empowered {
    from { opacity: 0.45; }
    to   { opacity: 1; }
}

#air_rune {
    --rune_glow: rgb(160, 205, 235);
    grid-column: 2;
    grid-row: 1;
    box-shadow: inset 0 0 35px rgb(79, 118, 184), inset 0 0 25px rgb(62, 130, 169), inset 0 0 15px rgba(109, 162, 175, 0.8);
}

#fire_rune {
    --rune_glow: rgb(235, 110, 40);
    grid-column: 1;
    grid-row: 2;
    box-shadow: inset 0 0 35px rgb(203, 50, 50), inset 0 0 25px rgb(172, 123, 0), inset 0 0 15px rgba(255, 255, 0, 0.8);
}

#water_rune {
    --rune_glow: rgb(70, 140, 230);
    grid-column: 3;
    grid-row: 2;
    box-shadow: inset 0 0 35px rgb(58, 50, 203), inset 0 0 25px rgb(21, 124, 184), inset 0 0 15px rgba(37, 136, 160, 0.8);

}

#earth_rune {
    --rune_glow: rgb(123, 169, 62);
    grid-column: 2;
    grid-row: 3;
    box-shadow: inset 0 0 35px rgb(106, 129, 29), inset 0 0 25px rgb(123, 169, 62), inset 0 0 15px rgba(109, 175, 139, 0.8);
}

.rune_progress{
    font-size: 14px;
    /* reserve room for "99.9K/99.9K" so the tile never resizes as digits are added */
    min-width: 11ch;

}
.alignment_icon {
    width: 1em;
    height: 1em;
    vertical-align: -0.15em;
}

/* their facets are lost at 1em */
.elemental_shard_icon {
    width: 1.5em;
    height: 1.5em;
    vertical-align: -0.4em;
}

/* fallback fonts draw cipher glyphs at varying widths; boxed to one monospace cell */
.cipher_glyph {
    display: inline-block;
    width: 1ch;
    margin: 0;
    text-align: center;
}

/* the global 2px margin lifts an img off the runes' baseline */
.rune_shard_icon {
    margin: 0;
}

.condense_rates .rune_shard_icon {
    width: 1.4em;
    height: 1.4em;
    vertical-align: -0.35em;
}

.rune_icon {
    width: 1em;
    height: 1em;
    vertical-align: -0.15em;
    margin: 0;
    fill: none;
    stroke-width: 2.5;
    stroke-linejoin: round;
    stroke-linecap: round;
}

/* stroke, not color: the global * { color: white } would override color inside the icon */
.rune_icon_fire { stroke: rgb(235, 110, 40); }
.rune_icon_water { stroke: rgb(70, 140, 230); }
.rune_icon_air { stroke: rgb(160, 205, 235); }
.rune_icon_earth { stroke: rgb(123, 169, 62); }

#offline_popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: calc(100vw - 32px);
    padding: 12px 24px;
    border: 2px solid darkgray;
    background-color: rgba(0, 0, 0, 0.92);
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.9);
    z-index: 20;
}

#offline_popup[hidden] {
    display: none;
}

.offline_popup_title {
    font-size: 18px;
}

#offline_popup_text {
    line-height: 1.6;
}

#offline_popup_ok {
    padding: 4px 24px;
}

/* over everything until the first real render frame; with .is_catching_up it shows the offline replay's progress */
#loading_screen {
    position: fixed;
    inset: 0;
    z-index: 50; /* above the top bar, even during the cataclysm animation (45) */
    margin: 0; /* the global * margin would leave a 2px strip of the page showing around the edges */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 12px;
    background-color: black;
}

#loading_screen[hidden] {
    display: none;
}

#loading_screen:not(.is_catching_up) > * {
    visibility: hidden;
}

#loading_screen_text {
    margin: 0;
}

#loading_screen_message {
    margin: 4px 0 0;
    line-height: 1.6;
}

#loading_screen_activate {
    margin-top: 8px;
    padding: 4px 24px;
    letter-spacing: 0.2em;
}

#loading_screen_activate:disabled {
    border-color: darkgray;
    color: darkgray;
}

#loading_screen_bar {
    width: 240px;
    max-width: calc(100vw - 32px);
    height: 6px;
    border: 1px solid darkgray;
    padding: 1px;
}

/* grows from the left by scaleX (cheap to draw); no other animation, for slow machines */
#loading_screen_fill {
    height: 100%;
    background-color: #4CAF50;
    transform: scaleX(0);
    transform-origin: left;
}

/* playback speed set by update_held_glow_speed */
@keyframes held_glow_pulse {
    from { box-shadow: inset 0 0 4px rgb(155, 38, 218), 0 0 2px rgb(155, 38, 218); }
    to   { box-shadow: inset 0 0 18px rgb(155, 38, 218), 0 0 12px rgb(155, 38, 218); }
}

#farm_button.is_focused {
    animation: held_glow_pulse 0.6s ease-in-out infinite alternate;
}

#runes_grid {
    position: relative;
}

#rune_held_rate {
    text-align: center;
    margin-bottom: 0;
}

.study_ring {
    display: none;
    position: absolute;
    inset: -6px;
    width: calc(100% + 12px);
    height: calc(100% + 12px);
    margin: 0;
    overflow: visible;
    pointer-events: none;
}

.rune.is_studied .study_ring {
    display: block;
}

.study_ring rect {
    x: 1px;
    y: 1px;
    width: calc(100% - 2px);
    height: calc(100% - 2px);
    rx: 19px; /* tile's 14px corner + the 6px gap, minus half the stroke */
    fill: none;
    stroke: #4CAF50;
    stroke-width: 2px;
    stroke-dasharray: 3 2; /* in pathLength units (100 around the ring) */
    animation: study_ring_march 4s linear infinite;
}

/* the rect path runs clockwise, so a falling offset moves the dashes clockwise; -10 = two dash periods, seamless loop */
@keyframes study_ring_march {
    to { stroke-dashoffset: -10; }
}

#rune_held_all {
    display: block;
}

/* the hint sits outside the button, whose overflow: hidden would clip it */
#condense_button_holder {
    position: relative;
    width: fit-content;
}

#condense_button_holder:hover > #condense_hint {
    display: block;
}

#condense_hint, #cataclysm_shard_hint {
    text-align: center;
    font-size: 0.85em;
}

#rune_held_row {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.condense_button, .cataclysm_button {
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 4px 14px;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none; /* a long press shouldn't scroll or open the context menu */
}

.condense_preview, .cataclysm_preview {
    font-size: 0.8em;
}

.cataclysm_preview {
    font-size: 0.9em;
}

.condense_fill, .cataclysm_fill {
    position: absolute;
    inset: 0;
    transform-origin: left;
    transform: scaleX(0);
    background: rgba(255, 255, 255, 0.35);
    pointer-events: none;
}

#energy_container.condense_drain {
    animation: condense_drain 1.05s ease-out;
}

@keyframes condense_drain {
    30% { opacity: 0.3; }
}

.condense_particle {
    position: fixed;
    width: 6px;
    height: 6px;
    margin: 0;
    border-radius: 50%;
    background: rgb(185, 121, 223);
    box-shadow: 0 0 6px rgb(185, 121, 223);
    pointer-events: none;
    z-index: 10;
}

#rune_held_rate {
    transform-origin: center;
}

.condense_button > span:not(.condense_fill), .cataclysm_button > span:not(.cataclysm_fill) {
    position: relative; /* text above the fill */
}

#cataclysm_info {
    text-align: center;
    font-size: 0.85em;
    color: rgb(170, 170, 170);
    margin-top: 30px;
    margin-bottom: 1cqb;
}

#cataclysm_rune_reset {
    color: inherit;
    margin: 0;
}

/* the hint sits outside the button, whose overflow: hidden would clip it */
#cataclysm_button_holder {
    position: relative;
    width: fit-content;
    margin: 0 auto;
}

.cataclysm_button {
    margin: 0;
}

#cataclysm_button_holder:hover > #cataclysm_shard_hint:not(:empty) {
    display: block;
}

.cataclysm_title {
    font-size: 2em;
}

#cataclysm_anim_layer {
    position: fixed;
    inset: 0;
    z-index: 40;
}

html.cataclysm_anim_playing {
    overflow: hidden; /* shaking must not cause scrollbars */
}

/* the top bar stays above the effect (it happens within the realm), but can't be clicked */
html.cataclysm_anim_playing #main_tabs {
    z-index: 45;
    pointer-events: none;
}

#cataclysm_wave {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    pointer-events: none;
    background: linear-gradient(90deg, #050a2a, #0e2275 60%, #3a6fd8 90%, #dfe9ff);
    /* wavy front edge: a solid block plus a column of curves */
    -webkit-mask-image: linear-gradient(#000, #000), var(--wave_edge);
    mask-image: linear-gradient(#000, #000), var(--wave_edge);
    -webkit-mask-size: calc(100% - var(--wave_edge_depth)) 100%, var(--wave_edge_depth) var(--wave_edge_length);
    mask-size: calc(100% - var(--wave_edge_depth)) 100%, var(--wave_edge_depth) var(--wave_edge_length);
    -webkit-mask-position: left top, right top;
    mask-position: left top, right top;
    -webkit-mask-repeat: no-repeat, repeat-y;
    mask-repeat: no-repeat, repeat-y;
}

/* will-change keeps each ring on the graphics card, where its CSS blur is cheap */
#cataclysm_burn_rim .burn_ring {
    position: fixed;
    top: 0;
    left: 0;
    pointer-events: none;
    will-change: transform;
}

#cataclysm_burn_rim path {
    fill: none;
    stroke-linejoin: round;
}

.burn_heat { stroke: rgba(255, 120, 30, 0.35); }
.burn_char { stroke: rgba(40, 14, 2, 0.9); }
.burn_glow { stroke: #ff6a00; }
.burn_core { stroke: #ffe08a; }
/* on the whole layer: the graphics card fades it, nothing is redrawn */
.burn_ring_glow { animation: burn_glow_flicker 0.35s ease-in-out infinite alternate; }

@keyframes burn_glow_flicker {
    to { opacity: 0.7; }
}

#cataclysm_modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 30;
}

#cataclysm_modal[hidden] {
    display: none;
}

.cataclysm_dialog {
    max-width: calc(100vw - 32px);
    padding: 12px 24px;
    border: 2px solid darkgray;
    background-color: rgba(0, 0, 0, 0.92);
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.9);
    text-align: center;
}

.cataclysm_dialog_title {
    font-size: 18px;
}

#cataclysm_choices {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    margin-bottom: 12px;
}

.cataclysm_choice {
    display: flex;
    padding: 8px;
}

.cataclysm_choice_fire  { background: linear-gradient(180deg, #5a1c08, #1c0a04); }
.cataclysm_choice_water { background: linear-gradient(180deg, #0e2275, #050a2a); }
.cataclysm_choice_earth { background: linear-gradient(180deg, #3a5a0c, #121c04); }
.cataclysm_choice_air   { background: linear-gradient(180deg, #1a3f80, #08142e); }

.alignment_glow_fire  { --glow_color: #5a1c08; }
.alignment_glow_water { --glow_color: #0e2275; }
.alignment_glow_earth { --glow_color: #3a5a0c; }
.alignment_glow_air   { --glow_color: #1a3f80; }

#alignment_glow {
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse at center, transparent 60%, var(--glow_color) 100%);
    z-index: -1;
    opacity: 0;
    transition: opacity 0.5s;
    pointer-events: none;
}

#realm_features {
    margin-top: 12px;
}

/* Tributes | core | Infusions */
#elemental_core_section {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: start;
    gap: 30px;
    padding: 10px 16px 16px;
    border: 2px dotted;
}

@media (max-width: 900px) {
    #elemental_core_section { grid-template-columns: 1fr; justify-items: center; }
    #core_column { grid-row: 1; }
    #elemental_core_section > #tributes_column, #elemental_core_section > #core_infusions { justify-self: center; } /* beats the later base rules */
}

.realm_feature_title {
    margin-bottom: 10px;
}

.realm_feature_hint {
    font-size: 0.85em;
    color: rgb(170, 170, 170);
    margin-bottom: 8px;
}

#shard_bonuses {
    margin-top: 12px;
}

#shard_bonuses_list {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px 24px;
}

.shard_bonus {
    position: relative;
    white-space: nowrap;
}

#shard_bonuses_list > p {
    margin: 4px 0;
    font-size: 0.85em;
}

/* fixed width: the grid's middle column is auto, so text growing under the core (Unleash) would shift the tributes
   and infusions beside it */
#core_column {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 400px;
    max-width: 100%;
    text-align: center;
}

/* same 420px slot as #tributes_column, so the core stays centred */
#core_infusions {
    max-width: 420px;
    width: 100%;
    justify-self: start;
    text-align: center;
}

.quintessence_table {
    margin: 0 auto;
    border-collapse: collapse;
    color: inherit;
    font-size: inherit;
}

.quintessence_table td,
.quintessence_table th {
    padding: 0 6px;
    text-align: center;
    min-width: 3ch; /* 3-digit levels don't widen the table */
}

.quintessence_table th {
    font-weight: normal;
    text-align: left;
}

.quintessence_table td.is_record {
    color: rgb(235, 220, 150);
}

.quintessence_formula {
    margin: 4px 0 0;
    white-space: nowrap; /* one line however big the levels get, so the cards below never move */
    min-width: 40ch; /* the widest line sizes the infusions column: room for 3-digit levels, so it doesn't widen */
}

#infusions_list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* display: flex would override [hidden] */
.infusion[hidden] {
    display: none;
}

.infusion {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 6px;
    outline: 2px solid darkgray;
    font-size: 14px;
    text-align: left;
}

.infusion_image {
    flex: none;
    width: 48px;
    height: 48px;
    margin: 0;
}

.infusion_fire  { --infusion_color: rgb(235, 110, 40); }
.infusion_water { --infusion_color: rgb(70, 140, 230); }
.infusion_air   { --infusion_color: rgb(160, 205, 235); }
.infusion_earth { --infusion_color: rgb(123, 169, 62); }

.infusion_fire, .infusion_water, .infusion_air, .infusion_earth {
    outline-color: var(--infusion_color);
    box-shadow: inset 0 0 12px color-mix(in srgb, var(--infusion_color) 50%, transparent);
}

/* recoloured without a CSS mask: Chrome fetches mask images with CORS, which a file:// page can't pass, so the icon
   came out blank. The <img> sits just left of the box and its drop-shadow (same shape and alpha, in the element's
   colour) lands exactly in it; the box clips the image itself. The offset must match .infusion_image's width */
.infusion_image_tinted {
    display: block;
    overflow: hidden;
}

.infusion_image_tinted > img {
    display: block;
    width: 100%;
    height: 100%;
    margin: 0;
    transform: translateX(-100%);
    filter: drop-shadow(48px 0 0 var(--infusion_color));
}

.infusion_text {
    flex: 1;
    min-width: 0;
}

.infusion_text > p {
    margin: 0;
    font-size: 14px;
}

.infusion_title {
    font-weight: bold;
}

.infusion_effect {
    color: rgb(170, 170, 170);
}

.infusion_buy {
    flex: none;
    min-width: 8ch;
    padding: 4px 8px;
    border-color: var(--core_bright);
}

.infusion_buy:disabled {
    border-color: darkgray;
}

.tribute > .hover_hint {
    border-color: var(--core_bright);
    font-size: 14px;
}

#tributes_column {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 420px;
    width: 100%;
    justify-self: end;
}

#tributes_column > * {
    width: 100%;
    max-width: 320px;
    box-sizing: border-box;
    align-self: flex-end;
}

.tribute {
    position: relative; /* no overflow hidden: it would clip the .hover_hint */
    margin: 0;
    padding: 6px 10px;
    outline: 2px solid darkgray;
    font-size: 14px;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
}

.tribute > p {
    position: relative; /* text above the fill */
    margin: 2px 0;
    font-size: 14px;
}

.tribute_title {
    font-weight: bold;
}

.tribute_fill {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    margin: 0;
    background: linear-gradient(to right, var(--core_dark), var(--core_bright));
    opacity: 0.45;
    transition: width 0.2s linear;
    pointer-events: none;
}

.tribute.is_open:hover {
    box-shadow: inset 0 0 20px color-mix(in srgb, var(--core_bright) 35%, transparent);
}

.tribute.is_held,
.discharge_button.is_held {
    animation: tribute_held_pulse 0.6s ease-in-out infinite alternate;
}

.discharge_button {
    position: relative;
    padding: 4px 12px;
    border-color: var(--core_bright);
    user-select: none;
    -webkit-user-select: none;
    touch-action: none; /* a long press shouldn't scroll or open the context menu */
}

.actives_discharge {
    margin: 6px 0 0; /* no side margins (the * rule adds 2px), so Unleash spans the column's width */
    text-align: center;
}

.actives_discharge > .discharge_button {
    display: block;
    box-sizing: border-box;
    width: 100%;
    margin: 0;
}

.discharge_button > .hover_hint,
#unleash_text > .hover_hint {
    border-color: var(--core_bright);
    font-size: 14px;
}

/* fit-content so only the text itself is hoverable */
#unleash_text {
    position: relative;
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
}

/* always 3 lines (get_unleash_text), so the height never jumps */
#unleash_text,
.actives_flux {
    line-height: 1.3;
    min-height: 3.9em;
    max-width: 100%;
}

#unleash_text:hover > .hover_hint {
    display: block;
}

@keyframes tribute_held_pulse {
    from { box-shadow: 0 0 4px var(--core_bright), inset 0 0 6px color-mix(in srgb, var(--core_bright) 40%, transparent); }
    to   { box-shadow: 0 0 16px var(--core_bright), inset 0 0 20px color-mix(in srgb, var(--core_bright) 60%, transparent); }
}

.tribute.is_complete {
    outline-color: var(--core_bright);
    cursor: default;
}

@property --tribute_trace_angle {
    syntax: "<angle>";
    inherits: false;
    initial-value: 0deg;
}

.tribute.just_completed::after {
    content: "";
    position: absolute;
    inset: -4px;
    margin: 0;
    padding: 4px;
    pointer-events: none;
    background: conic-gradient(from var(--tribute_trace_angle),
        transparent 0deg, transparent 250deg, var(--core_bright) 330deg, white 360deg);
    /* only the ring between the padding and the content shows */
    mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude; /* after the -webkit-mask shorthand, which resets it in Chrome */
    animation: tribute_complete_trace 0.9s ease-in-out forwards;
}

@keyframes tribute_complete_trace {
    0%   { --tribute_trace_angle: 0deg; opacity: 1; }
    80%  { opacity: 1; }
    100% { --tribute_trace_angle: 360deg; opacity: 0; }
}

.tribute.is_locked {
    cursor: not-allowed;
    opacity: 0.5;
}

.core_fire  { --core_dark: #c2410c; --core_bright: #ffb347; }
.core_water { --core_dark: #2563eb; --core_bright: #7fd0ff; }
.core_earth { --core_dark: #4d7c0f; --core_bright: #c8f07a; }
.core_air   { --core_dark: #3b82f6; --core_bright: #dbe9ff; }

/* frame SVG (128 units) has a round window of radius 47: at 272px it fits the 200px sphere exactly */
#core_frame_holder {
    position: relative;
    width: 272px;
    height: 272px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#core_frame {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    pointer-events: none;
}

#elemental_core {
    position: relative;
    margin: 0;
    overflow: hidden;
    width: 200px;
    height: 200px;
    padding: 0;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.5);
    background: transparent;
    box-shadow:
        inset 0 0 22px rgba(255, 255, 255, 0.26),
        0 0 18px rgba(255, 255, 255, 0.18),
        0 0 40px color-mix(in srgb, var(--core_bright) 25%, transparent);
    -webkit-user-select: none;
    user-select: none;
    cursor: pointer;
    touch-action: none; /* a long press shouldn't scroll or open the context menu */
}

/* only opacity animates, which the compositor runs on its own; animating blur sizes repaints every frame and
   stutters whenever the game loop is busy */
#core_glass::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    pointer-events: none;
    box-shadow: inset 0 0 50px color-mix(in srgb, var(--core_bright) 65%, transparent);
    opacity: 0;
    transition: opacity 0.3s;
    will-change: opacity;
}

#core_frame_holder.is_held #core_fill {
    filter: brightness(1.3);
}

#core_frame_holder.is_held #core_glass::before {
    opacity: 1;
    animation: core_glow_in 0.5s ease-out, var(--glow_pulse) 0.5s infinite;
}
/* every pulse starts at its dimmest (0.1), so the fade-in leads straight into it */
.core_fire  #core_frame_holder { --glow_pulse: core_held_flicker 5s ease-in-out; }
.core_water #core_frame_holder { --glow_pulse: core_held_swell 7s ease-in-out; }
.core_earth #core_frame_holder { --glow_pulse: core_held_throb 3.5s ease-in-out; }
.core_air   #core_frame_holder { --glow_pulse: core_held_shimmer 4s ease-in-out; }

@keyframes core_glow_in {
    from { opacity: 0; }
    to   { opacity: 0.1; }
}

@keyframes core_held_flicker {
    0%   { opacity: 0.1; }
    30%  { opacity: 1; }
    45%  { opacity: 0.45; }
    65%  { opacity: 0.9; }
    100% { opacity: 0.1; }
}

@keyframes core_held_swell {
    0%, 100% { opacity: 0.1; }
    50%      { opacity: 1; }
}

@keyframes core_held_throb {
    0%   { opacity: 0.1; }
    25%  { opacity: 1; }
    100% { opacity: 0.1; }
}

@keyframes core_held_shimmer {
    0%, 100% { opacity: 0.1; }
    25%      { opacity: 0.7; }
    45%      { opacity: 0.35; }
    70%      { opacity: 1; }
}

#core_fill {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    margin: 0;
    background: linear-gradient(to top, var(--core_liquid_dark), var(--core_liquid_light));
    opacity: 0.9;
    transition: height 0.2s linear, filter 0.3s;
}

/* dark, so the white number inside stays readable */
.core_fire  { --core_liquid_dark: #3d0f04; --core_liquid_light: #8a2f0c; }
.core_water { --core_liquid_dark: #08113f; --core_liquid_light: #1d3a94; }
.core_earth { --core_liquid_dark: #162905; --core_liquid_light: #426812; }
.core_air   { --core_liquid_dark: #0a1a3d; --core_liquid_light: #24508f; }

#core_amount {
    position: absolute;
    inset: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    text-shadow: 0 0 4px black, 0 0 2px black;
    pointer-events: none;
}

#core_amount > span {
    margin: 0;
}

#core_rate {
    font-size: 14px;
    opacity: 0.8;
}

#core_gathered:empty {
    display: none;
}

#core_glass {
    position: absolute;
    inset: 0;
    margin: 0;
    border-radius: 50%;
    background:
        radial-gradient(ellipse 22% 14% at 32% 20%, rgba(255, 255, 255, 0.55), transparent),
        radial-gradient(circle at 72% 82%, rgba(255, 255, 255, 0.12), transparent 30%);
    pointer-events: none;
}

#alignment_glow.is_visible {
    opacity: 0.225;
}

.cataclysm_choice .alignment_icon {
    width: 64px;
    height: 64px;
}

.cataclysm_choice {
    transition: opacity 0.2s, box-shadow 0.2s;
}

#cataclysm_choices.has_selection .cataclysm_choice:not(.is_selected) {
    opacity: 0.4;
}

.cataclysm_choice.is_selected {
    border-color: white;
    box-shadow: 0 0 12px rgba(255, 255, 255, 0.6);
}

#cataclysm_confirm_button {
    display: block;
    margin: 0 auto 4px;
    padding: 4px 14px;
    font-size: 1.1em;
}

#air_wind {
    position: absolute;
    margin: 0;
    transform: translate(-50%, -50%);
    pointer-events: none;
    opacity: 0;
    transition: left 1.2s ease-in-out, top 1.2s ease-in-out, transform 0.6s ease-out, opacity 2s;
}

#air_wind.is_visible {
    opacity: 1;
}

#air_wind.is_gusting {
    transform: translate(-50%, -50%) scale(1.35);
}

#air_wind svg {
    display: block;
    width: 100%;
    height: 100%;
    margin: 0;
    fill: none;
    stroke: rgb(160, 205, 235);
    stroke-linecap: round;
    opacity: 0.45;
    filter: blur(2.2px) drop-shadow(0 0 5px rgb(160, 205, 235));
}

/* spun inside the svg, not the svg itself: a rotating box pokes its corners out and stretches the page (earth is the bottom tile) */
#air_wind .wind_spin {
    transform-box: view-box;
    transform-origin: 50% 50%;
    animation: air_wind_spin 5s linear infinite;
}

#air_wind .wind_line {
    stroke-width: 4;
    stroke-dasharray: 75 25;
    opacity: 0.3;
    animation: air_wind_flow 1.8s linear infinite;
}

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

@keyframes air_wind_flow {
    to { stroke-dashoffset: -100; }
}

#settings_button {
    margin-left: auto;
}

#settings_tab {
    margin: auto;
    margin-top: 20px;
    width: 70%;
}

#save_buttons button {
    padding: 10px 15px;
    margin: 5px;
}

#skip_offline_setting,
#mouseover_mode_setting {
    display: block;
    margin: 10px auto;
    cursor: pointer;
}

#save_file_setting {
    display: block;
    margin: 10px auto;
}

/* the browser's default white box; the * rule makes all text white */
#save_file_name {
    width: 20ch;
    color: black;
}

#save_file_name:focus {
    outline: none;
}

#remnants_balance {
    margin-bottom: 30px;
}

/* one grid filled column by column, so cards in the same row share a height */
#remnants_columns {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(5, auto); /* title + REMNANT_ROW_COSTS.length */
    grid-auto-flow: column;
    gap: 20px 40px;
    max-width: 960px;
    margin: 0 auto;
}

@media (max-width: 600px) {
    #remnants_columns {
        grid-template-columns: 1fr;
        grid-template-rows: none;
        grid-auto-flow: row;
    }
}

.remnants_column {
    display: contents;
}

.remnants_column_title {
    font-weight: bold;
    letter-spacing: 0.2em;
}

.remnant_upgrade {
    margin: 2px; /* room for the outline and glow */
}

/* a seamless 600px fog tile, density in the alpha. Used twice: as the barely-visible haze itself, and as the mask
   on each node's backglow, so the glow is that same haze lit up */
:root {
    --research_fog: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='600' height='600'%3E%3Cfilter id='f' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.005' numOctaves='3' seed='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.66  0 0 0 0 0.62  0 0 0 0 0.81  1.6 0 0 0 -0.1'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23f)'/%3E%3C/svg%3E");
}

#research_tab::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background-image: var(--research_fog);
    background-size: 600px 600px;
    opacity: 0.025;
}

#research_tree {
    position: relative;
    isolation: isolate; /* keeps the node halos behind the lines, inside the tree */
    display: flex;
    flex-direction: column;
    gap: 100px;
    max-width: 960px;
    margin: 40px auto;
    padding: 90px 0; /* the top is fitted to the top panel's height (fit_top_panel_room) */
}

#research_lines {
    position: absolute;
    top: 0;
    left: 0;
    margin: 0;
    pointer-events: none;
    overflow: visible;
}

/* walls and fills get their colour (a gradient) from the svg, so no stroke here */
.research_tube_wall {
    stroke-width: 9;
    stroke-linecap: butt;
    stroke-opacity: 0.3;
}

/* matches the open ring's 75% */
.research_tube_wall.is_open {
    stroke-opacity: 0.75;
}

.research_tube_wall.is_researched {
    stroke-opacity: 1;
}

/* 3px narrower than the wall: leaves two 1.5px walls, the ring's border width */
.research_tube_hollow {
    stroke: black;
    stroke-width: 6;
    stroke-linecap: butt;
}

.research_tube_fill {
    stroke-width: 6;
    stroke-linecap: butt;
    stroke-opacity: 0.8;
}

.research_layer {
    display: flex;
    justify-content: center;
    gap: 200px; /* an inner node's panel (150px + 16px offset) fits between it and its outer neighbour */
    margin: 0;
}

.research_node {
    --node_mix: color-mix(in srgb, var(--node_left) 50%, var(--node_right));
    position: relative; /* above the svg */
    box-sizing: border-box;
    width: 46px;
    height: 46px;
    margin: 0;
    border-radius: 50%;
    border: 1.5px solid;
    border-color: color-mix(in srgb, var(--node_mix) 45%, transparent) color-mix(in srgb, var(--node_right) 45%, transparent)
        color-mix(in srgb, var(--node_mix) 45%, transparent) color-mix(in srgb, var(--node_left) 45%, transparent);
    background: black; /* lines don't show through */
    font-size: 14px;
    transition: opacity 1s, filter 1s, border-color 1s, box-shadow 1s;
}

/* masked by the haze's own fog, so it only shows where the haze is dense: wispy and uneven, not a clean disc */
.research_node::before {
    --halo: color-mix(in srgb, var(--node_left) 50%, var(--node_right));
    -webkit-mask-image: var(--research_fog);
    mask-image: var(--research_fog);
    -webkit-mask-size: 600px 600px;
    mask-size: 600px 600px;
    -webkit-mask-position: var(--fog_offset, 0 0);
    mask-position: var(--fog_offset, 0 0);
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 400px;
    height: 400px;
    transform: translate(-50%, -50%);
    z-index: -1; /* under the lines */
    pointer-events: none;
    border-radius: 50%;
    background:
        radial-gradient(closest-side,
            var(--halo),
            color-mix(in srgb, var(--halo) 75%, transparent) 10%,
            color-mix(in srgb, var(--halo) 50%, transparent) 20%,
            color-mix(in srgb, var(--halo) 20%, transparent) 60%,
            transparent),
        radial-gradient(closest-side,
            rgba(168, 159, 207, 0.6),
            rgba(168, 159, 207, 0.45) 10%,
            rgba(168, 159, 207, 0.3) 20%,
            rgba(168, 159, 207, 0.12) 60%,
            transparent);
    opacity: 0.3;
    transition: opacity 1s;
}

.research_node:not(.is_researched)::before {
    opacity: 0.15;
}

.research_node.is_encrypted {
    opacity: 0.35;
    filter: saturate(0.4);
}

.research_node.is_open {
    border-color: color-mix(in srgb, var(--node_mix) 75%, transparent) color-mix(in srgb, var(--node_right) 75%, transparent)
        color-mix(in srgb, var(--node_mix) 75%, transparent) color-mix(in srgb, var(--node_left) 75%, transparent);
}

.research_node.is_researched {
    border-color: var(--node_mix) var(--node_right) var(--node_mix) var(--node_left);
    box-shadow: inset 16px 0 18px -2px var(--node_left), inset -16px 0 18px -2px var(--node_right), inset 0 0 14px 8px var(--node_mix);
}

/* lifted while hovered, so its hint isn't covered by later circles */
.research_node:hover {
    z-index: 10;
}

.research_node > .hover_hint {
    top: calc(100% + 8px);
    bottom: auto;
    width: max-content;
    max-width: 260px;
    white-space: normal;
    border-color: rgb(168, 159, 207);
}

.research_node.has_panel_bottom > .hover_hint {
    top: auto;
    bottom: calc(100% + 8px);
}

.research_node:hover > .hover_hint {
    display: block;
}

/* no backdrop-filter, for slow machines */
.research_panel {
    position: absolute;
    box-sizing: border-box;
    width: 150px;
    margin: 0;
    padding: 6px 8px;
    font-size: 12px;
    text-align: left;
    background-color: rgba(12, 11, 16, 0.9);
    border: 1px solid color-mix(in srgb, var(--node_mix) 45%, transparent);
    box-shadow: 0 14px 22px -8px rgba(0, 0, 0, 0.85), 0 0 16px rgba(168, 159, 207, 0.12);
    transition: border-color 1s;
}

.research_panel * {
    text-align: left;
}

.research_node.is_open > .research_panel {
    border-color: color-mix(in srgb, var(--node_mix) 75%, transparent);
}

.research_node.is_researched > .research_panel {
    border-color: var(--node_mix);
}

.research_panel_right {
    left: calc(100% + 16px);
    top: 50%;
    translate: 0 -50%;
}

.research_panel_left {
    right: calc(100% + 16px);
    top: 50%;
    translate: 0 -50%;
}

/* grows downward from the node's top, so it doesn't reach into the row above. 162px + 280px from the centre fits
   the narrowest window that shows panels, 1100px */
.research_panel_right.is_hanging,
.research_panel_left.is_hanging {
    top: 0;
    translate: 0 0;
    width: 280px;
}

/* node centre 369px from the page's (4 nodes of 46px, 200px gaps), minus 23px + 16px to the panel, ~30px clear of
   the edge and the scrollbar: 50vw − 440px */
.research_panel.is_outer {
    width: clamp(150px, 50vw - 440px, 280px);
}

/* the room above the top node is only #research_tree's padding, so the panel spreads out instead of growing up */
.research_panel_top {
    width: 280px;
    bottom: calc(100% + 16px);
    left: 50%;
    translate: -50% 0;
}

.research_panel_bottom {
    top: calc(100% + 16px);
    left: 50%;
    translate: -50% 0;
}

.research_reward_name {
    margin: 0 0 3px;
    font-size: 13px;
    font-weight: bold;
}

.research_reward_description {
    margin: 0;
}

.research_keyword_focus {
    background-image: linear-gradient(to right,
        color-mix(in srgb, var(--node_left) 55%, white),
        color-mix(in srgb, var(--node_right) 55%, white));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    font-weight: bold;
}

/* inline-block: the gradient spans the text, not the whole panel */
.research_reward_current {
    display: inline-block;
    margin: 4px 0 0;
    background-image: linear-gradient(to right,
        color-mix(in srgb, var(--node_left) 55%, white),
        color-mix(in srgb, var(--node_right) 55%, white));
    -webkit-background-clip: text;
    background-clip: text;
}

.research_reward_current,
.research_reward_current * {
    color: transparent; /* shows the gradient through the text; the * rule sets white on nested text too */
}

.research_reward_current:empty {
    display: none;
}

/* only on narrow screens, where the panels are hidden */
.research_hint_reward {
    display: none;
    margin-bottom: 6px;
}

@media (max-width: 1099px) {
    .research_panel {
        display: none;
    }

    .research_hint_reward {
        display: block;
    }
}

.research_requirement {
    margin: 2px 0;
}

.research_shards {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 2px 12px;
}

/* the * rule sets white on nested text, so colour the children too */
.research_requirement.is_met,
.research_requirement.is_met * {
    color: #7ddc81;
}

.research_requirement.is_unmet,
.research_requirement.is_unmet * {
    color: #e05555;
}

.remnant_upgrade.upgrade_bought .upgrade_cost {
    display: none;
}

.remnant_upgrade.object_clickable {
    outline-color: #A89FCF;
    box-shadow: 0 0 8px rgba(168, 159, 207, 0.6);
}

.remnant_upgrade.object_clickable:hover {
    box-shadow: 0 0 8px rgba(168, 159, 207, 0.6), inset 0 0 30px rgba(92, 82, 140);
}

.remnant_upgrade.upgrade_bought {
    outline: 1px solid rgba(168, 159, 207, 0.6);
    box-shadow: inset 0 0 12px rgba(168, 159, 207, 0.25);
}

.remnant_upgrade.upgrade_bought > .upgrade_effect {
    color: #c9c2e8;
}
