/* PlayPal — vanilla CSS, light + dark, mobile-first */

:root {
    --bg: #f3efe6;
    --bg-accent: #e7f3ef;
    --surface: #fffaf3;
    --surface-2: #eee8dc;
    --text: #1c1a16;
    --muted: #6b6458;
    --line: rgba(28, 26, 22, 0.12);
    --primary: #4b3fd6;
    --primary-2: #2f7d72;
    --primary-text: #fffaf3;
    --danger: #b4232a;
    --shadow: 0 18px 40px rgba(47, 36, 18, 0.1);
    --radius: 18px;
    --font: "Segoe UI", "Candara", "Gill Sans", system-ui, sans-serif;
    --mono: "Cascadia Mono", "Consolas", monospace;
    --topbar: 56px;
    --tabbar: 62px;
    --tabbar-gap: 16px;
    --p1: #efc453;
    --p2: #d3544a;
}

[data-theme="dark"] {
    --bg: #12141c;
    --bg-accent: #1a2430;
    --surface: #1c2030;
    --surface-2: #262b3e;
    --text: #f2eee6;
    --muted: #a8a093;
    --line: rgba(242, 238, 230, 0.12);
    --primary: #8b83ff;
    --primary-2: #3ecfba;
    --primary-text: #12141c;
    --danger: #ff6b6b;
    --shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    font-family: var(--font);
    background:
        radial-gradient(1200px 500px at 10% -10%, var(--bg-accent), transparent 50%),
        var(--bg);
    color: var(--text);
    line-height: 1.5;
}

img {
    max-width: 100%;
    display: block;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

h1,
h2,
h3 {
    margin: 0 0 0.4em;
    letter-spacing: -0.03em;
    line-height: 1.15;
}

p {
    margin: 0 0 0.8em;
}

button,
input,
select,
textarea {
    font: inherit;
    color: inherit;
}

.page {
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto;
    padding: 28px 0 64px;
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    padding-bottom: calc(var(--tabbar) + var(--tabbar-gap) + 28px + env(safe-area-inset-bottom));
}

.page-head {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-end;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.page-head-actions {
    display: flex;
    gap: 10px;
}

.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-size: 0.72rem;
    color: var(--primary-2);
    margin-bottom: 4px;
    font-weight: 700;
}

.lede,
.muted,
.hint,
.optional {
    color: var(--muted);
}

.hint,
.optional {
    font-size: 0.85rem;
}

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
}

.stack {
    display: grid;
    gap: 16px;
}

.field {
    display: grid;
    gap: 6px;
}

.field input,
.field select,
.field textarea,
.composer input,
.inline-form input {
    width: 100%;
    border: 1px solid var(--line);
    background: var(--surface-2);
    border-radius: 12px;
    padding: 10px 12px;
    outline: none;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.composer input:focus,
.inline-form input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 25%, transparent);
}

.form-error {
    color: var(--danger);
    margin: 0;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 0;
    border-radius: 999px;
    padding: 10px 16px;
    font-weight: 650;
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}

.btn:hover {
    transform: translateY(-1px);
    text-decoration: none;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    background: var(--primary);
    color: var(--primary-text);
}

.btn-secondary {
    background: var(--primary-2);
    color: #071513;
}

.btn-ghost {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--line);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.9rem;
}

.btn-block {
    width: 100%;
}

.app-shell {
    min-height: 100vh;
    min-height: 100dvh;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    min-height: var(--topbar);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 20px;
    padding-top: env(safe-area-inset-top);
    padding-left: max(20px, env(safe-area-inset-left));
    padding-right: max(20px, env(safe-area-inset-right));
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--line);
}

.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
    font-weight: 800;
    letter-spacing: -0.04em;
    font-size: 1.2rem;
}

.brand:hover {
    text-decoration: none;
}

.nav {
    display: flex;
    gap: 6px;
}

.nav a {
    color: var(--muted);
    padding: 8px 12px;
    border-radius: 999px;
    font-weight: 650;
}

.nav a.is-active,
.nav a:hover {
    color: var(--text);
    background: var(--surface-2);
    text-decoration: none;
}

.topbar-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
}

.tabbar {
    position: fixed;
    left: 50%;
    bottom: calc(var(--tabbar-gap) + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    z-index: 80;
    display: flex;
    align-items: stretch;
    justify-content: space-around;
    gap: 2px;
    width: min(440px, calc(100% - 28px));
    min-height: var(--tabbar);
    padding: 7px 8px;
    border-radius: 28px;
    background: color-mix(in srgb, var(--surface) 62%, transparent);
    backdrop-filter: saturate(190%) blur(28px);
    -webkit-backdrop-filter: saturate(190%) blur(28px);
    border: 1px solid color-mix(in srgb, #ffffff 58%, var(--line));
    box-shadow:
        0 22px 48px rgba(20, 16, 10, 0.28),
        0 4px 14px rgba(20, 16, 10, 0.14),
        inset 0 1px 0 rgba(255, 255, 255, 0.55);
    pointer-events: auto;
    isolation: isolate;
}

[data-theme="dark"] .tabbar {
    background: color-mix(in srgb, #161a28 58%, transparent);
    border-color: rgba(255, 255, 255, 0.14);
    box-shadow:
        0 22px 48px rgba(0, 0, 0, 0.5),
        0 4px 14px rgba(0, 0, 0, 0.32),
        inset 0 1px 0 rgba(255, 255, 255, 0.14);
}

.tabbar-item {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 8px 6px 6px;
    border-radius: 22px;
    color: var(--muted);
    text-decoration: none;
    font-size: 10px;
    font-weight: 650;
    letter-spacing: 0.01em;
    line-height: 1;
    -webkit-tap-highlight-color: transparent;
}

.tabbar-item:hover {
    text-decoration: none;
    color: var(--text);
}

.tabbar-item:active {
    transform: scale(0.94);
}

.tabbar-item.is-active {
    color: var(--primary);
    background: color-mix(in srgb, var(--primary) 16%, transparent);
}

.tabbar-item svg {
    width: 26px;
    height: 26px;
    fill: currentColor;
    stroke: none;
}

.tabbar-item svg .tabbar-glyph {
    fill: none;
    stroke: var(--surface);
    stroke-width: 1.7;
    stroke-linecap: round;
}

.tabbar-item svg circle.tabbar-glyph {
    fill: var(--surface);
    stroke: none;
}

.tabbar-item.is-active svg .tabbar-glyph {
    stroke: var(--primary-text);
}

.tabbar-item.is-active svg circle.tabbar-glyph {
    fill: var(--primary-text);
}

.tabbar-item svg.is-outline {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.tabbar-item span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav,
.nav-toggle,
.nav-backdrop {
    display: none !important;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
    font-weight: 650;
}

.user-chip img,
.person img,
.conversation-item img,
.thread-user img,
.avatar-wrap img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--surface-2);
}

.theme-toggle,
.nav-toggle {
    border: 1px solid var(--line);
    background: var(--surface);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
}

.theme-toggle-float {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 5;
}

.nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
}

.nav-toggle span {
    width: 16px;
    height: 2px;
    background: var(--text);
}

.nav-backdrop {
    display: none;
}

.auth-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.auth-wrap {
    width: min(420px, 100%);
}

.auth-brand {
    text-align: center;
    margin-bottom: 20px;
}

.auth-brand img {
    margin: 0 auto 8px;
}

.auth-switch {
    text-align: center;
    margin-top: 16px;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 20px;
}

.stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.stat-label {
    color: var(--muted);
    margin: 0;
}

.stat-value {
    font-size: 2rem;
    font-weight: 800;
    margin: 0;
    letter-spacing: -0.04em;
}

.inline-form,
.challenge-form,
.composer {
    display: flex;
    gap: 10px;
    align-items: end;
    flex-wrap: wrap;
}

.challenge-form .field {
    flex: 1 1 180px;
}

.inline-form input,
.composer input {
    flex: 1;
}

.list {
    display: grid;
    gap: 10px;
    margin-top: 12px;
}

.list-row,
.person,
.conversation-item,
.game-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.person {
    width: 100%;
}

.person-meta {
    flex: 1;
    min-width: 0;
}

.person-meta strong,
.conversation-item strong {
    display: flex;
    align-items: center;
    gap: 6px;
}

.row-actions {
    display: flex;
    gap: 6px;
    margin-left: auto;
    flex-shrink: 0;
}

.pill,
.badge {
    border-radius: 999px;
    padding: 2px 8px;
    font-size: 0.75rem;
    font-weight: 700;
    background: var(--surface-2);
}

.badge {
    background: var(--primary);
    color: var(--primary-text);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    background: #9a9388;
}

.status-dot.status-online {
    background: #2f9e62;
}

.status-dot.status-ingame {
    background: var(--primary);
}

.profile-hero {
    display: flex;
    gap: 20px;
    align-items: center;
    margin-bottom: 20px;
}

.avatar-wrap {
    position: relative;
}

.avatar-wrap img {
    width: 96px;
    height: 96px;
}

.avatar-form {
    margin-top: 8px;
}

.chat-page .page {
    width: min(1200px, calc(100% - 20px));
    padding-top: 16px;
}

.chat-layout {
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr);
    gap: 16px;
    min-height: calc(100dvh - var(--topbar) - var(--tabbar) - var(--tabbar-gap) - 48px);
}

.chat-sidebar,
.chat-thread {
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 0;
    overflow: hidden;
}

.chat-sidebar-head,
.thread-head,
.composer {
    padding: 16px;
}

.conversation-list {
    overflow: auto;
    padding: 0 8px 12px;
    margin: 0;
}

.conversation-item {
    width: 100%;
    text-align: left;
    border: 0;
    background: transparent;
    border-radius: 14px;
    padding: 10px;
    cursor: pointer;
    color: inherit;
}

.conversation-item.is-active,
.conversation-item:hover {
    background: var(--surface-2);
}

.preview {
    margin: 0;
    color: var(--muted);
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.thread-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--line);
}

.thread-user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.thread-messages {
    flex: 1;
    overflow: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.bubble {
    max-width: min(72%, 420px);
    padding: 10px 12px;
    border-radius: 16px;
    background: var(--surface-2);
}

.bubble p {
    margin: 0 0 4px;
    white-space: pre-wrap;
    word-break: break-word;
}

.bubble time {
    font-size: 0.75rem;
    color: var(--muted);
}

.bubble-me {
    margin-left: auto;
    background: var(--primary);
    color: var(--primary-text);
}

.bubble-me time {
    color: color-mix(in srgb, var(--primary-text) 80%, transparent);
}

.typing-indicator {
    padding: 0 16px 8px;
    color: var(--muted);
    font-style: italic;
}

.composer {
    border-top: 1px solid var(--line);
}

.game-picker {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
    margin-bottom: 22px;
}

.game-tile {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    text-align: left;
    margin: 0;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 28px;
    background: var(--surface);
    box-shadow: var(--shadow);
    color: inherit;
    cursor: pointer;
    min-width: 0;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.game-tile:hover {
    transform: translateY(-4px);
    text-decoration: none;
}

.game-tile.is-selected {
    border-color: var(--primary);
    box-shadow:
        0 0 0 3px color-mix(in srgb, var(--primary) 28%, transparent),
        var(--shadow);
}

.game-tile h2 {
    margin: 10px 0 4px;
    font-size: 1.15rem;
}

.game-tile p {
    margin: 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.game-tile-art {
    flex: 1 1 auto;
    min-height: 0;
    border-radius: 20px;
    display: grid;
    place-items: center;
    padding: 12px;
    background: var(--surface-2);
}

.tile-ttt {
    width: min(100%, 168px);
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}

.tile-ttt span {
    aspect-ratio: 1;
    border-radius: 10px;
    background: var(--surface);
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: clamp(0.9rem, 3vw, 1.4rem);
    color: var(--primary);
}

.tile-ttt span:nth-child(2),
.tile-ttt span:nth-child(6) {
    color: var(--primary-2);
}

.tile-art-c4 {
    background: #1d4e89;
}

.tile-c4 {
    width: min(100%, 168px);
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}

.tile-c4 span {
    aspect-ratio: 1;
    border-radius: 50%;
    background: #0e2a4d;
}

.tile-c4 span.p1 {
    background: radial-gradient(circle at 30% 30%, #ffe9a0, var(--p1));
}

.tile-c4 span.p2 {
    background: radial-gradient(circle at 30% 30%, #ffb3ab, var(--p2));
}

.tile-draft {
    width: min(100%, 168px);
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    border-radius: 10px;
    overflow: hidden;
}

.tile-draft span {
    aspect-ratio: 1;
    background: #f3e6c9;
}

.tile-draft span.dark {
    background: #5b3a29;
}

.tile-draft span.p1::after,
.tile-draft span.p2::after {
    content: "";
    display: block;
    width: 62%;
    height: 62%;
    margin: 19%;
    border-radius: 50%;
}

.tile-draft span.p1::after {
    background: radial-gradient(circle at 30% 30%, #ffe27a, #ffd54a);
    box-shadow: 0 0 0 1px #7a4e00;
}

.tile-draft span.p2::after {
    background: radial-gradient(circle at 30% 30%, #9af0ff, #19d3ff);
    box-shadow: 0 0 0 1px #04586c;
}

.tile-chess {
    width: min(100%, 168px);
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    font-size: clamp(1rem, 4vw, 1.4rem);
    text-align: center;
}

.tile-chess span {
    aspect-ratio: 1;
    border-radius: 8px;
    background: #5b3a29;
    color: #19d3ff;
    display: grid;
    place-items: center;
}

.tile-chess span.w {
    background: #f3e6c9;
    color: #1a120c;
}

.tile-ludo {
    width: min(100%, 168px);
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}

.tile-ludo span {
    aspect-ratio: 1;
    border-radius: 10px;
}

.tile-ludo .yd.r { background: #e53935; }
.tile-ludo .yd.g { background: #43a047; }
.tile-ludo .yd.y { background: #fdd835; }
.tile-ludo .yd.b { background: #1e88e5; }
.tile-ludo .path { background: #f3e6c9; }
.tile-ludo .home { background: #fff; box-shadow: inset 0 0 0 3px #c9a227; }

.tile-art-matatu {
    background: #14532d;
}

.tile-matatu {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: center;
}

.tile-matatu .card {
    width: 42px;
    height: 58px;
    border-radius: 8px;
    background: #fff;
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: 0.85rem;
    box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.2);
}

.tile-matatu .card.red { color: #c62828; }
.tile-matatu .card.blk { color: #111; }
.tile-matatu .card.jok { background: #111; color: #ffd54a; }

.challenge-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 14px;
    margin-bottom: 20px;
}

.challenge-bar-copy {
    flex: 1 1 160px;
}

.challenge-bar-copy h2 {
    margin: 0;
}

.challenge-bar .field {
    flex: 1 1 200px;
}

.challenge-bar .btn {
    flex: 0 0 auto;
}

.game-lists {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 8px;
}

.challenge-card {
    margin-bottom: 8px;
}

.play-wrap {
    display: grid;
    gap: 16px;
    justify-items: center;
}

.play-status,
.board-wrap {
    width: min(560px, 100%);
}

.board-ttt {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.cell-ttt {
    aspect-ratio: 1;
    border: 0;
    border-radius: 16px;
    background: var(--surface-2);
    font-size: clamp(2rem, 8vw, 3.4rem);
    font-weight: 800;
    display: grid;
    place-items: center;
    color: var(--text);
}

.cell-ttt.is-x {
    color: var(--primary);
}

.cell-ttt.is-o {
    color: var(--primary-2);
}

.cell-ttt.is-open {
    cursor: pointer;
}

.cell-ttt.is-open:hover {
    transform: scale(1.03);
}

.board-c4 {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
    background: #1d4e89;
    padding: 12px;
    border-radius: 20px;
}

.c4-col {
    display: grid;
    gap: 6px;
    background: transparent;
    border: 0;
    padding: 0;
    cursor: pointer;
}

.c4-col:hover .disc:not(.p1):not(.p2) {
    background: color-mix(in srgb, #fff 35%, transparent);
}

.disc {
    aspect-ratio: 1;
    border-radius: 50%;
    background: #0e2a4d;
    display: block;
}

.disc.p1 {
    background: radial-gradient(circle at 30% 30%, #ffe9a0, var(--p1));
}

.disc.p2 {
    background: radial-gradient(circle at 30% 30%, #ffb3ab, var(--p2));
}

.play-actions {
    display: flex;
    gap: 10px;
}

.modal {
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 16, 0.55);
    display: grid;
    place-items: center;
    z-index: 100;
    padding: 20px;
}

.modal[hidden] {
    display: none !important;
}

.modal-card {
    width: min(420px, 100%);
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 12px;
}

.toast-stack {
    position: fixed;
    right: 16px;
    bottom: calc(var(--tabbar) + var(--tabbar-gap) + 16px + env(safe-area-inset-bottom));
    display: grid;
    gap: 8px;
    z-index: 90;
}

.toast {
    background: var(--text);
    color: var(--bg);
    padding: 10px 14px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    animation: toast-in 0.2s ease;
}

.toast-error {
    background: var(--danger);
    color: #fff;
}

.toast-success {
    background: var(--primary-2);
    color: #071513;
}

.toast.is-out {
    opacity: 0;
    transform: translateY(8px);
    transition: 0.25s ease;
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
}

html {
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    overflow-x: hidden;
}

button,
a,
input,
select,
textarea {
    touch-action: manipulation;
}

.nav-logout {
    display: none;
}

.chat-back {
    display: none;
}

.play-status,
.board-wrap {
    width: min(640px, 100%);
}

.board-wrap.is-draft {
    width: min(560px, 100%);
    padding: 12px;
}

.draft-hint {
    margin: 0 0 10px;
    text-align: center;
}

.board-draft {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    width: 100%;
    aspect-ratio: 1;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2);
}

.draft-sq {
    aspect-ratio: 1;
    border: 0;
    padding: 0;
    min-width: 0;
    min-height: 0;
    display: grid;
    place-items: center;
    cursor: default;
    background: #f3e6c9;
}

.draft-sq.is-dark {
    background: #5b3a29;
}

.draft-sq.is-from {
    cursor: pointer;
    box-shadow: inset 0 0 0 3px #efc453;
}

.draft-sq.is-selected {
    box-shadow: inset 0 0 0 3px #fff;
}

.draft-sq.is-target {
    cursor: pointer;
    background: #2f7d72;
}

.draft-piece {
    width: 72%;
    height: 72%;
    border-radius: 50%;
    display: block;
    pointer-events: none;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

.draft-piece.p1 {
    background: radial-gradient(circle at 30% 30%, #ffe27a, #ffd54a 55%, #e0a800);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45), 0 0 0 2px #7a4e00;
}

.draft-piece.p2 {
    background: radial-gradient(circle at 30% 30%, #b8f6ff, #19d3ff 55%, #0892b3);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45), 0 0 0 2px #04586c;
}

.draft-piece.is-king::after {
    content: "♛";
    display: grid;
    place-items: center;
    height: 100%;
    font-size: clamp(0.7rem, 3vw, 1.1rem);
    color: #3b1511;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.45);
}

.draft-piece.p2.is-king::after {
    color: #042a36;
}

.chess-piece {
    font-size: clamp(1.1rem, 5vw, 2rem);
    line-height: 1;
    pointer-events: none;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
}

.chess-piece.is-white {
    color: #fff8e4;
    -webkit-text-stroke: 1px #2a1810;
}

.chess-piece.is-black {
    color: #111;
    -webkit-text-stroke: 1px #f3e6c9;
}

.lobby-card {
    width: min(720px, 100%);
}

.lobby-seats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.lobby-seat {
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 12px;
    background: var(--surface-2);
}

.lobby-seat h3 {
    margin: 4px 0;
}

.lobby-seat.is-ready {
    box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--primary) 50%, transparent);
}

.lobby-seat.is-empty {
    opacity: 0.72;
}

.lobby-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-top: 12px;
}

.board-wrap.is-ludo {
    width: min(640px, 100%);
    padding: 12px;
}

.board-wrap.is-matatu {
    width: min(720px, 100%);
}

.ludo-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.ludo-legend {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-right: 8px;
    font-weight: 650;
}

.ludo-legend::before {
    content: "";
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.ludo-legend.p1::before { background: #e53935; }
.ludo-legend.p2::before { background: #43a047; }
.ludo-legend.p3::before { background: #fdd835; }
.ludo-legend.p4::before { background: #1e88e5; }

.ludo-dice {
    margin: 0;
    font-size: 1.05rem;
}

.board-ludo {
    display: grid;
    grid-template-columns: repeat(15, minmax(0, 1fr));
    width: 100%;
    aspect-ratio: 1;
    border-radius: 12px;
    overflow: hidden;
    background: #2a1810;
}

.ludo-sq {
    min-width: 0;
    min-height: 0;
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
}

.ludo-sq.ludo-empty { background: #3d2418; }
.ludo-sq.ludo-path { background: #f3e6c9; }
.ludo-sq.ludo-center { background: #fff; }
.ludo-sq.y1 { background: #b71c1c; }
.ludo-sq.y2 { background: #1b5e20; }
.ludo-sq.y3 { background: #f9a825; }
.ludo-sq.y4 { background: #0d47a1; }
.ludo-sq.h1 { background: #ef9a9a; }
.ludo-sq.h2 { background: #a5d6a7; }
.ludo-sq.h3 { background: #fff59d; }
.ludo-sq.h4 { background: #90caf9; }

.ludo-token {
    width: 62%;
    height: 62%;
    max-width: 22px;
    max-height: 22px;
    border: 0;
    border-radius: 50%;
    padding: 0;
    cursor: default;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.ludo-token.p1 { background: #ff5252; }
.ludo-token.p2 { background: #69f0ae; }
.ludo-token.p3 { background: #ffff00; }
.ludo-token.p4 { background: #40c4ff; }

.ludo-token.is-move {
    cursor: pointer;
    box-shadow: 0 0 0 2px #fff, 0 0 8px #ffd54a;
}

.matatu-table {
    display: grid;
    gap: 14px;
}

.matatu-rivals {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.matatu-rival {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 8px 12px;
}

.matatu-pile {
    text-align: center;
}

.matatu-hand {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.matatu-card {
    min-width: 54px;
    min-height: 76px;
    border-radius: 10px;
    border: 1px solid #ccc;
    background: #fff;
    display: grid;
    place-items: center;
    font-weight: 800;
    padding: 6px;
}

.matatu-card.is-red { color: #c62828; }
.matatu-card.is-black { color: #111; }
.matatu-card.is-joker { background: #111; color: #ffd54a; border-color: #111; }
.matatu-card.is-back { background: #14532d; color: #fff; }
.matatu-card.is-top {
    width: 72px;
    min-height: 100px;
    margin: 0 auto 8px;
    font-size: 1.2rem;
}

button.matatu-card {
    cursor: pointer;
}

.matatu-suits {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    justify-content: center;
}

@media (hover: hover) and (pointer: fine) {
    .draft-sq.is-from:hover,
    .draft-sq.is-target:hover {
        filter: brightness(1.08);
    }
}

@media (max-width: 900px) {
    .dashboard-grid,
    .chat-layout,
    .game-lists,
    .stats-row {
        grid-template-columns: 1fr;
    }

    .topbar .user-chip span {
        display: none;
    }

    .chat-layout {
        min-height: calc(100dvh - var(--topbar) - var(--tabbar) - var(--tabbar-gap) - 24px);
    }

    .chat-layout:not(.has-thread) .chat-thread {
        display: none;
    }

    .chat-layout.has-thread .chat-sidebar {
        display: none;
    }

    .chat-back {
        display: inline-flex;
    }

    .thread-head {
        gap: 8px;
        flex-wrap: wrap;
    }

    .inline-form,
    .challenge-form,
    .challenge-bar,
    .composer {
        flex-direction: column;
        align-items: stretch;
    }

    .play-actions,
    .modal-actions,
    .page-head-actions {
        width: 100%;
        flex-wrap: wrap;
    }

    .play-actions .btn,
    .modal-actions .btn,
    .page-head-actions .btn {
        flex: 1 1 140px;
    }

    .toast-stack {
        right: 12px;
        left: 12px;
        bottom: calc(var(--tabbar) + var(--tabbar-gap) + 12px + env(safe-area-inset-bottom));
    }
}

@media (max-width: 640px) {
    .game-picker {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
    }

    .game-tile {
        padding: 10px;
        border-radius: 22px;
    }

    .game-tile p {
        display: none;
    }

    .game-tile h2 {
        font-size: 0.85rem;
        text-align: center;
        margin-top: 8px;
    }

    .game-tile-art {
        padding: 8px;
        border-radius: 16px;
    }
    .page {
        width: min(1120px, calc(100% - 20px));
        padding: 16px 0 48px;
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
        padding-bottom: calc(var(--tabbar) + var(--tabbar-gap) + 20px + env(safe-area-inset-bottom));
    }

    .topbar {
        padding: 0 10px 0 max(10px, env(safe-area-inset-left));
        gap: 8px;
    }

    .card {
        padding: 14px;
    }

    .stat-value {
        font-size: 1.5rem;
    }

    .stats-row {
        grid-template-columns: 1fr;
    }

    .profile-hero {
        flex-direction: column;
        text-align: center;
    }

    .row-actions {
        flex-wrap: wrap;
        justify-content: flex-end;
    }

    .list-row,
    .game-row,
    .person {
        flex-wrap: wrap;
        align-items: flex-start;
    }

    .bubble {
        max-width: 88%;
    }

    .board-c4 {
        gap: 4px;
        padding: 8px;
    }

    h1 {
        font-size: 1.6rem;
    }
}

@media (max-width: 400px) {
    .brand-text {
        display: none;
    }

    .btn-sm {
        padding: 8px 10px;
    }
}
