/* Sudoku Slam base styles */
:root {
  color-scheme: light;
  --grid-cell-size: 52px;
  --grid-rendered-cell-size: var(--grid-cell-size);
  --grid-rendered-width: calc((var(--grid-rendered-cell-size) * 9) + 18px);
  --grid-number-size: 22pt;
  --grid-candidate-size: 11px;
  --bg-color: white;
  --text-color: #12253f;
  --text-muted: #4f6280;
  --text-soft: #6a7b95;
  --accent-color: #1f6fa8;
  --accent-strong: #195d8f;
  --accent-soft: #d8e9f8;
  --accent-soft-strong: #c7ddf2;
  --accent-border-soft: #a3c4df;
  --accent-border: #8db3d4;
  --accent-border-strong: #77a2ca;
  --highlight-disabled-color: var(--text-muted);
  --surface-muted: #dfe8f5;
  --surface-plain: #ffffff;
  --surface-soft: #f5f8fd;
  --surface-hover: #eaf1fa;
  --surface-alt: #f0f5fb;
  --border-strong: #2f4868;
  --border-color: #9eb1c9;
  --border-soft: #c8d4e4;
  --overlay-color: rgba(17, 32, 53, 0.56);
  --focus-ring: rgba(31, 111, 168, 0.34);
  --tooltip-bg: rgba(16, 32, 54, 0.95);
  --tooltip-text: #ffffff;
  --tooltip-shadow: rgba(7, 16, 30, 0.5);
  --warning-bg: #fff2d8;
  --warning-border: #d9ad67;
  --warning-text: #7b4d12;
  --warning-highlight-bg: #f6ead5;
  --danger-bg: #ffdfe5;
  --danger-border: #ca4d5d;
  --danger-text: #7d1f2c;
  --accent-on: #ffffff;
  --shadow-soft: rgba(18, 37, 63, 0.26);
  --font-stack: Open Sans, Arial, Helvetica, sans-serif;
}

body[data-theme="dark"] {
  color-scheme: dark;
  --bg-color: #101923;
  --text-color: #e5edf7;
  --text-muted: #adbacb;
  --text-soft: #91a0b4;
  --accent-color: #81c5ff;
  --accent-strong: #a8d7ff;
  --accent-soft: #18344c;
  --accent-soft-strong: #21435f;
  --accent-border-soft: #315976;
  --accent-border: #4b7595;
  --accent-border-strong: #6e9fc1;
  --highlight-disabled-color: #f5d792;
  --surface-muted: #1b2a39;
  --surface-plain: #14202b;
  --surface-soft: #192735;
  --surface-hover: #203446;
  --surface-alt: #172432;
  --border-strong: #d3e0ef;
  --border-color: #6d8096;
  --border-soft: #34495f;
  --overlay-color: rgba(4, 9, 15, 0.72);
  --focus-ring: rgba(129, 197, 255, 0.42);
  --tooltip-bg: rgba(5, 12, 20, 0.96);
  --tooltip-text: #f5f8fd;
  --tooltip-shadow: rgba(0, 0, 0, 0.7);
  --warning-bg: #302611;
  --warning-border: #8b6f37;
  --warning-text: #f5d792;
  --warning-highlight-bg: #3a301a;
  --danger-bg: #3b1720;
  --danger-border: #e0798a;
  --danger-text: #ffd5dc;
  --shadow-soft: rgba(0, 0, 0, 0.5);
}

body.board-size-small {
  --grid-cell-size: 44px;
  --grid-number-size: 20pt;
  --grid-candidate-size: 10px;
}

body.board-size-large {
  --grid-cell-size: 60px;
  --grid-number-size: 26pt;
  --grid-candidate-size: 13px;
}

body.board-size-xlarge {
  --grid-cell-size: 72px;
  --grid-number-size: 30pt;
  --grid-candidate-size: 16px;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg-color);
  color: var(--text-color);
  font-family: var(--font-stack);
  height: 100%;
  width: 100%;
  overflow-x: hidden;
}

body.modal-open {
  overflow: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Legacy layout --------------------------------------------------------- */

#page-container {
  max-width: 1420px;
  margin: 0 auto;
  padding: 2px 8px 24px;
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: flex-start;
  gap: 10px;
  box-sizing: border-box;
  user-select: none;
}

.hide-logo-toggle {
  font-size: 9px;
  text-align: center;
}

.text-center {
  text-align: center;
}

.centered-content {
  text-align: center;
}

.centered-content table {
  margin-left: auto;
  margin-right: auto;
}

.welcome-divider {
  width: 50%;
  border: 0;
  border-top: 1px solid var(--border-soft);
}

#left-column,
#right-column,
#board-column {
  position: static;
  margin: 0;
}

#left-column,
#right-column {
  width: 320px;
  flex: 0 0 320px;
}

#board-column {
  width: auto;
  flex: 0 1 auto;
  min-width: var(--grid-rendered-width);
  text-align: center;
}

#win-box {
  user-select: text;
}

#board-topbar {
  width: min(100%, 468px);
  margin: 0 auto 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

#dim {
  position: fixed;
  inset: 0;
  z-index: 69000;
  background: var(--overlay-color);
  display: none;
}

#tab-box {
  width: 320px;
  border: 1px solid var(--border-color);
  border-radius: 0;
  background: var(--surface-muted);
  box-shadow: none;
  overflow: hidden;
}

#inner-tab-box {
  width: 100%;
  border-collapse: collapse;
  text-align: center;
  font-size: smaller;
}

#inner-tab-box td {
  position: relative;
  padding: 5px 0;
  font-weight: 400;
  color: var(--text-color);
  cursor: pointer;
  transition: none;
}

#inner-tab-box td:hover,
#inner-tab-box td:focus {
  background: transparent;
  color: var(--accent-color);
}

#inner-tab-box td::after {
  display: none;
}

#inner-tab-box td.active::after,
#inner-tab-box td.selected::after {
  background: var(--accent-color);
}

#inner-tab-box td[style*="teal"] {
  color: var(--accent-color) !important;
}

#inner-tab-box td[style*="teal"]::after {
  display: none;
}

.panel {
  display: none;
  font-size: 0.9rem;
  color: var(--text-color);
}

.panel.visible {
  display: block;
}

#panel {
  position: relative;
  background: var(--surface-plain);
  border: 1px solid var(--border-color);
  border-radius: 0;
  padding: 4px 8px;
  box-shadow: none;
}

#panel-help {
  position: absolute;
  top: 12px;
  right: 12px;
  cursor: pointer;
  z-index: 10;
}

.action {
  cursor: pointer;
}

.actioninput {
  cursor: pointer;
}

#dark_mode {
  color: var(--text-color);
  background: var(--surface-plain);
  border: 1px solid var(--border-color);
  border-radius: 3px;
  font: inherit;
  font-size: smaller;
}

.highlight {
  border-collapse: collapse;
  border: 1px solid var(--border-strong);
  width: 11%;
  cursor: pointer;
  font-size: large;
}

.highlight-selected {
  border-color: var(--border-strong);
  box-shadow: inset 0 0 0 2px var(--border-strong);
}

.highlight-disabled {
  color: var(--highlight-disabled-color);
  cursor: default;
}

.highlight:hover,
.action:hover,
.action:focus {
  color: var(--accent-color);
}

.optiontable {
  width: 320px;
  margin: 0;
  border-collapse: collapse;
  border: 1px solid var(--border-color);
  border-radius: 0;
  overflow: hidden;
  box-shadow: none;
  background: var(--surface-plain);
}

.optionheader {
  padding: 5px 8px;
  background: var(--surface-muted);
  color: var(--text-color);
  font-weight: 400;
  font-size: 0.95rem;
  letter-spacing: 0;
}

.optionbody {
  padding: 4px;
  background: var(--surface-plain);
  color: var(--text-color);
  font-size: 0.9rem;
}

.recent-bookmarks {
  text-align: center;
  padding: 4px;
}

.mode-box {
  border: 2px solid var(--border-strong);
  width: 100px;
  text-align: center;
  background: var(--surface-muted);
  cursor: pointer;
  font-size: larger;
}

.board-size-label {
  display: inline-block;
  margin-top: 8px;
}

.board-size-slider {
  width: 180px;
  max-width: 100%;
  margin: 4px 0 2px;
  accent-color: var(--accent-color);
}

.off-display {
  position: absolute;
  right: 35px;
}

/* Grid ------------------------------------------------------------------ */

.grid {
  border: 3px solid var(--border-strong);
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  margin: 0 auto;
  background: var(--border-strong);
}

#puzzle {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 2px;
  user-select: none;
}

.gridtd {
  width: var(--grid-cell-size);
  height: var(--grid-cell-size);
  border: 0;
  border-right: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  padding: 0;
  background: var(--surface-plain);
}

.grid tr:nth-child(3n) .gridtd {
  border-bottom-width: 3px;
  border-bottom-color: var(--border-strong);
}

.grid tr:last-child .gridtd {
  border-bottom: 0;
}

.gridtd:nth-child(3n) {
  border-right-width: 3px;
  border-right-color: var(--border-strong);
}

.gridtd:last-child {
  border-right: 0;
}

body.game-paused[data-theme="dark"] #grid {
  border-color: var(--bg-color);
  background: var(--bg-color);
}

body.game-paused[data-theme="dark"] #grid .gridtd,
body.game-paused[data-theme="dark"] #grid .celltable {
  border-color: var(--bg-color) !important;
  background: var(--bg-color) !important;
}

.numtd {
  width: calc(var(--grid-cell-size) - 4px);
  height: calc(var(--grid-cell-size) - 4px);
  padding: 0;
  font-size: var(--grid-number-size);
  text-align: center;
  vertical-align: middle;
}

.num {
  color: var(--accent-color);
}

.celltable {
  border: 2px solid var(--surface-plain);
  table-layout: fixed;
  border-collapse: collapse;
  font-size: var(--grid-candidate-size);
  margin: auto;
  width: 100%;
  height: 100%;
}

.celltd,
.celltdhigh {
  width: 33%;
  height: 33%;
  border: 0;
  padding: 0;
  text-align: center;
  line-height: 1;
  cursor: pointer;
}

.celltdhigh:hover {
  background: var(--surface-hover);
}

.highlight-tools {
  margin-top: 6px;
  text-align: center;
  font-size: 0.78rem;
}

.absolute-tooltip {
  position: absolute;
}

.tooltip {
  position: absolute;
  z-index: 1500;
  display: none;
  max-width: 280px;
  padding: 10px 14px;
  border: 1px solid var(--accent-border-soft);
  border-radius: 10px;
  background: var(--tooltip-bg);
  color: var(--tooltip-text);
  font-size: 0.85rem;
  line-height: 1.45;
  box-shadow: 0 18px 38px var(--tooltip-shadow);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  pointer-events: none;
}

.tooltipshadow {
  position: absolute;
  z-index: 1400;
  display: none;
  width: 100%;
  height: 100%;
  border-radius: 12px;
  box-shadow: 0 10px 28px var(--tooltip-shadow);
  opacity: 0.75;
}

.closebutton {
  position: absolute;
  top: 10px;
  right: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: 1px solid var(--accent-border);
  background: linear-gradient(135deg, var(--surface-soft), var(--accent-soft));
  color: var(--accent-strong);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.24s ease, background 0.18s ease, border-color 0.18s ease;
}

.closebutton::before {
  content: "\00D7";
  font-size: 18px;
  font-weight: 600;
  line-height: 1;
}

.closebutton:hover,
.closebutton:focus {
  background: linear-gradient(135deg, var(--accent-soft), var(--accent-soft-strong));
  border-color: var(--accent-border-strong);
  transform: translateY(-1px);
}

.closebutton:active {
  transform: translateY(0);
}

.closebutton:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.closebutton img {
  display: none;
}

.box {
  display: none;
  overflow: auto;
  position: absolute;
  max-width: min(520px, 90vw);
  max-height: min(90vh, 640px);
  padding: 24px;
  border: 1px solid var(--border-strong);
  background: var(--surface-plain);
  box-shadow: 0 2px 12px var(--shadow-soft);
  border-radius: 12px;
  z-index: 1200;
}

/* Dialog buttons ------------------------------------------------------- */

button,
input[type="submit"],
input[type="button"] {
  display: inline-block;
  min-height: 0;
  padding: 1px 7px;
  margin: 8px 6px 0;
  border: 1px solid var(--border-color);
  border-radius: 0;
  background: var(--surface-plain);
  color: var(--text-color);
  font-weight: 400;
  font-size: 13px;
  letter-spacing: 0;
  text-decoration: none;
  cursor: pointer;
  transition: none;
  box-shadow: none;
}

.box button:hover,
.box input[type="submit"]:hover,
.box input[type="button"]:hover,
.box button:focus,
.box input[type="submit"]:focus,
.box input[type="button"]:focus {
  background: var(--surface-hover);
  border-color: var(--border-strong);
  transform: none;
  box-shadow: none;
  outline: none;
}

.box button:active,
.box input[type="submit"]:active,
.box input[type="button"]:active {
  transform: none;
  box-shadow: none;
}

.box button:focus-visible,
.box input[type="submit"]:focus-visible,
.box input[type="button"]:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.box button[id$="cancel"],
.box input[type="submit"][id$="cancel"],
.box input[type="button"][id$="cancel"] {
  background: var(--surface-plain);
  color: var(--text-color);
  border-color: var(--border-color);
  box-shadow: none;
  transition: none;
}

.box button[id$="cancel"]:hover,
.box input[type="submit"][id$="cancel"]:hover,
.box input[type="button"][id$="cancel"]:hover,
.box button[id$="cancel"]:focus,
.box input[type="submit"][id$="cancel"]:focus,
.box input[type="button"][id$="cancel"]:focus {
  background: var(--surface-hover);
  border-color: var(--border-strong);
  color: var(--text-color);
  box-shadow: none;
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
}

button.dialog-btn,
input[type="submit"].dialog-btn,
input[type="button"].dialog-btn {
  -webkit-appearance: none;
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  background: var(--surface-soft);
  color: var(--text-color);
  font-family: var(--font-stack);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  letter-spacing: 0.01em;
  box-shadow: none;
  cursor: pointer;
  background-image: none;
}

.box button.dialog-btn:hover,
.box button.dialog-btn:focus,
.box input[type="submit"].dialog-btn:hover,
.box input[type="submit"].dialog-btn:focus,
.box input[type="button"].dialog-btn:hover,
.box input[type="button"].dialog-btn:focus {
  background: var(--surface-hover);
  border-color: var(--border-color);
}

button.dialog-btn-primary,
input[type="submit"].dialog-btn-primary,
input[type="button"].dialog-btn-primary {
  background: var(--accent-color);
  border-color: var(--accent-color);
  color: var(--accent-on);
}

.box button.dialog-btn-primary:hover,
.box button.dialog-btn-primary:focus,
.box input[type="submit"].dialog-btn-primary:hover,
.box input[type="submit"].dialog-btn-primary:focus,
.box input[type="button"].dialog-btn-primary:hover,
.box input[type="button"].dialog-btn-primary:focus {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: var(--accent-on);
}

button.dialog-btn-secondary,
input[type="submit"].dialog-btn-secondary,
input[type="button"].dialog-btn-secondary {
  background: var(--surface-soft);
  border-color: var(--border-soft);
  color: var(--text-color);
}

.box button.dialog-btn-secondary:hover,
.box button.dialog-btn-secondary:focus,
.box input[type="submit"].dialog-btn-secondary:hover,
.box input[type="submit"].dialog-btn-secondary:focus,
.box input[type="button"].dialog-btn-secondary:hover,
.box input[type="button"].dialog-btn-secondary:focus {
  background: var(--surface-hover);
  border-color: var(--border-color);
  color: var(--text-color);
}

.dialog-field-label {
  display: block;
  margin: 2px 0 4px;
  font-weight: 700;
}

.dialog-text-input {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--surface-soft);
  color: var(--text-color);
  font-family: var(--font-stack);
  font-size: 14px;
}

.dialog-text-input:focus {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
  border-color: var(--border-strong);
}

.dialog-textarea {
  min-height: 120px;
  resize: vertical;
}

.dialog-copy-field {
  width: 100%;
  box-sizing: border-box;
  margin-top: 8px;
  text-align: left;
}

.bookmark-success-dialog {
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: center;
}

.bookmark-success-id {
  font-size: 32pt;
  font-weight: 700;
  line-height: 1;
}

.bookmark-success-note {
  margin: 0;
  color: var(--text-muted);
}

.bookmark-success-warning {
  color: var(--danger-text);
}

.feedback-dialog {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 420px;
}

.feedback-dialog-title {
  text-align: center;
  font-size: 1.2rem;
  font-weight: 700;
}

.feedback-dialog-copy {
  margin: 0;
  line-height: 1.5;
}

.feedback-dialog-actions {
  margin-top: 0;
}

.hidden {
  display: none !important;
}

.mobile-only {
  display: none;
}

#logo {
  width: 300px;
  height: auto;
}

body[data-theme="dark"] #logo,
body[data-theme="dark"] #topbar-logo,
body[data-theme="dark"] #welcome-logo {
  opacity: 0.78;
}

#timer {
  width: min(100%, 320px);
  margin-bottom: 6px;
  border-collapse: collapse;
}

#board-topbar #timer {
  margin: 0;
}

#timer td {
  padding: 2px 4px;
}

#timer img {
  vertical-align: middle;
}

#topbar-logo {
  display: none;
  width: 42px;
  height: auto;
  margin-left: 6px;
  vertical-align: middle;
}

#messages {
  margin-top: 12px;
}

#messagebox {
  font-size: smaller;
  height: 85px;
  vertical-align: top;
}

#hint-message {
  display: none;
  box-sizing: border-box;
  width: min(100%, var(--grid-rendered-width));
  margin: 8px auto 0;
  padding: 6px 8px;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  line-height: 1.35;
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
}

#hint-message-text {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 100%;
  overflow-wrap: break-word;
  text-align: left;
}

#hint-message-close {
  margin: 0;
  min-width: 26px;
  min-height: 26px;
  padding: 0;
  font-size: 20px;
  line-height: 1;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--surface-plain);
  color: var(--text-color);
}

#mobile-menu-toggle,
#mobile-menu-close,
#mobile-menu-modal {
  display: none;
}

/* Mobile controls ------------------------------------------------------- */

#mobile-controls {
  display: none;
  width: min(100%, 468px);
  margin: 0 auto;
  background: var(--surface-plain);
}

#mobile-keypad-help {
  display: none;
  width: min(100%, 468px);
  margin: 8px auto 4px;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.35;
}

#mobile-keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  margin-top: 8px;
}

#mobile-keypad.hidden {
  display: none;
}

#mobile-color-grid {
  display: none;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  margin-top: 8px;
}

#mobile-color-grid.active {
  display: grid;
}

#mobile-tools {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin-top: 8px;
}

#mobile-controls button,
.mobile-num-btn,
.mobile-tool-btn,
.mobile-color-btn {
  margin: 0;
  min-height: 36px;
  padding: 8px 6px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--surface-plain);
  color: var(--text-color);
  font-family: var(--font-stack);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.01em;
  box-shadow: none;
}

#mobile-controls button:hover,
#mobile-controls button:focus {
  border-color: var(--border-strong);
  background: var(--surface-hover);
  transform: none;
}

#mobile-controls button:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 1px;
}

#mobile-controls button:disabled {
  opacity: 0.52;
}

#mobile-controls button.mobile-num-btn.cand-on,
#mobile-controls button.mobile-num-btn.cand-on:hover,
#mobile-controls button.mobile-num-btn.cand-on:focus {
  background: var(--accent-soft);
  border-color: var(--accent-soft-strong);
  color: var(--accent-strong);
}

#mobile-controls button.mobile-num-btn.set-on,
#mobile-controls button.mobile-num-btn.set-on:hover,
#mobile-controls button.mobile-num-btn.set-on:focus {
  background: var(--warning-highlight-bg);
  border-color: var(--warning-border);
  color: var(--warning-text);
  box-shadow: inset 0 0 0 2px var(--warning-text);
}

#mobile-controls button.mobile-num-btn.hl-on,
#mobile-controls button.mobile-num-btn.hl-on:hover,
#mobile-controls button.mobile-num-btn.hl-on:focus {
  background: var(--warning-highlight-bg);
  border-color: var(--warning-border);
  color: var(--warning-text);
  box-shadow: inset 0 0 0 2px var(--warning-text);
}

@keyframes mobile-num-invalid-flash {
  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.38;
  }
}

.mobile-num-btn.invalid-flash {
  background: var(--danger-bg) !important;
  border-color: var(--danger-border) !important;
  color: var(--danger-text) !important;
  animation: mobile-num-invalid-flash 120ms linear 0s 3;
}

.mobile-tool-btn {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

#mobile-controls button.mobile-tool-btn.tool-on,
#mobile-controls button.mobile-tool-btn.tool-on:hover,
#mobile-controls button.mobile-tool-btn.tool-on:focus {
  background: var(--surface-plain);
  border-color: var(--border-strong);
  color: var(--text-color);
  box-shadow: inset 0 0 0 1px var(--border-strong);
}

.mobile-color-btn.active {
  outline: 3px solid var(--border-strong);
  outline-offset: -3px;
  border-color: var(--border-strong);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.82), 0 0 0 2px var(--border-strong);
}

/* Modal ----------------------------------------------------------------- */

#modal-alert-message {
  font-size: 0.95rem;
}

#feedback-box {
  text-align: left;
}

/* Responsive adjustments ------------------------------------------------- */

@media (min-width: 721px) and (max-width: 1089px) {
  :root {
    --side-column-width: calc((100vw - var(--grid-rendered-width) - 36px) / 2);
  }

  #left-column,
  #right-column {
    width: var(--side-column-width);
    flex: 0 0 var(--side-column-width);
    font-size: clamp(0.62rem, 1.45vw, 0.9rem);
  }

  #tab-box,
  .optiontable {
    width: 100%;
  }

  #logo {
    width: 100%;
  }

  #panel {
    padding: 3px 4px;
  }

  #panel-help {
    top: 8px;
    right: 6px;
  }

  #panel-help img {
    width: 16px;
    height: 16px;
  }

  #inner-tab-box td {
    padding: 4px 0;
  }

  .panel,
  .optionbody {
    font-size: 0.95em;
  }

  .optionheader {
    padding: 4px;
    font-size: 0.95em;
  }

  #highlight-indicator,
  #desktop-color-palette {
    width: 100% !important;
  }

  .highlight {
    font-size: 1em;
  }

  .board-size-slider {
    width: 100%;
  }

  .off-display {
    position: static;
    display: inline-flex;
    gap: 4px;
    margin-left: 4px;
  }

  #left-column .action,
  #right-column .action {
    overflow-wrap: anywhere;
  }
}

@media (max-width: 720px) {
  :root {
    --grid-rendered-cell-size: 40px;
  }

  #page-container {
    flex-direction: column;
    flex-wrap: wrap;
  }

  #left-column,
  #right-column,
  #board-column {
    margin: 0 auto 6px;
    width: 100%;
    flex: 1 1 auto;
  }

  #board-column {
    order: 1;
    min-width: 0;
  }

  #right-column {
    order: 2;
  }

  #left-column {
    order: 3;
  }

  #timer,
  #highlight,
  #desktop-colors,
  #hints,
  #messages {
    width: 100%;
  }

  #tab-box,
  .optiontable {
    width: 100%;
  }

  .off-display {
    position: static;
    display: inline-flex;
    gap: 8px;
    margin-left: 8px;
    font-size: 0.8rem;
  }
}

@media (max-width: 720px) {
  body,
  html {
    font-size: 15px;
  }

  .celltable {
    font-size: 10px;
  }

  #tab-box,
  .optiontable,
  #timer {
    width: 100%;
  }

  .gridtd {
    width: 40px;
    height: 40px;
  }

  .numtd {
    width: 40px;
    height: 40px;
    font-size: 20pt;
    font-weight: 600;
  }

  .highlight {
    width: 100%;
  }

  #mobile-controls {
    display: block;
  }

  #mobile-keypad-help {
    display: block;
    font-weight: bold;
  }

  .desktop-only {
    display: none;
  }

  .mobile-only {
    display: inline;
  }

  #highlight {
    display: none;
  }

  #desktop-colors {
    display: none;
  }

  #hints {
    display: none;
  }

  #message_title {
    display: none;
  }

  #highlight + p,
  #desktop-colors + p,
  #hints + p {
    display: none;
  }

  #messages {
    margin-top: 0;
  }

  #messagebox {
    height: auto;
    min-height: 85px;
  }

  #keys-tab {
    display: none !important;
  }

  #keys-panel {
    display: none !important;
  }

  #mobile-menu-toggle {
    display: inline-block;
    width: 42px;
    min-width: 42px;
    height: 42px;
    margin: 0;
    min-height: 42px;
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--surface-plain);
    color: var(--text-color);
    font-size: 24px;
    font-weight: 700;
    line-height: 1;
    box-shadow: none;
  }

  #board-topbar {
    justify-content: space-between;
    width: min(100%, 468px);
  }

  #board-topbar #timer {
    width: auto;
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
  }

  #topbar-logo {
    display: inline-block;
    margin-left: 0;
  }

  #topbar-logo,
  #mobile-menu-toggle {
    flex: 0 0 42px;
  }

  #left-column {
    display: none;
  }

  body.mobile-menu-open {
    overflow: hidden;
  }

  #mobile-menu-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1400;
    background: var(--overlay-color);
  }

  body.mobile-menu-open #mobile-menu-modal {
    display: flex;
    align-items: stretch;
    justify-content: stretch;
  }

  #mobile-menu-dialog {
    width: 100%;
    height: 100%;
    background: var(--surface-soft);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0;
    box-sizing: border-box;
  }

  .mobile-menu-header {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 14px 12px;
    border-bottom: 1px solid var(--border-soft);
    background: var(--surface-plain);
  }

  .mobile-menu-title {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--text-color);
  }

  #mobile-menu-close {
    display: inline-block;
    width: 40px;
    min-width: 40px;
    height: 40px;
    min-height: 40px;
    margin: 0;
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--surface-plain);
    color: var(--text-color);
    font-size: 28px;
    line-height: 1;
    box-shadow: none;
  }

  .mobile-menu-body {
    padding: 14px;
    display: grid;
    gap: 12px;
  }

  .mobile-menu-section {
    background: var(--surface-plain);
    border: 1px solid var(--border-soft);
    border-radius: 12px;
    padding: 10px;
  }

  .mobile-menu-section-title {
    margin: 0 0 8px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-soft);
  }

  .mobile-menu-action {
    display: block;
    width: 100%;
    margin: 0 0 8px;
    padding: 10px 12px;
    text-align: left;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-color);
    background: var(--surface-soft);
    border: 1px solid var(--border-soft);
    border-radius: 10px;
  }

  .mobile-menu-action:last-child {
    margin-bottom: 0;
  }

  .mobile-menu-action:active,
  .mobile-menu-action:hover,
  .mobile-menu-action:focus {
    background: var(--surface-hover);
    border-color: var(--border-color);
  }

  .mobile-menu-segment-wrap {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
    padding: 10px 12px;
    background: var(--surface-soft);
    border: 1px solid var(--border-soft);
    border-radius: 10px;
  }

  .mobile-menu-segment-label {
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-soft);
    align-self: flex-start;
  }

  .mobile-menu-segment {
    display: flex;
    width: 100%;
    gap: 0;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    overflow: hidden;
    background: var(--surface-plain);
  }

  .mobile-menu-segment-btn {
    flex: 1 1 0;
    margin: 0;
    padding: 9px 10px;
    text-align: center;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-color);
    background: transparent;
    border: 0;
    border-right: 1px solid var(--border-soft);
  }

  .mobile-menu-segment-btn:last-child {
    border-right: 0;
  }

  .mobile-menu-segment-btn.on {
    color: var(--accent-on);
    background: var(--accent-color);
  }

  .mobile-menu-switch-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 0 0 8px;
    padding: 10px 12px;
    background: var(--surface-soft);
    border: 1px solid var(--border-soft);
    border-radius: 10px;
    color: var(--text-color);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
  }

  .mobile-menu-switch-row:last-child {
    margin-bottom: 0;
  }

  .mobile-menu-switch {
    position: relative;
    width: 46px;
    height: 28px;
    display: inline-block;
  }

  .mobile-menu-switch-input {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    border: 0;
    padding: 0;
    opacity: 0;
    clip: rect(0 0 0 0);
    clip-path: inset(100%);
    overflow: hidden;
  }

  .mobile-menu-switch-slider {
    position: absolute;
    inset: 0;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    background: var(--surface-plain);
    transition: background-color 120ms ease, border-color 120ms ease;
    cursor: pointer;
  }

  .mobile-menu-switch-slider::before {
    content: "";
    position: absolute;
    width: 20px;
    height: 20px;
    top: 3px;
    left: 3px;
    border-radius: 999px;
    background: var(--border-color);
    transition: transform 120ms ease, background-color 120ms ease;
  }

  .mobile-menu-switch-input:checked + .mobile-menu-switch-slider {
    background: var(--accent-color);
    border-color: var(--accent-color);
  }

  .mobile-menu-switch-input:checked + .mobile-menu-switch-slider::before {
    transform: translateX(18px);
    background: var(--accent-on);
  }

  .mobile-menu-switch-input:focus-visible + .mobile-menu-switch-slider {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
  }

  #mobile-tools .mobile-tool-btn {
    font-size: 9px;
  }

  body.enter-puzzle-mobile #enter-puzzle-box {
    position: relative !important;
    left: auto !important;
    top: auto !important;
    right: auto !important;
    bottom: auto !important;
    transform: none !important;
    width: min(100%, 468px) !important;
    max-width: 100% !important;
    margin: 8px auto 0;
    box-sizing: border-box;
    z-index: auto;
  }

  body.enter-puzzle-mobile #enter-puzzle-box .dialog-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
  }
}

@media (max-width: 425px) {
  :root {
    --grid-rendered-cell-size: 32px;
  }

  .celltable {
    font-size: 9px;
  }

  .gridtd {
    width: 32px;
    height: 32px;
  }

  .numtd {
    width: 32px;
    height: 32px;
    font-size: 18pt;
  }

  #logo {
    width: 150px;
  }
}
.need-hint-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.need-hint-text {
  flex: 1 1 auto;
}

.need-hint-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 0;
  border: 1px solid var(--border-color);
  background: var(--surface-plain);
  color: var(--text-color);
  font-size: 18px;
  font-weight: 400;
  cursor: pointer;
  margin: 0;
  box-shadow: none;
  transition: none;
}

.need-hint-close:hover,
.need-hint-close:focus {
  background: var(--surface-hover);
  border-color: var(--border-strong);
  transform: none;
  box-shadow: none;
}

.need-hint-close:active {
  transform: translateY(0);
  box-shadow: none;
}

.need-hint-close:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 1px;
}
