/* ==========================================================================
   Ganarmas siteStyle.css (revamp)
   - Modern layout (fixed sidebar + content), no floats
   - Consistent form controls, buttons, tables
   - Scoped zebra striping (no global tr:nth-child)
   - Keeps your existing IDs/classes working
   ========================================================================== */

/* -----------------------------
   Fonts
----------------------------- */

@font-face {
    font-family: helvetica;
    src: url("fonts/helvetica.ttf");
}

@font-face {
    font-family: helvetica-bold;
    src: url("fonts/helvetica-bold.ttf");
}

/* -----------------------------
   Design tokens
----------------------------- */

:root {
    /* Palette */
    --bg: #b7d0a8;          /*  */
    --sidebar: #98807d;     /* plum */
    --sidebar-hover: #b8a396;
    --accent: #728f35;      /*  */
    --accent-2: #728f35;    /*  */
    --text: #111;
    --text-muted: #3b3b3b;

    /*
    --bg: #E4DCB2;          /* beige 
    --sidebar: #1E434C;     /* blue 
    --sidebar-hover: #2b5c68;
    --accent: #C99E10;      /* gold 
    --accent-2: #9B4F0F;    /* rust 
    --text: #111;
    --text-muted: #3b3b3b;
    */

    --card: rgba(255, 255, 255, 0.65);
    --card-solid: #ffffff;
    --border: rgba(0, 0, 0, 0.35);
    --border-strong: rgba(0, 0, 0, 0.6);

    --shadow: 0 2px 10px rgba(0,0,0,0.10);
    --radius: 10px;

    --space-1: 6px;
    --space-2: 10px;
    --space-3: 14px;
    --space-4: 18px;
    --space-5: 24px;

    --mono: Consolas, "Courier New", monospace;
    --sans: Arial, Helvetica, sans-serif;

    /* Desktop sidebar width */
    --menu-w: 360px;

    /* Content max width so long pages remain readable */
    --content-max: 1100px;
}

/* -----------------------------
   Base / Reset
----------------------------- */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    font-size: 16px;
    line-height: 1.45;
    text-align: left;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--sans);
}

/* Avoid "img { width:100% }" globally; it breaks icons/sprites.
   If you need full-width images, style them explicitly. */
img {
    max-width: 100%;
    height: auto;
}

/* Better default spacing for headings */
h1, h2, h3, h4 {
    margin: 0 0 var(--space-2) 0;
    color: var(--text);
}

h1, h2, h3 {
    font-family: helvetica-bold, var(--sans);
    letter-spacing: 0.02em;
}

h1 { font-size: 1.35rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1.0rem; }
h4 { font-size: 0.95rem; }

p {
    margin: 0 0 var(--space-3) 0;
}

/* Make HR consistent */
hr {
    border: none;
    height: 1px;
    background: var(--border);
    margin: var(--space-4) 0;
}

/* -----------------------------
   Layout: sidebar + content
----------------------------- */

.menu {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;

    width: var(--menu-w);
    padding: var(--space-4);

    background: var(--sidebar);
    color: #fff;

    overflow: auto;
    z-index: 10;

    box-shadow: 2px 0 12px rgba(0,0,0,0.20);
}

/* Keep the menu readable */
.menu h1,
.menu h2,
.menu h3,
.menu h4 {
    color: #fff;
}

.menu p,
.menu label {
    color: rgba(255,255,255,0.92);
}

/* Main content sits to the right of fixed sidebar */
.main-content {
    margin-left: var(--menu-w);
    padding: var(--space-4);
}

/* Constrain long content for readability */
.main-content > * {
    max-width: var(--content-max);
    margin-left: auto;
    margin-right: auto;
}

/* Mobile menu button (shown on small screens) */
#button-menu {
    display: none;
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 20;

    background: var(--sidebar);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.25);
    border-radius: 10px;

    padding: 10px 14px;
    font-size: 1rem;
    cursor: pointer;

    box-shadow: var(--shadow);
}

/* -----------------------------
   Form controls (global)
----------------------------- */

textarea,
input[type="text"],
input[type="number"],
select {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 0.95rem;
    background: rgba(255,255,255,0.92);
    color: var(--text);
}

textarea {
    resize: vertical;
}

/* Your primary input fields */
#input-text,
#input-textToSearchFor,
#input-textToSearchIn {
    min-height: 6.5rem;
}

/* URL box */
#input-urlToSearch {
    min-height: 2.6rem;
}

/* Numeric inputs should not be full width in paragraphs */
input[type="number"] {
    max-width: 180px;
}

/* Focus: clear + consistent */
textarea:focus,
input:focus,
select:focus,
button:focus {
    outline: 3px solid rgba(201, 158, 16, 0.35);
    outline-offset: 2px;
}

/* File input: keep usable */
input[type="file"] {
    width: 100%;
    color: rgba(255,255,255,0.95);
}

/* -----------------------------
   Buttons (unify)
----------------------------- */

button,
input[type="button"] {
    font-family: var(--sans);
}

.button {
    border: 1px solid transparent;
    border-radius: 10px;
    cursor: pointer;

    padding: 10px 12px;
    line-height: 1.2;
    text-decoration: none;

    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;

    white-space: normal;
    word-break: break-word;
}

/* Primary action style (your old .button1) */
.button1 {
    background: var(--accent-2);
    color: #fff;
    width: 100%;
    margin: 6px 0;
    font-size: 0.95rem;
    border-color: rgba(255,255,255,0.15);
}

.button1:hover {
    filter: brightness(1.08);
}

/* Secondary action style (your old .button2) */
.button2 {
    background: rgba(255,255,255,0.92);
    color: var(--text);
    border-color: var(--border-strong);

    padding: 8px 10px;
    margin: 0 8px 12px 0;
    font-size: 0.95rem;
}

.button2:hover {
    background: #fff;
}

/* Non-classed buttons: make them not ugly */
button:not(.button):not(.button1):not(.button2) {
    border: 1px solid var(--border-strong);
    background: rgba(255,255,255,0.9);
    color: var(--text);
    border-radius: 10px;
    padding: 8px 10px;
    cursor: pointer;
}

button:not(.button):not(.button1):not(.button2):hover {
    background: #fff;
}

/* -----------------------------
   Sidebar content polish
----------------------------- */

/* Tighten the sidebar forms a bit */
.menu textarea,
.menu input[type="text"],
.menu input[type="number"],
.menu select {
    background: rgba(255,255,255,0.95);
    border-color: rgba(0,0,0,0.25);
}

#window-selectedFileName {
    border: 1px solid rgba(255,255,255,0.35);
    border-radius: 10px;
    padding: 10px 12px;
    background: rgba(255,255,255,0.10);
    font-weight: 700;
    letter-spacing: 0.04em;
}

#output-selectedFileName {
    font-size: 1rem;
}

/* Progress bar */
#progress {
    width: 100%;
    height: 12px;
    background: rgba(255,255,255,0.25);
    border-radius: 999px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.25);
}

#inprogress {
    width: 10%;
    height: 100%;
    background: var(--accent);
}

#progress.hidden {
    display: none;
}

/* Menu table */
.menu-container {
    width: 100%;
    border: 1px solid rgba(255,255,255,0.35);
    border-radius: 10px;
    border-collapse: separate;
    border-spacing: 0;
    overflow: hidden;
}

.menu-container h3 {
    margin: 0 0 var(--space-2) 0;
}

table.menu-items {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
}

table.menu-items td {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.20);
    color: #fff;
    padding: 10px;
    text-align: center;
    vertical-align: middle;
}

table.menu-items a {
    color: #fff;
    text-decoration: none;
}

table.menu-items td:hover {
    background: var(--sidebar-hover);
}

/* -----------------------------
   Tool sections become "cards"
----------------------------- */

/* Every tool section already has an id="section-...".
   Give them consistent card styling. */
.main-content > div[id^="section-"] {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);

    padding: var(--space-4);
    margin: 0 auto var(--space-4) auto;
}

/* Tool section titles */
.main-content > div[id^="section-"] > h1,
.main-content > div[id^="section-"] > h2 {
    margin-top: 0;
}

/* Divider element you already use */
.divider {
    height: 2px;
    background: var(--border);
    border-radius: 999px;
    margin: var(--space-3) 0;
}

/* Outputs: make them consistent and readable */
#output-stringManipulation,
#output-stringConversion,
#output-caesarShift,
#output-beale,
#output-lettersNumbers,
#output-bacon,
#output-morse,
#output-morse-inverted,
#output-railfence,
#output-combined,
#output-atbash,
#output-letterSkipper,
#output-substitutionText,
#output-playfair,
#output-substitutionImages,
#output-searchTextInTextCommonWords,
#output-searchTextInTextLongestPhrase,
#output-periodicTable,
#output-caesarWordsearchWordsFound,
#subOutput {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(255,255,255,0.92);
    overflow: auto;
    word-break: break-word;
}

/* Make “code-like” outputs monospaced */
#output-stringManipulation,
#output-stringConversion,
#output-caesarShift,
#output-beale,
#output-lettersNumbers,
#output-bacon,
#output-morse,
#output-morse-inverted,
#output-railfence,
#output-combined,
#output-atbash,
#output-letterSkipper,
#output-playfair,
#output-searchTextInTextCommonWords,
#output-searchTextInTextLongestPhrase,
#output-periodicTable,
#output-caesarWordsearchWordsFound,
#subOutput,
#output-polybius,
#warningsText {
    font-family: var(--mono);
    font-size: 0.92rem;
}

/* -----------------------------
   Tables (scoped striping)
----------------------------- */

/* Remove the old global striping by NOT using tr:nth-child globally.
   Instead, stripe only your known tables. */
#tableStringManipulation,
#tableStringConversion,
#tableAnalysis,
#tableBeale,
#anagramsTable,
#tableSubstitutionInputImages {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid var(--border);
    background: rgba(255,255,255,0.85);
    border-radius: 10px;
    overflow: hidden;
}

/* Cell rules */
#tableStringManipulation td,
#tableStringConversion td,
#tableAnalysis td,
#tableBeale td,
#anagramsTable td,
#tableSubstitutionInputImages td {
    padding: 8px 10px;
    border: 1px solid rgba(0,0,0,0.18);
    vertical-align: top;
}

/* Zebra striping only where you want it */
#tableStringManipulation tr:nth-child(odd),
#tableStringConversion tr:nth-child(odd),
#tableAnalysis tr:nth-child(odd),
#tableBeale tr:nth-child(odd) {
    background: rgba(201, 158, 16, 0.14);
}

#tableStringManipulation tr:nth-child(even),
#tableStringConversion tr:nth-child(even),
#tableAnalysis tr:nth-child(even),
#tableBeale tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.75);
}

/* Analysis column sizing (keep intent, but less brittle) */
#tableAnalysis td:nth-child(1) { width: 26%; }
#tableAnalysis td:nth-child(2) { width: 60%; }
#tableAnalysis td:nth-child(3) { width: 14%; }

/* Analysis outputs should look like inputs but disabled */
#output-analysisTotalParagraphsCount,
#output-analysisTotalLineCount,
#output-analysisTotalSentenceCount,
#output-analysisTotalWordCount,
#output-analysisMissingLetters,
#output-letterFrequency,
#output-analysisFirstLetterByLine,
#output-analysisFirstLetterBySentence,
#output-analysisLastLetterByLine,
#output-analysisLastLetterBySentence,
#output-analysisCornerLetters,
#output-analysisWordCountByLine,
#output-analysisLetterCountByLine,
#output-analysisWordCountBySentence {
    height: 2.2rem;
    resize: none;
    font-family: var(--mono);
}

/* -----------------------------
   Specific: Caesar Word Search layout
----------------------------- */

.tables-wrapper {
    display: flex;
    gap: 18px;
    align-items: flex-start;
    flex-wrap: wrap; /* allows stacking when narrow */
}

.table-container {
    display: block;
    margin: 0;
}

#caesaredWordSearchInputTable,
#caesaredWordSearchOutputTable {
    border-collapse: collapse;
    background: rgba(255,255,255,0.92);
    border: 1px solid var(--border);
}

#caesaredWordSearchInputTable td,
#caesaredWordSearchOutputTable td {
    width: 1.35em;
    height: 1.35em;
    text-align: center;
    font-size: 1.05em;
    border: 1px solid rgba(0,0,0,0.18);
}

#output-caesarWordsearchWordsFound {
    white-space: pre-wrap;
}

#caesaredWordSearchOutputTable td.cws-highlight {
    outline: 2px solid rgba(0,0,0,0.75);
    background: rgba(201, 158, 16, 0.35);
}

#output-caesarWordsearchWordsFound .cws-word {
    cursor: pointer;
}

#output-caesarWordsearchWordsFound .cws-word-active {
    text-decoration: underline;
    font-weight: 700;
}

/* Fix this invalid rule you had:
   input[type="text"] { border: 1px solid empty; } */
#caesaredWordSearchInputTable input[type="text"],
#caesaredWordSearchOutputTable input[type="text"] {
    border: none;
    background: transparent;
    text-align: center;
    font: inherit;
    outline: none;
    padding: 0;
}

/* -----------------------------
   Substitution Text Tool: keep your namespacing, but harmonize tokens
----------------------------- */

#subTextTool {
    --bg: rgba(255,255,255,0.55);
    --panel: rgba(255,255,255,0.92);
    --text: #111;
    --muted: #555;
    --border: rgba(0,0,0,0.55);
    --soft-border: rgba(0,0,0,0.22);
    --warn: #b00020;

    color: var(--text);
    font-family: var(--sans);
    font-size: 16px;
}

#subTextTool .subTextWrap {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    padding: 12px;
    background: var(--bg);
    border-radius: 12px;
    border: 1px solid var(--soft-border);
}

#subTextTool .subTextPanel {
    background: var(--panel);
    border: 1px solid var(--soft-border);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 12px;
}

#subTextTool textarea,
#subTextTool .subTextMapInput,
#subTextTool pre {
    font-family: var(--mono);
}

/* -----------------------------
   Polybius: keep your existing namespacing; soften edges to match
----------------------------- */

#section-polybius .controlGroup,
#section-polybius .polybiusGridWrapper,
#section-polybius #warningsBlock {
    border-color: rgba(0,0,0,0.35);
    border-radius: 10px;
}

#section-polybius textarea,
#section-polybius select,
#section-polybius button,
#section-polybius .cellInput {
    border-color: rgba(0,0,0,0.35);
    border-radius: 10px;
}

/* -----------------------------
   Footer section
----------------------------- */

#section-footer {
    background: rgba(255,255,255,0.45);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: var(--space-4);
}

/* -----------------------------
   Responsive behavior
----------------------------- */

@media (max-width: 1000px) {
    :root { --menu-w: 320px; }
    .main-content { padding: var(--space-3); }
}

@media (max-width: 760px) {
    /* Sidebar becomes a normal flow block, content stacks */
    .menu {
        position: relative;
        width: 100%;
        height: auto;
        box-shadow: none;
    }

    .main-content {
        margin-left: 0;
        padding-top: var(--space-3);
    }

    #button-menu {
        display: block;
    }
}

/* Make “two-column button tables” behave better on smaller screens */
@media (max-width: 600px) {
    #tableStringManipulation td,
    #tableBeale td {
        display: block;
        width: 100%;
    }

    /* Reduce padding in tool sections for very small screens */
    .main-content > div[id^="section-"] {
        padding: var(--space-3);
    }
}

/* =========================
   MENU: prevent horizontal scroll
   ========================= */

/* Sidebar width scales with viewport; adjust as needed */
:root {
    /* was 360px; increase and clamp */
    --menu-w: clamp(360px, 34vw, 520px);
}

/* Ensure sidebar content wraps instead of forcing overflow */
.menu {
    overflow-x: hidden;          /* hard stop */
    word-break: break-word;      /* wrap long tokens */
    overflow-wrap: anywhere;     /* wrap long filenames/strings */
}

/* Make all controls fit the menu width */
.menu textarea,
.menu input,
.menu select,
.menu button {
    max-width: 100%;
}

/* Very common offender: long selected filename */
#window-selectedFileName,
#output-selectedFileName {
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* If you still see a tiny horizontal scroll from nested elements,
   this forces tables/blocks inside menu to respect width. */
.menu * {
    max-width: 100%;
}


/* =========================
   MORSE:
   ========================= */

.morse-error {
    color: #c00000;            /* red */
    font-weight: bold;
    padding: 0 2px;
}



/* =========================
   POLYBIUS: keep grid cells fixed
   ========================= */

/* Stop global text-input sizing from breaking Polybius cells */
#section-polybius input[type="text"],
#section-polybius input[type="search"],
#section-polybius input[type="email"],
#section-polybius input[type="url"],
#section-polybius input[type="tel"],
#section-polybius input[type="password"] {
    width: auto;
    max-width: none;
}

/* Ensure the actual grid input stays cell-sized */
#section-polybius .cellInput {
    width: 44px !important;
    height: 44px !important;
    padding: 0 !important;
    margin: 0 !important;
    border-radius: 6px;
    display: block;
}

/* Defensive: ensure grid wrapper doesn't compress to 0 and force wrapping */
#section-polybius #grid {
    align-items: stretch;
    justify-content: start;
    width: max-content;          /* allows horizontal scroll in wrapper, not cell wrap */
}

#section-polybius .polybiusGridWrapper {
    overflow-x: auto;
}

/* =========================================================
   POLYBIUS: force real grid columns (CSS fallback)
   Fixes "grid shows as a vertical list"
   Requires Chrome (supports :has)
   ========================================================= */

#section-polybius {
    /* default (5x5 board => 6 columns including header column) */
    --poly-cols: 6;
}

/* Set columns = (N + 1) based on selected board size */
#section-polybius:has(#boardSize option[value="5"]:checked) { --poly-cols: 6; }
#section-polybius:has(#boardSize option[value="6"]:checked) { --poly-cols: 7; }
#section-polybius:has(#boardSize option[value="7"]:checked) { --poly-cols: 8; }
#section-polybius:has(#boardSize option[value="8"]:checked) { --poly-cols: 9; }

/* Force #grid to behave like a fixed-cell grid regardless of JS */
#section-polybius #grid {
    display: grid !important;
    grid-template-columns: repeat(var(--poly-cols), 44px) !important;
    grid-auto-rows: 44px;
    gap: 2px;
    width: max-content;       /* allow horizontal scroll inside wrapper */
    justify-content: start;
    align-items: stretch;
}

/* Ensure children don't stretch and break layout */
#section-polybius #grid > * {
    width: 44px;
    height: 44px;
}

/* Keep the wrapper scroll (not the whole page) */
#section-polybius .polybiusGridWrapper {
    overflow-x: auto;
}


/* =========================
   SUBSTITUTION TEXT: mapping grid stays a grid
   ========================= */

/* Force stable columns: adjust min width to taste */
#subTextTool .subTextGrid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
    gap: 10px;
}

/* Ensure the cell structure remains vertical (tile above input) */
#subTextTool .subTextCell {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0; /* important: prevents overflow forcing weird wrapping */
}

/* Prevent global input[type="text"] width rules from breaking the grid */
#subTextTool input[type="text"] {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

/* Keep tile size consistent */
#subTextTool .subTextTile {
    height: 34px;
}

/* Full-width text inputs only in normal forms; exclude Polybius + grids */
.main-content input[type="text"],
.main-content input[type="number"],
.main-content select,
.main-content textarea,
.menu input[type="text"],
.menu input[type="number"],
.menu select,
.menu textarea {
    width: 100%;
}


/* =========================================================
   ANAGRAMS: tighten layout
   ========================================================= */

/* If your anagram section is #section-anagrams, this scopes the fixes nicely. */
#section-anagrams {
    /* reduce the big card padding just for this tool if needed */
    padding: 12px !important;
}

/* Tighten the anagrams table overall */
#section-anagrams #anagramsTable {
    border-collapse: collapse;
    border-spacing: 0;
    width: auto;                 /* don't stretch and create huge gaps */
    background: transparent;     /* stop “big sheet” look */
    border: none;                /* remove big card-like border if it got one */
}

/* Tighten cells */
#section-anagrams #anagramsTable td {
    padding: 2px 4px !important;     /* was big in the revamp */
    border: none !important;         /* prevents label-grid feel */
    background: transparent !important;
    vertical-align: middle;
    line-height: 1.15;
}

/* If you still want subtle row grouping, use a very light separator */
#section-anagrams #anagramsTable tr + tr td {
    padding-top: 4px !important;
}

/* Buttons inside anagrams: make them look like compact “chips”, not labels */
#section-anagrams #anagramsTable td > button {
    padding: 2px 6px !important;
    margin: 0 4px !important;        /* was 1em in your old CSS */
    border-radius: 6px !important;
    min-height: 0;
    line-height: 1.15;
    font-size: 0.92rem;
    box-shadow: none !important;
}

/* If your anagram words are spans/tds with class .word, tighten them too */
#section-anagrams #anagramsTable .word {
    padding: 2px 5px !important;
    margin: 0 2px !important;
    border-radius: 5px;
}

/* Preserve your selected state but keep it compact */
#section-anagrams #anagramsTable .word.isSelected,
#section-anagrams #anagramsTable.sentence .word.isSelected,
#section-anagrams #anagramsTable.compatible .word.isSelected {
    background-color: blue;
    color: white;
}

/* Your old rules used large margins for buttons; override them */
#section-anagrams #anagramsTable td:has(>button) {
    text-align: center;
}

/* =========================================================
   ANAGRAM CLUSTERS: wrap horizontally + black border per cluster
   ========================================================= */

#section-anagrams #anagramClusters {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 10px;
}

#section-anagrams #anagramClusters table.sentence {
    border: 2px solid #000;
    border-collapse: collapse;
    background: #fff;
    margin: 0;
}

#section-anagrams #anagramClusters table.sentence td {
    border: 1px solid #000;
    padding: 3px 6px;
    vertical-align: top;
    line-height: 1.15;
}

/* #section-anagrams #anagramClusters table.sentence .word.isSelected {
    background-color: blue;
    color: #fff;
} */

/* Selected word highlight – applies everywhere (anagrams + compatible list) */
#section-anagrams #anagramClusters .word.isSelected {
    background-color: blue;
    color: #fff;
}


/* =========================================================
   ANAGRAMS: compatible words as wrapping chips (no overflow)
   ========================================================= */

#section-anagrams .compatibleWords {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(255,255,255,0.92);
    max-width: 100%;
}

#section-anagrams .compatibleWords .wordChip {
    display: inline-block;
    padding: 4px 8px;
    border: 1px solid rgba(0,0,0,0.25);
    border-radius: 8px;
    background: rgba(255,255,255,0.85);
    font-family: var(--sans);
    font-size: 0.95rem;
    white-space: nowrap;
}

/* Anagrams form table should size naturally */
#section-anagrams table.form {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 8px;
    background: transparent;
    border: none;
}

#section-anagrams table.form td {
    background: rgba(255,255,255,0.75);
    border: 1px solid rgba(0,0,0,0.18);
    border-radius: 10px;
    padding: 10px;
}

#section-anagrams table.form .formLabel {
    width: 34%;
    text-align: right;
    font-weight: 700;
}

#section-anagrams .compatSpacer {
    height: 12px;
}

/* Compatible words should look/behave like normal anagram words */
#anagramsCompatible {
    margin-top: 10px;
}

/* If your .word already has styling, this simply makes chips compatible */
.word.wordChip {
    display: inline-block;
    cursor: pointer;
    user-select: none;
    margin: 3px 6px 3px 0;
}

/* Optional hover/focus affordance */
.word.wordChip:hover,
.word.wordChip:focus,
.word[data-word]:hover,
.word[data-word]:focus {
    text-decoration: underline;
    outline: none;
}

/* If your compatible buckets look different than the rest and you want them tighter */
.compatBucket {
    margin-bottom: 10px;
}

.compatHeader {
    margin-bottom: 6px;
    font-weight: bold;
}

.compatWords {
    line-height: 1.8;
}





/* =========================================================
   POPUP: keep hidden unless explicitly activated by JS
   ========================================================= */

.popup {
    position: fixed;
    inset: 0;                 /* top/right/bottom/left: 0 */
    z-index: 9999;
    display: none !important; /* hard hide by default */
    opacity: 0;
    background-color: rgba(255, 255, 255, 0.75);
    transition: opacity 0.2s ease;
}

/* JS should add .is-open when showing the popup */
.popup.is-open {
    display: block !important;
    opacity: 1;
}

.popup .popupcontent {
    position: absolute;
    left: 50%;
    top: 0;
    transform: translate(-50%, 60px);
    background-color: #ffd;
    padding: 20px;
    border: 1px solid #000;
    border-radius: 20px;
    text-align: center;
    max-width: min(720px, 92vw);
}

/* Ensure menu/sidebar never overlaps above popup */
.menu {
    z-index: 10;
}

[hidden] { display: none !important; }




#subTopGuesses {
  display: block !important;
  white-space: pre-wrap;
  max-height: none !important;
  overflow: visible !important;
}


/* Letter Bag Word Finder output */
.lbwSummary {
    margin-bottom: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(255,255,255,0.75);
}

.lbwGroup {
    margin: 12px 0;
    padding: 10px 12px;
    border: 1px solid rgba(0,0,0,0.25);
    border-radius: 10px;
    background: rgba(255,255,255,0.65);
}

.lbwGroupHeader {
    margin-bottom: 8px;
}

.lbwChips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

/* =========================
   Letter Bag Words output
   ========================= */

.lbw-results {
    max-width: 100%;
}

.lbw-meta {
    margin-bottom: 10px;
}

.lbw-group {
    margin: 10px 0 14px 0;
    padding-top: 8px;
    border-top: 1px solid rgba(0,0,0,0.18);
}

.lbw-header {
    font-weight: 700;
    margin-bottom: 8px;
}

/* Key part: wrap horizontally + spacing */
.lbw-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: flex-start;
}

/* Make each word visibly separate */
.lbw-chip {
    display: inline-block;
    padding: 3px 7px;
    border: 1px solid rgba(0,0,0,0.30);
    border-radius: 8px;
    background: rgba(255,255,255,0.9);
    font-family: var(--mono);
    font-size: 0.95rem;
    line-height: 1.2;
    white-space: nowrap;
}




























/*************/
/* This must be last */
/*************/
/* =========================================================
   MODAL POPUP: full-screen overlay, blocks interaction
   ========================================================= */

[hidden] { display: none !important; }

/* Overlay */
.popup {
    position: fixed;
    inset: 0;
    z-index: 99999;                /* must be above .menu (z=10) and everything else */
    display: none !important;      /* hidden by default */
    background: rgba(0, 0, 0, 0.55);
}

/* When open */
.popup.is-open {
    display: flex !important;      /* flex to center content */
    align-items: center;
    justify-content: center;
}

/* Dialog box */
.popup .popupcontent {
    background: #ffd;
    color: #000;

    width: min(720px, 92vw);
    max-height: min(80vh, 720px);
    overflow: auto;

    padding: 20px 22px;
    border: 2px solid #000;
    border-radius: 16px;

    box-shadow: 0 10px 40px rgba(0,0,0,0.35);
    position: relative;
}

/* Close button */
.popup .close {
    position: absolute;
    top: 10px;
    right: 10px;

    width: 36px;
    height: 36px;
    line-height: 34px;
    text-align: center;

    border-radius: 50%;
    border: 2px solid #000;
    background: rgba(0,0,0,0.1);
    cursor: pointer;
    user-select: none;
}

.popup .close:hover {
    background: #000;
    color: #fff;
}

/* Buttons inside dialog */
.popup .popupbutton {
    font-size: 1.05rem;
    padding: 6px 14px;
    border: 2px solid #000;
    border-radius: 8px;
    background: #ffa;
    cursor: pointer;
}

.popup .popupbutton:hover {
    background: #fd8;
}

/*************/
/* DO NOT PASTE ANYTHING AFTER THIS LINE */
/*************/