/* --- ICON ALIGNMENT & STRAIGHTENING ENGINE --- */

.pos-cell {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
    line-height: 1 !important;
    overflow: hidden;
}

.pos-cell i, 
.pos-cell svg,
#pos-selector-btn i {
    /* Neutralize rotational defaults from icon libraries */
    transform: none !important; 
    margin: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 1.2em; /* Standardize visual weight */
    pointer-events: none;
}

/* Ensure the HUD trigger button maintains alignment */
#pos-selector-btn {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0 !important;
}

/* --- EXISTING CODE MAINTAINED --- */

:root {
    --bg: #000;
    --card: rgba(28, 28, 30, 0.95);
    --accent: #0A84FF;
    --text-main: #FFF;
    --text-secondary: #8E8E93;
    --glass: rgba(255, 255, 255, 0.1);
    --green: #34C759;
    --danger: #FF3B30;
    --guide-color: rgba(0, 122, 255, 1);
}

/* --- RESIZABLE WINDOW ENGINE --- */
#stage-container {
    position: fixed; 
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 80vw;
    height: 70vh;
    min-width: 320px;
    min-height: 200px;
    max-width: 100vw;
    max-height: 100vh;
    background: var(--bg);
    overflow: hidden;
    resize: none !important; 
    z-index: 1;
    border: 2px solid var(--glass);
    box-sizing: border-box;
    transition: border-color 0.1s ease, box-shadow 0.4s ease, background-color 0.4s ease;
}

#stage-container {
    border-color: transparent;
}

#stage-container.show-boundary {
    border-style: solid;
}

#stage-container::-webkit-resizer {
    display: none !important;
    background: transparent !important;
    appearance: none !important;
}

#stage-container.playing {
    border-color: transparent !important;
    box-shadow: none !important;
}

#stage-container:not(.playing):hover {
    border: 2px solid var(--accent);
    box-shadow: 0 0 20px rgba(10, 132, 255, 0.2);
}

.resize-handle {
    position: absolute;
    right: 8px;
    bottom: 8px;
    width: 24px;
    height: 24px;
    color: var(--accent);
    font-size: 14px;
    pointer-events: none; 
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.8;
    z-index: 5;
    transition: opacity 0.3s ease;
}

#stage-container.playing .resize-handle {
    opacity: 0 !important;
}

#stage { 
    height: 100% !important; 
    width: 100% !important;
    overflow-y: scroll; 
    overflow-x: hidden;
    scroll-behavior: auto; 
    position: relative; 
    scrollbar-width: none; 
    cursor: pointer; 
    background-color: transparent;
    padding: 0 !important; 
    box-sizing: border-box;
}

#stage::-webkit-scrollbar {
    display: none;
}

/* --- THEME OVERRIDES --- */

body.theme-light {
    --bg: #FFFFFF;
    --card: #F2F2F7;
    --text-main: #1C1C1E;
    --text-secondary: #636366;
    --glass: rgba(0, 0, 0, 0.05);
    --accent: #007AFF;
}

body.theme-light #stage-container.show-boundary {
    border: 2px solid #D1D1D6;
}

body.theme-light .btn-circle.active {
    background: #007AFF !important;
    color: #FFFFFF !important;
    box-shadow: 0 0 12px rgba(0, 122, 255, 0.45);
    border: 1px solid #007AFF;
}

body.theme-light .modal-body h2, 
body.theme-light .modal-body h3, 
body.theme-light .manual-section h3,
body.theme-light .manual-text b {
    color: #000 !important;
    border-color: #D1D1D6 !important;
}

body.theme-yellow {
    --bg: #FFFF00;
    --card: #FFFF00;
    --text-main: #000;
    --text-secondary: #222;
    --glass: rgba(0, 0, 0, 0.15);
    --accent: #000;
}

body.theme-yellow #stage-container.show-boundary {
    border: 4px solid #000;
}

body:not(.theme-light):not(.theme-yellow) .transport-bar {
    background: linear-gradient(180deg, rgba(28, 28, 30, 0.95) 0%, rgba(10, 10, 12, 0.98) 100%);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5), inset 0 1px 1px rgba(255, 255, 255, 0.05);
}
body:not(.theme-light):not(.theme-yellow) .btn-circle.active {
    background: rgba(10, 132, 255, 0.2) !important;
    box-shadow: 0 0 15px rgba(10, 132, 255, 0.4);
    border: 1px solid var(--accent);
}

body.theme-yellow .transport-bar {
    background: #FFFF00 !important;
    border: 2px solid #000 !important;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
}
body.theme-yellow .lcd-display {
    background: #000 !important;
    color: #FFFF00 !important;
    border: 1px solid #000;
}
body.theme-yellow .lcd-label {
    color: #FFFF00 !important;
}
body.theme-yellow .btn-circle, 
body.theme-yellow .btn-main {
    background: #000 !important;
    color: #FFFF00 !important;
}

body.theme-yellow .btn-circle:hover {
    background: #000 !important;
    opacity: 0.8;
}
body.theme-yellow .btn-circle.active {
    background: #000 !important;
    color: #FFFF00 !important;
    outline: 2px solid #000;
    outline-offset: 2px;
}

body.theme-yellow .readout, 
body.theme-yellow .setting-group label {
    color: #000 !important;
}
body.theme-yellow input[type="range"]::-webkit-slider-runnable-track {
    background: #000 !important;
}

body.theme-yellow .modal-content {
    background: #FFFF00 !important;
    border: 2px solid #000 !important;
    color: #000 !important;
}
body.theme-yellow .modal-body h2, 
body.theme-yellow .modal-body h3, 
body.theme-yellow .manual-section h3,
body.theme-yellow .manual-text b {
    color: #000 !important;
    border-color: #000 !important;
}
body.theme-yellow .modal-body p, 
body.theme-yellow .manual-text span,
body.theme-yellow .manual-text p,
body.theme-yellow .manual-section ul li {
    color: #000 !important;
}
body.theme-yellow .manual-icon-box {
    background: #000 !important;
    color: #FFFF00 !important;
}
body.theme-yellow .modal-footer {
    background: #FFFF00 !important;
    border-top: 1px solid #000 !important;
}
body.theme-yellow .ok-modal {
    background: #000 !important;
    color: #FFFF00 !important;
}

body.theme-yellow #drawer {
    background: #FFFF00 !important;
    border-right: 2px solid #000 !important;
}
body.theme-yellow #drawer-tab {
    background: #000 !important;
    color: #FFFF00 !important;
    border: 2px solid #000 !important;
    border-left: none !important;
}
body.theme-yellow textarea {
    background: #FFFF00 !important;
    color: #000 !important;
    border: 2px solid #000 !important;
}

body, html {
    margin: 0; padding: 0; height: 100%;
    background: var(--bg); color: var(--text-main);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", sans-serif;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    transition: background-color 0.4s ease, color 0.4s ease;
}

/* --- UPDATED TOOLTIP ENGINE --- */
#tooltip {
    position: fixed; 
    bottom: 200px; 
    left: 50%; 
    transform: translateX(-50%) translateY(10px);
    background: rgba(30, 30, 32, 0.98); backdrop-filter: blur(20px);
    padding: 10px 16px; border-radius: 12px; border: 1px solid var(--accent);
    color: #FFF; font-size: 13px; font-weight: 500; max-width: 280px; text-align: center;
    pointer-events: none; opacity: 0; visibility: hidden;
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
    z-index: 20000; box-shadow: 0 10px 40px rgba(0,0,0,0.7);
    line-height: 1.4;
}

#tooltip.visible { 
    opacity: 1; 
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

body.theme-light #tooltip {
    background: #FFF;
    color: #1C1C1E;
    border: 1px solid #D1D1D6;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}
body.theme-yellow #tooltip {
    background: #000;
    color: #FFFF00;
    border: 1px solid #000;
}

.modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.8); backdrop-filter: blur(15px);
    display: none; align-items: center; justify-content: center; z-index: 20000;
}
.modal.active { display: flex; }
.modal-content { 
    background: #1c1c1e; border-radius: 24px; padding: 0; 
    width: 650px; max-height: 80vh; 
    border: 1px solid var(--glass); display: flex; flex-direction: column;
    overflow: hidden;
}

body.theme-light .modal-content { 
    background: #FFF; 
    border: 1px solid #D1D1D6;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}
body.theme-light .modal-footer { background: #F2F2F7; }

.modal-body { padding: 35px 35px 15px 35px; overflow-y: auto; flex-grow: 1; }
.modal-footer { padding: 0 35px 35px 35px; background: #1c1c1e; }

.manual-section { margin-bottom: 25px; }
.manual-section h3 { 
    color: var(--accent); border-bottom: 1px solid var(--glass); 
    padding-bottom: 6px; text-transform: uppercase; font-size: 13px; letter-spacing: 1px;
}
.manual-row { display: flex; align-items: flex-start; gap: 15px; margin-bottom: 12px; }
.manual-icon-box { 
    width: 36px; height: 36px; background: var(--glass); 
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    color: white; flex-shrink: 0; font-size: 14px;
}
body.theme-light .manual-icon-box { color: var(--accent); background: #E5E5EA; }

.manual-text b { color: var(--text-main); display: block; margin-bottom: 2px; font-size: 14px; }
.manual-text p { margin: 0; font-size: 13px; color: var(--text-secondary); line-height: 1.4; }

.ok-modal { background: var(--accent); border: none; color: white; padding: 14px; border-radius: 12px; font-weight: 600; cursor: pointer; width: 100%; transition: 0.2s; }
.ok-modal:hover { opacity: 0.9; transform: translateY(-1px); }
.ok-modal:active { transform: translateY(0); }

#drawer {
    position: fixed; top: 0; left: -420px; width: 420px; height: 100vh;
    background: rgba(15, 15, 15, 0.98); backdrop-filter: blur(50px);
    z-index: 2000; transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1), background-color 0.4s ease;
    border-right: 1px solid var(--glass); display: flex; flex-direction: column;
    padding: 30px; box-sizing: border-box;
    box-shadow: 20px 0 80px rgba(0,0,0,0.8);
}
body.theme-light #drawer { 
    background: #FFFFFF; 
    border-right: 1px solid #D1D1D6;
    box-shadow: 10px 0 30px rgba(0,0,0,0.05);
}
#drawer.open { transform: translateX(420px); }
#drawer-tab {
    position: absolute; right: -34px; top: 50%; transform: translateY(-50%); 
    width: 34px; height: 100px; background: #1c1c1e; border-radius: 0 12px 12px 0;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    color: var(--accent); border: 1px solid var(--glass); border-left: none;
    transition: background-color 0.4s ease, color 0.4s ease;
}
body.theme-light #drawer-tab { background: #FFFFFF; border: 1px solid #D1D1D6; border-left: none; }

textarea {
    flex-grow: 1; background: #000; border: 1px solid var(--glass);
    color: #fff; padding: 20px; border-radius: 16px; font-size: 18px;
    line-height: 1.5; resize: none; outline: none; margin-top: 10px; font-family: inherit;
    transition: border-color 0.3s ease, background-color 0.4s ease, color 0.4s ease;
}
body.theme-light textarea { 
    background: #F2F2F7; 
    color: #1C1C1E; 
    border: 1px solid #D1D1D6; 
}
textarea:focus { border-color: var(--accent); }

#content-wrapper { 
    padding: 0 0 50vh 0 !important; 
    position: relative; 
    pointer-events: none; 
    display: block; 
    width: 100%;
    box-sizing: border-box;
}

#prompter-text { 
    font-weight: 700; 
    line-height: 1.5; 
    text-align: left !important; 
    white-space: pre-wrap; 
    word-wrap: break-word; 
    transition: font-size 0.2s ease, line-height 0.2s ease, color 0.4s ease;
    padding: 0 5% 10px 0 !important; 
    color: var(--text-main);
}

.mirrored { transform: scaleX(-1); }

#eye-guide {
    position: fixed; 
    top: 50%; 
    left: 0; 
    right: 0; 
    height: 4px; 
    background: var(--guide-color) !important;
    box-shadow: 0 0 15px var(--guide-color); 
    opacity: 0; 
    pointer-events: none; 
    z-index: 500;
    transform: translateY(-50%);
    transition: opacity 0.3s ease;
    border: none !important;
}

#eye-guide.active { opacity: 1; }

/* --- HUD VISIBILITY ENGINE --- */
.transport-bar {
    position: fixed; 
    bottom: 30px; 
    left: 50%; 
    transform: translateX(-50%);
    background: var(--card); 
    backdrop-filter: blur(30px);
    border-radius: 28px; 
    padding: 16px 24px;
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    gap: 12px;
    border: 1px solid rgba(255,255,255,0.1);
    box-shadow: 0 20px 50px rgba(0,0,0,0.7);
    z-index: 1000;
    transition: bottom 0.4s cubic-bezier(0.16, 1, 0.3, 1), 
                opacity 0.4s ease, 
                background-color 0.4s ease;
    width: fit-content;
    min-width: 550px;
    max-width: 95vw;
    box-sizing: border-box;
}

#hud-trigger-zone {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 60px;
    z-index: 999;
    pointer-events: auto;
    background: transparent;
}

#hud {
    display: none; 
    transition: none !important; 
}

#hud-trigger-zone:hover ~ #hud, 
#hud:hover {
    display: flex !important;
}

.transport-bar.hidden { 
    bottom: -150px; 
    opacity: 0; 
    pointer-events: none; 
}

.hud-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    width: 100%;
}

.hud-row.top-row {
    border-bottom: 1px solid var(--glass);
    padding-bottom: 10px;
    justify-content: space-between; 
}

body.theme-light .transport-bar {
    background: #FFFFFF;
    border: 1px solid #D1D1D6;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.lcd-container { display: flex; gap: 10px; }
.lcd-display {
    background: #000; padding: 6px 14px; border-radius: 10px;
    font-family: 'SF Mono', monospace; color: var(--accent);
    font-size: 18px; min-width: 85px; text-align: center;
    border: 1px solid rgba(10, 132, 255, 0.15);
    display: flex; flex-direction: column; justify-content: center;
}
body.theme-light .lcd-display { 
    background: #F2F2F7; 
    border-color: #D1D1D6; 
    color: #1C1C1E; 
}

.lcd-label { font-size: 8px; text-transform: uppercase; color: var(--text-secondary); margin-bottom: 2px; font-weight: 700; }

.controls { display: flex; gap: 8px; align-items: center; }
.btn-circle {
    width: 38px; height: 38px; border-radius: 50%;
    border: none; background: var(--glass); color: var(--text-main);
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: 0.2s; font-size: 14px;
}
.btn-circle:hover { background: rgba(255,255,255,0.2); }
.btn-circle.active { color: var(--accent); background: rgba(10, 132, 255, 0.15); }

body.theme-light .btn-circle { background: #E5E5EA; color: #1C1C1E; }
body.theme-light .btn-circle:hover { background: #D1D1D6; }

.btn-main { background: var(--accent); width: 48px; height: 48px; font-size: 18px; color: #FFF; }

.setting-group { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 80px;}
.setting-group label { 
    font-size: 8px; 
    color: var(--text-secondary); 
    text-transform: uppercase; 
    letter-spacing: 1px; 
    font-weight: 800; 
}
.readout { 
    font-size: 10px; 
    color: var(--accent); 
    font-family: 'SF Mono', monospace; 
    font-weight: 600;
}

#font-ctrl, #theme-ctrl, #pos-ctrl, #size-ctrl {
    background: #111;
    color: #fff;
    border: 1px solid rgba(255,255,255,0.4);
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 13px;
    outline: none;
    cursor: pointer;
    transition: all 0.3s ease;
    height: 34px;
    appearance: auto;
}

#font-ctrl option, #theme-ctrl option, #pos-ctrl option, #size-ctrl option {
    background-color: #1c1c1e;
    color: #ffffff;
}

body.theme-light #font-ctrl, 
body.theme-light #theme-ctrl,
body.theme-light #pos-ctrl,
body.theme-light #size-ctrl { 
    background-color: #FFFFFF !important; 
    color: #1C1C1E !important; 
    border: 2px solid #8E8E93 !important; 
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

body.theme-yellow #font-ctrl, 
body.theme-yellow #theme-ctrl,
body.theme-yellow #pos-ctrl,
body.theme-yellow #size-ctrl {
    background-color: #000 !important;
    color: #FFFF00 !important;
    border: 2px solid #000 !important;
}

#font-ctrl:hover, #theme-ctrl:hover, #pos-ctrl:hover, #size-ctrl:hover { border-color: var(--accent) !important; }

input[type="range"] { -webkit-appearance: none; width: 70px; background: transparent; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 4px; background: var(--glass); border-radius: 2px; }
body.theme-light input[type="range"]::-webkit-slider-runnable-track { background: #D1D1D6; }
input[type="range"]::-webkit-slider-thumb { 
    -webkit-appearance: none; 
    height: 14px; width: 14px; 
    border-radius: 50%; 
    background: var(--text-main); 
    margin-top: -5px; 
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

#wpm-calc-btn.recording {
    background: var(--danger); 
    animation: pulseMic 1.5s infinite;
}

@keyframes pulseMic {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.modal-footer {
    border-top: none !important;
    padding-top: 0 !important;
    padding-bottom: 25px !important;
}

#help-modal .modal-footer {
    padding-bottom: 35px !important;
    margin-top: -15px !important;
}

#help-modal .ok-modal {
    width: auto !important;
    min-width: 160px;
    margin: 0 auto;
}

body.theme-light .modal-footer, 
body.theme-yellow .modal-footer {
    border-top: none !important;
    background: transparent !important;
}

.manual-section { margin-bottom: 25px; }
.manual-section h3 {
    border-bottom: none !important;
    padding-bottom: 4px !important;
}

body.theme-yellow .manual-section h3 {
    border-color: transparent !important;
}

.modal-content {
    display: flex;
    flex-direction: column;
    max-height: 85vh;
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 10px !important;
}

.modal-footer {
    flex-shrink: 0;
    border-top: none !important;
    padding: 10px 35px 25px 35px !important;
    background: inherit;
}

#help-modal .ok-modal {
    width: auto !important;
    min-width: 180px;
    margin: 0 auto;
    display: block;
}

body.theme-light .modal-footer { background: #FFF !important; }
body.theme-yellow .modal-footer { background: #FFFF00 !important; }

body.theme-light .modal-body h2, 
body.theme-light .modal-body h3,
body.theme-yellow .modal-body h2,
body.theme-yellow .modal-body h3 {
    border-bottom: none !important;
}

body.theme-light #reset-modal .modal-footer button:not(.ok-modal) {
    background: #FFFFFF !important;
    color: #1C1C1E !important;
    border: 1.5px solid #D1D1D6 !important;
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

body.theme-light #reset-modal .modal-footer button:not(.ok-modal):hover {
    background: #F2F2F7 !important;
    border-color: #8E8E93 !important;
    transform: translateY(-1px);
}

body.theme-light #reset-modal .ok-modal {
    background: var(--danger) !important;
    color: #FFFFFF !important;
    border: none !important;
    width: auto !important;
    padding: 12px 24px !important;
}

#reset-modal .modal-footer {
    display: flex !important;
    gap: 15px;
    justify-content: flex-end;
    padding-bottom: 30px !important;
}

#help-modal .modal-content {
    display: flex;
    flex-direction: column;
    max-height: 80vh;
}

#help-modal .modal-body {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 20px !important;
}

#help-modal .modal-footer {
    flex-shrink: 0;
    background: inherit;
    padding-top: 15px !important;
    padding-bottom: 30px !important;
    box-shadow: 0 -10px 20px -10px rgba(0,0,0,0.1);
}

body.theme-light .manual-icon-box {
    background: #FFFFFF !important;
    color: #007AFF !important;
    border: 1.5px solid #D1D1D6 !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08) !important;
    font-weight: 700 !important;
}

body.theme-yellow .manual-icon-box {
    border: 2px solid #000 !important;
}

.manual-row {
    padding: 8px 0;
    border-bottom: 1px solid var(--glass);
}

body.theme-light .manual-row {
    border-bottom: 1px solid #F2F2F7;
}

.manual-row:last-child {
    border-bottom: none;
}

/* --- LEFT-ALIGNMENT & POSITIONING ENGINE --- */

#prompter-text {
    text-align: left !important;
    width: 100%;
}

#stage-container.pos-nw { top: 0; left: 0; transform: none; }
#stage-container.pos-n { top: 0; left: 50%; transform: translateX(-50%); }
#stage-container.pos-ne { top: 0; right: 0; left: auto; transform: none; }
#stage-container.pos-w { top: 50%; left: 0; transform: translateY(-50%); }
#stage-container.pos-center { top: 50%; left: 50%; transform: translate(-50%, -50%); }
#stage-container.pos-e { top: 50%; right: 0; left: auto; transform: translateY(-50%); }
#stage-container.pos-sw { bottom: 130px; left: 0; top: auto; transform: none; }
#stage-container.pos-s { bottom: 180px; left: 50%; top: auto; transform: translateX(-50%); } 
#stage-container.pos-se { bottom: 130px; right: 0; left: auto; top: auto; transform: none; }

#stage {
    padding-right: 5% !important; 
}

/* --- HUD AUTO-HIDE SYSTEM --- */

.transport-bar.autohide {
    transform: translateX(-50%) translateY(100%); 
    opacity: 0;
    pointer-events: none;
    transition: transform 0.4s cubic-bezier(0.165, 0.84, 0.44, 1), opacity 0.3s ease;
}

.transport-bar.hud-visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    pointer-events: all;
}

#hud-hit-zone {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 60px;
    z-index: 999;
    background: transparent;
}

#hud {
    position: fixed;
    bottom: 30px; 
    left: 50%;
    transform: translateX(-50%);
    transition: opacity 0.4s ease, transform 0.4s ease;
    z-index: 10000;
}

#hud.autohide {
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, 20px) scale(0.95);
}

#hud.hud-visible {
    opacity: 1;
    pointer-events: all;
    transform: translate(-50%, 0) scale(1);
}

/* --- TOP ROW BUTTON ENGINE --- */

.hud-row.top-row {
    justify-content: space-between !important; 
    width: 100% !important;
    display: flex !important;
    padding-bottom: 12px !important;
}

.lcd-container {
    display: flex !important;
    gap: 10px;
}

.top-row-actions {
    display: flex !important;
    gap: 10px;
    align-items: center;
}

#wpm-calc-btn, #reset-btn {
    pointer-events: auto !important;
    cursor: pointer !important;
}

.bottom-row {
    display: flex;
    align-items: flex-start !important; 
    padding: 10px 20px;
    gap: 10px;
}

.group-container {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px; 
}

.group-title {
    font-size: 9px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--accent);
    opacity: 0.7;
    margin-bottom: 4px;
}

.group-controls {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 15px;
}

.hud-divider {
    width: 1px;
    height: 40px;
    background: var(--glass);
    margin: 20px 10px 0 10px; 
    opacity: 0.5;
}

/* --- SPATIAL GRID DIALOG ENGINE --- */

.pos-grid {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    padding: 10px 0;
}

.pos-cell {
    aspect-ratio: 1/1;
    background: var(--glass);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 12px;
    color: var(--text-main);
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
}

.pos-cell:hover {
    background: rgba(255,255,255,0.15);
    transform: translateY(-2px);
    border-color: var(--accent);
}

.pos-cell.active {
    background: var(--accent) !important;
    color: #FFF !important;
    border-color: #FFF;
    box-shadow: 0 0 15px rgba(10, 132, 255, 0.4);
    transform: scale(1.05);
}

/* --- THEME ADAPTATION FOR GRID --- */

body.theme-light .pos-cell {
    background: #E5E5EA;
    color: #1C1C1E;
    border: 1px solid #D1D1D6;
}

body.theme-light .pos-cell:hover {
    background: #D1D1D6;
}

body.theme-light .pos-cell.active {
    background: #007AFF !important;
    color: #FFFFFF !important;
    border-color: #007AFF;
}

body.theme-yellow .pos-cell {
    background: #FFFF00;
    color: #000;
    border: 2px solid #000;
}

body.theme-yellow .pos-cell:hover {
    background: #000;
    color: #FFFF00;
}

body.theme-yellow .pos-cell.active {
    background: #000 !important;
    color: #FFFF00 !important;
    box-shadow: 0 0 0 2px #000;
}

/* --- TRIGGER BUTTON STYLING --- */

#pos-selector-btn {
    transition: all 0.2s ease;
    font-size: 16px;
}

#pos-selector-btn:hover {
    border-color: var(--accent) !important;
    background: rgba(255,255,255,0.2);
}

body.theme-light #pos-selector-btn {
    background: #FFFFFF !important;
    border: 2px solid #8E8E93 !important;
    color: #1C1C1E !important;
}

body.theme-yellow #pos-selector-btn {
    background: #000 !important;
    color: #FFFF00 !important;
    border: none !important;
}