/* sums.css - Sums: a Kakuro number puzzle. Reuses tokens from
   styles.css and game-shell.css's shell/bar/pause chrome, same as every
   other game. DOM-based (no canvas): a CSS grid board (black clue cells
   + white playable cells), a tile tray, and overlays for the difficulty
   picker and the solved board. The board grows with difficulty -- 6x6
   Easy, 8x8 Medium, 10x10 Hard -- so the grid column count is set from
   JS and the clue/white font sizes step down per size class. */

.sums-stage {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 10px;
  gap: 8px;
  /* Locked down (Jeff, Nov 8): the game must not move while playing.
     No overscroll bounce, and no touch panning starting on the game
     area -- the board, the tray and the cells all set touch-action:
     none below, so a drag or a tap never scrolls the stage or the
     board-wrap. The wrap keeps overflow-y: auto so a very short
     screen can still reach the action buttons (via the message area
     or a mouse wheel); touch on the game itself never scrolls. */
  overscroll-behavior: none;
}

.sums-stats {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex: 0 0 auto;
  flex-wrap: wrap;
}

@media (max-width: 480px) {
  .sums-stats {
    padding: 0 var(--gs-bar-right-clear) 0 var(--gs-bar-left-clear);
    gap: 10px;
  }
  /* Same real-bug precedent as Stacks'/Numbers'/Slither's own mobile
     stat-row fix -- Coins is the least essential stat mid-play, so it's
     the one dropped when the shell's own button clearance squeezes
     this row. */
  .sums-stats .sums-stat-compact-hide {
    display: none;
  }
}

.sums-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.1;
  min-width: 56px;
}

.sums-stat-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 600;
  color: var(--muted);
}

.sums-stat-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

.sums-board-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  overflow-y: auto;
  overscroll-behavior: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding-bottom: 8px;
}

/* -- Board -------------------------------------------------------------- */
.sums-board {
  display: grid;
  gap: 4px;
  /* Equal rows (Jeff, Nov 8): every square the same size. Rows were
     auto-sized by content, and the top rows are mostly black clue
     cells whose numbers are absolutely positioned (no in-flow
     content), so they rendered shorter than rows with digits. JS sets
     grid-template-rows: repeat(N, 1fr) per board size; this 1fr
     auto-row is the fallback so no row can ever size to content. */
  grid-auto-rows: 1fr;
  width: min(100%, 380px);
  aspect-ratio: 1;
  flex: 0 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 8px;
  /* Locked down: a touch starting on the board never pans/scrolls. */
  touch-action: none;
}

.sums-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-size: clamp(18px, 6vw, 26px);
  font-weight: 700;
  color: var(--text);
  background: rgba(255, 255, 255, .05);
  border: 2px solid transparent;
  user-select: none;
  -webkit-user-select: none;
  /* Locked down (was manipulation): a touch on a cell never starts a
     pan/scroll -- the page must not move while playing. */
  touch-action: none;
  min-width: 0;
  min-height: 0;
  position: relative;
}

/* White playable cells. */
.sums-cell-white {
  background: rgba(255, 255, 255, .07);
  border-color: rgba(255, 255, 255, .14);
}

.sums-cell-given {
  color: var(--text);
  background-image: linear-gradient(rgba(255, 255, 255, .06), rgba(255, 255, 255, .06));
}

.sums-cell-placed {
  color: #fff;
  background: rgba(45, 212, 191, .30);
  border-color: rgba(45, 212, 191, .55);
}

/* Black clue cells: dark, with a diagonal line from top-left to
   bottom-right splitting the two clue numbers (across upper-right,
   down lower-left). A black cell with no clue is just a filler. */
.sums-cell-black {
  background: #171d24;
  border-color: rgba(255, 255, 255, .05);
}

.sums-clue {
  background-image: linear-gradient(to bottom right,
    transparent calc(50% - .5px),
    rgba(255, 255, 255, .35) calc(50% - .5px),
    rgba(255, 255, 255, .35) calc(50% + .5px),
    transparent calc(50% + .5px));
}

.sums-clue-across,
.sums-clue-down {
  position: absolute;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  color: #cbd5e1;
  font-variant-numeric: tabular-nums;
}

.sums-clue-across { top: 2px; right: 3px; }
.sums-clue-down { bottom: 2px; left: 3px; }

/* Smaller cells on the bigger boards: step the fonts down so the two
   clue numbers and the placed digit still fit. */
.sums-board-8 .sums-cell { font-size: clamp(16px, 5vw, 22px); }
.sums-board-8 .sums-clue-across,
.sums-board-8 .sums-clue-down { font-size: 11px; }

.sums-board-10 .sums-cell { font-size: clamp(14px, 4.5vw, 19px); }
.sums-board-10 .sums-clue-across,
.sums-board-10 .sums-clue-down { font-size: 10px; }
.sums-board-10 .sums-clue-across { top: 1px; right: 2px; }
.sums-board-10 .sums-clue-down { bottom: 1px; left: 2px; }

.sums-cell-drop {
  outline: 2px dashed var(--accent);
  outline-offset: -2px;
}

.sums-cell-wrong {
  border-color: #ef4444;
  background: rgba(239, 68, 68, .30);
  animation: sums-wrong-pulse 1s ease-in-out infinite;
}

@keyframes sums-wrong-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
  50% { box-shadow: 0 0 0 3px rgba(239, 68, 68, .35); }
}

.sums-cell-shake {
  animation: sums-shake .3s ease-in-out;
}

@keyframes sums-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* -- Tile tray ---------------------------------------------------------- */
.sums-tray {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
  width: min(100%, 380px);
  /* Locked down: a touch starting on the tray never pans/scrolls. */
  touch-action: none;
}

.sums-tile {
  /* Square, and sized to match a grid cell by syncTileSize() in
     sums.js (Jeff, Nov 8: the squares should all start the same
     size). These 40px defaults are only the pre-JS fallback; the
     script sets the inline size to the measured cell size on every
     deal and on resize. */
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: 0 3px 0 rgba(0, 0, 0, .35);
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

/* Tiles 1-9 are always available (Jeff, Nov 8): placing a digit never
   removes its tile from the tray, so there is no consumed state. */
.sums-tile:active { cursor: grabbing; }

.sums-tile-selected {
  border-color: var(--accent);
  background: var(--accent2);
  color: #fff;
  transform: translateY(2px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, .35);
}

.sums-drag-ghost {
  position: fixed;
  z-index: 60;
  /* Same square default as a tile; syncTileSize() in sums.js keeps
     the ghost the same size as the tiles (and the cells). */
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 22px;
  font-weight: 800;
  color: #fff;
  background: var(--accent2);
  border: 2px solid var(--accent);
  box-shadow: var(--shadow);
  pointer-events: none;
}

/* -- Message + actions -------------------------------------------------- */
.sums-message {
  min-height: 1.4em;
  margin: 0;
  text-align: center;
  font-size: 14px;
  color: var(--muted);
  max-width: 380px;
}

.sums-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.sums-action-btn {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.sums-action-btn:active { transform: translateY(1px); }

/* -- Overlays (mirror the other games' overlay cards) ------------------- */
.sums-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(16, 21, 26, .82);
  border-radius: var(--radius);
  z-index: 20;
  padding: 16px;
}

.sums-overlay[hidden] { display: none; }

.sums-overlay-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  max-width: 420px;
  width: 100%;
  text-align: center;
}

.sums-overlay-title {
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 8px;
}

.sums-overlay-text {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
  margin: 0 0 12px;
}

.sums-overlay-hint {
  color: var(--text);
  font-weight: 600;
}

.sums-difficulty-row {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.sums-difficulty-btn {
  flex: 1 1 0;
  min-width: 96px;
}
