.trojice-page {
    background:
        radial-gradient(circle at 12% 12%, rgba(255, 220, 143, .24), transparent 30rem),
        radial-gradient(circle at 88% 35%, rgba(109, 190, 173, .18), transparent 34rem),
        #f8f4ea;
}

.trojice-app {
    --to-ink: #283936;
    --to-muted: #65736f;
    --to-gold: #b67a2c;
    --to-gold-dark: #8d581d;
    --to-green: #286c61;
    --to-paper: #fffdf7;
    --to-line: rgba(45, 76, 70, .16);
    width: min(1240px, calc(100% - 32px));
    margin: 0 auto;
    padding: 34px 0 72px;
    color: var(--to-ink);
}

.trojice-app *,
.trojice-app *::before,
.trojice-app *::after {
    box-sizing: border-box;
}

.trojice-app [hidden] {
    display: none !important;
}

.trojice-app .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.trojice-preview-banner {
    margin-bottom: 18px;
    padding: 12px 18px;
    border: 1px solid #e0b55f;
    border-radius: 14px;
    background: #fff4ce;
    text-align: center;
    font-weight: 700;
}

.trojice-hero {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(300px, .75fr);
    min-height: 400px;
    margin-bottom: 28px;
    padding: clamp(34px, 6vw, 76px);
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 32px;
    color: #fffdf8;
    background:
        radial-gradient(circle at 78% 18%, rgba(255, 224, 155, .28), transparent 18rem),
        linear-gradient(135deg, #173f3a 0%, #245f55 58%, #327e6c 100%);
    box-shadow: 0 24px 70px rgba(29, 68, 61, .18);
}

.trojice-hero::after {
    content: "✦";
    position: absolute;
    left: 52%;
    bottom: 12%;
    color: rgba(255, 231, 174, .28);
    font-size: 4rem;
}

.trojice-hero-copy {
    position: relative;
    z-index: 2;
    align-self: center;
    max-width: 690px;
}

.trojice-hero h1 {
    margin: .08em 0 .22em;
    color: inherit;
    font-size: clamp(2.8rem, 7vw, 5.8rem);
    line-height: .98;
    letter-spacing: -.045em;
}

.trojice-hero .eyebrow {
    color: #f5d797;
}

.trojice-lead {
    max-width: 650px;
    margin: 0;
    color: rgba(255, 255, 255, .88);
    font-size: clamp(1.05rem, 1.7vw, 1.28rem);
    line-height: 1.65;
}

.trojice-facts {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 26px;
}

.trojice-facts span {
    padding: 8px 13px;
    border: 1px solid rgba(255, 255, 255, .18);
    border-radius: 999px;
    background: rgba(255, 255, 255, .09);
    color: #fff;
    font-size: .9rem;
}

.trojice-hero-cards {
    position: relative;
    min-height: 275px;
}

.trojice-hero-card {
    position: absolute;
    right: 8%;
    top: 50%;
    width: clamp(142px, 15vw, 190px);
    aspect-ratio: 2 / 3;
    border: 5px solid rgba(255, 255, 255, .88);
    border-radius: 17px;
    object-fit: cover;
    box-shadow: 0 20px 45px rgba(0, 0, 0, .28);
}

.trojice-hero-card-1 {
    transform: translate(-64%, -51%) rotate(-12deg);
}

.trojice-hero-card-2 {
    z-index: 2;
    transform: translate(-18%, -53%) rotate(1deg);
}

.trojice-hero-card-3 {
    z-index: 3;
    transform: translate(28%, -46%) rotate(11deg);
}

.trojice-panel,
.trojice-unlock {
    margin-top: 26px;
    padding: clamp(24px, 5vw, 52px);
    border: 1px solid var(--to-line);
    border-radius: 26px;
    background: rgba(255, 253, 247, .94);
    box-shadow: 0 16px 55px rgba(43, 74, 68, .08);
}

.trojice-section-heading {
    max-width: 760px;
    margin-bottom: 30px;
}

.trojice-section-heading h2,
.trojice-unlock h2,
.trojice-finish h2 {
    margin: .08em 0 .28em;
    color: var(--to-ink);
    font-size: clamp(1.9rem, 4vw, 3rem);
}

.trojice-section-heading > p:last-child,
.trojice-unlock p {
    color: var(--to-muted);
    line-height: 1.65;
}

.trojice-fieldset {
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.trojice-fieldset + .trojice-fieldset {
    margin-top: 34px;
}

.trojice-fieldset legend {
    margin-bottom: 13px;
    color: var(--to-ink);
    font-size: 1.08rem;
    font-weight: 800;
}

.trojice-choice-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.trojice-choice {
    position: relative;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 4px 13px;
    min-height: 132px;
    padding: 20px;
    border: 2px solid var(--to-line);
    border-radius: 18px;
    color: var(--to-ink);
    background: #fff;
    text-align: left;
    font: inherit;
    cursor: pointer;
    transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}

.trojice-choice:hover {
    transform: translateY(-2px);
    border-color: rgba(40, 108, 97, .45);
    box-shadow: 0 10px 25px rgba(40, 84, 75, .09);
}

.trojice-choice:focus-visible,
.trojice-small-button:focus-visible,
.trojice-card-button:focus-visible {
    outline: 3px solid rgba(182, 122, 44, .44);
    outline-offset: 3px;
}

.trojice-choice.is-selected {
    border-color: var(--to-green);
    background: #f1faf6;
    box-shadow: 0 0 0 3px rgba(40, 108, 97, .09);
}

.trojice-choice.is-locked {
    color: #6c716e;
    background: #f8f6f0;
}

.trojice-choice-icon {
    grid-row: 1 / span 4;
    color: var(--to-gold);
    font-size: 1.55rem;
    line-height: 1.25;
}

.trojice-choice strong {
    font-size: 1.02rem;
}

.trojice-choice span:not(.trojice-choice-icon),
.trojice-choice small {
    color: var(--to-muted);
    line-height: 1.42;
}

.trojice-choice em {
    align-self: end;
    margin-top: 7px;
    color: var(--to-green);
    font-size: .78rem;
    font-style: normal;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.trojice-start-row,
.trojice-sticky-actions,
.trojice-finish-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-top: 34px;
}

.trojice-start-row p {
    margin: 0;
    color: var(--to-muted);
}

.trojice-main-button {
    min-width: 220px;
}

.trojice-study-list {
    display: grid;
    gap: 20px;
}

.trojice-study-group {
    display: grid;
    grid-template-columns: 180px minmax(0, 1fr);
    gap: 25px;
    padding: 22px;
    border: 1px solid var(--to-line);
    border-radius: 20px;
    background: #fff;
}

.trojice-study-heading {
    align-self: center;
}

.trojice-study-heading span {
    display: block;
    margin-bottom: 6px;
    color: var(--to-gold);
    font-size: 1.65rem;
}

.trojice-study-heading h3 {
    margin: 0 0 8px;
    font-size: 1.35rem;
}

.trojice-study-heading p {
    margin: 0;
    color: var(--to-muted);
    font-size: .92rem;
    line-height: 1.48;
}

.trojice-study-cards {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.trojice-study-card {
    min-width: 0;
}

.trojice-study-card img {
    display: block;
    width: 100%;
    aspect-ratio: 2 / 3;
    border-radius: 12px;
    object-fit: cover;
    box-shadow: 0 7px 20px rgba(34, 62, 57, .14);
}

.trojice-study-card strong,
.trojice-study-card small {
    display: block;
}

.trojice-study-card strong {
    margin-top: 9px;
    font-size: .92rem;
}

.trojice-study-card small {
    margin-top: 3px;
    color: var(--to-muted);
    font-size: .78rem;
    line-height: 1.4;
}

.trojice-sticky-actions {
    position: sticky;
    z-index: 8;
    bottom: 12px;
    padding: 14px;
    border: 1px solid var(--to-line);
    border-radius: 18px;
    background: rgba(255, 253, 247, .94);
    box-shadow: 0 12px 35px rgba(32, 62, 56, .14);
    backdrop-filter: blur(9px);
}

.trojice-game {
    margin-top: 26px;
}

.trojice-gamebar {
    position: sticky;
    z-index: 12;
    top: 10px;
    display: grid;
    grid-template-columns: minmax(105px, 1fr) minmax(190px, 2fr) minmax(80px, .7fr) auto auto;
    align-items: center;
    gap: 11px;
    padding: 13px 16px;
    border: 1px solid var(--to-line);
    border-radius: 18px;
    background: rgba(255, 253, 247, .95);
    box-shadow: 0 12px 35px rgba(32, 62, 56, .13);
    backdrop-filter: blur(10px);
}

.trojice-turn span,
.trojice-time span {
    display: block;
    color: var(--to-muted);
    font-size: .72rem;
    letter-spacing: .05em;
    text-transform: uppercase;
}

.trojice-turn strong,
.trojice-time strong {
    display: block;
    margin-top: 2px;
}

.trojice-score {
    display: flex;
    justify-content: center;
    gap: 8px;
    color: var(--to-muted);
    font-size: .92rem;
}

.trojice-score strong {
    color: var(--to-ink);
}

.trojice-small-button {
    padding: 9px 11px;
    border: 1px solid var(--to-line);
    border-radius: 11px;
    color: var(--to-ink);
    background: #fff;
    font: inherit;
    font-size: .82rem;
    font-weight: 700;
    cursor: pointer;
}

.trojice-announcement {
    min-height: 26px;
    margin: 18px 0 14px;
    color: var(--to-green);
    text-align: center;
    font-weight: 800;
}

.trojice-board {
    display: grid;
    grid-template-columns: repeat(var(--board-columns, 6), minmax(0, 1fr));
    gap: clamp(6px, 1.2vw, 14px);
}

.trojice-card-button {
    position: relative;
    width: 100%;
    padding: 0;
    border: 0;
    border-radius: clamp(8px, 1.3vw, 14px);
    background: transparent;
    perspective: 1000px;
    cursor: pointer;
}

.trojice-card-button[disabled] {
    cursor: default;
}

.trojice-card-inner {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: 2 / 3;
    transform-style: preserve-3d;
    transition: transform .46s cubic-bezier(.2, .7, .25, 1);
}

.trojice-card-button.is-flipped .trojice-card-inner,
.trojice-card-button.is-matched .trojice-card-inner {
    transform: rotateY(180deg);
}

.trojice-card-face {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: clamp(8px, 1.3vw, 14px);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    box-shadow: 0 7px 20px rgba(37, 67, 61, .15);
}

.trojice-card-back {
    align-items: center;
    justify-content: center;
    border: clamp(3px, .45vw, 6px) solid #ead7aa;
    color: #f4d58d;
    background:
        radial-gradient(circle, rgba(250, 222, 155, .24) 0 3%, transparent 4% 100%),
        linear-gradient(145deg, #245f55, #173e39);
    background-size: 23px 23px, auto;
}

.trojice-card-back::before {
    content: "✦";
    display: grid;
    width: 48%;
    aspect-ratio: 1;
    place-items: center;
    border: 1px solid rgba(244, 213, 141, .72);
    border-radius: 50%;
    background: rgba(255, 255, 255, .05);
    font-size: clamp(1.2rem, 3vw, 3rem);
    box-shadow: 0 0 0 8px rgba(244, 213, 141, .08);
}

.trojice-card-front {
    transform: rotateY(180deg);
    border: 3px solid #fff;
    background: #fff;
}

.trojice-card-front img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.trojice-card-label {
    position: absolute;
    inset: auto 5px 5px;
    padding: clamp(4px, .65vw, 8px);
    border-radius: 7px;
    color: #fff;
    background: rgba(23, 57, 52, .86);
    font-size: clamp(.56rem, .95vw, .82rem);
    font-weight: 800;
    line-height: 1.12;
    text-align: center;
    backdrop-filter: blur(3px);
}

.trojice-card-button.is-matched {
    animation: trojice-found .58s ease;
}

.trojice-card-button.is-matched .trojice-card-face {
    box-shadow: 0 0 0 3px #e5be68, 0 8px 25px rgba(56, 102, 92, .22);
}

@keyframes trojice-found {
    0%, 100% { transform: scale(1); }
    45% { transform: scale(1.055); }
}

.trojice-finish {
    max-width: 920px;
    margin-right: auto;
    margin-left: auto;
    text-align: center;
}

.trojice-finish-symbol {
    margin: 0;
    color: var(--to-gold);
    font-size: 3rem;
}

.trojice-result {
    margin: 0 auto 30px;
    color: var(--to-muted);
    font-size: 1.08rem;
    line-height: 1.6;
}

.trojice-message-card {
    display: grid;
    grid-template-columns: minmax(250px, 42%) minmax(0, 1fr);
    align-items: center;
    gap: clamp(24px, 5vw, 48px);
    padding: clamp(22px, 4vw, 40px);
    border-radius: 23px;
    color: #fff;
    background: linear-gradient(135deg, #17443e, #2e786b);
    text-align: left;
    box-shadow: 0 22px 55px rgba(29, 75, 66, .2);
}

.trojice-message-card .eyebrow {
    color: #f4d58d;
}

.trojice-message-card h3 {
    margin: .1em 0 .38em;
    color: #fff;
    font-size: clamp(1.8rem, 4vw, 3rem);
}

.trojice-message-card p:last-child {
    margin: 0;
    color: rgba(255, 255, 255, .9);
    font-size: 1.05rem;
    line-height: 1.7;
}

.trojice-message-images {
    position: relative;
    min-height: 250px;
}

.trojice-message-images img {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 42%;
    aspect-ratio: 2 / 3;
    border: 3px solid #fff;
    border-radius: 10px;
    object-fit: cover;
    box-shadow: 0 14px 28px rgba(0, 0, 0, .26);
}

.trojice-message-images img:nth-child(1) {
    transform: translate(-104%, -50%) rotate(-9deg);
}

.trojice-message-images img:nth-child(2) {
    z-index: 2;
    transform: translate(-50%, -54%);
}

.trojice-message-images img:nth-child(3) {
    transform: translate(4%, -50%) rotate(9deg);
}

.trojice-finish-actions {
    justify-content: center;
}

.trojice-daily-note {
    margin: 18px 0 0;
    color: var(--to-muted);
    font-size: .86rem;
}

.trojice-unlock {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 32px;
    border-color: rgba(182, 122, 44, .28);
    background:
        radial-gradient(circle at right top, rgba(245, 208, 128, .2), transparent 22rem),
        #fffdf7;
}

.trojice-unlock p:last-child {
    max-width: 730px;
    margin-bottom: 0;
}

@media (max-width: 900px) {
    .trojice-hero {
        grid-template-columns: 1fr;
        padding-bottom: 20px;
    }

    .trojice-hero-cards {
        min-height: 235px;
    }

    .trojice-hero-card {
        right: 33%;
        width: 145px;
    }

    .trojice-choice-grid {
        grid-template-columns: 1fr;
    }

    .trojice-choice {
        min-height: auto;
    }

    .trojice-study-group {
        grid-template-columns: 1fr;
    }

    .trojice-study-heading {
        display: grid;
        grid-template-columns: auto 1fr;
        gap: 0 10px;
    }

    .trojice-study-heading span {
        grid-row: 1 / span 2;
    }

    .trojice-study-heading p {
        grid-column: 1 / -1;
        margin-top: 6px;
    }

    .trojice-gamebar {
        grid-template-columns: 1fr 1fr 1fr;
    }

    .trojice-score {
        order: 4;
        grid-column: 1 / -1;
    }

    .trojice-gamebar .trojice-small-button {
        order: 5;
    }

    .trojice-message-card {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .trojice-message-images {
        min-height: 230px;
    }
}

@media (max-width: 640px) {
    .trojice-app {
        width: min(100% - 18px, 1240px);
        padding-top: 15px;
    }

    .trojice-hero {
        min-height: 0;
        padding: 28px 21px 12px;
        border-radius: 22px;
    }

    .trojice-hero h1 {
        font-size: clamp(2.65rem, 15vw, 4.4rem);
    }

    .trojice-hero-cards {
        min-height: 205px;
    }

    .trojice-hero-card {
        right: 31%;
        width: 122px;
    }

    .trojice-panel,
    .trojice-unlock {
        padding: 21px 15px;
        border-radius: 20px;
    }

    .trojice-start-row,
    .trojice-finish-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .trojice-main-button {
        width: 100%;
    }

    .trojice-start-row p {
        text-align: center;
    }

    .trojice-study-group {
        gap: 16px;
        padding: 14px;
    }

    .trojice-study-cards {
        gap: 6px;
    }

    .trojice-study-card strong {
        font-size: .72rem;
    }

    .trojice-study-card small {
        display: none;
    }

    .trojice-sticky-actions {
        gap: 8px;
        bottom: 7px;
    }

    .trojice-sticky-actions .btn {
        flex: 1;
        min-width: 0;
        padding-right: 10px;
        padding-left: 10px;
    }

    .trojice-gamebar {
        top: 5px;
        gap: 7px;
        padding: 10px;
        border-radius: 14px;
    }

    .trojice-gamebar .trojice-small-button {
        font-size: .72rem;
    }

    .trojice-announcement {
        margin: 13px 0 10px;
        font-size: .9rem;
    }

    .trojice-board {
        grid-template-columns: repeat(var(--mobile-board-columns, 3), minmax(0, 1fr));
        gap: 5px;
    }

    .trojice-card-front {
        border-width: 2px;
    }

    .trojice-card-label {
        inset: auto 3px 3px;
        padding: 4px 2px;
        font-size: .56rem;
    }

    .trojice-message-card {
        padding: 22px 14px 28px;
    }

    .trojice-message-images {
        min-height: 190px;
    }

    .trojice-unlock {
        align-items: stretch;
        flex-direction: column;
    }
}

@media (prefers-reduced-motion: reduce) {
    .trojice-choice,
    .trojice-card-inner,
    .trojice-card-button.is-matched {
        transition: none;
        animation: none;
    }
}
