@layer game {
:root {
  --sudoku-board-size: min(calc(100vh - 16.25rem), calc(100vw - 28rem), 720px);
  --sudoku-cell-size: calc(var(--sudoku-board-size) / 9);
  --sudoku-accent: #2335C9;
  --sudoku-ink: #f6f3eb;
  --sudoku-muted: #9ea7b4;
  --sudoku-line: #343a45;
  --sudoku-line-strong: #88919e;
  --sudoku-surface: rgba(15, 17, 22, 0.78);
  --sudoku-surface-strong: rgba(20, 23, 29, 0.96);
  --sudoku-border: rgba(255, 255, 255, 0.13);
  --sudoku-panel: rgba(14, 16, 21, 0.76);
  --sudoku-cell: #11151b;
  --sudoku-cell-fixed: #1d222b;
  --sudoku-user: #8fd3ff;
  --sudoku-blue: #6aa6ff;
  --sudoku-green: #3fdc97;
  --sudoku-red: #f05d7b;
  --sudoku-violet: #b58cff;
}

body.game-mode {
  background:
    repeating-linear-gradient(0deg, transparent 0 15px, rgba(194, 195, 154, 0.035) 15px 16px),
    repeating-linear-gradient(90deg, transparent 0 15px, rgba(194, 195, 154, 0.035) 15px 16px),
    #FAFAF8;
}

.game-mode-native-wrapper.sudoku-shell {
  width: min(100%, 1240px);
  height: calc(100vh - 5.25rem);
  min-height: 0;
  justify-content: flex-start;
  gap: 0.7rem;
  margin: 0 auto;
  overflow: hidden;
  padding: 0.55rem 0.8rem;
}

body.game-mode .game-credits {
  color: var(--sudoku-muted);
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.sudoku-statusbar {
  width: min(100%, calc(var(--sudoku-board-size) + 2rem));
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0;
  align-items: center;
  justify-self: center;
  padding: 0.4rem 0.45rem;
  background: #20281f;
  border: 1px solid var(--sudoku-border);
  border-top-color: rgba(35, 53, 201, 0.5);
  border-radius: 12px;
  box-shadow: 0 0.7rem 2rem rgba(0, 0, 0, 0.18);
  backdrop-filter: none;
}

.stat-item {
  min-width: 0;
  padding: 0.08rem 0.55rem;
  color: var(--sudoku-ink);
  text-align: center;
}

.stat-item + .stat-item {
  border-left: 1px solid rgba(255, 255, 255, 0.09);
}

.stat-label,
.panel-title,
.best-times-title {
  display: block;
  color: var(--sudoku-muted);
  font-family: var(--font-body);
  font-size: 0.58rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  line-height: 1;
  text-transform: uppercase;
}

.stat-value {
  display: block;
  overflow: hidden;
  margin-top: 0.12rem;
  color: var(--sudoku-ink);
  font-family: var(--font-body);
  font-size: 0.98rem;
  font-weight: 900;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.sudoku-layout {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(150px, 190px) minmax(420px, var(--sudoku-board-size)) minmax(210px, 250px);
  gap: clamp(0.7rem, 1.5vw, 1.35rem);
  align-items: center;
  justify-content: center;
  min-height: 0;
}

.sudoku-stage {
  display: grid;
  gap: 0.42rem;
  justify-items: center;
  min-width: 0;
}

.sudoku-panel {
  display: grid;
  align-content: center;
  gap: 0.72rem;
  min-width: 0;
  padding: 0.8rem;
  background: var(--sudoku-panel);
  border: 1px solid var(--sudoku-border);
  border-radius: 14px;
  box-shadow: 0 1rem 2.5rem rgba(0, 0, 0, 0.2);
}

.sudoku-panel-right {
  position: relative;
}

.game-options-drawer {
  min-width: 0;
}

.game-options-drawer > summary {
  display: none;
}

.game-options-content,
.game-options-drawer:not([open]) > .game-options-content {
  display: grid;
  gap: 0.72rem;
}

.sudoku-panel-left::before {
  content: "Partida";
}

.sudoku-panel-left::before,
.control-heading {
  color: var(--sudoku-muted);
  font-family: var(--font-body);
  font-size: 0.62rem;
  font-weight: 900;
  letter-spacing: 0.09em;
  line-height: 1;
  text-transform: uppercase;
}

.sudoku-panel-left::before {
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--sudoku-border);
}

.control-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.control-heading span:last-child {
  color: var(--sudoku-muted);
  font-size: 0.54rem;
  letter-spacing: 0.06em;
}

.control-heading-tools {
  margin-top: 0.12rem;
  padding-top: 0.72rem;
  border-top: 1px solid var(--sudoku-border);
}

.sheet-title {
  display: none;
  margin: 0;
  color: var(--sudoku-ink);
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 900;
  line-height: 1;
}

.panel-group {
  display: grid;
  gap: 0.44rem;
  min-width: 0;
}

.panel-group-quiet {
  padding: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  backdrop-filter: none;
}

.segmented,
.difficulty-selector {
  display: grid;
  gap: 0.36rem;
}

.segmented {
  grid-template-columns: 1fr;
}

.difficulty-selector {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.seg-btn,
.diff-btn,
.action-btn,
.num-btn,
.dialog-btn,
.secondary-actions > summary {
  min-width: 0;
  min-height: 2.45rem;
  border: 1px solid var(--sudoku-border);
  border-radius: 10px;
  background: rgba(10, 12, 16, 0.72);
  color: var(--sudoku-ink);
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1.05;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease, transform 0.1s ease, box-shadow 0.16s ease;
}

.seg-btn,
.diff-btn,
.action-btn,
.secondary-actions > summary {
  font-size: 0.74rem;
}

.seg-btn:hover,
.diff-btn:hover,
.action-btn:hover,
.num-btn:hover,
.dialog-btn:hover,
.secondary-actions > summary:hover,
.seg-btn:focus-visible,
.diff-btn:focus-visible,
.action-btn:focus-visible,
.num-btn:focus-visible,
.dialog-btn:focus-visible,
.secondary-actions > summary:focus-visible {
  border-color: rgba(35, 53, 201, 0.78);
  outline: none;
  box-shadow: 0 0 0 2px rgba(35, 53, 201, 0.14);
}

.seg-btn:active,
.diff-btn:active,
.action-btn:active,
.num-btn:active,
.dialog-btn:active,
.secondary-actions > summary:active {
  transform: translateY(1px);
}

.seg-btn.active,
.diff-btn.active,
.action-btn.active,
.action-btn.primary,
.dialog-btn.primary {
  border-color: rgba(35, 53, 201, 0.94);
  background: var(--sudoku-accent);
  color: #08090b;
  box-shadow: 0 0.45rem 1.2rem rgba(35, 53, 201, 0.16);
}

.daily-compact {
  padding-top: 0.2rem;
}

.mini-stat {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  color: var(--sudoku-muted);
  font-family: var(--font-body);
  font-size: 0.78rem;
}

.mini-stat strong {
  color: var(--sudoku-ink);
  font-size: 0.9rem;
}

.daily-history {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.24rem;
}

.daily-dot {
  width: 100%;
  aspect-ratio: 1;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
}

.daily-dot.completed {
  background: var(--sudoku-accent);
}

.secondary-actions {
  position: relative;
  min-width: 0;
}

.secondary-actions > summary {
  display: grid;
  place-items: center;
  list-style: none;
}

.secondary-actions > summary::-webkit-details-marker {
  display: none;
}

.secondary-actions[open] > summary {
  border-color: rgba(35, 53, 201, 0.78);
  background: rgba(35, 53, 201, 0.12);
}

.secondary-actions:not([open]) > .tool-grid,
.secondary-actions:not([open]) > .compact-stats,
.secondary-actions:not([open]) > .sudoku-best-times {
  display: none;
}

.secondary-actions .tool-grid,
.secondary-actions .compact-stats,
.secondary-actions .sudoku-best-times {
  margin-top: 0.45rem;
}

.primary-tools .secondary-actions > summary {
  height: 100%;
  min-height: 2.85rem;
}

.primary-tools .secondary-actions .secondary-tools {
  position: absolute;
  right: 0;
  top: calc(100% + 0.5rem);
  z-index: 12;
  width: min(250px, 100%);
  padding: 0.55rem;
  background: rgba(12, 14, 18, 0.98);
  border: 1px solid var(--sudoku-border);
  border-radius: 12px;
  box-shadow: 0 1rem 2.5rem rgba(0, 0, 0, 0.42);
}

.stats-drawer .panel-group,
.stats-drawer .sudoku-best-times {
  padding: 0.55rem 0;
  background: transparent;
  border: 0;
  box-shadow: none;
  backdrop-filter: none;
}

.sudoku-board-container {
  position: relative;
  box-sizing: border-box;
  padding: 0.65rem;
  background: #343c2f;
  border: 2px solid #FAFAF8;
  border-radius: 0;
  box-shadow:
    inset 2px 2px 0 #929a78,
    inset -3px -3px 0 #171c15,
    2px 2px 0 #293124,
    4px 4px 0 #1b2119,
    6px 6px 0 #10140f,
    8px 8px 0 #050705;
  image-rendering: auto;
  isolation: isolate;
}

.sudoku-board-container::before,
.sudoku-board-container::after {
  content: "";
  position: absolute;
  width: 5px;
  height: 5px;
  pointer-events: none;
  background: #b3ac75;
  box-shadow: 1px 1px 0 #FAFAF8;
  z-index: 6;
}

.sudoku-board-container::before {
  top: 3px;
  left: 3px;
}

.sudoku-board-container::after {
  right: 4px;
  bottom: 4px;
}

.sudoku-grid {
  position: relative;
  display: grid;
  grid-template-columns: repeat(9, var(--sudoku-cell-size));
  grid-template-rows: repeat(9, var(--sudoku-cell-size));
  overflow: hidden;
  background: #FAFAF8;
  border: 2px solid #FAFAF8;
  border-right-color: #6e765d;
  border-bottom-color: #6e765d;
  border-radius: 0;
  box-shadow:
    -2px -2px 0 #111610,
    2px 2px 0 #4a5340;
  isolation: isolate;
}

.sudoku-row {
  display: contents;
}

.sudoku-cell {
  position: relative;
  box-sizing: border-box;
  width: var(--sudoku-cell-size);
  height: var(--sudoku-cell-size);
  padding: 0;
  border: 0;
  border-top: 1px solid #46513f;
  border-right: 2px solid #0b100c;
  border-bottom: 2px solid #FAFAF8;
  border-left: 1px solid #3b4637;
  border-radius: 0;
  background: #202820;
  color: #e9e6c9;
  cursor: pointer;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  outline: none;
  box-shadow:
    inset 1px 1px 0 #303a2d,
    inset -1px -1px 0 #131914;
  image-rendering: auto;
  transition: none;
  user-select: none;
}

.sudoku-cell:nth-child(3n) {
  border-right-color: #030503;
  border-right-width: 4px;
}

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

.sudoku-row:nth-child(3) .sudoku-cell,
.sudoku-row:nth-child(6) .sudoku-cell {
  border-bottom-color: #030503;
  border-bottom-width: 4px;
}

.sudoku-row:nth-child(9) .sudoku-cell {
  border-bottom: 1px solid #FAFAF8;
}

.sudoku-cell:hover,
.sudoku-cell:focus-visible {
  background: #394230;
  box-shadow:
    inset 2px 2px 0 #f2c949,
    inset -2px -2px 0 #756019;
  z-index: 3;
}

.sudoku-cell.initial {
  background: #333d30;
  box-shadow:
    inset 1px 1px 0 #56634e,
    inset -2px -2px 0 #1a211a;
}

.sudoku-cell.user-filled:not(.selected) {
  background: #173033;
  box-shadow:
    inset 1px 1px 0 #315358,
    inset -2px -2px 0 #0b181a;
}

.sudoku-cell.related:not(.selected) {
  background: #293329;
}

.sudoku-cell.same-number:not(.selected) {
  background: #554618;
  box-shadow:
    inset 2px 2px 0 #8b7830,
    inset -2px -2px 0 #241d09;
}

.sudoku-cell.selected {
  background: #2335C9;
  color: #050607;
  box-shadow:
    inset 2px 2px 0 #ffe277,
    inset -3px -3px 0 #76530a,
    2px 2px 0 #050705;
  transform: translate(-1px, -1px);
  z-index: 4;
}

.sudoku-cell.conflict,
.sudoku-cell.review-error {
  background: #5b2724;
  box-shadow:
    inset 2px 2px 0 #c05d4d,
    inset -3px -3px 0 #260d0c;
}

.sudoku-cell.conflict::after,
.sudoku-cell.review-error::after {
  content: "!";
  position: absolute;
  top: 0.18rem;
  right: 0.24rem;
  color: #fff;
  font-size: calc(var(--sudoku-cell-size) * 0.2);
  font-weight: 900;
}

.sudoku-cell.hint-used:not(.selected) {
  background: #17343d;
}

.sudoku-cell.hint-used::before,
.sudoku-cell.technique-cell::before {
  content: "";
  position: absolute;
  top: 0.22rem;
  left: 0.22rem;
  width: 0.38rem;
  height: 0.38rem;
  border-radius: 0;
  background: #65aeb3;
  box-shadow: 2px 2px 0 #173238;
  z-index: 2;
}

.sudoku-cell.technique-cell {
  box-shadow:
    inset 2px 2px 0 #c1a5d0,
    inset -3px -3px 0 #5a3d68;
}

.sudoku-cell.candidate-eliminated {
  box-shadow:
    inset 2px 2px 0 #e47863,
    inset -3px -3px 0 #66251f;
}

.cell-value {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  font-size: calc(var(--sudoku-cell-size) * 0.52);
  font-weight: 900;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  text-shadow: 2px 2px 0 #FAFAF8;
}

.notes-grid[hidden] {
  display: none !important;
}

.initial .cell-value {
  color: #e9e6c9;
}

.user-filled .cell-value {
  color: #78c8c8;
}

.selected .cell-value {
  color: #050607;
  text-shadow: none;
}

.notes-grid {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  padding: max(2px, calc(var(--sudoku-cell-size) * 0.06));
}

.note {
  display: grid;
  min-width: 0;
  place-items: center;
  color: #aeb79b;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: max(0.52rem, calc(var(--sudoku-cell-size) * 0.18));
  font-weight: 900;
  line-height: 1;
  text-shadow: 1px 1px 0 #FAFAF8;
}

.notes-mode .note {
  color: #e7c45d;
}

.sudoku-grid.is-paused .sudoku-cell,
.sudoku-grid.is-generating .sudoku-cell {
  color: transparent;
}

.sudoku-grid.is-paused .notes-grid,
.sudoku-grid.is-generating .notes-grid {
  visibility: hidden;
}

.sudoku-grid.is-paused::after,
.sudoku-grid.is-generating::after {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: #0d120e;
  color: #2335C9;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: clamp(2rem, 9vw, 4.5rem);
  font-weight: 900;
  letter-spacing: 0.08em;
  box-shadow:
    inset 5px 5px 0 #293328,
    inset -5px -5px 0 #030503;
  text-shadow: 3px 3px 0 #4d3708;
  text-align: center;
  z-index: 8;
}

.sudoku-grid.is-paused::after {
  content: "Pausa";
}

.sudoku-grid.is-generating::after {
  content: attr(data-loading-text);
  padding: 2rem;
  font-size: clamp(1.4rem, 4vw, 3rem);
}

.sudoku-progress {
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.5rem;
  align-items: center;
  box-sizing: border-box;
  padding: 0 0.15rem;
}

.progress-track {
  height: 0.42rem;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
}

.progress-fill {
  width: 0%;
  height: 100%;
  background: repeating-linear-gradient(90deg, #2335C9 0 8px, #6e5517 8px 10px);
  border-radius: inherit;
  transition: width 0.28s ease;
}

.progress-label,
.progress-text,
.sudoku-status {
  color: var(--sudoku-ink);
  font-family: var(--font-body);
  font-weight: 900;
}

.progress-label {
  color: var(--sudoku-muted);
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.progress-text {
  min-width: 2.6rem;
  color: var(--sudoku-muted);
  font-size: 0.74rem;
  text-align: right;
}

.sudoku-status {
  min-height: 0;
  color: #d8dde7;
  font-size: 0.84rem;
  text-align: center;
}

.sudoku-status:empty {
  display: none;
}

.sudoku-status[data-tone="danger"] {
  color: #ffc2cd;
}

.sudoku-status.flash {
  animation: statusFlash 0.22s ease both;
}

.number-pad {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.46rem;
}

.num-btn {
  position: relative;
  min-height: clamp(3rem, 8.5vh, 4.45rem);
  overflow: hidden;
  background: #20281f;
  font-size: 1.35rem;
  font-variant-numeric: tabular-nums;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.34), 0 0.35rem 0.8rem rgba(0, 0, 0, 0.12);
}

.num-btn:not(.erase)::after {
  content: attr(data-remaining);
  position: absolute;
  top: 0.34rem;
  right: 0.38rem;
  min-width: 1rem;
  padding: 0.12rem 0.2rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--sudoku-muted);
  font-size: 0.54rem;
  line-height: 1;
}

.num-btn.erase {
  grid-column: span 3;
  min-height: 2.8rem;
  color: #ffd3db;
  font-size: 0.86rem;
}

.num-btn.selected-number {
  border-color: var(--sudoku-accent);
  background: rgba(35, 53, 201, 0.2);
  box-shadow: inset 0 0 0 1px rgba(35, 53, 201, 0.28), 0 0.5rem 1.2rem rgba(35, 53, 201, 0.12);
}

.num-btn.visible-complete::after {
  content: "✓";
  background: rgba(63, 220, 151, 0.14);
  color: var(--sudoku-green);
}

.num-btn.visible-complete:not(.selected-number) {
  color: rgba(246, 243, 235, 0.58);
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.44rem;
}

.primary-tools {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.primary-tools .action-btn {
  min-height: 2.85rem;
}

.secondary-tools {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.secondary-tools .action-btn {
  min-height: 2.35rem;
  font-size: 0.7rem;
}

.action-btn:disabled,
.num-btn:disabled,
.dialog-btn:disabled {
  opacity: 0.62;
  cursor: not-allowed;
}

.action-btn[aria-pressed="true"],
.action-btn.active {
  box-shadow: 0 0 0 2px rgba(35, 53, 201, 0.2), inset 0 -2px 0 rgba(0, 0, 0, 0.18);
}

.sudoku-sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(0, 0, 0, 0.58);
  opacity: 0;
  backdrop-filter: none;
  transition: opacity 0.18s ease;
}

.sudoku-sheet-backdrop.is-visible {
  opacity: 1;
}

.sudoku-sheet-backdrop[hidden] {
  display: none;
}

.sudoku-sheet-lock {
  overflow: hidden;
  overscroll-behavior: none;
}

.sudoku-dialog-lock {
  overflow: hidden;
  overscroll-behavior: none;
}

.hint-panel {
  display: grid;
  gap: 0.48rem;
  padding: 0.7rem;
  background: var(--sudoku-surface);
  border: 1px solid var(--sudoku-border);
  border-radius: 8px;
}

.hint-panel[hidden] {
  display: none;
}

.hint-title {
  color: var(--sudoku-accent);
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 900;
  line-height: 1;
}

.hint-body {
  margin: 0;
  color: #e6e8ed;
  font-family: var(--font-body);
  font-size: 0.86rem;
  line-height: 1.35;
}

.hint-meta {
  color: var(--sudoku-muted);
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 800;
}

.hint-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
}

.sudoku-best-times {
  display: grid;
  gap: 0.38rem;
}

.best-times-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.3rem;
}

.best-time-item {
  min-width: 0;
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  color: var(--sudoku-muted);
  font-family: var(--font-body);
  font-size: 0.74rem;
}

.best-time-diff,
.best-time-detail {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.best-time-detail {
  color: var(--sudoku-ink);
  font-weight: 900;
}

.sudoku-dialog {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
  background: rgba(0, 0, 0, 0.74);
  backdrop-filter: none;
}

.sudoku-dialog[hidden] {
  display: none;
}

.dialog-panel {
  box-sizing: border-box;
  width: min(100%, 420px);
  max-height: min(100%, calc(100vh - 2rem));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  padding: 1.25rem;
  background: #20281f;
  border: 1px solid var(--sudoku-border);
  border-top-color: rgba(35, 53, 201, 0.62);
  border-radius: 16px;
  color: var(--sudoku-ink);
  text-align: center;
  box-shadow: 0 1.5rem 4rem rgba(0, 0, 0, 0.48);
  animation: dialogEnter 0.18s ease both;
}

.dialog-panel-wide {
  width: min(100%, 640px);
  text-align: left;
}

.sudoku-dialog.celebrate .dialog-panel {
  animation: dialogEnter 0.18s ease both, winGlow 0.9s ease both;
}

.dialog-title {
  margin: 0 0 0.55rem;
  color: var(--sudoku-accent);
  font-family: var(--font-display);
  font-size: 2rem;
  line-height: 1;
}

.dialog-body {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  margin: 0 0 1rem;
  color: #e0e3ea;
  font-family: var(--font-body);
  line-height: 1.45;
  white-space: pre-line;
}

.dialog-body-structured {
  display: grid;
  gap: 0.85rem;
  padding-right: 0.15rem;
  white-space: normal;
}

.help-section {
  display: grid;
  gap: 0.35rem;
}

.help-section h3 {
  margin: 0;
  color: var(--sudoku-accent);
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 900;
  line-height: 1.2;
}

.help-section p,
.help-section ul {
  margin: 0;
  color: #e0e3ea;
  font-size: 0.94rem;
  line-height: 1.45;
}

.help-section ul {
  padding-left: 1.15rem;
}

.help-section li + li {
  margin-top: 0.22rem;
}

.dialog-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(12rem, 100%), 1fr));
  gap: 0.5rem;
}

.dialog-actions button {
  min-height: 2.5rem;
}

@media (max-width: 1040px) {
  :root {
    --sudoku-board-size: min(calc(100vw - 2rem), calc(100vh - 18rem), 560px);
  }

  .game-mode-native-wrapper.sudoku-shell {
    height: auto;
    overflow: visible;
  }

  .sudoku-layout {
    grid-template-columns: minmax(0, 1fr) minmax(340px, var(--sudoku-board-size));
    grid-template-areas:
      "stage stage"
      "left right";
    align-items: start;
  }

  .sudoku-stage {
    grid-area: stage;
  }

  .sudoku-panel-left {
    grid-area: left;
  }

  .sudoku-panel-right {
    grid-area: right;
  }

  .segmented {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  :root {
    --sudoku-board-size: min(calc(100vw - 2rem), 430px);
  }

  body.game-mode .main-content {
    overflow-y: auto;
    overscroll-behavior-y: contain;
  }

  .game-mode-native-wrapper.sudoku-shell {
    gap: 0.36rem;
    padding: 0.38rem 0.5rem max(0.72rem, env(safe-area-inset-bottom));
  }

  .sudoku-statusbar {
    width: 100%;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    padding: 0.22rem 0.24rem;
    border-radius: 10px;
  }

  .stat-item {
    padding: 0.04rem 0.22rem;
  }

  .stat-label {
    font-size: 0.52rem;
    line-height: 1.05;
  }

  .stat-value {
    font-size: 0.84rem;
  }

  .sudoku-layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "stage"
      "right"
      "left";
    gap: 0.42rem;
  }

  .sudoku-panel-left {
    width: 100%;
    grid-template-columns: 1fr;
    align-content: start;
    gap: 0;
    padding: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
    backdrop-filter: none;
  }

  .sudoku-panel-left::before {
    display: none;
  }

  .sudoku-panel-right {
    padding: 0.45rem;
    border-radius: 12px;
  }

  .control-heading {
    display: none;
  }

  .game-options-drawer {
    width: 100%;
  }

  .game-options-drawer > summary,
  .primary-tools .secondary-actions > summary {
    min-height: 2.65rem;
    display: grid;
    place-items: center;
    list-style: none;
    border: 1px solid rgba(255, 255, 255, 0.11);
    border-radius: 8px;
    background: rgba(10, 11, 13, 0.74);
    color: var(--sudoku-ink);
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 0.74rem;
    font-weight: 900;
  }

  .primary-tools .secondary-actions > summary::after,
  .game-options-drawer > summary::after {
    content: "";
    width: 0.42rem;
    height: 0.42rem;
    margin-left: 0.35rem;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg) translateY(-1px);
  }

  .primary-tools .secondary-actions > summary,
  .game-options-drawer > summary {
    grid-auto-flow: column;
    justify-content: center;
  }

  .game-options-drawer > summary::-webkit-details-marker,
  .primary-tools .secondary-actions > summary::-webkit-details-marker {
    display: none;
  }

  .game-options-drawer:not([open]) > .game-options-content {
    display: none;
  }

  .game-options-drawer[open] > .game-options-content,
  .primary-tools .secondary-actions[open] .secondary-tools {
    display: grid;
    gap: 0.58rem;
    position: fixed;
    top: auto;
    right: max(0.65rem, env(safe-area-inset-right));
    bottom: max(4.35rem, calc(env(safe-area-inset-bottom) + 4.35rem));
    left: max(0.65rem, env(safe-area-inset-left));
    z-index: 502;
    width: auto;
    max-height: min(62vh, calc(100vh - 5.35rem - env(safe-area-inset-top)), 28rem);
    margin-top: 0;
    padding: 0.72rem 0.72rem max(0.72rem, env(safe-area-inset-bottom));
    overflow-y: auto;
    overscroll-behavior: contain;
    background: rgba(10, 11, 13, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px 12px 8px 8px;
    box-shadow: 0 1rem 2.5rem rgba(0, 0, 0, 0.48);
    transform: translateY(0);
    animation: sheetEnter 0.18s ease both;
  }

  .sheet-title {
    display: block;
    padding: 0.1rem 0 0.05rem;
    text-align: center;
  }

  .stats-drawer .sudoku-best-times {
    display: none;
  }

  .number-pad {
    width: 100%;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.38rem;
  }

  .num-btn {
    min-height: 3.35rem;
    display: grid;
    place-items: center;
    border-color: rgba(255, 255, 255, 0.14);
    background: #20281f;
    font-size: 1.28rem;
  }

  .num-btn:not(.erase)::after {
    top: 0.26rem;
    right: 0.28rem;
    min-width: 0.9rem;
    font-size: 0.5rem;
  }

  .num-btn.erase {
    grid-column: auto;
    color: var(--sudoku-ink);
    font-size: 0.7rem;
  }

  .primary-tools {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
    gap: 0.38rem;
  }

  .secondary-tools {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .action-btn,
  .secondary-actions > summary {
    min-height: 2.75rem;
    font-size: 0.7rem;
  }

  #btn-pause {
    border-color: rgba(35, 53, 201, 0.48);
  }

  .sudoku-status {
    position: fixed;
    right: max(0.75rem, env(safe-area-inset-right));
    bottom: max(0.8rem, env(safe-area-inset-bottom));
    left: max(0.75rem, env(safe-area-inset-left));
    z-index: 90;
    display: block;
    width: auto;
    max-width: none;
    min-height: 0;
    padding: 0.62rem 0.75rem;
    pointer-events: none;
    background: rgba(15, 17, 21, 0.94);
    border: 1px solid rgba(255, 255, 255, 0.13);
    border-radius: 8px;
    box-shadow: 0 0.9rem 2rem rgba(0, 0, 0, 0.42);
    opacity: 0;
    transform: translateY(0.45rem);
    transition: opacity 0.16s ease, transform 0.16s ease;
  }

  .sudoku-status.is-visible {
    opacity: 1;
    transform: translateY(0);
  }

  .dialog-panel {
    width: 100%;
    max-height: calc(100vh - max(2rem, env(safe-area-inset-top) + env(safe-area-inset-bottom) + 1.5rem));
    padding: 1rem;
  }

  .dialog-title {
    font-size: 1.45rem;
  }

  .help-section p,
  .help-section ul {
    font-size: 0.9rem;
  }
}

@media (max-width: 480px) {
  :root {
    --sudoku-board-size: min(calc(100vw - 2rem), 430px);
  }

  .sudoku-board-container {
    padding: 0.28rem;
  }

  .primary-tools,
  .secondary-tools {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 390px) {
  :root {
    --sudoku-board-size: min(calc(100vw - 2rem), 430px);
  }
}

@media (orientation: landscape) and (max-height: 560px) {
  :root {
    --sudoku-board-size: min(calc(100vh - 5.7rem), calc(100vw - 23rem));
  }

  .sudoku-statusbar,
  .stats-drawer {
    display: none;
  }

  .sudoku-panel-left::before,
  .control-heading {
    display: none;
  }

  .sudoku-panel {
    padding: 0.4rem;
    border-radius: 10px;
  }

  .sudoku-layout {
    grid-template-columns: minmax(160px, 200px) minmax(260px, var(--sudoku-board-size)) minmax(230px, 245px);
    grid-template-areas: "left stage right";
    align-items: center;
    gap: 0.35rem;
  }

  .game-options-drawer > summary,
  .primary-tools .secondary-actions > summary {
    min-height: 2rem;
    display: grid;
    grid-auto-flow: column;
    place-items: center;
    justify-content: center;
    list-style: none;
    border: 1px solid rgba(255, 255, 255, 0.11);
    border-radius: 8px;
    background: rgba(10, 11, 13, 0.74);
    color: var(--sudoku-ink);
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 0.66rem;
    font-weight: 900;
  }

  .game-options-drawer > summary::-webkit-details-marker,
  .primary-tools .secondary-actions > summary::-webkit-details-marker {
    display: none;
  }

  .game-options-drawer:not([open]) > .game-options-content {
    display: none;
  }

  .game-options-drawer[open] > .game-options-content,
  .primary-tools .secondary-actions[open] .secondary-tools {
    display: grid;
    gap: 0.45rem;
    position: fixed;
    top: auto;
    right: max(0.55rem, env(safe-area-inset-right));
    bottom: max(0.55rem, env(safe-area-inset-bottom));
    left: auto;
    z-index: 502;
    width: min(21rem, calc(100vw - 1.1rem));
    max-height: calc(100vh - 1.1rem);
    padding: 0.6rem;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: rgba(10, 11, 13, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    box-shadow: 0 1rem 2.5rem rgba(0, 0, 0, 0.48);
    animation: sheetEnter 0.18s ease both;
  }

  .sheet-title {
    display: block;
    padding: 0.05rem 0;
    text-align: center;
  }

  .number-pad {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.28rem;
  }

  .num-btn {
    min-height: 2rem;
  }

  .num-btn.erase {
    grid-column: auto;
  }

  .primary-tools {
    gap: 0.28rem;
  }

  .action-btn,
  .secondary-actions > summary {
    min-height: 2rem;
    font-size: 0.66rem;
  }

  .sudoku-panel {
    gap: 0.36rem;
  }

  .sudoku-dialog {
    align-items: stretch;
  }

  .dialog-panel {
    max-height: calc(100vh - 1.25rem);
    padding: 0.8rem;
  }

  .dialog-title {
    font-size: 1.25rem;
  }

  .dialog-body {
    margin-bottom: 0.65rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .game-options-drawer[open] > .game-options-content,
  .primary-tools .secondary-actions[open] .secondary-tools,
  .sudoku-sheet-backdrop {
    animation: none !important;
    transition: none !important;
  }
}

@keyframes sheetEnter {
  from {
    opacity: 0;
    transform: translateY(0.85rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes statusFlash {
  from {
    transform: translateY(0.18rem);
  }
  to {
    transform: translateY(0);
  }
}

@keyframes dialogEnter {
  from {
    opacity: 0;
    transform: translateY(0.45rem) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Perfil compartido: relieve pixelado, sin superficies SaaS ni efectos blandos. */
[data-game-profile="pixel-relief"] {
  --sudoku-ink: #eee9cb;
  --sudoku-muted: #aaa98a;
  --sudoku-border: #59634e;
  --sudoku-panel: #20281f;
  --sudoku-surface: #293227;
  --sudoku-surface-strong: #30392c;
}

[data-game-profile="pixel-relief"] :where(*) {
  border-radius: 0;
  backdrop-filter: none;
  filter: none;
}

body.game-mode:has([data-game-profile="pixel-relief"]) {
  background:
    repeating-linear-gradient(0deg, transparent 0 15px, rgba(194, 195, 154, 0.035) 15px 16px),
    repeating-linear-gradient(90deg, transparent 0 15px, rgba(194, 195, 154, 0.035) 15px 16px),
    #FAFAF8;
}

[data-game-profile="pixel-relief"] :is(
  .sudoku-statusbar,
  .sudoku-panel,
  .primary-tools .secondary-actions .secondary-tools,
  .hint-panel,
  .dialog-panel,
  .game-options-drawer[open] > .game-options-content,
  .primary-tools .secondary-actions[open] .secondary-tools,
  .sudoku-status
) {
  border: 2px solid #59634e;
  border-top-color: #a9ad86;
  border-left-color: #8d9477;
  border-right-color: #30382f;
  border-bottom-color: #30382f;
  border-radius: 0;
  background: #20281f;
  box-shadow: 3px 3px 0 #FAFAF8;
  backdrop-filter: none;
}

[data-game-profile="pixel-relief"] :is(
  .seg-btn,
  .diff-btn,
  .action-btn,
  .num-btn,
  .dialog-btn,
  .secondary-actions > summary,
  .game-options-drawer > summary
) {
  min-height: 44px;
  border: 2px solid;
  border-color: #8d9477 #343b31 #343b31 #747d65;
  border-radius: 0;
  background: #FAFAF8;
  color: #eee9cb;
  box-shadow: 3px 3px 0 #FAFAF8;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  text-transform: uppercase;
  transition: none;
}

[data-game-profile="pixel-relief"] :is(
  .seg-btn,
  .diff-btn,
  .action-btn,
  .num-btn,
  .dialog-btn,
  .secondary-actions > summary,
  .game-options-drawer > summary
):is(:hover, :focus-visible, .active, [aria-pressed="true"]) {
  border-color: #e1b43c #725817 #493708 #b68e25;
  background: #514519;
  color: #fff0ae;
  box-shadow: 2px 2px 0 #FAFAF8;
  transform: translate(1px, 1px);
}

[data-game-profile="pixel-relief"] .num-btn:not(.erase)::after {
  border-radius: 0;
  background: #111711;
  color: #c2c39a;
}

[data-game-profile="pixel-relief"] .progress-track {
  height: 8px;
  border: 1px solid #090c09;
  border-radius: 0;
  background: #111711;
  box-shadow: inset 2px 2px 0 #050705;
}

[data-game-profile="pixel-relief"] .progress-fill {
  border-radius: 0;
  background: repeating-linear-gradient(90deg, #2335C9 0 8px, #6e5517 8px 10px);
  transition: width 120ms steps(6, end);
}

[data-game-profile="pixel-relief"] .sudoku-sheet-backdrop,
[data-game-profile="pixel-relief"] .sudoku-dialog {
  background: rgba(5, 7, 5, 0.9);
  backdrop-filter: none;
}

[data-game-profile="pixel-relief"] .dialog-panel {
  animation: none;
}

[data-game-profile="pixel-relief"] .sudoku-dialog.celebrate .dialog-panel {
  animation: none;
}

@media (max-width: 768px) {
  :root { --sudoku-board-size: min(calc(100vw - 1.4rem), 430px); }

  [data-game-profile="pixel-relief"] .game-mode-native-wrapper.sudoku-shell {
    padding-inline: 0.25rem;
  }

  [data-game-profile="pixel-relief"] .sudoku-panel-right {
    border-radius: 0;
  }
}

}
