body {
  margin: 0;
  padding: 0;
  background: linear-gradient(135deg, #1a1a24 0%, #121218 100%);
  font-family: 'Inter', sans-serif;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
}

.player-count {
  width: 83%;
  margin-top: 10px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
}

.app-container {
  width: 100%;
  min-height: 100vh;
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  gap: 32px;
  align-items: center;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(240px, 260px) minmax(500px, 1fr) minmax(240px, 280px);
  gap: 32px;
  width: 90%;
  max-width: 1400px;
  align-items: start;
}

.app-title {
  margin: 0;
  text-align: center;
  font-size: 36px;
  font-weight: 800;
  color: #ffffff;
  text-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  letter-spacing: 2px;
  background: linear-gradient(90deg, #f3e5f5, #e0d4c3);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.board-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
}
.display-No {
  display: none;
}

.waitt {
  display: none;
}
#main-element.search-active {
  position: fixed;
  inset: 0;
  z-index: 1500;
  display: block;
  background: rgba(8, 8, 12, 0.4);      
  backdrop-filter: blur(28px);           
  -webkit-backdrop-filter: blur(28px);
  animation: fadeIn 0.3s ease-in-out;
}
#waitingJoin.search-visible {
  display: block;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1600;
  margin: 0;
  text-align: center;
  font-size: 50px;
  font-weight: 700;
  color: #f0b429;
  text-shadow: 0 0 20px rgba(240, 180, 41, 0.5),
               0 4px 12px rgba(0, 0, 0, 0.6);
  letter-spacing: 2px;
  animation: pulse 1.5s infinite;
}

#root {
  display: flex;
  flex-direction: column;
  width: fit-content;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
  border-radius: 8px;
  overflow: hidden;
  border: 4px solid #2a2a35;
}

.left-panel{
  background: rgba(42, 42, 53, 0.45);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.25);
}

.left-panel {
  align-items: center;
}

#start-btn {
  background: linear-gradient(135deg, #2e7d32, #1b5e20);
  box-shadow: 0 4px 14px rgba(46, 125, 50, 0.35);
}

#start-btn.started {
  background: linear-gradient(135deg, #f9a825, #e65100);
  box-shadow: 0 4px 14px rgba(249, 168, 37, 0.35);
}

#start-btn:hover {
  filter: brightness(1.12);
  transform: translateY(-1px);
}

#offline-btn {
  background: linear-gradient(135deg, #1565c0, #0d47a1);
  box-shadow: 0 4px 14px rgba(21, 101, 192, 0.35);
}

#offline-btn:hover {
  filter: brightness(1.12);
  transform: translateY(-1px);
}

#offline-btn:disabled,
#offline-btn.disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.4);
  transform: none;
}

#offline-btn:disabled:hover,
#offline-btn.disabled:hover {
  filter: grayscale(0.4);
  transform: none;
}
.right-panel {
  width: 100%;
  max-width: 300px;
  min-height: 600px;
  height: min(70vh, 650px);
  max-height: 650px;
  background: rgba(42, 42, 53, 0.45);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.divider {
  width: 100%;
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
  margin: 0;
}

.clock {
  width: 90%;
  height: 68px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 1.9rem;
  font-weight: 700;
  text-align: left;
  padding: 0 18px;
  border-radius: 14px;
  letter-spacing: 2px;
  box-sizing: border-box;
}

.clock-label {
  display: block;
  font-size: 0.92rem;
  font-weight: 500;
  letter-spacing: 0;
  opacity: 0.8;
}

.clock-time {
  font-size: 1.95rem;
  font-weight: 800;
  letter-spacing: 2px;
}

.clock.active {
  background-color: #d9a43a;
  color: #1a1408;
  box-shadow: 0 0 10px rgba(217, 164, 58, 0.35);
}

.clock.inactive {
  background-color: #2a2a2a;
  color: #888;
}

.left-panel select,
.left-panel .action-btn {
  width: 100%;
}

.left-panel select {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.left-panel select:focus {
  outline: none;
  border-color: #f5a623;
  box-shadow: 0 0 0 4px rgba(245, 166, 35, 0.15);
}

.left-panel select:disabled,
.left-panel select.disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.08);
}

.left-panel select option {
  background: #1a1a24;
  color: #fff;
}

.left-panel .action-btn,
.left-panel .action-btn.secondary {
  padding: 12px 16px;
}

.move-history {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 15px;
  padding-right: 8px;
}
.squareRow {
  display: flex;
}

/* Black's perspective: reverse rank order and file order within each rank.
   Pieces stay upright since only the flex layout is mirrored. */
#root.flipped {
  flex-direction: column-reverse;
}

#root.flipped .squareRow {
  flex-direction: row-reverse;
}

.square {
  position: relative;
  width: 75px;
  height: 75px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.white {
  background-color: #E2D1B8;
}

.black {
  background-color: #93705C;
}

.highlightYellow {
  background-color: rgba(249, 168, 37, 0.6) !important;
}

.piece {
  width: 85%;
  cursor: pointer;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.4));
  transition: transform 0.1s ease;
}

.piece:hover {
  transform: scale(1.05);
}

.captureColor {
  background-color: rgba(229, 57, 53, 0.8) !important;
}

.highlight {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 24px;
  height: 24px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background-color: rgba(0, 0, 0, 0.25);
  pointer-events: none;
}

.sidebar-header {
  width: 100%;
  box-sizing: border-box;
  margin: 0 0 12px;
  padding: 18px 16px;

  text-align: center;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 1px;

  color: #fff;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  border-top-left-radius: 18px;
  border-top-right-radius: 18px;
  white-space: normal;
  word-break: break-word;
}

.action-btn {
  background: linear-gradient(135deg, #F9A825, #e65100);
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 6px;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 100%;
  box-shadow: 0 4px 14px rgba(249, 168, 37, 0.35);
}

.move-history::-webkit-scrollbar {
  width: 6px;
}

.move-history::-webkit-scrollbar-track {
  background: transparent;
}

.move-history::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 10px;
}

.move-row {
  display: flex;
  margin-bottom: 8px;
  background: rgba(0, 0, 0, 0.15);
  border-radius: 6px;
  overflow: hidden;
}

.move-num {
  padding: 8px 12px;
  color: #888;
  font-weight: 600;
  background: rgba(0, 0, 0, 0.2);
  font-size: 14px;
}

.move-w,
.move-b {
  flex: 1;
  padding: 8px 12px;
  color: #e0e0e0;
  font-size: 15px;
  text-align: center;
  font-weight: 500;
}

.move-b {
  color: #aaa;
}

.modal {
  display: flex;
  justify-content: center;
  align-items: center;
  position: fixed;
  top: 0;
  bottom: 0;
  right: 0;
  left: 0;
  z-index: 1000;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(5px);
}

.promotion-box {
  background: rgba(42, 42, 53, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 30px;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
  gap: 20px;
}

.promotion-title {
  font-family: 'Inter', sans-serif;
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.promotion-images {
  display: flex;
  gap: 15px;
  background: rgba(0, 0, 0, 0.2);
  padding: 15px;
  border-radius: 12px;
}

.promotion-images img {
  width: 70px;
  height: 70px;
  cursor: pointer;
  transition: all 0.2s ease;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.4));
  border-radius: 8px;
  padding: 5px;
}

.promotion-images img:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-5px) scale(1.1);
}

.game-over {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;

  background-color: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);

  display: flex;
  justify-content: center;
  align-items: center;
  
  z-index: 1000;
  opacity: 0;
  animation: fadeIn 0.4s ease forwards;
}

.game-over-box {
  background: rgba(48, 46, 43, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  padding: 40px 60px;
  border-radius: 16px;
  text-align: center;
  transform: translateY(20px);
  animation: slideUp 0.4s ease forwards 0.1s;
  opacity: 0;
}

#game-over-message {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  color: #fff;
  font-size: 36px;
  font-weight: bold;
  margin-bottom: 30px;
  margin-top: 0;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
  letter-spacing: 1px;
}

#restart-btn {
  background: linear-gradient(135deg, #F9A825, #E08B00);
  border: none;
  padding: 12px 30px;
  color: #fff;
  font-size: 18px;
  font-weight: bold;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 10px rgba(249, 168, 37, 0.3);
}

#restart-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 15px rgba(249, 168, 37, 0.4);
  background: linear-gradient(135deg, #ffb53e, #f19803);
}

#restart-btn:active {
  transform: translateY(1px);
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    transform: translateY(30px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}