/* =============================================================
   MOBILE LAYER
   -------------------------------------------------------------
   Loaded AFTER style.css, so everything here wins on equal
   specificity and nothing already approved has to be undone.

   WHY A SEPARATE FILE RATHER THAN A MOBILE-FIRST REWRITE
   -------------------------------------------------------
   The existing sheets are desktop-first: full-width rules, then
   max-width queries to shrink them. Inverting that to true
   mobile-first (mobile as the base, min-width to enhance) means
   restructuring ~5,000 lines across four stylesheets, and every
   rule that currently reads "fine on desktop" would have to be
   re-derived. That is a large blast radius for a change whose
   whole point is that it looks right on a screen nobody opens
   during testing.

   This is additive instead. The desktop design is untouched and
   still the base; everything here is what a phone needs, in one
   place, applied at small widths. If a rule here is wrong it can
   be deleted without touching anything else.

   WHAT IS ACTUALLY WRONG ON A PHONE, AND WHY
   -----------------------------------------
   1. iOS zooms the page when a field's font is under 16px. Every
      13-14px .form-control below triggered it, so an admin typing
      a contest title got the page magnified and had to pinch back
      out to reach the next field. This is the single most visible
      defect and the reason .form-control is 16px here.
   2. 42px tap targets are below the 44px floor, and the small
      .btn-sm at ~30px is well below it. Both are enlarged.
   3. A notched phone clips the sticky top bar and the sidebar.
      env(safe-area-inset-*) is the fix; there is no other.
   4. Touch scrolling lags without -webkit-overflow-scrolling.
   ============================================================= */

/* ---------------------------------------------------------------
   1. FOUNDATION
   --------------------------------------------------------------- */

/* Stop iOS "text inflation". In landscape it scales text up to fill
   the viewport, which breaks every fixed-height row and card here. */
html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    /* Momentum scrolling on every scroll container, declared once. */
    -webkit-overflow-scrolling: touch;
}

/* ---------------------------------------------------------------
   1b. EVERYTHING VISUAL IS SCOPED TO A PHONE
   ---------------------------------------------------------------

   Everything from here to the end of section 12 lives inside a
   max-width query, and that is deliberate rather than tidy.

   16px inputs, 44px buttons and 16px card padding are right on a
   390px phone and wrong on a 1440px monitor - a 16px form field
   next to 13px body copy looks like a typo, and 44px-tall buttons
   make a dense admin table feel loose. Scoping them keeps the
   desktop design exactly as approved, and makes this file safe to
   load everywhere: it can only ever affect a phone.

   1024px is the same breakpoint the sidebar drawer already uses, so
   there is one line in the CSS where "this is a phone/tablet now"
   is decided, not two that can disagree.
   --------------------------------------------------------------- */
@media (max-width: 1024px) {

/* The scrollbar gutter only exists on desktop. Reserving it on a
   phone steals 15px of an already narrow screen for a scrollbar
   that is never visible (overlay scrollbars), which pushed wide
   tables one notch further off-screen for nothing. */
html { scrollbar-gutter: auto; }

/* Belt and braces against a sideways-scrolling page. The whole
   design assumes the page itself never scrolls horizontally - only
   .table-wrapper and .matrix-wrap do. A single over-wide element
   anywhere (a long URL in a read-only input, a nowrap heading)
   otherwise turns the entire page into a sideways-scrolling mess
   on a phone, and no amount of table-level overflow handling
   helps. */
body { overflow-x: hidden; }
/* ...but the scroll containers must keep their own overflow, so
   they are opted back in explicitly. */
body .table-wrapper,
body .matrix-wrap,
body .table-scroll,
body .sc-table-wrap,
body .lp-table-wrap { overflow-x: auto; }

/* ---------------------------------------------------------------
   2. FORM CONTROLS - the iOS zoom fix
   --------------------------------------------------------------- */

/* 16px is not a style preference, it is the threshold below which
   Safari zooms on focus. At 14px the admin filled in a form and the
   viewport jumped, hiding the fields they were moving between. */
.form-control,
select.form-control,
textarea.form-control,
.login-input,
.login-input-wrap input {
    font-size: 16px;
    /* 16px type needs a little more box to stay legible at that size. */
    padding: 12px 14px;
    /* iOS zooms on focus of any field; :focus is too late to stop it,
       so the size must be right before the tap. This line is the
       whole reason for the block above it. */
}

/* Height as well as font, so a date picker or number field is not
   shorter than the text field beside it. */
input[type="date"].form-control,
input[type="number"].form-control,
input[type="time"].form-control { min-height: 46px; }

/* Selects match the height of every other field here, and leave room for the
   native arrow, which otherwise sits on top of the text at 16px.

   This rule used to add height:200px as well. style.css did the same at every
   width, so the box was oversized on desktop too; both are gone now. See the note
   beside the select rule in style.css for why the tall box is no longer needed. */
select.form-control {
    min-height: 46px;
    padding-right: 34px;
}

/* --- Contest picker ---
   The searchable picker replaced the tall native contest select, so its trigger
   gets the same 16px / 46px treatment as every other field here, and the panel
   spans the screen instead of the field's 260px - a 260px dropdown with a
   category chip on each row is unreadable at that width. The option list still
   caps at ten rows inside it, which is the point of the control.

   .cs-native is not reset here: the select is display:none, so the rule above
   does not apply to anything the eye can see. It stays in the form, which is
   why the trigger has to look like the field it replaced. */
.cs-trigger,
.qr-switcher .cs-trigger {
    font-size: 16px;
    min-height: 46px;
    padding: 12px 14px;
}
/* Full-bleed across the screen. No max-height here: contest-select.js sizes
   the option list to the room it actually measured, and capping the panel as
   well would clip that list rather than help it. */
.cs-panel {
    left: 8px !important;
    right: 8px;
    width: auto !important;
}
.cs-opt { padding: 12px 10px; }
.cs-opt-title { font-size: 15px; }
.cs-opt-cat { max-width: 50%; }
.cs-search { font-size: 16px; padding: 10px 12px 10px 30px; }

/* The eye toggle on password fields sat at 42px and sat too close
   to the edge of a phone screen. */
.form-control.has-toggle { padding-right: 46px; }
.pw-toggle,
.login-toggle {
    width: 46px; height: 46px;
    /* The toggle is vertically centred in the input's own height
       rather than a fixed offset, so it stays centred now that the
       input grew. */
    top: 50%; transform: translateY(-50%);
}

/* ---------------------------------------------------------------
   3. TAP TARGETS
   --------------------------------------------------------------- */

/* 44px is the smallest target reliably hittable with a thumb. The
   buttons were 38px (.btn-sm) and ~30px inside dense tables. */
.btn,
.btn-sm {
    min-height: 44px;
    /* Vertical padding stays as it was; min-height does the work, and
       a real phone button that grows to 44px should not also grow
       proportionally in width. */
    justify-content: center;
    /* A flex row with three actions in it used to shrink each button
       until its label wrapped one letter per line ("Down/load
       PNG"). Buttons keep their label on one line and the row wraps
       instead - the rule below makes .d-flex rows wrap. */
    flex-shrink: 0;
    white-space: nowrap;
}
/* Primary actions in a form get the full width: on a phone a
   right-aligned Save button is both hard to hit and easy to miss. */
.form-group + .d-flex .btn,
.card-body > form > .d-flex .btn { width: 100%; }
.card-body > form > .d-flex { flex-wrap: wrap; }

/* Nav and tab links: the setup tabs and the filter pills are the
   most-used controls on the Contests tab and were 36px tall. */
.setup-tabs a,
.setup-type-filter .btn,
.contest-category-tab {
    min-height: 44px;
    display: inline-flex; align-items: center; justify-content: center;
}
/* The filter row scrolls sideways rather than wrapping into three
   full-width rows, which on a phone pushed the table below the
   fold before any contest was visible. */
.setup-type-filter {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    /* Room for the scroll, so the last pill is not flush to the edge. */
    padding-bottom: 2px;
}
.setup-type-filter::-webkit-scrollbar { display: none; }
.setup-type-filter .btn { flex: 0 0 auto; white-space: nowrap; }

/* Inline controls inside a table row - Edit / Delete - were the
   smallest and most-fingered targets in the app. */
td .btn-sm,
.data-table td .btn-sm { min-height: 44px; padding: 8px 14px; }

/* The row Actions menu trigger. */
.act-menu-trigger { min-height: 44px; }

/* Icon-only controls in the top bar: 42px circles, and the bell's
   badge sits on the edge. */
.notif-bell,
.guide-btn,
.sidebar-toggle { width: 44px; height: 44px; }

/* The switch on the Settings page. */
.switch-track { width: 52px; height: 30px; }
.switch-thumb { width: 24px; height: 24px; }
.switch-input:checked ~ .switch .switch-thumb { transform: translateX(22px); }

/* Checkboxes and radios get a bigger hit area without growing the
   drawn box, so labels stay the tap target. */
input[type="checkbox"],
input[type="radio"] { min-width: 22px; min-height: 22px; }

/* ---------------------------------------------------------------
   4. SAFE AREAS - notched phones
   --------------------------------------------------------------- */

/* On a phone with a notch or a home indicator, a full-bleed fixed
   header is drawn UNDER the notch: the title is clipped and the
   bell is half off-screen. env() is the only thing that knows where
   the hardware cutout is. */
.top-bar {
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
    padding-top: env(safe-area-inset-top);
    height: auto;
    min-height: var(--topbar-h);
}

/* The sidebar is a full-height fixed panel: same clipping, top and
   bottom. */
.sidebar {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
}

/* The page needs the same at the bottom, or the last row of a form
   sits under the home indicator and cannot be tapped. */
.page-content {
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
    padding-bottom: calc(28px + env(safe-area-inset-bottom));
}

/* ---------------------------------------------------------------
   5. LAYOUT - stacking and overflow
   --------------------------------------------------------------- */

/* Cards were 24px padded on each side, leaving ~290px of usable
   width on a small phone for a two-column grid. */
.card-header { padding: 16px; flex-wrap: wrap; }
.card-body { padding: 16px; }

/* Every two-column grid in the app becomes one column. Set at a
   wide-ish phone breakpoint rather than 768px: a 768px-wide screen
   held two cramped columns, which is worse than one good one. */
@media (max-width: 900px) {
    .dashboard-grid,
    .settings-grid,
    .form-row,
    .stats-grid { grid-template-columns: minmax(0, 1fr) !important; }

    /* minmax(0, 1fr) alone is not enough - a grid item defaults to
       min-width:auto and refuses to shrink below its content, which
       is what pushes a card past the viewport. */
    .dashboard-grid > *,
    .settings-grid > *,
    .form-row > * { min-width: 0; }
}

/* The settings switch row wraps instead of crushing the explanation
   beside the control. */
.switch-row { flex-wrap: wrap; }
.switch-text { flex: 1 1 200px; }

/* Rows of actions wrap rather than compressing their labels into a
   vertical stack. .d-flex is used for toolbars, modal footers and
   form actions all over the app; on a phone the exact same row can
   hold three buttons that no longer fit side by side. Wrapping is
   the only outcome that keeps every label readable. */
.d-flex { flex-wrap: wrap; }

/* Card headers with their own action cluster: the cluster takes its
   own row under the title instead of pushing past the card's right
   edge. The QR page measured 495px inside a 356px header - the
   contest picker and status badge ran off the screen while the card
   itself still reported no overflow, because the child overflowed
   its parent rather than the page. */
.card-header-actions {
    flex-wrap: wrap;
    min-width: 0;
}
@media (max-width: 640px) {
    .card-header-actions { gap: 8px; width: 100%; }
    .card-header-actions > * { min-width: 0; }
    .qr-switcher { flex: 1 1 100%; }
    .qr-switcher .form-control,
    .qr-switcher .cs { width: 100%; max-width: none; }

    /* The QR code, its download/print/refresh row, the judging link
       and the two judging-state forms all sit in fixed rows on
       desktop. On a phone each becomes a full-width block: the three
       action buttons used to shrink until "Download PNG" read one
       character per line. */
    .qr-container { padding: 16px 0; }
    .qr-container .d-flex { flex-wrap: wrap; }
    .qr-container .d-flex .btn { flex: 1 1 auto; }
    .qr-link-box { flex-wrap: wrap; }
    .qr-link-box .form-control { flex: 1 1 160px; min-width: 0; width: auto; }
    .card-body .d-flex > form { flex: 1 1 100%; min-width: 0; }
    .card-body .d-flex > form .btn { width: 100%; }

    /* The All Contests / Sports / Non-Sports folders are three equal
       flex items at this width. Each was left ~40px of text beside a
       34px icon, so "Non-Sports" broke into two letters per line and
       the row set the page wider than the screen. Two columns above
       420px and one column on the smallest phones gives the labels
       the room they need. */
    .contest-group-tabs {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 6px;
    }
    .contest-group-tab {
        min-width: 0;
        width: auto;
        flex: none;
    }
    .contest-group-tab:first-child { grid-column: 1 / -1; }

    /* The search form never wraps, and its automatic minimum width is
       the input's intrinsic width plus the Search button (302px). The
       actions row is only 262px at 320, so the form refused to shrink
       and stretched the whole page to 331px. With min-width:0 the
       input - already allowed to shrink - gives up the difference. */
    .contest-list-actions .setup-search { min-width: 0; }
}
@media (max-width: 420px) {
    .contest-group-tabs { grid-template-columns: minmax(0, 1fr); }
    .contest-group-tab:first-child { grid-column: auto; }
}

/* Read-only inputs showing a long value (a judging link, a URL)
   must not widen their card. */
.form-control[readonly] { overflow-x: auto; white-space: nowrap; }

/* ---------------------------------------------------------------
   6. TABLES
   --------------------------------------------------------------- */

/* The responsive stack (each row becomes a labelled card) is the
   right answer on a phone, but it only applied at 768px. It is
   correct at every width a phone has, so it is applied from here
   instead - and this also covers the tables that did not carry the
   class, which previously scrolled sideways with no way to read a
   row's label. */
@media (max-width: 768px) {

    /* The stacked form is unreadable with a sticky header still
       painted over the first card, so the heading goes. */
    .ct-table thead th,
    .ct-table td:last-child,
    .data-table.ct-table thead { position: static; }

    /* The sticky # and Contestant columns have nothing left to stick
       to once rows are full-width cards. */
    .sticky-col { position: static !important; box-shadow: none !important; }
    .sticky-col thead { display: block; }

    /* Stacked rows need breathing room between them, which the
       table borders do not provide on their own. */
    .ct-table tbody tr {
        display: block;
        border: 1px solid var(--border);
        border-radius: 12px;
        margin-bottom: 12px;
        padding: 12px 14px;
        background: #fff;
        box-shadow: var(--shadow-sm, 0 1px 3px rgba(16,40,32,.07));
    }
    .ct-table tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 12px;
        padding: 7px 0;
        border: none;
        text-align: right;
        /* Long titles wrap instead of overflowing the card. */
        min-width: 0;
        overflow-wrap: anywhere;
    }
    /* Each cell announces its own column via the data-label the
       markup already carries - no extra markup needed. */
    .ct-table tbody td::before {
        content: attr(data-label);
        font-size: 11px;
        font-weight: 800;
        letter-spacing: .5px;
        text-transform: uppercase;
        color: var(--text-muted);
        text-align: left;
        flex: 0 0 auto;
    }
    /* The title is the point of the row, so it leads and stays left. */
    .ct-table tbody td[data-label="Title"] {
        font-size: 15px;
        font-weight: 700;
        text-align: left;
        margin-bottom: 4px;
    }
    .ct-table tbody td[data-label="Title"]::before { display: none; }
    .ct-table tbody td[data-label="Actions"] { justify-content: flex-end; }
}

/* The results matrix keeps its horizontal scroll - stacking one row
   per contestant would destroy the comparison the matrix exists for -
   but the scroll needs to be discoverable and must not fight the
   page. */
@media (max-width: 768px) {
    .matrix-wrap,
    .table-scroll-tall,
    .table-wrapper { border-radius: 10px; }

    /* A sticky heading inside a scroller is what makes a wide matrix
       readable, but it costs vertical space on a phone where there
       is little to spare. The heading stays - it is the only place
       the contest names appear - but it is tightened. */
    .matrix-wrap thead th,
    .table-scroll-tall thead th { font-size: 12px; padding: 8px 10px; }

    /* The contestant column is the anchor for every other number on
       screen; it keeps most of its width and the event columns give
       up theirs. */
    .sticky-name { min-width: 132px; }
    .sticky-rank { width: 40px; min-width: 40px; }
    .data-table.matrix .matrix-col { min-width: 104px; }
}

/* ---------------------------------------------------------------
   6b. SCORE SHEETS - one card per criterion on a phone
   ---------------------------------------------------------------
   The scoring sheet and the two read-only receipts are five-column
   tables whose content is not interchangeable: a criterion, its
   description, its weight, the score and the points it contributed.
   Their minimum widths (760px, 940px, 820px) meant a 320-390px phone
   showed only the first two columns, with the Weight, Score and
   Points columns parked off-screen behind an invisible scroll - the
   numbers a judge is actually checking.

   Stacking is the only layout that keeps all five numbers on screen
   together. Each row becomes its own card: criterion and description
   across the full width, then Weight / Score / Points in three equal
   columns. The column headings move into ::before labels on those
   three cells, so the numbers keep the words they belong to. The
   markup is untouched, and this is screen-only so the printed sheets
   keep their table layout.
   --------------------------------------------------------------- */
@media screen and (max-width: 768px) {
    body[data-judge-page="evaluate"] .sc-table,
    body[data-judge-page="view"] .view-score-table,
    .sv-table {
        display: block;
        width: 100%;
        min-width: 0;
        border-collapse: separate;
        border-spacing: 0;
    }
    body[data-judge-page="evaluate"] .sc-table thead,
    body[data-judge-page="view"] .view-score-table thead,
    .sv-table thead { display: none; }
    body[data-judge-page="evaluate"] .sc-table tbody,
    body[data-judge-page="view"] .view-score-table tbody,
    .sv-table tbody { display: block; }

    body[data-judge-page="evaluate"] .sc-table tbody tr,
    body[data-judge-page="view"] .view-score-table tbody tr,
    .sv-table tbody tr {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 2px 12px;
        padding: 12px;
        margin: 0 0 10px;
        border: 1px solid #DCEAE4;
        border-radius: 12px;
        background: #fff;
        break-inside: avoid;
    }
    /* The submission view has a fourth column, not a fifth: two
       equal numeric cells read better than two thirds of a row. */
    .sv-table tbody tr { grid-template-columns: repeat(2, minmax(0, 1fr)); }

    body[data-judge-page="evaluate"] .sc-table tbody tr > th,
    body[data-judge-page="evaluate"] .sc-table tbody tr > td,
    body[data-judge-page="view"] .view-score-table tbody tr > td,
    .sv-table tbody tr > td {
        display: block;
        width: auto !important;
        min-width: 0 !important;
        max-width: none !important;
        padding: 3px 0 !important;
        border: 0 !important;
        background: transparent !important;
        text-align: left;
    }
    body[data-judge-page="evaluate"] .sc-table tbody tr > :first-child,
    body[data-judge-page="view"] .view-score-table tbody tr > td:first-child,
    .sv-table tbody tr > td:first-child { grid-column: 1 / -1; }
    body[data-judge-page="evaluate"] .sc-table tbody tr:not(.sc-group-row):not(.sc-group-empty) > td:nth-child(2),
    body[data-judge-page="view"] .view-score-table tbody tr > td:nth-child(2),
    .sv-table tbody tr > td:nth-child(2) { grid-column: 1 / -1; }

    /* A Main Criteria row is the group heading: it keeps its tint
       across the whole card so the subcriteria below it still read
       as belonging to it. */
    body[data-judge-page="evaluate"] .sc-table tbody tr.sc-group-row,
    body[data-judge-page="view"] .view-score-table tbody tr.rv-group-row,
    .sv-table tbody tr.rv-group-row {
        background: var(--mint);
        border-color: #BFE3D0;
        border-top: 2px solid var(--emerald);
    }

    body[data-judge-page="evaluate"] .sc-table tbody tr > td.num,
    body[data-judge-page="view"] .view-score-table tbody tr > td.num,
    .sv-table tbody tr > td.num { text-align: center; }

    /* The three numeric cells each announce their heading. The
       submission view only has Score / Points, so its pair is
       labelled separately below. */
    body[data-judge-page="evaluate"] .sc-table tbody tr:not(.sc-group-row):not(.sc-group-empty) > td:nth-child(3)::before,
    body[data-judge-page="evaluate"] .sc-table tbody tr.sc-group-row > td:nth-child(2)::before,
    body[data-judge-page="view"] .view-score-table tbody tr > td:nth-child(3)::before { content: "Weight"; }
    body[data-judge-page="evaluate"] .sc-table tbody tr:not(.sc-group-row):not(.sc-group-empty) > td:nth-child(4)::before,
    body[data-judge-page="evaluate"] .sc-table tbody tr.sc-group-row > td:nth-child(3)::before,
    body[data-judge-page="view"] .view-score-table tbody tr > td:nth-child(4)::before { content: "Score"; }
    body[data-judge-page="evaluate"] .sc-table tbody tr:not(.sc-group-row):not(.sc-group-empty) > td:nth-child(5)::before,
    body[data-judge-page="evaluate"] .sc-table tbody tr.sc-group-row > td:nth-child(4)::before,
    body[data-judge-page="view"] .view-score-table tbody tr > td:nth-child(5)::before { content: "Points"; }
    .sv-table tbody tr > td:nth-child(3)::before { content: "Score"; }
    .sv-table tbody tr > td:nth-child(4)::before { content: "Points"; }

    body[data-judge-page="evaluate"] .sc-table tbody tr > td.num::before,
    body[data-judge-page="view"] .view-score-table tbody tr > td.num::before,
    .sv-table tbody tr > td.num::before {
        display: block;
        margin-bottom: 2px;
        font-size: 9px;
        line-height: 1.2;
        font-weight: 800;
        letter-spacing: .07em;
        text-transform: uppercase;
        color: var(--text-muted);
        text-align: center;
    }

    /* The score box was 86px wide at minimum, which is wider than a
       third of a 320px phone once the card's padding is removed.
       16px type is the iOS no-zoom threshold. */
    body[data-judge-page="evaluate"] .sc-score-input {
        min-width: 0;
        max-width: none;
        width: 100%;
        padding: 8px 6px;
        font-size: 16px;
    }
    body[data-judge-page="evaluate"] .sc-table .sc-crit,
    body[data-judge-page="evaluate"] .sc-table .sc-desc,
    body[data-judge-page="view"] .view-score-table .rv-crit,
    .sv-table .rv-crit { min-width: 0; max-width: none; }

    body[data-judge-page="evaluate"] .sc-table tbody tr.sc-group-empty > td {
        grid-column: 1 / -1;
        text-align: center;
    }
}

/* ---------------------------------------------------------------
   7. MODALS AND DIALOGS
   --------------------------------------------------------------- */

/* Modals were capped at max-height 90vh with the body scrolling
   inside, which on a phone means a dialog whose header scrolls away
   and whose close button cannot be reached. */
.modal {
    width: calc(100% - 16px);
    max-width: none;
    max-height: calc(100dvh - 32px);
    /* dvh is the honest unit: vh is the browser chrome height, so a
       vh-based dialog is taller than the visible area on a phone and
       its footer sits under the home indicator. */
    margin: auto;
}
.modal-header { padding: 14px 16px; }
.modal-body { padding: 16px; }
/* The footer stays put and the body scrolls, so Close is always
   reachable however long the content is. */
.modal-body { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.modal-footer { padding: 12px 16px; }
.modal-footer .btn { flex: 1; }

/* The guide is a paged dialog with a Next button - it must work with
   a thumb, and its own slide is a scrolling column. */
.modal-guide .modal-body { padding: 16px 14px; }
.guide-nav .btn { min-height: 44px; flex: 1; }

/* ---------------------------------------------------------------
   8. TOASTS
   --------------------------------------------------------------- */

/* Toasts sat at a fixed inset from the right edge, which put them
   off-screen or half-visible on a phone, and they covered the
   bottom of the content they were reporting on. */
.sc-toast,
#livePill,
.notify-toast {
    left: 12px !important;
    right: 12px !important;
    bottom: calc(12px + env(safe-area-inset-bottom)) !important;
    width: auto !important;
    max-width: none !important;
}

/* ---------------------------------------------------------------
   9. SIDEBAR DRAWER
   --------------------------------------------------------------- */

/* The drawer slides in but has no backdrop, so the page behind it
   stays tappable and half-visible - and there is no visual cue that
   the nav is a temporary layer. */
@media (max-width: 1024px) {
    .sidebar { box-shadow: none; }
    .sidebar.open { box-shadow: 0 0 40px rgba(0,0,0,.4); }

    /* Nav links get the same 44px floor as everything else. */
    .sidebar-nav a { min-height: 44px; }

    /* The drawer is fixed and full-height: keep it inside the
       notch at the bottom too. */
    .sidebar .sidebar-footer { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
}

/* ---------------------------------------------------------------
   10. TEXT
   --------------------------------------------------------------- */

/* Long unbroken strings - a contestant name, a judging link, an
   email - are the classic cause of a page-wide horizontal scrollbar
   on a phone. */
.page-content,
.card-body,
.activity-text,
.winner-card,
.setup-selector-title { overflow-wrap: anywhere; }

/* The top bar title truncates rather than pushing the bell off. */
.top-bar-heading { min-width: 0; }
.top-bar-title {
    font-size: 17px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Sub-labels and helper text were 11-12px, which is below the
   readable floor on a phone at arm's length. */
.form-hint,
.login-hint,
.rt-sub,
.setup-selector-sub { font-size: 13px; }

/* The receipt's contest banner is icon + title + a "Submitted and
   Signed" pill on one line. On a 320px phone the pill won 173px of
   the row and the contest name was squeezed to a one-character
   column, while the pill itself still ran past the card edge. The
   name gets the first line; the pill moves below it intact. */
@media (max-width: 640px) {
    body[data-judge-page="view"] .view-contest-head { flex-wrap: wrap; }
    body[data-judge-page="view"] .view-contest-head .sc-card-text {
        flex: 1 1 calc(100% - 56px);
    }
    body[data-judge-page="view"] .view-contest-head > .cf-pill {
        max-width: 100%;
        white-space: normal;
    }
    /* Same shape in the certification heading, and the signature
       thumbnail + "View signature" link no longer sit in one
       unbreakable row (190px + 91px inside ~254px). */
    body[data-judge-page="view"] .view-certification-heading { flex-wrap: wrap; }
    body[data-judge-page="view"] .view-certification-heading > .cf-pill { max-width: 100%; }
    body[data-judge-page="view"] .view-signature-trigger {
        flex-wrap: wrap;
        max-width: 100%;
    }
    body[data-judge-page="view"] .view-signature-thumb {
        flex: 0 1 190px;
        max-width: 100%;
    }
}

} /* end of the max-width: 1024px phone block */

/* ---------------------------------------------------------------
   11. HOVER  - gated on pointer type, not width
   ---------------------------------------------------------------

   Closed out of the phone block above, because these two rules are
   gated by whether the device HAS a pointer rather than how wide it
   is. A large touchscreen (an iPad in landscape, a tablet) is wider
   than 1024px and still has no hover, and it needs the :active
   feedback just as much as a phone does. Wrapping them in the width
   query would have left every tablet with no tap feedback at all.
   --------------------------------------------------------------- */

/* :hover sticks on a touch screen. A phone that taps a button leaves
   it in the hovered state until you tap elsewhere, so every hover
   colour change becomes a permanent-looking one after a single tap.
   Wrapped in @media (hover: hover) so they apply only where a real
   pointer exists. */
@media (hover: hover) {
    .btn-primary:hover { background: var(--emerald); }
    .btn-secondary:hover { background: var(--mint); }
}

/* On a touch device the hover rules are simply not applied, so the
   only feedback a tap gives is the :active state - which nothing in
   the design sets. Given. */
@media (hover: none) {
    .btn:active,
    .setup-tabs a:active,
    .notif-bell:active,
    .guide-btn:active { transform: scale(.97); opacity: .9; }
    /* No transition on transform for touch: it reads as lag. */
    .btn, .setup-tabs a { transition: background-color .15s ease, opacity .15s ease; }
}

/* ---------------------------------------------------------------
   12. LANDSCAPE
   --------------------------------------------------------------- */

/* A phone in landscape is ~360px tall. A tall sticky header plus
   page padding leaves almost nothing for content, so the header
   gives its height back rather than the page scrolling a screenful
   before anything appears. */
@media (max-height: 480px) and (orientation: landscape) {
    .top-bar { min-height: 48px; }
    .page-content { padding-top: 12px; }
    .card-header { padding: 12px 16px; }
    .card-body { padding: 12px 16px; }
    /* The heading is still worth keeping - it is what identifies the
       contest - but it must not eat the viewport. */
    .top-bar-title { font-size: 15px; }
}

/* ---------------------------------------------------------------
   13. PRINT
   --------------------------------------------------------------- */

/* The responsive stack and the phone layout must never reach paper.
   style.css already reverts the stacking rules for print; these two
   undo this file's own contributions, because print on a phone is a
   real thing to do with a results sheet. */
@media print {
    .form-control,
    .btn,
    .btn-sm,
    .setup-tabs a,
    td .btn-sm { min-height: 0; }
    .form-control { font-size: 11pt; }
    .modal { max-height: none; width: auto; max-width: none; }
    .page-content { padding: 0; }
}
