:root {
  --bg: #070707;
  --panel: rgba(18, 18, 18, 0.03);
  --panel-strong: rgba(28, 28, 28, 0.03);
  --line: rgba(255, 255, 255, 0.03);
  --line-strong: rgba(255, 255, 255, 0.03);
  --text: #f7f7f2;
  --muted: #a7a7a0;
  --gold: #ffffff; /* retained variable name so existing HTML/JS still works */
  --ember: #5f5f5a;
  --stone-dark: #2f2f2d;
  --stone-light: #d7d7cf;
  --black-piece: #111111;
  --white-piece: #e8e8df;
  --board-size: min(74vw, 680px);
  --square-size: calc(var(--board-size) / 8);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(0,0,0,.72), rgba(0,0,0,.9)),
    radial-gradient(circle at 50% 0%, rgba(255,255,255,.08), transparent 34%),
    radial-gradient(circle at 18% 80%, rgba(255,255,255,.055), transparent 30%),
    url("bg.jpg") center / cover fixed no-repeat,
    linear-gradient(135deg, #050505 0%, #171717 46%, #000000 100%);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.1;
  background-image:
    linear-gradient(rgba(255,255,255,.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.07) 1px, transparent 1px),
    radial-gradient(circle, rgba(255,255,255,.12) 1px, transparent 1px);
  background-size: 104px 104px, 104px 104px, 7px 7px;
  mask-image: radial-gradient(circle at center, #000, transparent 80%);
}

.background-orb {
  position: fixed;
  width: 340px;
  height: 340px;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.18;
  pointer-events: none;
}
.orb-one { background: #ffffff; top: 12%; left: -120px; }
.orb-two { background: #6f6f6a; bottom: 5%; right: -120px; }

.app-shell {
  width: min(1500px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 36px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 24px;
  padding: 18px 0 28px;
  border-bottom: 1px solid var(--line);
}

.kicker,
.label {
  display: block;
  margin: 0 0 8px;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: .18em;
  font-size: 11px;
  font-weight: 700;
}

h1, h2, p { margin-top: 0; }

h1 {
  margin-bottom: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(42px, 6vw, 92px);
  line-height: .88;
  letter-spacing: -.06em;
}

h2 {
  margin-bottom: 6px;
  font-size: 18px;
  letter-spacing: -.02em;
}

p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.5;
  font-size: 14px;
}

.top-actions,
.control-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn,
.difficulty {
  appearance: none;
  border: 1px solid var(--line-strong);
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.015)),
    rgba(25, 21, 18, .86);
  padding: 12px 15px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 10px 28px rgba(0,0,0,.24);
  transition: transform .16s ease, border-color .16s ease, background .16s ease;
}

.btn:hover,
.difficulty:hover {
  transform: translateY(-1px);
  border-color: rgba(255,255,255,.68);
}

.btn.primary,
.difficulty.active {
  color: #050505;
  border-color: rgba(255,255,255,.72);
  background: linear-gradient(180deg, #ffffff 0%, #b8b8b0 100%);
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(230px, 300px) minmax(420px, 1fr) minmax(260px, 340px);
  gap: 24px;
  align-items: center;
  padding-top: 34px;
}

.panel {
  background:
    linear-gradient(145deg, rgba(255,255,255,.015), rgba(255,255,255,.003)),
    rgba(10, 10, 10, .22);
  backdrop-filter: blur(6px);
  min-height: 560px;
  padding: 22px;
  box-shadow: 0 18px 50px rgba(0,0,0,.12);
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.035);
}

.panel::before {
  content: "";
  position: absolute;
  inset: 10px;
  
  pointer-events: none;
}

.panel-heading {
  display: flex;
  gap: 14px;
  align-items: start;
  margin-bottom: 24px;
}

.roman-index {
  display: grid;
  place-items: center;
  width: 42px;
  height: 54px;
  flex: 0 0 auto;
  font-family: Georgia, serif;
  font-weight: 700;
  color: var(--gold);
  
  border-radius: 42px 42px 6px 6px;
  background: linear-gradient(180deg, rgba(255,255,255,.12), rgba(0,0,0,.14));
}

.difficulty-grid {
  display: grid;
  gap: 10px;
  margin-bottom: 22px;
}

.status-card {
  padding: 18px;
  margin-top: 12px;
  border: 1px solid var(--line);
  background:
    radial-gradient(circle at 0 0, rgba(255,255,255,.12), transparent 48%),
    rgba(10, 9, 8, .38);
}

.status-card span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .14em;
  margin-bottom: 8px;
}

.status-card strong {
  font-size: 17px;
  line-height: 1.35;
}

.status-card.small strong { font-size: 10px; }

.board-stage {
  display: grid;
  place-items: center;
  min-height: calc(var(--board-size) + 70px);
  position: relative;
  perspective: none;
}

.board-shadow {
  position: absolute;
  width: calc(var(--board-size) + 86px);
  height: 68px;
  bottom: 18px;
  background: radial-gradient(ellipse at center, rgba(0,0,0,.78), transparent 70%);
  filter: blur(16px);
}

.board-frame {
  width: calc(var(--board-size) + 38px);
  height: calc(var(--board-size) + 38px);
  position: relative;
  padding: 19px;
  transform: rotateX(0deg);

  background:
    linear-gradient(135deg, rgba(255,255,255,.055), transparent 22%),
    linear-gradient(315deg, rgba(0,0,0,.34), transparent 38%),
    linear-gradient(90deg,
      #070605 0%,
      #120d09 22%,
      #1c120b 48%,
      #100b08 72%,
      #050404 100%
    );

  

  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.08),
    inset 0 -14px 28px rgba(0,0,0,.42),
    0 42px 90px rgba(0,0,0,.62);
}

/* Removed overlay border that was creating visible vertical frame lines */
.board-frame::before {
  content: none;
}

/* Keep only subtle inner depth, but do not overlay across the board */
.board-frame::after {
  content: "";
  position: absolute;
  inset: 19px;
  pointer-events: none;
  box-shadow:
    inset 0 0 0 1px rgba(0,0,0,.42),
    inset 0 0 22px rgba(0,0,0,.22);
  z-index: 1;
}

.board {
  position: relative;
  z-index: 2;
}

.board-lip {
  position: absolute;
  pointer-events: none;
  
  opacity: .85;
}
.board-lip.top { top: 0; left: 0; right: 0; height: 18px; }
.board-lip.bottom { bottom: 0; left: 0; right: 0; height: 18px; }
.board-lip.left { left: 0; top: 0; bottom: 0; width: 18px; }
.board-lip.right { right: 0; top: 0; bottom: 0; width: 18px; }

.board {
  width: var(--board-size);
  height: var(--board-size);
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  position: relative;
  z-index: 2;
  background: #111;
}

.square {
  position: relative;
  display: grid;
  place-items: center;
  cursor: pointer;
  user-select: none;
  overflow: visible;
}

.square.light {
  background-color: #cfcfc8;
  background-image:
    radial-gradient(ellipse at 18% 24%, rgba(255,255,255,.13), transparent 34%),
    radial-gradient(ellipse at 72% 68%, rgba(88,88,82,.10), transparent 42%),
    radial-gradient(ellipse at 46% 42%, rgba(255,255,255,.07), transparent 50%),
    radial-gradient(ellipse at 28% 76%, rgba(0,0,0,.055), transparent 36%),
    linear-gradient(145deg, #eeeeea 0%, #cecec7 46%, #aaa9a2 100%);
  background-size: 100% 100%;
  background-position: center;
}

.square.dark {
  background-color: #1f1f1f;
  background-image:
    radial-gradient(ellipse at 22% 26%, rgba(255,255,255,.06), transparent 34%),
    radial-gradient(ellipse at 76% 72%, rgba(0,0,0,.20), transparent 44%),
    radial-gradient(ellipse at 48% 38%, rgba(255,255,255,.03), transparent 52%),
    radial-gradient(ellipse at 32% 80%, rgba(0,0,0,.16), transparent 38%),
    linear-gradient(145deg, #393939 0%, #212121 48%, #0d0d0e 100%);
  background-size: 100% 100%;
  background-position: center;
}

.square::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 12% 18%, rgba(255,255,255,.035), transparent 28%),
    radial-gradient(ellipse at 88% 78%, rgba(0,0,0,.06), transparent 34%),
    radial-gradient(ellipse at 52% 44%, rgba(255,255,255,.025), transparent 42%);
  opacity: .55;
  mix-blend-mode: overlay;
  box-shadow:
    inset 1px 1px 0 rgba(255,255,255,.055),
    inset -1px -1px 0 rgba(0,0,0,.22),
    inset 0 0 18px rgba(0,0,0,.08);
  pointer-events: none;
}

.square.selected {
  outline: 3px solid rgba(255, 255, 255, .9);
  outline-offset: -3px;
  z-index: 4;
}

.square.legal::before {
  content: "";
  width: 28%;
  height: 28%;
  border-radius: 50%;
  background: rgba(255, 255, 255, .72);
  box-shadow: 0 0 24px rgba(255, 255, 255, .28);
  position: absolute;
  z-index: 4;
}

.square.capture-target::before {
  width: 70%;
  height: 70%;
  background: transparent;
  border: 3px solid rgba(255, 255, 255, .82);
}

.square.last-move {
  box-shadow: inset 0 0 0 4px rgba(255, 255, 255, .22);
}

.piece {
  width: calc(var(--square-size) * .78);
  height: calc(var(--square-size) * .78);
  display: grid;
  place-items: center;
  border-radius: 50%;
  position: relative;
  z-index: 5;
  font-size: calc(var(--square-size) * .48);
  font-family: "Times New Roman", Georgia, serif;
  line-height: 1;
  transform: translateY(-7px);
  transition: transform .18s ease, filter .18s ease;
  will-change: transform;
}

.piece::before {
  content: "";
  position: absolute;
  inset: 8%;
  border-radius: 50%;
  z-index: -1;
  opacity: .9;
}

.piece::after {
  content: "";
  position: absolute;
  left: 9%;
  right: 9%;
  bottom: -12%;
  height: 20%;
  border-radius: 50%;
  background: rgba(0,0,0,.45);
  filter: blur(5px);
  z-index: -2;
}

.piece.white {
  color: #3a3028;
  text-shadow: 0 1px 0 rgba(255,255,255,.52), 0 -1px 0 rgba(92,74,58,.32);
  background:
    radial-gradient(circle at 30% 22%, rgba(255,255,255,.82), transparent 18%),
    repeating-radial-gradient(circle at 48% 42%, rgba(255,255,255,.08) 0 2px, rgba(0,0,0,.055) 2px 5px),
    linear-gradient(145deg, #eee0c3 0%, #b8aa90 46%, #82735d 100%);
  box-shadow:
    inset 4px 4px 8px rgba(255,255,255,.44),
    inset -8px -10px 15px rgba(74,59,45,.42),
    0 9px 0 #776a58,
    0 18px 24px rgba(0,0,0,.42);
}

.piece.white::before {
  box-shadow: inset 0 0 0 1px rgba(82,65,47,.35), inset 0 0 20px rgba(255,255,255,.16);
}

.piece.black {
  color: #d8c8a9;
  text-shadow: 0 1px 0 rgba(0,0,0,.7), 0 0 8px rgba(255,255,255,.14);
  background:
    radial-gradient(circle at 32% 24%, rgba(255,255,255,.28), transparent 17%),
    repeating-radial-gradient(circle at 50% 50%, rgba(255,255,255,.045) 0 2px, rgba(0,0,0,.12) 2px 5px),
    linear-gradient(145deg, #51483d 0%, #2c2823 50%, #11100e 100%);
  box-shadow:
    inset 4px 4px 8px rgba(255,255,255,.09),
    inset -8px -10px 15px rgba(0,0,0,.62),
    0 9px 0 #16130f,
    0 18px 24px rgba(0,0,0,.58);
}

.piece.black::before {
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.16), inset 0 0 20px rgba(0,0,0,.28);
}

.square:hover .piece {
  transform: translateY(-11px) scale(1.025);
}

.piece.moving {
  animation: piecePulse .28s ease;
}

@keyframes piecePulse {
  50% { transform: translateY(-15px) scale(1.08); }
}

.captured-grid {
  display: grid;
  gap: 16px;
  margin-bottom: 20px;
}

.captured {
  min-height: 44px;
  padding: 10px;
  border: 1px solid var(--line);
  background: rgba(5, 4, 3, .3);
  font-family: Georgia, serif;
  font-size: 24px;
  letter-spacing: 4px;
  color: var(--muted);
}

.move-history-wrap {
  margin-top: 12px;
}

.move-history {
  height: 265px;
  overflow: auto;
  margin: 8px 0 18px;
  padding: 12px 12px 12px 34px;
  border: 1px solid var(--line);
  background: rgba(5, 4, 3, .3);
  color: var(--muted);
}

.move-history li {
  padding: 5px 0;
  font-size: 13px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(20px);
  opacity: 0;
  pointer-events: none;
  padding: 13px 18px;
  color: #050505;
  background: #f4f4ef;
  border: 1px solid rgba(255,255,255,.52);
  box-shadow: 0 18px 42px rgba(0,0,0,.36);
  font-weight: 800;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 100;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 1180px) {
  :root { --board-size: min(86vw, 640px); }
  .game-layout {
    grid-template-columns: 1fr;
  }
  .panel {
    min-height: auto;
  }
  .left-panel,
  .right-panel {
    display: grid;
    gap: 16px;
  }
}

@media (max-width: 680px) {
  :root { --board-size: calc(100vw - 64px); }
  .app-shell { width: min(100% - 20px, 1500px); padding-top: 14px; }
  .topbar { align-items: start; flex-direction: column; }
  .board-frame {
    width: calc(var(--board-size) + 24px);
    height: calc(var(--board-size) + 24px);
    padding: 12px;
  }
  .board-frame::after { inset: 12px; }
  .piece { font-size: calc(var(--square-size) * .43); }
  .panel { padding: 16px; }
}

/* Premium uniform typography */
body,
button,
input,
select,
textarea,
.btn,
.difficulty,
.kicker,
.label,
h1,
h2,
p,
.status-card span,
.status-card strong,
.move-history li,
.captured,
.roman-index {
  font-family: "Helvetica Neue", "Inter", Arial, sans-serif;
  font-size: 10px;
  line-height: 1.45;
  font-weight: 300;
  letter-spacing: -0.01em;
}

.left-panel {
  display: flex;
  flex-direction: column;
}

.left-panel-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: auto;
  padding-top: 22px;
}


/* =========================================================
   SUDOKU BOARD — ALL WHITE STONE + 3x3 TABLE BORDERS
   ========================================================= */

.sudoku-board {
  width: var(--board-size);
  height: var(--board-size);
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  grid-template-rows: repeat(9, 1fr);
  background: #f2f2ee;
  border: 2px solid rgba(255,255,255,.72);
}

/* All cells now use the same white stone style */
.sudoku-cell,
.sudoku-cell.light,
.sudoku-cell.dark {
  position: relative;
  display: grid;
  place-items: center;
  appearance: none;
  cursor: pointer;

  border: 1px solid rgba(0,0,0,.22);
  background:
    radial-gradient(ellipse at 18% 24%, rgba(255,255,255,.22), transparent 34%),
    radial-gradient(ellipse at 72% 68%, rgba(70,70,65,.08), transparent 42%),
    radial-gradient(ellipse at 48% 52%, rgba(255,255,255,.12), transparent 44%),
    linear-gradient(145deg, #f5f5f0 0%, #dcdcd5 52%, #bdbdb6 100%);

  color: rgba(0,0,0,.82);
  font-family: "Helvetica Neue", "Inter", Arial, sans-serif;
  font-size: calc(var(--square-size) * .32);
  font-weight: 500;
  line-height: 1;
  transition:
    background .16s ease,
    color .16s ease,
    box-shadow .16s ease,
    transform .16s ease;
}

/* Stronger 3x3 vertical table borders */
.sudoku-cell:nth-child(3n) {
  border-right: 2px solid rgba(0,0,0,.62);
}

.sudoku-cell:nth-child(9n) {
  border-right: 1px solid rgba(0,0,0,.22);
}

/* Stronger 3x3 horizontal table borders */
.sudoku-cell:nth-child(n + 19):nth-child(-n + 27),
.sudoku-cell:nth-child(n + 46):nth-child(-n + 54) {
  border-bottom: 2px solid rgba(0,0,0,.62);
}

/* Optional: stronger outer edge */
.sudoku-cell:nth-child(-n + 9) {
  border-top: 1px solid rgba(0,0,0,.34);
}

.sudoku-cell:nth-child(9n + 1) {
  border-left: 1px solid rgba(0,0,0,.34);
}

.sudoku-cell:nth-child(n + 73) {
  border-bottom: 1px solid rgba(0,0,0,.34);
}

/* Fixed starting numbers */
.sudoku-cell.fixed {
  font-weight: 700;
  color: rgba(0,0,0,.92);
  text-shadow: none;
}

/* Selected and related cells */
.sudoku-cell.selected {
  z-index: 4;
  box-shadow:
    inset 0 0 0 2px rgba(0,0,0,.72),
    0 0 24px rgba(255,255,255,.18);
}

.sudoku-cell.related {
  box-shadow: inset 0 0 0 999px rgba(0,0,0,.045);
}

.sudoku-cell.same-number {
  box-shadow:
    inset 0 0 0 2px rgba(0,0,0,.22),
    inset 0 0 0 999px rgba(0,0,0,.065);
}

.sudoku-cell:hover {
  transform: translateY(-1px);
  box-shadow:
    inset 0 0 0 2px rgba(0,0,0,.28),
    0 12px 28px rgba(0,0,0,.22);
}

/* Number pad */
.number-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.number-key {
  appearance: none;
  min-height: 42px;
  border: 1px solid rgba(255,255,255,.09);
  background:
    linear-gradient(180deg, rgba(255,255,255,.035), rgba(255,255,255,.006)),
    rgba(8,8,8,.42);
  color: rgba(255,255,255,.74);
  font-family: "Helvetica Neue", "Inter", Arial, sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color .16s ease, background .16s ease, transform .16s ease;
}

.number-key:hover {
  transform: translateY(-1px);
  border-color: rgba(255,255,255,.28);
  background:
    linear-gradient(180deg, rgba(255,255,255,.08), rgba(255,255,255,.012)),
    rgba(14,14,14,.62);
}

/* Hide chess-specific piece styling if still present */
.piece {
  display: none;
}

@media (max-width: 680px) {
  .sudoku-cell {
    font-size: calc(var(--square-size) * .28);
  }

  .number-pad {
    grid-template-columns: repeat(9, 1fr);
  }

  .number-key {
    min-height: 34px;
  }
}