/* =========================================================
   1. TOKENS
   ========================================================= */

:root {
    --overlay-bg: rgba(255, 255, 255, 0.7);
}

/* Both dark hooks kept: `.dark-mode` is legacy, `data-theme` is current. */
html[data-theme="dark"],
.dark-mode {
    --overlay-bg: rgba(0, 0, 0, 0.7);
}

/* =========================================================
   2. LAYOUT
   ========================================================= */

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px 80px;
}

.table-container {
    display: flex;
    gap: 20px;
    padding: 10px;
    align-items: flex-start;
}

div.sticky {
    position: sticky;
    top: 0;
    width: 50%;
    padding: 5px;
    border: 2px groove;
    background: var(--surface-2);
    color: var(--text);
    z-index: 9999;
}

/* =========================================================
   3. LINKS & READER HOVER
   ========================================================= */

a:hover {
    text-decoration: underline;
}

/* Reader words: bare spans or anchor-wrapped */
.hover-element {
    cursor: pointer;
}

a:hover .hover-element,
.hover-element:hover {
    text-decoration: underline;
    text-decoration-color: var(--accent);
    text-underline-offset: 3px;
}

a:has(.hover-element):hover {
    text-decoration: none;
}

.color7 { color: var(--text); }        /* word has a dictionary entry */
.color8 { color: var(--no-dict); }     /* word has no dictionary entry */

/* =========================================================
   4. NAV (hide / show topbar)
   ========================================================= */

.nav-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

.nav-toggle {
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: all var(--transition);
}

.nav-toggle:hover {
    border-color: var(--accent);
}

/* Default: topbar visible */
#navShow,
#menu2,
#finishBtn {
    display: none;
}

#navHide {
    display: block;
}

/* Nav hidden (class set on <html>) */
.nav-hidden-init #navShow,
.nav-hidden-init #menu2,
.nav-hidden-init #finishBtn {
    display: inline-block;
}

.nav-hidden-init #navHide {
    display: none;
}

.nav-hidden-init .topbar {
    height: 0;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    margin: 0;
    padding: 0;
}

/* =========================================================
   5. BUTTONS & SPINNERS
   ========================================================= */

.d-btn {
    margin: 10px;
}

.d-btn-finish {
    position: relative;
    border-radius: 999px;
    isolation: isolate;
}

.d-btn-finish::before {
    content: "";
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    background: linear-gradient(90deg, #ff4d6d, #ffd93d, #4dabf7, #ff4d6d);
    background-size: 300% 100%;
    z-index: -1;
    opacity: 0.5;
    animation: borderShift 50s linear infinite;
}

@keyframes borderShift {
    0%   { background-position: 0% 50%; }
    30%  { background-position: 90% 50%; }
    55%  { background-position: 150% 50%; }
    80%  { background-position: 240% 50%; }
    100% { background-position: 300% 50%; }
}

.btn7 {
    font-size: 100%;
    margin: 2em 0.1em 2em 0;
    padding: 0.2em 0.5em;
    border: #9aafe5 1px solid;
}

.btn-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    opacity: 0.7;
    vertical-align: middle;
}

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

.d-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: d-spin 3s ease infinite;
}

@keyframes d-spin {
    to { transform: rotate(360deg); }
}

.d-loading {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 4px;
    color: var(--text-2);
    font-size: 14px;
}

/* =========================================================
   6. TABLES
   ========================================================= */

.d-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.d-table thead {
    background: var(--surface-2);
}

.d-table th {
    text-align: left;
    font-size: 13px;
    letter-spacing: .04em;
    text-transform: uppercase;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
}

.d-table td {
    padding: 18px 20px;
    vertical-align: top;
}

.d-table tbody tr + tr {
    border-top: 1px solid var(--border);
}

.d-table td.d-table-actions {
    text-align: right;
    white-space: nowrap;
}

.d-table th.d-table-actions {
    text-align: right;
}

.d-card .d-table {
    border: 1px solid var(--border) !important;
    background: var(--surface) !important;
    box-shadow: none;
}

.d-card .d-table th,
.d-card .d-table td {
    background: var(--surface) !important;
    padding: 18px 20px !important;
}

tr.highlight td {
    background: var(--accent-soft) !important;
}

/* Forum + gold coin tables share the same shell */
.forum-table,
.goldcoin-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border: 1px solid var(--border);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.goldcoin-table {
    border-radius: var(--radius);
}

.forum-table th,
.goldcoin-table th {
    background: var(--surface-2);
    color: var(--text);
    font-weight: 700;
    padding: 14px 18px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.forum-table td,
.goldcoin-table td {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

.forum-table tr:hover,
.goldcoin-table tr:hover {
    background: var(--surface-2);
}

.gold-positive {
    background: var(--green-soft);
    color: var(--green);
    font-weight: 700;
}

.gold-negative {
    background: var(--amber-soft);
    color: var(--amber);
    font-weight: 700;
}

/* =========================================================
   7. QUIZ FEEDBACK STATES
   ========================================================= */

.clicked-row-red td,
.d-clicked-row-red td {
    background-color: var(--amber-soft) !important;
    color: var(--amber) !important;
    border-radius: var(--radius-sm);
    transition: background-color var(--transition), color var(--transition);
}

.clicked-row-green td,
.d-clicked-row-green td {
    background-color: var(--green-soft) !important;
    color: var(--green) !important;
    border-radius: var(--radius-sm);
    transition: background-color var(--transition), color var(--transition);
}

tr.red_highlight {
    animation: red-highlight-shake 0.5s ease-in-out;
    animation-iteration-count: 2;
}

tr.red_highlight td:first-child {
    position: relative;
    padding-left: 26px !important;
}

tr.red_highlight td:first-child::before {
    content: "!";
    position: absolute;
    left: 4px;
    top: 6px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 800;
    line-height: 1;
    color: var(--text);
    animation: red-highlight-pulse 1.2s ease-in-out infinite;
}

@keyframes red-highlight-shake {
    0%, 100% { transform: translateX(0); }
    25%      { transform: translateX(-6px); }
    75%      { transform: translateX(6px); }
}

@keyframes red-highlight-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50%      { transform: scale(1.25); opacity: 0.6; }
}

@media (prefers-reduced-motion: reduce) {
    tr.red_highlight { animation: none; }
    tr.red_highlight td:first-child::before { animation: none; opacity: 1; }
}

/* =========================================================
   8. FEEDBACK / RATING
   ========================================================= */

.d-feedback-stats {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.d-like-box,
.d-dislike-box,
.d-neutral-box {
    flex: 1;
    min-width: 180px;
    padding: 16px;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
    font-weight: 600;
    text-align: center;
    transition: all var(--transition);
}

.d-like-box::before    { content: "👍 "; }
.d-dislike-box::before { content: "👎 "; }

.d-like-box    { border-left: 3px solid var(--accent); }
.d-dislike-box { border-left: 3px solid var(--text-3); }
.d-neutral-box { color: var(--text-2); }

.d-feedback-form h2 {
    margin-bottom: 20px;
    text-align: center;
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
}

.d-rating-options {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.d-rating {
    flex: 1;
    min-width: 200px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    border: 1px solid var(--border);
    transition: all var(--transition);
}

.d-rating:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}

.d-rating input[type="radio"] {
    accent-color: var(--accent);
    transform: scale(1.1);
}

.d-comment-box {
    margin-top: 20px;
}

.d-comment-box label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-3);
    font-weight: 600;
}

.d-comment-box textarea {
    width: 100%;
    min-height: 70px;
    padding: 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    font-family: var(--font), serif;
    resize: vertical;
    transition: border var(--transition);
}

.d-comment-box textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.d-btn-row {
    margin-top: 20px;
    display: flex;
    justify-content: center;
}

/* =========================================================
   9. CARDS, NOTICES, STATS, REWARDS
   ========================================================= */

.d-jcard {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 0;
    margin-bottom: 0;
    transition: background var(--transition), border var(--transition);
}

.d-notice {
    display: flex;
    align-items: flex-start;
    gap: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 28px 32px;
    max-width: 820px;
    margin: 2rem auto;
}

.d-notice-icon {
    flex: 0 0 auto;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--amber-soft);
    display: flex;
    align-items: center;
    justify-content: center;
}

.d-notice-icon i {
    font-size: 28px;
    color: var(--amber);
    line-height: 1;
}

.d-notice-title {
    color: var(--text);
    margin: 0 0 6px;
    letter-spacing: -.01em;
    font-size: clamp(18px, 4.5vw, 25px);
}

.d-notice-body {
    color: var(--text-2);
    margin: 0;
    line-height: 1.6;
    font-size: clamp(15px, 3.8vw, 20px);
}

.d-notice-confirm .d-notice-icon {
    background: rgba(5, 150, 105, .12);
    background: color-mix(in srgb, var(--green) 14%, transparent);
}
.d-notice-confirm .d-notice-icon i {
    color: var(--green);
}

/* --- fluency --- */
.d-fluency img {
    border-radius: 12px;
    width: 100px;
    height: auto;
    object-fit: contain;
}

.d-fluency-card {
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
    text-align: center;
    padding: 24px 20px;
}

.d-fluency-card img {
    width: 120px;
    height: auto;
    display: block;
    margin: 0 auto;
}

.d-fluency-card img.is-final {
    width: 160px;
}

.d-fluency-label {
    display: block;
    margin-top: 20px;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.d-fluency-card img {
    border-radius: 12px;
}

/* --- rewards --- */
.d-rewards {
    display: grid;
    gap: 10px;
    margin: 16px 0;
    max-width: 520px;
}

.d-reward-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 12px;
    padding: 12px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.d-reward-name {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: var(--text);
}

.d-reward-value {
    margin-left: auto;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.d-reward-links {
    display: flex;
    gap: 8px;
}

.d-reward-links a {
    font-size: 13px;
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--accent-text);
    text-decoration: none;
    white-space: nowrap;
}

.d-reward-links a:hover {
    border-color: var(--accent);
    text-decoration: none;
}

/* --- stats --- */
.d-stats-card {
    max-width: 620px;
    margin: 0 auto 24px;
    padding: 24px 26px;
}

.d-stats-card h2 {
    font-size: 20px;
    margin: 0 0 16px;
    color: var(--text);
}

.d-stats-list {
    display: grid;
    gap: 8px;
    margin: 0 0 20px;
}

.d-stat {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.d-stat:last-child {
    border-bottom: 0;
}

.d-stat-label {
    color: var(--text-2);
}

.d-stat-value {
    margin-left: auto;
    font-weight: 700;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.d-stat-value small {
    font-weight: 400;
    color: var(--text-3);
}

.d-stat-link {
    flex: 0 0 auto;
    font-size: 13px;
    white-space: nowrap;
}

.d-stats-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 16px 0;
}

.d-stats-footnote {
    color: var(--text-3);
    font-size: 14px;
    line-height: 1.6;
    margin: 16px 0 0;
}

/* =========================================================
   10. MEDIA (images, video)
   ========================================================= */

.restricted-img {
    display: block;
    width: 100%;
    max-width: 520px;
    height: auto;
    margin: 0 auto;
    border-radius: var(--radius-sm);
}

.d-video {
    position: relative;
    width: 100%;
    max-width: 800px;
    aspect-ratio: 16 / 9;
    margin: 1rem 0;
    background: var(--bg);
    border-radius: var(--radius);
    overflow: hidden;
}

.d-video iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* =========================================================
   11. SEARCH & PAGINATION
   ========================================================= */

#suggested_names {
    width: 100%;
    max-width: 300px;
    min-width: 5px;
    box-sizing: border-box;
}

#hide_or_show_search_results_box {
    color: var(--accent-text);
    background-color: var(--bg);
    z-index: 999999;
}

#hide_or_show_search_results_box a {
    color: var(--accent-text);
}

.pages a,
.pages span.current,
.pages span.dots {
    float: left;
    margin-right: 0.1em;
    padding: 0.2em 0.5em;
}

.pages a,
.pages span.current {
    border: var(--border) 1px solid;
}

.pages span.current {
    text-decoration: underline;
    text-decoration-color: var(--border);
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
}

.pages a:hover {
    border-color: var(--accent);
}

/* =========================================================
   12. TAGGING / PARSING (legacy admin tools)
   ========================================================= */

div.tagging {
    float: left;
    background-color: #ededed;
    font-size: 14pt;
    margin: 1pt;
    height: 60px;
}

div.parse,
div.parse2,
div.parse3,
div.parse4,
div.parse5 {
    float: left;
    border: 1px solid #d7d7d7;
    padding: 0.3em;
}

div.parse  { height: 110px; }
div.parse3 { height: 60px; }
div.parse4 { height: 180px; }
div.parse5 { height: 80px; }

html[data-theme="dark"] div.mousover {
    background-color: var(--bg);
    padding: 20px;
}

/* Tipped.js / tooltip surfaces */
.tpd-content,
.tpd-background-content {
    background: var(--bg) !important;
}

/* =========================================================
   13. READER CONTROLS
   ========================================================= */

#add,
#remove,
#time,
#block,
#known {
    font-size: 20px;
}

#add    { color: #5e962f !important; }
#remove { color: #fb5656 !important; }
#block  { color: #cc66cc !important; }
#known  { color: var(--accent) !important; }

/* =========================================================
   14. LEGACY TYPOGRAPHY & UTILITIES
   ========================================================= */

h1 { font-size: 25px; }

.header_type_1 { font-size: 25px; }
.header_type_2 { font-size: 1.3em; }
.header_type_3 { font-family: Verdana, serif; font-size: 16px; }
.header_type_4 { font-size: 20px; }

.header_faq {
    font-family: Verdana, serif;
    font-size: 17px;
    font-weight: bold;
    border-left: 4px solid;
    padding-left: 8px;
}

.form_header {
    margin-bottom: 0.6em;
    font-weight: 800;
    font-size: 18px;
}

.level {
    font-family: "Open Sans", Verdana, sans-serif;
    font-size: 17px;
    color: var(--text-2);
}

/* Font-size utilities */
.fs60 { font-size: 60px; }
.fs50 { font-size: 50px; }
.fs40 { font-size: 40px; }
.fs35 { font-size: 35px; }
.fs30 { font-size: 30px; }
.fs28 { font-size: 28px; }
.fs26 { font-size: 26px; }
.fs25 { font-size: 25px; }
.fs24 { font-size: 24px; }
.fs23 { font-size: 23px; }
.fs22 { font-size: 22px; }
.fs20 { font-size: 20px; }
.fs19 { font-size: 19px; }
.fs18 { font-size: 18px; }
.fs17 { font-size: 17px; }
.fs16 { font-size: 16px; }
.fs15 { font-size: 15px; }
.fs14 { font-size: 14px; }

/* Arrows */
.arrow-up-green,
.arrow-down-green,
.arrow-up-red,
.arrow-down-red {
    display: inline-block;
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
}

.arrow-up-green   { border-bottom: 10px solid #00C92F; }
.arrow-down-green { border-top: 10px solid #00C92F; }
.arrow-up-red     { border-bottom: 10px solid #EB465C; }
.arrow-down-red   { border-top: 10px solid #EB465C; }

/* =========================================================
   15. RESPONSIVE (largest to smallest)
   ========================================================= */

@media (min-width: 800px) {
    .search { display: block; }
}

@media (max-width: 1000px) {
    #menu1 .menu-text,
    #switchlanglink  {
        display: none;
    }
}

@media (max-width: 900px) {
    .list_overview { display: none; }
}

@media (max-width: 800px) {
    /* Only the toggle inside the nav bar hides; standalone
       toggles (e.g. #themeToggle2) stay visible */
    .topbar .theme-toggle { display: none; }
}

/* --- 640px: two separate table-stacking strategies --- */
@media (max-width: 640px) {
    /* A. plain .d-table -> block rows, centred */
    .d-table,
    .d-table tbody,
    .d-table tr,
    .d-table td {
        display: block;
        width: auto !important;
    }

    .d-table tr {
        margin-bottom: .75rem;
        text-align: center;
    }

    .d-table .d-btn {
        display: block;
        min-height: 2.75rem;
    }

    /* B. .d-table--stack -> card rows with a 2-up button line */
    .d-table--stack,
    .d-table--stack tbody {
        display: block;
        width: 100%;
    }

    .d-table--stack tr {
        display: flex;
        flex-wrap: wrap;
        gap: .5rem;
        padding: .75rem;
        margin-bottom: .75rem;
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        background: var(--surface);
        text-align: left;
    }

    .d-table--stack td {
        display: block;
        padding: 0;
        border: 0;
    }

    .d-table--stack td:nth-child(1) {
        flex: 0 0 100%;
        font-weight: 600;
    }

    .d-table--stack td:nth-child(2),
    .d-table--stack td:nth-child(3) {
        flex: 1 1 0;
        min-width: 0;
    }

    .d-table--stack td:nth-child(4) {
        flex: 0 0 100%;
        font-size: .875rem;
        opacity: .8;
    }

    .d-table--stack .d-btn {
        display: block;
        width: 100%;
        text-align: center;
        box-sizing: border-box;
    }
}

@media (max-width: 560px) {
    .d-reward-links { flex: 1 0 100%; }
    .d-reward-row   { padding: 10px 12px; }
}

@media (max-width: 480px) {
    .container { padding: 0; }

    .card {
        padding: 4px;
        border: 0;
    }

    .d-notice {
        gap: 12px;
        padding: 18px 16px;
        margin: 1rem auto;
        border-radius: var(--radius-sm);
    }

    .d-notice-icon {
        width: 32px;
        height: 32px;
    }

    .d-notice-icon i { font-size: 18px; }

    .d-fluency-card { padding: 18px 14px; }

    .d-stats-card { padding: 18px 16px; }

    .d-stat-value {
        margin-left: 0;
        flex: 1 0 100%;
    }

    .d-stats-actions .d-btn {
        flex: 1 1 100%;
        margin: 0;
        text-align: center;
    }

    .adv-section-label {
        font-size: 1.15rem;
        margin: 12px 0 10px;
        letter-spacing: 0.03em;
    }

    /* was height:170px -- clipped once text reflowed narrow */

    .d-loading      { font-size: 20px; }
    .header_nav     { font-size: 20px; }
    .lang           { font-size: 20px; }
    .form_header    { font-size: 16px; }
    .header_faq     { font-size: 15px; }
    .header_type_3  { font-size: 15px; }
    .level          { font-size: 15px; }

    /* Reader controls: thumb-sized targets */
    #add, #remove, #time, #block, #known {
        font-weight: 700;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }

    /* font-size does nothing to a radio or checkbox: size the control */
    input[type="radio"],
    input[type="checkbox"] {
        width: 22px;
        height: 22px;
        accent-color: var(--accent);
    }
}

/* =========================================================
   15b. MOBILE TOPBAR — one row, smaller logo + ring,
        language switcher stays, collapse button hidden
   ========================================================= */
@media (max-width: 1000px) {

    .topbar-inner {
        gap: 8px;
        padding: 8px 12px;
    }

    /* Smaller logo (overrides width="70") */
    .topbar .logo-light,
    .topbar .logo-dark {
        width: 40px;
        height: auto;
    }

    /* Smaller fluency ring */
    .topbar .ring-wrap {
        width: 42px;
        height: 42px;
    }
    .topbar .ring-wrap svg {
        width: 42px;
        height: 42px;
    }
    .topbar .ring-label {
        font-size: 10px !important;
    }

    /* Force the language switcher to stay visible with flag + name */
    #switchlanglink {
        display: inline-flex !important;
        align-items: center;
        gap: 6px;
        min-width: 0;
    }
    #switchlanglink .project-flag { flex: 0 0 auto; }
    #switchlanglink .project-text {
        display: inline !important;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        max-width: 120px;
    }

    /* Hide the collapse button on mobile (already effectively collapsed) */
    #navHide {
        display: none !important;
    }
}wwww

/* =========================================================
   GOLDCOIN RANKING
   Append to css-style-tidy.css (section 6 area).
   Builds on the existing .goldcoin-table shell.
   ========================================================= */

.gc-intro {
    margin: 0 0 16px;
    color: var(--text-2);
}

/* Safety net: if the table ever exceeds its container it scrolls
   sideways instead of pushing the whole page wide. */
.gc-wrap {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.goldcoin-table.gc-rank {
    width: 100%;
    min-width: 0;
}

/* Column sizing: username takes the slack, everything else is tight */
.gc-rank .gc-col-rank   { width: 64px; text-align: center; }
.gc-rank .gc-col-coins  { width: 110px; }
.gc-rank .gc-col-pct    { width: 100px; }
.gc-rank .gc-col-animal { width: 150px; }

.gc-rank .gc-cell-rank {
    text-align: center;
    vertical-align: middle;
}

.gc-rank .gc-cell-coins,
.gc-rank .gc-cell-pct {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.gc-rank .gc-cell-name {
    overflow-wrap: anywhere;
}

.gc-medal {
    font-size: 24px;
    line-height: 1;
}

.gc-num {
    font-size: 16px;
    color: var(--text-2);
    font-variant-numeric: tabular-nums;
}

.gc-num::after {
    content: ".";
}

.gc-animal {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: inherit;
}

.gc-animal img {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: block;
    flex: 0 0 auto;
}

.gc-animal:hover {
    text-decoration: none;
}

.gc-animal:hover .gc-animal-name {
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* --- Mobile: one card per player, no horizontal scroll --------------- */

@media (max-width: 640px) {

    .gc-wrap {
        overflow-x: visible;
    }

    .goldcoin-table.gc-rank,
    .gc-rank tbody {
        display: block;
        box-shadow: none;
    }

    .gc-rank thead {
        display: none;
    }

    .gc-rank tr {
        display: grid;
        grid-template-columns: 2.25rem auto minmax(0, 1fr) 44px;
        grid-template-areas:
            "rank name  name   animal"
            "rank coins pct    animal";
        align-items: center;
        gap: 2px 10px;
        padding: 10px 12px;
        border-bottom: 1px solid var(--border);
    }

    .gc-rank td {
        display: block;
        padding: 0;
        border: 0;
        min-width: 0;
    }

    .gc-rank .gc-cell-rank   { grid-area: rank; }
    .gc-rank .gc-cell-name   { grid-area: name; font-weight: 600; }
    .gc-rank .gc-cell-coins  { grid-area: coins; }
    .gc-rank .gc-cell-pct    { grid-area: pct; }
    .gc-rank .gc-cell-animal { grid-area: animal; }

    .gc-rank .gc-cell-coins,
    .gc-rank .gc-cell-pct {
        font-size: 14px;
        color: var(--text-2);
    }

    .gc-rank .gc-cell-coins::before {
        content: "🟡 ";
    }

    /* The image alone carries the animal on small screens */
    .gc-animal-name {
        display: none;
    }

    .gc-medal { font-size: 20px; }
    .gc-num   { font-size: 14px; }

    /* Highlight the whole card rather than each cell */
    .gc-rank tr.highlight {
        background: var(--accent-soft);
    }

    .gc-rank tr.highlight td {
        background: transparent !important;
    }
}

/* =========================================================
   LANGUAGE SWITCHER TABLE (.d-langtable)
   Append to css-style-tidy.css after section 6.
   Fallback values are supplied so the legacy theme, which may
   not define the d- tokens, still renders sensibly.
   ========================================================= */

.d-langtable .lt-lang {
    display: block;
    font-size: 1.3em;
    font-weight: 600;
    color: var(--text, #222);
    line-height: 1.3;
}

.d-langtable .lt-level {
    display: block;
    margin-top: 4px;
    font-size: 14px;
    color: var(--text-2, #666);
}

/* Column header carries this on desktop, so the inline label is hidden */
.d-langtable .lt-label {
    display: none;
    font-size: 13px;
    color: var(--text-3, #888);
    margin-bottom: 2px;
}

.d-langtable .lt-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 999px;
    background: var(--green-soft, #e7f5ec);
    color: var(--green, #2b7a3d);
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
}

.d-langtable .lt-status::before {
    content: "●";
    font-size: 9px;
    line-height: 1;
}

.d-langtable .lt-btns {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

/* Cancels the global .d-btn { margin: 10px } so the gap does the spacing */
.d-langtable .lt-btn {
    margin: 0;
}

.d-langtable .lt-btn-quiet {
    opacity: .85;
}

.d-langtable .lt-btn-quiet:hover {
    opacity: 1;
}

/* --- Mobile: one card per language pair ------------------------------ */
/* Selectors are doubled up (.d-table.d-langtable) so they outrank the
   generic .d-table stacking rules in section 15. */

@media (max-width: 640px) {

    .d-table.d-langtable,
    .d-table.d-langtable tbody {
        display: block;
        border: 0;
        box-shadow: none;
        background: none;
    }

    .d-table.d-langtable thead {
        display: none;
    }

    .d-table.d-langtable tr {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        gap: 12px;
        padding: 16px;
        margin: 0 0 12px;
        text-align: left;
        border: 1px solid var(--border, #ddd);
        border-radius: var(--radius-sm, 8px);
        background: var(--surface, #fff);
    }

    .d-table.d-langtable tr + tr {
        border-top: 1px solid var(--border, #ddd);
    }

    .d-table.d-langtable td {
        display: block;
        width: auto;
        padding: 0;
        border: 0;
        text-align: left;
    }

    .d-table.d-langtable .lt-label {
        display: block;
    }

    .d-table.d-langtable .lt-explain .lt-lang {
        font-size: 1.1em;
        font-weight: 500;
    }

    /* Buttons go full width and share the row evenly */
    .d-table.d-langtable .lt-btns {
        justify-content: stretch;
    }

    .d-table.d-langtable .lt-btn {
        flex: 1 1 0;
        min-width: 0;
        display: block;
        min-height: 2.75rem;
        line-height: 2.75rem;
        padding: 0 12px;
        text-align: center;
        box-sizing: border-box;
    }

    /* Active row gets a quiet accent edge instead of a filled cell */
    .d-table.d-langtable tr.is-active {
        border-left: 3px solid var(--accent, #2b7a3d);
    }
}

@media (max-width: 380px) {
    .d-table.d-langtable .lt-btns {
        flex-direction: column;
    }
}

.d-notice-email {
    font-size: 1.375rem;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 var(--space-3, 0.75rem);
    word-break: break-all;
}

.d-notice p { margin: 0 0 var(--space-3, 0.75rem); }
.d-notice p:last-child { margin-bottom: 0; }



.d-notice a:not(.d-btn) {
    color: var(--link, var(--text));
    text-decoration: underline;
    text-underline-offset: 0.15em;
    text-decoration-thickness: 1px;
}

.d-notice a:not(.d-btn):hover {
    text-decoration-thickness: 2px;
}

/* =========================================================
   16. FORMS (d-)
   ========================================================= */

.d-form {
    max-width: 720px;
    margin: 0 auto 24px;
    padding: 24px 26px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.d-form-group {
    margin-bottom: 20px;
}

.d-form-group:last-of-type {
    margin-bottom: 0;
}

.d-form--left {
    margin-left: 0;
    margin-right: 0;
}

/* intro line above the first .d-form-group */
.d-form-intro {
    margin: 0 0 20px;
    color: var(--text-2);
    font-size: 16px;
    line-height: 1.5;
}

.d-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 700;
    font-size: 18px;
    color: var(--text);
}

.d-input {
    width: 100%;
    box-sizing: border-box;
    padding: 12px 14px;
    font-family: var(--font), serif;
    font-size: 18px;
    color: var(--text);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: border-color var(--transition);
}

textarea.d-input {
    min-height: 90px;
    resize: vertical;
    line-height: 1.5;
}

.d-input:focus {
    outline: none;
    border-color: var(--accent);
}

.d-input:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.d-input::placeholder {
    color: var(--text-3);
}

.d-input[type="file"] {
    padding: 10px;
    background: none;
}

select.d-input {
    width: auto;
    min-width: 160px;
}

.d-form-inline,
.d-form-options {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.d-form-options {
    gap: 10px 18px;
    align-items: center;
}

.d-form-options label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.d-form-options input[type="radio"],
.d-form-options input[type="checkbox"] {
    accent-color: var(--accent);
}

.d-form-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

/* Cancels the global .d-btn { margin: 10px } so the gap does the spacing */
.d-form-actions .d-btn,
.d-form-actions input[type="submit"] {
    margin: 0;
}

.d-form-current {
    font-weight: 600;
    color: var(--text-2);
}

/* --- error state --- */

.d-form-group--error .d-input {
    border-color: var(--red, #EB465C);
}

.d-form-group--error .d-label {
    color: var(--red, #EB465C);
}

@media (max-width: 480px) {
    .d-form {
        padding: 18px 16px;
        border-radius: var(--radius-sm);
    }

    .d-label { font-size: 16px; }

    /* 16px minimum stops iOS zooming the page on focus */
    .d-input { font-size: 16px; }

    select.d-input { width: 100%; }

    .d-form-actions .d-btn,
    .d-form-actions input[type="submit"] {
        flex: 1 1 100%;
        text-align: center;
    }
}

/* =========================================================
   16b. SUBMIT BUTTON (.d-btn-submit)
   Generated by generate_submit_button(). Replaces the old
   .d-btn-submit block after section 16.
   ========================================================= */

.d-btn-submit {
    min-width: 220px;
    justify-content: center;
    text-align: center;
    white-space: normal;      /* long labels wrap instead of overflowing */
    box-sizing: border-box;
}

.d-btn-submit.d-btn--lg {
    min-width: 280px;
    padding: 14px 28px;
    font-size: 19px;
}

@media (max-width: 480px) {
    .d-btn-submit {
        min-width: 0;
        width: 100%;
        margin: 10px 0;       /* keeps vertical rhythm, kills the 20px
                                 horizontal overflow from .d-btn margin */
        min-height: 44px;     /* thumb-sized target */
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .d-btn-submit.d-btn--lg {
        min-width: 0;
        padding: 12px 20px;
        font-size: 17px;
    }

    /* status span: own centred line above a full-width button */
    .btn-status {
        display: block;
        text-align: center;
        margin-bottom: 4px;
    }

    .btn-status:empty { display: none; }
}

.cc-found {
    display: flex;
    flex-wrap: wrap;
    gap: var(--d-space-4, 1rem);
    padding: var(--d-space-4, 1rem);
    align-items: flex-start;
}

.cc-found__media {
    flex: 0 0 175px;
    text-align: center;
    margin-inline: auto;
}

.cc-found__media img {
    width: 175px;
    max-width: 100%;
    height: auto;
    border-radius: var(--d-radius-sm, 4px);
}

.cc-found__caption {
    margin-top: .5rem;
    font-size: .875rem;
    color: var(#e3d5d5);
}

.cc-found__body {
    flex: 1 1 260px;
    font-size: 1.125rem;
    line-height: 1.5;
}

.cc-found__body p { margin: 0 0 1rem; }
.cc-found__body p:last-child { margin-bottom: 0; }

@media (max-width: 480px) {
    .cc-found { text-align: center; }
    .cc-found__body { font-size: 1rem; }
}

/* ============================================================
  REWARD CARD
  ============================================================ */

.reward-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 18px 20px;
    text-align: center;
}

/* --- eyebrow --- */

.reward-card .reward-eyebrow {
    display: block;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-3);
    margin: 0;
}

/* --- action row: main button + thumbs --- */

.reward-card .reward-action {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
}

/* margin: 0 cancels the global .d-btn { margin: 10px } from section 5 */
.reward-card .reward-main {
    flex: 0 1 auto;
    margin: 0;
    min-height: 44px;
    max-width: 100%;
}

/* --- thumbs --- */

.reward-card .reward-thumbs {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.reward-card .reward-thumbs.is-sending {
    opacity: .55;
    pointer-events: none;
}

.reward-card .reward-thumb {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 10px;
    transition: transform var(--transition), border-color var(--transition);
}

.reward-card .reward-thumb:hover {
    transform: translateY(-2px);
    border-color: var(--accent);
}

.reward-card .reward-thumb:active {
    transform: translateY(0) scale(.94);
}

.reward-card .reward-thumb:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.reward-card .reward-thumb.is-chosen {
    border-color: var(--accent);
}

/* --- post-rating stats --- */

.reward-card .reward-stats {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    width: 100%;
    max-width: 320px;
    animation: reward-stats-in .35s ease both;
}

.reward-card .reward-stats-top {
    display: flex;
    align-items: center;
    gap: 8px;
}

.reward-card .reward-stats-face {
    font-size: 24px;
    line-height: 1;
    animation: reward-pop .45s cubic-bezier(.34, 1.56, .64, 1) both;
}

.reward-card .reward-stats-text {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.reward-card .reward-stats-pct {
    font-size: 20px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--accent-text);
}

.reward-card .reward-stats-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-2);
}

.reward-card .reward-meter {
    width: 100%;
    height: 8px;
    border-radius: 999px;
    overflow: hidden;
    background: var(--border);
}

.reward-card .reward-meter-fill {
    height: 100%;
    border-radius: 999px;
    background: var(--accent);
    transition: width .9s cubic-bezier(.22, 1, .36, 1);
}

.reward-card .reward-stats-count {
    font-size: 12px;
    color: var(--text-3);
}

.reward-card .reward-thanks-err {
    font-size: 13px;
    font-weight: 600;
    color: var(--danger, #b91c1c);
}

@keyframes reward-stats-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: none; }
}

@keyframes reward-pop {
    0%   { transform: scale(.4) rotate(-12deg); opacity: 0; }
    100% { transform: scale(1) rotate(0); opacity: 1; }
}

/* --- bonus pills --- */

.reward-card .reward-bonus {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 2px;
}

.reward-card .reward-bonus-label {
    font-size: 13px;
    color: var(--text-2);
    margin-right: 2px;
}

.reward-card .reward-pill {
    font-size: 13px;
    line-height: 1.4;
    padding: 5px 11px;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--accent-text);
    white-space: nowrap;
    text-decoration: none;
    transition: border-color var(--transition);
}

.reward-card .reward-pill:hover {
    border-color: var(--accent);
    text-decoration: none;
}

/* --- footer --- */

.reward-card .reward-foot {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 4px 16px;
    width: 100%;
    margin-top: 2px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-3);
}

.reward-card .reward-foot a {
    color: var(--text-3);
}

.reward-card .reward-foot a:hover {
    color: var(--accent-text);
}

/* --- mobile --- */

@media (max-width: 480px) {
    .reward-card {
        padding: 16px 14px;
    }

    /* section 15 sets .card { padding: 4px; border: 0 } at this width;
       .reward-card is a .d-card, so it keeps its own padding */

    .reward-card .reward-main {
        flex: 1 1 100%;
        width: 100%;
        justify-content: center;
    }

    .reward-card .reward-thumbs {
        width: 100%;
    }

    .reward-card .reward-bonus {
        gap: 6px 5px;
    }

    .reward-card .reward-pill {
        padding: 6px 12px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .reward-card .reward-thumb,
    .reward-card .reward-meter-fill {
        transition: none;
    }

    .reward-card .reward-thumb:hover,
    .reward-card .reward-thumb:active {
        transform: none;
    }

    .reward-card .reward-stats,
    .reward-card .reward-stats-face {
        animation: none;
    }
}

.d-dow { border: 0; margin: 0; }
.d-dow__legend { font-weight: 600; padding: 0 .25rem; }

.d-dow__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(115px, 1fr));
    gap: .5rem;
}

.d-dow__day {
    display: flex;
    align-items: center;
    gap: .5rem;
    min-height: 44px;
    padding: .5rem .75rem;
    border: 1px solid var(--border, #d5d5d5);
    border-radius: var(--radius, 8px);
    background: var(--surface, #fff);
    cursor: pointer;
    user-select: none;
}

.d-dow__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
    gap: .5rem;
    align-items: stretch;
}

.d-dow__day span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.d-dow__day input { width: 1.15rem; height: 1.15rem; margin: 0; flex: none; accent-color: var(--accent, #4a6fa5); }
.d-dow__day:has(input:checked) { border-color: var(--accent, #4a6fa5); background: var(--accent-soft, rgba(74,111,165,.1)); }
.d-dow__day:focus-within { outline: 2px solid var(--accent, #4a6fa5); outline-offset: 2px; }

/* =========================================================
   HEARTS RANKING (.hc-rank)
   Reuses the .goldcoin-table shell, minus the animal column.
   ========================================================= */

.hc-rank .hc-col-rank   { width: 64px; text-align: center; }
.hc-rank .hc-col-hearts { width: 110px; }
.hc-rank .hc-col-pct    { width: 110px; }

.hc-rank .hc-cell-rank {
    text-align: center;
    vertical-align: middle;
}

.hc-rank .hc-cell-hearts,
.hc-rank .hc-cell-pct {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.hc-rank .hc-cell-name {
    overflow-wrap: anywhere;
}

/* --- Mobile: one card per user --- */

@media (max-width: 640px) {

    .goldcoin-table.hc-rank,
    .hc-rank tbody {
        display: block;
        box-shadow: none;
    }

    .hc-rank thead { display: none; }

    .hc-rank tr {
        display: grid;
        grid-template-columns: 2.25rem auto minmax(0, 1fr);
        grid-template-areas:
            "rank name   name"
            "rank hearts pct";
        align-items: center;
        gap: 2px 10px;
        padding: 10px 12px;
        border-bottom: 1px solid var(--border);
    }

    .hc-rank td {
        display: block;
        padding: 0;
        border: 0;
        min-width: 0;
    }

    .hc-rank .hc-cell-rank   { grid-area: rank; }
    .hc-rank .hc-cell-name   { grid-area: name; font-weight: 600; }
    .hc-rank .hc-cell-hearts { grid-area: hearts; }
    .hc-rank .hc-cell-pct    { grid-area: pct; }

    .hc-rank .hc-cell-hearts,
    .hc-rank .hc-cell-pct {
        font-size: 14px;
        color: var(--text-2);
    }

    .hc-rank .hc-cell-hearts::before { content: "❤️ "; }

    .hc-rank tr.highlight { background: var(--accent-soft); }
    .hc-rank tr.highlight td { background: transparent !important; }
}


/* =========================================================
   ESSAY / HEARTS LIST (.d-hearts)
   Builds on .d-table--stack from section 15.
   ========================================================= */

@media (max-width: 640px) {

    /* section 15 stacks the rows but leaves the header row behind */
    .d-table--stack thead { display: none; }

    /* .d-btn carries margin:10px from section 5; with width:100% that
       overflows the card by 20px */
    .d-table--stack .d-btn { margin: 0; }

    /* date gets its own line instead of sharing with the button */
    .d-table.d-hearts td:nth-child(2) {
        flex: 0 0 100%;
        font-size: .875rem;
        color: var(--text-2);
    }

    .d-table.d-hearts td.d-table-actions {
        flex: 0 0 100%;
        text-align: left;
    }

    /* display:flex restores the centring that display:block killed */
    .d-table.d-hearts .d-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        min-height: 44px;
        padding: 0 16px;
        font-size: 15px;
    }
}

/* =========================================================
   COLLECTIBLE CARDS (.cc-)
   Append to css-style-all-new.css. Uses the shared tokens
   only, so it inherits both css-style-2 and css-style-3.
   ========================================================= */

.cc-intro {
    margin: 0 0 20px;
    color: var(--text-2);
    max-width: 60ch;
}

/* --- summary strip --- */

.cc-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 24px;
    padding: 20px 24px;
}

.cc-summary-stat {
    flex: 1 1 120px;
    min-width: 0;
}

.cc-summary-num {
    display: block;
    font-size: 26px;
    font-weight: 800;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
}

.cc-summary-lbl {
    display: block;
    margin-top: 2px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-3);
}

/* --- set header --- */

.cc-set {
    padding: 22px 24px;
}

.cc-set-head {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 6px 12px;
    margin-bottom: 12px;
}

.cc-set-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    margin: 0;
}

.cc-set-name {
    color: var(--text-2);
    font-weight: 600;
}

.cc-set-count {
    margin-left: auto;
    font-size: 13px;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 999px;
    border: 1px solid var(--border);
    color: var(--text-2);
    white-space: nowrap;
}

.cc-set-count.is-complete {
    background: var(--green-soft);
    border-color: transparent;
    color: var(--green);
}

/* --- progress meter --- */

.cc-meter {
    height: 6px;
    margin-bottom: 18px;
    border-radius: 999px;
    background: var(--border);
    overflow: hidden;
}

.cc-meter-fill {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: var(--accent);
    transition: width .9s cubic-bezier(.22, 1, .36, 1);
}

/* --- card grid --- */

.cc-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.cc-tile {
    margin: 0;
    padding: 10px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    text-align: center;
    transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.cc-tile:hover {
    transform: translateY(-2px);
    border-color: var(--accent);
    box-shadow: var(--shadow);
}

.cc-tile-link {
    display: block;
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.cc-tile-link:hover {
    text-decoration: none;
}

.cc-tile img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: var(--radius-sm);
}

.cc-tile-cap {
    display: flex;
    align-items: baseline;
    justify-content: center;
    flex-wrap: wrap;
    gap: 2px 8px;
    margin-top: 8px;
    font-size: 13px;
}

.cc-tile-name {
    font-weight: 600;
    color: var(--text);
}

.cc-tile-count {
    color: var(--accent-text);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* --- not yet found --- */

.cc-tile--missing {
    border-style: dashed;
}

.cc-tile--missing img {
    opacity: .45;
    filter: grayscale(1);
}

.cc-tile--missing:hover {
    transform: none;
    border-color: var(--border);
    box-shadow: none;
}

.cc-tile--missing .cc-tile-name,
.cc-tile--missing .cc-tile-count {
    color: var(--text-3);
    font-weight: 600;
}

/* --- mobile --- */

@media (max-width: 640px) {
    .cc-set {
        padding: 16px 14px;
    }

    .cc-grid {
        gap: 8px;
    }

    .cc-tile {
        padding: 6px;
    }

    .cc-tile-cap {
        margin-top: 6px;
        font-size: 12px;
    }

    .cc-summary {
        padding: 16px 14px;
        gap: 10px;
    }

    .cc-summary-stat {
        flex: 1 1 40%;
    }

    .cc-summary-num {
        font-size: 22px;
    }

    .cc-set-count {
        margin-left: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .cc-tile,
    .cc-meter-fill {
        transition: none;
    }

    .cc-tile:hover {
        transform: none;
    }
}

/* =========================================================
   17. HELP INDEX (.d-help-grid)
   Widens the generic .d-actions grid so each card can carry
   a title plus a description line without cramping.
   ========================================================= */

.d-actions.d-help-grid {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 12px;
}

.d-help-grid .d-action {
    min-height: 44px;
    justify-content: flex-start;
}

.d-help-title {
    font-size: 17px;
    font-weight: 700;
    line-height: 1.3;
}

.d-help-desc {
    font-size: 14px;
    font-weight: 400;
    line-height: 1.45;
    color: var(--text-2);
}

@media (max-width: 480px) {
    .d-actions.d-help-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .d-help-title { font-size: 16px; }
    .d-help-desc  { font-size: 14px; }
}

/* =========================================================
   18. GUESS-THE-LANGUAGE RANKING (.gl-rank)
   Reuses the .goldcoin-table shell and the .gc-wrap
   overflow guard from the goldcoin section.
   ========================================================= */

.gl-rank .gl-col-total,
.gl-rank .gl-col-correct { width: 130px; }

.gl-rank .gl-col-pct     { width: 110px; }
.gl-rank .gl-col-score   { width: 130px; }

.gl-rank .gl-cell-name {
    overflow-wrap: anywhere;
}

.gl-rank .gl-cell-total,
.gl-rank .gl-cell-correct,
.gl-rank .gl-cell-pct,
.gl-rank .gl-cell-score {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* --- Mobile: one card per player, no horizontal scroll --- */

@media (max-width: 640px) {

    .goldcoin-table.gl-rank,
    .gl-rank tbody {
        display: block;
        box-shadow: none;
    }

    .gl-rank thead { display: none; }

    .gl-rank tr {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        grid-template-areas:
            "name    name"
            "score   pct"
            "total   correct";
        gap: 4px 12px;
        padding: 12px;
        border-bottom: 1px solid var(--border);
    }

    .gl-rank td {
        display: block;
        padding: 0;
        border: 0;
        min-width: 0;
        white-space: normal;
    }

    .gl-rank .gl-cell-name {
        grid-area: name;
        font-weight: 600;
        font-size: 17px;
        margin-bottom: 2px;
    }

    .gl-rank .gl-cell-score   { grid-area: score; }
    .gl-rank .gl-cell-pct     { grid-area: pct; }
    .gl-rank .gl-cell-total   { grid-area: total; }
    .gl-rank .gl-cell-correct { grid-area: correct; }

    .gl-rank .gl-cell-score,
    .gl-rank .gl-cell-pct,
    .gl-rank .gl-cell-total,
    .gl-rank .gl-cell-correct {
        font-size: 14px;
        color: var(--text-2);
    }

    /* inline labels replace the hidden header row */
    .gl-rank .gl-cell-score::before   { content: "Score: "; color: var(--text-3); }
    .gl-rank .gl-cell-pct::before     { content: "Accuracy: "; color: var(--text-3); }
    .gl-rank .gl-cell-total::before   { content: "Guesses: "; color: var(--text-3); }
    .gl-rank .gl-cell-correct::before { content: "Correct: "; color: var(--text-3); }

    .gl-rank .gl-cell-score {
        font-weight: 700;
        color: var(--accent-text);
    }

    /* highlight the whole card rather than each cell */
    .gl-rank tr.highlight { background: var(--accent-soft); }
    .gl-rank tr.highlight td { background: transparent !important; }
}


/* =========================================================
   19. SEARCH RESULTS (.sr-) & WORD LIST (.wl-)
   Replaces the legacy .pastel result tables on
   show-words.php. Uses existing tokens only.
   ========================================================= */

.sr-heading {
    font-size: clamp(20px, 5vw, 25px);
    margin: 0 0 12px;
    overflow-wrap: anywhere;
}

.sr-lead {
    margin: 0 0 12px;
    color: var(--text-2);
}

.sr-sublabel {
    margin: 0 0 10px;
    color: var(--text-2);
    font-size: 15px;
}

.sr-block {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

/* .d-btn carries margin:10px from section 5; the row gap does the
   spacing instead, otherwise buttons overflow narrow cards */
.sr-btn-row .d-btn,
.sr-actions .d-btn,
.wl-side .d-btn,
.sr-nohits .d-btn,
.sr-admin .d-btn {
    margin: 0;
}

/* --- result rows --- */

.sr-list {
    list-style: none;
    margin: 0 0 20px;
    padding: 0;
    display: grid;
    gap: 10px;
}

.sr-item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 16px;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    transition: border-color var(--transition);
}

.sr-item:hover {
    border-color: var(--accent);
}

.sr-link {
    display: flex;
    flex: 1 1 240px;
    min-width: 0;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 2px 12px;
    color: inherit;
    text-decoration: none;
}

.sr-link:hover {
    text-decoration: none;
}

.sr-link:hover .sr-title {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.sr-title {
    font-weight: 600;
    color: var(--text);
    overflow-wrap: anywhere;
}

.sr-count,
.sr-trans {
    font-size: 14px;
    color: var(--text-2);
    overflow-wrap: anywhere;
}

.sr-count {
    white-space: nowrap;
    font-weight: 600;
}

.sr-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.sr-item--word .sr-link {
    flex-direction: column;
    gap: 4px;
}

/* --- AI explanation panels injected by JS --- */

.sr-explain {
    padding: 12px 14px;
    margin-top: 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.sr-error {
    margin-top: 12px;
    color: var(--amber);
    font-style: italic;
}

/* --- CJK / JP script spans --- */

.sr-trad { font-family: PMingLiU, serif; }
.sr-simp { font-family: SimSun, serif; color: var(--green); }
.sr-jp   { font-family: Meiryo, serif; }
.sr-kana { color: var(--amber); }

/* --- admin block --- */

.sr-admin .d-form {
    margin-left: 0;
    margin-right: 0;
}

.sr-dict-links {
    margin-top: 16px;
    overflow-wrap: anywhere;
}

/* --- word list --- */

.wl-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 12px;
}

.wl-item {
    display: flex;
    flex-wrap: wrap;
    gap: 16px 20px;
    padding: 18px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.wl-main {
    flex: 1 1 300px;
    min-width: 0;
    overflow-wrap: anywhere;
}

.wl-side {
    flex: 0 0 160px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-align: center;
}

.wl-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
}

.wl-meta {
    font-size: 14px;
    color: var(--text-2);
}

.wl-admin {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.wl-admin .d-btn-row {
    margin-top: 0;
    margin-bottom: 8px;
}

/* --- mobile --- */

@media (max-width: 640px) {

    .sr-item {
        padding: 12px 14px;
    }

    .sr-actions {
        flex: 1 1 100%;
        margin-left: 0;
    }

    .sr-actions .d-btn {
        flex: 1 1 0;
        min-width: 0;
        min-height: 44px;
        justify-content: center;
        text-align: center;
    }

    .sr-btn-row .d-btn {
        flex: 1 1 auto;
        min-height: 44px;
        justify-content: center;
    }

    .wl-item {
        padding: 14px;
        gap: 12px;
    }

    .wl-side {
        flex: 1 1 100%;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        align-items: center;
        gap: 10px 14px;
        padding-top: 12px;
        border-top: 1px solid var(--border);
    }

    .wl-side .d-btn {
        min-height: 44px;
        justify-content: center;
    }

    .wl-meta {
        display: none;
    }

}

@media (max-width: 380px) {

    .sr-actions .d-btn {
        flex: 1 1 100%;
    }
}

/* =========================================================
   20. FORUM LIST (.fm-)
   Replaces the legacy .pastel thread tables on forum.php.
   Uses existing tokens only.
   ========================================================= */

.fm-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 0 0 20px;
}

/* .d-btn carries margin:10px from section 5; the gap does the spacing */
.fm-toolbar .d-btn,
.fm-actions .d-btn {
    margin: 0;
}

.fm-list {
    display: grid;
    gap: 16px;
}

.fm-thread {
    margin-bottom: 0;
    padding: 20px 22px;
}

.fm-title {
    font-size: clamp(18px, 4.2vw, 22px);
    font-weight: 700;
    line-height: 1.3;
    margin: 0 0 8px;
    overflow-wrap: anywhere;
}

.fm-title a {
    color: var(--text);
    text-decoration: none;
}

.fm-title a:hover {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.fm-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 12px;
    margin: 0 0 12px;
    font-size: 14px;
    color: var(--text-2);
}

.fm-meta strong,
.fm-meta a {
    font-weight: 600;
}

.fm-date,
.fm-lang {
    color: var(--text-3);
}

.fm-lang {
    font-style: italic;
}

.fm-text {
    line-height: 1.6;
    overflow-wrap: anywhere;
}

.fm-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.fm-new {
    font-size: 14px;
    font-weight: 600;
    color: var(--accent-text);
}

.fm-del {
    margin-left: auto;
    color: var(--amber);
    border-color: var(--amber);
}

.fm-del:hover {
    color: var(--amber);
    border-color: var(--amber);
    filter: brightness(1.1);
}

@media (max-width: 480px) {
    .fm-thread {
        padding: 16px 14px;
    }

    .fm-toolbar .d-btn {
        flex: 1 1 100%;
        justify-content: center;
        min-height: 44px;
    }

    .fm-actions .d-btn {
        flex: 1 1 100%;
        justify-content: center;
        min-height: 44px;
    }

    .fm-del {
        margin-left: 0;
    }
}


/* =========================================================
   20. COPY LIST (.cl-)
   Small additions only; the form itself uses the standard
   .d-form / .d-form-group / .d-label / .d-input classes.
   ========================================================= */

.cl-intro {
    margin: 0 0 20px;
    color: var(--text-2);
    font-size: 16px;
    line-height: 1.5;
}

.cl-intro strong {
    color: var(--text);
}

/* the two radios sit on one line on desktop, stack on very narrow phones */
@media (max-width: 380px) {
    .d-form-options {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
}

/* =========================================================
   21. ADVENTURE GAMES (.adv-)
   Card grid replacing the legacy .pastel table on
   show-adventures.php. Tokens only, so it inherits both
   css-style-2 and css-style-3.
   ========================================================= */

.adv-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
    margin: 0 0 24px;
}

.adv-card {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.adv-card:hover {
    transform: translateY(-2px);
    border-color: var(--accent);
    box-shadow: var(--shadow-lg);
}

/* --- cover image --- */

.adv-cover {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    background: var(--surface-2);
}

.adv-cover:hover {
    text-decoration: none;
}

.adv-cover img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* --- body --- */

.adv-body {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    gap: 10px;
    padding: 18px 20px;
}

.adv-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
}

.adv-title {
    margin: 0;
    font-size: clamp(18px, 4.5vw, 21px);
    font-weight: 700;
    line-height: 1.25;
    color: var(--text);
    overflow-wrap: anywhere;
}

.adv-tag {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    padding: 4px 10px;
    border-radius: 999px;
    white-space: nowrap;
}

.adv-tag--new {
    background: var(--accent-soft);
    color: var(--accent-text);
}

.adv-tag--draft {
    background: var(--amber-soft);
    color: var(--amber);
}

.adv-help {
    color: var(--text-2);
    line-height: 1.55;
    overflow-wrap: anywhere;
}

.adv-help p:last-child {
    margin-bottom: 0;
}

.adv-done {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--green);
}

/* --- actions --- */

.adv-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: auto;
    padding-top: 4px;
}

/* .d-btn carries margin:10px from section 5; the gap does the spacing */
.adv-btn {
    margin: 0;
    min-height: 44px;
    justify-content: center;
}

.adv-actions .adv-btn {
    flex: 1 1 auto;
}

/* --- admin block --- */

.adv-admin {
    margin-top: 4px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.adv-meta {
    margin: 0 0 4px;
    font-size: 14px;
    color: var(--text-3);
}

.adv-meta strong {
    color: var(--text-2);
}

.adv-admin-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.adv-admin-btns .adv-btn {
    flex: 1 1 90px;
}

/* --- mobile --- */

@media (max-width: 640px) {
    .adv-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .adv-body {
        padding: 16px 14px;
    }

    .adv-actions .adv-btn {
        flex: 1 1 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .adv-card {
        transition: none;
    }

    .adv-card:hover {
        transform: none;
    }
}

/* =========================================================
   22. DIAMOND RANKING (.dm-rank)
   Reuses the .goldcoin-table shell and the .gc-wrap
   overflow guard from the goldcoin section.
   ========================================================= */

.dm-ways {
    margin: 0 0 20px;
    padding-left: 0;
    list-style: none;
    color: var(--text-2);
}

.dm-ways li {
    position: relative;
    padding-left: 24px;
    margin: 6px 0;
    line-height: 1.5;
}

.dm-ways li::before {
    content: "💎";
    position: absolute;
    left: 0;
    top: 0.1em;
    font-size: 0.85rem;
}

.dm-total {
    margin: 0 0 20px;
    max-width: 320px;
}

.dm-rank .dm-col-rank     { width: 64px; text-align: center; }
.dm-rank .dm-col-diamonds { width: 120px; }
.dm-rank .dm-col-pct      { width: 110px; }

.dm-rank .dm-cell-rank {
    text-align: center;
    vertical-align: middle;
}

.dm-rank .dm-cell-diamonds,
.dm-rank .dm-cell-pct {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.dm-rank .dm-cell-name {
    overflow-wrap: anywhere;
}

/* --- Mobile: one card per user --- */

@media (max-width: 640px) {

    .goldcoin-table.dm-rank,
    .dm-rank tbody {
        display: block;
        box-shadow: none;
    }

    .dm-rank thead { display: none; }

    .dm-rank tr {
        display: grid;
        grid-template-columns: 2.25rem auto minmax(0, 1fr);
        grid-template-areas:
            "rank name     name"
            "rank diamonds pct";
        align-items: center;
        gap: 2px 10px;
        padding: 10px 12px;
        border-bottom: 1px solid var(--border);
    }

    .dm-rank td {
        display: block;
        padding: 0;
        border: 0;
        min-width: 0;
    }

    .dm-rank .dm-cell-rank     { grid-area: rank; }
    .dm-rank .dm-cell-name     { grid-area: name; font-weight: 600; }
    .dm-rank .dm-cell-diamonds { grid-area: diamonds; }
    .dm-rank .dm-cell-pct      { grid-area: pct; }

    .dm-rank .dm-cell-diamonds,
    .dm-rank .dm-cell-pct {
        font-size: 14px;
        color: var(--text-2);
    }

    .dm-rank .dm-cell-diamonds::before { content: "💎 "; }

    .dm-rank tr.highlight { background: var(--accent-soft); }
    .dm-rank tr.highlight td { background: transparent !important; }
}

/* =========================================================
   23. SILVERCOIN RANKING (.sv-rank)
   Reuses the .goldcoin-table shell and the .gc-wrap
   overflow guard from the goldcoin section.
   ========================================================= */

.sv-total {
    margin: 0 0 20px;
    max-width: 320px;
}

.sv-rank .sv-col-rank    { width: 64px; text-align: center; }
.sv-rank .sv-col-silvers { width: 130px; }
.sv-rank .sv-col-pct     { width: 110px; }

.sv-rank .sv-cell-rank {
    text-align: center;
    vertical-align: middle;
}

.sv-rank .sv-cell-silvers,
.sv-rank .sv-cell-pct {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.sv-rank .sv-cell-name {
    overflow-wrap: anywhere;
}

/* --- Mobile: one card per user --- */

@media (max-width: 640px) {

    .goldcoin-table.sv-rank,
    .sv-rank tbody {
        display: block;
        box-shadow: none;
    }

    .sv-rank thead { display: none; }

    .sv-rank tr {
        display: grid;
        grid-template-columns: 2.25rem auto minmax(0, 1fr);
        grid-template-areas:
            "rank name    name"
            "rank silvers pct";
        align-items: center;
        gap: 2px 10px;
        padding: 10px 12px;
        border-bottom: 1px solid var(--border);
    }

    .sv-rank td {
        display: block;
        padding: 0;
        border: 0;
        min-width: 0;
    }

    .sv-rank .sv-cell-rank    { grid-area: rank; }
    .sv-rank .sv-cell-name    { grid-area: name; font-weight: 600; }
    .sv-rank .sv-cell-silvers { grid-area: silvers; }
    .sv-rank .sv-cell-pct     { grid-area: pct; }

    .sv-rank .sv-cell-silvers,
    .sv-rank .sv-cell-pct {
        font-size: 14px;
        color: var(--text-2);
    }

    .sv-rank .sv-cell-silvers::before { content: "🥈 "; }

    .sv-rank tr.highlight { background: var(--accent-soft); }
    .sv-rank tr.highlight td { background: transparent !important; }
}


/* =========================================================
   24. DAILY GOLDCOIN GAINS & LOSSES (.gd-)
   Two side-by-side lists reusing the .goldcoin-table shell,
   .gc-wrap guard, .gc-medal/.gc-num ranks, and the existing
   .gold-positive / .gold-negative value cells.
   ========================================================= */

.gd-date {
    margin: 0 0 20px;
    color: var(--text-2);
}

.gd-cols {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    align-items: start;
}

.gd-head {
    font-size: 18px;
    font-weight: 700;
    margin: 0 0 10px;
    color: var(--text);
}

.gd-empty {
    margin: 0;
    padding: 16px;
    color: var(--text-3);
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
}

.gd-rank .gd-col-rank  { width: 56px; text-align: center; }
.gd-rank .gd-col-value { width: 110px; }

.gd-rank .gd-cell-rank {
    text-align: center;
    vertical-align: middle;
}

.gd-rank .gd-cell-value {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    text-align: right;
}

.gd-rank .gd-col-value { text-align: right; }

.gd-rank .gd-cell-name { overflow-wrap: anywhere; }

@media (max-width: 640px) {
    .gd-rank th,
    .gd-rank td {
        padding: 10px 12px;
    }

    .gd-cols { gap: 14px; }
}

/* =========================================================
   24. SUBSCRIPTION STATUS (.sub-)
   Builds on .d-card / .d-stats-card / .d-stat from section 9
   and .d-alert / .d-btn from the theme files. Tokens only.
   ========================================================= */

.sub-head {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
}

.sub-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 15px;
    font-weight: 700;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text-2);
}

.sub-pill--premium {
    background: var(--accent-soft);
    border-color: transparent;
    color: var(--accent-text);
}

.sub-pill--free {
    background: var(--green-soft);
    border-color: transparent;
    color: var(--green);
}

.sub-lead {
    margin: 0 0 16px;
    color: var(--text-2);
    line-height: 1.5;
}

/* .d-alert carries margin-top:16px in the theme files */
.sub-card .sub-alert {
    margin: 0 0 18px;
}

.sub-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
}

/* cancels the global .d-btn { margin: 10px } from section 5 */
.sub-actions .d-btn {
    margin: 0;
}

/* --- FAQ cards --- */

.sub-faq-q {
    margin: 0 0 10px;
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
}

.sub-faq-body {
    color: var(--text-2);
    line-height: 1.6;
}

.sub-faq-body p {
    margin: 0 0 12px;
}

.sub-faq-body p:last-child {
    margin-bottom: 0;
}

.sub-faq-body a {
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* --- mobile --- */

@media (max-width: 480px) {
    .sub-actions .d-btn {
        flex: 1 1 100%;
        justify-content: center;
        min-height: 44px;
        text-align: center;
    }
}

/* =========================================================
   25. TEXT READER PAGE NAV (#style1)
   Back / Next submit buttons sit two-up in a 50/50 table on
   show-text-reader.php; the global .d-btn-submit min-widths
   (220px / 280px via .d-btn--lg) overflow the cells on
   phones. Scoped to #style1 so nothing else is affected.
   ========================================================= */

#style1 form {
    margin: 0;
}

#style1 .d-btn-submit,
#style1 .d-btn-submit.d-btn--lg {
    min-width: 0;              /* kills the 220/280px floor */
    width: 100%;               /* fill the cell; whole td is clickable anyway */
    margin: 0;                 /* .d-btn's 10px margin overflows a full-width cell */
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    white-space: normal;       /* "Next Page >>" wraps instead of pushing wide */
}

@media (max-width: 640px) {
    #style1 .d-btn-submit.d-btn--lg {
        padding: 10px 12px;
        font-size: clamp(15px, 4.2vw, 19px);
    }
}

/* =========================================================
   26. WORDS BY LEVEL (.d-levels)
   Builds on the .d-table shell. Selectors are doubled up
   (.d-table.d-levels) so they outrank the generic .d-table
   stacking rules in section 15.
   ========================================================= */

.d-levels .lv-col-count { width: 160px; }

.d-levels .lv-cell-count {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.d-levels .lv-cell-btns {
    text-align: right;
    white-space: nowrap;
}

/* cancels the global .d-btn { margin: 10px } from section 5 */
.d-levels .lv-btn {
    margin: 0 0 0 8px;
}

/* --- Mobile: one card per level --- */

@media (max-width: 640px) {

    .d-table.d-levels,
    .d-table.d-levels tbody {
        display: block;
        border: 0;
        box-shadow: none;
        background: none;
    }

    .d-table.d-levels thead { display: none; }

    .d-table.d-levels tr {
        display: flex;
        flex-wrap: wrap;
        align-items: baseline;
        gap: 8px 10px;
        padding: 12px 14px;
        margin: 0 0 12px;
        text-align: left;
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        background: var(--surface);
    }

    .d-table.d-levels td {
        display: block;
        width: auto !important;
        padding: 0;
        border: 0;
        min-width: 0;
    }

    .d-table.d-levels .lv-cell-name {
        flex: 1 1 auto;
        font-size: 17px;
    }

    /* header row is hidden, so the suffix restores context */
    .d-table.d-levels .lv-cell-count {
        font-size: 14px;
        color: var(--text-2);
    }

    .d-table.d-levels .lv-cell-count::after {
        content: " words";
    }

    /* buttons drop to their own line and share it evenly */
    .d-table.d-levels .lv-cell-btns {
        flex: 0 0 100%;
        display: flex;
        gap: 8px;
        white-space: normal;
        text-align: left;
    }

    .d-table.d-levels .lv-btn {
        flex: 1 1 0;
        min-width: 0;
        margin: 0;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        text-align: center;
        box-sizing: border-box;
    }
}

/* =========================================================
  27. TEXT READER SHELL (.tr-)
  Replaces the legacy #style1 bordered table and .pastel
  input/word tables on show-text-reader.php. Tokens only.
  ========================================================= */

.tr-notice {
    max-width: 820px;
    margin: 0 auto 20px;
    padding: 16px 18px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-2);
    line-height: 1.6;
}

.tr-notice a {
    color: var(--accent-text);
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* --- toolbar (Translate / Explain) --- */

.tr-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 0 0 16px;
}

/* .d-btn carries margin:10px from section 5; the gap does the spacing */
.tr-toolbar .d-btn {
    margin: 0;
}

/* --- reader card --- */

.tr-reader {
    padding: 24px 26px;
}

.tr-text {
    font-size: clamp(17px, 2.4vw, 20px);
    line-height: 1.7;
    overflow-wrap: anywhere;
}

.tr-translation {
    margin-top: 18px;
    padding: 16px 18px;
    background: var(--surface-2);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius-sm);
    line-height: 1.6;
    color: var(--text-2);
}

.tr-explain {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
}

.tr-quick-trans {
    padding: 12px 14px;
    margin-bottom: 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

/* --- Back / Next nav rows --- */

.tr-nav {
    display: flex;
    gap: 12px;
    margin: 0 0 18px;
}

.tr-nav:last-of-type {
    margin: 18px 0 0;
}

.tr-nav-cell {
    flex: 1 1 0;
    min-width: 0;
    cursor: pointer;
}

.tr-nav-cell:empty {
    display: none;
    cursor: default;
}

.tr-nav-cell form {
    margin: 0;
}

/* the submit buttons fill their half of the row */
.tr-nav-cell .d-btn-submit,
.tr-nav-cell .d-btn-submit.d-btn--lg {
    min-width: 0;
    width: 100%;
    margin: 0;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    white-space: normal;
}

/* --- word list --- */

.tr-wordlist-head {
    margin: 24px 0 12px;
}

.tr-wordlist-head form {
    margin: 0;
}

.tr-wordlist-head input[type="submit"] {
    margin: 0;
}

.tr-wordlist .tr-wl-word {
    text-align: left;
}

.tr-wordlist .tr-wl-side {
    width: 160px;
    text-align: center;
    white-space: normal;
}

/* .d-btn carries margin:10px; keep it tidy inside the side cell */
.tr-wordlist .tr-wl-side .d-btn {
    margin: 8px 0 0;
}

/* --- input form extras --- */

.tr-form-links {
    margin-bottom: 16px;
}

.tr-input-form textarea.d-input {
    min-height: 320px;
}

/* --- mobile --- */

@media (max-width: 640px) {

    .tr-nav {
        gap: 8px;
    }

    /* word list: stack the two cells into one card per word */
    .tr-wordlist,
    .tr-wordlist tbody,
    .tr-wordlist tr,
    .tr-wordlist td {
        display: block;
        width: auto !important;
    }

    .tr-wordlist tr {
        padding: 14px;
        margin-bottom: 12px;
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        background: var(--surface);
    }

    .tr-wordlist tbody tr + tr {
        border-top: 1px solid var(--border);
    }

    .tr-wordlist .tr-wl-side {
        width: auto;
        text-align: left;
        margin-top: 10px;
        padding-top: 10px;
        border-top: 1px solid var(--border);
    }

    .tr-wordlist .tr-wl-side .d-btn {
        min-height: 44px;
    }
}

@media (max-width: 480px) {
    .tr-reader { padding: 16px 14px; }

    .tr-toolbar .d-btn,
    .tr-form-links .d-btn {
        flex: 1 1 100%;
        justify-content: center;
        min-height: 44px;
    }
}

/* =========================================================
   28. COLLECTIBLE CARDS RANKING (.cc-rank)
   Reuses the .goldcoin-table shell and the .gc-wrap
   overflow guard from the goldcoin section. Adds a
   "sets completed" column the other rankings don't carry.
   ========================================================= */

.cc-rank .cc-col-rank  { width: 64px; text-align: center; }
.cc-rank .cc-col-found { width: 120px; }
.cc-rank .cc-col-sets  { width: 140px; }
.cc-rank .cc-col-pct   { width: 110px; }

.cc-rank .cc-cell-rank {
    text-align: center;
    vertical-align: middle;
}

.cc-rank .cc-cell-found,
.cc-rank .cc-cell-sets,
.cc-rank .cc-cell-pct {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.cc-rank .cc-cell-name {
    overflow-wrap: anywhere;
}

/* --- Mobile: one card per user --- */

@media (max-width: 640px) {

    .goldcoin-table.cc-rank,
    .cc-rank tbody {
        display: block;
        box-shadow: none;
    }

    .cc-rank thead { display: none; }

    .cc-rank tr {
        display: grid;
        grid-template-columns: 2.25rem auto minmax(0, 1fr);
        grid-template-areas:
            "rank name  name"
            "rank found pct"
            "rank sets  sets";
        align-items: center;
        gap: 2px 10px;
        padding: 10px 12px;
        border-bottom: 1px solid var(--border);
    }

    .cc-rank td {
        display: block;
        padding: 0;
        border: 0;
        min-width: 0;
    }

    .cc-rank .cc-cell-rank  { grid-area: rank; }
    .cc-rank .cc-cell-name  { grid-area: name; font-weight: 600; }
    .cc-rank .cc-cell-found { grid-area: found; }
    .cc-rank .cc-cell-pct   { grid-area: pct; }
    .cc-rank .cc-cell-sets  { grid-area: sets; }

    .cc-rank .cc-cell-found,
    .cc-rank .cc-cell-sets,
    .cc-rank .cc-cell-pct {
        font-size: 14px;
        color: var(--text-2);
    }

    .cc-rank .cc-cell-found::before { content: "🃏 "; }
    .cc-rank .cc-cell-sets::before  { content: "Sets: "; color: var(--text-3); }

    .cc-rank tr.highlight { background: var(--accent-soft); }
    .cc-rank tr.highlight td { background: transparent !important; }
}


/* =========================================================
   29. SHORT TEXTS LIST (.d-shorttexts / .st-)
   Builds on .d-table--stack from section 15. Adds status
   pills and mobile stacking. Tokens only.
   ========================================================= */

.st-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
}

.st-status::before {
    content: "●";
    font-size: 9px;
    line-height: 1;
}

.st-status--public {
    background: var(--green-soft);
    color: var(--green);
}

.st-status--private {
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text-2);
}

.d-table.d-shorttexts .st-cell-date {
    color: var(--text-2);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.d-table.d-shorttexts .st-cell-author {
    color: var(--text-2);
    font-size: 14px;
}

.d-table.d-shorttexts .st-cell-author u {
    color: var(--text);
    font-weight: 600;
    text-decoration: none;
}

/* --- Mobile: one card per text --- */

@media (max-width: 640px) {

    /* section 15 stacks the rows but leaves the header row behind */
    .d-table.d-shorttexts thead { display: none; }

    /* .d-btn carries margin:10px from section 5; with width:100% that
       overflows the card by 20px */
    .d-table.d-shorttexts .d-btn { margin: 0; }

    .d-table.d-shorttexts .st-cell-title {
        flex: 0 0 100%;
        font-weight: 600;
        font-size: 16px;
    }

    .d-table.d-shorttexts .st-cell-status,
    .d-table.d-shorttexts .st-cell-date {
        flex: 1 1 auto;
    }

    .d-table.d-shorttexts td.d-table-actions {
        flex: 0 0 100%;
        text-align: left;
    }

    .d-table.d-shorttexts td.d-table-actions .d-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        min-height: 44px;
    }

}


/* =========================================================
   30. MORE OPTIONS PANEL (.mo-)
   Replaces the legacy #y1 mousover tables on the exercise
   pages. #x1 / #y1 keep their ids for the toggle JS.
   Tokens only, so it inherits css-style-2 and css-style-3.
   ========================================================= */

.mo-panel {
    max-width: 640px;
    margin: 12px auto 0;
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    text-align: center;
}

/* --- action row --- */

.mo-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-bottom: 14px;
}

.mo-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 8px 14px;
    box-sizing: border-box;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--text);
    font-weight: 600;
    font-size: 15px;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    transition: border-color var(--transition), color var(--transition), transform var(--transition);
}

.mo-btn:hover {
    border-color: var(--accent);
    color: var(--accent-text);
    text-decoration: none;
    transform: translateY(-1px);
}

/* semantic accents (same palette as the old #remove/#known/#block) */
.mo-remove        { color: #fb5656; }
.mo-remove:hover  { color: #fb5656; border-color: #fb5656; }
.mo-known         { color: var(--accent-text); }
.mo-block         { color: #cc66cc; }
.mo-block:hover   { color: #cc66cc; border-color: #cc66cc; }

/* --- label --- */

.mo-label {
    margin: 4px 0 10px;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-3);
}

/* --- interval grid: reflows 5-up on desktop to 3-up on phones,
   and survives text zoom because nothing has a fixed height --- */

.mo-times {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
    gap: 8px;
}

.mo-times .mo-btn {
    padding: 8px 6px;
    font-size: 14px;
}

/* --- mobile --- */

@media (max-width: 480px) {
    .mo-panel {
        padding: 12px;
    }

    .mo-actions {
        flex-direction: column;
    }

    .mo-actions .mo-btn {
        width: 100%;
    }

    .mo-times {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 6px;
    }

    .mo-times .mo-btn {
        font-size: 13px;
        padding: 8px 4px;
    }
}

/* =========================================================
   31. WORD COLORS (.color1–.color8)
   Fixed palettes per mode. `body` in the selector outranks
   the token-based .color7/.color8 rules in section 3 and
   the html[data-theme="dark"] .color7 rules in the theme
   files, regardless of stylesheet load order.
   ========================================================= */

html:not([data-theme="dark"]) body .color1 { color: #5a5a5a; }
html:not([data-theme="dark"]) body .color2 { color: #000080; }
html:not([data-theme="dark"]) body .color3 { color: #194775; }
html:not([data-theme="dark"]) body .color4 { color: #0a0fe9; }
html:not([data-theme="dark"]) body .color5 { color: #FF0000; }
html:not([data-theme="dark"]) body .color6 { color: #228B22; }
html:not([data-theme="dark"]) body .color7 { color: #000; }
html:not([data-theme="dark"]) body .color8 { color: #6b6b6b; }

/* --- dark mode --- */
html[data-theme="dark"] body .color1 { color: #9497c6; }
html[data-theme="dark"] body .color2 { color: #87ceeb; }
html[data-theme="dark"] body .color3 { color: #58A6FF; }
html[data-theme="dark"] body .color4 { color: #8f92ff; }
html[data-theme="dark"] body .color5 { color: #E57373; }
html[data-theme="dark"] body .color6 { color: #4CAF50; }
html[data-theme="dark"] body .color7 { color: #fff; }
html[data-theme="dark"] body .color8 { color: #7d7d7d; }

/* =========================================================
   32. ANIMAL LEAGUE (.al-)
   Append to css-style-all-new.css.
   Static tier ladder with the user's own tier highlighted.
   Reuses design tokens; auto dark-mode / multi-theme aware.
   ========================================================= */

.al-intro {
    margin: 0 0 16px;
    color: var(--text-2);
}

.al-pct-you {
    color: var(--text-2);
    font-variant-numeric: tabular-nums;
}

/* Scroll sideways rather than blow out the page on narrow screens */
.al-wrap {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.al-ladder {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.al-ladder thead th {
    text-align: left;
    padding: 12px 16px;
    background: var(--surface-2);
    color: var(--text-2);
    font-weight: 700;
    border-bottom: 1px solid var(--border);
}

.al-ladder td {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.al-ladder tbody tr:last-child td {
    border-bottom: 0;
}

.al-ladder tbody tr:hover {
    background: var(--surface-2);
}

.al-cell-pct {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    color: var(--text-2);
}

.al-animal {
    display: inline-flex;
    align-items: center;
    gap: 12px;
}

.al-animal img {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    display: block;
    flex: 0 0 auto;
}

.al-name {
    font-weight: 600;
}

/* Highlighted current tier */
.al-ladder tbody tr.al-current td {
    background: var(--accent-soft);
}

.al-ladder tbody tr.al-current:hover td {
    background: var(--accent-soft);
}

.al-ladder tbody tr.al-current .al-name {
    color: var(--accent);
}

.al-you {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 2px 10px;
    border-radius: 999px;
    background: var(--accent);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
}

/* --- Mobile --------------------------------------------------------- */

@media (max-width: 640px) {

    .al-ladder td,
    .al-ladder thead th {
        padding: 10px 12px;
    }

    .al-animal {
        gap: 10px;
    }

    .al-animal img {
        width: 48px;
        height: 48px;
    }

    .al-cell-pct {
        font-size: 14px;
    }
}

@media (max-width: 480px) {

    .al-animal img {
        width: 44px;
        height: 44px;
    }

    .al-name {
        font-size: 15px;
    }
}

/* =========================================================
   33. USER UPLOAD FORMS (shared) — .upl-
   Used by add-picture-description-user.php and
   upload-by-user-text-reader.php. Move the inline .upl- rules
   out of add-picture-description-user.php once this is in place.
   Append to css-style-all-new.css
   ========================================================= */

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

.upl-intro {
    margin-bottom: 20px;
    color: var(--text-2);
    line-height: 1.6;
}

.upl-intro a { color: var(--accent); }

/* --- drop / file selector --- */
.upl-drop {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 22px 18px;
    text-align: center;
    background: var(--surface-2);
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
}

.upl-drop:hover { border-color: var(--accent); }

.upl-drop.is-over {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.upl-drop-text {
    font-size: 15px;
    color: var(--text-2);
}

.upl-pick { min-height: 44px; }

.upl-file:focus-visible + .upl-pick {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.upl-name {
    display: block;
    margin-top: 10px;
    font-size: 14px;
    color: var(--text-2);
    overflow-wrap: anywhere;
}

.upl-preview {
    display: none;
    width: 100%;
    max-width: 320px;
    height: auto;
    margin-top: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.upl-preview.is-visible { display: block; }

.upl-hint {
    display: block;
    margin-top: 6px;
    font-size: 14px;
    font-weight: 400;
    color: var(--text-3);
}

/* --- language radio group (text-reader upload) --- */
.upl-choices {
    margin: 0 0 var(--d-form-gap, 18px);
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
}

.upl-choices legend { padding: 0 6px; }

.upl-radio {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    cursor: pointer;
    color: var(--text);
}

.upl-radio input {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
}

.upl-terms {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-3);
}

/* No dragging on a touch screen, so the zone becomes a plain button area. */
@media (hover: none) {
    .upl-drop { padding: 14px; border-style: solid; }
    .upl-drop-text { display: none; }
}

@media (max-width: 480px) {
    .upl-drop { padding: 16px 12px; }
    .upl-pick { display: flex; width: 100%; justify-content: center; }
    .upl-preview { max-width: 100%; }
    .upl-choices { padding: 12px; }
}

/* =========================================================
   34. GAME PICKER (.gp-)
   Grid of game links inside a .d-card. Uses existing
   .d-btn from section 5; the grid gap handles spacing.
   ========================================================= */
.gp-card {
    text-align: center;
}
.gp-title {
    margin: 0 0 16px;
    font-size: 1.15rem;
    color: var(--text);
}
.gp-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}
/* .d-btn carries margin:10px from section 5; the gap does the spacing */
.gp-grid .d-btn {
    margin: 0;
    width: 100%;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

@media (max-width: 640px) {
    .gp-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
@media (max-width: 480px) {
    .gp-grid {
        grid-template-columns: 1fr;
    }
}

/* =========================================================
   35. WORD LISTS OVERVIEW (.wl-cards)
   Replaces the legacy .pastel table on show-lists-words.php.
   Card-per-list layout. Uses existing tokens only.
   NB: distinct from the .wl-item two-column block in section 19.
   ========================================================= */

.wl-intro {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 0 0 20px;
}

/* .d-btn carries margin:10px from section 5; the flex gaps
   handle spacing instead, otherwise buttons overflow cards */
.wl-intro .d-btn,
.wl-actions .d-btn {
    margin: 0;
}

.wl-cards {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 16px;
}

.wl-card {
    padding: 20px 22px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transition: border-color var(--transition);
}

.wl-card:hover {
    border-color: var(--accent);
}

.wl-card--main {
    border-left: 3px solid var(--accent);
}

.wl-name {
    font-size: clamp(18px, 4vw, 22px);
    font-weight: 600;
    margin: 0 0 14px;
    color: var(--text);
    overflow-wrap: anywhere;
}

.wl-inline-link {
    font-size: 14px;
    font-weight: 400;
    white-space: nowrap;
}

/* --- meta rows --- */

.wl-meta {
    margin: 0 0 14px;
    display: grid;
    gap: 4px;
}

.wl-meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 10px;
}

.wl-meta-row dt {
    flex: 0 0 90px;
    color: var(--text-3);
    font-size: 14px;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.wl-meta-row dd {
    flex: 1 1 200px;
    min-width: 0;
    margin: 0;
    color: var(--text);
    overflow-wrap: anywhere;
}

/* --- status badge --- */

.wl-status {
    margin: 0 0 14px;
}

.wl-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 700;
    line-height: 1.5;
}

.wl-badge--on {
    color: var(--green);
    background: var(--accent-soft, rgba(0,128,0,.10));
}

.wl-badge--off {
    color: var(--amber);
    background: var(--accent-soft, rgba(200,120,0,.10));
}

/* --- action rows --- */

.wl-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.wl-actions--admin {
    margin-top: 10px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

/* --- mobile --- */

@media (max-width: 640px) {

    .wl-card {
        padding: 16px;
    }

    .wl-meta-row dt {
        flex: 0 0 100%;
        margin-bottom: -2px;
    }

    .wl-intro .d-btn,
    .wl-actions .d-btn {
        flex: 1 1 auto;
        min-height: 44px;
        justify-content: center;
        text-align: center;
    }
}

@media (max-width: 380px) {

    .wl-actions .d-btn {
        flex: 1 1 100%;
    }
}

/* =========================================================
   36. HIGH-SCORE WORDS RANKING (.hs-rank)
   Reuses the .goldcoin-table shell and the .gc-wrap
   overflow guard from the goldcoin section.
   ========================================================= */

.hs-rank .hs-col-date,
.hs-rank .hs-col-last    { width: 140px; }

.hs-rank .hs-col-score,
.hs-rank .hs-col-correct,
.hs-rank .hs-col-total   { width: 120px; }

.hs-rank .hs-cell-name {
    overflow-wrap: anywhere;
}

.hs-rank .hs-cell-date,
.hs-rank .hs-cell-last,
.hs-rank .hs-cell-score,
.hs-rank .hs-cell-correct,
.hs-rank .hs-cell-total {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* --- Mobile: one card per player, no horizontal scroll --- */

@media (max-width: 640px) {

    .goldcoin-table.hs-rank,
    .hs-rank tbody {
        display: block;
        box-shadow: none;
    }

    .hs-rank thead { display: none; }

    .hs-rank tr {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        grid-template-areas:
            "name    name"
            "score   correct"
            "total   date"
            "last    last";
        gap: 4px 12px;
        padding: 12px;
        border-bottom: 1px solid var(--border);
    }

    .hs-rank td {
        display: block;
        padding: 0;
        border: 0;
        min-width: 0;
        white-space: normal;
    }

    .hs-rank .hs-cell-name {
        grid-area: name;
        font-weight: 600;
        font-size: 17px;
        margin-bottom: 2px;
    }

    .hs-rank .hs-cell-score   { grid-area: score; }
    .hs-rank .hs-cell-correct { grid-area: correct; }
    .hs-rank .hs-cell-total   { grid-area: total; }
    .hs-rank .hs-cell-date    { grid-area: date; }
    .hs-rank .hs-cell-last    { grid-area: last; }

    .hs-rank .hs-cell-score,
    .hs-rank .hs-cell-correct,
    .hs-rank .hs-cell-total,
    .hs-rank .hs-cell-date,
    .hs-rank .hs-cell-last {
        font-size: 14px;
        color: var(--text-2);
    }

    /* inline labels replace the hidden header row */
    .hs-rank .hs-cell-score::before   { content: "Score: ";   color: var(--text-3); }
    .hs-rank .hs-cell-correct::before { content: "Correct: ";  color: var(--text-3); }
    .hs-rank .hs-cell-total::before   { content: "Games: ";    color: var(--text-3); }
    .hs-rank .hs-cell-date::before    { content: "Record: ";   color: var(--text-3); }
    .hs-rank .hs-cell-last::before    { content: "Last: ";     color: var(--text-3); }

    .hs-rank .hs-cell-score {
        font-weight: 700;
        color: var(--accent-text);
    }

    /* highlight the whole card rather than each cell */
    .hs-rank tr.highlight { background: var(--accent-soft); }
    .hs-rank tr.highlight td { background: transparent !important; }
}

/* =========================================================
   36b. HIGH-SCORE GAME RANKING (.hs-rank language column)
   Adds the Language column used by the arcade high-score
   pages on top of section 36's shared .hs-rank layout.
   ========================================================= */

.hs-rank .hs-col-lang { width: 140px; }

.hs-rank .hs-cell-lang {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

@media (max-width: 640px) {

    /* extend the card grid with a language row */
    .hs-rank tr {
        grid-template-areas:
            "name    name"
            "score   total"
            "date    last"
            "lang    lang";
    }

    .hs-rank .hs-cell-lang { grid-area: lang; }

    .hs-rank .hs-cell-lang {
        font-size: 14px;
        color: var(--text-2);
    }

    .hs-rank .hs-cell-lang::before {
        content: "Language: ";
        color: var(--text-3);
    }
}

/* =========================================================
   37. TOPIC LISTS (.tl-list)
   Replaces the legacy .pastel table on the short-texts
   topic overview page. Responsive card grid, whole card is
   the link. Uses existing tokens only.
   ========================================================= */

.tl-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 14px;
    margin: 8px 0 20px;
}

.tl-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 14px;
    padding: 18px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-decoration: none;
    color: inherit;
    transition: transform var(--transition),
    border-color var(--transition),
    box-shadow var(--transition);
}

.tl-card:hover {
    transform: translateY(-2px);
    border-color: var(--accent);
    box-shadow: 0 6px 18px rgba(0,0,0,.08);
}

.tl-name {
    font-size: clamp(18px, 3.5vw, 20px);
    font-weight: 600;
    line-height: 1.25;
    color: var(--text);
    overflow-wrap: anywhere;
}

.tl-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.tl-count {
    font-size: 14px;
    color: var(--text-3);
}

.tl-go {
    font-size: 14px;
    font-weight: 600;
    color: var(--accent);
    white-space: nowrap;
}

/* --- mobile --- */

@media (max-width: 480px) {

    .tl-list {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .tl-card {
        padding: 16px 18px;
    }
}

/* --- action-card variant (sentences topic page) --- */

.tl-list {
    /* ul reset when the list carries <li> cards */
    list-style: none;
    padding: 0;
}

.tl-card--actions {
    gap: 6px;
}

.tl-card--actions .tl-count {
    margin-bottom: 6px;
}

.tl-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: auto;
}

/* margin:0 cancels the global .d-btn { margin:10px } from section 5 */
.tl-act {
    margin: 0;
    flex: 0 0 auto;
    padding: 5px 12px;
    font-size: 13px;
    line-height: 1.4;
}

/* =========================================================
   38. NOTES
   ========================================================= */

.notes-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 2147483647;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.notes-modal.open { display: flex; }
.notes-box {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    width: 100%;
    max-width: 420px;
    padding: 20px;
    box-sizing: border-box;
}
.notes-box textarea {
    width: 100%;
    min-height: 140px;
    box-sizing: border-box;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 16px; /* stops iOS zoom on focus */
}
.notes-msg { color: #c00; font-size: 14px; margin-top: 8px; }

/* =========================================================
   39. WORD FLASHCARD LOOP (.fl-)
   Replaces the legacy nested .pastel tables on the word
   flashcard page. The interval grids reuse .mo-times /
   .mo-btn from section 30. Tokens only, so it inherits
   css-style-2 and css-style-3.
   ========================================================= */

/* --- summary strip --- */

.fl-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 24px;
    padding: 18px 22px;
    margin: 0 0 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.fl-stat {
    flex: 1 1 120px;
    min-width: 0;
}

.fl-num {
    display: block;
    font-size: 26px;
    font-weight: 800;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
}

.fl-lbl {
    display: block;
    margin-top: 2px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-3);
}

/* --- card list --- */

.fl-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 18px;
}

.fl-card {
    padding: 22px 24px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transition: border-color var(--transition);
}

.fl-card:hover {
    border-color: var(--accent);
}

/* --- headword --- */

.fl-word {
    font-size: clamp(20px, 5vw, 26px);
    line-height: 1.35;
    color: var(--text);
    overflow-wrap: anywhere;
}

.fl-english {
    margin-top: 8px;
    color: var(--text-2);
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.fl-label {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--accent-text);
}

/* --- hidden-meaning reveal: hover on desktop, tap on touch --- */

.fl-reveal {
    display: inline-block;
    padding: 2px 10px;
    border: 1px dashed var(--border);
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--text-3);
    font-size: 14px;
    cursor: pointer;
    user-select: none;
    transition: border-color var(--transition), color var(--transition);
}

.fl-reveal:hover,
.fl-reveal:focus-visible {
    border-color: var(--accent);
    color: var(--accent-text);
}

.fl-reveal.fl-revealed {
    padding: 0;
    border: 0;
    background: none;
    color: var(--text-2);
    font-size: inherit;
    cursor: default;
}

/* --- sound player + related words --- */

.fl-player {
    margin-top: 8px;
}

.fl-related {
    margin-top: 6px;
    font-size: 15px;
    color: var(--text-2);
}

/* --- button rows.  .d-btn carries margin:10px from section 5;
   the flex gap does the spacing instead --- */

.fl-actions,
.fl-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.fl-actions .d-btn,
.fl-controls .d-btn,
.fl-controls .btn {
    margin: 0;
}

/* --- nested example sentence --- */

.fl-example {
    margin-top: 16px;
    padding: 16px 18px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius-sm);
}

.fl-example-text {
    line-height: 1.6;
    overflow-wrap: anywhere;
}

/* --- ajax status line (set_flashcard_word writes here) --- */

.fl-status {
    min-height: 1.4em;
    margin-top: 14px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-3);
}

.fl-times {
    margin-top: 4px;
}

/* --- footer --- */

.fl-footer {
    margin-top: 26px;
    padding-top: 22px;
    border-top: 1px solid var(--border);
}

.fl-footer-note {
    margin: 20px 0 12px;
    color: var(--text-2);
    font-size: 15px;
}

/* --- mobile --- */

@media (max-width: 640px) {
    .fl-card {
        padding: 18px 16px;
    }

    .fl-summary {
        padding: 16px;
        gap: 12px 16px;
    }

    .fl-num {
        font-size: 22px;
    }

    .fl-example {
        padding: 14px;
    }

    .fl-actions .d-btn,
    .fl-controls .d-btn {
        flex: 1 1 100%;
        text-align: center;
    }
}

/* =========================================================
   40. WORD DETAIL PAGE (.wd-)
   Replaces the legacy cellspacing/cellpadding table shell on
   show-word-details.php. Two-column flex shell that stacks on
   mobile, plus card wrappers for the admin/translator tools.
   Tokens only, so it inherits css-style-2 and css-style-3.
   ========================================================= */

.wd-shell {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 20px;
    margin: 0 0 4px;
}

/* --- main column: the headword, readings, translation --- */

.wd-main {
    flex: 1 1 420px;
    min-width: 0;
    padding: 24px 22px;
    text-align: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

/* control buttons (add / remove / known) sit under the word */

.wd-controls {
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--rule);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

/* .d-btn carries margin:10px from section 5; the gap does the spacing */
.wd-controls .d-btn,
.wd-nav .d-btn {
    margin: 0;
}

/* --- side column: sound, level, extra meta --- */

.wd-side {
    flex: 0 1 240px;
    min-width: 0;
    padding: 18px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    font-size: 14px;
    color: var(--text-2);
}

.wd-side:empty {
    display: none;
}

/* --- edit links strip (translators / admins) --- */

.wd-editbar {
    margin: 0 0 16px;
    padding: 10px 14px;
    background: var(--accent-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    text-align: center;
}

/* --- generic content block between the shell and the footer --- */

.wd-section {
    margin: 0 0 22px;
}

.wd-section:last-child {
    margin-bottom: 0;
}

/* --- admin-only tools (dictionary links, inflections, history) --- */

.wd-tools {
    margin: 0 0 22px;
    padding: 16px 20px;
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    font-size: 14px;
}

/* --- nav rows (Go Back / Jump to Top) --- */

.wd-nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin: 18px 0 24px;
}

/* --- mobile --- */

@media (max-width: 640px) {

    .wd-shell {
        gap: 14px;
    }

    .wd-side {
        display: none;
    }

    .wd-main {
        flex: 1 1 100%;
        padding: 18px 14px;
    }

    .wd-controls > * {
        width: 100%;
        max-width: 260px;
    }

    .wd-controls .d-btn {
        width: 100%;
    }

    .wd-nav .d-btn {
        flex: 1 1 140px;
    }
}

@media (max-width: 480px) {

    .wd-main {
        padding: 16px 12px;
    }
}






/* =========================================================
   41. THEME SETTINGS (.th-)
   Replaces the legacy table on edit-theme-settings.php.
   Each row reloads this page with ?preview_theme=N, so the
   page itself repaints in the chosen theme; a sticky bar
   shows what is being tried out until it is saved.
   Tokens only, so it inherits css-style-2 / css-style-3.
   ========================================================= */

/* --- sticky "you are previewing" bar --- */

.th-bar {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin: 0 0 14px;
    padding: 10px 14px;
    border: 1px solid var(--accent);
    border-radius: var(--radius-sm, 10px);
    background: var(--accent-soft);
    box-shadow: var(--shadow);
}

.th-bar-text {
    font-size: 14px;
    color: var(--text);
}

.th-bar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.th-bar-keep,
.th-bar-revert {
    padding: 9px 14px;
    min-height: 40px;
    border-radius: 999px;
    border: 1px solid var(--accent);
    font: inherit;
    font-size: 14px;
    line-height: 1.2;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: opacity .15s ease, background .15s ease;
}

/* --- classic view link (not previewable, applies immediately) --- */

.th-classic {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin: 0 0 14px;
    padding: 10px 14px;
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm, 10px);
    background: var(--surface-2);
}

.th-classic.is-current {
    border-style: solid;
    border-color: var(--green);
    background: var(--green-soft);
}

.th-classic-text {
    font-size: 13.5px;
    color: var(--text-2);
    line-height: 1.45;
}

.th-classic.is-current .th-classic-text { color: var(--text); }

.th-classic-link {
    flex: 0 0 auto;
    padding: 9px 14px;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--accent-text);
    font-size: 14px;
    text-decoration: none;
    white-space: nowrap;
    transition: border-color .15s ease, background .15s ease;
}

.th-classic-link:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.th-bar-keep {
    background: var(--accent);
    color: #fff;
    font-weight: 600;
}

.th-bar-keep:hover { opacity: .88; }

.th-bar-revert {
    background: var(--surface);
    color: var(--accent-text);
}

.th-bar-revert:hover { background: var(--surface-2); }

/* --- theme rows --- */

.th-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0 0 6px;
}

.th-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 12px;
    min-height: 44px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm, 10px);
    background: var(--surface);
    cursor: pointer;
    scroll-margin-top: 70px;
    transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}

.th-row:hover { border-color: var(--accent); }

.th-row.is-selected {
    border-color: var(--accent);
    background: var(--accent-soft);
    box-shadow: var(--shadow);
    cursor: default;
}

.th-row input[type="radio"] {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
}

.th-main {
    flex: 1 1 140px;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.th-name {
    font-weight: 600;
    font-size: 15px;
    line-height: 1.3;
    color: var(--text);
    text-decoration: none;
}

.th-row.is-selected .th-name { color: var(--accent-text); }

.th-meta {
    font-size: 12px;
    color: var(--text-3);
}

.th-badge {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 7px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
}

.th-badge-saved {
    background: var(--green-soft);
    color: var(--green);
}

.th-badge-preview {
    background: var(--amber-soft);
    color: var(--amber);
}

.th-links {
    flex: 0 0 auto;
    font-size: 13px;
    white-space: nowrap;
}

.th-links a { color: var(--accent-text); }

/* --- vote cluster --- */

.th-vote {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    color: var(--text-2);
    white-space: nowrap;
}

.th-vote button {
    background: none;
    border: 0;
    padding: 4px;
    font-size: 17px;
    line-height: 1;
    cursor: pointer;
    opacity: .5;
    transition: opacity .15s ease, filter .15s ease, transform .15s ease;
}

.th-vote button:hover {
    opacity: 1;
    transform: scale(1.12);
}

.th-vote[data-user-rating="1"] .vote-up {
    opacity: 1;
    filter: drop-shadow(0 0 2px var(--green));
}

.th-vote[data-user-rating="2"] .vote-down {
    opacity: 1;
    filter: drop-shadow(0 0 2px var(--amber));
}

.th-vote .percent {
    margin-left: 4px;
    font-weight: 600;
    color: var(--text-2);
}

/* --- mobile --- */

@media (max-width: 640px) {
    .th-bar {
        flex-direction: column;
        align-items: stretch;
    }
    .th-bar-actions { justify-content: space-between; }
    .th-row { padding: 10px; row-gap: 8px; }
    .th-main { flex-basis: 100%; }
    .th-links,
    .th-vote { margin-left: 28px; }
}


/* =========================================================
   42. REVIEW INTERVAL PANEL (.mo-review)
   Extends section 30. Adds the full-width primary interval
   button and the "permanently hide" footer link used on the
   exercise pages. Tokens only, so it inherits
   css-style-2 and css-style-3.
   ========================================================= */

.mo-review .mo-label {
    margin: 0 0 12px;
}

/* --- "Again Soon": full width, sits above the interval grid --- */

.mo-btn--primary {
    display: flex;
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 10px;
    padding: 10px 16px;
    border-color: var(--accent);
    color: var(--accent-text);
    font-size: 17px;
}

.mo-btn--primary:hover {
    background: var(--surface);
    border-color: var(--accent);
    color: var(--accent-text);
}

/* --- footer link --- */

.mo-foot {
    margin: 14px 0 0;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.mo-hide {
    display: inline-block;
    padding: 6px 4px;          /* keeps the tap target ~32px tall */
    font-size: 13px;
    color: var(--text-3);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.mo-hide:hover {
    color: #fb5656;
}

/* --- mobile: 2 x 2 instead of section 30's 3-up, which would
   leave the fourth interval stranded on its own row --- */

@media (max-width: 480px) {
    .mo-review .mo-times {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .mo-review .mo-times .mo-btn {
        font-size: 14px;
        padding: 10px 6px;
    }
}

/* =========================================================
   43.  aspect pair (imperfective / perfective) — inline-flex so the
   parent's text-align:center centres it
   ========================================================= */

.wd-aspects {
    display: inline-flex;
    flex-direction: column;
    max-width: 100%;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.wd-aspect {
    padding: 12px 28px;
}

.wd-aspect + .wd-aspect {
    border-top: 1px solid var(--rule);
}

.wd-aspect-label {
    display: block;
    margin-bottom: 4px;
    font-size: 13px;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--text-2);
}

.wd-headword {
    display: block;
    font-size: 50px;
    line-height: 1.15;
    overflow-wrap: anywhere;
}

@media (max-width: 480px) {
    .wd-aspect {
        padding: 10px 16px;
    }

    .wd-headword {
        font-size: 36px;
    }
}


