* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #1e2124;
  color: #eee;
  display: flex;
  justify-content: center;
  min-height: 100vh;
  padding: 24px 12px;
}

.screen { width: 100%; max-width: 480px; text-align: center; }
.hidden { display: none !important; }

h1 { font-size: 1.6rem; margin-bottom: 20px; }

.card {
  background: #2a2d31;
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 16px;
}

button {
  cursor: pointer;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 1rem;
  background: #3a3d42;
  color: #eee;
}
button.primary { background: #4caf50; color: white; font-weight: 600; }
button:hover { filter: brightness(1.1); }
button:disabled { opacity: 0.5; cursor: default; }

.hint { color: #999; font-size: 0.85rem; margin-top: 8px; }
.error { color: #e57373; font-size: 0.85rem; min-height: 1em; }

.join-row, .link-row { display: flex; gap: 8px; }
#roomInput, #shareLink {
  flex: 1;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid #444;
  background: #1e2124;
  color: #eee;
  font-size: 1rem;
  text-align: center;
  text-transform: uppercase;
}

.topbar { display: flex; justify-content: space-between; margin-bottom: 10px; font-weight: 600; }

.name-input {
  width: 100%;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid #444;
  background: #1e2124;
  color: #eee;
  font-size: 1rem;
  text-align: center;
}

.player-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 4px;
  transition: background-color 0.2s;
  border-radius: 6px;
}
.player-row.active-turn { background: rgba(76, 175, 80, 0.18); }
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}
.avatar.avatar-white { background: #eeeed2; color: #333; }
.avatar.avatar-black { background: #3a3d42; color: #eee; border: 1px solid #666; }
.pname { flex: 1; text-align: left; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pclock {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  background: #1e2124;
  padding: 3px 8px;
  border-radius: 6px;
  min-width: 3em;
  text-align: center;
}
.player-row.active-turn .pclock { color: #4caf50; }

.hints-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-end;
  font-size: 0.78rem;
  color: #888;
  cursor: pointer;
  margin-bottom: 4px;
  user-select: none;
}
.hints-toggle input { cursor: pointer; }
.status {
  min-height: 1.4em;
  margin-bottom: 10px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  transition: background-color 0.2s, color 0.2s;
}
.status.your-turn {
  background: #4caf50;
  color: #fff;
}
.status.invalid-flash {
  background: #e53935;
  color: #fff;
  animation: shake 0.3s;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 6px;
  overflow: hidden;
  border: 2px solid #444;
}
.square {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: min(9.5vw, 58px);
  user-select: none;
  cursor: pointer;
  position: relative;
}
.square.light { background: #eeeed2; }
.square.dark { background: #769656; }
.square.selected { outline: 3px solid #ffeb3b; outline-offset: -3px; }
.square.last-move { background-color: #f6f669; }
.square.dark.last-move { background-color: #baca44; }

.coord {
  position: absolute;
  font-size: 0.32em;
  font-weight: 700;
  opacity: 0.65;
  user-select: none;
  pointer-events: none;
}
.coord-rank { top: 2px; left: 3px; }
.coord-file { bottom: 1px; right: 3px; }
.square.light .coord { color: #769656; }
.square.dark .coord { color: #eeeed2; }

.hint-dot {
  position: absolute;
  width: 28%;
  height: 28%;
  border-radius: 50%;
  background: rgba(20, 20, 20, 0.22);
  pointer-events: none;
}
.square.hint-capture {
  box-shadow: inset 0 0 0 4px rgba(20, 20, 20, 0.28);
}
.square .piece-white {
  color: #fbfbfb;
  -webkit-text-stroke: 1.5px #2b2b2b;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.5);
}
.square .piece-black {
  color: #111;
  -webkit-text-stroke: 1px #111;
  text-shadow: 0 0 2px #fff, 0 0 2px #fff;
}

.controls { display: flex; justify-content: center; gap: 10px; margin: 14px 0; }

.history {
  text-align: left;
  background: #2a2d31;
  border-radius: 8px;
  padding: 10px 10px 10px 30px;
  max-height: 140px;
  overflow-y: auto;
  font-size: 0.9rem;
  columns: 2;
}
