/* =========================================================================
   GAME WORKSPACE & PHOTOREALISTIC 3D REVERSI BOARD
   ========================================================================= */
.workspace {
  max-width: 1040px;
  margin: 0 auto;
  padding: 16px 12px 36px;
  display: grid;
  grid-template-columns: auto minmax(260px, 325px);
  gap: 18px;
  justify-content: center;
  align-items: start;
}

.board-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  width: fit-content;
}

.reconnect-banner {
  width: 100%;
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(254, 244, 224, 0.96);
  border: 1.5px solid #c27803;
  color: #7c4a03;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

/* Player Strip */
.player-strip {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 12px;
  border-radius: 9px;
  background: rgba(252, 248, 240, 0.94);
  border: 1px solid var(--panel-border);
  box-shadow: 0 4px 12px -6px rgba(60, 40, 15, 0.16);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.player-strip.active-turn {
  border-color: var(--gold);
  box-shadow: 0 0 0 1.5px rgba(140, 101, 37, 0.45), 0 6px 16px -8px rgba(100, 68, 18, 0.35);
}
.player-ident {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.side-tag {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
}
.player-name {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-main);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 190px;
}
.strip-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.score-pill {
  min-width: 34px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--panel-bg-soft);
  border: 1px solid rgba(133, 102, 60, 0.28);
  font-size: 13.5px;
  font-weight: 800;
  text-align: center;
  color: var(--gold-bright);
  font-variant-numeric: tabular-nums;
}
.clock-box {
  padding: 3px 10px;
  border-radius: 6px;
  background: var(--panel-bg-soft);
  border: 1px solid rgba(133, 102, 60, 0.28);
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-main);
  white-space: nowrap;
}
.clock-box.byoyomi {
  border-color: rgba(166, 28, 28, 0.5);
  color: var(--vermilion);
  background: #fdf2f1;
}
.clock-box.low {
  background: #f9d8d5;
  color: #841212;
  border-color: var(--vermilion);
}

/* Mini Disc Badges */
.disc-badge {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
  position: relative;
}
.disc-badge.sm {
  width: 13px;
  height: 13px;
}
.disc-badge.black {
  background: radial-gradient(circle at 32% 28%, #525962 0%, #1d2126 42%, #090b0d 100%);
  border: 1px solid #040507;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.45), inset 0 1px 1px rgba(255, 255, 255, 0.25);
}
.disc-badge.white {
  background: radial-gradient(circle at 32% 28%, #ffffff 0%, #f5efe2 55%, #cfc2ab 100%);
  border: 1px solid #9f8f76;
  box-shadow: 0 1px 3px rgba(40, 28, 12, 0.35), inset 0 1px 1px rgba(255, 255, 255, 0.9);
}

/* Real-time Disc Balance Bar */
.disc-balance-bar {
  width: 100%;
  height: 7px;
  border-radius: 999px;
  overflow: hidden;
  display: flex;
  background: #d8ccb8;
  border: 1px solid rgba(133, 102, 60, 0.35);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.22);
}
.balance-fill {
  height: 100%;
  transition: width 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}
.balance-fill.black {
  background: linear-gradient(180deg, #3b4048, #121518);
}
.balance-fill.white {
  background: linear-gradient(180deg, #ffffff, #e6dcc9);
}

/* =========================================================================
   PHOTOREALISTIC WALNUT & TOURNAMENT WOOL FELT BOARD
   ========================================================================= */
.board-frame {
  position: relative;
  padding: 18px 20px;
  border-radius: 12px;
  background-color: #462813;
  background-image:
    var(--tex-wood, none),
    linear-gradient(145deg, rgba(130, 82, 42, 0.55) 0%, rgba(56, 31, 13, 0.45) 55%, rgba(28, 14, 5, 0.72) 100%);
  background-size: 280px 280px, 100% 100%;
  border: 2px solid #261407;
  box-shadow:
    0 24px 48px -14px rgba(22, 12, 4, 0.62),
    0 8px 18px -6px rgba(22, 12, 4, 0.45),
    inset 0 2px 3px rgba(255, 224, 178, 0.28),
    inset 0 -3px 6px rgba(10, 5, 1, 0.72),
    inset 0 0 0 1px rgba(212, 170, 102, 0.24);
  user-select: none;
}

/* Brushed Antique Brass Corner Brackets */
.board-brass-corner {
  position: absolute;
  width: 22px;
  height: 22px;
  pointer-events: none;
  z-index: 3;
  opacity: 0.85;
}
.board-brass-corner::before,
.board-brass-corner::after {
  content: "";
  position: absolute;
  background: linear-gradient(135deg, #f3d78e, #9f7126 55%, #5e3e0c);
  border-radius: 1px;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.45);
}
.board-brass-corner.tl { top: 6px; left: 6px; }
.board-brass-corner.tl::before { top: 0; left: 0; width: 16px; height: 2.5px; }
.board-brass-corner.tl::after { top: 0; left: 0; width: 2.5px; height: 16px; }
.board-brass-corner.tr { top: 6px; right: 6px; }
.board-brass-corner.tr::before { top: 0; right: 0; width: 16px; height: 2.5px; }
.board-brass-corner.tr::after { top: 0; right: 0; width: 2.5px; height: 16px; }
.board-brass-corner.bl { bottom: 6px; left: 6px; }
.board-brass-corner.bl::before { bottom: 0; left: 0; width: 16px; height: 2.5px; }
.board-brass-corner.bl::after { bottom: 0; left: 0; width: 2.5px; height: 16px; }
.board-brass-corner.br { bottom: 6px; right: 6px; }
.board-brass-corner.br::before { bottom: 0; right: 0; width: 16px; height: 2.5px; }
.board-brass-corner.br::after { bottom: 0; right: 0; width: 2.5px; height: 16px; }

.coord-top,
.coord-bottom {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  width: var(--board-size);
  margin: 0 auto;
  padding: 0 2px;
  font-size: 11px;
  font-weight: 700;
  color: rgba(235, 206, 152, 0.85);
  text-shadow: 0 1px 1px rgba(10, 5, 1, 0.85);
  letter-spacing: 0.04em;
}
.coord-top { margin-bottom: 4px; }
.coord-bottom { margin-top: 4px; }
.coord-top span,
.coord-bottom span { text-align: center; }

.board-row-wrap {
  display: flex;
  align-items: stretch;
  gap: 5px;
}

.coord-left,
.coord-right {
  display: grid;
  grid-template-rows: repeat(8, 1fr);
  width: 14px;
  font-size: 11px;
  font-weight: 700;
  color: rgba(235, 206, 152, 0.85);
  text-shadow: 0 1px 1px rgba(10, 5, 1, 0.85);
}
.coord-left span,
.coord-right span {
  display: flex;
  align-items: center;
  justify-content: center;
}

.board-stage {
  position: relative;
  width: var(--board-size);
  height: var(--board-size);
  padding: 3px;
  border-radius: 5px;
  background: #0d2b1a;
  box-shadow:
    inset 0 3px 10px rgba(0, 0, 0, 0.72),
    0 1px 0 rgba(255, 224, 178, 0.25);
}

.reversi-grid {
  position: relative;
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  border-radius: 3px;
  overflow: hidden;
  background-color: #165231;
  background-image:
    radial-gradient(ellipse 68% 62% at 38% 34%, rgba(168, 224, 178, 0.14) 0%, transparent 62%),
    radial-gradient(circle at 50% 50%, transparent 56%, rgba(4, 18, 9, 0.42) 100%),
    var(--tex-felt, none),
    linear-gradient(155deg, var(--felt-light) 0%, var(--felt-mid) 58%, var(--felt-dark) 100%);
  background-size: 100% 100%, 100% 100%, 180px 180px, 100% 100%;
  box-shadow: inset 0 0 18px rgba(4, 22, 11, 0.65);
}

/* Official 4 Star Dots at (c3, g3, c7, g7) corners -> 25% & 75% grid intersections */
.board-stars {
  position: absolute;
  inset: 3px;
  pointer-events: none;
  z-index: 2;
}
.board-stars span {
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #234f34, #071b0f);
  box-shadow: 0 1px 0 rgba(168, 224, 178, 0.25);
  transform: translate(-50%, -50%);
}
.board-stars span:nth-child(1) { left: 25%; top: 25%; }
.board-stars span:nth-child(2) { left: 75%; top: 25%; }
.board-stars span:nth-child(3) { left: 25%; top: 75%; }
.board-stars span:nth-child(4) { left: 75%; top: 75%; }

/* Pass Cut-in Overlay */
.pass-overlay {
  position: absolute;
  inset: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 22, 14, 0.42);
  backdrop-filter: blur(2px);
  pointer-events: none;
  animation: passFade 0.24s ease-out;
}
.pass-card {
  padding: 14px 28px;
  border-radius: 10px;
  background: rgba(252, 247, 236, 0.96);
  border: 2px solid var(--gold);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.45);
  text-align: center;
}
.pass-title {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0.25em;
  color: var(--gold-bright);
}
.pass-sub {
  font-size: 12px;
  color: var(--text-sub);
  margin-top: 2px;
}
@keyframes passFade {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

/* Individual Cell */
.cell {
  position: relative;
  border-right: 1px solid rgba(5, 22, 11, 0.56);
  border-bottom: 1px solid rgba(5, 22, 11, 0.56);
  box-shadow: inset 1px 1px 0 rgba(162, 220, 178, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  perspective: 520px;
  cursor: default;
  transition: background-color 0.14s;
}
.cell:nth-child(8n) { border-right: none; }
.cell:nth-child(n+57) { border-bottom: none; }

.cell.last-move-sq {
  background: radial-gradient(circle at 50% 50%, rgba(240, 200, 108, 0.16) 0%, transparent 72%);
}

.cell.legal {
  cursor: pointer;
}
.cell.legal:hover {
  background: rgba(255, 244, 196, 0.12);
}

/* Legal Move Dot */
.legal-dot {
  position: absolute;
  width: 24%;
  height: 24%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(246, 224, 152, 0.78) 0%, rgba(212, 168, 72, 0.48) 70%, transparent 100%);
  box-shadow: 0 0 8px rgba(244, 212, 128, 0.45);
  pointer-events: none;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.cell.legal.show-guide .legal-dot {
  opacity: 1;
  transform: scale(1);
}
.cell.legal:hover .legal-dot {
  opacity: 0;
}

/* Hover Ghost Disc & Flip Count Chip */
.ghost-disc {
  position: absolute;
  width: 82%;
  height: 82%;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  transform: scale(0.86);
  transition: opacity 0.12s ease, transform 0.12s ease;
  z-index: 4;
}
.cell.legal:hover .ghost-disc {
  opacity: 0.48;
  transform: scale(1);
}
.ghost-disc.black {
  background: radial-gradient(circle at 35% 30%, #444a52, #0d1013);
  border: 1px solid rgba(255, 255, 255, 0.18);
}
.ghost-disc.white {
  background: radial-gradient(circle at 35% 30%, #ffffff, #dcd2be);
  border: 1px solid rgba(0, 0, 0, 0.25);
}

.flip-count-tip {
  position: absolute;
  z-index: 6;
  font-size: 11px;
  font-weight: 800;
  color: #fffdf6;
  background: rgba(20, 14, 8, 0.78);
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid rgba(240, 200, 112, 0.65);
  pointer-events: none;
  opacity: 0;
  transform: translateY(3px);
  transition: opacity 0.12s ease, transform 0.12s ease;
}
.cell.legal.show-guide:hover .flip-count-tip {
  opacity: 1;
  transform: translateY(0);
}

/* Preview highlight on discs that would flip on hover */
.cell.preview-flip .disc-wrap {
  filter: drop-shadow(0 0 6px rgba(252, 222, 128, 0.85));
}

/* =========================================================================
   PHOTOREALISTIC 3D TWO-SIDED REVERSI DISC
   ========================================================================= */
.disc-wrap {
  position: relative;
  width: 84%;
  height: 84%;
  transform-style: preserve-3d;
  pointer-events: none;
  z-index: 3;
}

.disc-shadow {
  position: absolute;
  inset: 4% 2% -5% 5%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(2, 12, 6, 0.68) 45%, rgba(2, 12, 6, 0.25) 75%, transparent 100%);
  transform: translateZ(-2px);
  transition: transform 0.24s ease, opacity 0.24s ease;
}

.disc-body {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  transform-style: preserve-3d;
  transition: transform 0.44s cubic-bezier(0.32, 1.18, 0.54, 1);
  will-change: transform;
}
.disc-body.is-black {
  transform: rotateY(0deg);
}
.disc-body.is-white {
  transform: rotateY(180deg);
}

.disc-face {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

/* Black Obsidian / Resin Face */
.disc-face.face-black {
  transform: rotateY(0deg) translateZ(2px);
  background:
    radial-gradient(circle at 31% 27%, rgba(255, 255, 255, 0.24) 0%, rgba(255, 255, 255, 0.04) 24%, transparent 48%),
    radial-gradient(circle at 68% 72%, rgba(220, 232, 240, 0.07) 0%, transparent 45%),
    radial-gradient(circle at 50% 50%, #24282e 0%, #14171b 58%, #07090b 100%);
  box-shadow:
    inset 0 2px 3px rgba(255, 255, 255, 0.22),
    inset 0 -3px 4px rgba(0, 0, 0, 0.85),
    0 0 0 1px rgba(0, 0, 0, 0.72);
}
/* Concentric machined groove on disc face */
.disc-face.face-black::before {
  content: "";
  position: absolute;
  inset: 14%;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.07);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.75);
}

/* White Ivory / Resin Face */
.disc-face.face-white {
  transform: rotateY(180deg) translateZ(2px);
  background:
    radial-gradient(circle at 31% 27%, rgba(255, 255, 255, 0.98) 0%, rgba(255, 255, 255, 0.4) 28%, transparent 54%),
    radial-gradient(circle at 68% 76%, rgba(164, 146, 114, 0.24) 0%, transparent 50%),
    radial-gradient(circle at 50% 50%, #fffdf8 0%, #f3ecde 58%, #d3c6af 100%);
  box-shadow:
    inset 0 2px 3px rgba(255, 255, 255, 0.95),
    inset 0 -3px 4px rgba(124, 108, 82, 0.42),
    0 0 0 1px rgba(132, 118, 94, 0.6);
}
.disc-face.face-white::before {
  content: "";
  position: absolute;
  inset: 14%;
  border-radius: 50%;
  border: 1px solid rgba(152, 134, 106, 0.18);
  box-shadow: inset 0 1px 2px rgba(160, 142, 112, 0.22);
}

/* Middle Rim Layer for 3D Thickness During Flip */
.disc-rim {
  position: absolute;
  inset: 1%;
  border-radius: 50%;
  background: linear-gradient(90deg, #1b1e22 0%, #7d7569 50%, #e5dcc9 100%);
  transform: translateZ(0px);
}

/* Last Move Brass Pip */
.last-move-pip {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  transform: translate(-50%, -50%) translateZ(4px);
  background: radial-gradient(circle at 35% 35%, #ffe699, #b88424);
  box-shadow: 0 0 5px rgba(242, 200, 96, 0.85);
  z-index: 6;
  pointer-events: none;
}

/* Placement & Flip Cascade Animations */
.disc-wrap.just-placed .disc-body {
  animation: discDrop 0.26s cubic-bezier(0.22, 1.28, 0.36, 1);
}
@keyframes discDrop {
  0% { transform: scale(1.22) translateZ(16px); }
  70% { transform: scale(0.96) translateZ(0); }
  100% { transform: scale(1) translateZ(0); }
}

.disc-wrap.just-flipped .disc-shadow {
  animation: flipShadow 0.44s ease-out;
}
@keyframes flipShadow {
  0% { transform: scale(1) translateZ(-2px); opacity: 0.9; }
  45% { transform: scale(1.24) translate(4px, 6px) translateZ(-2px); opacity: 0.45; }
  100% { transform: scale(1) translateZ(-2px); opacity: 0.9; }
}

@media (prefers-reduced-motion: reduce) {
  .disc-body,
  .disc-wrap.just-placed .disc-body,
  .disc-wrap.just-flipped .disc-shadow {
    transition: none !important;
    animation: none !important;
  }
}

/* =========================================================================
   REPLAY BAR & SIDEBAR
   ========================================================================= */
.replay-bar {
  width: 100%;
  padding: 10px 12px;
  border-radius: 9px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border-strong);
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.replay-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.replay-slider {
  flex: 1;
  min-width: 120px;
  accent-color: var(--gold);
}
.replay-summary {
  font-size: 11.5px;
  color: var(--gold-bright);
  font-weight: 700;
}

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.side-card {
  padding: 14px;
}

.turn-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.turn-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 800;
  color: var(--text-main);
}
.turn-disc-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
}
.turn-disc-dot.black {
  background: radial-gradient(circle at 32% 28%, #525962, #090b0d);
  border: 1px solid #040507;
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.35);
}
.turn-disc-dot.white {
  background: radial-gradient(circle at 32% 28%, #ffffff, #d3c6af);
  border: 1px solid #8f7e64;
  box-shadow: 0 0 6px rgba(140, 101, 37, 0.35);
}
.turn-disc-dot.ended {
  background: var(--gold);
}
.ply-text {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.score-cards-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 10px;
}
.mini-score-card {
  padding: 6px 8px;
  border-radius: 7px;
  background: var(--panel-bg-soft);
  border: 1px solid rgba(133, 102, 60, 0.24);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
.mini-score-label {
  font-size: 11px;
  color: var(--text-muted);
}
.mini-score-val {
  font-size: 15px;
  font-weight: 800;
  color: var(--gold-bright);
  font-variant-numeric: tabular-nums;
}

.vis-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11.5px;
  color: var(--text-muted);
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--panel-border);
}
.guide-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  color: var(--text-sub);
  font-weight: 600;
}
.guide-toggle input {
  accent-color: var(--gold);
}

.game-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.side-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 10px;
}
.side-tab {
  flex: 1;
  padding: 6px 8px;
  border-radius: 7px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--panel-bg-soft);
  border: 1px solid rgba(133, 102, 60, 0.2);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.side-tab.active {
  color: #543507;
  border-color: var(--gold);
  background: rgba(235, 202, 139, 0.34);
  font-weight: 700;
}
.unread-dot {
  position: absolute;
  top: 4px;
  right: 5px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--vermilion-bright);
}

.log-box {
  height: 245px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 8px;
  border-radius: 8px;
  background: rgba(246, 240, 228, 0.92);
  border: 1px solid rgba(133, 102, 60, 0.24);
}
.log-item {
  font-size: 11.5px;
  padding: 5px 8px;
  border-radius: 5px;
  border-left: 3px solid rgba(133, 102, 60, 0.45);
  background: #fffdf8;
  color: var(--text-sub);
}
.log-item.pass {
  border-left-color: #c27803;
  color: #6b4308;
  background: #fef8e7;
}
.log-item.end {
  border-left-color: var(--emerald);
  color: #16492d;
  background: #eff8f2;
  font-weight: 700;
}

.quick-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 8px;
}
.quick-chip {
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 10.5px;
  background: var(--panel-bg-soft);
  border: 1px solid rgba(133, 102, 60, 0.28);
  color: var(--text-sub);
}
.quick-chip:hover {
  border-color: var(--gold);
  color: var(--gold-bright);
}

@media (max-width: 840px) {
  .workspace {
    grid-template-columns: 1fr;
    justify-items: center;
  }
  .board-column,
  .side-panel {
    width: min(96vw, 540px);
  }
  :root {
    --board-size: min(82vw, 440px);
  }
}
@media (max-width: 440px) {
  :root {
    --board-size: min(79vw, 352px);
  }
  .board-frame {
    padding: 13px 12px;
  }
}
