/* Embedding Tangram — FunSlop.com
   Drag word tiles on a 2D board so their distances satisfy semantic relations.
   Self-contained dark-neon styling, no shared theme stylesheet required. */

:root {
    --bg-dark: #090b10;
    --bg-board: #0b0d14;
    --neon-green: #39ff14;
    --neon-purple: #bd00ff;
    --cyan: #05d9e8;
    --pink: #ff2a6d;
    --gold: #ffd54a;
    --text-primary: #f0f4f8;
    --text-muted: #8b9bb4;
    --glass-border: rgba(255, 255, 255, 0.08);
    --font-body: 'Outfit', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-display: 'Space Grotesk', 'Outfit', system-ui, sans-serif;
    --radius-md: 14px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    min-height: 100%;
}

body {
    font-family: var(--font-body);
    color: var(--text-primary);
    background: var(--bg-dark);
    background-image:
        radial-gradient(circle at 15% 12%, rgba(189, 0, 255, 0.16), transparent 46%),
        radial-gradient(circle at 85% 88%, rgba(5, 217, 232, 0.14), transparent 48%),
        radial-gradient(circle at 50% 50%, rgba(57, 255, 20, 0.04), transparent 62%);
    background-attachment: fixed;
}

.game-container {
    position: relative;
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    user-select: none;
    -webkit-user-select: none;
}

.content {
    width: 100%;
    max-width: 560px;
    padding: 1.5rem 1.1rem 6rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* ---- header ---- */
.header-info {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    width: 100%;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.title {
    font-family: var(--font-display);
    font-size: 1.85rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(45deg, var(--cyan), var(--neon-purple));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.level-display {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 500;
    color: var(--neon-purple);
    text-shadow: 0 0 12px rgba(189, 0, 255, 0.55);
    white-space: nowrap;
}

.prompt {
    width: 100%;
    font-size: 1rem;
    line-height: 1.45;
    color: var(--text-muted);
    margin-bottom: 1rem;
    min-height: 1.4em;
}

/* ---- board ---- */
.board-wrapper {
    width: min(92vw, 440px);
    aspect-ratio: 1;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid rgba(5, 217, 232, 0.28);
    box-shadow:
        0 0 28px rgba(189, 0, 255, 0.22),
        inset 0 0 20px rgba(5, 217, 232, 0.10);
}

#board {
    display: block;
    width: 100%;
    height: 100%;
    background: var(--bg-board);
    touch-action: none;
    cursor: grab;
}

#board:active {
    cursor: grabbing;
}

/* ---- constraint checklist ---- */
.constraints {
    list-style: none;
    width: 100%;
    margin: 1rem 0 0.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.constraint {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.55rem 0.85rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
    font-size: 0.98rem;
    transition: border-color 0.2s, background 0.2s, color 0.2s;
}

.constraint .check {
    flex: 0 0 1.4rem;
    width: 1.4rem;
    height: 1.4rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 1px solid rgba(139, 155, 180, 0.4);
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-muted);
    transition: all 0.2s;
}

.constraint .rel-text { line-height: 1.3; }

.constraint .rel {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.8rem;
    letter-spacing: 0.5px;
    padding: 0.05rem 0.4rem;
    border-radius: 6px;
}

.rel-near { color: var(--neon-green); background: rgba(57, 255, 20, 0.10); }
.rel-far  { color: var(--pink);      background: rgba(255, 42, 109, 0.10); }
.rel-opp  { color: var(--neon-purple); background: rgba(189, 0, 255, 0.12); }

.constraint.satisfied {
    border-color: rgba(57, 255, 20, 0.55);
    background: rgba(57, 255, 20, 0.07);
    color: var(--text-primary);
}

.constraint.satisfied .check {
    border-color: var(--neon-green);
    background: var(--neon-green);
    color: #04130a;
    box-shadow: 0 0 12px rgba(57, 255, 20, 0.6);
}

.constraint.pop {
    animation: chk-pop 0.32s ease-out;
}

@keyframes chk-pop {
    0% { transform: scale(1); }
    45% { transform: scale(1.035); }
    100% { transform: scale(1); }
}

/* ---- result / best ---- */
.result-line {
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--neon-green);
    text-shadow: 0 0 14px rgba(57, 255, 20, 0.45);
    text-align: center;
    margin: 0.9rem 0 0.3rem;
    min-height: 1.3em;
}

.state-gameover .result-line {
    color: var(--gold);
    text-shadow: 0 0 16px rgba(255, 213, 74, 0.5);
}

.best-line {
    font-size: 0.95rem;
    color: var(--cyan);
    text-align: center;
    margin-bottom: 0.6rem;
    min-height: 1.2em;
}

/* ---- action button ---- */
.buttons {
    display: flex;
    justify-content: center;
    margin-top: 0.4rem;
}

.game-btn {
    font-family: var(--font-display);
    background: linear-gradient(135deg, var(--cyan), var(--neon-purple));
    color: #04101a;
    border: none;
    padding: 0.9rem 2.2rem;
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.3px;
    border-radius: 999px;
    cursor: pointer;
    box-shadow: 0 0 22px rgba(5, 217, 232, 0.32);
    transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

.game-btn:hover {
    transform: scale(1.04);
    filter: brightness(1.08);
    box-shadow: 0 0 32px rgba(189, 0, 255, 0.5);
}

.game-btn:active {
    transform: scale(0.97);
}

.game-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(5, 217, 232, 0.65);
}

/* ---- state-driven visibility ---- */
.state-playing .buttons { display: none; }

.state-idle .constraints,
.state-idle .result-line,
.state-idle .level-display { display: none; }

.state-gameover .constraints { display: none; }

/* fade in feedback on solve */
.state-solved .result-line,
.state-solved .buttons,
.state-gameover .result-line,
.state-gameover .buttons {
    animation: fadeIn 0.35s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* hide SEO sections during active play / feedback to keep focus */
.state-playing .how-to-play,
.state-playing .related-games,
.state-solved .how-to-play,
.state-solved .related-games,
.state-gameover .how-to-play,
.state-gameover .related-games {
    display: none;
}

/* ---- SEO / how-to content ---- */
.how-to-play {
    text-align: left;
    margin: 2.25rem auto 0;
    width: 100%;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 1.6rem;
}

.how-to-play h2 {
    font-family: var(--font-display);
    font-size: 1.35rem;
    margin-bottom: 0.7rem;
    color: var(--text-primary);
}

.how-to-play h3 {
    font-family: var(--font-display);
    font-size: 1.05rem;
    margin: 1.2rem 0 0.4rem;
    color: var(--cyan);
}

.how-to-play p {
    font-weight: 300;
    line-height: 1.6;
    color: var(--text-muted);
    margin-bottom: 0.7rem;
}

.how-to-play strong { color: var(--text-primary); font-weight: 500; }
.how-to-play em { color: var(--neon-green); font-style: normal; }

.how-to-play ol {
    margin: 0.5rem 0 0.75rem 1.25rem;
    color: var(--text-muted);
    line-height: 1.7;
}

.fun-fact {
    margin-top: 1.2rem;
    padding: 1rem;
    border-left: 3px solid var(--neon-purple);
    background: rgba(189, 0, 255, 0.06);
    border-radius: 0 10px 10px 0;
}

.fun-fact p { margin: 0; }
.fun-fact strong { color: var(--neon-purple); }

/* ---- related games ---- */
.related-games {
    margin: 1.75rem auto 0;
    width: 100%;
    text-align: center;
}

.related-games h3 {
    font-family: var(--font-display);
    font-size: 1.05rem;
    margin-bottom: 0.7rem;
    color: var(--text-muted);
}

.related-games-list {
    display: flex;
    gap: 0.6rem;
    justify-content: center;
    flex-wrap: wrap;
}

.related-game-link {
    text-decoration: none;
    color: var(--text-primary);
    background: rgba(5, 217, 232, 0.06);
    border: 1px solid rgba(5, 217, 232, 0.22);
    border-radius: 999px;
    padding: 0.45rem 1rem;
    font-size: 0.9rem;
    transition: border-color 0.2s, color 0.2s, box-shadow 0.2s;
}

.related-game-link:hover {
    border-color: var(--cyan);
    color: var(--cyan);
    box-shadow: 0 0 16px rgba(5, 217, 232, 0.3);
}

/* ---- home link ---- */
.home-link {
    position: fixed;
    bottom: 1.1rem;
    bottom: calc(1.1rem + env(safe-area-inset-bottom, 0px));
    left: 50%;
    transform: translateX(-50%);
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.9rem;
    padding: 0.5rem 1.1rem;
    background: rgba(11, 13, 20, 0.85);
    border: 1px solid var(--glass-border);
    border-radius: 999px;
    backdrop-filter: blur(8px);
    transition: border-color 0.2s, color 0.2s, box-shadow 0.2s;
    z-index: 50;
}

.home-link:hover {
    border-color: var(--neon-purple);
    color: var(--neon-purple);
    box-shadow: 0 0 18px rgba(189, 0, 255, 0.3);
}

.home-link:active {
    transform: translateX(-50%) scale(0.96);
}

.home-link:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(5, 217, 232, 0.65);
}

/* ---- responsive ---- */
@media (max-width: 600px) {
    .title { font-size: 1.5rem; }
    .level-display { font-size: 0.9rem; }
    .prompt { font-size: 0.92rem; }
    .constraint { font-size: 0.9rem; padding: 0.5rem 0.7rem; }
    .result-line { font-size: 1.05rem; }
    .game-btn { padding: 0.8rem 1.7rem; font-size: 1rem; }
}

@media (max-width: 360px) {
    .header-info { flex-direction: column; gap: 0.1rem; align-items: flex-start; }
}
