body {
  padding: 0;
  margin: 0;
  width: 100%;
  background: #ffffff;
  -webkit-touch-callout: none;
  user-select: none;
}

.anarchy-shell {
  max-width: 520px;
  margin: 0 auto;
  padding: 0 12px;
}

.anarchy-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: #212529;
}

.preset-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

.preset-btn {
  border: 1px solid #ced4da;
  background: #f8f9fa;
  color: #495057;
  border-radius: 999px;
  padding: 3px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.preset-btn:hover {
  background: #e9ecef;
}

.preset-btn.active {
  background: #343a40;
  border-color: #343a40;
  color: #ffffff;
}

.daily-difficulty-bar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 3px;
  border-radius: 999px;
  background: #f1f3f5;
  border: 1px solid #dee2e6;
}

.daily-diff-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid transparent;
  background: transparent;
  color: #495057;
  border-radius: 999px;
  padding: 2px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.12s ease, color 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}

.daily-diff-btn:hover:not(.active) {
  color: #212529;
  background: rgba(255, 255, 255, 0.65);
}

.daily-diff-btn.active[data-difficulty="easy"] {
  background: #d4edda;
  border-color: #b1dfbb;
  color: #155724;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.daily-diff-btn.active[data-difficulty="medium"] {
  background: #fff3cd;
  border-color: #ffe69c;
  color: #856404;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.daily-diff-btn.active[data-difficulty="hard"] {
  background: #f8d7da;
  border-color: #f1aeb5;
  color: #721c24;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.daily-diff-check {
  font-size: 0.72rem;
  font-weight: 800;
  color: #137333;
}

.puzzle-meta {
  min-height: 1.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
}

.solved-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  background-color: #e6f4ea;
  color: #137333;
}

.timer-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  background-color: #f1f3f5;
  border: 1px solid #dee2e6;
  color: #495057;
}

.timer-badge.timer-running {
  background-color: #e7f5ff;
  border-color: #a5d8ff;
  color: #1864ab;
}

.timer-badge.timer-locked {
  background-color: #e6f4ea;
  border-color: #b7e1cd;
  color: #137333;
}

.unranked-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  background-color: #fff3cd;
  color: #856404;
}

.board-holder {
  display: flex;
  justify-content: center;
  margin: 8px 0;
}

.anarchy-board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  width: min(92vw, 448px);
  height: min(92vw, 448px);
  border: 2px solid #5a3e28;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  touch-action: none;
}

.chess-sq {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  border: none;
}

.chess-sq.sq-light {
  background-color: #f0d9b5;
}

.chess-sq.sq-dark {
  background-color: #b58863;
}

.chess-sq:hover {
  filter: brightness(0.96);
}

.chess-sq.sq-blocked {
  background: repeating-linear-gradient(
    45deg,
    #495057,
    #495057 6px,
    #343a40 6px,
    #343a40 12px
  );
  cursor: not-allowed;
}

.chess-sq.sq-conflict {
  background-color: #e05252;
}

.chess-sq.sq-dark.sq-conflict {
  background-color: #c93c3c;
}

.anarchy-board.board-spotlight .chess-sq:not(.sq-available):not(.sq-conflict):not(.sq-hint-remove)::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(24, 18, 12, 0.32);
  pointer-events: none;
  z-index: 1;
}

.chess-sq.sq-available {
  box-shadow: inset 0 0 0 1.5px rgba(255, 248, 225, 0.55);
}

.chess-sq.sq-unattacked-solved {
  box-shadow: inset 0 0 0 3px #17a2b8;
}

.chess-sq.sq-hinted {
  box-shadow: inset 0 0 0 3px #007bff;
}

.chess-sq.sq-hint-remove {
  background-color: #f6b93b;
  box-shadow: inset 0 0 0 3px #b33939;
}

.chess-sq.sq-dark.sq-hint-remove {
  background-color: #e58e26;
  box-shadow: inset 0 0 0 3px #8c2626;
}

.chess-sq.sq-dragging-origin .sq-piece {
  opacity: 0.3;
}

.chess-sq.sq-drop-target {
  box-shadow: inset 0 0 0 3px #212529;
  filter: brightness(1.06);
}

.threat-dot {
  width: 24%;
  height: 24%;
  border-radius: 50%;
  background: rgba(33, 37, 41, 0.24);
  pointer-events: none;
}

.chess-sq.sq-dark .threat-dot {
  background: rgba(20, 22, 25, 0.30);
}

.sq-piece {
  position: relative;
  z-index: 2;
  width: 82%;
  height: 82%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.sq-piece svg {
  width: 100%;
  height: 100%;
  display: block;
}

.sq-coord {
  position: absolute;
  z-index: 2;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  pointer-events: none;
  opacity: 0.75;
}

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

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

.chess-sq.sq-light .sq-coord {
  color: #b58863;
}

.chess-sq.sq-dark .sq-coord {
  color: #f0d9b5;
}

.chess-sq.sq-conflict .sq-coord {
  color: #ffffff;
}

.chess-sq.sq-hint-remove .sq-coord {
  color: #212529;
}

.tray-holder {
  display: flex;
  justify-content: center;
  margin-top: 10px;
}

.piece-tray {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  min-height: 58px;
}

.tray-card {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 2px solid #dee2e6;
  background: #f8f9fa;
  cursor: grab;
  touch-action: none;
  transition: transform 0.1s ease, border-color 0.12s ease, background-color 0.12s ease;
}

.tray-card:active:not(.tray-card-empty) {
  cursor: grabbing;
}

.tray-card:hover:not(.tray-card-empty) {
  border-color: #adb5bd;
}

.tray-card.tray-card-selected {
  border-color: #212529;
  background: #e9ecef;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.tray-card.tray-card-empty {
  opacity: 0.42;
  cursor: default;
}

.tray-piece-icon {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tray-piece-icon svg {
  width: 100%;
  height: 100%;
}

.tray-count {
  font-size: 0.92rem;
  font-weight: 700;
  color: #212529;
}

#hint-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  vertical-align: middle;
}

.hint-cooldown-spinner {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  display: block;
}

.hint-spinner-track {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.6;
  opacity: 0.25;
}

.hint-spinner-arc {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.6;
  stroke-linecap: butt;
}

.hint-cooldown-spinner.hint-spinner-indeterminate {
  animation: hint-spinner-rotate 0.8s linear infinite;
}

.hint-cooldown-spinner.hint-spinner-indeterminate .hint-spinner-arc {
  stroke-linecap: round;
}

@keyframes hint-spinner-rotate {
  to {
    transform: rotate(360deg);
  }
}

.status-banner {
  max-width: 448px;
  margin: 10px auto;
  text-align: center;
  font-size: 0.92rem;
}

.faq-holder {
  max-width: 448px;
  margin: 8px auto 0 auto;
}

.controls-card {
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 8px;
}

.highlight-threshold-row {
  display: flex;
  align-items: center;
}

.highlight-threshold-input {
  width: 68px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.leaderboard-section {
  max-width: 448px;
  margin: 10px auto;
}

.leaderboard-submit-box {
  background: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 8px;
  padding: 8px 10px;
  text-align: center;
}

.leaderboard-submit-form {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}

.leaderboard-nickname-input {
  max-width: 180px;
  font-weight: 600;
}

.leaderboard-submit-feedback {
  color: #495057;
}

.leaderboard-submit-feedback.feedback-error {
  color: #c92a2a;
}

.leaderboard-submit-feedback.feedback-ok {
  color: #137333;
  font-weight: 600;
}

.leaderboard-card {
  border: 1px solid #dee2e6;
  border-radius: 8px;
  background: #ffffff;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.leaderboard-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 12px 2px 12px;
  background: #f8f9fa;
}

.leaderboard-card-title {
  font-size: 0.86rem;
  font-weight: 700;
  color: #212529;
}

.leaderboard-count-badge {
  font-size: 0.74rem;
  font-weight: 600;
  color: #6c757d;
}

.leaderboard-card-subtitle {
  padding: 0 12px 6px 12px;
  font-size: 0.72rem;
  color: #6c757d;
  background: #f8f9fa;
  border-bottom: 1px solid #e9ecef;
}

.leaderboard-body {
  max-height: 240px;
  overflow-y: auto;
}

.leaderboard-empty {
  padding: 12px;
  text-align: center;
  font-size: 0.82rem;
  color: #6c757d;
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.81rem;
  font-variant-numeric: tabular-nums;
}

.leaderboard-table th {
  padding: 5px 10px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: #6c757d;
  border-bottom: 1px solid #e9ecef;
  background: #fcfcfd;
}

.leaderboard-table td {
  padding: 5px 10px;
  border-bottom: 1px solid #f1f3f5;
  color: #212529;
}

.leaderboard-table tr:last-child td {
  border-bottom: none;
}

.leaderboard-table .col-rank {
  width: 38px;
  text-align: center;
  font-weight: 700;
  color: #495057;
}

.leaderboard-table .col-player {
  text-align: left;
  font-weight: 600;
}

.leaderboard-table .col-num {
  width: 62px;
  text-align: right;
}

.leaderboard-table .col-time {
  width: 74px;
  text-align: right;
  font-weight: 600;
}

.leaderboard-row-you td {
  background: #edf7ed;
}

.leaderboard-you-pill {
  display: inline-block;
  margin-left: 5px;
  padding: 0 5px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  background: #137333;
  color: #ffffff;
  vertical-align: middle;
}

.leaderboard-separator td {
  text-align: center;
  padding: 2px 10px;
  font-size: 0.72rem;
  color: #868e96;
  background: #f8f9fa;
}

.drag-ghost {
  position: fixed;
  width: 52px;
  height: 52px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 9999;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.28));
}

.drag-ghost svg {
  width: 100%;
  height: 100%;
  display: block;
}
