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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #121212;
    color: #e0e0e0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

.notification {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    transform: translateY(-120%);
    background: rgba(231, 76, 60, 0.95);
    color: #fff;
    padding: 0.65rem 1.2rem;
    border-radius: 999px;
    font-size: 0.95rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.3s ease, opacity 0.3s ease;
    z-index: 1100;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.notification.is-visible {
    transform: translateY(0);
    opacity: 1;
}

body.result-active .game-container {
    filter: blur(4px);
}

.container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    padding: 1rem;
    width: 100%;
}

.game-container {
    transition: opacity 0.4s ease;
}

.game-hidden {
    opacity: 0;
    pointer-events: none;
}

h1 {
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 600;
    letter-spacing: 0.25em;
    text-align: center;
    text-transform: uppercase;
    color: #f5f5f5;
    position: relative;
    padding-bottom: 0.5rem;
}

h1::after {
    content: '';
    display: block;
    margin: 0.5rem auto 0;
    width: clamp(80px, 28vw, 200px);
    height: 2px;
    background: rgba(245, 245, 245, 0.35);
    border-radius: 999px;
}

.game-board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    width: min(90vw, 500px);
    aspect-ratio: 1;
    border: 2px solid #444;
    border-radius: 12px;
    overflow: hidden;
    background: #2d2d2d;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.move-controls {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    padding: 0.5rem;
    z-index: 500;
}

.move-button {
    border: 1px solid rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.08);
    color: #f5f5f5;
    border-radius: 999px;
    padding: 0.65rem 1.5rem;
    text-transform: uppercase;
    letter-spacing: 0.25em;
    font-weight: 600;
    cursor: pointer;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
    transition: transform 0.2s ease, background 0.2s ease, opacity 0.2s ease;
}

.move-button:not(:disabled):hover {
    transform: translateY(-2px);
    background: rgba(255, 255, 255, 0.18);
}

.move-button:not(:disabled):active {
    transform: translateY(0);
}

.move-button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    box-shadow: none;
}

.square {
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1;
    position: relative;
    transition: background-color 0.25s ease, box-shadow 0.25s ease;
}

.square.last-move-from,
.square.last-move-to {
    position: relative;
    isolation: isolate;
}

.square.last-move-from::before,
.square.last-move-to::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 4px;
    background: rgba(118, 190, 255, 0.12);
    border: 2px solid rgba(118, 190, 255, 0.25);
    pointer-events: none;
    z-index: 2;
    animation: lastMoveGlow 0.55s ease-out;
}

.square.last-move-from::before {
    background: rgba(118, 190, 255, 0.08);
    border-color: rgba(118, 190, 255, 0.18);
}

.square.last-move-to::before {
    background: rgba(110, 231, 183, 0.2);
    border-color: rgba(110, 231, 183, 0.6);
    box-shadow: 0 0 28px rgba(110, 231, 183, 0.35);
}

@keyframes lastMoveGlow {
    0% {
        opacity: 0;
        transform: scale(0.8);
    }
    60% {
        opacity: 1;
        transform: scale(1.05);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.square.force-move::before,
.square.force-move::after {
    content: '';
    position: absolute;
    width: 80%;
    height: 80%;
    border-radius: 18px;
    pointer-events: none;
}

.square.force-move::before {
    border: 2px dashed rgba(255, 255, 255, 0.45);
    animation: forceOrbit 1s ease-in-out infinite;
}

.square.force-move::after {
    border: 2px solid rgba(255, 255, 255, 0.15);
    animation: forceOrbitReverse 1.2s linear infinite;
}

.square.highlight-move::after {
    content: '';
    position: absolute;
    width: 26%;
    height: 26%;
    border-radius: 50%;
    background: rgba(236, 240, 241, 0.65);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.square.light {
    background: #4a5568;
}

.square.dark {
    background: #2d3748;
}

.square img {
    width: 70%;
    height: 70%;
    object-fit: cover;
    border-radius: 50%;
    image-rendering: pixelated;
}

.piece {
    width: 70%;
    height: 70%;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #fff;
    cursor: grab;
    user-select: none;
    position: relative;
    transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.2s ease;
    will-change: transform;
}

.piece-moving {
    box-shadow: 0 18px 28px rgba(0, 0, 0, 0.45);
}


.piece img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
    image-rendering: pixelated;
}


.piece:active {
    cursor: grabbing;
}

.piece.selected {
    outline: 3px solid rgba(255,255,255,0.6);
    outline-offset: 2px;
}

.piece.highlight-capture::after {
    content: '';
    position: absolute;
    width: 45%;
    height: 45%;
    border-radius: 50%;
    background: rgba(231, 76, 60, 0.9);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 8px rgba(231, 76, 60, 0.75);
    pointer-events: none;
}

.result-overlay {
    position: fixed;
    inset: 0;
    background: rgba(5, 5, 5, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    z-index: 1000;
    transition: opacity 0.35s ease;
}

.result-overlay.is-hidden {
    opacity: 0;
    pointer-events: none;
}

.result-dialog {
    width: min(420px, 90vw);
    background: #161616;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 22px;
    padding: 2rem;
    box-shadow: 0 25px 90px rgba(0, 0, 0, 0.65);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    text-align: center;
}

.result-eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.4em;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.45);
}

.result-dialog h2 {
    font-size: clamp(1.9rem, 6vw, 2.7rem);
    font-weight: 700;
}

.result-copy,
.result-secondary {

    .difficulty-dialog {
        padding: 1.5rem;
    }
    color: rgba(255, 255, 255, 0.75);
    line-height: 1.6;
}

.result-secondary {
    letter-spacing: 0.25em;
    font-size: 0.85rem;
}

.result-button {
    margin-top: 0.5rem;
    border: none;
    background: #f5f5f5;
    color: #0f0f0f;
    padding: 0.85rem 1.5rem;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.result-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

/* I find myself to be rather proud of this */
.intro-overlay {
    position: fixed;
    inset: 0;
    background: #050505;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    z-index: 999;
    transition: opacity 0.35s ease;
}

.intro-overlay.is-hidden {
    opacity: 0;
    pointer-events: none;
}

.intro-dialog {
    width: min(480px, 90vw);
    background: #161616;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    padding: 2rem;
    box-shadow: 0 20px 80px rgba(0, 0, 0, 0.65);
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.intro-eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.4em;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.55);
}

.intro-dialog h2 {
    font-size: clamp(1.75rem, 5vw, 2.5rem);
    font-weight: 600;
}

.intro-copy {
    color: rgba(255, 255, 255, 0.65);
    line-height: 1.6;
}

.intro-rules {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    color: rgba(255, 255, 255, 0.85);
}

.intro-rules li {
    position: relative;
    padding-left: 1.5rem;
}

.intro-rules li::before {
    content: '';
    position: absolute;
    left: 0.2rem;
    top: 0.55rem;
    width: 0.35rem;
    height: 0.35rem;
    background: #f5f5f5;
    border-radius: 50%;
}

.intro-choice {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.1em;
}

.intro-buttons {
    display: flex;
    gap: 0.75rem;
}

.intro-buttons--compact {
    gap: 0.5rem;
}

.intro-buttons--compact .intro-button {
    padding: 0.75rem 1rem;
}

.intro-button {
    flex: 1;
    border: none;
    background: #111;
    color: #f5f5f5;
    padding: 0.85rem 1.5rem;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    font-weight: 600;
    position: relative;
    overflow: hidden;
    transition: transform 0.25s ease, color 0.25s ease, background 0.25s ease;
    cursor: pointer;
}

.intro-button::before,
.intro-button::after {
    content: '';
    position: absolute;
    inset: -20%;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    opacity: 0;
    transform: scale(0.8);
}

.intro-button::after {
    border-color: rgba(255, 255, 255, 0.35);
}

.intro-button:hover {
    background: #1c1c1c;
    transform: translateY(-2px);
}

.intro-button.is-active {
    background: #f5f5f5;
    color: #0f0f0f;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.3) inset;
}

/* im boutta ruin the players whole carrear */
/* says the man who can't spell... */
.friend-overlay {
    position: fixed;
    inset: 0;
    background: rgba(5, 5, 5, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    z-index: 1001;
    transition: opacity 0.35s ease;
}

.friend-overlay.is-hidden {
    opacity: 0;
    pointer-events: none;
}

.friend-dialog {
    width: min(360px, 90vw);
    background: #161616;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 18px;
    padding: 1.75rem;
    box-shadow: 0 20px 80px rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    text-align: center;
}

.friend-copy {
    color: rgba(255, 255, 255, 0.75);
    font-size: 1.1rem;
    line-height: 1.6;
}

.friend-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.friend-button {
    border: none;
    background: #f5f5f5;
    color: #0f0f0f;
    padding: 0.9rem 1.2rem;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.friend-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
}

.difficulty-overlay {
    position: fixed;
    inset: 0;
    background: rgba(5, 5, 5, 0.88);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    z-index: 1002;
    transition: opacity 0.35s ease;
    opacity: 1;
}

.difficulty-overlay.is-hidden {
    opacity: 0;
    pointer-events: none;
}

.difficulty-dialog {
    width: min(360px, 90vw);
    background: #151515;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 18px;
    padding: 1.75rem;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.65);
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    text-align: center;
}

.difficulty-eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.35em;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.55);
}

.difficulty-copy {
    color: rgba(255, 255, 255, 0.7);
    line-height: 1.5;
}

.difficulty-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.difficulty-button {
    border: none;
    background: #0f0f0f;
    color: #f5f5f5;
    padding: 0.85rem 1.2rem;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.difficulty-button:hover {
    transform: translateY(-1px);
    background: #1d1d1d;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.4);
}

.difficulty-button.is-active {
    background: #f5f5f5;
    color: #101010;
}

.intro-button.is-active:hover {
    background: #f5f5f5;
    color: #0f0f0f;
    transform: translateY(-1px);
}

.intro-button:hover::before,
.intro-button:hover::after {
    opacity: 1;
    animation: orbit 1.4s linear infinite;
}

.intro-button:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.4);
    outline-offset: 4px;
}

@keyframes orbit {
    0% {
        transform: rotate(0deg) scale(0.95);
    }
    50% {
        transform: rotate(180deg) scale(1.05);
    }
    100% {
        transform: rotate(360deg) scale(0.95);
    }
}

@keyframes forceOrbit {
    0% {
        transform: rotate(0deg) scale(0.9);
        opacity: 0.5;
    }
    50% {
        transform: rotate(180deg) scale(1.05);
        opacity: 1;
    }
    100% {
        transform: rotate(360deg) scale(0.9);
        opacity: 0.5;
    }
}

@keyframes forceOrbitReverse {
    0% {
        transform: rotate(0deg) scale(1.05);
        opacity: 0.35;
    }
    50% {
        transform: rotate(-180deg) scale(0.85);
        opacity: 0.8;
    }
    100% {
        transform: rotate(-360deg) scale(1.05);
        opacity: 0.35;
    }
}

@media (max-width: 600px) {
    .container {
        gap: 1rem;
    }

    .intro-dialog {
        padding: 1.5rem;
    }

    .intro-buttons {
        flex-direction: column;
    }
    .result-dialog {
        padding: 1.5rem;
    }

    .friend-dialog {
        padding: 1.5rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .piece {
        transition: none;
    }
}
