/* Catur Master — Ular design system + chess gold identity */
:root {
    --bg: #070b18;
    --surface: rgba(17, 24, 48, 0.72);
    --surface-solid: #111830;
    --surface-2: rgba(30, 41, 78, 0.85);
    --border: rgba(126, 146, 205, 0.16);
    --border-strong: rgba(126, 146, 205, 0.32);
    --text: #eef1fb;
    --muted: #93a0c4;
    --accent: #e8b84b;
    --accent-strong: #c79a2e;
    --cyan: #22d3ee;
    --purple: #a78bfa;
    --danger: #ff5470;
    --warning: #ffd166;
    --radius: 16px;
    --radius-sm: 11px;
    --shadow: 0 18px 44px rgba(2, 6, 20, 0.55);
    --glow-accent: 0 0 22px rgba(232, 184, 75, 0.35);
    --font-display: "Segoe UI", "Trebuchet MS", system-ui, -apple-system, Roboto, sans-serif;
    --sq-light: #ecd9b9;
    --sq-dark: #a97e4f;
    --hl-last: rgba(247, 227, 87, .42);
    --hl-sel: rgba(120, 220, 120, .45);
}

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

[hidden] { display: none !important; }

::selection {
    background: rgba(232, 184, 75, 0.28);
    color: var(--text);
}

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: var(--font-display);
    background:
        radial-gradient(1000px 560px at 88% -12%, rgba(232, 184, 75, 0.10), transparent 60%),
        radial-gradient(760px 460px at -12% 112%, rgba(180, 130, 50, 0.09), transparent 60%),
        radial-gradient(600px 400px at 55% 45%, rgba(160, 100, 200, 0.05), transparent 65%),
        var(--bg);
    color: var(--text);
    line-height: 1.55;
}

/* ===== Animated background ===== */
.bg-fx {
    position: fixed;
    inset: 0;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.bg-fx::after {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(148, 163, 214, 0.045) 1px, transparent 1px),
        linear-gradient(90deg, rgba(148, 163, 214, 0.045) 1px, transparent 1px);
    background-size: 46px 46px;
    -webkit-mask-image: radial-gradient(ellipse 90% 80% at 50% 40%, black 25%, transparent 78%);
    mask-image: radial-gradient(ellipse 90% 80% at 50% 40%, black 25%, transparent 78%);
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(95px);
    opacity: 0.4;
    will-change: transform;
}

.orb-a {
    width: 500px; height: 500px;
    background: rgba(232, 184, 75, 0.17);
    top: -150px; right: -130px;
    animation: orb-drift-a 26s ease-in-out infinite alternate;
}

.orb-b {
    width: 440px; height: 440px;
    background: rgba(180, 130, 50, 0.15);
    bottom: -170px; left: -130px;
    animation: orb-drift-b 32s ease-in-out infinite alternate;
}

.orb-c {
    width: 320px; height: 320px;
    background: rgba(160, 100, 200, 0.13);
    top: 42%; left: 56%;
    animation: orb-drift-c 38s ease-in-out infinite alternate;
}

@keyframes orb-drift-a {
    from { transform: translate(0, 0) scale(1); }
    to { transform: translate(-90px, 70px) scale(1.15); }
}
@keyframes orb-drift-b {
    from { transform: translate(0, 0) scale(1); }
    to { transform: translate(80px, -60px) scale(1.12); }
}
@keyframes orb-drift-c {
    from { transform: translate(0, 0) scale(1); }
    to { transform: translate(-70px, -50px) scale(0.85); }
}

/* ===== Asas ===== */
a { color: var(--cyan); text-decoration: none; }

h1, h2 { margin: 0 0 0.5rem; line-height: 1.25; }

.muted { color: var(--muted); }

/* ===== Header ===== */
.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.85rem clamp(1rem, 4vw, 2.5rem);
    border-bottom: 1px solid var(--border);
    background: rgba(7, 11, 24, 0.68);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    position: sticky;
    top: 0;
    z-index: 10;
}

.brand {
    font-weight: 800;
    font-size: 1.18rem;
    letter-spacing: 0.03em;
    color: var(--text);
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    transition: filter 0.2s ease;
    min-width: 0;
}

.brand:hover {
    filter: brightness(1.2);
}

.brand-icon {
    font-size: 1.35rem;
    color: var(--accent);
    filter: drop-shadow(0 0 10px rgba(232, 184, 75, 0.7));
    animation: brand-wiggle 5s ease-in-out infinite;
}

@keyframes brand-wiggle {
    0%, 84%, 100% { transform: rotate(0deg); }
    88% { transform: rotate(-14deg); }
    92% { transform: rotate(12deg); }
    96% { transform: rotate(-6deg); }
}

.brand-title {
    font-size: 1.18rem;
    font-weight: 800;
    letter-spacing: 0.03em;
    line-height: 1.15;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.brand-sub {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-ghost {
    background: rgba(148, 163, 214, 0.06);
    border-color: var(--border);
    color: var(--muted);
}

.btn-ghost:hover {
    color: var(--text);
    border-color: var(--border-strong);
    background: rgba(148, 163, 214, 0.1);
}

.btn-small {
    padding: 0.38rem 0.85rem;
    font-size: 0.85rem;
}

@media (max-width: 576px) {
    .brand-icon { font-size: 1.15rem; }
    .brand-title { font-size: 1rem; }
    .brand-sub { display: none; }
}

/* ===== Footer ===== */
.site-footer {
    text-align: center;
    padding: 1.3rem;
    font-size: 0.85rem;
    border-top: 1px solid var(--border);
    background: rgba(7, 11, 24, 0.5);
    color: var(--muted);
    margin-top: auto;
}

.site-footer .brand-credit {
    color: var(--accent);
    font-weight: 700;
    letter-spacing: 0.05em;
    text-shadow: 0 0 12px rgba(232, 184, 75, 0.35);
}

.site-footer .brand-credit:hover {
    text-shadow: 0 0 18px rgba(232, 184, 75, 0.65);
}

/* ===== Susun atur ===== */
.layout {
    display: flex;
    gap: 22px;
    justify-content: center;
    align-items: flex-start;
    padding: clamp(1rem, 3vw, 2rem) 1rem 2rem;
    flex-wrap: wrap;
    flex: 1;
}

.board-zone { position: relative; }
.board-row { display: flex; align-items: stretch; gap: 10px; }
.board-stack { position: relative; }

.panel {
    width: 300px;
    background: linear-gradient(180deg, rgba(23, 31, 60, 0.82) 0%, rgba(15, 21, 42, 0.86) 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: border-color 0.25s ease;
}

.panel:hover {
    border-color: var(--border-strong);
}

/* ===== Bar penilaian ===== */
#eval-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    width: 34px;
}

#eval-num { font-size: 11px; color: var(--text); font-weight: 700; white-space: nowrap; }

.eval-track {
    flex: 1;
    width: 12px;
    border-radius: 6px;
    overflow: hidden;
    background: rgba(7, 11, 24, 0.75);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column-reverse;
}

#eval-fill {
    width: 100%;
    height: 50%;
    background: linear-gradient(180deg, var(--accent), var(--accent-strong));
    transition: height .5s ease;
}

/* ===== Papan ===== */
#board {
    display: grid;
    grid-template-columns: repeat(8, min(11vw, 76px));
    grid-template-rows: repeat(8, min(11vw, 76px));
    border: 6px solid var(--surface-solid);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    user-select: none;
}

.sq { position: relative; cursor: pointer; }
.sq.light { background: var(--sq-light); }
.sq.dark  { background: var(--sq-dark); }

.sq.hl  { box-shadow: inset 0 0 0 100vmax var(--hl-last); }
.sq.sel { box-shadow: inset 0 0 0 100vmax var(--hl-sel); }
.sq.check::before {
    content: ""; position: absolute; inset: 0;
    background: radial-gradient(circle at 50% 45%, rgba(255, 84, 112, .85), rgba(255, 84, 112, 0) 68%);
}

.sq.hint::after {
    content: ""; position: absolute; left: 50%; top: 50%;
    width: 30%; height: 30%; transform: translate(-50%, -50%);
    border-radius: 50%; background: rgba(20, 30, 20, .28);
}
.sq.cap-hint::after {
    content: ""; position: absolute; inset: 4%;
    border-radius: 50%;
    border: 5px solid rgba(20, 30, 20, .28);
}

.sq.suggest {
    box-shadow: inset 0 0 0 4px var(--accent);
    animation: suggest-blink 1s ease-in-out infinite;
}
@keyframes suggest-blink { 50% { box-shadow: inset 0 0 0 4px rgba(232, 184, 75, .25); } }

.pc {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: calc(min(11vw, 76px) * .78);
    line-height: 1; z-index: 2; pointer-events: none;
}
.pc.w { color: #fafafa; text-shadow: 0 1px 0 #555, 0 -1px 0 #555, 1px 0 0 #555, -1px 0 0 #555, 0 3px 6px rgba(0,0,0,.5); }
.pc.b { color: #1c1c1c; text-shadow: 0 1px 0 rgba(255,255,255,.25), 0 3px 6px rgba(0,0,0,.5); }
.sq.drag-src .pc { opacity: .35; }

/* Koordinat pada petak tepi */
.sq[data-file-coord]::before,
.sq[data-rank-coord]::before {
    content: attr(data-file-coord);
    position: absolute; right: 3px; bottom: 1px;
    font-size: 10px; font-weight: 700; z-index: 1;
}
.sq[data-rank-coord]::before {
    content: attr(data-rank-coord);
    right: auto; bottom: auto; left: 3px; top: 1px;
}
.sq.light::before { color: var(--sq-dark); }
.sq.dark::before  { color: var(--sq-light); }

/* ===== Sepanduk hasil ===== */
.banner {
    position: absolute; inset: 0; z-index: 6;
    background:
        radial-gradient(420px 300px at 50% 38%, rgba(232, 184, 75, 0.07), transparent 70%),
        rgba(6, 10, 22, 0.82);
    backdrop-filter: blur(7px);
    -webkit-backdrop-filter: blur(7px);
    border-radius: var(--radius-sm);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 10px; text-align: center; padding: 20px;
}

.banner h2 {
    font-family: Georgia, serif;
    font-size: 30px;
    background: linear-gradient(92deg, var(--accent) 15%, var(--cyan) 55%, var(--accent) 95%);
    background-size: 200% auto;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    filter: drop-shadow(0 0 22px rgba(232, 184, 75, 0.4));
    animation: title-shine 3.2s linear infinite;
}

@keyframes title-shine {
    to { background-position: 200% center; }
}

.banner p { color: var(--muted); font-size: 15px; max-width: 340px; }

/* ===== Modal promosi ===== */
.promo {
    position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
    z-index: 7;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    text-align: center;
    box-shadow: var(--shadow);
}

.promo p { margin-bottom: 10px; font-size: 14px; color: var(--muted); }
.promo-row { display: flex; gap: 8px; }
.promo-row button {
    width: 58px; height: 58px; font-size: 38px; line-height: 1;
    background: var(--surface); color: inherit;
    border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer;
    transition: transform .08s, border-color .08s;
}
.promo-row button:hover { transform: translateY(-2px); border-color: var(--accent); }
.promo-row .pc { display: block; width: 42px; height: 42px; }
.promo-row .pc .psvg { display: block; width: 100%; height: 100%; }

/* ===== Tindanan mula ===== */
.start-overlay {
    position: absolute; inset: 0; z-index: 8;
    background:
        radial-gradient(420px 300px at 50% 38%, rgba(232, 184, 75, 0.07), transparent 70%),
        rgba(6, 10, 22, 0.88);
    backdrop-filter: blur(7px);
    -webkit-backdrop-filter: blur(7px);
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
}

.start-card {
    background: linear-gradient(180deg, rgba(23, 31, 60, 0.82) 0%, rgba(15, 21, 42, 0.86) 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 22px;
    width: min(88%, 360px);
    text-align: center;
    display: flex; flex-direction: column; gap: 12px;
    box-shadow: var(--shadow);
}

.start-card h2 {
    font-family: Georgia, serif;
    letter-spacing: .5px;
    background: linear-gradient(92deg, var(--accent) 15%, var(--cyan) 55%, var(--accent) 95%);
    background-size: 200% auto;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.opt-group { display: flex; flex-direction: column; gap: 7px; text-align: left; }
.opt-label { font-size: 12px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--muted); }
.opt-row { display: flex; gap: 6px; flex-wrap: wrap; }

.btn.opt {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.82rem;
    padding: 0.4rem 0.85rem;
}

.btn.opt:hover {
    color: var(--text);
    border-color: var(--border-strong);
    background: var(--surface-2);
}

.btn.opt.active {
    border-color: var(--accent);
    color: #1a1200;
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    box-shadow: 0 0 14px rgba(232, 184, 75, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.3);
    font-weight: 700;
}

#fen-input {
    flex: 1; min-width: 0;
    background: rgba(7, 11, 24, 0.75); color: var(--text);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 9px 11px; font-size: 12.5px;
    font-family: "Consolas", "Menlo", monospace;
}
#fen-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(232, 184, 75, 0.16); }
.fen-msg { font-size: 12px; margin-top: 6px; }
.fen-msg.err { color: var(--danger); }
.fen-msg.ok { color: var(--accent); }
#fen-input.invalid { border-color: var(--danger) !important; }
#fen-input.valid { border-color: var(--accent); }

.fen-box { padding: 10px 12px; }
.fen-box summary {
    cursor: pointer; user-select: none;
    font-size: 12px; text-transform: uppercase; letter-spacing: 1.2px;
    color: var(--muted); list-style: none;
}
.fen-box summary::-webkit-details-marker { display: none; }
.fen-box summary::after { content: "+"; float: right; color: var(--muted); }
.fen-box[open] summary::after { content: "\2013"; }
.fen-box summary .fen-tag {
    display: inline-block; margin-left: 6px; padding: 1px 7px;
    font-size: 10px; letter-spacing: .4px; text-transform: none;
    border: 1px solid var(--border); border-radius: 999px; color: var(--muted);
}
.fen-body { margin-top: 10px; }
.fen-help { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.fen-row { display: flex; gap: 6px; align-items: stretch; }
.fen-preview {
    margin-top: 10px;
    width: 184px; height: 184px;
    display: grid; grid-template-columns: repeat(8, 23px); grid-template-rows: repeat(8, 23px);
    border-radius: var(--radius-sm); overflow: hidden;
    border: 1px solid var(--border);
}
.fen-preview .fp {
    display: flex; align-items: center; justify-content: center;
    font-size: 17px; line-height: 1;
}
.fen-preview .fp.lt { background: #e9d6ae; }
.fen-preview .fp.dk { background: #b0804e; }
.fen-preview .fp.w { color: #fafafa; text-shadow: 0 0 2px #333, 0 1px 1px rgba(0, 0, 0, .6); }
.fen-preview .fp.b { color: #1d1d1f; }

/* ===== Butang ===== */
.btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    font: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.4rem 0.85rem;
    cursor: pointer;
    overflow: hidden;
    color: var(--muted);
    background: var(--surface);
    transition: transform 0.14s ease, box-shadow 0.14s ease, background 0.14s ease, border-color 0.14s ease, color 0.14s ease;
}

.btn:hover {
    color: var(--text);
    border-color: var(--border-strong);
    background: var(--surface-2);
}

.btn:active { transform: translateY(1px) scale(0.99); }
button:disabled { opacity: .4; cursor: not-allowed; }

.btn-accent {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
    color: #1a1200;
    border-color: transparent;
    font-weight: 700;
    box-shadow: 0 4px 14px rgba(232, 184, 75, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.btn-accent:hover {
    box-shadow: 0 6px 20px rgba(232, 184, 75, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
    color: #1a1200;
}

.btn-wide { width: 100%; padding: 0.55rem; font-size: 0.88rem; }
.btn-icon { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; padding: 0; font-size: 0.85rem; }

/* ===== Panel pemain & status ===== */
.player-bar {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 14px; border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, rgba(30, 41, 78, 0.5), rgba(17, 24, 48, 0.5));
}

#bar-bottom { border-bottom: none; border-top: 1px solid var(--border); order: 5; }
.dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.dot-w { background: #f5f5f5; box-shadow: 0 0 0 2px #666; }
.dot-b { background: #111; box-shadow: 0 0 0 2px #555; }

.player-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.player-info strong { font-size: 14px; color: var(--text); }
.captured { font-size: 17px; letter-spacing: 1px; min-height: 20px; color: var(--muted); line-height: 1; }
.think { color: var(--accent); font-size: 11.5px; animation: pulse 1.1s ease-in-out infinite; white-space: nowrap; }
@keyframes pulse { 50% { opacity: .35; } }

.clock {
    font-variant-numeric: tabular-nums;
    font-family: "Consolas", "Menlo", monospace;
    font-size: 19px; font-weight: 700;
    background: rgba(7, 11, 24, 0.75);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 4px 9px; min-width: 74px; text-align: center;
    color: var(--text);
}
.clock.active-clock { border-color: var(--accent); color: var(--accent); }
.clock.low { border-color: var(--danger); color: var(--danger); animation: pulse 1s ease-in-out infinite; }

.status {
    order: 3;
    margin: 12px 14px 0;
    padding: 11px 13px; border-radius: var(--radius-sm);
    background: var(--surface-2); border: 1px solid var(--border);
    font-size: 14.5px; text-align: center; color: var(--text);
}
.status.alert { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.status.danger { border-color: var(--danger); color: var(--danger); font-weight: 600; }

.controls {
    order: 4;
    display: flex; gap: 7px; flex-wrap: wrap;
    padding: 12px 14px;
}

/* ===== Senarai langkah ===== */
.moves-head {
    order: 6;
    padding: 10px 14px 6px;
    font-size: 11px; text-transform: uppercase; letter-spacing: 1.4px;
    color: var(--muted);
    display: flex; align-items: center; justify-content: space-between;
}

.moves-actions { display: flex; gap: 6px; }

.mini-btn {
    appearance: none; cursor: pointer;
    background: var(--surface); color: var(--muted);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    font-size: 10.5px; letter-spacing: .8px;
    padding: 3px 8px;
    transition: color .15s, border-color .15s;
}

.mini-btn:hover { color: var(--accent); border-color: var(--accent); }

.moves {
    order: 7;
    list-style: none; margin: 0 8px 12px;
    overflow-y: auto; max-height: 210px; min-height: 90px;
    display: grid; grid-template-columns: 44px 1fr 1fr;
    gap: 2px 4px; padding: 6px 8px;
    background: rgba(7, 11, 24, 0.75);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    font-size: 13.5px; scrollbar-width: thin;
}

.moves li { padding: 2px 5px; border-radius: 5px; }
.moves li.no { color: var(--muted); }
.moves li.cur { background: rgba(232, 184, 75, .14); color: var(--accent); font-weight: 600; }

.moves:empty::after {
    content: "— tiada langkah lagi —"; grid-column: 1 / -1;
    color: var(--muted); font-size: 12px; text-align: center; padding: 18px 0;
}

/* ===== Multiplayer ===== */
#mp-name, #mp-code, #mp-link {
    background: rgba(7, 11, 24, 0.75); border: 1px solid var(--border); color: var(--text);
    border-radius: var(--radius-sm); padding: 9px 11px; font-size: 14px; width: 100%;
}
#mp-name:focus, #mp-code:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(232, 184, 75, 0.16); }

.mp-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.mp-actions .btn { padding: 9px 12px; white-space: nowrap; }
.or-sep { color: var(--muted); font-size: 12.5px; }
#mp-code { width: 110px; text-transform: uppercase; letter-spacing: 2px; text-align: center; font-weight: 700; }
#mp-link { flex: 1; min-width: 160px; font-size: 12px; opacity: .85; }

.room-badge {
    display: flex; align-items: center; justify-content: space-between;
    gap: 8px; padding: 7px 12px; margin-bottom: 10px;
    background: rgba(232, 184, 75, .08); border: 1px dashed var(--accent);
    border-radius: var(--radius-sm); font-size: 13px; color: var(--accent);
}

.player-bar.offline { opacity: .45; }
.player-bar.offline::after { content: " (luring)"; font-size: 11px; color: var(--muted); }

.draw-prompt {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 8px 12px; margin-bottom: 10px;
    background: rgba(232, 184, 75, .1); border: 1px solid var(--accent);
    border-radius: var(--radius-sm); font-size: 13px;
}
.draw-actions { display: flex; gap: 6px; }
.banner-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

.chat { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; order: 8; }
.chat-log {
    height: 130px; overflow-y: auto; scrollbar-width: thin;
    background: rgba(7, 11, 24, 0.75); border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 6px 9px; font-size: 12.5px; line-height: 1.5;
}
.chat-log:empty::after { content: "— sembang —"; color: var(--muted); font-size: 11.5px; }
.chat-msg.me { color: var(--accent); }
.chat-msg.them { color: inherit; }
.chat-msg.spec { color: var(--muted); font-style: italic; }
.chat-msg.sys { color: var(--muted); font-style: italic; }

.chat-form { display: flex; gap: 6px; }
.chat-form input {
    flex: 1; background: rgba(7, 11, 24, 0.75); border: 1px solid var(--border); color: var(--text);
    border-radius: var(--radius-sm); padding: 8px 10px; font-size: 13px;
}
.chat-form input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(232, 184, 75, 0.16); }

/* ===== Papan 3D ===== */
#board3d {
    position: relative;
    width: min(92vw, 600px);
    aspect-ratio: 1 / 1;
    display: grid;
    place-items: center;
    user-select: none;
    --tile: min(11vw, 76px);
}

.b3-scene {
    position: absolute; inset: 0;
    perspective: 1150px;
    touch-action: none;
    cursor: grab;
}
.b3-scene:active { cursor: grabbing; }

.b3-world {
    position: absolute; left: 50%; top: 50%;
    width: min(84vw, 545px); height: min(84vw, 545px);
    transform-style: preserve-3d;
    transform:
        translate(-50%, -50%)
        rotateX(calc(var(--tilt) * 1deg))
        rotateZ(calc(var(--yaw) * 1deg))
        scale(var(--zoom));
}
.b3-world.b3-anim { transition: transform .48s cubic-bezier(.25, .8, .3, 1); }

.b3-board { position: absolute; inset: 0; transform-style: preserve-3d; }

.b3-deck, .b3-floor {
    position: absolute; inset: 0; border-radius: var(--radius-sm);
    pointer-events: none;
}

.b3-floor {
    inset: -6%;
    background: radial-gradient(closest-side, rgba(0, 0, 0, .5), transparent 78%);
    filter: blur(6px);
}

.b3-tile {
    position: absolute; width: 12.5%; height: 12.5%;
    cursor: pointer;
}
.b3-tile.light { background: linear-gradient(145deg, #f2e2c6, var(--sq-light)); }
.b3-tile.dark  { background: linear-gradient(145deg, #b3885a, var(--sq-dark)); }
.b3-tile::after {
    content: ""; position: absolute; inset: 0; pointer-events: none;
    box-shadow: inset 0 0 22px rgba(60, 35, 10, .18);
}

.b3-tile.hl  { box-shadow: inset 0 0 0 100vmax var(--hl-last); }
.b3-tile.sel { box-shadow: inset 0 0 0 100vmax var(--hl-sel); }
.b3-tile.check::before {
    content: ""; position: absolute; inset: 0; z-index: 1;
    background: radial-gradient(circle at 50% 45%, rgba(255, 84, 112, .85), rgba(255, 84, 112, 0) 68%);
}
.b3-tile.hint::after {
    content: ""; position: absolute; left: 50%; top: 50%; z-index: 1;
    width: 30%; height: 30%; transform: translate(-50%, -50%);
    border-radius: 50%;
    background: rgba(20, 30, 20, .32);
    box-shadow: none;
}
.b3-tile.cap-hint::after {
    content: ""; position: absolute; inset: 4%; z-index: 1;
    border-radius: 50%;
    border: 5px solid rgba(20, 30, 20, .34);
    box-shadow: none;
}
.b3-tile.suggest {
    box-shadow: inset 0 0 0 4px var(--accent);
    animation: suggest-blink 1s ease-in-out infinite;
}

.b3-tile[data-file-coord]::before,
.b3-tile[data-rank-coord]::before {
    content: attr(data-file-coord);
    position: absolute; right: 4px; bottom: 2px;
    font-size: clamp(9px, 1.6vw, 11px); font-weight: 700; z-index: 2;
}
.b3-tile[data-rank-coord]::before {
    content: attr(data-rank-coord);
    right: auto; bottom: auto; left: 4px; top: 2px;
}
.b3-tile.light::before { color: var(--sq-dark); }
.b3-tile.dark::before  { color: var(--sq-light); }

.piece3 {
    position: absolute; width: 12.5%; height: 12.5%;
    transform-style: preserve-3d;
    pointer-events: none;
    transition: left .23s ease, top .23s ease;
    z-index: 2;
}
.piece3 .p-sh {
    position: absolute; left: 16%; right: 16%; top: 26%; bottom: 8%;
    border-radius: 50%;
    background: radial-gradient(closest-side, rgba(0, 0, 0, .40), transparent 72%);
}
.piece3 .pl {
    position: absolute; inset: 0;
    display: flex; align-items: flex-end; justify-content: center;
    padding-bottom: 9%;
    line-height: .92;
    backface-visibility: hidden;
    filter: drop-shadow(2px 5px 4px rgba(0, 0, 0, .38));
}
.piece3.w .pl {
    color: #fafafa;
    text-shadow: 0 1px 0 #555, 0 -1px 0 #555, 1px 0 0 #555, -1px 0 0 #555, 0 3px 6px rgba(0, 0, 0, .5);
}
.piece3.b .pl {
    color: #1c1c1c;
    text-shadow: 0 1px 0 rgba(255, 255, 255, .25), 0 3px 6px rgba(0, 0, 0, .5);
}

.p-moving .pl { animation: b3hop .23s ease; }
@keyframes b3hop { 55% { margin-top: -7%; } }
.piece3.p-captured { opacity: 0; transition: opacity .24s ease; }
.piece3.p-captured .pl { animation: b3cap .24s ease forwards; }
@keyframes b3cap { to { transform: scale(.4); } }
.p-spawn .pl { animation: b3spawn .28s ease; }
@keyframes b3spawn { from { transform: scale(.5); } }

#btn-view.on { border-color: var(--accent); color: var(--accent); }

.b3-pieces {
    position: absolute; inset: 0;
    transform-style: preserve-3d;
    pointer-events: none;
}

.b3-board::before {
    content: ""; position: absolute; inset: -1.6%;
    border-radius: 16px;
    background: linear-gradient(160deg, #4a3826, #241a10);
    transform: translateZ(-0.5px);
    pointer-events: none;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: rgba(126, 146, 205, 0.25); border-radius: 999px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: rgba(232, 184, 75, 0.4); }

/* ===== Responsive ===== */
@media (max-width: 900px) {
    .layout { flex-direction: column; align-items: center; }
    .panel { width: min(94vw, 480px); }
}

@media (max-width: 700px) {
    #eval-col { display: none; }
}

@media (max-width: 480px) {
    .opt-row { gap: 4px; }
    .btn { padding: 0.5rem 1rem; font-size: 13px; }
}

/* ===== Kurangkan gerakan ===== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
