/*
 * Othello's isolated visual system: the site's glass panels frame a felt table,
 * and the board scales down for larger grids while remaining horizontally
 * scrollable when a truly huge board would make phone squares too small.
 */
.othello-page {
    display: grid;
    gap: 1rem;
    padding-block: 1.2rem 3rem;
}

.othello-intro,
.othello-setup,
.othello-online-panel,
.othello-game,
.othello-help {
    border-radius: 1.35rem;
    padding: clamp(1rem, 3vw, 1.6rem);
}

.othello-intro,
.othello-section-heading,
.othello-game-topline,
.othello-board-tools,
.othello-game-bottomline,
.othello-setup-actions,
.othello-key-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.othello-intro h1,
.othello-section-heading h2,
.othello-game-topline h2 {
    margin: 0;
}

.othello-intro p:not(.eyebrow) {
    max-width: 48rem;
    margin: .45rem 0 0;
    color: var(--muted-strong);
}

.othello-section-heading {
    margin-bottom: 1.1rem;
}

.othello-section-heading .eyebrow,
.othello-game-topline .eyebrow {
    margin: 0 0 .2rem;
}

.othello-default-badge {
    padding: .45rem .75rem;
    border: 1px solid rgba(154, 156, 255, .35);
    border-radius: 999px;
    background: rgba(109, 106, 247, .13);
    color: #d8d9ff;
    font-size: .84rem;
    white-space: nowrap;
}

.othello-settings-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: .9rem;
}

.othello-field {
    display: grid;
    gap: .35rem;
    color: var(--muted-strong);
    font-weight: 700;
}

.othello-field select,
.othello-field input,
.othello-zoom-control select {
    width: 100%;
    min-height: 2.85rem;
    padding: .55rem .75rem;
    border: 1px solid rgba(220, 231, 247, .2);
    border-radius: .75rem;
    color: var(--ink);
    background: rgba(5, 11, 19, .68);
    font: inherit;
}

.othello-field option,
.othello-zoom-control option {
    color: #f5f8fc;
    background: #101827;
}

.othello-field input {
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: .9rem;
    overflow-wrap: anywhere;
}

.othello-color-preview {
    display: flex;
    align-items: center;
    gap: .7rem;
    min-height: 3.1rem;
    margin-top: 1rem;
    padding: .55rem .75rem;
    border: 1px solid rgba(255, 255, 255, .1);
    border-radius: .9rem;
    background: rgba(4, 8, 15, .28);
}

.othello-preview-side {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    color: var(--muted);
    font-size: .85rem;
    white-space: nowrap;
}

.othello-preview-disc {
    width: 1.55rem;
    height: 1.55rem;
    border: 3px solid rgba(255, 255, 255, .45);
    border-radius: 50%;
    box-shadow: 0 2px 5px rgba(0, 0, 0, .35);
}

.othello-preview-versus,
.othello-color-preview [data-preview-felt-label] {
    color: var(--muted);
    font-size: .85rem;
}

.othello-preview-felt {
    width: 1.4rem;
    height: 1.4rem;
    margin-left: auto;
    border: 1px solid rgba(255, 255, 255, .35);
    border-radius: .35rem;
}

.othello-setup-hint,
.othello-private-note {
    margin: .85rem 0;
    color: var(--muted);
    font-size: .92rem;
}

.othello-setup-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
}

.othello-setup-actions [data-login-hint] {
    color: var(--muted);
    font-size: .9rem;
}

.othello-setup-actions a {
    color: var(--copper-soft);
}

.othello-online-panel > p {
    color: var(--muted-strong);
}

.othello-key-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
    margin-top: .8rem;
}

.othello-game-topline {
    align-items: flex-start;
    flex-wrap: wrap;
}

.othello-scoreboard {
    display: flex;
    gap: .6rem;
}

.othello-score-card {
    min-width: 5.5rem;
    padding: .45rem .7rem;
    border: 1px solid rgba(255, 255, 255, .14);
    border-radius: .85rem;
    background: rgba(4, 8, 15, .3);
    text-align: center;
}

.othello-score-card strong,
.othello-score-card small {
    display: block;
}

.othello-score-card strong {
    font-size: 1.35rem;
    line-height: 1.15;
}

.othello-score-card small {
    color: var(--muted);
    font-size: .72rem;
}

.othello-last-move {
    min-height: 1.5rem;
    margin: .65rem 0;
    color: var(--copper-soft);
}

.othello-board-tools {
    margin-bottom: .65rem;
    color: var(--muted-strong);
    flex-wrap: wrap;
}

.othello-move-hint-toggle {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    color: var(--muted);
    font-size: .84rem;
    white-space: nowrap;
}

.othello-move-hint-toggle input {
    width: 1.05rem;
    height: 1.05rem;
    margin: 0;
    accent-color: #8f85ff;
}

.othello-zoom-control {
    display: flex;
    align-items: center;
    gap: .5rem;
    color: var(--muted);
    font-size: .84rem;
}

.othello-zoom-control select {
    width: auto;
    min-height: 2.3rem;
    padding: .25rem .5rem;
}

.othello-board-scroll {
    max-width: 100%;
    overflow: auto;
    padding: 1.5rem .7rem .7rem;
    border: 1px solid rgba(255, 255, 255, .13);
    border-radius: 1.2rem;
    background: rgba(0, 0, 0, .25);
    overscroll-behavior: contain;
    scrollbar-color: rgba(226, 164, 108, .52) rgba(0, 0, 0, .2);
}

.othello-board {
    --board-size: 8;
    --cell-size: clamp(18px, calc(90vw / var(--board-size)), 68px);
    display: grid;
    grid-template-columns: repeat(var(--board-size), var(--cell-size));
    grid-template-rows: repeat(var(--board-size), var(--cell-size));
    gap: 1px;
    width: max-content;
    margin-inline: auto;
    padding: 3px;
    border: 2px solid rgba(226, 164, 108, .56);
    border-radius: .6rem;
    background: var(--felt-base, #25224d);
    box-shadow: 0 12px 30px rgba(0, 0, 0, .34), inset 0 0 0 1px rgba(255, 255, 255, .07);
    transform: scale(var(--board-zoom, 1));
    transform-origin: top center;
}

.othello-board-scroll[data-zoomed="true"] {
    padding-block-end: 3rem;
}

.othello-square {
    position: relative;
    display: grid;
    place-items: center;
    min-width: 0;
    min-height: 0;
    padding: 0;
    overflow: visible;
    border: 0;
    border-radius: 1px;
    background: color-mix(in srgb, var(--felt-base, #25224d) 86%, white 14%);
    cursor: default;
    touch-action: manipulation;
}

.othello-square:nth-child(2n) {
    background: color-mix(in srgb, var(--felt-base, #25224d) 94%, black 6%);
}

.othello-square.is-legal {
    cursor: pointer;
}

.othello-square.is-legal::before {
    position: absolute;
    z-index: 0;
    width: 22%;
    height: 22%;
    border: 1px solid rgba(255, 255, 255, .76);
    border-radius: 50%;
    background: rgba(255, 255, 255, .25);
    content: "";
    box-shadow: 0 0 7px rgba(255, 255, 255, .42);
}

.othello-square.is-legal:hover,
.othello-square.is-legal:focus-visible {
    outline: 2px solid rgba(255, 255, 255, .85);
    outline-offset: -2px;
}

.othello-disc {
    position: relative;
    z-index: 1;
    width: 86%;
    height: 86%;
    border-radius: 50%;
    -webkit-transform-style: preserve-3d;
    transform-style: preserve-3d;
    transform: translateY(-2px) rotateY(0deg);
    /* A filter on this 3D parent flattens its faces in Safari and can make
       every chip show the same side. The face shadows provide depth instead. */
}

.othello-disc.is-player-two {
    transform: translateY(-2px) rotateY(180deg);
}

.othello-disc-face {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    overflow: hidden;
    border: 2px solid var(--other-color, #f3f1e7);
    border-radius: 50%;
    background: var(--disc-color, #17191e);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    box-shadow: 0 3px 3px rgba(0, 0, 0, .4), inset 0 2px 4px rgba(255, 255, 255, .2), inset 0 -4px 7px rgba(0, 0, 0, .3);
}

.othello-disc-face.back {
    transform: rotateY(180deg);
    background: var(--other-color, #f3f1e7);
    border-color: var(--disc-color, #17191e);
}

.othello-disc-face::after {
    content: "";
    display: block;
    width: 54%;
    height: 54%;
    background-image: var(--elh-disc-logo);
    background-position: center;
    background-repeat: no-repeat;
    background-size: contain;
    opacity: .33;
    filter: grayscale(1) brightness(1.75) contrast(.88);
    mix-blend-mode: screen;
    pointer-events: none;
}

.othello-disc-face.back::after {
    filter: grayscale(1) brightness(.35) contrast(1.1);
    mix-blend-mode: multiply;
}

.othello-disc.is-new {
    animation: othello-drop .4s cubic-bezier(.15, .76, .3, 1.18) both;
}

/* Player two's face is the reverse side of the double-sided disc. Keep the
   180-degree orientation throughout the drop animation; otherwise the generic
   drop transform overrides the base rotation and briefly shows player one's
   color until the next board render. */
.othello-disc.is-player-two.is-new {
    animation-name: othello-drop-player-two;
}

.othello-disc.flip-from-one {
    animation: othello-flip-forward .6s cubic-bezier(.2, .75, .22, 1) both;
}

.othello-disc.flip-from-two {
    animation: othello-flip-back .6s cubic-bezier(.2, .75, .22, 1) both;
}

@keyframes othello-drop {
    0% { transform: translateY(-23px) scale(.68); opacity: .15; }
    62% { transform: translateY(2px) scale(1.07); opacity: 1; }
    100% { transform: translateY(-2px) scale(1); opacity: 1; }
}

@keyframes othello-drop-player-two {
    0% { transform: translateY(-23px) scale(.68) rotateY(180deg); opacity: .15; }
    62% { transform: translateY(2px) scale(1.07) rotateY(180deg); opacity: 1; }
    100% { transform: translateY(-2px) rotateY(180deg); opacity: 1; }
}

@keyframes othello-flip-forward {
    0% { transform: translateY(-2px) rotateY(0); }
    42% { transform: translateY(-15px) rotateY(90deg); }
    100% { transform: translateY(-2px) rotateY(180deg); }
}

@keyframes othello-flip-back {
    0% { transform: translateY(-2px) rotateY(180deg); }
    42% { transform: translateY(-15px) rotateY(270deg); }
    100% { transform: translateY(-2px) rotateY(360deg); }
}

.othello-game-bottomline {
    margin-top: .75rem;
    color: var(--muted);
    font-size: .88rem;
}

.othello-move-log {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem .7rem;
    max-height: 8rem;
    margin: .85rem 0 0;
    padding: .7rem .9rem .7rem 2rem;
    overflow: auto;
    border-radius: .75rem;
    background: rgba(3, 7, 13, .28);
    color: var(--muted);
    font-size: .82rem;
}

.othello-move-log:empty {
    display: none;
}

.othello-help summary {
    cursor: pointer;
    color: var(--copper-soft);
    font-weight: 800;
}

.othello-help p {
    max-width: 70rem;
    color: var(--muted-strong);
}

.othello-page [hidden] {
    display: none !important;
}

@media (max-width: 700px) {
    .othello-intro,
    .othello-section-heading,
    .othello-game-topline,
    .othello-game-bottomline {
        align-items: flex-start;
        flex-direction: column;
    }

    .othello-settings-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .othello-default-badge {
        white-space: normal;
    }

    .othello-board-tools {
        align-items: flex-start;
    }

    .othello-scoreboard {
        width: 100%;
    }

    .othello-score-card {
        flex: 1;
    }
}

@media (max-width: 420px) {
    .othello-settings-grid {
        grid-template-columns: 1fr;
    }

    .othello-color-preview {
        flex-wrap: wrap;
    }
}

@media (prefers-reduced-motion: reduce) {
    .othello-disc,
    .othello-disc.is-new,
    .othello-disc.flip-from-one,
    .othello-disc.flip-from-two {
        animation-duration: .01ms !important;
    }
}
