/* =========================================================
   TOWNTUNE V2 - SHARED GAME LANDING + FULLSCREEN PLAYER
   ========================================================= */

body.game-open {
    overflow: hidden;
}

.game-page-main {
    width: min(100%, var(--tt-max));
    margin: 0 auto;
    padding: 30px 22px 70px;
}

.game-launch-card {
    position: relative;
    display: block;
    min-height: 540px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 30px;
    background:
        radial-gradient(circle at 80% 10%, rgba(255,255,255,.14), transparent 23%),
        linear-gradient(135deg, #f7aa2a 0%, #ff7148 46%, #f24b83 100%);
    box-shadow: var(--tt-shadow);
    text-decoration: none;
    isolation: isolate;
}

.game-launch-card::before,
.game-launch-card::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    background: rgba(255,255,255,.12);
}

.game-launch-card::before {
    width: 420px;
    height: 420px;
    right: -120px;
    top: -160px;
}

.game-launch-card::after {
    width: 330px;
    height: 330px;
    left: -140px;
    bottom: -160px;
}

.word-art {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 34px;
}

.word-art-tiles {
    display: flex;
    justify-content: center;
    gap: clamp(7px, 1.3vw, 16px);
    transform: rotate(-4deg);
}

.word-art-tiles span {
    width: clamp(54px, 10vw, 116px);
    aspect-ratio: 1;
    display: grid;
    place-items: center;
    border: 3px solid rgba(255,255,255,.7);
    border-radius: clamp(14px, 2vw, 25px);
    background: rgba(255,255,255,.18);
    box-shadow: 0 20px 40px rgba(77,25,18,.2);
    color: #fff;
    font-size: clamp(31px, 6vw, 72px);
    font-weight: 950;
    text-shadow: 0 5px 16px rgba(0,0,0,.18);
    backdrop-filter: blur(6px);
}

.game-launch-copy {
    position: absolute;
    z-index: 3;
    left: 34px;
    right: 34px;
    bottom: 30px;
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 24px;
}

.game-launch-copy::before {
    content: "";
    position: absolute;
    z-index: -1;
    left: -34px;
    right: -34px;
    bottom: -30px;
    height: 220px;
    background: linear-gradient(to top, rgba(6,16,34,.9), rgba(6,16,34,0));
    pointer-events: none;
}

.game-launch-copy h1 {
    margin: 4px 0 7px;
    color: #fff;
    font-size: clamp(34px, 5vw, 64px);
    line-height: .98;
    letter-spacing: -2px;
}

.game-launch-copy p {
    margin: 0;
    max-width: 660px;
    color: rgba(255,255,255,.8);
    font-size: 16px;
}

.game-launch-kicker {
    color: #fff1b8;
    font-size: 12px;
    font-weight: 950;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.game-launch-play {
    flex: 0 0 auto;
    width: 86px;
    height: 86px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 50%;
    background: #fff;
    color: #12213b;
    box-shadow: 0 16px 34px rgba(0,0,0,.25);
    font-size: 31px;
    cursor: pointer;
    transition: transform .18s ease;
}

.game-launch-card:hover .game-launch-play {
    transform: scale(1.06);
}

.game-landing-section {
    margin-top: 48px;
}

.game-landing-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.game-landing-heading h2 {
    margin: 3px 0 0;
    font-size: clamp(26px, 3vw, 38px);
    letter-spacing: -1px;
}

.related-game-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0,1fr));
    gap: 16px;
}

.game-info-panel {
    padding: clamp(26px, 4vw, 48px);
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 28px;
    background: linear-gradient(180deg, #f8fbff, #edf4fb);
    color: #173351;
    box-shadow: 0 22px 52px rgba(0,0,0,.2);
}

.game-info-panel h2 {
    margin: 0 0 16px;
    color: #0c2949;
    font-size: clamp(30px, 4vw, 48px);
    letter-spacing: -1.5px;
}

.game-info-panel h3 {
    margin: 28px 0 8px;
    color: #123b65;
    font-size: 21px;
}

.game-info-panel p,
.game-info-panel li {
    color: #49637d;
    font-size: 16px;
    line-height: 1.7;
}

.game-info-panel ul {
    margin: 10px 0 0;
    padding-left: 22px;
}

.game-info-links {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 25px;
}

.game-info-links a {
    padding: 10px 14px;
    border-radius: 12px;
    background: #102d4e;
    color: #fff;
    text-decoration: none;
    font-size: 13px;
    font-weight: 850;
}

/* FULLSCREEN PLAYER */
.tt-game-player {
    position: fixed;
    z-index: 5000;
    inset: 0;
    display: none;
    background:
        radial-gradient(circle at 20% 0%, rgba(255,112,70,.18), transparent 30%),
        #07172c;
    color: #fff;
    overflow: auto;
    overscroll-behavior: contain;
}

.tt-game-player.open {
    display: block;
}

.tt-game-player-inner {
    min-height: 100dvh;
    width: min(100%, 1050px);
    margin: 0 auto;
    padding:
        max(74px, calc(env(safe-area-inset-top) + 66px))
        18px
        max(28px, env(safe-area-inset-bottom));
    display: flex;
    align-items: center;
    justify-content: center;
}

.tt-game-exit {
    position: fixed;
    z-index: 5010;
    top: max(14px, env(safe-area-inset-top));
    left: max(14px, env(safe-area-inset-left));
    min-width: 66px;
    height: 46px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 0 14px;
    border: 1px solid rgba(255,255,255,.15);
    border-radius: 16px;
    background: rgba(255,255,255,.95);
    color: #0e2745;
    box-shadow: 0 10px 28px rgba(0,0,0,.28);
    font-size: 14px;
    font-weight: 950;
    cursor: pointer;
}

.word-game {
    width: min(100%, 850px);
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 28px;
    background:
        radial-gradient(circle at 100% 0%, rgba(255,170,42,.15), transparent 30%),
        #102845;
    box-shadow: 0 24px 65px rgba(0,0,0,.36);
    overflow: hidden;
}

.word-game-top {
    padding: 22px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}

.word-game-title {
    margin: 0 0 14px;
    font-size: 27px;
    letter-spacing: -.7px;
}

.word-game-status {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.word-status-pill {
    padding: 7px 11px;
    border-radius: 999px;
    background: rgba(255,255,255,.08);
    color: #d7e4f4;
    font-size: 13px;
    font-weight: 800;
}

.word-theme-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
}

.word-theme {
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 12px;
    background: rgba(255,255,255,.06);
    color: #fff;
    padding: 9px 12px;
    font-size: 13px;
    font-weight: 850;
    cursor: pointer;
}

.word-theme.active-category {
    background: #fff;
    color: #102845;
}

.word-game-stage {
    padding: clamp(20px, 4vw, 38px);
    text-align: center;
}

.word-drag-instruction {
    margin: 0 auto 14px;
    color: #9fb1c7;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: .02em;
}

.letter-board {
    width: min(100%, 720px);
    min-height: 112px;
    margin: 0 auto 22px;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    align-content: center;
    flex-wrap: wrap;
    gap: 10px;
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 22px;
    outline: none;
    background:
        radial-gradient(circle at 50% 0%, rgba(255,179,49,.09), transparent 60%),
        rgba(255,255,255,.035);
    box-shadow: inset 0 1px rgba(255,255,255,.025);
}

.letter-board:focus-visible {
    box-shadow: 0 0 0 4px rgba(101,222,208,.12);
}

.letter-tile,
.letter-tile-placeholder {
    width: clamp(50px, 8vw, 74px);
    height: clamp(58px, 9vw, 82px);
    flex: 0 0 auto;
    border-radius: 16px;
}

.letter-tile {
    display: grid;
    place-items: center;
    border: 2px solid rgba(255,255,255,.36);
    background: linear-gradient(145deg, #ffb231, #ff724b 58%, #ef4e79);
    color: #fff;
    box-shadow:
        0 10px 22px rgba(0,0,0,.20),
        inset 0 1px rgba(255,255,255,.30);
    font-size: clamp(25px, 5vw, 40px);
    font-weight: 950;
    line-height: 1;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    transition:
        transform .14s ease,
        box-shadow .14s ease,
        border-color .14s ease;
}

.letter-tile:hover {
    transform: translateY(-2px);
    box-shadow:
        0 14px 26px rgba(0,0,0,.24),
        inset 0 1px rgba(255,255,255,.32);
}

.letter-tile.dragging {
    z-index: 6000;
    cursor: grabbing;
    transform: rotate(4deg) scale(1.07);
    box-shadow: 0 22px 42px rgba(0,0,0,.38);
    pointer-events: none;
    transition: none;
}

.letter-tile-placeholder {
    border: 2px dashed rgba(101,222,208,.55);
    background: rgba(101,222,208,.08);
}

.letter-board.is-dragging {
    border-color: rgba(101,222,208,.24);
}

.letter-tile.hint-letter {
    border-color: #fff3a0;
    box-shadow:
        0 0 0 4px rgba(255,224,99,.16),
        0 15px 30px rgba(0,0,0,.26);
    animation: hintPulse .8s ease 2;
}

@keyframes hintPulse {
    50% {
        transform: translateY(-5px) scale(1.06);
    }
}

.word-actions {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 9px;
    margin-top: 15px;
}

.word-actions button {
    min-height: 43px;
    border: 0;
    border-radius: 12px;
    padding: 9px 14px;
    background: #6377ff;
    color: #fff;
    font-size: 13px;
    font-weight: 900;
    cursor: pointer;
}

.word-actions button.secondary {
    background: rgba(255,255,255,.09);
    color: #e6eef8;
}

.word-feedback {
    min-height: 54px;
    max-width: 650px;
    margin: 19px auto 0;
    padding: 13px 15px;
    border-radius: 15px;
    background: rgba(255,255,255,.06);
    color: #d7e4f4;
    font-size: 14px;
    font-weight: 800;
}

@media (max-width: 900px) {
    .related-game-grid {
        grid-template-columns: repeat(2, minmax(0,1fr));
    }
}

@media (max-width: 600px) {
    .game-page-main {
        padding: 18px 12px 52px;
    }

    .game-launch-card {
        min-height: 480px;
        border-radius: 24px;
    }

    .game-launch-copy {
        left: 20px;
        right: 20px;
        bottom: 20px;
        align-items: flex-end;
    }

    .game-launch-copy::before {
        left: -20px;
        right: -20px;
        bottom: -20px;
    }

    .game-launch-copy h1 {
        font-size: 38px;
        letter-spacing: -1.5px;
    }

    .game-launch-copy p {
        display: none;
    }

    .game-launch-play {
        width: 70px;
        height: 70px;
        font-size: 25px;
    }

    .word-art {
        align-items: start;
        padding-top: 80px;
    }

    .related-game-grid {
        gap: 12px;
    }

    .tt-game-player-inner {
        padding-left: 10px;
        padding-right: 10px;
        align-items: stretch;
    }

    .word-game {
        border-radius: 22px;
        align-self: center;
    }

    .word-game-top {
        padding: 18px;
    }

    .word-game-title {
        font-size: 23px;
    }

    .word-game-stage {
        padding: 22px 14px 25px;
    }

    .letter-board {
        min-height: 104px;
        padding: 13px 10px;
        gap: 8px;
        border-radius: 18px;
    }

    .letter-tile,
    .letter-tile-placeholder {
        width: clamp(44px, 13vw, 58px);
        height: clamp(52px, 15vw, 66px);
        border-radius: 14px;
    }

    .letter-tile {
        font-size: 27px;
    }

    .word-actions button {
        flex: 1 1 calc(50% - 9px);
    }
}


/* =========================================================
   RELATED GAME ROTATION + GAME INFO LINK CONTRAST
   ========================================================= */

/* JS hides the non-selected suggestions after each refresh. */
.related-game-grid [data-related-game][hidden] {
    display: none !important;
}

/*
 * styles-v2.css has a general body.portal-v2 a rule.
 * These selectors deliberately beat it so the dark CTA buttons
 * always keep bright readable text.
 */
body.portal-v2 .game-info-panel .game-info-links a,
body.portal-v2 .game-info-panel .game-info-links a:visited {
    color: #ffffff;
}

body.portal-v2 .game-info-panel .game-info-links a:hover,
body.portal-v2 .game-info-panel .game-info-links a:focus-visible {
    color: #ffffff;
    background: #17436f;
}


/* =========================================================
   WORD SCRAMBLE APP MODE
   Locked to the viewport: no vertical page scrolling in-game.
   This block intentionally overrides the older player rules above.
   ========================================================= */

.tt-game-player {
    --player-bar-h: clamp(52px, 7.5dvh, 64px);
    --player-edge: clamp(7px, 1.4dvh, 14px);
    overflow: hidden;
    height: 100dvh;
    max-height: 100dvh;
}

.tt-game-player.open {
    display: block;
}

/* Universal game topbar: TT left, title dead-centre. */
.tt-player-topbar {
    position: absolute;
    z-index: 5020;
    top: 0;
    left: 0;
    right: 0;
    height: calc(var(--player-bar-h) + env(safe-area-inset-top));
    padding:
        env(safe-area-inset-top)
        max(10px, env(safe-area-inset-right))
        0
        max(10px, env(safe-area-inset-left));
    display: grid;
    grid-template-columns: 78px minmax(0, 1fr) 78px;
    align-items: center;
    gap: 8px;
    background: linear-gradient(
        to bottom,
        rgba(7, 23, 44, .98),
        rgba(7, 23, 44, .84)
    );
    border-bottom: 1px solid rgba(255,255,255,.07);
    backdrop-filter: blur(14px);
}

.tt-game-exit {
    position: static;
    z-index: auto;
    width: 70px;
    min-width: 70px;
    height: clamp(38px, 5.5dvh, 46px);
    padding: 0 11px;
    border-radius: 15px;
    font-size: clamp(13px, 1.9dvh, 15px);
    box-shadow: 0 7px 18px rgba(0,0,0,.22);
}

.tt-player-title {
    min-width: 0;
    overflow: hidden;
    color: #fff;
    font-size: clamp(18px, 3.1dvh, 27px);
    font-weight: 950;
    line-height: 1;
    letter-spacing: -.6px;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tt-player-topbar-spacer {
    width: 70px;
}

.tt-game-player-inner {
    width: min(100%, 930px);
    height: 100dvh;
    min-height: 0;
    margin: 0 auto;
    padding:
        calc(var(--player-bar-h) + env(safe-area-inset-top) + var(--player-edge))
        max(7px, env(safe-area-inset-right))
        max(var(--player-edge), env(safe-area-inset-bottom))
        max(7px, env(safe-area-inset-left));
    display: flex;
    align-items: stretch;
    justify-content: center;
    overflow: hidden;
}

.word-game {
    width: min(100%, 850px);
    height: 100%;
    max-height: 100%;
    min-height: 0;
    align-self: stretch;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    border-radius: clamp(18px, 2.7dvh, 27px);
    overflow: hidden;
}

/* Compact top section so the game always fits. */
.word-game-top {
    padding: clamp(9px, 1.7dvh, 17px);
    border-bottom: 1px solid rgba(255,255,255,.08);
}

.word-game-title {
    display: none;
}

.word-game-status {
    justify-content: center;
    gap: clamp(4px, .8dvh, 8px);
}

.word-status-pill {
    padding:
        clamp(5px, .8dvh, 7px)
        clamp(8px, 1.5vw, 11px);
    font-size: clamp(11px, 1.7dvh, 13px);
}

.word-theme-row {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: clamp(4px, .8dvh, 8px);
    margin-top: clamp(6px, 1.2dvh, 12px);
}

.word-theme {
    min-width: 0;
    padding:
        clamp(6px, 1dvh, 9px)
        clamp(4px, 1.2vw, 10px);
    border-radius: clamp(9px, 1.6dvh, 12px);
    font-size: clamp(11px, 1.8dvh, 14px);
    white-space: nowrap;
}

/* The actual game stage fills whatever viewport height remains. */
.word-game-stage {
    min-height: 0;
    padding:
        clamp(7px, 1.35dvh, 14px)
        clamp(8px, 2vw, 18px)
        clamp(8px, 1.4dvh, 15px);
    display: flex;
    flex-direction: column;
    justify-content: space-evenly;
    gap: clamp(3px, .8dvh, 8px);
    overflow: hidden;
}

.word-drag-instruction {
    margin: 0;
    flex: 0 0 auto;
    font-size: clamp(10px, 1.65dvh, 13px);
    line-height: 1.25;
}

.word-build-label {
    margin: 0 !important;
    flex: 0 0 auto;
    color: #d9e6f4;
    font-size: clamp(10px, 1.55dvh, 13px);
    font-weight: 950;
    line-height: 1.15;
    letter-spacing: .045em;
    text-transform: uppercase;
}

/* Top mixed-letter row and bottom answer row. */
.letter-board.letter-rack,
.answer-board {
    --slot-gap: 6px;
    width: min(100%, 740px);
    height: clamp(58px, 10.5dvh, 90px);
    min-height: 0 !important;
    margin: 0 auto !important;
    padding: clamp(5px, .9dvh, 9px) !important;
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    align-content: center;
    flex-wrap: nowrap;
    gap: var(--slot-gap) !important;
    border-radius: clamp(14px, 2dvh, 20px);
    overflow: visible;
}

.source-slot,
.answer-slot {
    width: var(--tt-slot-w, 56px) !important;
    height: var(--tt-slot-h, 66px) !important;
    min-width: 0;
    min-height: 0;
    flex: 0 0 var(--tt-slot-w, 56px) !important;
    display: grid;
    place-items: center;
    border-radius: clamp(8px, 1.5dvh, 13px);
    transition:
        border-color .14s ease,
        background .14s ease,
        transform .14s ease;
}

.source-slot {
    border: 2px dashed rgba(255,255,255,.10);
    background: rgba(255,255,255,.022);
}

.source-slot:empty {
    background: rgba(255,255,255,.012);
}

.answer-board {
    border: 1px solid rgba(101,222,208,.22);
    background:
        radial-gradient(circle at 50% 0%, rgba(101,222,208,.08), transparent 60%),
        rgba(255,255,255,.025);
}

.answer-slot {
    border: 2px dashed rgba(101,222,208,.52);
    background: rgba(101,222,208,.045);
}

.answer-slot.is-over,
.source-slot.is-over {
    border-color: rgba(255,255,255,.95);
    background: rgba(101,222,208,.16);
    transform: translateY(-1px);
}

.answer-slot.correct-hint {
    border-color: #fff3a0;
    background: rgba(255,224,99,.12);
    box-shadow: 0 0 0 3px rgba(255,224,99,.10);
}

.letter-tile {
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    padding: 0;
    border-radius: inherit;
    font-size: clamp(16px, 3.2dvh, 28px);
}

.letter-tile.dragging {
    width: var(--drag-w, 56px) !important;
    height: var(--drag-h, 66px) !important;
}

/* Clue remains visible but compact. */
.word-clue {
    margin: 0 auto;
    flex: 0 0 auto;
    max-width: 720px;
    font-size: clamp(11px, 1.9dvh, 16px);
    line-height: 1.25;
}

/* Two-by-two app buttons. */
.word-actions {
    width: min(100%, 720px);
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: clamp(5px, .9dvh, 9px);
    flex: 0 0 auto;
}

.word-actions button {
    min-width: 0;
    min-height: clamp(34px, 5.4dvh, 47px);
    padding:
        clamp(5px, .8dvh, 9px)
        8px;
    border-radius: clamp(9px, 1.5dvh, 12px);
    font-size: clamp(11px, 1.85dvh, 14px);
}

/* Feedback cannot grow and push the game off-screen. */
.word-feedback {
    width: min(100%, 720px);
    min-height: 0;
    max-height: clamp(40px, 7.5dvh, 62px);
    margin: 0 auto;
    padding:
        clamp(7px, 1.1dvh, 11px)
        12px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    overflow: hidden;
    border-radius: clamp(10px, 1.7dvh, 15px);
    font-size: clamp(10px, 1.65dvh, 13px);
    line-height: 1.25;
}

/* Extra compression for short phones / landscape windows. */
@media (max-height: 680px) {
    .tt-game-player {
        --player-bar-h: 48px;
        --player-edge: 5px;
    }

    .word-game-top {
        padding: 7px 10px;
    }

    .word-status-pill {
        padding: 4px 8px;
        font-size: 10px;
    }

    .word-theme-row {
        margin-top: 5px;
        gap: 4px;
    }

    .word-theme {
        padding: 5px 4px;
        font-size: 10px;
    }

    .word-game-stage {
        padding: 5px 8px 7px;
        gap: 2px;
    }

    .letter-board.letter-rack,
    .answer-board {
        height: 54px;
        padding: 4px !important;
        --slot-gap: 4px;
    }

    .word-feedback {
        max-height: 38px;
        padding: 5px 9px;
    }
}

@media (max-width: 600px) {
    .tt-player-topbar {
        grid-template-columns: 68px minmax(0, 1fr) 68px;
        padding-left: max(7px, env(safe-area-inset-left));
        padding-right: max(7px, env(safe-area-inset-right));
    }

    .tt-game-exit {
        width: 62px;
        min-width: 62px;
        border-radius: 14px;
    }

    .tt-player-topbar-spacer {
        width: 62px;
    }

    .word-game {
        border-radius: 18px;
    }
}
