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

:root{
  --bg:#e9eaee;
  --panel:#f5f6f8;
  --panel-dark:#4b5563;
  --square-light:#f7f7f9;
  --square-dark:#dfe3ea;
  --text:#1f2937;
  --muted:#6b7280;
  --border:#d1d5db;
  --selected:#c7d2e3;
}

body{
  font-family:Segoe UI,Tahoma,Geneva,Verdana,sans-serif;
  background:var(--bg);
  color:var(--text);
  min-height:100vh;
  display:flex;
  justify-content:center;
  padding:20px;
}

.main-menu {
  width: 100%;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 80vh;
}

.menu-brand {
  margin-bottom: 50px;
}

.menu-logo {
  font-size: 90px;
  color: var(--text);
  display: block;
  margin-bottom: 10px;
  line-height: 1;
}

.menu-brand h1 {
  font-size: 36px;
  font-weight: 700;
}

.menu-modes {
  display: flex;
  gap: 36px;
  margin-top: 20px;
  margin-bottom: 40px;
  font-size: 16px;
  color: var(--muted);
}

.mode-option {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  font-weight: 600;
}

.mode-option.active {
  color: var(--text);
  }

.mode-icon {
  transform: scale(1.2) translateY(-1px);
  font-weight: 400;
}

.menu-actions {
  width: 100%;
  max-width: 300px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 40px;
}

.menu-btn {
  width: 100%;
  padding: 14px;
  margin-inline: 4px;
  border-radius: 16px;
  font-weight: 600;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  font-size: 16px;
}

.menu-btn:disabled {
  opacity: 0.4;
  background: transparent;
}

.menu-quotes {
  position: relative;
  max-width: 160px;
  margin: 10px auto 20px auto;
}

.menu-quotes p {
  font-size: 14px;
  font-style: italic;
  color: var(--muted);
  line-height: 1.5;
  position: relative;
}

.menu-quotes::before {
  content: "“";
  position: absolute;
  left: -10px;
  top: -20px;
  font-size: 32px;
  font-family: Georgia, serif;
  color: var(--border);
  line-height: 1;
  }

.menu-difficulty {
  width: 100%;
}

.menu-difficulty p {
  font-size: 14px;
  margin-bottom: 16px;
}

.diff-selector {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 500;
}

.diff-arrow {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  color: var(--text);
  padding: 8px;
  transform: translateY(-1px)
}

.diff-arrow:hover {
  color: var(--muted);
}

.app-footer {
  margin-top: 64px;
  width: 100%;
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  pointer-events: none;
  user-select: none;
}

.app{
  width:100%;
  max-width:520px;
}

.topbar{
  display:flex;
  justify-content:space-between;
  align-items:center;
  margin-bottom:16px;
}

.brand h1{
  font-size:28px;
  font-weight:700;
}

.brand h1 span {
  font-weight:400;
}

.brand p{
  color:var(--muted);
  margin-top:4px;
  font-size:14px;
}

.status-indicator {
  border-radius: 50%;
  margin-left: 4px;
  display: inline-block;
  animation: pulse-green 1s infinite;
}

@keyframes pulse-green {
  0% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
  }
  90% {
    box-shadow: 0 0 0 6px rgba(34, 197, 94, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
  }
}

.ghost-btn,
.action-btn{
  border:none;
  cursor:pointer;
  border-radius:12px;
  padding:10px 16px;
  font-weight:600;
}

.ghost-btn{
  background:white;
  border:1px solid var(--border);
}

.action-btn{
  background:white;
  border:1px solid var(--border);
}
 
.action-btn:disabled,
.ghost-btn:disabled {
  opacity: 0.4;
  pointer-events: none;
}

.status-card{
  background:var(--panel);
  border-radius:16px;
  padding:16px;
  margin-bottom:18px;
  box-shadow:0 2px 10px rgba(0,0,0,.04);
}

.status-row{
  display:flex;
  justify-content:space-between;
}

.status-row + .status-row{
  margin-top:10px;
}

.board-wrapper{
  display:flex;
  justify-content:center;
}

.board{
  display:grid;
  grid-template-columns:repeat(8,58px);
  grid-template-rows:repeat(8,58px);
  gap:4px;
  border-top:4px solid var(--bg);
  border-bottom:4px solid var(--bg);
  border-radius:12px;
}

.board-danger {
  box-shadow: 
    0 -8px 18px -18px rgb(220, 38, 38), 
    0 8px 18px -18px rgb(220, 38, 38);
  animation: flashDanger 0.5s infinite alternate;
}

@keyframes flashDanger {
  from { box-shadow: 
    0 -8px 18px -18px rgb(220, 38, 38), 
    0 8px 18px -18px rgb(220, 38, 38); }
  to { box-shadow: unset; }
}

.square{
  width:58px;
  height:58px;
  border-radius:12px;
  display:flex;
  justify-content:center;
  align-items:center;
  cursor:pointer;
  user-select:none;
  position:relative;
}

.light{
  background:var(--square-light);
}

.dark{
  background:var(--square-dark);
}

.square.selected{
  outline:4px solid var(--selected);
}

.piece{
  font-size:38px;
  pointer-events:none;
}

.white-piece{
  color:#474b52;
}

.black-piece{
  color:#1f2937;
}

.piece.pawn-piece {
  transform: scale(0.8);
  transform-origin: center;
  }

.square span, .white-piece, .black-piece {
  display: inline-block; /* Wajib agar elemen span bisa di-rotate oleh CSS */
}

.move-dot{
  width:14px;
  height:14px;
  border-radius:50%;
  background:rgba(80,110,180,.28);
  position:absolute;
}

.board-coord {
  position: absolute;
  font-size: 10px;
  font-weight: bold;
  font-family: sans-serif;
  pointer-events: none;
}

.rank-coord {
  top: 2px;
  left: 4px;
}

.file-coord {
  bottom: 2px;
  right: 4px;
}

.light .board-coord {
  color: var(--square-dark);
}

.dark .board-coord {
  color: var(--square-light);
}

.pgn-area {
  margin-top: 12px;
  display: block;
}

.pgn-block {
  background: var(--panel);
  border-radius: 14px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
}

.pgn-block label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--muted);
}

#pgn-log {
  font-size:13px;
  color:var(--muted);
  word-break: break-all;
  min-height: 34px;
}

.captured-area{
  margin-top:20px;
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:12px;
}

.captured-block{
  background:var(--panel);
  border-radius:14px;
  padding:12px 14px;
  display: flex;
  flex-direction: column;
}

.captured-block label{
  display:block;
  margin-bottom:8px;
  font-size:13px;
  color:var(--muted);
}

#captured-white,
#captured-black {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  align-items: center;
  min-height: 28px;
}

.bottom-panel{
  margin-top:20px;
  display:flex;
  gap:10px;
}

.bottom-panel .action-btn{
  flex:1;
}

.ai-thinking{
  color:#dc2626;
  animation:blink 1s infinite;
}

@keyframes blink{
  0%{opacity:1;}
  50%{opacity:.4;}
  100%{opacity:1;}
}

/* FASE 2: Modal Styling */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  padding: 64px 16px;
}

.modal-content {
  background: white;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 30px rgba(0,0,0,0.15);
  animation: slideUp 0.3s ease-out;
}

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

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 { font-size: 20px; font-weight: 700; }
.close-btn { background: none; border: none; font-size: 24px; cursor: pointer; color: var(--muted); }

.modal-body {
  padding: 20px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--panel-dark) transparent;
}

.recap-section { margin-bottom: 22px; }
.recap-section h3 { font-size: 14px; text-transform: uppercase; color: var(--muted); letter-spacing: 0.5px; margin-bottom: 10px; }

.summary-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 8px; }
.summary-cards .card { padding: 12px; border-radius: 12px; display: flex; flex-direction: column; }
.w-card { background: var(--panel); border: 1px solid var(--border); }
.b-card { background: var(--panel-dark); color: white; }

.player-label { font-size: 11px; opacity: 0.8; }
.acc-val { font-size: 24px; font-weight: 700; margin: 2px 0; }
.rating-val { font-size: 12px; font-weight: 600; opacity: 0.9; }

.recap-text { font-size: 13px; margin-top: 6px; }

.recap-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.recap-table th { background: var(--panel); text-align: left; padding: 6px 8px; font-weight: 600; }
.recap-table td { padding: 6px 8px; border-bottom: 1px solid var(--panel); }

.recap-list { font-size: 13px; padding-left: 16px; line-height: 1.6; }

.elo-container { display: flex; justify-content: space-between; background: var(--panel); padding: 10px 14px; border-radius: 10px; font-size: 13px; }
.elo-up { color: #16a34a; font-weight: 600; }
.elo-down { color: #dc2626; font-weight: 600; }

.timeline-box { background: var(--panel); padding: 12px; border-radius: 12px; font-size: 12px; line-height: 1.5; color: var(--text); }

.modal-footer { padding: 16px 20px; border-top: 1px solid var(--border); }
.modal-footer .action-btn { width: 100%; padding: 12px; border-radius: 12px; font-size: 15px; }

@media (max-width:540px){

  .board{
    grid-template-columns:repeat(8,44px);
    grid-template-rows:repeat(8,44px);
  }

  .square{
    width:44px;
    height:44px;
  }

  .piece{
    font-size:30px;
  }
}
