/* ============================================================================
   Sudoku — focused play screen (gamesy). Re-skins the existing board engine;
   the .sg-* class names / #sg-* IDs are engine hooks and must stay.
   ============================================================================ */

.play-body { margin: 0; background: #ece5d4; color: #2b2620; min-height: 100vh;
  font-family: Georgia, 'Times New Roman', serif; }

.sp-page { max-width: 960px; margin: 0 auto; }

/* ── Header ─────────────────────────────────────────────────────────────── */
.sp-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.sp-back { font-family: system-ui, sans-serif; font-weight: 700; font-size: 16px; letter-spacing: 1px; color: #1f4a33; text-decoration: none; }
.sp-back:hover { color: #2f6e42; }
.sp-header-actions { display: flex; gap: 10px; }
.sp-iconbtn { width: 38px; height: 38px; border-radius: 10px; border: 1px solid #d8cdb2; background: #fffdf7; color: #4a443b; font-size: 15px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; box-shadow: 0 1px 2px rgba(60,50,30,.06); transition: background .12s; }
.sp-iconbtn:hover:not(:disabled) { background: #f3ecd9; }
.sp-iconbtn:disabled { opacity: .5; cursor: default; }
#sg-pause { font-size: 14px; }

/* Header dropdowns (Settings / Menu) */
.sp-dd { position: relative; }
.sp-dd-panel { position: absolute; top: calc(100% + 6px); right: 0; min-width: 224px; background: #fffdf7; border: 1px solid #e6ddc6; border-radius: 10px; box-shadow: 0 8px 24px rgba(40,30,15,.18); padding: 8px; z-index: 30; display: none; }
.sp-dd.open .sp-dd-panel { display: block; }
.sp-dd-title { font-family: system-ui, sans-serif; font-size: 11px; letter-spacing: .8px; text-transform: uppercase; color: #7a7468; padding: 4px 8px 6px; }
.sp-toggle { display: flex; align-items: center; gap: 9px; padding: 8px; border-radius: 7px; font-family: system-ui, sans-serif; font-size: 13.5px; color: #2b2620; cursor: pointer; }
.sp-toggle:hover { background: #f3ecd9; }
.sp-toggle input { width: 16px; height: 16px; accent-color: #355e3b; cursor: pointer; }
.sp-dd-panel-menu { min-width: 200px; }
.sp-dd-item { display: flex; align-items: center; width: 100%; padding: 10px; background: none; border: 0; border-radius: 7px; font-family: system-ui, sans-serif; font-size: 14px; color: #2b2620; cursor: pointer; text-decoration: none; text-align: left; }
.sp-dd-item:hover { background: #f3ecd9; }

/* ── Stat bar ───────────────────────────────────────────────────────────── */
.sp-statbar { display: flex; align-items: center; background: linear-gradient(180deg, #fffdf8, #faf4e6); border: 1px solid #e0d4b6; border-radius: 12px; padding: 14px 18px; margin-bottom: 18px; box-shadow: inset 0 1px 0 #fff, 0 1px 2px rgba(60,50,30,.07); }
.sp-badge { font-family: system-ui, sans-serif; font-weight: 700; font-size: 12px; letter-spacing: 1px; color: #fff; padding: 7px 16px; border-radius: 8px; background: linear-gradient(180deg, #5f9148, #4e7d3a); margin-right: 16px; box-shadow: 0 2px 5px rgba(60,50,30,.18), inset 0 1px 0 rgba(255,255,255,.25); }
.sp-badge.medium { background: linear-gradient(180deg, #e0ad3e, #d29a2b); }
.sp-badge.hard   { background: linear-gradient(180deg, #e07c35, #cf6a26); }
.sp-badge.expert { background: linear-gradient(180deg, #a23b48, #8b2f3a); }
.sp-stat { flex: 1; text-align: center; border-left: 1px solid #ece3cb; padding: 0 10px; }
.sp-stat-l { font-family: system-ui, sans-serif; font-size: 11px; letter-spacing: .6px; text-transform: uppercase; color: #7a7468; }
.sp-stat-v { font-family: Georgia, serif; font-size: 25px; font-weight: 700; color: #2b2620; margin-top: 2px; }

/* ── Board + actions ────────────────────────────────────────────────────── */
.sp-main { display: grid; grid-template-columns: minmax(0, 1fr) clamp(250px, 27vw, 310px); gap: 28px; align-items: start; }
/* Velvet gold-edged board frame — the clubhouse premium treatment. */
.sp-board-wrap { position: relative; min-width: 0; padding: 12px; border-radius: 18px; background: linear-gradient(160deg, #3d342a, #241e16); box-shadow: 0 12px 28px rgba(40,30,15,.32), inset 0 0 0 1.5px #b08a35; }

/* container-type: cell digits size off the BOARD (cqw), not the viewport,
   so a height-capped board keeps its type proportional. */
.sg-board { width: 100%; aspect-ratio: 1; display: grid; grid-template-columns: repeat(9, 1fr); grid-template-rows: repeat(9, 1fr); background: #fdf9ee; border: 0; border-radius: 9px; overflow: hidden; user-select: none; container-type: inline-size; }
.sg-cell { position: relative; border-right: 1px solid #d9cfb6; border-bottom: 1px solid #d9cfb6; display: grid; place-items: center; font-family: Georgia, serif; font-size: clamp(14px, calc(100cqw / 9 * .52), 30px); font-weight: 600; color: #1f6f4a; cursor: pointer; background: transparent; min-width: 0; min-height: 0; transition: background .08s; }
.sg-cell[data-col="2"], .sg-cell[data-col="5"] { border-right: 2px solid #6f5a30; }
.sg-cell[data-row="2"], .sg-cell[data-row="5"] { border-bottom: 2px solid #6f5a30; }
.sg-cell[data-col="8"] { border-right: none; }
.sg-cell[data-row="8"] { border-bottom: none; }
.sg-cell.given { color: #2b2620; cursor: default; }
.sg-cell.peer { background: #e6efdc; }
.sg-cell.same-digit { background: #d3e6c2; }
.sg-cell.selected { background: #cfe7cf; box-shadow: inset 0 0 0 2px #2f6e42; }
.sg-cell.conflict { color: #b3261e; }
.sg-cell.wrong { background: rgba(179,38,30,.12) !important; color: #b3261e !important; text-decoration: underline wavy #b3261e; text-underline-offset: 3px; }
.sg-cell.hint-revealed { box-shadow: inset 0 0 0 2px #357a4a; }
.sg-cell.hint-pending { animation: sp-hint-pulse 1.4s ease-in-out infinite; }
@keyframes sp-hint-pulse {
  0%, 100% { box-shadow: inset 0 0 0 2px #d29a2b; }
  50%      { box-shadow: inset 0 0 0 3px #d29a2b; background: rgba(210,154,43,.18); }
}
.sg-pencil { position: absolute; inset: 4px; display: grid; grid-template-columns: repeat(3,1fr); grid-template-rows: repeat(3,1fr); font-family: system-ui, sans-serif; font-size: clamp(6px, calc(100cqw / 9 * .18), 10px); color: #7a7468; pointer-events: none; }
.sg-pencil span { display: grid; place-items: center; }
.sg-cell.selected .sg-pencil span { color: #1f4a33; }

.sg-paused-mask { position: absolute; inset: 12px; background: rgba(244,238,221,.94); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; font-family: Georgia, serif; font-size: 40px; color: #355e3b; z-index: 5; border-radius: 9px; }
.sg-paused-mask.hidden { display: none; }
.sg-paused-mask button { font-family: system-ui, sans-serif; font-weight: 700; font-size: 13px; padding: 10px 18px; background: #355e3b; color: #fff; border: none; border-radius: 8px; cursor: pointer; }

.sp-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.sg-pad-btn, .sp-erasebtn { aspect-ratio: 1; display: inline-flex; align-items: center; justify-content: center; background: linear-gradient(180deg, #fffdf7, #f3ecd8); border: 1px solid #ddd0b0; border-radius: 12px; font-family: Georgia, serif; font-weight: 700; font-size: clamp(28px, 5.5vw, 38px); color: #1f4a33; cursor: pointer; padding: 0; box-shadow: inset 0 1px 0 #fff, 0 1px 2px rgba(60,50,30,.1); transition: background .12s, color .12s, transform .1s, box-shadow .12s; }
.sg-pad-btn:hover:not(:disabled), .sp-erasebtn:hover:not(:disabled) { background: #355e3b; color: #fff; border-color: #355e3b; transform: translateY(-1px); box-shadow: 0 5px 12px rgba(53,94,59,.28); }
.sg-pad-btn:active:not(:disabled), .sp-erasebtn:active:not(:disabled) { transform: translateY(0); box-shadow: 0 1px 2px rgba(60,50,30,.1); }
.sg-pad-btn.complete, .sg-pad-btn:disabled, .sp-erasebtn:disabled { background: #efe8d6; color: #b3a98c; cursor: not-allowed; box-shadow: none; }
/* Desktop: erase fills the row under the 3x3 pad. */
.sp-erasebtn { grid-column: 1 / -1; aspect-ratio: auto; height: 50px; font-size: 22px; color: #8b2f3a; }

.sp-controls { display: flex; flex-direction: column; gap: 14px; }

/* Normal / Candidate segmented toggle — reflects the engine's pencil mode
   (#sg-pencil-toggle gets .active when in candidate/pencil mode). */
.sp-modebtn { display: flex; padding: 0; border: 1px solid #d8cdb2; border-radius: 10px; overflow: hidden; background: #fffdf7; cursor: pointer; box-shadow: 0 1px 2px rgba(60,50,30,.07); }
.sp-modebtn span { flex: 1; padding: 11px 8px; font-family: system-ui, sans-serif; font-size: 14px; font-weight: 700; color: #6b6357; text-align: center; transition: background .12s, color .12s; }
.sp-modebtn .sp-mode-normal { background: #355e3b; color: #fff; }
.sp-modebtn.active .sp-mode-normal { background: transparent; color: #6b6357; }
.sp-modebtn.active .sp-mode-candidate { background: #355e3b; color: #fff; }

.sp-actrow { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 10px; }
.sp-action { display: inline-flex; align-items: center; justify-content: center; gap: 5px; padding: 12px 6px; background: #fffdf7; border: 1px solid #e6ddc6; border-radius: 10px; font-family: system-ui, sans-serif; font-weight: 600; font-size: 12.5px; color: #4a443b; cursor: pointer; box-shadow: 0 1px 2px rgba(60,50,30,.06); transition: background .12s; }
.sp-action:hover:not(:disabled) { background: #f3ecd9; }
.sp-action:disabled { opacity: .45; cursor: not-allowed; }
.sp-count { font-weight: 400; opacity: .7; font-size: 11px; }
.sp-autocand { display: flex; align-items: center; gap: 8px; padding: 2px; font-family: system-ui, sans-serif; font-size: 13px; color: #4a443b; cursor: pointer; user-select: none; }
.sp-autocand input { width: 16px; height: 16px; accent-color: #355e3b; cursor: pointer; }

.sp-hint-msg { margin-top: 14px; padding: 12px 14px; background: rgba(210, 154, 43, .10); border: 1px solid rgba(210, 154, 43, .45); border-radius: 8px; font-size: 14px; color: #4a443b; line-height: 1.5; }
.sp-hint-msg em { font-style: normal; font-weight: 700; color: #2b2620; }

/* ── Footer streak banner (stub) ────────────────────────────────────────── */
.sp-footer { display: flex; align-items: center; gap: 16px; margin-top: 22px; background: linear-gradient(180deg, #fffdf8, #faf4e6); border: 1px solid #e0d4b6; border-radius: 12px; padding: 16px 20px; box-shadow: inset 0 1px 0 #fff, 0 1px 2px rgba(60,50,30,.07); }
.sp-footer-text { flex: 1; }
.sp-footer-title { font-family: Georgia, serif; font-weight: 700; font-size: 17px; color: #2b2620; }
.sp-footer-sub { font-family: system-ui, sans-serif; font-size: 13px; color: #7a7468; margin-top: 2px; }
.sp-footer-badge { width: 62px; height: 62px; object-fit: contain; filter: drop-shadow(0 2px 3px rgba(60,50,30,.28)); }
.sp-footer-streak { display: flex; flex-direction: column; align-items: center; flex: 0 0 auto; }
.sp-footer-num { font-family: Georgia, serif; font-weight: 700; font-size: 24px; color: #5b2a6e; line-height: 1; margin-top: 4px; }
.sp-footer-lbl { font-family: system-ui, sans-serif; font-size: 9px; letter-spacing: 1.2px; color: #7a7468; margin-top: 2px; }

/* ── Completion modal ───────────────────────────────────────────────────── */
.sp-modal-backdrop { position: fixed; inset: 0; background: rgba(27,20,8,.55); display: flex; align-items: center; justify-content: center; z-index: 200; padding: 20px; }
.sp-modal-backdrop.hidden { display: none; }
.sp-modal { background: #fffdf7; border: 1px solid #e6ddc6; border-radius: 16px; box-shadow: 0 20px 50px rgba(0,0,0,.4); padding: 34px 34px 26px; max-width: 440px; width: 100%; text-align: center; animation: sp-pop .3s ease-out; }
@keyframes sp-pop { from { transform: scale(.94); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.sp-modal-stamp { display: inline-block; font-family: 'Alfa Slab One', Georgia, serif; font-size: 34px; font-weight: 400; letter-spacing: .5px; color: #b0832a; border: 3px solid #c79a3a; border-radius: 10px; padding: 12px 28px 8px; transform: rotate(-3deg); margin-bottom: 12px; box-shadow: 0 3px 10px rgba(120,90,30,.18); }
.sp-modal-sub { font-family: Georgia, serif; font-style: italic; font-size: 16px; color: #4a443b; margin-bottom: 18px; }
.sp-modal-stats { display: grid; grid-template-columns: repeat(2,1fr); max-width: 300px; margin: 14px auto 22px; border-top: 1px solid #e6ddc6; border-bottom: 1px solid #e6ddc6; padding: 14px 0; }
.sp-modal-stats > div { border-right: 1px solid #e6ddc6; }
.sp-modal-stats > div:last-child { border-right: none; }
.sp-modal-stats .n { display: block; font-family: Georgia, serif; font-size: 24px; font-weight: 700; color: #2b2620; }
.sp-modal-stats .l { font-family: system-ui, sans-serif; font-size: 11px; letter-spacing: .6px; text-transform: uppercase; color: #7a7468; }
.sp-modal-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.sp-modal-btn { font-family: system-ui, sans-serif; font-weight: 700; font-size: 13px; padding: 11px 20px; border-radius: 9px; cursor: pointer; border: 1px solid #2f6e42; text-decoration: none; display: inline-flex; align-items: center; }
.sp-modal-btn.primary { background: #2f6e42; color: #fff; }
.sp-modal-btn.primary:hover { filter: brightness(1.08); }
.sp-modal-btn.secondary { background: #fffdf7; color: #2f6e42; }
.sp-modal-btn.secondary:hover { background: #f3ecd9; }

/* ── Responsive ─────────────────────────────────────────────────────────── */
/* Stack: board on top, controls below. Pad becomes 5 wide rectangular keys
   (1-5 / 6-9 + erase), NYT-mobile style. */
@media (max-width: 900px) {
  .sp-main { grid-template-columns: 1fr; gap: 18px; }
  .sp-board-wrap { padding: 9px; border-radius: 14px; }
  .sg-paused-mask { inset: 9px; }
  .sp-controls { max-width: 460px; margin: 0 auto; width: 100%; }
  .sp-pad { grid-template-columns: repeat(5, 1fr); gap: 8px; }
  .sg-pad-btn, .sp-erasebtn { aspect-ratio: auto; height: 58px; font-size: 28px; }
  .sp-erasebtn { grid-column: auto; }
}

/* ── Completion celebration: confetti (mirrors the jigsaw) ───────────────── */
.sg-confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 9999; }
.sg-confetti span { position: absolute; top: -10px; width: 8px; height: 14px; opacity: .9; animation: sg-fall 2.6s linear forwards; }
@keyframes sg-fall { to { transform: translateY(110vh) rotate(720deg); opacity: 0; } }

/* Achievement-unlocked line in the completion modal. */
.sp-modal-ach { margin: 2px auto 14px; max-width: 320px; padding: 9px 14px; border-radius: 10px;
  background: rgba(216,181,107,.14); border: 1px solid rgba(216,181,107,.45); color: #6a5326;
  font: 600 13px system-ui, sans-serif; line-height: 1.4; }
.sp-modal-ach b { color: #4a3a12; }
.sp-modal-ach .sp-ach-pts { color: #1f6047; font-weight: 700; white-space: nowrap; }

/* ── Responsive doctrine (matches the other games): the board is height-
      capped everywhere (max() floor so the calc can't go negative), the
      streak banner yields on constrained screens, and short-wide phones get
      the two-column game layout with hidden clubhouse chrome. Last in file
      on purpose — these must win the cascade. ─────────────────────────────── */
@media (min-width: 901px) {
  /* width:min() not max-width+auto-margins: an auto-margined grid item stops
     stretching and collapses circularly with the board’s percentage width */
  .sp-board-wrap { width: min(100%, max(320px, calc(100vh - 345px))); justify-self: center; }
}
@media (max-height: 980px) and (min-width: 901px) {
  .sp-footer { margin-top: 14px; padding: 10px 16px; }
  .sp-footer-badge { width: 44px; height: 44px; }
}
@media (max-height: 940px) and (min-width: 901px) {
  .sp-controls { gap: 10px; }
  .sg-pad-btn { aspect-ratio: auto; height: 48px; font-size: 24px; }
  .sp-erasebtn { height: 40px; }
  .sp-action { padding: 9px 6px; }
}
@media (max-height: 840px) and (min-width: 901px) {
  .sp-footer { display: none; }
  .sp-board-wrap { width: min(100%, max(320px, calc(100vh - 300px))); }
}
@media (max-width: 560px) {
  .sp-statbar { padding: 8px 10px; }
  .sp-badge { font-size: 10px; padding: 5px 10px; margin-right: 8px; letter-spacing: .6px; }
  .sp-stat { padding: 0 6px; }
  .sp-stat-l { font-size: 9.5px; letter-spacing: .4px; }
  .sp-stat-v { font-size: 17px; margin-top: 1px; }
  .sp-header { margin-bottom: 10px; }
  .sp-main { gap: 10px; }
  .sp-statbar { margin-bottom: 10px; }
  /* short phones: a smaller board beats scrolling to reach the numpad */
  .sp-board-wrap { width: min(100%, max(280px, calc(100vh - 360px))); justify-self: center; }
  .sp-footer { display: none; }   /* motivational stub — the lobby owns streaks */
  .ch-content { padding-bottom: 6px; }
}
@media (max-height: 520px) and (min-aspect-ratio: 3/2) {
  .ch-mobilebar { display: none; }
  .ch-main { padding-top: 0; }
  .ch-content { padding: 6px 12px 8px; }
  /* Two-pane split: full-height board left, everything else in a right rail.
     display:contents dissolves .sp-main so the board and controls become
     grid items of .sp-page alongside the header and statbar. */
  .sp-page { display: grid; grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: auto auto minmax(0, 1fr); gap: 6px 14px; max-width: none; }
  .sp-main { display: contents; }
  .sp-board-wrap { grid-column: 1; grid-row: 1 / -1; padding: 8px; justify-self: start;
    width: calc(100vh - 18px); width: calc(100svh - 18px); }
  .sg-paused-mask { inset: 8px; }
  .sp-header { grid-column: 2; grid-row: 1; margin-bottom: 0; }
  .sp-iconbtn { width: 32px; height: 32px; }
  .sp-statbar { grid-column: 2; grid-row: 2; padding: 4px 10px; margin-bottom: 0; }
  .sp-badge { padding: 5px 12px; margin-right: 10px; }
  .sp-stat-l { display: inline; font-size: 10px; margin-right: 6px; }
  .sp-stat-v { display: inline; font-size: 16px; margin-top: 0; }
  .sp-controls { grid-column: 2; grid-row: 3; max-width: none; margin: 0; min-height: 0;
    overflow-y: auto; scrollbar-width: thin; scrollbar-color: #cfc3a4 #f3ecd9; gap: 8px; }
  /* 5-wide pad: 1-5 / 6-9 + erase — no orphan erase row. */
  .sp-pad { grid-template-columns: repeat(5, 1fr); gap: 6px; }
  .sg-pad-btn, .sp-erasebtn { height: 44px; font-size: 22px; }
  .sp-erasebtn { grid-column: auto; }
  .sp-modebtn span { padding: 8px 8px; }
  .sp-action { padding: 8px 6px; }
  .sp-hint-msg { grid-column: 2; margin-top: 0; }
  .sp-footer { display: none; }
}
