/* The Tactical Board on a phone, in the PrecisionPlay app (since 2026-12-01 -
   the website on a phone says to get the app). html.board-phone is set by
   tactical_board.html from the browser's identity (app.py), and every rule
   here starts with it, so tablets and computers are untouched. The board is
   drawn smaller than the size it works at, so a drill looks as it does on a
   computer (phoneWorkingSize in tactical_board_core.js).

   The board fills the screen like an app: the page's header, footer and the
   video below are hidden; a top bar (the panel buttons - .mobile-panel-
   toggles - plus Home, AI and the colour for new players) sits above the
   pitch and the toolbar below it, one row you swipe along. Turned sideways
   the toolbar becomes a rail down the left and the top bar one down the
   right, so the pitch keeps the screen's whole height. The canvas is sized
   to the space left (phoneBoardSpace in tactical_board_core.js). The side
   panels and the toolbar's menus open as sheets over the pitch
   (tactical_board_phone.js). Selectors start "html.board-phone
   .tactical-container" where the board's own rules for narrow windows and
   tablets (tactical_board.html, tactical_board_enhancements.css) would
   otherwise win. */

/* Only on a phone */
.phone-only { display: none !important; }
.mpt-short { display: none; }

/* A touch screen (tablets too) has no right-click - a press and hold opens
   the same menu (tactical_board_core.js) */
.tip-touch { display: none; }
@media (pointer: coarse) {
    .tip-mouse { display: none; }
    .tip-touch { display: inline; }
}

html.board-phone,
html.board-phone body {
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
    background: #1b2128;
}

/* The page around the board */
html.board-phone header[role="banner"],
html.board-phone footer[role="contentinfo"],
html.board-phone .tb-tutorial-section,
html.board-phone #mobileDesktopBanner,
html.board-phone .help-widget-btn,
html.board-phone .help-panel,
html.board-phone .tactical-container .board-status,
html.board-phone .tactical-container .hotkeys-section,
html.board-phone .keyboard-tip,
html.board-phone #fullscreenBtn {
    display: none !important;
}

html.board-phone .tactical-container {
    position: fixed;
    inset: 0;
    z-index: 900;
    max-width: none;
    width: auto;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    background: #1b2128;
    /* (the page's fade-in slides it with a transform - which would make the
       sheets inside position against it instead of the screen) */
    animation: none;
    transform: none;
    -webkit-user-select: none;
    user-select: none;
}
html.board-phone .tactical-container.cinematic-mode { padding: 0; }

/* ---- Top bar ---- */
html.board-phone .tactical-container .mobile-panel-toggles {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 6px;
    margin: 0;
    padding: 6px 8px;
    background: #0e2338;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    position: relative;
    z-index: 3;
}
/* (all of it here - the board's own button rules only apply below 768px
   wide, and a phone on its side is wider) */
html.board-phone .tactical-container .mobile-panel-toggle {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    flex: 1 1 0;
    min-width: 0;
    min-height: 42px;
    margin: 0;
    padding: 0 8px;
    gap: 5px;
    border: 0;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.1);
    box-shadow: none;
    color: #ffffff;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.1;
    text-align: center;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
html.board-phone .tactical-container .mobile-panel-toggle svg { flex-shrink: 0; }
html.board-phone .tactical-container .mobile-panel-toggle:active { background: #ff6b00; color: #0e2338; }
html.board-phone .tactical-container .phone-only { display: flex !important; }
html.board-phone .tactical-container .mpt-long { display: none; }
html.board-phone .tactical-container .mpt-short { display: inline; }
html.board-phone .tactical-container .phone-home { flex: 0 0 auto; padding: 0 12px; }
html.board-phone .tactical-container .phone-ai { color: #ffb066; }

/* The colour for new players: a dot, and its menu of swatches */
html.board-phone .tactical-container .phone-colour { position: relative; flex: 0 0 auto; }
html.board-phone .tactical-container .phone-colour > .mobile-panel-toggle { flex: 0 0 auto; width: 48px; padding: 0; }
.phone-colour-dot {
    display: block;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.85);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
    background: #ffffff;
}
html.board-phone .phone-colour-menu {
    position: fixed;
    z-index: 1990;
    top: calc(var(--phone-topbar-h, 54px) + 6px);
    right: 8px;
    display: grid;
    grid-template-columns: repeat(4, 44px);
    gap: 8px;
    padding: 10px;
    border-radius: 14px;
    background: var(--dmbg-ffffff, #ffffff);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}
html.board-phone .phone-colour-menu[hidden] { display: none; }
html.board-phone .phone-colour-menu button {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid rgba(0, 0, 0, 0.15);
    padding: 0;
    cursor: pointer;
}
html.board-phone .phone-colour-menu button[aria-checked="true"] { box-shadow: 0 0 0 3px #ff6b00; }

/* "Reset View" (shown after pinching in or moving the view): a clear button
   over the pitch's top corner, above everything on the board - it's moved
   out of the top bar (tactical_board_phone.js) */
html.board-phone .tactical-container #resetViewBtn {
    position: fixed;
    top: calc(var(--phone-topbar-h, 54px) + 10px);
    right: 10px;
    z-index: 30;
    flex: 0 0 auto;
    width: auto;
    min-height: 44px;
    padding: 0 16px;
    gap: 6px;
    border-radius: 999px;
    background: #ff6b00 !important;
    color: #0e2338;
    font-size: 15px;
    font-weight: 700;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
}
html.board-phone .tactical-container #resetViewBtn svg { width: 20px; height: 20px; }

/* ---- The pitch ---- */
html.board-phone .tactical-container .main-layout {
    flex: 1 1 auto;
    min-height: 0;
    min-width: 0;
    display: flex;
    /* (the narrow-window rules stack and centre it - which let the pitch's
       column grow to its toolbar's full width, off the screen) */
    flex-direction: row;
    align-items: stretch;
    justify-content: flex-start;
    flex-wrap: nowrap;
    margin: 0;
    padding: 0;
    gap: 0;
    height: auto;
    max-width: none;
}
html.board-phone .tactical-container .center-panel {
    order: 0;
    flex: 1 1 auto;
    width: auto;
    max-width: 100%;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: visible;
}
html.board-phone .tactical-container .center-panel .canvas-wrapper {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    max-width: none;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 0;
    overflow: visible;
    background: transparent;
}
/* (Fabric's own box around the canvas) - centred in the space left */
html.board-phone .tactical-container .canvas-wrapper > .canvas-container {
    margin: auto;
    flex: 0 0 auto;
}
/* The frame round the pitch is a shadow here, not the computer's 3px border:
   the border made the pitch 6px bigger than Fabric's box round it, so it sat
   3px right of and below the middle - and 3px off the top layer, where a
   drag-select box or a line being drawn shows */
html.board-phone .tactical-container .center-panel #tacticalCanvas {
    border: 0;
    box-shadow: 0 0 0 3px #3d3d3d, 0 6px 24px rgba(0, 0, 0, 0.45);
}

/* Under the pitch (upright): the animation strip, then the toolbar */
html.board-phone .tactical-container .canvas-wrapper > .canvas-container { order: 0; }
html.board-phone .tactical-container .canvas-wrapper > .phone-anim-strip { order: 1; }
html.board-phone .tactical-container .canvas-wrapper > .bottom-toolbar { order: 2; }
html.board-phone .tactical-container .phone-anim-strip {
    flex: 0 0 auto;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    background: rgba(14, 35, 56, 0.94);
    color: #ffffff;
    position: relative;
    z-index: 3;
}
html.board-phone .tactical-container .pas-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-width: 40px;
    height: 38px;
    padding: 0 10px;
    border: 0;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
html.board-phone .tactical-container .pas-btn:active { background: rgba(255, 255, 255, 0.25); }
html.board-phone .tactical-container .pas-btn:disabled { opacity: 0.35; }
html.board-phone .tactical-container .pas-count {
    flex: 1 1 auto;
    min-width: 0;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
html.board-phone .tactical-container .pas-play { background: #ff6b00; padding: 0 14px; color: #0e2338; }
html.board-phone .tactical-container .pas-play .pas-icon-stop,
html.board-phone .tactical-container .pas-play.is-playing .pas-icon-play { display: none; }
html.board-phone .tactical-container .pas-play.is-playing .pas-icon-stop { display: block; }
html.board-phone .tactical-container.cinematic-mode .phone-anim-strip { display: none !important; }
/* Cinematic mode's two controls as round buttons, Play and X (the words
   "Exit cinematic" go): small enough to stand in the gap beside a side-on
   pitch on a phone turned sideways (positionCinematicControls), not over
   its corner */
html.board-phone .tactical-container.cinematic-mode .cinematic-controls { padding: 5px; gap: 8px; }
html.board-phone .tactical-container.cinematic-mode .cinematic-controls #cinematicPlayBtn,
html.board-phone .tactical-container.cinematic-mode .cinematic-controls .cinematic-exit-btn {
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 50%;
}
html.board-phone .tactical-container.cinematic-mode .cinematic-exit-btn span { display: none; }

/* Upright with the pitch side on (the default): a hint in the empty space
   above it that turning the phone gives a bigger pitch - until the phone
   has been turned once (.board-turned, remembered: tactical_board_phone.js) */
html.board-phone .tactical-container .phone-turn-hint.phone-only { display: none !important; }
html.board-phone.pitch-side-on:not(.board-turned):not(.has-selection):not(.board-zoomed) .tactical-container:not(.fullscreen-mode) .phone-turn-hint.phone-only {
    display: flex !important;
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 5;
    align-items: center;
    gap: 8px;
    max-width: calc(100% - 32px);
    padding: 8px 14px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.85);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    pointer-events: none;
}

/* Offered on load: unsaved work, and the quick start - over the pitch. (The
   banner is centred with a transform and sized to its text elsewhere - it
   came out half off the screen; here it's the pitch area's width, wrapping) */
html.board-phone .tactical-container .restore-banner {
    position: absolute;
    top: 8px;
    left: 8px;
    right: 8px;
    width: auto;
    max-width: none;
    transform: none;
    z-index: 20;
    margin: 0;
    /* one compact row (user, 2026-12-02: "needs to be smaller") - shorter
       words on a phone too (showRestoreBanner, tactical_board_boards.js) */
    flex-wrap: nowrap;
    justify-content: space-between;
    gap: 8px;
    padding: 5px 5px 5px 12px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.3;
}
html.board-phone .tactical-container .restore-banner-text { flex: 1 1 auto; min-width: 0; }
html.board-phone .tactical-container .restore-banner-actions { flex: 0 0 auto; gap: 6px; }
html.board-phone .tactical-container .restore-banner button { min-height: 38px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
/* "Start from a drill": compact (user, 2026-12-02: "too big") - as tall as
   what's in it, not the whole screen; the drills two by two, no tips */
html.board-phone .tactical-container .quick-start {
    position: fixed;
    z-index: 1500;
    top: calc(var(--phone-topbar-h, 54px) + 8px);
    left: 8px;
    right: 8px;
    bottom: auto;
    max-height: calc(100dvh - var(--phone-topbar-h, 54px) - var(--phone-toolbar-h, 66px) - 24px);
    width: auto;
    max-width: none;
    margin: 0;
    padding: 14px 14px 6px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    transform: none;
}
html.board-phone .tactical-container .quick-start h2 { font-size: 17px; margin: 2px 44px 2px 0; }
html.board-phone .tactical-container .quick-start-sub { font-size: 13px; margin: 0 0 10px; }
html.board-phone .tactical-container .quick-start-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
html.board-phone .tactical-container .quick-start-option { padding: 9px 10px; min-height: 64px; justify-content: center; }
html.board-phone .tactical-container .quick-start-option strong { font-size: 14px; line-height: 1.25; }
html.board-phone .tactical-container .quick-start-option span { font-size: 12px; line-height: 1.3; }
/* (the "Animated" tag under the name - the tile is too narrow for it beside) */
html.board-phone .tactical-container .quick-start-option em { position: static; align-self: flex-start; margin-top: 3px; font-size: 11px; }
html.board-phone .tactical-container .quick-start-tips { display: none; }
html.board-phone .tactical-container .quick-start-close { top: 4px; right: 4px; }
html.board-phone .tactical-container .quick-start-footer { margin-top: 4px; flex-wrap: nowrap; }
html.board-phone .tactical-container .quick-start-footer button { min-height: 44px; font-size: 14px; }

/* ---- Toolbar: one row you swipe along ---- */
html.board-phone .tactical-container .center-panel .bottom-toolbar {
    flex: 0 0 auto;
    width: auto;
    max-width: none;
    margin: 0;
    border: 0;
    border-top: 1px solid rgba(0, 0, 0, 0.2);
    border-radius: 0;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.25);
    padding: 6px 8px;
    display: block;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    background: var(--dmbg-ffffff, #ffffff);
    position: relative;
    z-index: 3;
}
html.board-phone .tactical-container .bottom-toolbar::-webkit-scrollbar { display: none; }
html.board-phone .tactical-container .bottom-toolbar .toolbar-row {
    display: flex;
    flex-wrap: nowrap;
    justify-content: flex-start;
    width: max-content;
    gap: 6px;
}
html.board-phone .tactical-container .bottom-toolbar .toolbar-separator { display: none !important; }
html.board-phone .tactical-container .bottom-toolbar .tool-btn.toolbar-btn-labeled {
    width: auto !important;
    min-width: 58px !important;
    height: 52px !important;
    padding: 4px 6px !important;
    gap: 4px !important;
    border-radius: 10px !important;
    -webkit-tap-highlight-color: transparent;
}
html.board-phone .tactical-container .bottom-toolbar .tool-btn.toolbar-btn-labeled .btn-label { font-size: 12px; }
html.board-phone .tactical-container .bottom-toolbar .tool-btn svg,
html.board-phone .tactical-container .bottom-toolbar .tool-btn img { width: 22px; height: 22px; }
/* (no hover on a touch screen - a tap left the button "hovered" and grown) */
html.board-phone .tactical-container .tool-btn:hover { transform: none !important; }
html.board-phone .tactical-container .tool-btn:not(.active):hover {
    background: linear-gradient(135deg, var(--dmbg-f8f9fa, #f8f9fa) 0%, var(--dmbg-e9ecef, #e9ecef) 100%) !important;
    border-color: var(--dmbd-c0c0c0, #c0c0c0) !important;
    color: var(--dmtx-0e2338, #0e2338) !important;
    box-shadow: none !important;
}
/* What a coach reaches for most comes first: Undo and Redo next to the tools */
html.board-phone .tactical-container .toolbar-row > button[onclick="undo()"] { order: 1; }
html.board-phone .tactical-container .toolbar-row > button[onclick="redo()"] { order: 1; }
html.board-phone .tactical-container .toolbar-row > #toggleLinesBtn2,
html.board-phone .tactical-container .toolbar-row > #rotateBtn2,
html.board-phone .tactical-container .toolbar-row > #gridBtn2,
html.board-phone .tactical-container .toolbar-row > button[onclick="clearBoard()"],
html.board-phone .tactical-container .toolbar-row > .tool-group[data-group="saveload"],
html.board-phone .tactical-container .toolbar-row > #boardLinkBtn,
html.board-phone .tactical-container .toolbar-row > .tool-group[data-group="export"],
html.board-phone .tactical-container .toolbar-row > #cinematicBtn { order: 2; }

/* ---- The toolbar's menus: sheets above the toolbar ----
   (moved out of the scrolling toolbar into .tactical-container by
   tactical_board_phone.js - Safari kept them inside its strip of screen,
   out of sight; shown by .phone-open / .open on the menu itself) */
html.board-phone .tactical-container .tool-group-menu:not(.phone-open) { display: none !important; }
html.board-phone .tactical-container .tool-group-menu.phone-open { display: flex !important; }
html.board-phone .tactical-container .tool-group-menu,
html.board-phone .tactical-container .tool-mega-menu {
    position: fixed;
    z-index: 1600;
    left: 8px;
    right: 8px;
    top: auto;
    bottom: calc(var(--phone-toolbar-h, 66px) + 8px);
    transform: none;
    margin: 0;
    min-width: 0;
    max-height: min(62vh, 460px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 14px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}
html.board-phone .tactical-container .tool-group-menu::before,
html.board-phone .tactical-container .tool-group-menu::after,
html.board-phone .tactical-container .tool-mega-menu::before,
html.board-phone .tactical-container .tool-mega-menu::after { display: none; }
html.board-phone .tactical-container .tool-group-menu .tool-btn {
    min-width: 0 !important;
    height: 46px !important;
    font-size: 14px !important;
}
html.board-phone .tactical-container .tool-mega-menu.open {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding: 12px;
}
html.board-phone .tactical-container .tool-mega-menu .mega-menu-section { min-width: 0; }
html.board-phone .tactical-container .tool-mega-menu .mega-menu-label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--dmtx-6b7280, #6b7280);
    padding: 0 2px 2px;
}
html.board-phone .tactical-container .tool-mega-menu .tool-btn {
    min-width: 0 !important;
    width: 100% !important;
    height: 42px !important;
    font-size: 13px !important;
    gap: 8px !important;
}

/* ---- A player's menu (press and hold): a sheet from the bottom ---- */
html.board-phone #contextMenu {
    position: fixed !important;
    left: 8px !important;
    right: 8px !important;
    top: auto !important;
    bottom: 8px !important;
    width: auto !important;
    max-width: none !important;
    max-height: 70vh;
    /* (the narrow-window rule centres it with a transform) */
    transform: none !important;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    z-index: 2100 !important;
    border-radius: 16px;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.35);
}
@media (orientation: landscape) {
    html.board-phone #contextMenu { left: auto !important; right: 90px !important; top: 8px !important; width: min(340px, 50vw) !important; max-height: none; }
}

/* ---- Formations: nearly the whole screen, its close button in reach ---- */
html.board-phone .formation-menu {
    box-sizing: border-box;
    width: auto !important;
    max-width: none !important;
    left: 8px !important;
    right: 8px !important;
    top: 8px !important;
    bottom: 8px !important;
    max-height: none !important;
    transform: none !important;
    padding: 1.1rem 1rem 1.25rem !important;
    border-radius: 16px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
html.board-phone .formation-menu h2 { font-size: 1.3rem; margin-right: 44px; }
html.board-phone .formation-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 0.6rem; }
html.board-phone .formation-card { padding: 0.6rem; }
html.board-phone .formation-card:hover { transform: none; }

/* ---- Side panels (Pitch / Frames & AI): a sheet from the bottom ---- */
html.board-phone .tactical-container .side-panel { display: none !important; }
html.board-phone .tactical-container .side-panel.mobile-visible {
    display: block !important;
    position: fixed;
    z-index: 2000;
    left: 0;
    right: 0;
    top: auto;
    bottom: 0;
    width: auto;
    height: auto;
    max-height: 78vh;
    max-height: 78dvh;
    margin: 0;
    padding: 18px 14px 20px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.35);
    animation: phoneSheetUp 0.22s ease-out;
    -webkit-user-select: text;
    user-select: text;
}
@keyframes phoneSheetUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}
/* (the phone's Reduce Motion setting: sheets just appear) */
@media (prefers-reduced-motion: reduce) {
    html.board-phone .tactical-container .side-panel.mobile-visible { animation: none; }
}
html.board-phone .tactical-container .mobile-panel-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1999;
}
html.board-phone .tactical-container .mobile-panel-overlay.active { display: block; }
html.board-phone .tactical-container .mobile-panel-close {
    display: block !important;
    position: sticky;
    top: 0;
    float: right;
    margin: -8px -4px 0 8px;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: #dc3545;
    color: #ffffff;
    font-size: 1.3rem;
    line-height: 1;
    z-index: 10;
}

/* ---- Frames and AI are two sheets here (one panel on a computer):
   tactical_board_phone.js marks which one the panel was opened for - AI
   opened half way down the frame controls ---- */
html.board-phone .tactical-container .right-panel[data-phone-show="frames"] #aiPanelSection,
html.board-phone .tactical-container .right-panel[data-phone-show="ai"] > .panel-section:not(#aiPanelSection) { display: none; }

/* ---- Every control in the sheets and menus finger-sized, their words
   readable (2026-12-02 review, "easy to use ... for anyone": the
   computer's 13-37px controls and 10-11px labels; Apple's guide is 44pt) ---- */
html.board-phone .tactical-container .pas-btn { height: 44px; min-width: 44px; }
html.board-phone .tactical-container .mobile-panel-close,
html.board-phone .tactical-container .quick-start-close,
html.board-phone .formation-menu .formation-menu-close {
    width: 44px !important;
    height: 44px !important;
    font-size: 1.5rem !important;
}
html.board-phone .tactical-container .quick-start-blank,
html.board-phone .tactical-container .quick-start-never { min-height: 44px; padding: 0 12px; font-size: 15px; }
html.board-phone .tactical-container .side-panel.mobile-visible h4 { font-size: 17px; margin-right: 52px; }
html.board-phone .tactical-container .side-panel .ps-label,
html.board-phone .tactical-container .side-panel .anim-options,
html.board-phone .tactical-container .side-panel .frame-timing,
html.board-phone .tactical-container .side-panel .frame-timing label,
html.board-phone .tactical-container .side-panel .frame-timing-title,
html.board-phone .tactical-container .side-panel .frame-caption-field { font-size: 14px; }
html.board-phone .tactical-container .side-panel select,
html.board-phone #contextMenu select { min-height: 44px; border-radius: 8px; }
/* tick boxes: big, and the whole row taps */
html.board-phone .tactical-container .side-panel .anim-options label { min-height: 44px; gap: 10px; }
html.board-phone .tactical-container .side-panel input[type="checkbox"] { width: 22px; height: 22px; margin: 0; flex: 0 0 auto; }
/* Animation's buttons say what they do (they were ➕ 🗑️ ▶️ ⏹️ alone) */
html.board-phone .tactical-container .anim-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
html.board-phone .tactical-container .anim-btn { width: auto; height: 44px; gap: 8px; border-radius: 10px; font-size: 16px; }
html.board-phone .tactical-container .anim-btn::after { content: attr(title); font-size: 15px; font-weight: 700; }
html.board-phone .tactical-container .frame-actions button { min-height: 44px; font-size: 14px; }
html.board-phone .tactical-container .frames-list .frame-item { min-width: 44px; min-height: 44px; }
html.board-phone .tactical-container .frames-list .frame-item span { font-size: 15px; }
/* Pitch style: swatches a finger can pick */
html.board-phone .tactical-container .ps-swatch { width: 40px; height: 40px; }
html.board-phone .tactical-container .ps-swatch.ps-mini { width: 36px; height: 36px; }
html.board-phone .tactical-container .ps-pattern-name,
html.board-phone .tactical-container .ps-strength-value { font-size: 13px; }
/* the AI section's small print (inline sizes of 9-11px) */
html.board-phone .tactical-container #aiPanelSection h4 > span:first-child,
html.board-phone .tactical-container #aiPanelSection .ai-model-badge { font-size: 11px !important; }
html.board-phone .tactical-container #aiPanelSection .ai-whats-new summary,
html.board-phone .tactical-container #aiUsageCounter,
html.board-phone .tactical-container #aiCharCount,
html.board-phone .tactical-container #aiPanelSection p { font-size: 13px !important; }
html.board-phone .tactical-container .tool-mega-menu .mega-menu-label { font-size: 12px; }
html.board-phone .tactical-container .ps-reset { min-height: 44px; padding: 0 16px; font-size: 15px; }
html.board-phone .tactical-container #psStrength { height: 36px; }
html.board-phone .tactical-container #aiGenerateBtn,
html.board-phone .tactical-container #aiSurpriseBtn { min-height: 48px; font-size: 16px !important; }
/* A player's menu (press and hold) */
html.board-phone #contextMenu button:not(.context-color-grid button) { min-height: 44px; }
html.board-phone #contextMenu .context-color-grid { gap: 8px; }
html.board-phone #contextMenu .context-color-grid button { width: 40px; height: 40px; min-width: 40px; }

/* ---- Something selected: Delete, Duplicate and its Options one tap away
   (tactical_board_phone.js) - a phone has no Delete key, and the press-and-
   hold menu's Delete was at the foot of a long list, off the screen ---- */
html.board-phone .tactical-container .phone-selection-bar {
    position: fixed;
    z-index: 1550;
    transform: translateX(-50%);
    display: flex;
    gap: 6px;
    padding: 5px;
    border-radius: 14px;
    background: rgba(14, 35, 56, 0.96);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
    white-space: nowrap;
}
html.board-phone .tactical-container .phone-selection-bar[hidden] { display: none; }
html.board-phone .tactical-container .phone-selection-bar button {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 44px;
    padding: 0 13px;
    border: 0;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    -webkit-tap-highlight-color: transparent;
}
html.board-phone .tactical-container .phone-selection-bar button:active { background: rgba(255, 255, 255, 0.25); }
html.board-phone .tactical-container .phone-selection-bar button[data-act="delete"] { background: #c62828; }
html.board-phone .tactical-container .phone-selection-bar svg { width: 20px; height: 20px; flex: 0 0 auto; }

/* ---- The toolbar swipes along: its far edge fades while there's more
   that way (tactical_board_phone.js sets .more-start / .more-end) ---- */
html.board-phone .tactical-container .bottom-toolbar.more-end {
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 44px), rgba(0, 0, 0, 0.2));
    mask-image: linear-gradient(to right, #000 calc(100% - 44px), rgba(0, 0, 0, 0.2));
}
html.board-phone .tactical-container .bottom-toolbar.more-start {
    -webkit-mask-image: linear-gradient(to left, #000 calc(100% - 44px), rgba(0, 0, 0, 0.2));
    mask-image: linear-gradient(to left, #000 calc(100% - 44px), rgba(0, 0, 0, 0.2));
}
html.board-phone .tactical-container .bottom-toolbar.more-start.more-end {
    -webkit-mask-image: linear-gradient(to right, rgba(0, 0, 0, 0.2), #000 44px, #000 calc(100% - 44px), rgba(0, 0, 0, 0.2));
    mask-image: linear-gradient(to right, rgba(0, 0, 0, 0.2), #000 44px, #000 calc(100% - 44px), rgba(0, 0, 0, 0.2));
}

/* ---- Turned sideways: rails either side of the pitch ---- */
@media (orientation: landscape) {
    html.board-phone .tactical-container { flex-direction: row; }
    html.board-phone.pitch-side-on .tactical-container .phone-turn-hint.phone-only { display: none !important; }

    /* The animation strip becomes a column beside the pitch - Play, a new
       frame and the frame you're on always in reach without a panel over
       the drill (user: "hard to then play the drill") */
    html.board-phone .tactical-container .phone-anim-strip {
        flex-direction: column;
        justify-content: center;
        align-self: stretch;
        width: 66px;
        padding: 8px 5px;
        gap: 8px;
        box-shadow: -2px 0 8px rgba(0, 0, 0, 0.25);
    }
    html.board-phone .tactical-container .phone-anim-strip .pas-btn {
        width: 100%;
        min-width: 0;
        height: 46px;
        padding: 0;
        flex-direction: column;
        gap: 2px;
        font-size: 12px;
    }
    html.board-phone .tactical-container .phone-anim-strip .pas-play { order: -2; height: 54px; }
    html.board-phone .tactical-container .phone-anim-strip .pas-add { order: -1; }
    html.board-phone .tactical-container .phone-anim-strip .pas-count { flex: 0 0 auto; white-space: normal; font-size: 12px; line-height: 1.25; }
    html.board-phone .tactical-container .phone-anim-strip #phonePrevFrame svg { transform: rotate(90deg); }
    html.board-phone .tactical-container .phone-anim-strip #phoneNextFrame svg { transform: rotate(90deg); }
    html.board-phone .tactical-container .phone-anim-strip #phonePrevFrame { order: 0; }
    html.board-phone .tactical-container .phone-anim-strip .pas-count { order: 1; }
    html.board-phone .tactical-container .phone-anim-strip #phoneNextFrame { order: 2; }

    /* The top bar becomes a rail down the right */
    html.board-phone .tactical-container .mobile-panel-toggles {
        order: 2;
        flex-direction: column;
        justify-content: flex-start;
        width: 76px;
        padding: 8px 6px;
        overflow-y: auto;
        box-shadow: -2px 0 8px rgba(0, 0, 0, 0.3);
    }
    html.board-phone .tactical-container .mobile-panel-toggle {
        flex: 0 0 auto;
        width: 100%;
        min-height: 54px;
        flex-direction: column;
        gap: 3px;
        padding: 4px 2px;
        font-size: 12px;
    }
    html.board-phone .tactical-container .phone-home { padding: 4px 2px; }
    html.board-phone .tactical-container .phone-colour,
    html.board-phone .tactical-container .phone-colour > .mobile-panel-toggle { width: 100%; }
    html.board-phone .phone-colour-menu { top: auto; bottom: 10px; right: calc(var(--phone-topbar-w, 76px) + 10px); }
    html.board-phone .tactical-container #resetViewBtn {
        top: 10px;
        right: calc(var(--phone-topbar-w, 76px) + var(--phone-strip-w, 66px) + 10px);
    }
    html.board-phone .tactical-container .restore-banner {
        left: calc(var(--phone-toolbar-w, 82px) + 8px);
        right: calc(var(--phone-strip-w, 66px) + 8px);
    }
    html.board-phone .tactical-container .main-layout { order: 1; }

    /* The toolbar becomes a rail down the left */
    html.board-phone .tactical-container .center-panel .canvas-wrapper { flex-direction: row; }
    html.board-phone .tactical-container .center-panel .bottom-toolbar {
        order: -1;
        height: auto;
        align-self: stretch;
        overflow-x: hidden;
        overflow-y: auto;
        padding: 8px 6px;
        border-top: 0;
        border-right: 1px solid rgba(0, 0, 0, 0.2);
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.25);
    }
    html.board-phone .tactical-container .bottom-toolbar .toolbar-row {
        flex-direction: column;
        width: auto;
        height: max-content;
    }
    html.board-phone .tactical-container .bottom-toolbar .tool-btn.toolbar-btn-labeled {
        width: 68px !important;
        min-width: 68px !important;
        height: 52px !important;
    }

    /* (the rail scrolls up and down - its fade goes that way) */
    html.board-phone .tactical-container .bottom-toolbar.more-end {
        -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 44px), rgba(0, 0, 0, 0.2));
        mask-image: linear-gradient(to bottom, #000 calc(100% - 44px), rgba(0, 0, 0, 0.2));
    }
    html.board-phone .tactical-container .bottom-toolbar.more-start {
        -webkit-mask-image: linear-gradient(to top, #000 calc(100% - 44px), rgba(0, 0, 0, 0.2));
        mask-image: linear-gradient(to top, #000 calc(100% - 44px), rgba(0, 0, 0, 0.2));
    }
    html.board-phone .tactical-container .bottom-toolbar.more-start.more-end {
        -webkit-mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.2), #000 44px, #000 calc(100% - 44px), rgba(0, 0, 0, 0.2));
        mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.2), #000 44px, #000 calc(100% - 44px), rgba(0, 0, 0, 0.2));
    }

    /* Menus open beside the toolbar rail */
    html.board-phone .tactical-container .tool-group-menu,
    html.board-phone .tactical-container .tool-mega-menu {
        left: calc(var(--phone-toolbar-w, 82px) + 8px);
        right: auto;
        top: 8px;
        bottom: 8px;
        width: min(440px, calc(100vw - var(--phone-toolbar-w, 82px) - 100px));
        max-height: none;
    }
    html.board-phone .tactical-container .tool-group-menu { bottom: auto; max-height: calc(100vh - 16px); }
    html.board-phone .tactical-container .tool-mega-menu.open { grid-template-columns: repeat(3, minmax(0, 1fr)); align-content: start; }

    /* Panels slide in from the side, the pitch still in view */
    html.board-phone .tactical-container .side-panel.mobile-visible {
        top: 0;
        bottom: 0;
        width: min(380px, 58vw);
        max-height: none;
        border-radius: 0;
        animation-name: phoneSheetIn;
    }
    html.board-phone .tactical-container .side-panel.left-panel.mobile-visible { left: 0; right: auto; }
    html.board-phone .tactical-container .side-panel.right-panel.mobile-visible { right: 0; left: auto; }

    html.board-phone .tactical-container .quick-start {
        top: 8px;
        bottom: auto;
        max-height: calc(100dvh - 16px);
        left: calc(var(--phone-toolbar-w, 82px) + 8px);
        right: calc(var(--phone-topbar-w, 76px) + 8px);
    }
    /* sideways there's room for all four drills in a row */
    html.board-phone .tactical-container .quick-start-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@keyframes phoneSheetIn {
    from { opacity: 0; transform: translateX(30px); }
    to { opacity: 1; transform: translateX(0); }
}
