/* ============================================================
   HeroesT3 theme.
   Dark, warm "launcher" backdrop; game art always sits on light cards
   because every original asset is drawn to fade into white.
   The legacy layout positions header, resources and server time
   absolutely around a fixed 980px column; this sheet puts everything
   back into normal flow + CSS grid so desktop and phone share one model.
   ht3_ui.js adds the app bar (brand, menu button), the nav drawer,
   medallion labels and live storage bars.
   Some pages link compact.css after lang.css, hence the !important on
   properties compact.css also sets.
   ============================================================ */

:root {
    --night-0: #120d09;
    --night-1: #1f1710;
    --night-2: #2b2016;
    --glass: rgba(255, 236, 200, 0.06);
    --glass-strong: rgba(30, 21, 14, 0.82);
    --glass-edge: rgba(226, 182, 90, 0.28);
    --gold: #e2b65a;
    --gold-hi: #f6d58c;
    --gold-deep: #9a6a1f;
    --on-dark: #efe2c6;
    --on-dark-soft: #b9a888;

    --card: #ffffff;
    --card-edge: #e6d6b0;
    --line: #eee3cb;
    --tint: #f7efdc;
    --ink: #2f2519;
    --ink-soft: #6b5b45;
    --heading: #5b2814;
    --link: #8a4f12;
    --link-hover: #5b2814;
    --danger: #c0392b;

    --radius: 14px;
    --shadow: 0 18px 40px rgba(0, 0, 0, 0.45), 0 2px 6px rgba(0, 0, 0, 0.3);
}

html {
    background:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 .88 0 0 0 0 .65 0 0 0 .07 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"),
        radial-gradient(1100px 520px at 50% -8%, rgba(226, 182, 90, 0.20), transparent 62%),
        radial-gradient(900px 500px at 100% 0%, rgba(140, 50, 25, 0.12), transparent 70%),
        radial-gradient(600px 420px at 0% 10%, rgba(40, 70, 60, 0.18), transparent 60%),
        linear-gradient(180deg, var(--night-1), var(--night-0)) !important;
    background-color: var(--night-0) !important;
    background-repeat: repeat, no-repeat, no-repeat, no-repeat, no-repeat !important;
    min-height: 100%;
    scrollbar-color: #8a5d1c var(--night-0);
}
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--night-0); }
::-webkit-scrollbar-thumb { background: linear-gradient(#b07a2a, #7d5216); border-radius: 10px; border: 2px solid var(--night-0); }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
body {
    background: none !important;
    color: var(--ink);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "DejaVu Sans", sans-serif;
    -webkit-font-smoothing: antialiased;
}

/* ---------- page skeleton: flow layout ---------- */
.wrapper {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: none !important;
}
div#dynamic_header, div#header, div#mid, div#res, div#footer, div#ltime {
    min-width: 0 !important;
}
div#header, div#footer, div#mfoot, div#cfoot {
    box-sizing: border-box;
    width: auto !important;
    max-width: 100%;
}

/* min-height is multiplied by zoom, so divide it back: the page ends at the footer, no scroll below it */
@media (min-width: 1300px) { .wrapper { zoom: 1.12; min-height: calc(100vh / 1.12); } }
@media (min-width: 1600px) { .wrapper { zoom: 1.3; min-height: calc(100vh / 1.3); } }
@media (min-width: 2300px) { .wrapper { zoom: 1.65; min-height: calc(100vh / 1.65); } }
/* popups (manual tooltips, large map) live in #ce, outside .wrapper: give them the same scale */
div#ce { width: 100% !important; box-sizing: border-box; }
@media (min-width: 1300px) { div#ce { zoom: 1.12; width: calc(100vw / 1.12) !important; } }
@media (min-width: 1600px) { div#ce { zoom: 1.3; width: calc(100vw / 1.3) !important; } }
@media (min-width: 2300px) { div#ce { zoom: 1.65; width: calc(100vw / 1.65) !important; } }

/* Hero: the illustrated panorama, fading into the night backdrop. */
div#dynamic_header {
    order: 1;
    width: 1099px;
    max-width: 100%;
    height: 99px !important;
    margin: 0 auto;
    background-size: auto 99px !important;
    background-position: center top !important;
    -webkit-mask-image: linear-gradient(to right, transparent, #000 14%, #000 86%, transparent), linear-gradient(to bottom, #000 62%, transparent);
    -webkit-mask-composite: source-in;
    mask-image: linear-gradient(to right, transparent, #000 14%, #000 86%, transparent), linear-gradient(to bottom, #000 62%, transparent);
    mask-composite: intersect;
}

/* ---------- app bar ---------- */
div#header {
    order: 2;
    position: sticky;
    top: 0;
    z-index: 150; /* above the dorf2 level badges (z-index 97) */
    height: auto !important;
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 6px max(16px, calc((100% - 1110px) / 2));
    margin-top: -22px;
    background: #241a11 !important; /* opaque: the page no longer shows through the sticky bar while scrolling */
    /* HeroesT3: no backdrop blur - it forces a GPU re-blur on every scroll and page load */
    border-top: 1px solid var(--glass-edge);
    border-bottom: 1px solid var(--glass-edge);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
.ht3-brand {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "DejaVu Sans", sans-serif;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: var(--gold) !important;
    text-decoration: none !important;
    text-shadow: 0 0 18px rgba(226, 182, 90, 0.35);
    white-space: nowrap;
}
.ht3-brand span {
    color: var(--on-dark);
    margin-left: 4px;
    font-size: 0.75em;
    vertical-align: 0.12em;
}
.ht3-burger {
    display: none;
    width: 42px;
    height: 42px;
    padding: 10px;
    border: 1px solid var(--glass-edge);
    border-radius: 10px;
    background: var(--glass);
    cursor: pointer;
    flex: none;
}
.ht3-burger span {
    display: block;
    height: 2px;
    margin: 4px 0;
    border-radius: 2px;
    background: var(--gold);
}

div#mtop,
body.mod1 div#mtop, body.mod2 div#mtop, body.mod3 div#mtop {
    position: static !important;
    left: auto !important;
    top: auto !important;
    margin: 0 !important;
    width: auto !important;
    height: auto !important;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    font-size: 13px;
}
div#mtop > * {
    position: static !important;
    left: auto !important;
    top: auto !important;
    float: none !important;
    margin: 0 !important;
}
/* medallions */
div#mtop > a[id^="n"], div#mtop > div#n5 {
    display: flex !important;
    flex-direction: column;
    align-items: center;
    width: 78px !important;
    height: auto !important;
    align-self: flex-start;
    text-decoration: none;
    transition: transform 0.15s ease;
}
div#mtop > a[id^="n"]:hover, div#mtop > div#n5:hover {
    transform: translateY(-2px);
}
div#mtop > a[id^="n"] img, div#mtop > div#n5 {
    zoom: 0.82;
}
/* reports/messages: one sprite on the div, split by two 35px links */
div#mtop > div#n5 {
    display: block !important;
    position: relative !important;
    width: 70px !important;
    height: 67px !important;
    margin: 0 4px !important;
    white-space: nowrap;
}
div#mtop > div#n5 > a {
    float: none !important;
}

div#goldHeader, div#goldHeader font {
    color: var(--gold-hi) !important;
    white-space: nowrap;
    position: static !important;
    left: auto !important;
    top: auto !important;
    margin: 0 !important;
    float: none !important;
    transform: none !important;
    min-width: 0 !important;
    line-height: 1.2 !important;
    padding: 6px 12px;
    border: 1px solid var(--glass-edge);
    border-radius: 999px;
    background: var(--glass);
}
div#goldHeader font {
    border: 0;
    padding: 0;
    margin: 0 !important;
    background: none;
}
div#header a#plus {
    display: flex !important;
    align-items: center;
    width: auto !important;
    height: auto !important;
    background: linear-gradient(180deg, #d9a24a, var(--gold-deep)) !important;
    border: 1px solid #6a4512;
    border-radius: 999px;
    padding: 7px 16px;
    margin-left: 8px !important;
    box-shadow: 0 0 0 3px rgba(226, 182, 90, 0.15);
    text-decoration: none;
}
div#header a#plus span.plus_text {
    display: inline !important;
    width: auto !important;
    height: auto !important;
    padding: 0 !important;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "DejaVu Sans", sans-serif;
    font-size: 13px;
    letter-spacing: 0.12em;
    line-height: 1;
}
div#header a#plus * {
    color: #fff8e6 !important;
    background: none !important;
}
div#header a#plus img {
    display: none !important;
}
img.day, img.night, div.peace, div#mtop > div#wrapper, div#mtop > .clear {
    display: none !important;
}

/* server-time line: a small HUD pill bottom-right */
div#stime {
    display: block !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible;
}
div#ltime,
body.mod1 div#ltime, body.mod2 div#ltime, body.mod3 div#ltime {
    position: fixed !important;
    top: auto !important;
    left: auto !important;
    right: 14px;
    bottom: 14px;
    width: auto !important;
    height: auto !important;
    z-index: 40;
    padding: 6px 12px;
    border: 1px solid var(--glass-edge);
    border-radius: 10px;
    background: var(--glass-strong);
    /* HeroesT3: no backdrop blur - it forces a GPU re-blur on every scroll and page load */
    pointer-events: none;
    font-size: 11px;
    line-height: 1.5;
}
div#ltime div#ltimeWrap {
    width: auto !important;
    margin: 0 !important;
}
div#ltime, div#ltime b, div#ltime span {
    color: var(--on-dark-soft) !important;
}
div#ltime b {
    color: var(--gold-hi) !important;
}
div#ltime a, div#ltime button, div#ltime input {
    pointer-events: auto;
}

/* ---------- resource strip ---------- */
div#res,
body.mod1 div#res, body.mod2 div#res, body.mod3 div#res {
    order: 3;
    position: static !important;
    width: auto !important;
    height: auto !important;
    padding: 18px 12px 0;
}
div#resWrap {
    position: static !important;
    left: auto !important;
    margin: 0 auto !important;
    width: auto !important;
}
div#res table {
    margin: 0 auto;
    border: 0 !important;
    background: none !important;
    border-spacing: 0;
}
div#res table tbody, div#res table tr {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}
div#res table td {
    display: flex;
    align-items: center;
    background: none !important;
    border: 0 !important;
}
div#res td.ht3-res-icon {
    padding: 0 0 0 12px !important;
    margin-right: -10px;
    height: 40px;
    border-radius: 12px 0 0 12px;
    background: var(--card) !important;
    border: 1px solid var(--card-edge) !important;
    border-right: 0 !important;
    position: relative;
    z-index: 1;
}
div#res td.ht3-res-val {
    position: relative;
    height: 40px;
    padding: 0 14px 0 10px !important;
    min-width: 92px;
    border-radius: 0 12px 12px 0;
    background: var(--card) !important;
    border: 1px solid var(--card-edge) !important;
    border-left: 0 !important;
    color: var(--ink);
    font-weight: 700;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}
/* the icon cell casts no shadow: it fell over the value cell as a grey band at the seam */
div#res td.ht3-res-icon {
    box-shadow: none;
}
div#res td.ht3-res-val::after {
    content: "";
    position: absolute;
    left: 8px;
    right: 12px;
    bottom: 7px;
    height: 4px;
    border-radius: 4px;
    background:
        linear-gradient(90deg, #6aa84f, #a7c957) 0 0 / var(--fill, 0%) 100% no-repeat,
        #efe6d2;
}
div#res td.ht3-res-val.ht3-full::after {
    background:
        linear-gradient(90deg, #d35400, var(--danger)) 0 0 / var(--fill, 0%) 100% no-repeat,
        #efe6d2;
}
div#res td.ht3-res-val.ht3-full {
    color: var(--danger);
}

/* ---------- three-card body ---------- */
div#mid {
    order: 4;
    width: auto !important;
    height: auto !important;
    margin: 22px auto 0 !important;
    padding: 0 16px !important;
    display: grid !important;
    grid-template-columns: 210px 606px 270px;
    gap: 20px;
    justify-content: center;
    align-items: start;
    background: none !important;
    border: 0 !important;
}
div#mid > * {
    grid-column: 1 / -1;
}
div#mid > div#side_navi { grid-column: 1; grid-row: 2; }
div#mid > div#content { grid-column: 2; grid-row: 2; }
div#mid > div#side_info { grid-column: 3; grid-row: 2; }
div#mid > div#res { grid-row: 1; padding-top: 0; }
div#mid > div#footer { grid-row: 3; }
/* server-time HUD is fixed-position: keep it out of the grid so it adds no gap below the footer */
div#mid > div#stime { position: absolute; width: 0; }
div#mid > .clear, div#mid > br { display: none; }

div#side_navi, div#content, div#side_info,
body.mod1 div#content, body.mod2 div#content, body.mod3 div#content,
body.mod1 div#side_info, body.mod2 div#side_info, body.mod3 div#side_info {
    float: none !important;
    height: auto !important;
    min-height: 0 !important;
    margin: 0 !important;
    left: auto !important;
    background-image: none !important;
}

/* content card */
div#content {
    width: 552px !important;
    padding: 24px 26px 26px !important;
    background: var(--card) !important;
    border: 1px solid var(--card-edge);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    position: relative;
}
div#content::before {
    content: "";
    position: absolute;
    left: 18px;
    right: 18px;
    top: -1px;
    height: 3px;
    border-radius: 0 0 3px 3px;
    background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

/* advisor / villages card */
div#side_info {
    width: auto !important;
    padding: 16px !important;
    background: var(--card) !important;
    border: 1px solid var(--card-edge);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    position: relative;
}
div#side_info > br {
    display: none;
}
div#side_info.ht3-empty {
    display: none !important;
}

/* navigation panel */
div#side_navi {
    width: auto !important;
    padding: 10px !important;
    background: var(--glass) !important;
    border: 1px solid var(--glass-edge);
    border-radius: var(--radius);
    /* HeroesT3: no backdrop blur - it forces a GPU re-blur on every scroll and page load */
}
div#side_navi a#logo {
    display: none !important;
}
.ht3-drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 8px 10px;
    margin-bottom: 6px;
    border-bottom: 1px solid var(--glass-edge);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "DejaVu Sans", sans-serif;
    font-size: 13px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--gold);
}
.ht3-drawer-close {
    display: none;
    width: 34px;
    height: 34px;
    border: 1px solid var(--glass-edge);
    border-radius: 8px;
    background: var(--glass);
    color: var(--gold);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}
div#side_navi p {
    margin: 0 !important;
    padding: 6px 0;
}
div#side_navi p + p {
    border-top: 1px solid rgba(226, 182, 90, 0.14);
}
div#side_navi br {
    display: none;
}
div#side_navi p a, div#side_navi a {
    display: block;
    position: relative;
    color: var(--on-dark) !important;
    font-size: 14px;
    line-height: 1.25;
    padding: 8px 12px 8px 16px;
    border-radius: 8px;
    background: none !important;
    height: auto !important;
    width: auto !important;
    transition: background 0.15s ease, color 0.15s ease;
}
div#side_navi p a::before, div#side_navi a::before {
    content: "";
    position: absolute;
    left: 6px;
    top: 50%;
    width: 4px;
    height: 4px;
    margin-top: -2px;
    transform: rotate(45deg);
    background: var(--gold-deep);
}
div#side_navi p a:hover, div#side_navi a:hover {
    background: rgba(226, 182, 90, 0.12) !important;
    color: var(--gold-hi) !important;
}
div#side_navi a.ht3-active {
    background: rgba(226, 182, 90, 0.18) !important;
    color: var(--gold-hi) !important;
    box-shadow: inset 3px 0 0 var(--gold);
}
div#side_navi a.ht3-active::before, div#side_navi a:hover::before {
    background: var(--gold);
}
div#side_navi font[color="Red"], div#side_navi font[color="red"] {
    color: #ff8a7a !important;
}
div#side_navi font[color="Blue"], div#side_navi font[color="blue"] {
    color: #8ab4ff !important;
}

/* ---------- typography ---------- */
h1, h2, h3, h4, h5 {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "DejaVu Sans", sans-serif;
    font-weight: 700;
    color: var(--heading);
    letter-spacing: 0.02em;
}
div#content h1 {
    font-size: 24px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--line);
}
a {
    color: var(--link);
}
a:hover {
    color: var(--link-hover);
}

/* ---------- tables ---------- */
div#content table {
    border-collapse: separate;
    border-spacing: 0;
    border: 1px solid var(--card-edge) !important;
    border-radius: 10px;
    overflow: hidden;
}
table {
    border-color: var(--line) !important;
}
table thead th, table thead td, table th {
    background-color: var(--tint) !important;
    background-image: none !important;
    color: var(--heading) !important;
    font-weight: 700;
    border-color: var(--line) !important;
}
table td {
    border-color: var(--line) !important;
}
table.row_table_data tr:hover td {
    background-color: #fdf8ec !important;
}
table.row_table_data tr.hlight td {
    background-color: #fbf3df !important;
}
table.row_table_data tr.marked td {
    background-color: #f8ebcb !important;
}

/* ---------- forms & buttons ---------- */
input.text, select.dropdown, textarea, input.std {
    background: #fff;
    border: 1px solid var(--card-edge);
    border-radius: 6px;
    color: var(--ink);
    padding: 3px 7px;
}
input.text:focus, select.dropdown:focus, textarea:focus, input.std:focus {
    border-color: var(--gold-deep);
    box-shadow: 0 0 0 3px rgba(226, 182, 90, 0.25);
    outline: none;
}
.trav_buttons {
    background: linear-gradient(to bottom, #c8913a, #7d5216) !important;
    border: 1px solid #6a4512 !important;
    border-radius: 8px !important;
    color: #fff8e6 !important;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "DejaVu Sans", sans-serif;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.35) inset, 0 3px 8px rgba(70, 45, 15, 0.25);
    cursor: pointer;
}
.trav_buttons:hover {
    background: linear-gradient(to bottom, #d9a24a, #8d5d1a) !important;
}

/* map popup window */
div#mbig {
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

/* ---------- footer ---------- */
div.footer-stopper {
    display: none;
}
div#footer {
    order: 5;
    position: static !important;
    height: auto !important;
    margin-top: 12px !important;
    padding: 10px 16px 12px;
    background: none !important;
    border-top: 1px solid rgba(226, 182, 90, 0.14);
}
div#footer div#mfoot {
    margin: 0 auto !important;
    width: auto !important;
    max-width: 1100px;
    height: auto !important;
    background-image: none !important;
    text-align: center;
}
div#footer div#mfoot, div#footer div#mfoot a, div#footer div#mfoot div.copyright {
    color: var(--on-dark-soft) !important;
}
div#footer div#mfoot div.copyright,
div#footer div#mfoot div.footer-menu {
    float: none !important;
    position: static !important;
    text-align: center;
}
div#mid > div#footer {
    margin-top: 8px !important;
}
/* copyright and version on one line, no extra height */
div#footer div#mfoot { padding: 0 !important; min-height: 0 !important; }
div#footer div#mfoot div.copyright {
    display: inline-block;
    margin: 0 8px;
    padding: 0 !important;
    height: auto !important;
    line-height: 1.5;
    font-size: 12px;
}
div#footer div#cfoot { display: none; }

/* ============================================================
   Tablets and phones: one column, nav becomes a slide-in drawer.
   ============================================================ */
/* level switch: top-right corner of the village map rectangle (the map sits 27px / 25px inside the card, 540x448) */
@media (min-width: 1101px) {
    div.village2 img#lswitch {
        left: 546px !important;
        top: 30px !important;
    }
}
@media (max-width: 1100px) {
    div#dynamic_header {
        height: 70px !important;
        background-size: auto 70px !important;
    }
    div#header {
        flex-wrap: wrap;
        gap: 6px 10px;
        padding: 8px 10px;
        margin-top: -14px;
    }
    .ht3-burger {
        display: block;
    }
    .ht3-brand {
        font-size: 19px;
        flex: 1;
    }
    div#mtop,
    body.mod1 div#mtop, body.mod2 div#mtop, body.mod3 div#mtop {
        flex: 1 1 100%;
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px 2px;
        order: 3;
    }
    div#mtop > a[id^="n"] {
        width: 62px !important;
    }
    div#mtop > div#n5 {
        width: 70px !important;
    }
    div#mtop > a[id^="n"] img, div#mtop > div#n5 {
        zoom: 0.72;
    }
    div#goldHeader {
        padding: 5px 10px;
        font-size: 12px;
    }
    div#header a#plus {
        padding: 6px 12px;
        margin-left: 0 !important;
    }
    div#ltime {
        display: none !important;
    }

    div#res {
        padding: 12px 8px 0;
    }
    div#res table tr {
        display: grid;
        grid-template-columns: repeat(3, 30px minmax(0, 1fr));
        gap: 8px 0;
    }
    div#res td.ht3-res-val {
        margin-right: 6px;
    }
    div#res td.ht3-res-val {
        min-width: 0;
        font-size: 12px;
        height: 34px;
        padding: 0 10px 0 8px !important;
    }
    div#res td.ht3-res-icon {
        height: 34px;
        padding-left: 8px !important;
    }

    div#mid {
        grid-template-columns: minmax(0, 1fr);
        gap: 14px;
        margin-top: 14px !important;
        padding: 0 8px !important;
    }
    div#mid > div#content, div#mid > div#side_info {
        grid-column: 1;
    }
    div#mid > div#side_info {
        grid-row: 3;
    }
    div#mid > div#footer {
        grid-row: 4;
    }
    div#content {
        width: auto !important;
        padding: 16px 14px !important;
        overflow-x: auto;
    }
    div#content h1 {
        position: static !important;
        font-size: 20px;
    }
    div#content img, div#content input.text, div#content textarea {
        max-width: 100%;
    }
    div.village2 img#lswitch {
        left: auto !important;
        right: 6px !important;
        top: 10px !important;
    }
    div.village1 div#map_details {
        float: none !important;
        width: auto !important;
        margin: 14px 0 0 !important;
        clear: both;
    }
    div#build, div#build > h1, div#build > p, div#build > div#textmenu, div#build > h4 {
        width: auto !important;
        max-width: 100%;
    }
    div#build a.build_logo img {
        position: static !important;
        float: right;
        margin: 0 0 8px 10px;
    }

    /* drawer */
    div#mid > div#side_navi {
        position: fixed !important;
        z-index: 170; /* above the sticky app bar (z-index 150) */
        top: 0;
        bottom: 0;
        left: 0;
        width: min(300px, 84vw) !important;
        padding: 14px !important;
        border-radius: 0 16px 16px 0;
        border-left: 0;
        background: linear-gradient(180deg, #2b2016, #17110b) !important;
        box-shadow: 18px 0 40px rgba(0, 0, 0, 0.5);
        overflow-y: auto;
        transform: translateX(-105%);
        transition: transform 0.25s ease;
        visibility: hidden;
    }
    body.ht3-nav-open div#mid > div#side_navi {
        transform: none;
        visibility: visible;
    }
    .ht3-drawer-close {
        display: block;
    }
    .ht3-scrim {
        position: fixed;
        inset: 0;
        z-index: 160;
        background: rgba(8, 5, 3, 0.55);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.25s ease;
    }
    body.ht3-nav-open .ht3-scrim {
        opacity: 1;
        pointer-events: auto;
    }
    body.ht3-nav-open {
        overflow: hidden;
    }
    /* the open drawer covers the bar too (in case #mid makes its own stacking context in an older stylesheet) */
    body.ht3-nav-open div#header {
        z-index: 60;
    }
    div#side_navi p a, div#side_navi a {
        font-size: 16px;
        padding: 11px 12px 11px 18px;
    }
}

@media (max-width: 400px) {
    div#header {
        gap: 6px 8px;
    }
    .ht3-brand {
        font-size: 16px;
    }
    .ht3-burger {
        width: 38px;
        height: 38px;
        padding: 9px;
    }
    div#goldHeader {
        padding: 4px 8px;
    }
    div#header a#plus {
        padding: 5px 10px;
    }
    div#header a#plus span.plus_text {
        letter-spacing: 0.06em;
    }
}

/* ============================================================
   Ornament & motion layer
   ============================================================ */

/* gold corner brackets on the light cards */
div#content::after, div#side_info::after {
    content: "";
    position: absolute;
    inset: 7px;
    pointer-events: none;
    border-radius: 9px;
    opacity: 0.55;
    background:
        linear-gradient(var(--gold-deep), var(--gold-deep)) left top / 22px 1.5px no-repeat,
        linear-gradient(var(--gold-deep), var(--gold-deep)) left top / 1.5px 22px no-repeat,
        linear-gradient(var(--gold-deep), var(--gold-deep)) right top / 22px 1.5px no-repeat,
        linear-gradient(var(--gold-deep), var(--gold-deep)) right top / 1.5px 22px no-repeat,
        linear-gradient(var(--gold-deep), var(--gold-deep)) left bottom / 22px 1.5px no-repeat,
        linear-gradient(var(--gold-deep), var(--gold-deep)) left bottom / 1.5px 22px no-repeat,
        linear-gradient(var(--gold-deep), var(--gold-deep)) right bottom / 22px 1.5px no-repeat,
        linear-gradient(var(--gold-deep), var(--gold-deep)) right bottom / 1.5px 22px no-repeat;
}

/* ornamental rule under page titles */
div#content h1 {
    border-bottom: 0 !important;
    padding-bottom: 16px !important;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='12' viewBox='0 0 240 12'%3E%3Cdefs%3E%3ClinearGradient id='g' x1='0' x2='1'%3E%3Cstop offset='0' stop-color='%239a6a1f' stop-opacity='0'/%3E%3Cstop offset='.5' stop-color='%23b8862f'/%3E%3Cstop offset='1' stop-color='%239a6a1f' stop-opacity='0'/%3E%3C/linearGradient%3E%3C/defs%3E%3Crect x='0' y='5.5' width='240' height='1' fill='url(%23g)'/%3E%3Cpath d='M120 1l5 5-5 5-5-5z' fill='%23b8862f'/%3E%3Cpath d='M106 6l4-2.5v5zM134 6l-4-2.5v5z' fill='%23b8862f'/%3E%3C/svg%3E") left bottom / 240px 12px no-repeat;
}
div.village2 h1 {
    background: none !important;
    text-shadow: 0 0 6px #fff, 0 0 12px #fff;
}
h1.ht3-text-heading, h5.ht3-text-heading {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "DejaVu Sans", sans-serif;
    color: var(--heading) !important;
    text-transform: none;
}
h5.ht3-text-heading {
    font-size: 16px;
    margin: 4px 0 8px;
}
div#content h1.ht3-text-heading {
    text-align: center;
    background-position: center bottom;
}

/* navigation icons */
div#side_navi a.ht3-has-ico {
    display: flex !important;
    align-items: center;
    gap: 10px;
    padding-left: 12px !important;
}
div#side_navi a.ht3-has-ico::before {
    display: none;
}
.ht3-ico {
    width: 18px;
    height: 18px;
    flex: none;
    fill: none;
    stroke: var(--gold);
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
    opacity: 0.8;
    transition: opacity 0.15s ease, transform 0.15s ease;
}
div#side_navi a:hover .ht3-ico, div#side_navi a.ht3-active .ht3-ico {
    opacity: 1;
    transform: scale(1.08);
}
div#side_navi span.plus_g, div#side_navi span.plus_o,
div#side_navi font[color="#71D000"], div#side_navi font[color="#FF6F0F"] {
    color: var(--gold-hi) !important;
}

/* medallions: always in colour, glowing ring on the current page */
div#mtop > a[id^="n"] img {
    background-position: 0 -121px !important;
    filter: saturate(0.9);
    transition: filter 0.2s ease;
}
div#mtop > a[id^="n"]:hover img {
    filter: saturate(1.15) drop-shadow(0 0 8px rgba(246, 213, 140, 0.55));
}
div#mtop > a[id^="n"], div#mtop > div#n5 {
    position: relative !important;
}
div#mtop > a.ht3-current img, div#mtop > div#n5.ht3-current {
    filter: saturate(1.15) drop-shadow(0 0 3px var(--gold)) drop-shadow(0 0 12px rgba(226, 182, 90, 0.7));
}

/* resource chips: production rate, time-to-full on hover */
div#res td.ht3-res-val[data-rate] {
    padding-right: 12px !important;
    padding-left: 18px !important;
    gap: 10px;
}
/* the rate sits in the flow next to the amount, so a long amount makes the chip wider instead of overlapping it */
div#res td.ht3-res-val[data-rate]::before {
    content: attr(data-rate);
    position: static;
    order: 2;
    align-self: flex-start;
    margin-top: 7px;
    font-size: 11px;
    font-weight: 700;
    color: #4f8a3a;
    letter-spacing: 0.02em;
}
/* time-to-full is shown in a floating tip under the chip (ht3_ui.js), so hovering never changes the chip size */
div.ht3-res-tip {
    position: fixed;
    z-index: 9999;
    transform: translateX(-50%);
    padding: 6px 12px;
    border-radius: 10px;
    background: var(--card);
    border: 1px solid var(--card-edge);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
    color: var(--ink);
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    pointer-events: none;
}
div.ht3-res-tip b { color: #4f8a3a; margin-right: 8px; }
div.ht3-res-tip.ht3-warn { color: var(--danger); }
div#res td.ht3-res-val.ht3-full::before {
    color: var(--danger) !important;
}
div#res td.ht3-res-val, div#res td.ht3-res-icon {
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
div#res tr:hover td.ht3-res-val {
    box-shadow: 0 10px 22px rgba(0, 0, 0, 0.38);
}

/* tables: soft zebra */
div#content table tbody tr:nth-child(even) td {
    background-color: #fdfaf3;
}

/* buttons: sheen sweep */
.trav_buttons {
    position: relative;
    overflow: hidden;
}
.trav_buttons::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: -60%;
    width: 40%;
    background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.45), transparent);
    transform: skewX(-20deg);
    transition: left 0.5s ease;
    pointer-events: none;
}
.trav_buttons:hover::after {
    left: 120%;
}
.ht3-burger:hover, div#header a#plus:hover {
    filter: brightness(1.1);
}

/* page-load rise/fade animations removed: they replay on every navigation and read as a stutter */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation: none !important;
        transition: none !important;
    }
}

@media (max-width: 600px) {
    div#res td.ht3-res-val[data-rate] {
        padding: 0 4px 0 10px !important;
        font-size: 11px;
    }
    div#res td.ht3-res-val[data-rate]::before {
        display: none;
    }
}

@media (max-width: 1100px) {
    div#mid {
        width: 100% !important;
        max-width: 780px;
        box-sizing: border-box;
        margin: 14px auto 0 !important;
    }
    div#res table {
        width: 100%;
        max-width: 764px;
    }
}

/* Shared treasury has no storage cap: hide the fill bar and "full in" hint */
#res td.ht3-res-val.ht3-uncapped::after { display: none; }
#res td.ht3-res-val.ht3-uncapped::before { content: attr(data-rate); }

/* incoming attacks box (Templates/incoming.tpl), hoisted to <body> by ht3_ui.js */
#ht3-incoming {
    position: fixed; right: 16px; bottom: 16px; z-index: 900; width: 330px; max-height: 60vh; overflow: auto;
    background: #f6ecd2; color: #3b2a14; border: 1px solid #b08a4a; border-left: 5px solid #a8321c;
    border-radius: 6px; box-shadow: 0 4px 14px rgba(0,0,0,.28); font-size: 12px; line-height: 1.35;
}
#ht3-incoming .ht3-inc-head { padding: 6px 10px; font-weight: bold; color: #a8321c; border-bottom: 1px solid #d7c394; }
#ht3-incoming .ht3-inc-row { padding: 6px 10px; border-bottom: 1px solid #e6d8b0; }
#ht3-incoming .ht3-inc-row:last-child { border-bottom: 0; }
#ht3-incoming .ht3-inc-kind { display: inline-block; padding: 0 5px; margin-right: 4px; border-radius: 3px; background: #a8321c; color: #fff; font-weight: bold; }
#ht3-incoming a { color: #6b3a0f; text-decoration: underline; }
#ht3-incoming .ht3-inc-from, #ht3-incoming .ht3-inc-eta { display: block; color: #5c4a2c; }
#ht3-incoming .ht3-inc-eta span { font-weight: bold; color: #3b2a14; }

#vlist .ht3-att { color: #fff; background: #a8321c; border-radius: 3px; padding: 0 4px; margin-left: 3px; font-size: 11px; font-weight: bold; white-space: nowrap; }
#ht3-incoming .ht3-inc-units { display: block; font-weight: bold; color: #6b3a0f; }

/* report list pager: compact, fits the content width */
.ht3pager { display:flex; flex-wrap:wrap; gap:3px; align-items:center; margin:6px 0; max-width:100%; box-sizing:border-box; }
.ht3pager .ht3pg { display:inline-block; box-sizing:border-box; min-width:26px; height:26px; padding:0 7px; line-height:24px; text-align:center; font-size:12px; border:1px solid #b8a37a; border-radius:3px; background:#f4ead2; color:#4a3a1a; text-decoration:none; }
.ht3pager a.ht3pg:hover { background:#e6d5a8; }
.ht3pager .ht3pg.cur { background:#8a6a2b; color:#fff; border-color:#8a6a2b; font-weight:bold; }
.ht3pager .ht3pg.off { opacity:.4; }
.ht3pager .ht3pg.gap { border:0; background:none; min-width:0; padding:0 1px; }
.ht3pager .ht3pg-info { margin-left:auto; opacity:.7; font-size:11px; }

/* village centre on tablets/phones: build queue is a normal full-width block below the map, not overlapping it */
@media (max-width: 1100px) {
    div.village2 table#building_contract,
    div.village1 table#building_contract {
        width: 100% !important;
        max-width: 100%;
        margin: 12px 0 0 !important;
        position: static !important;
        box-sizing: border-box;
        table-layout: auto;
    }
    div.village2 table#building_contract th,
    div.village2 table#building_contract td { white-space: normal; }
    div.village2 table#building_contract td { width: auto !important; }
}

/* ---------- home page (index.php) ---------- */
div#content.ht3-home {
    padding-bottom: 24px;
}
div#content.ht3-home h1.ht3-home-title {
    text-align: center;
    margin: 6px 0 10px;
}
.ht3-home-lead {
    max-width: 640px;
    margin: 0 auto 18px;
    text-align: center;
    color: var(--ink-soft);
    line-height: 1.55;
}
.ht3-home-cta {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    margin: 0 0 22px;
}
.ht3-home-cta .trav_buttons {
    display: inline-flex; align-items: center; justify-content: center;
    box-sizing: border-box; width: 200px; height: 46px; padding: 0 20px;
    font-size: 14px; line-height: 1; text-decoration: none !important;
}
.ht3-home-cta .ht3-cta-alt {
    background: var(--card) !important;
    color: var(--heading) !important;
    border: 1px solid var(--card-edge) !important;
    box-shadow: none !important;
}
.ht3-home-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin: 0 0 22px;
}
.ht3-home-stats > div {
    background: var(--tint);
    border: 1px solid var(--card-edge);
    border-radius: 12px;
    padding: 12px 8px;
    text-align: center;
}
.ht3-home-stats b {
    display: block;
    font-size: 24px;
    color: var(--heading);
    line-height: 1.2;
}
.ht3-home-stats span {
    font-size: 12px;
    color: var(--ink-soft);
}
.ht3-home-goal {
    background: linear-gradient(135deg, #f6e7c4, #fbf3de);
    border: 1px solid var(--card-edge);
    border-left: 4px solid var(--gold);
    border-radius: 12px;
    padding: 4px 18px 12px;
    margin: 0 0 26px;
}
.ht3-home-goal h2 {
    margin: 12px 0 6px;
}
.ht3-home-goal p {
    margin: 0;
    line-height: 1.55;
}
div#content.ht3-home h2.ht3-home-h2 {
    margin: 4px 0 4px;
}
.ht3-home-release {
    margin: 0 0 12px;
    color: var(--ink-soft);
}
.ht3-home-release span {
    font-size: 12px;
    margin-left: 8px;
}
.ht3-changes {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
details.ht3-chg {
    background: var(--card);
    border: 1px solid var(--card-edge);
    border-radius: 10px;
    padding: 0 16px;
}
details.ht3-chg > summary {
    cursor: pointer; list-style: none; padding: 11px 0; font-weight: 700; color: var(--heading);
    display: flex; justify-content: space-between; align-items: center;
}
details.ht3-chg > summary::-webkit-details-marker { display: none; }
details.ht3-chg > summary::after { content: "\25BE"; margin-left: 10px; color: var(--gold-deep); transition: transform .15s; }
details.ht3-chg[open] > summary::after { transform: rotate(180deg); }
details.ht3-chg > summary span { margin-left: auto; font-size: 11px; font-weight: 600; color: var(--ink-soft); background: var(--tint); border-radius: 10px; padding: 1px 8px; }
details.ht3-chg[open] > summary { border-bottom: 1px solid var(--line); margin-bottom: 6px; }
details.ht3-chg > ul { margin: 0 0 12px; padding-left: 18px; }
.ht3-chg-card {
    background: var(--card);
    border: 1px solid var(--card-edge);
    border-radius: 12px;
    padding: 4px 16px 12px;
    box-shadow: 0 2px 8px rgba(91, 40, 20, 0.08);
}
.ht3-chg-card h3 {
    margin: 12px 0 6px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--line);
    color: var(--heading);
}
.ht3-chg-card ul {
    margin: 0;
    padding-left: 18px;
}
.ht3-chg-card li {
    margin: 5px 0;
    line-height: 1.45;
}
@media (max-width: 900px) {
    .ht3-home-stats { grid-template-columns: repeat(2, 1fr); }
}

/* raids are orange (attacks stay red) */
#movements .ht3-raid, #movements .ht3-raid * { color: #d9740f !important; }
#ht3-incoming .ht3-inc-kind.ht3-raid { background: #d9740f; color: #fff; }
#vlist .ht3-att.ht3-att-raid { background: #d9740f; }
/* reinforcements are green */
#movements .ht3-reinf, #movements .ht3-reinf * { color: #2e8b3a !important; }
/* own troops on the road: attack red, raid orange, support green, return grey */
#vlist .ht3-att.ht3-own-attack, #ht3-incoming .ht3-inc-kind.ht3-own-attack { background: #2f5d9e; color: #fff; }
#vlist .ht3-att.ht3-raid, #ht3-incoming .ht3-inc-kind.ht3-raid { background: #d9740f; color: #fff; }
#vlist .ht3-att.ht3-own-reinf, #ht3-incoming .ht3-inc-kind.ht3-own-reinf { background: #2e8b3a; color: #fff; }
#vlist .ht3-att.ht3-own-return, #ht3-incoming .ht3-inc-kind.ht3-own-return { background: #7a6a4a; color: #fff; }

/* message read view: a parchment card instead of the narrow 440px strip */
div.messages #read_head, div.messages #read_foot { display: none; }
div.messages #read_content { width: auto; max-width: 720px; box-sizing: border-box; margin: 6px 0 10px; padding: 12px 16px 14px;
    background: var(--tint); border: 1px solid var(--card-edge); border-radius: 10px; box-shadow: 0 1px 3px rgba(60, 40, 10, .15); }
div.messages #read_content img#label { display: none; }
div.messages #read_content div#heading { float: left; padding: 0; max-width: 62%; }
div.messages #read_content div#heading div { width: auto; height: auto; line-height: 1.4; }
div.messages #read_content div#heading div:first-child { font-size: 12px; color: var(--ink-soft); }
div.messages #read_content div#heading div:last-child { font-size: 16px; font-weight: bold; color: var(--heading); }
div.messages #read_content div#time { padding-right: 0; color: var(--ink-soft); }
div.messages #read_content div.line { height: auto; width: auto; clear: both; border-bottom: 1px solid var(--card-edge); margin: 8px 0 10px; }
div.messages #read_content div.message { width: auto; margin: 0; min-height: 140px; padding: 4px 0 12px; font-weight: normal; font-size: 13px; line-height: 1.55; color: var(--ink); overflow-x: auto; }
div.messages #read_content p.btn { margin: 4px 0 0; text-align: left; }

/* previous / next arrows (messages and reports) */
.ht3-msgnav { display: flex; justify-content: space-between; margin: 6px 0; max-width: 720px; box-sizing: border-box; }
.ht3-msgnav-btn { display: inline-block; padding: 3px 12px; border: 1px solid #b89b5e; border-radius: 3px; background: #f1e4bf; color: #6b3a0f; font-weight: bold; text-decoration: none; }
a.ht3-msgnav-btn:hover { background: #e8d49a; }
.ht3-msgnav-btn.off { opacity: .35; }
#ht3-incoming .ht3-arrow { font-weight: bold; }

/* the read card no longer sits on the old 440px background pictures (they drew a stray line at 440px) */
div.messages div#read_content { background-image: none; }
div.messages div#read_content #heading div, div.messages div#read_content .line, div.messages div#read_content div.message { background-image: none; }
div.messages div#read_content .line { border-bottom: 1px solid var(--card-edge); }

/* reports: the same parchment card and full width as the message view */
div.reports table#report_surround { width: 100%; box-sizing: border-box; border-collapse: separate; border-spacing: 0; margin: 6px 0 10px;
    background: var(--tint); border: 1px solid var(--card-edge); border-radius: 10px; box-shadow: 0 1px 3px rgba(60, 40, 10, .15); overflow: hidden; }
div.reports table#report_surround > thead th { color: var(--heading); font-size: 15px; padding: 10px 12px 2px; }
div.reports table#report_surround > thead td { color: var(--ink-soft); padding: 0 12px 8px; }
div.reports table#report_surround > thead td.sent { width: 22%; }
div.reports table#report_surround > thead tr:last-child td { border-bottom: 1px solid var(--card-edge); }
div.reports table#report_surround td.report_content { padding: 12px 12px 4px; }
div.reports table#report_surround td.report_content > table, div.reports table#report_surround td.report_content table { width: 100%; box-sizing: border-box; background: var(--card); }
div.reports table#report_surround td.report_content table thead td { background: var(--tint); }
div.reports table#report_surround td.report_content table tbody.units td { width: auto; }
div.reports table#report_surround td.report_content table tbody.infos th, div.reports table#report_surround td.report_content table tbody.infos td,
div.reports table#report_surround td.report_content table tbody.goods th, div.reports table#report_surround td.report_content table tbody.goods td,
div.reports table#report_surround td.report_content table tbody.res th, div.reports table#report_surround td.report_content table tbody.res td,
div.reports table#report_surround td.report_content table tbody.regards th, div.reports table#report_surround td.report_content table tbody.regards td { background: var(--tint); }
div.reports table#report_surround td.empty { display: none; }
div.reports table#overview { width: 100%; }

.ht3-hero-msg { margin: 8px 0; padding: 8px 12px; border: 1px solid #c0392b; border-left-width: 4px; border-radius: 4px; background: #fbeae6; color: #7b1f13; font-weight: bold; }

/* village list: search box, own scroll area, tidy rows (31+ villages) */
.ht3-vfilter { display: flex; align-items: center; gap: 6px; margin: 0 0 6px; }
.ht3-vfilter input { flex: 1; min-width: 0; box-sizing: border-box; padding: 4px 8px; border: 1px solid var(--card-edge); border-radius: 4px; background: var(--card); color: var(--ink); font-size: 12px; }
.ht3-vfilter input:focus { outline: 0; border-color: var(--gold-deep); box-shadow: 0 0 0 2px rgba(226, 182, 90, .35); }
#ht3-vcount { font-size: 11px; color: var(--ink-soft); white-space: nowrap; }
.ht3-vscroll-on { max-height: 360px; overflow-y: auto; overflow-x: hidden; border: 1px solid var(--line); border-radius: 6px; scrollbar-width: thin; }
.ht3-vscroll-on #vlist { width: 100%; }
#vlist td { padding-top: 2px; padding-bottom: 2px; }
#vlist td.link { max-width: 150px; overflow: hidden; text-overflow: ellipsis; }
#vlist td.link a { white-space: nowrap; }
#vlist td.aligned_coords { white-space: nowrap; font-size: 11px; color: var(--ink-soft); }
#vlist tbody tr:nth-child(even) { background: rgba(247, 239, 220, .55); }
#vlist tbody tr:hover { background: rgba(226, 182, 90, .18); }
#vlist tbody tr.ht3-v-alert { background: #fbeae6; box-shadow: inset 3px 0 0 #a8321c; }
#vlist td.dot.hl { color: var(--gold-deep); }
.ht3-vhead { margin: 0 0 4px; font-weight: bold; }
.ht3-vhead a { color: var(--heading); text-decoration: none; }
.ht3-vhead a:hover { color: var(--link-hover); text-decoration: underline; }

/* troops movements box on small screens: a collapsed pill that opens as a bottom sheet on tap, never over the village list */
#ht3-incoming .ht3-inc-chev, #ht3-incoming .ht3-inc-ico { display: none; }
#ht3-incoming .ht3-inc-warn { color: #fff; background: #a8321c; border-radius: 3px; padding: 0 5px; margin-left: 4px; }
@media (max-width: 1100px) {
    body.ht3-has-inc { padding-bottom: 52px; }
    #ht3-incoming { left: auto; right: 8px; bottom: 8px; width: auto; max-width: calc(100vw - 16px); max-height: none; overflow: hidden; border-radius: 18px; }
    #ht3-incoming .ht3-inc-head { cursor: pointer; border-bottom: 0; padding: 8px 14px; white-space: nowrap; user-select: none; }
    #ht3-incoming .ht3-inc-ico, #ht3-incoming .ht3-inc-chev { display: inline; }
    #ht3-incoming .ht3-inc-chev { margin-left: 8px; font-size: 10px; color: #6b3a0f; }
    #ht3-incoming .ht3-inc-row { display: none; }
    #ht3-incoming.ht3-open { left: 8px; right: 8px; bottom: 8px; width: auto; max-width: none; max-height: 70vh; overflow-y: auto; border-radius: 10px; box-shadow: 0 -6px 24px rgba(0,0,0,.35); }
    #ht3-incoming.ht3-open .ht3-inc-head { position: sticky; top: 0; background: #f6ecd2; border-bottom: 1px solid #d7c394; }
    #ht3-incoming.ht3-open .ht3-inc-row { display: block; padding: 10px 14px; }
    #ht3-incoming.ht3-open .ht3-inc-chev { transform: rotate(180deg); }
}

/* mobile: the fixed-pixel village boards (fields, town centre) are centred in the card; ht3_ui.js only scales them down */
@media (max-width: 1100px) {
    div.village1, div.village2 { padding-left: 14px !important; padding-right: 14px !important; }
    div.village1 div#village_map, div.village2 div#village_map { float: none !important; margin: 4px auto 14px !important; }
    div.village1 div#village_map { width: 300px; }
    div.village2 div#village_map { width: 540px; }
    div.village1 div#cap { text-align: center; }
    div.village1 div#map_details, div.village1 div#map_details > table, div.village1 div#map_details table#production,
    div.village1 div#map_details table#movements, div.village1 div#map_details table#troops { width: 100% !important; max-width: 520px; margin-left: auto; margin-right: auto; box-sizing: border-box; }
    div.village1 div#map_details { text-align: center; }
    div.village1 div#map_details table td { text-align: left; }
    div.village2 div#village_map ~ * { margin-left: auto; margin-right: auto; }
}

/* minimise on desktop too */
#ht3-incoming .ht3-inc-head { cursor: pointer; user-select: none; }
#ht3-incoming .ht3-inc-ico, #ht3-incoming .ht3-inc-chev { display: inline; }
#ht3-incoming .ht3-inc-chev { float: right; margin-left: 10px; font-size: 10px; color: #6b3a0f; transform: rotate(180deg); }
@media (min-width: 1101px) {
    #ht3-incoming.ht3-min { width: auto; max-height: none; overflow: hidden; border-radius: 18px; }
    #ht3-incoming.ht3-min .ht3-inc-head { border-bottom: 0; padding: 7px 14px; white-space: nowrap; }
    #ht3-incoming.ht3-min .ht3-inc-row { display: none; }
    #ht3-incoming.ht3-min .ht3-inc-chev { transform: none; }
}
@media (max-width: 1100px) {
    #ht3-incoming .ht3-inc-chev { float: none; transform: none; }
    #ht3-incoming.ht3-open .ht3-inc-chev { transform: rotate(180deg); }
}

/* one width for the box, open or minimised, on every screen: it only grows / shrinks in height */
#ht3-incoming, #ht3-incoming.ht3-min, #ht3-incoming.ht3-open {
    left: auto !important; right: 8px; bottom: 8px; width: min(330px, calc(100vw - 16px)) !important; max-width: none !important;
    box-sizing: border-box; border-radius: 8px;
}
#ht3-incoming.ht3-open, #ht3-incoming:not(.ht3-min) { max-height: 60vh; overflow-y: auto; }
#ht3-incoming .ht3-inc-head { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
#ht3-incoming .ht3-inc-chev { margin-left: auto; float: none; }
@media (min-width: 1101px) { #ht3-incoming, #ht3-incoming.ht3-min { right: 16px; bottom: 16px; } }

/* troops movements box: bigger type and airier rows, easier to read */
#ht3-incoming, #ht3-incoming.ht3-min, #ht3-incoming.ht3-open { width: min(390px, calc(100vw - 16px)) !important; font-size: 14px; line-height: 1.45; }
#ht3-incoming .ht3-inc-head { font-size: 15px; padding: 9px 12px; }
#ht3-incoming .ht3-inc-row { padding: 9px 12px 10px; }
#ht3-incoming .ht3-inc-kind { font-size: 13px; padding: 1px 8px; border-radius: 4px; margin-right: 6px; }
#ht3-incoming .ht3-inc-row > a { font-weight: bold; font-size: 14px; }
#ht3-incoming .ht3-inc-from, #ht3-incoming .ht3-inc-eta { margin-top: 3px; font-size: 13px; }
#ht3-incoming .ht3-inc-eta span { font-size: 14px; }
#ht3-incoming .ht3-inc-units { font-size: 13px; margin-top: 3px; }
#vlist .ht3-att { font-size: 12px; padding: 1px 5px; }

/* movements box: one line per movement, a bigger arrow that renders in a symbol font */
#ht3-incoming, #ht3-incoming.ht3-min, #ht3-incoming.ht3-open { width: min(470px, calc(100vw - 16px)) !important; }
#ht3-incoming .ht3-inc-row { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; white-space: nowrap; padding: 7px 12px; }
#ht3-incoming .ht3-inc-kind { flex: none; display: inline-flex; align-items: center; gap: 4px; margin: 0; font-size: 13px; padding: 1px 8px 1px 6px; }
#ht3-incoming .ht3-arrow { font-family: "Segoe UI Symbol", "DejaVu Sans", "Noto Sans Symbols", "Arial Unicode MS", sans-serif; font-size: 18px; line-height: 1; font-weight: bold; }
#ht3-incoming .ht3-inc-row > a { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
#ht3-incoming .ht3-inc-from { display: inline !important; flex: 1 1 0; min-width: 0; margin: 0 !important; overflow: hidden; text-overflow: ellipsis; color: #5c4a2c; font-size: 13px; }
#ht3-incoming .ht3-inc-eta { display: inline !important; flex: none; margin: 0 0 0 auto !important; font-size: 14px; }
#ht3-incoming .ht3-inc-units { flex: 1 0 100%; white-space: normal; }
#vlist .ht3-att { font-size: 13px; line-height: 1.2; font-family: "Segoe UI Symbol", "DejaVu Sans", sans-serif; }
#ht3-incoming .ht3-inc-from a { display: inline; font-weight: bold; }
#movements .ht3-mv-who { color: #6b5b45; font-size: 11px; }
#movements div.mov a { font-weight: bold; }

/* village view, movements in the narrow right column: stack the lines and let long names wrap instead of stretching the page */
div.village1 table#movements { width: 100%; table-layout: fixed; }
div.village1 table#movements td.typ { width: 30px; }
div.village1 table#movements div.mov { float: none; display: block; font-size: 12px; line-height: 1.3; overflow-wrap: anywhere; word-break: break-word; }
div.village1 table#movements div.dur_r { float: none; display: block; padding: 0; font-size: 11px; color: var(--ink-soft); }
div.village1 table#movements td { padding: 3px 0; vertical-align: top; }
div.village1 table#movements .ht3-mv-who { display: block; }
div.village1 table#movements tbody tr { border-bottom: 1px solid var(--line); }
div.village1 div#map_details { width: 229px; max-width: 100%; box-sizing: border-box; overflow: hidden; }

/* mobile village view: the movement / production / troop tables are compact, not stretched over the whole screen */
@media (max-width: 1100px) {
    div.village1 div#map_details { width: auto !important; max-width: 340px !important; margin: 10px auto 0 !important; float: none !important; }
    div.village1 div#map_details table, div.village1 div#map_details table#production, div.village1 div#map_details table#movements,
    div.village1 div#map_details table#troops { width: 100% !important; max-width: 340px !important; margin-left: auto; margin-right: auto; font-size: 13px; }
    div.village1 table#production td.res { width: 22%; }
    div.village1 table#production td.per { width: auto; }
    div.village1 div#map_details table td, div.village1 div#map_details table th { padding: 3px 6px; }
    div.village1 div#map_details table#movements td { padding: 4px 6px; }
}

/* mobile: the build queue is a compact centred table as well (fields view and town centre) */
@media (max-width: 1100px) {
    div.village1 table#building_contract, div.village2 table#building_contract { width: 100% !important; max-width: 340px !important; margin: 12px auto 0 !important; font-size: 13px; }
    div.village1 table#building_contract td, div.village1 table#building_contract th,
    div.village2 table#building_contract td, div.village2 table#building_contract th { padding: 4px 6px; }
    div.village2 table#building_contract td.ico { width: 28px !important; }
}

/* mobile village view: one line per movement, like the floating Troops movements box */
@media (max-width: 1100px) {
    div.village1 table#movements, div.village1 table#movements tbody { display: block; width: 100% !important; }
    div.village1 table#movements tr { display: flex; align-items: center; gap: 6px; padding: 4px 6px; white-space: nowrap; }
    div.village1 table#movements td { padding: 0 !important; display: block; }
    div.village1 table#movements td.typ { flex: none; width: auto; }
    div.village1 table#movements td:not(.typ) { display: flex; flex: 1 1 0; min-width: 0; align-items: center; gap: 8px; }
    div.village1 table#movements div.mov { flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
    div.village1 table#movements div.mov a { display: inline; }
    div.village1 table#movements .ht3-mv-who { display: inline; margin-left: 4px; }
    div.village1 table#movements div.dur_r { flex: none; margin-left: auto; font-size: 13px; color: inherit; }
}

/* desktop village view: one line per movement too (the narrow column): the kind is already told by the icon and the colour */
@media (min-width: 1101px) {
    div.village1 table#movements, div.village1 table#movements tbody { display: block; width: 100% !important; }
    div.village1 table#movements tr { display: flex; align-items: center; gap: 4px; padding: 3px 0; white-space: nowrap; }
    div.village1 table#movements td { padding: 0 !important; display: block; }
    div.village1 table#movements td.typ { flex: none; width: auto; }
    div.village1 table#movements td:not(.typ) { display: flex; flex: 1 1 0; min-width: 0; align-items: center; gap: 6px; }
    div.village1 table#movements div.mov { flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
    div.village1 table#movements div.mov .ht3-mv-kind { display: none; }
    div.village1 table#movements div.mov a { display: inline; }
    div.village1 table#movements .ht3-mv-who { display: inline; margin-left: 4px; }
    div.village1 table#movements div.dur_r { flex: none; margin-left: auto; font-size: 12px; }
}

/* top bar medallions: smaller, softer edges, bigger click area */
div#mtop > a[id^="n"], div#mtop > div#n5 { padding: 3px 0; border-radius: 10px; }
div#mtop > a[id^="n"] { width: 58px !important; }
div#mtop > div#n5 { width: 70px !important; height: 67px !important; margin: 0 2px !important; padding: 0; } /* the sprite is 70px wide, split in two 35px links: keep its real size, only zoom it */
div#mtop > a[id^="n"] img, div#mtop > div#n5 { zoom: 0.62; }
div#mtop > a[id^="n"] img { filter: saturate(0.95) drop-shadow(0 1px 2px rgba(0,0,0,.45)); }
div#mtop > a[id^="n"]:hover, div#mtop > div#n5:hover { background-color: rgba(246, 213, 140, 0.12); } /* colour only: the reports/messages sprite is the div's own background-image */
@media (max-width: 1100px) {
    div#mtop > a[id^="n"] { width: 50px !important; }
    div#mtop > div#n5 { width: 70px !important; height: 67px !important; }
    div#mtop > a[id^="n"] img, div#mtop > div#n5 { zoom: 0.54; }
}

/* top bar: the medallions sit in the middle of the bar, not against the right edge */
div#mtop, body.mod1 div#mtop, body.mod2 div#mtop, body.mod3 div#mtop { justify-content: center; }

/* coin bubble: a link to the deputy shop */
div#goldHeader { padding: 0 !important; overflow: hidden; display: flex; align-items: stretch; }
div#goldHeader a.ht3-coins { display: flex; align-items: center; gap: 6px; padding: 6px 12px; color: var(--gold-hi) !important; text-decoration: none; font-size: 13px; font-weight: normal; }
div#goldHeader a.ht3-coins:hover { background: rgba(246, 213, 140, 0.16); }
div#goldHeader a.ht3-coins img { width: 18px; height: 18px; margin: 0; }
div#goldHeader a.ht3-coins b { font-size: 15px; }
div#goldHeader .ht3-coins-dep { margin-left: 4px; padding: 1px 8px; border-radius: 999px; font-size: 11px; background: rgba(255,255,255,.1); }
div#goldHeader .ht3-coins-dep.on { background: #3f7a2a; color: #fff; }
div#goldHeader .ht3-coins-dep.off { background: #8a3a1e; color: #fff; }
div#goldHeader .ht3-coins-dep.none { border: 1px dashed var(--gold); }
/* the hero's silver sits INSIDE the coin bubble, to the right of the coins, separated by a thin line (it used to be a second bubble nested in the first) */
div#goldHeader div#silverHeader { display: flex; align-items: center; gap: 5px; margin: 0 !important; padding: 6px 12px; border: 0; border-left: 1px solid var(--glass-edge); border-radius: 0; background: none; color: var(--gold-hi) !important; font-size: 13px; font-weight: normal; line-height: 1.2; white-space: nowrap; }
div#goldHeader div#silverHeader img { width: 16px; height: 16px; margin: 0; }
@media (max-width: 600px) { div#goldHeader .ht3-coins-l, div#goldHeader .ht3-coins-dep, div#goldHeader .ht3-silver-l { display: none; } div#goldHeader div#silverHeader { padding: 5px 8px; } div#goldHeader a.ht3-coins { padding: 5px 10px; } }

/* dorf1 and dorf2 share one layout: the board in the same slot, then movements, production, troops and the build queue in the same order */
div.village1 div#village_map { float: none !important; margin: 92px auto 92px !important; }
div.village1.ht3-details { padding: 0 !important; width: auto !important; position: static; }
div.village1 div#map_details, div.village1.ht3-details div#map_details { float: none !important; width: auto !important; max-width: none !important; margin: 0 !important; }
@media (min-width: 1101px) {
    div.village1 div#map_details { width: 540px !important; margin: 0 auto !important; }
    div.village1 div#map_details > table, div.village1 div#map_details table#production, div.village1 div#map_details table#movements,
    div.village1 div#map_details table#troops, div.village1 table#building_contract, div.village2 table#building_contract {
        width: 100% !important; max-width: 540px; margin: 0 auto 14px !important; position: static !important; clear: both; box-sizing: border-box;
    }
    div.village1 table#movements div.mov .ht3-mv-kind { display: inline !important; }
    div#content.village1 { width: 540px; padding-left: 6px; padding-right: 6px; }
}
@media (max-width: 1100px) {
    div.village1 div#village_map, div.village2 div#village_map { margin: 4px auto 14px !important; }
}

/* desktop: the fields board is scaled up to fill the same 540x448 slot as the town centre, and the title sits in the same place,
   so switching between dorf1 and dorf2 does not make anything jump */
@media (min-width: 1101px) {
    div.village1 div#village_map { zoom: 1.45; margin: 22px auto !important; } /* 264*1.45 + 2*22*1.45 = 447: the same 448px slot as the town centre board */
    div.village1 > h1 { position: absolute !important; left: 25px !important; top: auto; height: auto; z-index: 30; }
    div.village1 > div#cap { position: absolute; left: 25px; top: 72px; z-index: 30; height: 0; }
    div#content.village1 { padding-top: 43px; position: relative; }
}

/* the village title on dorf1 is styled exactly like on dorf2: no ornamental rule under it */
div.village1 h1 { background: none !important; text-shadow: 0 0 6px #fff, 0 0 12px #fff; padding-bottom: 0 !important; }

/* the loyalty line sits in the same spot and has the same look on dorf1 and dorf2 */
div#content.village1 h1, div#content.village2 h1 { height: auto !important; line-height: normal; }
div.village1 h1 div#loyality, div.village2 h1 div#loyality {
    position: static !important; top: auto !important; float: none !important; display: block;
    margin: 0 !important; padding: 0 !important; font-size: xx-small !important; font-weight: normal !important; line-height: normal;
}
div.village1 h1 div#loyality.re { color: red !important; }
div.village1 h1 div#loyality.gr { color: green !important; }

/* movements table is laid out with flex rows: its header row must be a full-width block too, or it shrinks and the box looks broken */
div.village1 table#movements { display: block; width: 100% !important; table-layout: auto; border-collapse: separate; }
div.village1 table#movements thead, div.village1 table#movements thead tr, div.village1 table#movements thead th { display: block; width: 100% !important; box-sizing: border-box; text-align: left; }
div.village1 table#movements tbody { display: block; width: 100%; }
div.village1 table#movements tr { box-sizing: border-box; width: 100%; }
div.village1 table#movements td.typ { min-width: 34px; }

/* reports of a village that was captured or lost */
table#overview tr.ht3-capture td { font-weight: bold; }
table#overview tr.ht3-capture.ht3-won td { background: #e4f1cf !important; }
table#overview tr.ht3-capture.ht3-lost td { background: #f6d9d2 !important; }
table#overview tr.ht3-capture td.sel { border-left: 5px solid #4c8a24; }
table#overview tr.ht3-capture.ht3-lost td.sel { border-left-color: #b8321b; }
.ht3-cap-badge { display: inline-block; padding: 1px 8px; margin-right: 6px; border-radius: 999px; font-size: 11px; font-weight: bold; color: #fff; white-space: nowrap; }
.ht3-cap-badge.won { background: #4c8a24; }
.ht3-cap-badge.lost { background: #b8321b; }

/* captured / lost village: just a coloured flag, the text shows on hover */
.ht3-cap-flag { display: inline-block; margin-right: 6px; font-size: 20px; line-height: 1; vertical-align: middle; cursor: help; font-family: "Segoe UI Symbol", "DejaVu Sans", "Noto Sans Symbols", sans-serif; }
.ht3-cap-flag.won { color: #3f8a1c; }
.ht3-cap-flag.lost { color: #c0341a; }

/* village list: the name takes what is left and is cut with an ellipsis, the movement badges stay together on the right and never wrap the row */
#vlist td.link { max-width: none; width: 100%; padding-right: 2px; }
#vlist .ht3-vl { display: flex; align-items: center; gap: 6px; min-width: 0; }
#vlist .ht3-vname { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#vlist .ht3-vb { flex: none; display: inline-flex; gap: 3px; align-items: center; }
#vlist .ht3-vb .ht3-att { margin: 0; padding: 0 5px; line-height: 17px; min-width: 28px; text-align: center; }
#vlist td.aligned_coords { width: 1%; padding-left: 4px; }

/* the side column is only ~240px wide: the name needs the whole first line, so the movement badges go on their own second line (only for villages that have movements) */
#vlist .ht3-vl { flex-wrap: wrap; gap: 2px 6px; }
#vlist .ht3-vname { flex: 1 1 100%; }
#vlist .ht3-vb { flex: 1 1 100%; justify-content: flex-start; flex-wrap: wrap; gap: 4px; padding-bottom: 2px; }
#vlist .ht3-vb:not(:has(.ht3-att)) { display: none; }
#vlist td.aligned_coords { width: 1%; }
#vlist td.aligned_coords div { float: none; display: inline; width: auto; padding: 0; }
#vlist td.aligned_coords div.cox { text-align: right; }

/* one link colour everywhere: the old stylesheet turned visited links bright green (#71D000) */
a:visited { color: var(--link); }
a:active { color: var(--link-hover); }
a:visited:hover { color: var(--link-hover); }

/* desktop: a smaller gap between the resource strip and the cards below it */
@media (min-width: 1101px) {
    div#mid { row-gap: 4px; margin-top: 12px !important; }
    div#res, body.mod1 div#res, body.mod2 div#res, body.mod3 div#res { padding-top: 10px; padding-bottom: 0; margin-bottom: 0; }
}

/* mobile: the four resources in ONE line */
@media (max-width: 1100px) {
    div#res table tr { grid-template-columns: repeat(4, 22px minmax(0, 1fr)); gap: 0; }
    div#res td.ht3-res-icon { height: 30px; padding-left: 4px !important; margin-right: -6px; }
    div#res td.ht3-res-val { height: 30px; font-size: 11px; padding: 0 4px 0 8px !important; margin-right: 3px; min-width: 0; overflow: hidden; text-overflow: ellipsis; box-shadow: 0 3px 8px rgba(0,0,0,.25); }
    div#res td.ht3-res-icon img { max-width: 16px; height: auto; }
}
/* mobile: the movements box is a bar until it is tapped open (the desktop row rule had kept the rows always visible) */
@media (max-width: 1100px) {
    #ht3-incoming:not(.ht3-open) .ht3-inc-row { display: none !important; }
    #ht3-incoming:not(.ht3-open) { max-height: none; overflow: hidden; }
    #ht3-incoming.ht3-open .ht3-inc-row { display: flex; }
}

/* the fields board is enlarged by the browser: sharpen it a little so the resource fields stay crisp */
@media (min-width: 1101px) {
    div.village1 div#village_map { filter: url(#ht3-sharpen) contrast(1.04); image-rendering: -webkit-optimize-contrast; }
}

/* resource field level badges as text: sharp at any board scale */
div.village1 div#village_map span.ht3-lvl { position: absolute; z-index: 12; box-sizing: border-box; border-radius: 6px; border: 1px solid #fff; color: #fff; text-align: center; font: bold 10px/1 Arial, sans-serif; text-shadow: 0 1px 1px rgba(0,0,0,.5); box-shadow: 0 1px 2px rgba(0,0,0,.45); pointer-events: none; }
div.village1 div#village_map span.ht3-lvl.l1 { background: #5f9b2e; }
div.village1 div#village_map span.ht3-lvl.l2 { background: #d49a2a; }
div.village1 div#village_map span.ht3-lvl.l3 { background: #b8321b; }
div.village1 div#village_map span.ht3-lvl.act { background: #2f5d9e; }

/* level badges: the same size, font and colours on the fields (dorf1, board x1.45) and in the town centre (dorf2, board x1) */
div.village2 div#village_map div#levels div.ht3-lv {
    background: #5f9b2e !important; width: 25px; height: 18px; line-height: 16px; margin: -1px 0 0 -4px; box-sizing: border-box;
    border: 1px solid #fff; border-radius: 6px; color: #fff; font: bold 14.5px/16px Arial, Helvetica, sans-serif;
    text-shadow: 0 1px 1px rgba(0,0,0,.5); box-shadow: 0 1px 2px rgba(0,0,0,.45);
}
div.village2 div#village_map div#levels div.ht3-lv.l2 { background: #d49a2a !important; }
div.village2 div#village_map div#levels div.ht3-lv.l3 { background: #b8321b !important; }

/* level badges: sandy background like the field art, the number in green inside a green frame (dorf1 and dorf2) */
div.village1 div#village_map span.ht3-lvl, div.village2 div#village_map div#levels div.ht3-lv {
    background: #ead9a6 !important; color: #2f6b13 !important; border: 2px solid #3f7d1f !important;
    text-shadow: none !important; box-shadow: 0 1px 2px rgba(60, 40, 10, .45), inset 0 0 0 1px rgba(255, 255, 255, .5);
}
div.village1 div#village_map span.ht3-lvl.l2, div.village2 div#village_map div#levels div.ht3-lv.l2 { color: #9a5b0d !important; border-color: #b9770f !important; }
div.village1 div#village_map span.ht3-lvl.l3, div.village2 div#village_map div#levels div.ht3-lv.l3 { color: #a52a14 !important; border-color: #a52a14 !important; }
div.village1 div#village_map span.ht3-lvl.act { color: #1f4a8a !important; border-color: #2f5d9e !important; background: #dbe6f3 !important; }

/* level badges, final: a plain sandy circle without any frame; only the digit has an outline */
div.village1 div#village_map span.ht3-lvl, div.village2 div#village_map div#levels div.ht3-lv {
    border: 0 !important; border-radius: 50% !important; background: #ead9a6 !important;
    box-shadow: 0 1px 2px rgba(60, 40, 10, .4) !important;
    color: #3d9a1f !important;
    text-shadow: -1px 0 #14420a, 1px 0 #14420a, 0 -1px #14420a, 0 1px #14420a, -1px -1px #14420a, 1px 1px #14420a, -1px 1px #14420a, 1px -1px #14420a !important;
    font-weight: bold; text-align: center;
}
div.village1 div#village_map span.ht3-lvl { width: 16px !important; height: 16px !important; line-height: 16px !important; margin: -2px 0 0 1px; font-size: 10px; }
div.village2 div#village_map div#levels div.ht3-lv { width: 23px !important; height: 23px !important; line-height: 23px !important; margin: -3px 0 0 -3px; font-size: 14.5px; }
div.village1 div#village_map span.ht3-lvl.l2, div.village2 div#village_map div#levels div.ht3-lv.l2 { color: #e0a02a !important; text-shadow: -1px 0 #5a3a05, 1px 0 #5a3a05, 0 -1px #5a3a05, 0 1px #5a3a05, -1px -1px #5a3a05, 1px 1px #5a3a05, -1px 1px #5a3a05, 1px -1px #5a3a05 !important; }
div.village1 div#village_map span.ht3-lvl.l3, div.village2 div#village_map div#levels div.ht3-lv.l3 { color: #e0432a !important; text-shadow: -1px 0 #4a0f05, 1px 0 #4a0f05, 0 -1px #4a0f05, 0 1px #4a0f05, -1px -1px #4a0f05, 1px 1px #4a0f05, -1px 1px #4a0f05, 1px -1px #4a0f05 !important; }
div.village1 div#village_map span.ht3-lvl.act { color: #5a9be0 !important; background: #ead9a6 !important; text-shadow: -1px 0 #12335f, 1px 0 #12335f, 0 -1px #12335f, 0 1px #12335f, -1px -1px #12335f, 1px 1px #12335f, -1px 1px #12335f, 1px -1px #12335f !important; }

/* level badges, matched to the field art (its sand is about #fcf8c1): lighter sand circle, brown digit with a black outline */
div.village1 div#village_map span.ht3-lvl, div.village2 div#village_map div#levels div.ht3-lv,
div.village1 div#village_map span.ht3-lvl.l2, div.village2 div#village_map div#levels div.ht3-lv.l2,
div.village1 div#village_map span.ht3-lvl.l3, div.village2 div#village_map div#levels div.ht3-lv.l3,
div.village1 div#village_map span.ht3-lvl.act {
    background: #f8eebb !important;
    color: #8a4f12 !important;
    text-shadow: -1px 0 #000, 1px 0 #000, 0 -1px #000, 0 1px #000, -1px -1px #000, 1px 1px #000, -1px 1px #000, 1px -1px #000 !important;
    box-shadow: 0 1px 2px rgba(60, 40, 10, .35) !important;
}

/* dorf1: the board art (img/g/f*.jpg) already has a sand circle under every level number, so the badge adds no circle of its own:
   it is transparent, centred on that painted circle, and only the number is drawn (brown with a black outline) */
div.village1 div#village_map span.ht3-lvl {
    background: transparent !important; box-shadow: none !important;
    width: 26px !important; height: 26px !important; line-height: 26px !important;
    margin: -10px 0 0 -4px !important; font-size: 14px !important;
}

/* level numbers, final: plain dark brown digits, no outline - crisp on the sand */
div.village1 div#village_map span.ht3-lvl, div.village2 div#village_map div#levels div.ht3-lv,
div.village1 div#village_map span.ht3-lvl.l2, div.village2 div#village_map div#levels div.ht3-lv.l2,
div.village1 div#village_map span.ht3-lvl.l3, div.village2 div#village_map div#levels div.ht3-lv.l3,
div.village1 div#village_map span.ht3-lvl.act {
    color: #3a1f06 !important; text-shadow: none !important; -webkit-text-stroke: 0 !important;
    font-family: Arial, Helvetica, sans-serif; font-weight: bold; -webkit-font-smoothing: antialiased;
}
div.village1 div#village_map span.ht3-lvl { font-size: 15px !important; }

/* the same digit size on screen: dorf2 is 14.5px, dorf1 is zoomed 1.45 so 10px there */
div.village1 div#village_map span.ht3-lvl { font-size: 10px !important; }

/* dorf1: no badge background in any variant (level 11+ and "upgrade in progress" had kept the sand circle on top of the painted one) */
div.village1 div#village_map span.ht3-lvl, div.village1 div#village_map span.ht3-lvl.l1, div.village1 div#village_map span.ht3-lvl.l2,
div.village1 div#village_map span.ht3-lvl.l3, div.village1 div#village_map span.ht3-lvl.act {
    background: transparent !important; background-color: transparent !important; box-shadow: none !important; border: 0 !important;
}

/* dorf1: the sand circle behind the number is back (it looked good); a field that is being upgraded gets an amber circle instead */
div.village1 div#village_map span.ht3-lvl, div.village1 div#village_map span.ht3-lvl.l1, div.village1 div#village_map span.ht3-lvl.l2,
div.village1 div#village_map span.ht3-lvl.l3 {
    background: #f8eebb !important; background-color: #f8eebb !important; box-shadow: 0 1px 2px rgba(60, 40, 10, .35) !important;
}
div.village1 div#village_map span.ht3-lvl.act {
    background: #ffb739 !important; background-color: #ffb739 !important; box-shadow: 0 0 0 2px #fff, 0 0 6px 2px rgba(255, 150, 0, .75) !important; color: #2b1503 !important;
}

/* dorf2 badges aligned with dorf1: same sand, same thin dark-sand rim as the circles painted in the field art, same size on screen (~37px) */
div.village2 div#village_map div#levels div.ht3-lv {
    width: 36px !important; height: 36px !important; line-height: 34px !important; margin: -9px 0 0 -9px !important;
    border: 1px solid #7b6a43 !important; border-radius: 50% !important; background: #f8eebb !important;
    box-shadow: 0 1px 2px rgba(60, 40, 10, .35) !important; font-size: 14.5px !important; box-sizing: border-box;
}
div.village1 div#village_map span.ht3-lvl { border: 1px solid #7b6a43 !important; box-sizing: border-box; width: 25px !important; height: 25px !important; line-height: 23px !important; }
div.village1 div#village_map span.ht3-lvl.act { border-color: #fff !important; }

/* dorf2: a building under construction has the same amber badge as a field being upgraded on dorf1 */
div.village2 div#village_map div#levels div.ht3-lv.act {
    background: #ffb739 !important; border-color: #fff !important; color: #2b1503 !important;
    box-shadow: 0 0 0 2px #fff, 0 0 6px 2px rgba(255, 150, 0, .75) !important;
}

/* server clock in the app bar, beside the coin bubble */
div#ht3Clock { display: flex; align-items: center; gap: 5px; padding: 6px 12px; border: 1px solid var(--glass-edge); border-radius: 999px; background: var(--glass);
    color: var(--gold-hi); font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; position: static !important; }
div#ht3Clock .ht3-clock-ico { font-size: 15px; line-height: 1; }
div#ht3Clock .ht3-clock-val { font-weight: bold; }
@media (max-width: 600px) { div#ht3Clock { padding: 5px 8px; font-size: 12px; } div#ht3Clock .ht3-clock-ico { display: none; } }

div#ht3Clock .ht3-clock-ms { margin-left: 4px; padding-left: 8px; border-left: 1px solid var(--glass-edge); font-size: 11px; opacity: .75; }
/* the old bottom-left block (generation time and server time) moved to the bar: it was covered by the movements box anyway */
div#mid > div#stime, div#stime { display: none !important; }
@media (max-width: 600px) { div#ht3Clock .ht3-clock-ms { display: none; } }

/* mobile: medallions are bigger and share the whole width of the row evenly */
@media (max-width: 1100px) {
    div#mtop, body.mod1 div#mtop, body.mod2 div#mtop, body.mod3 div#mtop { flex-wrap: nowrap; justify-content: space-between; gap: 0; width: 100% !important; }
    div#mtop > a[id^="n"], div#mtop > div#n5 { flex: 1 1 0; min-width: 0; width: auto !important; align-items: center; justify-content: center; }
    div#mtop > a[id^="n"] img, div#mtop > div#n5 { zoom: 0.9; }
    div#mtop > div#n5 { flex: 1 1 0; width: 70px !important; max-width: 70px; margin: 0 auto !important; }
    div#mtop > a[id^="n"] { text-align: center; }
}

/* resource strip: the fill bar sits UNDER each resource chip instead of inside it */
div#res td.ht3-res-val { overflow: visible; }
div#res td.ht3-res-val::after { left: 2px; right: 6px; bottom: -9px; height: 5px; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); }
div#res table { margin-bottom: 12px; }
/* phones: only the current amount, the storage size is hidden */
@media (max-width: 1100px) {
    div#res td.ht3-res-val .ht3-cap { display: none; }
    div#res td.ht3-res-val::after { bottom: -7px; height: 4px; left: 2px; right: 4px; }
    div#res table { margin-bottom: 10px; }
}

/* resource strip, corrected: the fill bar is INSIDE the chip, directly under the number (not below the chip) */
div#res td.ht3-res-val { overflow: hidden; padding-bottom: 9px !important; align-items: center; }
div#res td.ht3-res-val::after { left: 10px; right: 12px; bottom: 6px; height: 4px; box-shadow: none; }
div#res table { margin-bottom: 0; }
@media (max-width: 1100px) {
    div#res td.ht3-res-val { padding-bottom: 8px !important; }
    div#res td.ht3-res-val::after { left: 6px; right: 6px; bottom: 5px; height: 3px; }
    div#res table { margin-bottom: 0; }
}

/* desktop resource strip: taller chips so the number and the bar under it both have room */
@media (min-width: 1101px) {
    div#res td.ht3-res-icon, div#res td.ht3-res-val { height: 48px; }
    /* the number sits 9px from the top, the bar 9px from the bottom: no bottom padding needed to keep them apart */
    div#res td.ht3-res-val { padding: 9px 12px 0 10px !important; align-items: flex-start; font-size: 15px; line-height: 1.1; }
    div#res td.ht3-res-val::after { left: 10px; right: 14px; bottom: 9px; height: 5px; border-radius: 5px; }
}

/* desktop: the bar follows the number directly (a flex column, no absolute offsets), centred in the chip */
@media (min-width: 1101px) {
    div#res td.ht3-res-icon, div#res td.ht3-res-val { height: 42px; }
    div#res td.ht3-res-val { flex-direction: column; align-items: stretch; justify-content: center; padding: 0 12px 0 10px !important; gap: 4px; }
    div#res td.ht3-res-val::after { position: static; display: block; flex: none; width: 100%; height: 5px; margin: 0; }
}

/* resource strip, simple and robust: the number is centred in the upper part of the chip, the bar sits just below it (absolute), */
/* and the storage size is never shown in the chip (the full "amount/size" stays in the tooltip data) */
div#res td.ht3-res-val .ht3-cap { display: none !important; }
@media (min-width: 1101px) {
    div#res td.ht3-res-icon, div#res td.ht3-res-val { height: 44px; }
    div#res td.ht3-res-val { flex-direction: row; align-items: center; justify-content: flex-start; gap: 0; padding: 0 12px 11px 10px !important; font-size: 15px; line-height: 1.1; }
    div#res td.ht3-res-val::after { position: absolute; left: 10px; right: 12px; bottom: 9px; width: auto; height: 5px; margin: 0; display: block; }
}

/* desktop resource chip, final: border-box (padding no longer makes the value cell taller than the icon cell),
   number centred in the upper part, the bar 4px under it */
@media (min-width: 1101px) {
    div#res td.ht3-res-icon, div#res td.ht3-res-val { box-sizing: border-box; height: 38px; }
    div#res td.ht3-res-val { padding: 0 12px 10px 10px !important; }
    div#res td.ht3-res-val::after { bottom: 8px; left: 10px; right: 12px; }
}

/* mobile: the resource strip uses almost the whole screen width (smaller side margins, smaller gaps between chips) */
@media (max-width: 1100px) {
    div#res, body.mod1 div#res, body.mod2 div#res, body.mod3 div#res { padding-left: 3px !important; padding-right: 3px !important; }
    div#res td.ht3-res-val { margin-right: 2px; padding-right: 2px !important; }
}

/* mobile: the table fills the whole width, so the four chips spread edge to edge */
@media (max-width: 1100px) {
    div#res table, div#res table tbody { display: block; width: 100%; margin: 0; }
    div#res table tr { width: 100%; box-sizing: border-box; }
}

/* mobile: the resource strip has exactly the width of #content (both are children of #mid's single column, no extra side padding) */
@media (max-width: 1100px) {
    div#res, body.mod1 div#res, body.mod2 div#res, body.mod3 div#res { padding-left: 0 !important; padding-right: 0 !important; box-sizing: border-box; width: 100% !important; }
    div#res td.ht3-res-val { margin-right: 0; }
}

/* 601-1100px: the strip is exactly as wide as #content (the old 764px cap made it narrower than the 780px column) */
@media (max-width: 1100px) {
    div#res table { max-width: none; }
    div#res td.ht3-res-icon, div#res td.ht3-res-val { box-sizing: border-box; }
}

/* the strip has the same width as #content (max 764px) and is centred like it */
@media (max-width: 1100px) {
    div#res, body.mod1 div#res, body.mod2 div#res, body.mod3 div#res { max-width: 764px; margin-left: auto !important; margin-right: auto !important; }
    div#res table { max-width: 100%; }
}

/* 2px side margins for the strip on narrow screens */
@media (max-width: 1100px) {
    div#res, body.mod1 div#res, body.mod2 div#res, body.mod3 div#res { padding-left: 2px !important; padding-right: 2px !important; }
}

/* gaps between the four resource tiles */
@media (max-width: 1100px) {
    div#res td.ht3-res-val { margin-right: 5px; }
    div#res td.ht3-res-val:last-child { margin-right: 0; }
}

/* side margins of the tile row (6px) */
@media (max-width: 1100px) {
    div#res, body.mod1 div#res, body.mod2 div#res, body.mod3 div#res { padding-left: 6px !important; padding-right: 6px !important; }
}

/* side margins of the tile row = the inner padding of #content (14px) */
@media (max-width: 1100px) {
    div#res, body.mod1 div#res, body.mod2 div#res, body.mod3 div#res { padding-left: 14px !important; padding-right: 14px !important; }
}

/* side margins of the tile row: a bit less than #content padding */
@media (max-width: 1100px) {
    div#res, body.mod1 div#res, body.mod2 div#res, body.mod3 div#res { padding-left: 9px !important; padding-right: 9px !important; }
}

/* narrow screens: smaller gap between the resource tiles and #content below them */
@media (max-width: 1100px) {
    div#mid { row-gap: 6px !important; }
    div#res, body.mod1 div#res, body.mod2 div#res, body.mod3 div#res { margin-bottom: 0 !important; padding-bottom: 0 !important; }
    div#res table { margin-bottom: 0 !important; }
}

/* reports on narrow screens: one frame only (the #content card), wide unit tables scroll inside it,
   and the Previous / Next buttons always span the visible width */
@media (max-width: 1100px) {
    div.reports table#report_surround { background: none; border: 0; border-radius: 0; box-shadow: none; margin: 0 0 8px; overflow: visible; display: block; }
    div.reports table#report_surround > thead, div.reports table#report_surround > tbody, div.reports table#report_surround > thead > tr { display: block; }
    div.reports table#report_surround > thead th, div.reports table#report_surround > thead td { padding-left: 0; padding-right: 0; }
    div.reports table#report_surround td.report_content { display: block; padding: 8px 0 4px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    div.reports table#report_surround td.report_content > table { width: max-content; min-width: 100%; }
    div.reports .ht3-msgnav { max-width: none; width: 100%; gap: 8px; }
    div.reports .ht3-msgnav-btn { flex: 1 1 0; text-align: center; }
}

/* reports on narrow screens, narrower: the surround never exceeds the card, the inner tables shrink to fit
   (smaller cells and numbers); only a really wide table scrolls inside the report */
@media (max-width: 1100px) {
    div.reports table#report_surround { width: 100% !important; max-width: 100% !important; }
    div.reports table#report_surround td.report_content { max-width: 100%; box-sizing: border-box; }
    div.reports table#report_surround td.report_content > table { width: 100% !important; min-width: 0; table-layout: auto; }
    div.reports table#report_surround td.report_content table td,
    div.reports table#report_surround td.report_content table th { padding-left: 2px !important; padding-right: 2px !important; font-size: 11px; }
    div.reports table#report_surround td.report_content table tbody.units td { min-width: 0; }
    div.reports table#report_surround td.report_content table img.unit { max-width: 18px; height: auto; }
    div.reports table#report_surround > thead td.sent { width: auto; white-space: nowrap; }
}

/* reports on narrow screens: every table inside the report (#attacker, .defender, #reinforcement, ...) scrolls left-right on its own;
   the page and the card stay exactly as wide as the screen */
@media (max-width: 1100px) {
    div.reports table#report_surround td.report_content { overflow-x: visible; }
    div.reports table#report_surround td.report_content > table,
    div.reports table#report_surround td.report_content table#attacker,
    div.reports table#report_surround td.report_content table.defender,
    div.reports table#report_surround td.report_content table#reinforcement {
        display: block; width: 100% !important; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; margin-bottom: 10px;
    }
    div.reports table#report_surround td.report_content table td,
    div.reports table#report_surround td.report_content table th { padding-left: 4px !important; padding-right: 4px !important; font-size: 12px; white-space: nowrap; }
    div.reports table#report_surround td.report_content table td.desc, div.reports table#report_surround td.report_content table td.sub { white-space: normal; }
    div.reports table#report_surround td.report_content table img.unit { max-width: none; }
}

/* the rows of #report_surround were still table rows, wrapped in an anonymous table that grew to the width of the widest inner table;
   make every level a plain block so the surround is exactly as wide as #content and only the inner tables scroll */
@media (max-width: 1100px) {
    div.reports table#report_surround > thead > tr, div.reports table#report_surround > tbody > tr { display: block; width: 100%; }
    div.reports table#report_surround > tbody > tr > td.report_content { display: block; width: 100%; box-sizing: border-box; min-width: 0; }
    div.reports table#report_surround > thead > tr { display: flex; flex-wrap: wrap; gap: 0 10px; }
    div.reports table#report_surround > thead > tr > th, div.reports table#report_surround > thead > tr > td { display: block; }
}

/* compact.css forces ".reports table { min-width: 500px }": on narrow screens the tables must be able to be as narrow as #content */
@media (max-width: 1100px) {
    div.reports table, div.reports table#report_surround, div.reports table#report_surround td.report_content table { min-width: 0 !important; }
}
@media (max-width: 1100px) {
    div.reports table#report_surround > thead { background: var(--tint); border-radius: 8px 8px 0 0; padding: 4px 8px; box-sizing: border-box; }
    div.reports table#report_surround > thead th, div.reports table#report_surround > thead td { background: none !important; }
}

/* reports: from 641px up the inner tables fit, so they are normal full-width tables again; only phones scroll them sideways */
@media (min-width: 641px) and (max-width: 1100px) {
    div.reports table#report_surround td.report_content > table,
    div.reports table#report_surround td.report_content table#attacker,
    div.reports table#report_surround td.report_content table.defender,
    div.reports table#report_surround td.report_content table#reinforcement { display: table; overflow: visible; }
}
/* phones: the scrolling block has the tint itself, so no white strip appears to the right of a table narrower than the card */
@media (max-width: 640px) {
    div.reports table#report_surround td.report_content > table { background: var(--tint); }
}

/* tab menu (reports, messages, ...): the "a | b | c" text becomes a row of pill tabs that wraps on narrow screens */
div#content div#textmenu { display: flex; flex-wrap: wrap; gap: 6px; font-size: 0; line-height: 0; margin: 4px 0 12px; padding: 0; background: none; border: 0; text-align: left; }
div#content div#textmenu a { font-size: 13px; line-height: 1.2; padding: 5px 12px; border: 1px solid var(--card-edge); border-radius: 999px; background: var(--card); color: var(--link); text-decoration: none; white-space: nowrap; }
div#content div#textmenu a:hover { background: var(--tint); }
div#content div#textmenu a.selected { background: var(--gold-deep, #b8862f); border-color: var(--gold-deep, #b8862f); color: #fff; font-weight: bold; }
@media (max-width: 640px) {
    div#content div#textmenu { gap: 5px; }
    div#content div#textmenu a { font-size: 12px; padding: 5px 10px; }
}

/* phones: the tabs stay in ONE line (smaller pills); if even that does not fit, the row scrolls sideways */
@media (max-width: 640px) {
    div#content div#textmenu { flex-wrap: nowrap; gap: 3px; overflow-x: auto; scrollbar-width: none; margin-left: -4px; margin-right: -4px; }
    div#content div#textmenu::-webkit-scrollbar { display: none; }
    div#content div#textmenu a { flex: 0 1 auto; font-size: 11px; padding: 5px 7px; letter-spacing: -.1px; }
}
@media (max-width: 420px) {
    div#content div#textmenu { gap: 2px; }
    div#content div#textmenu a { font-size: 10px; padding: 4px 5px; letter-spacing: -.2px; }
}

/* tab menu: square-ish tabs, no pill rounding */
div#content div#textmenu a { border-radius: 3px; }

/* tab menu: plain text tabs, no boxes; the selected one is bold with an underline in the accent colour */
div#content div#textmenu a { border: 0 !important; background: none !important; border-radius: 0; padding: 4px 2px; color: var(--link); box-shadow: inset 0 -2px 0 transparent; }
div#content div#textmenu a:hover { background: none !important; box-shadow: inset 0 -2px 0 var(--card-edge); }
div#content div#textmenu a.selected { color: var(--heading) !important; font-weight: bold; box-shadow: inset 0 -2px 0 var(--gold-deep, #b8862f); }
div#content div#textmenu { gap: 4px 14px; }
@media (max-width: 640px) { div#content div#textmenu { gap: 2px 9px; } div#content div#textmenu a { padding: 4px 0; } }
@media (max-width: 420px) { div#content div#textmenu { gap: 2px 6px; } }

/* pagination spans the whole width of the container: the buttons share the row, the total count stays at the right end */
.ht3pager { width: 100%; flex-wrap: nowrap; gap: 4px; }
.ht3pager .ht3pg:not(.gap) { flex: 1 1 0; min-width: 0; }
.ht3pager .ht3pg.gap { flex: 0 0 auto; }
.ht3pager .ht3pg-info { flex: 0 0 auto; margin-left: 6px; }

/* the total count at the end of the pager is not shown */
.ht3pager .ht3pg-info { display: none; }

/* pager: buttons keep ONE fixed size on every page (no more growing/shrinking with the number of buttons);
   the row still spans the container: the first and last button sit at the edges, the rest is spread evenly */
.ht3pager { justify-content: space-between; }
.ht3pager .ht3pg:not(.gap) { flex: 0 0 auto; width: 40px; min-width: 40px; height: 32px; line-height: 30px; font-size: 13px; padding: 0; }
.ht3pager .ht3pg.gap { flex: 0 0 auto; width: 16px; }
@media (max-width: 640px) {
    .ht3pager .ht3pg:not(.gap) { width: 36px; min-width: 36px; height: 32px; }
}
@media (max-width: 400px) {
    .ht3pager .ht3pg:not(.gap) { width: 32px; min-width: 32px; }
}

/* the gap ("...") takes a full slot as well, so every page has exactly the same layout */
.ht3pager .ht3pg.gap { width: 40px; min-width: 40px; height: 32px; line-height: 30px; padding: 0; }
@media (max-width: 640px) { .ht3pager .ht3pg.gap { width: 36px; min-width: 36px; } }
@media (max-width: 400px) { .ht3pager .ht3pg.gap { width: 32px; min-width: 32px; } }

/* Nature villages on the map: the tile's own red/white dotted border is covered, a dashed green one replaces it (diamond) */
div#map div#map_content div.ht3nat::after {
    content: ""; position: absolute; left: 1px; top: 33px; width: 72px; height: 40px; pointer-events: none; z-index: 3;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='72' height='40' viewBox='0 0 72 40'%3E%3Cpolygon points='36,2.5 69,20 36,37.5 3,20' fill='none' stroke='%23e6f1d6' stroke-width='5' stroke-linejoin='round'/%3E%3Cpolygon points='36,2.5 69,20 36,37.5 3,20' fill='none' stroke='%232f9e4f' stroke-width='2.5' stroke-dasharray='5 3' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat center / 72px 40px;
}

/* Nature villages that still have animals defending them: the same dashed border in orange instead of green */
div#map div#map_content div.ht3nat.ht3nat-def::after {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='72' height='40' viewBox='0 0 72 40'%3E%3Cpolygon points='36,2.5 69,20 36,37.5 3,20' fill='none' stroke='%23e6f1d6' stroke-width='5' stroke-linejoin='round'/%3E%3Cpolygon points='36,2.5 69,20 36,37.5 3,20' fill='none' stroke='%23e07b1a' stroke-width='2.5' stroke-dasharray='5 3' stroke-linejoin='round'/%3E%3C/svg%3E");
}

/* the large map (pop-up / extra window) does not work on phones and tablets (touch screens) or in very narrow windows: hidden there, a desktop browser keeps it */
@media (pointer: coarse), (max-width: 700px) {
    a#map_makelarge, div#mbig, div.popup_map, div#drag2, div#dark_overlay, iframe#bigmap { display: none !important; }
}

/* Rally Point: "Send back | Merge into this village" stays on ONE line */
div#build.gid16 table.troop_details div.sback { white-space: nowrap; }
div#build.gid16 table.troop_details div.sback a { white-space: nowrap; }

/* Village list: the selected village stands out (blue-green highlight + bold name) */
#vlist tbody tr.ht3-v-cur, #vlist tbody tr.ht3-v-cur:nth-child(even) { background: #e3f0d4; box-shadow: inset 4px 0 0 #4a8a1c; }
#vlist tbody tr.ht3-v-cur:hover { background: #d6e8c0; }
#vlist tr.ht3-v-cur a.ht3-vname { color: #2f5f10; font-weight: bold; }
#vlist tr.ht3-v-cur td.aligned_coords { color: #2f5f10; }
#vlist tr.ht3-v-cur td.aligned_coords, #vlist tr.ht3-v-cur td.aligned_coords * { font-weight: bold; }
.ht3-rc { color: #6a5d38; font-size: 11px; white-space: nowrap; }
#vlist .ht3-hstar { color: #d99a00; font-size: 14px; line-height: 1; margin-left: 3px; text-shadow: 0 0 1px rgba(90,60,0,.5); cursor: default; flex: 0 0 auto; }
#vlist .ht3-vn { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 3px; }
#vlist .ht3-vn .ht3-vname { flex: 0 1 auto; }
#vlist .ht3-vn .ht3-hstar { margin-left: 0; }
@media (max-width: 1100px) { #vlist .ht3-vn { flex: 1 1 100%; } }

/* Rally Point: reserve heroes and hero adventure movements as cards */
.ht3-reserve, .ht3-advcard { background: #fffef9; border: 1px solid #cdbf93; border-radius: 8px; padding: 8px 12px; margin: 8px 0; box-shadow: 0 1px 3px rgba(90,70,20,.15); color: #1d1808; }
.ht3-reserve-h { font-weight: bold; color: #4a3f22; padding-bottom: 6px; margin-bottom: 4px; border-bottom: 2px solid #e2d6b0; }
.ht3-reserve-row { display: flex; align-items: center; gap: 10px; padding: 5px 0; border-bottom: 1px solid #eee5c9; }
.ht3-reserve-row:last-child { border-bottom: 0; }
.ht3-rname { flex: 1 1 auto; font-weight: bold; white-space: nowrap; }
.ht3-rname small, .ht3-advtitle span { color: #6a5d38; font-weight: normal; }
.ht3-rhp { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.ht3-rbar { display: inline-block; width: 80px; height: 10px; border: 1px solid #b7a878; border-radius: 6px; background: #e4dabb; overflow: hidden; }
.ht3-rbar i { display: block; height: 100%; background: #2f7a10; }
.ht3-rbtn { display: inline-block; padding: 3px 12px; border: 1px solid #2a6a0c; border-radius: 5px; background: linear-gradient(#6fb43a,#3f7a12); color: #fff !important; font-weight: bold; text-decoration: none !important; white-space: nowrap; }
.ht3-rbtn:hover { background: linear-gradient(#7fc44a,#4a8a1c); }
.ht3-reserve-msg { color: #a8321c; padding-top: 4px; }
.ht3-advcard { display: flex; align-items: center; gap: 12px; }
.ht3-advinfo { flex: 1 1 auto; min-width: 0; }
.ht3-advtitle { font-size: 13px; }
.ht3-advsub { color: #6a5d38; font-size: 11px; }
.ht3-advtime { text-align: right; white-space: nowrap; font-weight: bold; }
.ht3-advtime small { display: block; font-weight: normal; color: #6a5d38; }

/* Hero's Mansion: which hero the Inventory / Adventures tab is about */
.ht3-herobanner { display: flex; align-items: center; gap: 8px; margin: 6px 0 8px; padding: 6px 12px; border: 1px solid #9bc47a; border-left: 4px solid #4a8a1c; border-radius: 6px; background: #eaf5df; color: #1d1808; font-size: 13px; }
.ht3-herobanner small { color: #5a4d28; margin-left: 4px; }

/* Hero's Mansion: the sections (Hero / Inventory / Adventures) of the selected hero, right under his tab */
.ht3-hsec { display: flex; gap: 6px; margin: 0 0 8px; padding: 6px 10px; border: 1px solid #d9cfae; border-top: 0; border-radius: 0 0 8px 8px; background: #fffef9; }
.ht3-hsec a, .ht3-hsec span { padding: 3px 12px; border-radius: 12px; font-size: 12px; text-decoration: none; }
.ht3-hsec a { color: #4a3f22; background: #efe7cb; border: 1px solid #d9cfae; }
.ht3-hsec a:hover { background: #e4dabb; }
.ht3-hsec span.on { color: #fff; background: #4a8a1c; border: 1px solid #2a6a0c; font-weight: bold; }

/* phones: the tutorial adviser is a small figure under the village list, not a card of its own as tall as the map */
@media (max-width: 700px) {
    div#side_info div#qge { text-align: center; }
    div#side_info div#qge img { display: block; margin: 0 auto; height: 96px !important; width: auto; cursor: pointer; }
    div#side_info > div#anm { position: absolute; pointer-events: none; } /* the arrival animation only: it no longer reserves 140px */
}
/* the narrowest phones (360-380px): burger, brand, coins/silver and the clock still fit on one line */
@media (max-width: 380px) {
    div#header { padding-left: 10px !important; padding-right: 10px !important; gap: 6px !important; }
    div#ht3Clock { padding: 4px 6px; font-size: 11px; }
    div#goldHeader a.ht3-coins, div#goldHeader div#silverHeader { padding: 4px 7px; }
}
/* Marketplace "send resources": the "Villages:" label was a heading-sized word next to small inputs */
table#target_select td.vil span { font-size: 13px; font-weight: bold; vertical-align: middle; }

/* village overview (villages.php) and own troops (villages.php?s=5): the same card - full width, rounded, soft shadow, the same header and row heights
   (table#overview gets this from md3.css; table#troops only had it on the send-troops page, div.a2b) */
div.village3 table#overview, div.village3 table#troops {
  width: 100%; margin: 0 0 10px; table-layout: auto;
  border-collapse: separate; border-spacing: 0;
  background: var(--md-sys-color-surface);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-medium);
  box-shadow: var(--md-elev-1);
  overflow: hidden;
  color: var(--md-sys-color-on-surface);
}
div.village3 table#troops > thead > tr > :is(th, td), div.village3 table#troops > tbody > tr > :is(th, td), div.village3 table#troops > tfoot > tr > :is(th, td) {
  padding: 7px 4px; border: 0; border-bottom: 1px solid var(--md-sys-color-outline-variant);
  background: transparent; color: inherit; vertical-align: middle;
}
div.village3 table#troops > thead > tr > :is(th, td) {
  background: var(--md-sys-color-surface-container-high); color: var(--md-sys-color-on-secondary-container);
  font-weight: 700; letter-spacing: .02em;
}
div.village3 table#troops > thead > tr:first-child > th { padding: 7px 10px; text-align: left; }
div.village3 table#troops > tbody > tr:last-child > :is(th, td) { border-bottom: 0; }
div.village3 table#troops > tbody > tr:hover > td { background: var(--md-sys-color-surface-container); }
div.village3 table#troops td.vil, div.village3 table#overview td.vil { text-align: left; padding-left: 10px; }
div.village3 table#overview > thead > tr:first-child > th { text-align: left; }

/* phones: the statistics / alliance icon menu sat on top of the table heading (absolute position for the desktop layout);
   the village overview (dorf3) is squeezed so its five columns fit and village names stay on one line */
@media (max-width: 700px) {
    div.statistics div#submenu, div.alliance div#submenu { position: static; display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; margin: 6px 0 2px; }
    div.statistics div#submenu img, div.alliance div#submenu img { float: none; margin: 0; }
    div.village3 { overflow-x: auto; }
    div.village3 table#overview { font-size: 12px; }
    div.village3 table#overview th, div.village3 table#overview td { padding: 5px 3px !important; }
    div.village3 table#overview td:first-child, div.village3 table#overview td:first-child a { white-space: nowrap; }
}
/* phones: the alliance profile's two columns (details | description) stack, and the member list scrolls inside its card */
@media (max-width: 700px) {
    div.alliance table#profile, div.alliance table#profile > tbody, div.alliance table#profile > tbody > tr,
    div.alliance table#profile > tbody > tr > td.details, div.alliance table#profile > tbody > tr > td.desc1 { display: block; width: auto !important; }
    div.alliance table#profile > thead { display: none; }
    div.alliance table#profile td.empty { display: none; }
    div.alliance table#profile td.details table { width: 100%; }
}
@media (max-width: 700px) {
    div.alliance table#member { width: 100% !important; }
    div.alliance table#member th, div.alliance table#member td { width: auto !important; padding: 4px 4px !important; font-size: 12px; }
}

/* phones: easier taps. The level badges of the fields (dorf1) and of the buildings (dorf2) open the building (their click
   handlers were there, but the dorf1 badges ignored the pointer) and get an invisible ~40px touch area around them; the rows
   of the village list are taller and the whole row is the link */
@media (max-width: 700px) {
    div.village1 div#village_map span.ht3-lvl { pointer-events: auto !important; cursor: pointer; }
    div.village1 div#village_map span.ht3-lvl::after,
    div.village2 div#village_map div#levels div.ht3-lv::after {
        content: ""; position: absolute; left: calc(50% - 20px); top: calc(50% - 20px); width: 40px; height: 40px; border-radius: 50%;
    }
    div.village2 div#village_map div#levels, div.village2 div#village_map div#levels div.ht3-lv { visibility: visible !important; } /* on phones the badges are the touch targets of the buildings */
    div.village2 div#village_map div#levels div.ht3-lv { pointer-events: auto !important; } /* the layer itself stays click-through (md3.css): it covers the map */
    div.village2 div#village_map div#levels div.ht3-lv { cursor: pointer; }
}

/* phones: the village list as a touch list - 44px rows with the name and the coordinates on one centred line, the current
   village marked by its row (not a dot), no empty badge line, a 16px search box (iOS zooms into smaller inputs) and a taller
   scroll area; ht3_ui.js makes the whole row a link */
@media (max-width: 700px) {
    .ht3-vfilter input { font-size: 16px; padding: 9px 12px; border-radius: 8px; }
    .ht3-vscroll-on { max-height: 60vh; border-radius: 10px; }
    #vlist { border-collapse: collapse; width: 100%; }
    #vlist tbody tr { cursor: pointer; border-bottom: 1px solid var(--line); }
    #vlist tbody tr:last-child { border-bottom: 0; }
    #vlist td { vertical-align: middle !important; padding-top: 0 !important; padding-bottom: 0 !important; }
    #vlist td.dot { width: 4px; padding: 0 !important; font-size: 0; }
    #vlist tbody tr.ht3-v-cur td { background: #e3f0d4; }
    #vlist tbody tr.ht3-v-cur td.dot { background: #4a8a1c; } /* the 4px dot column is the green bar of the current village */
    #vlist td.link { padding-left: 10px !important; }
    /* name and movement badges on one line when they fit (the badges wrap below the name only when there are many) */
    #vlist .ht3-vl { min-height: 44px; box-sizing: border-box; padding: 6px 0; align-content: center; align-items: center; gap: 4px 8px; }
    #vlist .ht3-vn { flex: 1 1 96px; min-width: 96px; }
    #vlist .ht3-vname { display: block; font-size: 15px; line-height: 24px; }
    #vlist .ht3-vb:not(:has(*)) { display: none; }
    #vlist .ht3-vb { flex: 0 1 auto; justify-content: flex-end; gap: 3px; padding: 0; }
    #vlist .ht3-vb .ht3-att { font-size: 11px; line-height: 20px; min-width: 30px; padding: 0 5px; border-radius: 10px; }
    #vlist td.aligned_coords { font-size: 12px; padding-left: 8px !important; padding-right: 10px !important; }
    #vlist td.aligned_coords div { display: inline; }
}

/* phones: the top-10 tables (players and alliances) one under the other at full width instead of 246px tables in a zigzag */
@media (max-width: 700px) {
    div.statistics table.top10, div.statistics table#top10_offs, div.statistics table#top10_defs,
    div.statistics table#top10_climbers, div.statistics table#top10_raiders { float: none !important; width: 100% !important; margin: 12px 0 0 !important; }
    div.statistics table.top10 td { padding: 6px 6px !important; }
    div.statistics table.top10 td.ra { width: 2.5em; white-space: nowrap; }
    div.statistics table.top10 td.val { width: auto; text-align: right; white-space: nowrap; }
    div.statistics table.top10 tr.none td { background: #f3ead2 !important; font-weight: bold; }
    div.statistics table.top10 tr td.empty { padding: 2px !important; }
}

/* HeroesT3: the hero panel medallion (build.php?hero) - the sixth medallion of the top bar, the same size and states as the others */
a#n6 img { background: url(../img/l/n6.png) no-repeat 0 -21px; width: 70px; height: 72px; } /* 72px like n1-n4 (new_layout_ltr.css), or it sits lower in the centred row */
a#n6:hover img { background-position: 0 -121px; }
div#mtop a#n6 { float: left; margin: 0; padding: 0; } /* like n1-n5 (compact.css), so it lines up with them */
.ht3-hero-panel-link { margin: 12px 0; }
.ht3-hero-panel-link img.ht3-helm { width: 28px; height: 27px; background: url(../img/l/n6.png) no-repeat 0 -8.4px; background-size: 28px 80px; }
.ht3-hero-none { margin: 10px 0; padding: 10px 14px; border: 1px solid var(--card-edge); border-radius: 8px; background: #fbf4e0; }
.ht3-mansion-oases { margin-top: 16px; } /* the oases under training / reviving on the Hero's Mansion page */
/* phones: the hero's "produced resource" choice - five pills in one row of equal columns (they wrapped onto two lines) */
@media (max-width: 520px) {
    div#build .t4h-res.t4h-resbox { display: block; }
    div#build .t4h-res.t4h-resbox .t4h-rescap { margin-bottom: 5px; }
    div#build .t4h-res.t4h-resbox form { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; width: 100%; }
    div#build .t4h-res.t4h-resbox label { justify-content: center; gap: 1px; padding: 3px 2px; font-size: 11px; min-width: 0; }
    div#build .t4h-res.t4h-resbox img.mini { margin: 0; }
    div#build .t4h-res.t4h-resbox img.t4h-resall { height: 13px; }
}
/* the Hero's Mansion / hero panel button: enabled and disabled look the same, the disabled one is only greyed out */
.ht3-hero-panel-link a, .ht3-hero-panel-link .ht3-disabled { box-sizing: border-box; display: inline-flex; align-items: center; gap: 8px; max-width: 100%; padding: 8px 14px; border: 1px solid var(--card-edge); border-radius: 10px; background: var(--card); font-weight: bold; line-height: 1.35; text-decoration: none !important; }
.ht3-hero-panel-link img.building { flex: none; width: 40px; height: 40px; zoom: .6; }
.ht3-hero-panel-link .ht3-disabled { color: var(--ink-soft); cursor: not-allowed; opacity: .75; }
.ht3-hero-panel-link .ht3-disabled img.building { filter: grayscale(1); }
.ht3-hero-panel-link a:hover { background: rgba(226, 182, 90, .18); }
/* the silver in the top bar is a link to the hero shop: the link fills the whole silver box (its padding moves onto the link) */
div#goldHeader div#silverHeader { padding: 0 !important; }
div#goldHeader div#silverHeader a.ht3-silver-link { display: flex; align-items: center; gap: 5px; padding: 6px 12px; color: inherit !important; text-decoration: none !important; }
div#goldHeader div#silverHeader a.ht3-silver-link:hover { background: rgba(246, 213, 140, 0.16); }
@media (max-width: 600px) { div#goldHeader div#silverHeader a.ht3-silver-link { padding: 5px 8px; } }
@media (max-width: 380px) { div#goldHeader div#silverHeader a.ht3-silver-link { padding: 4px 7px; } }

/* HeroesT3 phones: the village switcher - a button under the resource bar opens the village list as a sheet from the bottom (ht3_ui.js) */
.ht3-vswitch { box-sizing: border-box; display: flex; align-items: center; gap: 8px; width: 100%; margin: 8px 0 0; padding: 10px 14px;
    border: 1px solid var(--card-edge); border-radius: 12px; background: var(--card); color: var(--heading); font: inherit; font-size: 15px; font-weight: bold;
    text-align: left; cursor: pointer; box-shadow: 0 1px 2px rgba(60, 40, 10, .25); }
.ht3-vswitch:active { background: #f3ead2; }
.ht3-vswitch-n { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ht3-vswitch-c { flex: none; font-size: 12px; font-weight: normal; color: var(--ink-soft); }
.ht3-vswitch-alert { flex: none; width: 20px; height: 20px; border-radius: 50%; background: #a8321c; color: #fff; font-size: 13px; line-height: 20px; text-align: center; }
.ht3-vswitch-caret { flex: none; color: var(--gold-deep); font-size: 14px; }
body.ht3-vsheet-on #side_info .ht3-vhead { display: none; } /* the list lives in the sheet now */
.ht3-vsheet-scrim { position: fixed; inset: 0; z-index: 980; background: rgba(8, 5, 3, .55); opacity: 0; pointer-events: none; transition: opacity .2s ease; }
.ht3-vsheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 990; box-sizing: border-box; display: flex; flex-direction: column; max-height: 80vh; max-height: 80dvh;
    padding: 0 12px 12px; border-radius: 16px 16px 0 0; background: var(--card); box-shadow: 0 -10px 30px rgba(0, 0, 0, .35);
    transform: translateY(105%); visibility: hidden; transition: transform .25s ease, visibility .25s; }
body.ht3-vsheet-open .ht3-vsheet { transform: none; visibility: visible; }
body.ht3-vsheet-open .ht3-vsheet-scrim { opacity: 1; pointer-events: auto; }
body.ht3-vsheet-open { overflow: hidden; }
.ht3-vsheet-head { flex: none; display: flex; align-items: center; justify-content: space-between; padding: 12px 2px 8px; }
.ht3-vsheet-head::before { content: ""; position: absolute; left: 50%; top: 6px; width: 40px; height: 4px; margin-left: -20px; border-radius: 2px; background: #d9cba3; }
.ht3-vsheet-head a { font-size: 16px; font-weight: bold; color: var(--heading) !important; text-decoration: none !important; }
.ht3-vsheet-close { width: 40px; height: 40px; border: 0; border-radius: 50%; background: #f1e7cc; color: var(--heading); font-size: 24px; line-height: 40px; cursor: pointer; }
.ht3-vsheet-body { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.ht3-vsheet-body .ht3-vfilter { flex: none; }
.ht3-vsheet-body .ht3-vscroll { flex: 1 1 auto; min-height: 0; max-height: none !important; overflow-y: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: 10px; }
/* phones: the village pages' heading has no ornament under it, so its 16px bottom padding made the space above the map
   twice the space below it */
@media (max-width: 700px) {
    div#content.village1 > h1, div#content.village2 > h1 { padding-bottom: 4px !important; }
}
/* phones/tablets: on build.php pages the resource bar (and the village switcher in it) sits inside #mid, whose 8px side
   padding made it narrower than on dorf1/dorf2/reports, where it is outside #mid */
@media (max-width: 1100px) {
    div#mid > div#res { margin-left: -8px !important; margin-right: -8px !important; width: auto !important; justify-self: stretch; padding-top: 12px !important; }
}
/* phones/tablets: no top margin on #mid - it added 14px above the content on dorf1/dorf2/reports (#res outside #mid) and
   pushed the resource bar down on build.php pages (#res inside #mid); now the bar and the gap under it are the same everywhere */
@media (max-width: 1100px) {
    div#mid { margin-top: 0 !important; }
}

/* ===== the hero panel on phones (build.php?hero) ===== */
@media (max-width: 700px) {
    /* inventory: compact cards - the name on top, the price with Sell on the left and Equip / Use on the right in one row */
    div#build.gid37 .ht3-bag { gap: 8px; }
    div#build.gid37 .ht3-card { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 10px; }
    div#build.gid37 .ht3-card-head { flex: 1 1 100%; }
    div#build.gid37 .ht3-card > form.ht3-card-act:nth-of-type(1) { order: 2; flex: none; }
    div#build.gid37 .ht3-card > form.ht3-card-act:nth-of-type(2) { order: 1; flex: 1 1 auto; justify-content: flex-start; }
    div#build.gid37 .ht3-card-act input[type="text"] { width: 34px; height: 30px; box-sizing: border-box; font-size: 16px; }
    /* equipment tiles: the slot name leaves room for the take-off x */
    div#build.gid37 .ht3-slot.has .ht3-slot-label { padding-right: 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* hero panel: Hero / Inventory / Adventures / Shop as tabs with pictures (img/hero/sections.png: helmet, sack, map, merchant)
   under the selected hero's tab: the current section is a raised light card with a green label and bar, the others are muted */
div#build.gid37 .ht3-hsec.ht3-hsec-tabs { display: flex !important; flex-wrap: nowrap !important; gap: 4px !important; padding: 6px !important; margin: 0 0 12px;
    border: 1px solid #d9cfae; border-top: 0; border-radius: 0 0 12px 12px; background: #f3ecd6; }
div#build .ht3-hsec.ht3-hsec-tabs .ht3-stab { position: relative; flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    padding: 7px 2px 8px; border: 1px solid transparent; border-radius: 10px; background: none; color: #7a6c45 !important;
    font-size: 12px; font-weight: bold; line-height: 1.1; text-decoration: none !important; transition: background .15s ease; }
div#build .ht3-hsec.ht3-hsec-tabs .ht3-stab-ico { display: block; width: 30px; height: 30px; background: url(../../../img/hero/sections.png) no-repeat 0 0 / 120px 30px;
    filter: saturate(.55); opacity: .8; transition: transform .15s ease, opacity .15s ease, filter .15s ease; }
div#build .ht3-hsec.ht3-hsec-tabs .ht3-stab-ico1 { background-position: -30px 0; }
div#build .ht3-hsec.ht3-hsec-tabs .ht3-stab-ico2 { background-position: -60px 0; }
div#build .ht3-hsec.ht3-hsec-tabs .ht3-stab-ico3 { background-position: -90px 0; }
div#build .ht3-hsec.ht3-hsec-tabs .ht3-stab-l { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
div#build .ht3-hsec.ht3-hsec-tabs a.ht3-stab:hover { background: rgba(255, 255, 255, .55); color: #4a3f22 !important; }
div#build .ht3-hsec.ht3-hsec-tabs a.ht3-stab:hover .ht3-stab-ico { opacity: 1; filter: none; transform: translateY(-1px); }
div#build .ht3-hsec.ht3-hsec-tabs .ht3-stab.on { background: #fffef9; border-color: #d9cfae; color: #2f6a10 !important; cursor: default;
    box-shadow: 0 1px 3px rgba(80, 60, 20, .18); }
div#build .ht3-hsec.ht3-hsec-tabs .ht3-stab.on .ht3-stab-ico { opacity: 1; filter: none; }
div#build .ht3-hsec.ht3-hsec-tabs .ht3-stab.on::after { content: ""; position: absolute; left: 28%; right: 28%; bottom: 3px; height: 3px; border-radius: 2px; background: #4a8a1c; }
@media (min-width: 701px) {
    /* on a wide screen: picture and label side by side */
    div#build .ht3-hsec.ht3-hsec-tabs .ht3-stab { flex-direction: row; gap: 8px; padding: 8px 6px 9px; font-size: 13px; }
}
@media (max-width: 380px) { div#build .ht3-hsec.ht3-hsec-tabs .ht3-stab { font-size: 11px; } }
/* the labels are spans: the old pill rule (.ht3-hsec span) gave them 12px side padding, a background and a border - none here */
div#build .ht3-hsec.ht3-hsec-tabs .ht3-stab-l { padding: 0 !important; border: 0 !important; border-radius: 0 !important; background: none !important; font-size: inherit !important; }
@media (max-width: 700px) {
    /* a longer label (Adventures, Inventory) takes a bit more of the row than Hero and Shop */
    div#build .ht3-hsec.ht3-hsec-tabs .ht3-stab { flex: 1 1 auto; padding-left: 4px; padding-right: 4px; }
}

/* ===== hero picker (Templates/Build/37_herotabs.tpl, ht3_ui.js): the selected hero on top of the section tabs; the list of
   all heroes is a dropdown on a wide screen (scrolls when there are many) and a sheet from the bottom on a phone ===== */
.ht3-hpick { position: relative; margin: 8px 0 0; }
.ht3-hpick-card { display: flex; align-items: stretch; border: 1px solid #d9cfae; border-bottom: 0; border-radius: 12px 12px 0 0; background: #f3ecd6; }
.ht3-hpick-btn { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 0; border-radius: 12px 0 0 0; background: none;
    color: var(--heading); font: inherit; text-align: left; cursor: pointer; }
.ht3-hpick-btn:hover { background: rgba(255, 255, 255, .45); }
.ht3-hpick-btn img.unit, .ht3-hp-row img.unit { flex: none; transform: scale(1.4); margin: 0 5px; }
.ht3-hp-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ht3-hp-name { font-size: 16px; font-weight: bold; color: var(--heading); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ht3-hp-name small { font-size: 12px; font-weight: normal; color: var(--ink-soft); }
.ht3-hp-st { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ht3-hp-st .dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: #5fae2a; }
.ht3-hp-st .dot.away { background: #d98a1f; } .ht3-hp-st .dot.dead { background: #b03030; } .ht3-hp-st .dot.wait { background: #9a9a9a; }
.ht3-hp-count { flex: none; min-width: 22px; padding: 1px 7px; border-radius: 10px; background: #e2d6b0; color: #5a4d28; font-size: 12px; font-weight: bold; text-align: center; }
.ht3-hp-caret { flex: none; color: var(--gold-deep); font-size: 14px; transition: transform .15s ease; }
.ht3-hpick.open .ht3-hp-caret { transform: rotate(180deg); }
.ht3-hpick-edit { flex: none; width: 46px; border: 0; border-left: 1px solid #e2d6b0; border-radius: 0 12px 0 0; background: none; color: #7a6c45; font-size: 18px; cursor: pointer; }
.ht3-hpick-edit:hover { background: rgba(255, 255, 255, .45); color: #2f6a10; }
/* rename: the name becomes an input with save / cancel in the same field */
.ht3-hpick-rename { display: none; flex: 1 1 auto; align-items: center; gap: 6px; margin: 0; padding: 8px 10px; }
.ht3-hpick.renaming .ht3-hpick-btn, .ht3-hpick.renaming .ht3-hpick-edit { display: none; }
.ht3-hpick.renaming .ht3-hpick-rename { display: flex; }
.ht3-hpick-rename input.text { flex: 1 1 auto; min-width: 0; box-sizing: border-box; height: 38px; padding: 4px 10px; border: 1px solid #cdbf93; border-radius: 8px;
    background: #fff; color: #1d1808; font-size: 16px; font-weight: bold; }
.ht3-hpick-rename input.text:focus { outline: 0; border-color: #3f7a12; box-shadow: 0 0 0 2px rgba(63, 122, 18, .2); }
.ht3-hpick-ok, .ht3-hpick-cancel { flex: none; width: 38px; height: 38px; border: 1px solid #cdbf93; border-radius: 8px; background: #fffef9; font-size: 18px; cursor: pointer; }
.ht3-hpick-ok { background: #4a8a1c; border-color: #3a7212; color: #fff; }
.ht3-hpick-cancel { color: #7a6c45; }
/* the list */
.ht3-hpick-list { display: none; }
.ht3-hpick-list .ht3-vsheet-head span { font-size: 16px; font-weight: bold; color: var(--heading); }
.ht3-hsheet-list { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.ht3-hp-row { display: flex; align-items: center; gap: 10px; min-height: 52px; box-sizing: border-box; padding: 7px 12px; border-bottom: 1px solid var(--line);
    color: var(--ink) !important; text-decoration: none !important; }
.ht3-hp-row:last-child { border-bottom: 0; }
a.ht3-hp-row:hover, a.ht3-hp-row:active { background: rgba(226, 182, 90, .18); }
.ht3-hp-row.on { background: #e3f0d4; box-shadow: inset 4px 0 0 #4a8a1c; }
.ht3-hp-row.on .ht3-hp-name { color: #2f5f10; }
.ht3-hp-row.locked { opacity: .6; }
.ht3-hp-hp { flex: none; width: 44px; height: 6px; border-radius: 3px; background: #e6d8b4; overflow: hidden; }
.ht3-hp-hp span { display: block; height: 100%; background: #4a8a1c; }
.ht3-hpick-scrim { display: none; }
body.ht3-hpick-open .ht3-hpick-scrim { display: block; position: fixed; inset: 0; z-index: 980; background: transparent; }
/* wide screen: a dropdown under the button, up to ~7 heroes visible, the rest scroll */
@media (min-width: 1101px) {
    .ht3-hpick.open .ht3-hpick-list { display: block; position: absolute; left: 0; right: 0; top: 100%; z-index: 990; margin-top: 4px; border: 1px solid #d9cfae;
        border-radius: 12px; background: #fffef9; box-shadow: 0 10px 28px rgba(60, 40, 10, .28); overflow: hidden; }
    .ht3-hpick-list .ht3-vsheet-head { display: none; }
    .ht3-hpick-list .ht3-hsheet-list { max-height: 370px; }
}
/* phone / tablet: a sheet from the bottom, like the village switcher */
@media (max-width: 1100px) {
    .ht3-hpick-list { display: flex; flex-direction: column; position: fixed; left: 0; right: 0; bottom: 0; z-index: 990; box-sizing: border-box; max-height: 80vh; max-height: 80dvh;
        padding: 0 12px 12px; border-radius: 16px 16px 0 0; background: var(--card); box-shadow: 0 -10px 30px rgba(0, 0, 0, .35);
        transform: translateY(105%); visibility: hidden; transition: transform .25s ease, visibility .25s; }
    .ht3-hpick.open .ht3-hpick-list { transform: none; visibility: visible; }
    body.ht3-hpick-open .ht3-hpick-scrim { background: rgba(8, 5, 3, .55); }
    body.ht3-hpick-open { overflow: hidden; }
    .ht3-hpick-list .ht3-hsheet-list { flex: 1 1 auto; min-height: 0; border: 1px solid var(--line); border-radius: 10px; }
    .ht3-hpick-list .ht3-vsheet-head { position: relative; }
    .ht3-hp-row { min-height: 56px; }
}
.ht3-hp-st { font-weight: normal; } /* the same weight in the button and in the list */

/* Rally Point: prisoners in one compact table (Templates/Build/16.tpl) */
.ht3-pris-wrap { overflow-x: auto; margin: 0 0 14px; }
table.ht3-pris { width: 100%; border-collapse: collapse; border: 1px solid #e2d6b0; border-radius: 10px; background: #fffef9; font-size: 13px; }
table.ht3-pris th, table.ht3-pris td { padding: 6px 6px; border-bottom: 1px solid #eee4c8; text-align: center; white-space: nowrap; }
table.ht3-pris thead th { background: #f6f0dc; color: #5a4d28; font-size: 12px; }
table.ht3-pris .pl { text-align: left; white-space: normal; }
table.ht3-pris .pl .xy { color: var(--ink-soft); font-size: 11px; white-space: nowrap; }
table.ht3-pris td.none { color: #b9ae8c; }
table.ht3-pris td.act { text-align: right; }
table.ht3-pris td.act a { font-weight: bold; }
table.ht3-pris tfoot th { background: #f3ecd6; font-weight: bold; color: #3a3018; border-bottom: 0; }
table.ht3-pris tbody tr:last-child td { border-bottom: 1px solid #e2d6b0; }
/* phones: no search box in the village sheet (the list is short enough to scroll, and the keyboard closed itself there) */
.ht3-vsheet-body .ht3-vfilter { display: none !important; }
/* hero inventory: the Bucket of Water's choice of the fallen hero */
.ht3-bucket-hero { max-width: 100%; min-width: 0; height: 32px; padding: 2px 6px; border: 1px solid #cdbf93; border-radius: 8px; background: #fff; font-size: 13px; }
.ht3-bucket-none { font-size: 12px; }
@media (max-width: 700px) { .ht3-bucket-hero { font-size: 16px; flex: 1 1 auto; } }
/* hero panel: a fallen hero's card (from the hero list) with the Bucket of Water revival */
.ht3-fallen { display: flex; align-items: center; gap: 12px; margin: 10px 0; padding: 12px 14px; border: 1px solid #e0c2b8; border-radius: 12px; background: #fbefe9; }
.ht3-fallen img.unit { transform: scale(1.5); margin: 0 6px; filter: grayscale(1); opacity: .8; }
.ht3-fallen-main b { font-size: 16px; color: var(--heading); }
.ht3-fallen-main small { color: var(--ink-soft); }
.ht3-fallen-st { color: #a52a14; font-size: 13px; margin-top: 2px; }
.ht3-fallen-act { margin: 0 0 12px; }
.ht3-bucket-btn { display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px 6px 8px; border: 1px solid #3a7212; border-radius: 10px; background: #4a8a1c;
    color: #fff; font: inherit; font-weight: bold; cursor: pointer; }
.ht3-bucket-btn:hover { background: #3f7a16; }
.ht3-bucket-btn .heroT4Item { zoom: .7; }

/* Alliance forum: the original tables are a fixed 502px wide; they fill the card now, the editor and the text area follow */
div#content.forum table:not(#vlist) { width: 100%; box-sizing: border-box; }
div#content.forum table#new_topic textarea, div#content.forum table#new_post textarea, div#content.forum table#edit_post textarea { width: 100% !important; box-sizing: border-box; }
div#content.forum table#new_topic input.text[name="thema"], div#content.forum table#new_topic input.text[name="umfrage_thema"] { width: 100%; max-width: 420px; box-sizing: border-box; }

/* Alliance forum: thread view */
div#content.forum table#posts td.pinfo { width: 150px; border-right: 1px solid var(--card-edge); vertical-align: top; }
div#content.forum table#posts tbody tr + tr td { border-top: 1px solid var(--card-edge); }
div#content.forum table#posts td.pcontent { vertical-align: top; word-wrap: break-word; overflow-wrap: anywhere; }

/* ---- Alliance forum: refreshed look (cards, soft rows, chat-like posts) ---- */
div#content.forum h4 { margin: 6px 0 12px; font-size: 13px; font-weight: 600; color: var(--ink-soft); }
div#content.forum h4 a { color: var(--gold-deep); text-decoration: none; }
div#content.forum h4 a:hover { text-decoration: underline; }
div#content.forum table:not(#vlist) {
    border-collapse: separate; border-spacing: 0; background: var(--card);
    border: 1px solid var(--card-edge); border-radius: 12px; overflow: hidden;
    box-shadow: 0 1px 3px rgba(80,55,20,.08); margin-bottom: 16px;
}
div#content.forum table:not(#vlist) thead th {
    background: linear-gradient(180deg, #f9f1de, var(--tint)); color: var(--ink);
    font-size: 14px; font-weight: 700; text-align: left; padding: 10px 14px;
    border: 0; border-bottom: 1px solid var(--card-edge);
}
div#content.forum table:not(#vlist) thead td {
    background: var(--tint); color: var(--ink-soft); font-size: 11px; text-transform: uppercase;
    letter-spacing: .05em; padding: 6px 14px; border: 0; border-bottom: 1px solid var(--card-edge);
}
div#content.forum table:not(#vlist) tbody td { border: 0; padding: 10px 14px; background: transparent; }
div#content.forum table:not(#vlist) tbody tr + tr td { border-top: 1px solid #f0e6cc; }
div#content.forum table:not(#vlist) tbody tr:hover td { background: #fcf8ee; }
div#content.forum td.tit a { font-weight: 600; color: var(--ink); text-decoration: none; }
div#content.forum td.tit a:hover { color: var(--gold-deep); }
div#content.forum td.cou, div#content.forum td.last { color: var(--ink-soft); font-size: 12px; }
div#content.forum td.last a { color: var(--gold-deep); }
div#content.forum td.ico { width: 46px; }

/* thread: author card + message bubble */
div#content.forum table#posts tbody tr:hover td { background: transparent; }
div#content.forum table#posts td.pinfo { background: #fcf8ee; font-size: 12px; color: var(--ink-soft); line-height: 1.5; }
div#content.forum table#posts td.pinfo a.name { font-size: 14px; font-weight: 700; color: var(--ink); text-decoration: none; }
div#content.forum table#posts td.pcontent { padding: 12px 18px; }
div#content.forum table#posts .posted { font-size: 11px; color: var(--ink-soft); margin-bottom: 6px; }
div#content.forum table#posts .clear.dotted { border-top: 1px dashed var(--card-edge); margin: 4px 0 10px; height: 0; }
div#content.forum table#posts .text { color: var(--ink); line-height: 1.55; font-size: 13px; }

/* forms: new thread / reply / edit */
div#content.forum textarea, div#content.forum input.text {
    border: 1px solid var(--card-edge); border-radius: 8px; padding: 8px 10px; background: #fffdf8; color: var(--ink);
}
div#content.forum textarea:focus, div#content.forum input.text:focus { outline: 2px solid var(--gold); border-color: var(--gold); }

/* Alliance forum: plain buttons instead of the old gif ones */
div#content.forum a.ht3-btn {
    display: inline-block; margin: 0 6px 6px 0; padding: 7px 16px; border-radius: 8px; font-size: 13px; font-weight: 700;
    color: #fff !important; text-decoration: none !important; border: 1px solid var(--gold-deep);
    background: linear-gradient(180deg, #d9a24a, var(--gold-deep)); box-shadow: 0 1px 2px rgba(80,55,20,.25);
}
div#content.forum a.ht3-btn:hover { filter: brightness(1.08); }
div#content.forum a.ht3-btn[title="Toggle Admin mode"] {
    color: var(--gold-deep) !important; background: var(--card); box-shadow: none;
}
div#content.forum a.ht3-mini {
    display: inline-block; width: auto; height: auto; margin: 1px 3px 1px 0; padding: 1px 7px; border-radius: 6px;
    font-size: 11px; line-height: 1.5; color: var(--gold-deep) !important; text-decoration: none !important;
    background: var(--tint) !important; border: 1px solid var(--card-edge); text-indent: 0; float: none;
}
div#content.forum a.ht3-mini:hover { background: #fff !important; border-color: var(--gold); }
div#content.forum a.ht3-mini.fdel { color: #9b2c1f !important; }
div#content.forum div.admin { text-align: right; margin-bottom: 4px; }

/* Home page: releases as the outer accordion */
details.ht3-rel { margin: 0 0 14px; border-radius: 12px; background: var(--tint); border: 1px solid var(--card-edge); padding: 0 12px 12px; }
details.ht3-rel > summary {
    cursor: pointer; list-style: none; display: flex; align-items: baseline; gap: 12px; padding: 14px 4px 10px;
}
details.ht3-rel > summary::-webkit-details-marker { display: none; }
details.ht3-rel > summary::after { content: "\25BE"; margin-left: auto; color: var(--gold-deep); transition: transform .15s; }
details.ht3-rel[open] > summary::after { transform: rotate(180deg); }
.ht3-rel-title { font-size: 16px; font-weight: 700; color: var(--heading); }
.ht3-rel-date { font-size: 12px; color: var(--ink-soft); background: var(--card); border: 1px solid var(--card-edge); border-radius: 10px; padding: 1px 9px; }
details.ht3-rel .ht3-changes { margin-top: 2px; }

/* HeroesT3: attack / defence of a unit after the Blacksmith and Armoury upgrades (training lists, upgrade pages) */
.ht3-unit-stats { margin-top: 3px; font-size: 11px; color: #5a4a2a; }
.ht3-unit-stats b { color: #2a2a2a; }
.ht3-unit-stats .ht3-stat-up { color: #2e7d32; font-weight: bold; }
.ht3-unit-stats .ht3-stat-base { color: #8a7a5a; }

/* hero inventory: what the item does, under its name (it was only in the tooltip) */
.ht3-card-desc { font-size: 12px; line-height: 1.35; color: var(--md-sys-color-on-surface-variant, inherit); }
div#build.gid37 .ht3-card > .ht3-card-desc { order: 0; flex: 1 1 100%; }

/* header and menu appear once ht3_ui.js has built them (no pumping while loading) */
html.ht3:not(.ht3-ready) #header, html.ht3:not(.ht3-ready) #side_navi { visibility: hidden; }
