/* Halaman Main (index_play.html). Layout sama dengan halaman Tonton (css/watch.css).
   Selector diawali .play-body supaya menang dari aturan lama di asset/main.css & css/caturid.css. */
body.play-body {
    background: radial-gradient(ellipse at center, #3a3a3a 0%, #1e1e1e 100%) !important;
    color: #e8e8e8;
    margin: 0;
}

.play-body .hidden { display: none !important; }
.play-body .muted { color: #9a9a9a; font-size: 13px; }

/* SEMENTARA: tombol Analisis Server disembunyikan. Hapus baris ini untuk memunculkannya lagi. */
.play-body #btnAnalyzeGame { display: none !important; }

.play-page {
    max-width: 1100px;
    margin: 20px auto;
    padding: 0 16px;
    box-sizing: border-box;
}

.play-body .w-card {
    background: #2b2b2b;
    border: 1px solid #444;
    border-radius: 6px;
    padding: 14px;
}
.play-body .w-card h3 { margin: 0 0 10px; font-size: 15px; }
.play-body .card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

/* ---------- Tombol ---------- */
.play-body .btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 4px;
    background: #444; color: #e8e8e8;
    border: 1px solid #555; border-radius: 4px;
    padding: 8px 12px; font-size: 13px;
    cursor: pointer; text-decoration: none;
    transform: none; box-shadow: none;
}
.play-body .btn:hover:not(:disabled) { background: #555; border-color: #666; transform: none; }
.play-body .btn:disabled { opacity: 0.55; cursor: not-allowed; }
.play-body .btn-primary { background: #2e7d32; border-color: #2e7d32; color: #fff; }
.play-body .btn-primary:hover:not(:disabled) { background: #388e3c; border-color: #388e3c; }
.play-body .btn-danger { background: #a33; border-color: #a33; color: #fff; }
.play-body .btn-danger:hover:not(:disabled) { background: #b84040; border-color: #b84040; }
.play-body .btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.play-body .btn-row.end { justify-content: flex-end; margin-top: 16px; }

/* ---------- Layout ---------- */
.game-layout {
    display: grid;
    grid-template-columns: minmax(0, 600px) 340px;
    gap: 16px;
    justify-content: center;
    align-items: start;
}
.board-col { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.side-col { display: flex; flex-direction: column; gap: 12px; min-width: 0; }

/* #board juga diatur asset/main.css; id+class supaya aturan itu kalah */
#board.play-board {
    width: 100%;
    height: auto;
    max-width: none;
    max-height: none;
    aspect-ratio: 1 / 1;
    border-radius: 4px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
}

/* ---------- Strip pemain + jam ---------- */
.play-body .player-strip {
    display: flex; align-items: center; gap: 8px;
    background: #2b2b2b; border: 1px solid #444; border-radius: 4px;
    padding: 6px 10px;
}
.play-body .player-strip .p-color { width: 12px; height: 12px; border-radius: 50%; border: 1px solid #777; flex-shrink: 0; }
.play-body .player-strip .p-color.white { background: #f0f0f0; }
.play-body .player-strip .p-color.black { background: #111; }
.play-body .player-strip .p-name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.play-body .player-strip .p-rating { color: #38bdf8; font-family: monospace; font-size: 13px; }
.play-body .player-strip .p-clock {
    font-family: monospace; font-size: 20px; font-weight: 700;
    background: #1f1d1b; color: #bbb; padding: 2px 10px; border-radius: 4px; min-width: 76px; text-align: right;
}
/* Kelas active/timeout dipasang UIManager pada strip (#whiteClock / #blackClock) */
.play-body .player-strip.active .p-clock { background: #2e7d32; color: #fff; }
.play-body .player-strip.low .p-clock { background: #a33; color: #fff; }
.play-body .player-strip.timeout .p-clock { background: #6b1f1f; color: #fff; }

/* ---------- Status ---------- */
.play-body .status-row { display: flex; align-items: center; gap: 8px; }
.play-body .game-status { margin: 10px 0; font-size: 15px; }
.play-body #openingName { margin: -4px 0 10px; }
.play-body #rematchOffer { margin-top: 10px; }

/* ---------- Langkah ---------- */
.play-body .move-list {
    max-height: 300px;
    overflow-y: auto;
    font-family: monospace;
    font-size: 14px;
}
.play-body .move-list .move-row {
    display: grid;
    grid-template-columns: 36px 1fr 1fr;
    gap: 2px 6px;
    align-items: center;
    padding: 0;
}
.play-body .move-list .move-row > span:first-child { color: #777; text-align: right; }
.play-body .move-list .move-row span { padding: 2px 4px; border-radius: 3px; cursor: pointer; }
.play-body .move-list .move-row span:first-child { cursor: default; }
.play-body .move-list .move-row span:hover:not(:first-child) { background: #3a3a3a; }
.play-body .move-list .move-row span.move-highlight { background: #3a6ea5; color: #fff; }

.play-body #analysisChart { background: #1f1d1b; border-bottom: none; border-radius: 4px; }
.play-body #analysisChart:empty { display: none; }

.play-body .history-nav { display: flex; justify-content: center; gap: 6px; margin-top: 10px; }
.play-body .history-nav .btn { font-size: 16px; padding: 4px 14px; }

/* ---------- Lobi & log ---------- */
.play-body .lobby-games { display: flex; flex-wrap: wrap; gap: 6px; max-height: 120px; overflow-y: auto; }
.play-body .log-card summary { cursor: pointer; color: #9a9a9a; font-size: 13px; }
.play-body .log-panel {
    margin-top: 8px; max-height: 160px; overflow-y: auto;
    white-space: pre-wrap; font-family: monospace; font-size: 11px; color: #bfbfbf;
    background: #1f1d1b; border-radius: 4px; padding: 8px;
}
.play-body .log-panel:empty::before { content: 'Belum ada log.'; color: #666; }

/* ---------- Modal ---------- */
.play-body .modal {
    position: fixed; inset: 0; z-index: 1000;
    display: none; place-items: center;
    background: rgba(0, 0, 0, 0.65);
    padding: 16px; box-sizing: border-box;
    border-radius: 0; min-width: 0; box-shadow: none;
    color: #e8e8e8; text-align: left;
}
.play-body .modal.show { display: grid; }
.play-body .modal-content {
    background: #2b2b2b; border: 1px solid #444; border-radius: 8px;
    padding: 20px; width: min(440px, 100%); box-sizing: border-box; min-width: 0;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}
.play-body .modal-content.center { text-align: center; }
.play-body .modal-title { margin: 0 0 8px; font-size: 18px; }
.play-body .modal-subtitle { margin: 0 0 16px; font-size: 14px; color: #9a9a9a; }
/* UIManager menampilkan modal ini lewat style.display = 'block' */
.play-body #modal-searching .modal-content { margin: 20vh auto 0; }
.play-body .spinner {
    width: 32px; height: 32px; margin: 16px auto;
    border: 3px solid #555; border-top-color: #2e7d32; border-radius: 50%;
    animation: play-spin 1s linear infinite;
}
@keyframes play-spin { to { transform: rotate(360deg); } }

.play-body .form-group { margin-bottom: 14px; }
.play-body .form-group label { display: block; margin-bottom: 6px; font-size: 13px; color: #ccc; font-weight: 600; }
.play-body .input {
    width: 100%; box-sizing: border-box; padding: 10px;
    background: #1f1d1b; color: #e8e8e8; border: 1px solid #444; border-radius: 4px; font-size: 14px;
}
.play-body .input:focus { border-color: #2e7d32; outline: none; }
.play-body .auth-error { color: #ef4444; text-align: center; margin: 12px 0 0; min-height: 1em; }

.play-body .analysis-summary-container { gap: 16px; }
.play-body .player-summary h4 { margin: 8px 0; }

/* ---------- Responsif ---------- */
@media (max-width: 900px) {
    .game-layout { grid-template-columns: 1fr; }
    .board-col { max-width: 600px; width: 100%; margin: 0 auto; }
    .side-col { max-width: 600px; width: 100%; margin: 0 auto; }
    .play-body .move-list { max-height: 200px; }
}
@media (max-width: 480px) {
    .play-page { margin: 8px auto; padding: 0 8px; }
    .play-body .player-strip .p-clock { font-size: 17px; min-width: 64px; }
    .play-body .analysis-summary-container { grid-template-columns: 1fr; }
}
