/* white-puzzle.css — page styles for the White Puzzle game.
   "백지 퍼즐" means a single-color puzzle: pieces are --g4, so they render
   white on the dark theme and black on the light theme. */

body {
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

/* --- Header --- */
.game-header {
  width: 100%;
  flex-shrink: 0;
  padding: var(--space-2) var(--space-4);
  padding-right: 64px; /* keep clear of the fixed theme toggle */
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 44px;
  color: var(--g3);
  font-size: var(--text-l);
  text-decoration: none;
  transition: opacity var(--duration-fast) var(--ease);
}

.back-link:hover {
  opacity: 0.6;
}

.back-link svg {
  width: 20px;
  height: 20px;
}

/* --- Board --- */
#game-area {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding-bottom: var(--space-2);
}

#board-wrap {
  position: relative;
  padding: calc(var(--cell) * 0.45);
}

#loading-msg {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  color: var(--g3);
  z-index: 100;
}

#loading-msg.show {
  display: flex;
}

#board {
  display: grid;
  grid-template-columns: repeat(7, var(--cell));
  grid-template-rows: repeat(7, var(--cell));
  position: relative;
  touch-action: none;
}

/* Grid lines are drawn with an inset shadow instead of a border: a border
   would shift the cell's padding box, misaligning the absolutely
   positioned pieces by 1px. */
.cell {
  width: var(--cell);
  height: var(--cell);
  position: relative;
  box-shadow: inset 0 0 0 1px transparent;
  transition: box-shadow var(--duration-fast) var(--ease);
}

.board-active .cell {
  box-shadow: inset 0 0 0 1px var(--g2);
}

/* --- Pieces (game content: motion rules do not apply inside the board) --- */
.piece {
  position: absolute;
  pointer-events: none;
  z-index: 1;
  transition: opacity var(--duration-fast) var(--ease);
}

.piece.selected {
  z-index: 50;
}

.piece.ghost-src {
  opacity: 0.15;
}

.piece svg {
  display: block;
}

.piece path,
#ghost-wrap path {
  fill: var(--g4);
  fill-opacity: 0.75;
  stroke: var(--g3);
  stroke-width: 1;
}

.piece.selected path {
  fill-opacity: 1;
}

#ghost-wrap {
  position: fixed;
  display: none;
  pointer-events: none;
  opacity: 0.7;
  z-index: 9999;
}

/* --- Controls --- */
#controls-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
}

#controls {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.ctrl-btn {
  width: 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--g1);
  border: var(--border);
  border-radius: var(--radius-m);
  color: var(--g4);
  cursor: pointer;
  transition: opacity var(--duration-fast) var(--ease);
}

.ctrl-btn:hover {
  opacity: 0.7;
}

.ctrl-btn svg {
  width: 22px;
  height: 22px;
}

#timer-display {
  min-width: 72px;
  text-align: center;
  font-size: var(--text-l);
  font-variant-numeric: tabular-nums;
}

#game-info {
  color: var(--g3);
  font-size: var(--text-m);
  text-align: center;
  max-width: 90vw;
}

/* --- Clear overlay --- */
#overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  background: color-mix(in srgb, var(--g0) 92%, transparent);
}

#overlay.show {
  display: flex;
  animation: fade-in var(--duration-base) var(--ease);
}

#overlay h1 {
  margin: 0;
  font-size: clamp(2rem, 8vw, 3.5rem);
  line-height: var(--leading-tight);
  letter-spacing: 0.1em;
}

.clear-time {
  color: var(--g3);
  font-size: var(--text-l);
  font-variant-numeric: tabular-nums;
}

#overlay button {
  margin-top: var(--space-4);
  min-height: 44px;
  padding: var(--space-2) var(--space-6);
  font: inherit;
  color: var(--g4);
  background: var(--g1);
  border: var(--border);
  border-radius: var(--radius-m);
  cursor: pointer;
  transition: opacity var(--duration-fast) var(--ease);
}

#overlay button:hover {
  opacity: 0.7;
}
