@font-face {
    font-family: 'AdlamDisplay';
    src: url('../fonts/ADLAMDISPLAY-REGULAR.TTF') format('truetype');
    font-weight: normal;
    font-style: normal;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow: hidden;
}

.hidden { display: none !important; }

body {
    font-family: System, -apple-system, sans-serif;
    background: #0F1117;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
}

.app {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100dvh;
    background: #0F1117;
    overflow: hidden;
}

.top-bar {
    background: #13151F;
    border-bottom: 1px solid #1E2130;
    height: clamp(44px, 9vh, 88px);
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    flex-shrink: 0;
}

.player-section {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1 1 auto;
    min-width: 0;
}

.p2-section {
    flex-direction: row-reverse;
}

.player-avatar {
    width: 2.2vh;
    height: 2.2vh;
    min-width: 20px;
    min-height: 20px;
    border-radius: 50%;
    flex-shrink: 0;
    overflow: hidden;
}

.p1-avatar { background: #9E4A40; box-shadow: 0 0 0 2px #9E4A40; }
.p2-avatar { background: #3E68A8; box-shadow: 0 0 0 2px #3E68A8; }

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

.player-name {
    color: #8890A8;
    font-size: max(12px, 1.85vh);
    font-weight: bold;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.wall-boxes {
    display: flex;
    gap: max(3px, 0.4vh);
}

.wall-box {
    width: max(6px, 0.88vh);
    height: max(14px, 2.25vh);
    border-radius: max(2px, 0.25vh);
    flex-shrink: 0;
    transform-origin: center bottom;
}

.wall-box.active {
    background: inherit;
}

.wall-box.used {
    background: #252838;
}

/* A wall being spent lifts slightly, glows, then drains to the "used" colour */
.wall-box.spending {
    animation: wall-spend 0.42s ease-out forwards;
}

@keyframes wall-spend {
    0%   { transform: translateY(0) scaleY(1);    filter: brightness(1); }
    30%  { transform: translateY(-0.35vh) scaleY(1.15); filter: brightness(1.35); }
    60%  { transform: translateY(0) scaleY(0.94); }
    100% { transform: translateY(0) scaleY(1);    filter: brightness(1); background: #252838; }
}

.logo {
    max-height: clamp(26px, 5.5vh, 54px);
    height: auto;
    width: auto;
    max-width: 100%;
    object-fit: contain;
}

.board-wrapper {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    background: #0F1117;
    min-height: 0;
    position: relative;
    perspective: 1400px;
}

canvas {
    display: block;
    cursor: default;
    transform-origin: center center;
    backface-visibility: hidden;
}

.bottom-bar {
    background: #13151F;
    border-top: 1px solid #1E2130;
    padding: max(10px, 1.75vh) 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    flex-shrink: 0;
    position: relative;
}

.status-label {
    color: #C8CCDC;
    font-size: max(14px, 2vh);
    font-weight: bold;
}

.status-label.p1 {
    color: #9E4A40;
}

.status-label.p2 {
    color: #3E68A8;
}

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

button {
    padding: max(8px, 1.25vh) 22px;
    font-size: max(13px, 1.75vh);
    border: 1px solid #2E3250;
    border-radius: 4px;
    cursor: pointer;
    background: #1E2130;
    color: #8890A8;
    transition: all 0.2s;
    font-weight: bold;
}

button:hover {
    background: #252840;
    color: #C8CCDC;
    border-color: #3E4470;
}

button:active {
    background: #3E68A8;
    color: #FFFFFF;
    border-color: #2E508A;
}

/* Unified close button — used on all modal/overlay X buttons */
.modal-close {
    position: absolute;
    background: none;
    border: none;
    color: #404668;
    font-size: 17px;
    font-weight: normal;
    cursor: pointer;
    padding: 6px 8px;
    line-height: 1;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
}

.modal-close:hover  { background: none; color: #9BA3C3; }
.modal-close:active { background: none; color: #C8CCDC; }

.icon-btn {
    padding: max(5px, 0.65vh) 9px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn svg {
    color: #8890A8;
    width: max(16px, 2vh);
    height: max(16px, 2vh);
}

.icon-btn:hover svg {
    color: #C8CCDC;
}

/* Bottom-bar controls, tactile and animated */
.controls button {
    height: 4.4vh;
    min-height: 38px;
    padding: 0 18px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: #AEB6D2;
    background: #1B1F2E;
    border: 1px solid #2A3047;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
    transition: transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1),
                background 0.2s ease, border-color 0.2s ease,
                box-shadow 0.2s ease, color 0.2s ease;
}

.controls .icon-btn {
    width: 4.4vh;
    min-width: 38px;
    padding: 0;
}

.controls button:hover {
    transform: translateY(-2px);
    color: #EAEDF6;
    background: #232A40;
    border-color: rgba(62, 104, 168, 0.7);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4),
                0 0 0 1px rgba(62, 104, 168, 0.25),
                inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.controls button:active {
    transform: translateY(0) scale(0.93);
    color: #EAEDF6;
    background: #161926;
    border-color: rgba(62, 104, 168, 0.6);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.4);
    transition-duration: 0.08s;
}

.controls button svg {
    width: max(16px, 2vh);
    height: max(16px, 2vh);
    color: inherit;
    transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1), color 0.2s ease;
}

.controls .icon-btn:hover svg { color: #EAEDF6; }

/* Change Mode: dark navy to distinguish from game actions */
#change-mode-btn {
    color: #FFFFFF;
    background: #1E3050;
    border-color: #2E4870;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.07);
}

#change-mode-btn:hover {
    background: #243860;
    border-color: #3A5880;
    box-shadow: 0 6px 16px rgba(30, 60, 100, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

#change-mode-btn:active {
    background: #18263E;
    border-color: #263A5E;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.35);
}

/* Resign: muted red to signal a destructive action. position/overflow support
   the two-step inline confirm (armed state + draining countdown bar). */
#new-game-btn {
    position: relative;
    overflow: hidden;
    color: #FFFFFF;
    background: #7A3535;
    border-color: #9E4A4A;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

#new-game-btn:hover {
    color: #FFFFFF;
    background: #8B3D3D;
    border-color: #B35555;
    box-shadow: 0 6px 16px rgba(158, 74, 64, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.14);
}

#new-game-btn:active {
    color: #FFFFFF;
    background: #622B2B;
    border-color: #8A3F3F;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.35);
}

/* Active toggle look shared by Confirm walls (on) and Animations (on): the
   blue. Solid colours (translucent blue composited over the dark bar) so the
   contrast checker can evaluate them. */
.icon-btn.tap-active,
#anim-btn:not(.anim-off) {
    color: #C3D6F4;
    background: linear-gradient(180deg, #243450, #1B2438);
    border-color: rgba(90, 140, 210, 0.8);
    box-shadow: 0 0 14px rgba(62, 104, 168, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.icon-btn.tap-active svg,
#anim-btn:not(.anim-off) svg { color: #C3D6F4; }

.icon-btn.tap-active:hover,
#anim-btn:not(.anim-off):hover {
    transform: translateY(-2px);
    color: #EAF1FB;
    background: linear-gradient(180deg, #314A72, #202E48);
    border-color: rgba(122, 168, 230, 0.95);
    box-shadow: 0 6px 18px rgba(62, 104, 168, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.icon-btn.tap-active:hover svg,
#anim-btn:not(.anim-off):hover svg { color: #EAF1FB; }

.icon-btn.tap-active:active,
#anim-btn:not(.anim-off):active {
    transform: translateY(0) scale(0.93);
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.35);
}

/* Animations off: a normal clickable button; the slashed icon conveys the
   off state, so it isn't dimmed (which would read as disabled) */
.icon-btn.anim-off svg {
    color: #9AA2BE;
}

.icon-btn.anim-off:hover svg {
    color: #EAEDF6;
}

/* Mute, red tint while muted, with a brighter hover (solid colours for the
   contrast checker) */
#mute-btn.muted {
    color: #E0998C;
    border-color: rgba(158, 74, 64, 0.6);
    background: linear-gradient(180deg, #3A2530, #221A22);
}

#mute-btn.muted svg { color: #E0998C; }

#mute-btn.muted:hover {
    color: #F2B7AA;
    border-color: rgba(196, 96, 84, 0.9);
    background: linear-gradient(180deg, #4A2F3A, #2C212A);
    box-shadow: 0 6px 18px rgba(158, 74, 64, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

#mute-btn.muted:hover svg { color: #F2B7AA; }

@keyframes mute-pop {
    0%   { transform: scale(1); }
    40%  { transform: scale(0.68); }
    100% { transform: scale(1); }
}

@keyframes ctrl-icon-pop {
    0%   { transform: scale(1); }
    45%  { transform: scale(1.22); }
    100% { transform: scale(1); }
}

/* Win Screen */
@keyframes win-card-in {
    from { opacity: 0; transform: translateY(20px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes win-pawn-in {
    from { opacity: 0; transform: scale(0.3); }
    to   { opacity: 1; transform: scale(1); }
}

@keyframes win-item-in {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes rematch-pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.5; }
}

.win-overlay {
    position: fixed;
    inset: 0;
    background:
        radial-gradient(120% 90% at 50% 38%, rgba(20, 24, 38, 0.48) 0%, rgba(6, 7, 12, 0.85) 72%),
        rgba(6, 7, 12, 0.75);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.win-overlay.hidden {
    display: none;
}

.win-card {
    position: relative;
    background: none;
    border: none;
    border-radius: 0;
    padding: 40px 32px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: none;
    animation: win-card-in 0.32s cubic-bezier(0.22, 1, 0.36, 1) both;
    width: 380px;
    max-width: calc(100vw - 48px);
}

.win-card-close { top: 10px; right: 8px; }

.win-pawn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    margin-bottom: 14px;
    animation: win-pawn-in 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) 0.06s both;
}

.win-pawn.p1 { background: #9E4A40; box-shadow: 0 4px 28px rgba(158, 74, 64, 0.6); }
.win-pawn.p2 { background: #3E68A8; box-shadow: 0 4px 28px rgba(62, 104, 168, 0.6); }

.win-title {
    font-size: 2.2rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.1;
    margin-bottom: 24px;
    text-align: center;
    animation: win-item-in 0.3s cubic-bezier(0.22, 1, 0.36, 1) 0.14s both;
}

.win-title.p1 { color: #C05A4E; }
.win-title.p2 { color: #5080C8; }

/* Win stats — centered 2-column */
.win-stats {
    display: flex;
    align-items: stretch;
    width: 100%;
    margin-bottom: 16px;
    background: rgba(10, 12, 22, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 14px;
    overflow: hidden;
    animation: win-item-in 0.3s cubic-bezier(0.22, 1, 0.36, 1) 0.22s both;
}

.win-stat-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 9px;
    padding: 16px 12px;
}

.win-card.p1 .win-stat-col:first-child { background: rgba(158, 74, 64, 0.08); }
.win-card.p2 .win-stat-col:last-child  { background: rgba(62, 104, 168, 0.08); }

.win-stat-sep {
    width: 1px;
    background: rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
    margin: 10px 0;
}

.win-stat-name {
    font-size: 10px;
    font-weight: 700;
    color: #454A68;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.win-card.p1 .win-stat-col:first-child .win-stat-name { color: rgba(192, 90, 78, 0.7); }
.win-card.p2 .win-stat-col:last-child  .win-stat-name { color: rgba(80, 128, 200, 0.7); }

.win-stat-moves {
    font-size: 11px;
    color: #404768;
    font-variant-numeric: tabular-nums;
    text-align: center;
}

.win-stat-moves strong {
    display: block;
    color: #9BA3C3;
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1;
    margin-bottom: 2px;
}

.win-card.p1 .win-stat-col:first-child .win-stat-moves strong { color: #C05A4E; }
.win-card.p2 .win-stat-col:last-child  .win-stat-moves strong { color: #5080C8; }

.win-stat-walls {
    display: flex;
    gap: 2px;
    flex-wrap: nowrap;
    justify-content: center;
}

.win-wall-mini {
    width: 5px;
    height: 13px;
    border-radius: 2px;
}

.win-wall-mini.used { background: rgba(255, 255, 255, 0.07); }

/* Bar slot — floats pills above the bottom-bar via bottom: 100% */
.bar-slot {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 100%;
    display: flex;
    justify-content: center;
    padding-bottom: 12px;
    pointer-events: none;
}

@keyframes bar-in {
    from { opacity: 0; transform: translateY(8px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Game notification pills */
.win-footer {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px;
    background: rgba(10, 12, 22, 0.90);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 100px;
    pointer-events: auto;
    animation: bar-in 0.3s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.win-footer.hidden { display: none; }

.win-footer-label {
    font-size: 12px;
    color: #5C6280;
    font-weight: 500;
    white-space: nowrap;
    padding: 0 10px 0 12px;
}

.win-footer-btn {
    padding: 10px 22px;
    background: #1C1E2E;
    border: none;
    border-radius: 100px;
    color: #9BA3C3;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}

.win-footer-btn:hover {
    background: #242538;
    color: #C8CCDC;
}

.win-footer-btn.win-footer-muted {
    background: transparent;
    opacity: 0.55;
}

.win-footer-btn.incoming {
    background: #231715;
    color: #D88070;
    animation: rematch-pulse 1.2s ease-in-out infinite;
}

.win-footer-btn.waiting { opacity: 0.45; }

/* Win action buttons — lobby row style */
.win-actions {
    display: flex;
    flex-direction: column;
    width: 100%;
    animation: win-item-in 0.3s cubic-bezier(0.22, 1, 0.36, 1) 0.3s both;
}

.win-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 13px 16px;
    background: none;
    border: none;
    border-radius: 10px;
    color: #5A6080;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.16s ease, color 0.16s ease;
    font-family: inherit;
    width: 100%;
}

.win-btn svg {
    flex-shrink: 0;
    opacity: 0.4;
    transition: opacity 0.16s ease;
}

.win-btn:hover {
    background: #1A1D2A;
    color: #C8CCDC;
}

.win-btn:hover svg { opacity: 0.7; }

.win-card.p1 .win-btn--primary       { color: #C87060; }
.win-card.p1 .win-btn--primary svg   { opacity: 1; color: #9E4A40; }
.win-card.p1 .win-btn--primary:hover { background: #1C1210; color: #D88070; }

.win-card.p2 .win-btn--primary       { color: #6898D8; }
.win-card.p2 .win-btn--primary svg   { opacity: 1; color: #3E68A8; }
.win-card.p2 .win-btn--primary:hover { background: #0E1218; color: #78A8E8; }

#btn-rematch.incoming { animation: rematch-pulse 1.4s ease-in-out infinite; }
#btn-rematch.waiting  { opacity: 0.45; }

/* Icon-top action buttons (lobby + future use) */
.win-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    min-width: 116px;
    min-height: 108px;
    padding: 22px 16px 18px;
    background: #191C2A;
    border: 1px solid #242842;
    border-radius: 12px;
    color: #9BA3C3;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}

.win-action-btn svg {
    color: #99A1C2;
    width: 28px;
    height: 28px;
    flex-shrink: 0;
}

.win-action-btn:hover {
    background: #1C2236;
    color: #C8CCDC;
    border-color: #3E68A8;
    box-shadow: 0 0 14px rgba(62, 104, 168, 0.25);
}

.win-action-btn:hover svg { color: #8AAADA; }

.win-action-btn:active {
    background: #3E68A8;
    color: #FFFFFF;
    border-color: #5A84C4;
    box-shadow: none;
}

.win-action-btn:active svg { color: #FFFFFF; }

/* Lobby */
.lobby-overlay {
    position: fixed;
    inset: 0;
    background:
        radial-gradient(120% 90% at 50% 38%, rgba(20, 24, 38, 0.42) 0%, rgba(6, 7, 12, 0.73) 72%),
        rgba(6, 7, 12, 0.68);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.lobby-overlay.hidden { display: none; }

/* Clean fade between lobby and game */
.lobby-overlay.lobby-fade-out {
    opacity: 0;
    pointer-events: none;
}

.lobby-card-close { top: 12px; right: 14px; }
.lobby-card-close.hidden { display: none; }

@keyframes lobby-card-in {
    from { opacity: 0; transform: translateY(20px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes view-slide-in {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

.lobby-view-entering {
    animation: view-slide-in 0.22s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.lobby-card {
    position: relative;
    background: none;
    border: none;
    border-radius: 0;
    padding: 40px 32px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: none;
    width: 380px;
    max-width: calc(100vw - 48px);
    animation: lobby-card-in 0.32s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.lobby-logo {
    height: 69px;
    object-fit: contain;
    margin-bottom: 52px;
}

.lobby-view {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.lobby-subtitle {
    color: #454A68;
    font-size: 11px;
    font-weight: bold;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    margin-bottom: 22px;
}

/* Field label for form views (join) */
.lobby-field-label {
    color: #454A68;
    font-size: 11px;
    font-weight: bold;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    margin-bottom: 10px;
}

.lobby-field-label + .lobby-name-wrap { margin-bottom: 26px; }

.lobby-code {
    font-size: 2.2rem;
    font-weight: bold;
    letter-spacing: 0.25em;
    color: #C8CCDC;
    font-family: monospace;
    margin: 4px 0 24px;
}

.lobby-input {
    width: 100%;
    background: none;
    border: none;
    border-bottom: 1px solid transparent;
    border-radius: 0;
    padding: 8px 4px;
    font-size: 1.6rem;
    font-weight: bold;
    letter-spacing: 0.3em;
    color: #C8CCDC;
    text-align: center;
    text-transform: uppercase;
    margin-bottom: 10px;
    outline: none;
    font-family: monospace;
    transition: border-color 0.2s;
}

.lobby-input::placeholder { color: #3A4060; }
.lobby-input:focus { border-bottom-color: rgba(255, 255, 255, 0.16); }

.lobby-error {
    color: #9E4A40;
    font-size: 12px;
    margin-bottom: 10px;
    min-height: 16px;
    text-align: center;
}

.lobby-back {
    background: none;
    border: none;
    color: #3A3F58;
    font-size: 12px;
    cursor: pointer;
    padding: 8px 4px;
    margin-top: 6px;
    transition: color 0.2s;
    font-weight: bold;
}

.lobby-back:hover {
    color: #8890A8;
    background: none;
    border: none;
}

/* Lobby name input */
.lobby-name-wrap {
    width: 100%;
    margin-bottom: 16px;
}

.lobby-name-input {
    width: 100%;
    background: none;
    border: none;
    border-bottom: 1px solid transparent;
    border-radius: 0;
    padding: 8px 4px;
    font-size: 16px;
    font-weight: bold;
    color: #C8CCDC;
    text-align: center;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
}

.lobby-name-input::placeholder { color: #454A68; font-weight: bold; }
.lobby-name-input:focus { border-bottom-color: rgba(255, 255, 255, 0.16); }

/* Lobby mode list */
.lobby-mode-list {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.lobby-mode-row {
    display: flex;
    align-items: center;
    gap: 16px;
    width: 100%;
    padding: 16px 14px;
    border: none;
    border-radius: 10px;
    background: none;
    cursor: pointer;
    text-align: left;
    transition: background 0.16s ease;
}

/* Chromium freezes :hover on a pressed element until the button is released,
   so holding and dragging the cursor off would leave the highlight stuck on.
   JS toggles .cursor-out on mouseleave to force the highlight off in that case. */
.lobby-mode-row.cursor-out { background: none !important; }

.mode-icon {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    transition: transform 0.16s ease;
}

.lobby-mode-row:hover .mode-icon { transform: scale(1.08); }

.mode-title {
    font-size: 16px;
    font-weight: bold;
    color: #D2D6E4;
}

.mode-sub {
    margin-left: auto;
    font-size: 12px;
    font-weight: normal;
    color: #4A5070;
}

.mode-arrow {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    color: #2E3350;
    opacity: 0;
    transform: translateX(-4px);
    transition: opacity 0.16s ease, transform 0.16s ease;
}

.lobby-mode-row:hover .mode-arrow { opacity: 1; transform: translateX(0); }

#btn-local  .mode-icon { color: #C05A4E; }
#btn-online .mode-icon { color: #5080C8; }
#btn-ai     .mode-icon { color: #8070C8; }

#btn-local:hover  { background: rgba(192, 90, 78, 0.14); }
#btn-online:hover { background: rgba(80, 128, 200, 0.14); }
#btn-ai:hover     { background: rgba(128, 112, 200, 0.14); }

#btn-local:hover:active  { background: rgba(192, 90, 78, 0.24); }
#btn-online:hover:active { background: rgba(80, 128, 200, 0.24); }
#btn-ai:hover:active     { background: rgba(128, 112, 200, 0.24); }

#btn-create .mode-icon, #btn-join .mode-icon { color: #5080C8; }
#btn-create:hover, #btn-join:hover { background: rgba(80, 128, 200, 0.14); }
#btn-create:hover:active, #btn-join:hover:active { background: rgba(80, 128, 200, 0.24); }

.lobby-mode-disabled { cursor: not-allowed; }

/* Lobby footer (shared across all lobby views) */
.lobby-footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    margin-top: 48px;
    font-size: 11px;
}

.lobby-footer a {
    color: #4A5080;
    text-decoration: none;
    transition: color 0.15s;
}

.lobby-footer a:hover { color: #7880B0; }

.lobby-footer-icons {
    display: flex;
    gap: 20px;
    align-items: center;
    justify-content: center;
}

.lobby-icon-link {
    display: flex;
    align-items: center;
    color: #3E4468;
    transition: color 0.15s;
}

.lobby-icon-link:hover { color: #7880B0; }

/* The website link only makes sense inside the Discord activity; on the web you are already here. */
.lobby-website-link { display: none; }
.discord-activity .lobby-website-link { display: flex; }

.lobby-footer-meta {
    display: flex;
    gap: 7px;
    align-items: center;
    color: #2A2F48;
    letter-spacing: 0.04em;
}

.lobby-version { color: #3E4468; }

/* "Play AI while you wait" — quiet secondary action on the invite screens */
.lobby-ai-link {
    display: inline-block;
    border: none;
    background: none;
    color: rgba(255, 255, 255, 0.42);
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
    padding: 6px 4px;
    text-decoration: underline;
    text-decoration-color: rgba(255, 255, 255, 0.16);
    text-underline-offset: 3px;
    transition: color 0.15s;
}

.lobby-ai-link:hover {
    color: rgba(255, 255, 255, 0.7);
    background: none;
    border-color: transparent;
}

/* Discord activity waiting UI */
.discord-queue-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 20px 0 8px;
}

.discord-queue-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(62, 104, 168, 0.3);
    border-top-color: #3E68A8;
    border-radius: 50%;
    animation: discord-spin 0.9s linear infinite;
    flex-shrink: 0;
}

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

.discord-status-text {
    color: #8890A8;
    font-size: 15px;
    font-weight: bold;
}

/* Spectator banner pill (overlaid at bottom of board-wrapper) */
.spectator-banner {
    position: absolute;
    bottom: 14px;
    left: 0;
    right: 0;
    width: fit-content;
    margin: 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 16px;
    background: rgba(10, 12, 22, 0.90);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 100px;
    font-size: 12px;
    font-weight: 500;
    color: #8890B8;
    pointer-events: none;
    z-index: 5;
    animation: bar-in 0.3s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.spectator-queue-pos {
    color: #6878A8;
    font-size: 11px;
}

/* Spectator count chip - top-right corner of board */
.spectator-count-chip {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 6px;
    background: rgba(25, 28, 42, 0.88);
    border: 1px solid #2A2E48;
    color: #8890A8;
    font-size: 11px;
    font-weight: bold;
    backdrop-filter: blur(4px);
    z-index: 4;
}

/* Legal modal */
.legal-modal {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.legal-modal.hidden { display: none; }

.legal-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(3px);
    cursor: pointer;
}

.legal-modal-card {
    position: relative;
    background: #13151F;
    border: 1px solid #2A2E48;
    border-radius: 16px;
    padding: 40px 48px;
    max-width: 640px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    z-index: 1;
}

.legal-modal-x { top: 14px; right: 14px; }

.legal-modal-card::-webkit-scrollbar { width: 6px; }
.legal-modal-card::-webkit-scrollbar-track { background: transparent; }
.legal-modal-card::-webkit-scrollbar-thumb { background: #2A2E48; border-radius: 3px; }
.legal-modal-card::-webkit-scrollbar-thumb:hover { background: #3E4470; }

.legal-modal-card h1 { color: #C8CCDC; font-size: 1.4rem; margin-bottom: 6px; }
.legal-modal-card h2 { color: #C8CCDC; font-size: 0.85rem; letter-spacing: 0.08em; text-transform: uppercase; margin: 24px 0 8px; }
.legal-modal-card p,
.legal-modal-card li { font-size: 13px; line-height: 1.7; color: #8890A8; }
.legal-modal-card .meta { font-size: 11px; color: #454A68; margin-bottom: 28px; }
.legal-modal-card ul { padding-left: 20px; }
.legal-modal-card li { margin-bottom: 4px; }
.legal-modal-card a { color: #3E68A8; text-decoration: none; }
.legal-modal-card a:hover { text-decoration: underline; }
.legal-modal-card hr { border: none; border-top: 1px solid #1E2130; margin: 24px 0; }

/* Resign: two-step inline confirm — first click arms, second confirms */
#new-game-btn .resign-confirm-icon { display: none; }

/* Reserve width for the longest label so swapping "Resign" -> "Sure?"
   never reflows the button or the toolbar. */
.resign-label {
    display: inline-grid;
    justify-items: center;
    white-space: nowrap;
}

.resign-label::after {
    content: 'Resign';
    grid-area: 1 / 1;
    height: 0;
    overflow: hidden;
    visibility: hidden;
}

.resign-label-text { grid-area: 1 / 1; }

/* Armed state: button morphs in place, no popup, no layout shift */
#new-game-btn.armed {
    background: #9E4A4A;
    border-color: #C86A6A;
    box-shadow: 0 0 0 1px rgba(200, 106, 106, 0.4), 0 6px 18px rgba(158, 74, 64, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.16);
}

#new-game-btn.armed .resign-icon { display: none; }
#new-game-btn.armed .resign-confirm-icon { display: inline-block; }

/* Thin countdown bar that drains over the arm window, then disarms */
.resign-arm-bar {
    position: absolute;
    left: 0;
    bottom: 0;
    height: 2px;
    width: 100%;
    background: rgba(255, 255, 255, 0.7);
    transform: scaleX(0);
    transform-origin: left center;
    pointer-events: none;
}

@keyframes resign-arm-drain {
    from { transform: scaleX(1); }
    to   { transform: scaleX(0); }
}

#new-game-btn.armed .resign-arm-bar {
    animation: resign-arm-drain var(--resign-arm-ms, 3000ms) linear forwards;
}

@media (prefers-reduced-motion: reduce) {
    #new-game-btn.armed .resign-arm-bar { animation: none; transform: scaleX(0); }
}

/* Discord mobile — push content below Discord's voice overlay (~48px) */
@media (max-width: 768px) {
    .discord-activity .app {
        padding-top: 52px;
    }
}

/* Discord minimized pip (~320×180): strip card chrome, show only spinner + text */
@media (max-height: 200px) {
    .lobby-card {
        background: transparent;
        border-color: transparent;
        box-shadow: none;
        border-radius: 0;
        padding: 6px 16px;
        width: 100%;
        animation: none;
    }

    .lobby-logo,
    .lobby-subtitle,
    .lobby-htp-link,
    .lobby-version {
        display: none;
    }

    .discord-queue-status {
        padding: 2px 0;
    }

    .discord-status-text {
        font-size: 12px;
    }

    .discord-activity .app {
        padding-top: 0;
    }
}

/* Collapse text labels to icon-only before they can overflow the bottom bar */
@media (max-width: 680px) {
    .controls button:not(.icon-btn) {
        width: 4.4vh;
        min-width: 38px;
        padding: 0;
    }

    #change-mode-btn span,
    #new-game-btn span {
        display: none;
    }
}

/* Tall-narrow viewports: vh-based wall widths balloon in a width-constrained
   layout. Two overlapping conditions cover the problem range:
   1. ratio < 4/9 (height > ~2.25x width, <=600px wide): 500x1136, 522x1270...
      threshold sits safely above regular phones (390x844=0.462, 430x932=0.461)
   2. height >=800px at 500-700px wide: catches 500x860 and above; regular phones
      are all <500px wide so they never match the min-width:500px guard */
@media ((max-aspect-ratio: 4/9) and (max-width: 600px)),
       ((min-height: 800px) and (min-width: 500px) and (max-width: 700px)) {
    .wall-box {
        width: max(7px, 1.5vw);
    }

    .wall-boxes {
        gap: max(3px, 0.8vw);
    }

    .logo {
        max-height: clamp(22px, 5.5vh, 36px);
    }
}

@media (max-width: 520px) {
    .top-bar {
        padding: 0 10px;
        gap: 8px;
    }

    .player-section {
        gap: 6px;
    }

    .logo {
        max-height: clamp(20px, 5.5vh, 28px);
    }

    .htp-logo-q {
        right: 0;
    }

    .player-name {
        display: none;
    }

    .bottom-bar {
        flex-direction: column;
        padding: 0.85vh 10px;
        gap: 0.6vh;
    }

    .status-label {
        font-size: 1.75vh;
    }

    .controls {
        gap: 8px;
    }

    .lobby-card {
        width: calc(100vw - 40px);
        padding: 36px 24px 28px;
    }
}

/* ─── Tap-to-preview mode ─────────────────────────────────────────────── */


/* Confirm bar — overlays the bottom bar, replacing status + controls */
.tap-confirm-hint {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 12;
    background: #13151F;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
}

.tap-confirm-hint.visible {
    opacity: 1;
    pointer-events: auto;
}

/* Inner row springs in while the backdrop fades */
.tap-confirm-row {
    display: flex;
    align-items: center;
    gap: 10px;
    transform: translateY(12px) scale(0.92);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.tap-confirm-hint.visible .tap-confirm-row {
    transform: translateY(0) scale(1);
}

.tap-confirm-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    border: 1px solid;
    border-radius: 99px;
    cursor: pointer;
    font-weight: bold;
    font-family: inherit;
    backdrop-filter: blur(16px);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.12s ease, background 0.16s ease,
                border-color 0.16s ease, box-shadow 0.16s ease;
}

.tap-confirm-btn:active { transform: scale(0.93); }

/* Primary "place" pill — generous 48px tap target with a label */
.tap-confirm-place {
    height: 48px;
    padding: 0 22px 0 18px;
    font-size: 14px;
    letter-spacing: 0.01em;
    color: #FFFFFF;
}

.tap-confirm-place svg { flex-shrink: 0; }
.tap-confirm-label { white-space: nowrap; }

.tap-confirm-hint.p1 .tap-confirm-place {
    background: rgba(158, 74, 64, 0.92);
    border-color: rgba(216, 130, 118, 0.7);
    animation: tap-place-pulse-p1 1.8s ease-in-out infinite;
}

.tap-confirm-hint.p1 .tap-confirm-place:hover { background: rgba(176, 84, 73, 0.96); }

.tap-confirm-hint.p2 .tap-confirm-place {
    background: rgba(62, 104, 168, 0.92);
    border-color: rgba(122, 170, 232, 0.7);
    animation: tap-place-pulse-p2 1.8s ease-in-out infinite;
}

.tap-confirm-hint.p2 .tap-confirm-place:hover { background: rgba(72, 118, 188, 0.96); }

@keyframes tap-place-pulse-p1 {
    0%, 100% { box-shadow: 0 6px 26px rgba(158, 74, 64, 0.5), 0 0 0 0 rgba(216, 130, 118, 0.5); }
    50%      { box-shadow: 0 8px 30px rgba(158, 74, 64, 0.6), 0 0 0 8px rgba(216, 130, 118, 0); }
}

@keyframes tap-place-pulse-p2 {
    0%, 100% { box-shadow: 0 6px 26px rgba(62, 104, 168, 0.5), 0 0 0 0 rgba(122, 170, 232, 0.5); }
    50%      { box-shadow: 0 8px 30px rgba(62, 104, 168, 0.6), 0 0 0 8px rgba(122, 170, 232, 0); }
}

/* Secondary "cancel" — circular, neutral, high-contrast glyph */
.tap-confirm-cancel {
    width: 48px;
    height: 48px;
    padding: 0;
    color: #C8CCDC;
    background: rgba(13, 15, 24, 0.9);
    border-color: rgba(120, 128, 160, 0.4);
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.45);
}

.tap-confirm-cancel:hover {
    background: rgba(32, 36, 52, 0.95);
    border-color: rgba(150, 158, 190, 0.6);
    color: #FFFFFF;
}

/* Transient toast — announces mode changes / first-use hint */
.tap-toast {
    position: absolute;
    top: 14px;
    left: 50%;
    z-index: 11;
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: calc(100% - 28px);
    padding: 9px 16px;
    border-radius: 99px;
    font-size: 12px;
    font-weight: bold;
    color: #D4D8E6;
    background: rgba(13, 15, 24, 0.94);
    border: 1px solid rgba(120, 128, 160, 0.32);
    backdrop-filter: blur(14px);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
    text-align: center;
    opacity: 0;
    pointer-events: none;
    transform: translateX(-50%) translateY(-16px) scale(0.95);
    transition: opacity 0.25s ease,
                transform 0.34s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.tap-toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
}

@media (prefers-reduced-motion: reduce) {
    .tap-confirm-hint,
    .tap-confirm-row,
    .tap-toast { transition-duration: 0.12s; }
    .tap-confirm-place { animation: none; }
    .controls button svg { transition: color 0.2s ease; }
    .controls button:hover { transform: none; }
}

/* Keep the confirm buttons within a short landscape bottom bar */
@media (max-height: 480px) {
    .tap-confirm-place { height: 38px; padding: 0 18px 0 14px; font-size: 13px; }
    .tap-confirm-cancel { width: 38px; height: 38px; }
}

/* Landscape phone — tighten both bars vertically */
@media (max-height: 480px) {
    .top-bar {
        height: 44px;
    }

    .bottom-bar {
        padding-top: 6px;
        padding-bottom: 6px;
    }
}

/* Logo ? badge */
.logo-wrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    flex-shrink: 1;
}
.htp-logo-q {
    position: absolute;
    bottom: -6px;
    right: clamp(-28px, -2.5vh, -18px);
    width: clamp(14px, 1.8vh, 20px);
    height: clamp(14px, 1.8vh, 20px);
    border-radius: 50%;
    border: none;
    background: none;
    color: rgba(255,255,255,0.4);
    font-size: clamp(10px, 1.2vh, 13px);
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
    transition: color 0.15s;
}
.htp-logo-q:hover { color: rgba(255,255,255,0.85); }

/* Lobby how-to-play link */
.lobby-htp-link {
    display: block;
    margin-top: 6px;
    border: none;
    background: none;
    color: rgba(255, 255, 255, 0.32);
    font-family: inherit;
    font-size: 12px;
    font-weight: bold;
    letter-spacing: 0.08em;
    cursor: pointer;
    padding: 8px 14px;
    border-radius: 8px;
    transition: color 0.15s;
}
.lobby-htp-link:hover {
    color: rgba(255, 255, 255, 0.7);
    background: none;
    border-color: transparent;
}

/* ===== How to Play Modal ===== */
.htp-overlay {
    position: fixed;
    inset: 0;
    background:
        radial-gradient(120% 90% at 50% 38%, rgba(20, 24, 38, 0.42) 0%, rgba(6, 7, 12, 0.73) 72%),
        rgba(6, 7, 12, 0.68);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 4000;
}
.htp-overlay.hidden { display: none; }

.htp-card {
    position: relative;
    background: none;
    border: none;
    border-radius: 0;
    box-shadow: none;
    width: 380px;
    max-width: calc(100vw - 48px);
    padding: 40px 32px 28px;
    max-height: calc(100dvh - 24px);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: win-card-in 0.32s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.htp-close { top: 10px; right: 8px; }

.htp-dots {
    display: flex;
    gap: 7px;
    justify-content: center;
    width: 100%;
    margin-bottom: 24px;
}
.htp-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.2);
    cursor: pointer;
    padding: 0;
    transition: background 0.2s, transform 0.2s;
}
.htp-dot.active {
    background: rgba(255,255,255,0.75);
    transform: scale(1.2);
}

.htp-slides { width: 100%; }
.htp-slide { display: none; }
.htp-slide.active {
    display: block;
    animation: htp-fadein 0.22s ease;
}
@keyframes htp-fadein {
    from { opacity: 0; transform: translateY(5px); }
    to   { opacity: 1; transform: none; }
}

.htp-illo {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 18px;
}

/* Mini 5x5 board: cell=26px, gap=5px, step=31px, total=150px */
.htp-board {
    display: grid;
    grid-template-columns: repeat(5, 26px);
    grid-template-rows: repeat(5, 26px);
    gap: 5px;
    background: #0F1117;
    border-radius: 7px;
    position: relative;
}
.htp-c {
    background: #191C2A;
    border-radius: 2px;
    position: relative;
}
.htp-gp1::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: rgba(158,74,64,0.8);
    border-radius: 2px 2px 0 0;
}
.htp-gp2::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 3px;
    background: rgba(62,104,168,0.8);
    border-radius: 0 0 2px 2px;
}

/* Pawns -- flat colors matching in-game, centered with transform */
.htp-pawn {
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    transform: translate(-50%, -50%);
}
.htp-p1 { background: #9E4A40; }
.htp-p2 { background: #3E68A8; }

/* Walls: H = row-gap-spanning, V = col-gap-spanning */
.htp-wh {
    position: absolute;
    height: 5px;
    width: 57px;  /* 2*26+5 */
    border-radius: 2px;
}
.htp-wv {
    position: absolute;
    width: 5px;
    height: 57px;
    border-radius: 2px;
}
.htp-pw1 { background: #9E4A40; }
.htp-pw2 { background: #3E68A8; }

/* Move dots -- match in-game style: small filled circle at half opacity */
.htp-mdot {
    position: absolute;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #9E4A40;
    opacity: 0.5;
    transform: translate(-50%, -50%);
}
/* Dots fade out when the pawn starts jumping, back when it reappears */
@keyframes htp-mdot-jump {
    0%, 14%   { opacity: 0.5; }
    24%, 72%  { opacity: 0; }
    82%, 100% { opacity: 0.5; }
}
.htp-mdot-a { animation: htp-mdot-jump 3s ease-in-out infinite; }

/* Gap highlight strips for slide 2 - H during red phase, V during blue phase */
.htp-gaphl-h {
    position: absolute;
    left: 0; right: 0;
    height: 5px;
    background: rgba(255,255,255,0.12);
    animation: htp-gaphl-phase1 8s ease-in-out infinite;
}
.htp-gaphl-v {
    position: absolute;
    top: 0; bottom: 0;
    width: 5px;
    background: rgba(255,255,255,0.12);
    animation: htp-gaphl-phase2 8s ease-in-out infinite;
}
@keyframes htp-gaphl-phase1 {
    0%, 8%    { opacity: 0; }
    14%, 42%  { opacity: 1; }
    50%, 100% { opacity: 0; }
}
@keyframes htp-gaphl-phase2 {
    0%, 58%   { opacity: 0; }
    64%, 90%  { opacity: 1; }
    98%, 100% { opacity: 0; }
}

/* Drag finger indicator */
.htp-finger {
    position: absolute;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: rgba(210,218,235,0.88);
    box-shadow: 0 0 0 4px rgba(210,218,235,0.22);
    transform: translate(-50%, -50%);
}

/* Path dots for slide 3 */
.htp-pdot {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #3E68A8;
    transform: translate(-50%, -50%);
    opacity: 0;
    animation: htp-pdot-p 2.5s ease-in-out infinite both;
}
.htp-pd1 { animation-delay: 0s; }
.htp-pd2 { animation-delay: 0.4s; }
.htp-pd3 { animation-delay: 0.8s; }
.htp-pd4 { animation-delay: 1.2s; }

/* Upward arrow for slide 0 */
.htp-arr-line {
    position: absolute;
    width: 2px;
    background: repeating-linear-gradient(
        to bottom,
        #9E4A40 0px, #9E4A40 5px,
        transparent 5px, transparent 10px
    );
}
.htp-arr-head {
    position: absolute;
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-bottom: 9px solid #9E4A40;
}

/* Wall count display */
.htp-wcount {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    margin-top: 10px;
}
.htp-wcrow { display: flex; gap: 3px; }
.htp-wb {
    width: 9px;
    height: 16px;
    border-radius: 2px;
    opacity: 0.85;
}
.htp-wc-p1 .htp-wb { background: #9E4A40; }
.htp-wc-p2 .htp-wb { background: #3E68A8; }

/* Text */
.htp-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: #C8CCDC;
    text-align: center;
    margin: 0 0 10px;
    letter-spacing: -0.02em;
    line-height: 1.15;
}
.htp-desc {
    font-size: 14px;
    color: #5A6080;
    text-align: center;
    margin: 0;
    line-height: 1.55;
}

/* Navigation */
.htp-nav {
    display: flex;
    align-items: center;
    width: 100%;
    margin-top: 28px;
}
.htp-prev {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    margin-right: 10px;
    border-radius: 10px;
    border: none;
    background: none;
    color: #5A6080;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    overflow: hidden;
    transition: width 0.28s cubic-bezier(0.22, 1, 0.36, 1),
                margin 0.28s cubic-bezier(0.22, 1, 0.36, 1),
                opacity 0.28s ease,
                transform 0.28s cubic-bezier(0.22, 1, 0.36, 1),
                background 0.16s ease,
                color 0.16s ease;
}
.htp-prev:hover { background: #1A1D2A; color: #C8CCDC; }
.htp-prev.htp-hidden {
    width: 0;
    margin-right: 0;
    opacity: 0;
    transform: translateX(-8px);
    pointer-events: none;
}
.htp-next {
    flex: 1;
    padding: 13px 16px;
    border-radius: 10px;
    border: none;
    background: #162032;
    color: #8FB4E8;
    font-family: inherit;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.16s ease, color 0.16s ease, transform 0.1s ease;
}
.htp-next:hover { background: #1D2B44; color: #A8C6F0; }
.htp-next:active { transform: scale(0.98); }

/* Animations */
@keyframes htp-arr-pulse {
    0%, 100% { opacity: 0.28; }
    50%       { opacity: 0.88; }
}
.htp-arr-anim { animation: htp-arr-pulse 1.8s ease-in-out infinite; }

@keyframes htp-pawn-bob {
    0%, 100% { transform: translate(-50%, -50%); }
    50%       { transform: translate(-50%, calc(-50% - 5px)); }
}
.htp-pawn-bob { animation: htp-pawn-bob 1.8s ease-in-out infinite; }

@keyframes htp-pawn-jump {
    0%, 18%  { transform: translate(-50%, -50%);              opacity: 1; }
    42%, 58% { transform: translate(-50%, calc(-50% - 62px)); opacity: 1; }
    70%      { transform: translate(-50%, calc(-50% - 62px)); opacity: 0; }
    71%      { transform: translate(-50%, -50%);              opacity: 0; }
    82%, 100%{ transform: translate(-50%, -50%);              opacity: 1; }
}
.htp-pawn-jump {
    animation: htp-pawn-jump 3s ease-in-out infinite;
    z-index: 2;
}

/* Red H wall: grows in at start, stays visible through blue phase, fades at end */
@keyframes htp-wall-seq {
    0%, 18%   { width: 0; opacity: 0; }
    26%       { opacity: 1; }
    36%, 88%  { width: 57px; opacity: 1; }
    97%, 100% { width: 57px; opacity: 0; }
}
.htp-wall-r { animation: htp-wall-seq 8s ease-in-out infinite; }

/* Blue V wall: second half of 8s cycle, grows height */
@keyframes htp-wall-seq-v {
    0%, 18%  { height: 0; opacity: 0; }
    26%      { opacity: 1; }
    38%, 43% { height: 57px; opacity: 1; }
    50%      { height: 57px; opacity: 0; }
    51%, 100%{ height: 0; opacity: 0; }
}
.htp-wall-b { animation: htp-wall-seq-v 8s ease-in-out infinite; animation-delay: -4s; }

/* H finger: first half of cycle */
@keyframes htp-drag-h {
    0%, 14%  { transform: translate(-50%,-50%) translateX(0);   opacity: 0; }
    22%      { opacity: 1; }
    40%      { transform: translate(-50%,-50%) translateX(57px); opacity: 1; }
    48%      { transform: translate(-50%,-50%) translateX(57px); opacity: 0; }
    49%, 100%{ transform: translate(-50%,-50%) translateX(0);   opacity: 0; }
}
.htp-drag-anim { animation: htp-drag-h 8s ease-in-out infinite; }

/* V finger: second half of cycle */
@keyframes htp-drag-v {
    0%, 64%  { transform: translate(-50%,-50%) translateY(0);   opacity: 0; }
    72%      { opacity: 1; }
    90%      { transform: translate(-50%,-50%) translateY(57px); opacity: 1; }
    98%      { transform: translate(-50%,-50%) translateY(57px); opacity: 0; }
    99%, 100%{ transform: translate(-50%,-50%) translateY(0);   opacity: 0; }
}
.htp-drag-v { animation: htp-drag-v 8s ease-in-out infinite; }

@keyframes htp-pdot-p {
    0%, 10%, 90%, 100% { opacity: 0.1; }
    40%, 60%           { opacity: 0.8; }
}

@media (prefers-reduced-motion: reduce) {
    .htp-pawn-bob, .htp-pawn-jump, .htp-arr-anim,
    .htp-wall-r, .htp-wall-b, .htp-drag-anim, .htp-drag-v,
    .htp-gaphl-h, .htp-gaphl-v, .htp-mdot-a { animation: none; }
    .htp-wall-r { width: 57px; opacity: 1; }
    .htp-wall-b { height: 57px; opacity: 0; }
    .htp-gaphl-h { opacity: 1; }
    .htp-gaphl-v { opacity: 0; }
    .htp-mdot-a { opacity: 0.5; }
    .htp-pdot { opacity: 0.6; }
}
