:root {
  color-scheme: light;
  --page: #eaf0f4;
  --page-top: #f8fafc;
  --panel: #ffffff;
  --panel-soft: #f6f9fb;
  --panel-raised: #ffffff;
  --ink: #12263a;
  --muted: #687786;
  --line: #c7d3dd;
  --line-strong: #17344f;
  --border: rgba(18, 38, 58, 0.10);
  --header: #12263a;
  --header-soft: rgba(255, 255, 255, 0.08);
  --header-line: rgba(255, 255, 255, 0.22);
  --accent: #cf7b3b;
  --accent-dark: #a95a23;
  --accent-soft: #fff0e4;
  --selected: #d8eaf5;
  --related: #eef6fa;
  --same-number: #c5e0ef;
  --board-cell: #ffffff;
  --button: #ffffff;
  --button-soft: #f5f9fb;
  --button-hover: #e9f3f8;
  --error: #b42318;
  --error-soft: #fde8e7;
  --success: #166534;
  --success-soft: #eaf7ed;
  --fixed: #102a43;
  --user-number: #176b94;
  --overlay: rgba(18, 38, 58, 0.95);
  --shadow: 0 14px 35px rgba(25, 45, 62, 0.12);
  --shadow-soft: 0 9px 24px rgba(25, 45, 62, 0.08);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #07192b;
  --page-top: #0b2239;
  --panel: #0d2742;
  --panel-soft: #102e4c;
  --panel-raised: #123250;
  --ink: #e8f2f9;
  --muted: #9fb4c7;
  --line: #55728b;
  --line-strong: #d0e0ec;
  --border: rgba(186, 210, 229, 0.16);
  --header: #081a2f;
  --header-soft: rgba(255, 255, 255, 0.08);
  --header-line: rgba(210, 228, 241, 0.25);
  --accent: #e69452;
  --accent-dark: #f1ab70;
  --accent-soft: #253a50;
  --selected: #285777;
  --related: #153957;
  --same-number: #22506e;
  --board-cell: #0f2d49;
  --button: #123250;
  --button-soft: #102e4c;
  --button-hover: #193f60;
  --error: #ff9d94;
  --error-soft: #542d35;
  --success: #98ddb0;
  --success-soft: #163f36;
  --fixed: #f3f7fa;
  --user-number: #83c9ee;
  --overlay: rgba(5, 20, 35, 0.96);
  --shadow: 0 18px 45px rgba(0, 8, 20, 0.34);
  --shadow-soft: 0 12px 30px rgba(0, 8, 20, 0.26);
}

* { box-sizing: border-box; }

html {
  min-width: 280px;
  min-height: 100%;
  background: var(--page);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-width: 280px;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 0%, color-mix(in srgb, var(--accent) 11%, transparent), transparent 25rem),
    linear-gradient(180deg, var(--page-top) 0%, var(--page) 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

button, select { font: inherit; }
button { color: inherit; }
button, a, select { touch-action: manipulation; }
button:disabled { cursor: default; }

.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
}

.topbar {
  position: relative;
  z-index: 20;
  min-height: 72px;
  display: grid;
  grid-template-columns: minmax(105px, 1fr) auto minmax(105px, 1fr);
  align-items: center;
  gap: 16px;
  padding: 10px max(clamp(14px, 3vw, 36px), env(safe-area-inset-right)) 10px max(clamp(14px, 3vw, 36px), env(safe-area-inset-left));
  color: #fff;
  background: var(--header);
  box-shadow: 0 3px 16px rgba(4, 18, 31, 0.28);
}

.home-button, .icon-button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--header-line);
  border-radius: 11px;
  color: #fff;
  background: var(--header-soft);
  text-decoration: none;
  cursor: pointer;
}

.home-button {
  width: max-content;
  justify-self: start;
  gap: 8px;
  padding: 0 14px;
  font-weight: 750;
}

.header-actions {
  justify-self: end;
  display: flex;
  gap: 8px;
}

.icon-button {
  width: 44px;
  padding: 0;
  font-size: 22px;
}

.home-button:hover, .icon-button:hover { background: rgba(255, 255, 255, 0.16); }
.home-button:focus-visible, .icon-button:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 45px;
  height: 45px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-size: 27px;
  font-weight: 900;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.13);
}
.brand h1 { margin: 0; font-size: 23px; line-height: 1; letter-spacing: 0.02em; }
.brand p { margin: 5px 0 0; color: #c9d5df; font-size: 12px; }

.game-layout {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: clamp(14px, 3vw, 34px) max(clamp(10px, 3vw, 34px), env(safe-area-inset-right)) max(clamp(18px, 3vw, 34px), env(safe-area-inset-bottom)) max(clamp(10px, 3vw, 34px), env(safe-area-inset-left));
  display: grid;
  grid-template-columns: minmax(0, 760px) minmax(260px, 320px);
  justify-content: center;
  align-items: start;
  gap: clamp(18px, 3vw, 32px);
}

.game-panel {
  min-width: 0;
  padding: clamp(12px, 2.4vw, 25px);
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.statusbar {
  display: grid;
  grid-template-columns: minmax(130px, 1.35fr) repeat(3, minmax(66px, 0.65fr));
  gap: 9px;
  margin-bottom: 15px;
}

.difficulty-control, .status-item {
  min-width: 0;
  min-height: 58px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel-soft);
}

.difficulty-control {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
}

.difficulty-control > span, .status-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.difficulty-control select {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-weight: 800;
  cursor: pointer;
}

.status-item {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 7px 4px;
}
.status-item strong { margin-top: 3px; font-size: 18px; font-variant-numeric: tabular-nums; }

.board-wrap {
  position: relative;
  width: min(100%, 610px);
  margin: 0 auto;
}

.sudoku-board {
  width: 100%;
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  grid-template-rows: repeat(9, minmax(0, 1fr));
  overflow: hidden;
  border: 3px solid var(--line-strong);
  border-radius: 8px;
  background: var(--board-cell);
  box-shadow: 0 7px 18px rgba(7, 24, 39, 0.14);
  touch-action: manipulation;
}

.cell {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: var(--board-cell);
  font-size: clamp(20px, 5.7vw, 38px);
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.cell:nth-child(9n) { border-right: 0; }
.cell:nth-child(n+73) { border-bottom: 0; }
.cell.box-right { border-right: 3px solid var(--line-strong); }
.cell.box-bottom { border-bottom: 3px solid var(--line-strong); }
.cell.fixed { color: var(--fixed); font-weight: 850; }
.cell.user-value { color: var(--user-number); }
.cell.related { background: var(--related); }
.cell.same-number { background: var(--same-number); }
.cell.selected { background: var(--selected); box-shadow: inset 0 0 0 3px var(--accent); z-index: 1; }
.cell.error { color: var(--error); background: var(--error-soft); animation: shake 0.25s linear; }
.cell.hinted, .cell.auto-filled { color: var(--accent-dark); background: var(--accent-soft); font-weight: 850; }
.cell:focus-visible { outline: 3px solid var(--accent); outline-offset: -4px; z-index: 3; }

.notes-grid {
  position: absolute;
  inset: 3px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  color: var(--user-number);
  font-size: clamp(7px, 1.6vw, 12px);
  font-weight: 700;
  line-height: 1;
}
.notes-grid span { display: grid; place-items: center; }
.notes-grid span.empty { visibility: hidden; }

.pause-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--overlay);
  color: #fff;
  text-align: center;
}
.pause-overlay[hidden] { display: none; }
.pause-overlay strong { display: block; margin-bottom: 18px; font-size: clamp(20px, 4vw, 30px); }
.pause-overlay button { min-height: 44px; padding: 10px 23px; border: 0; border-radius: 9px; background: var(--accent); color: #fff; font-weight: 800; cursor: pointer; }

.message-bar {
  min-height: 42px;
  display: grid;
  place-items: center;
  margin: 13px auto 10px;
  padding: 7px 12px;
  border-radius: 10px;
  color: var(--muted);
  background: var(--panel-soft);
  font-size: 14px;
  line-height: 1.25;
  text-align: center;
}
.message-bar.warning { color: var(--error); background: var(--error-soft); }
.message-bar.success { color: var(--success); background: var(--success-soft); }

.number-pad {
  width: min(100%, 610px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 7px;
}

.number-button {
  min-width: 0;
  min-height: clamp(43px, 8vw, 58px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--user-number);
  background: var(--button-soft);
  font-size: clamp(19px, 4vw, 28px);
  font-weight: 850;
  cursor: pointer;
}
.number-button:hover { border-color: var(--user-number); background: var(--button-hover); }
.number-button:disabled { opacity: 0.28; }
.number-button:focus-visible, .action-button:focus-visible, .primary-button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.main-actions {
  width: min(100%, 610px);
  margin: 12px auto 0;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.action-button {
  min-width: 0;
  min-height: 74px;
  padding: 7px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--button);
  font-weight: 800;
  cursor: pointer;
}
.action-button > span:first-child { color: var(--accent-dark); font-size: 20px; }
.action-button > span:nth-child(2) { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.action-button small { max-width: 100%; color: var(--muted); font-size: 9px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.action-button:hover:not(:disabled) { background: var(--button-soft); }
.action-button.active, .auto-finish-button.ready { border-color: var(--accent); background: var(--accent-soft); }
.action-button:disabled { opacity: 0.45; }
.auto-finish-button.ready { opacity: 1; }

.side-panel { min-width: 0; display: grid; gap: 16px; }
.card {
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--panel-raised);
  box-shadow: var(--shadow-soft);
}
.card h2 { margin: 0 0 8px; font-size: 18px; }
.card p { margin: 0 0 15px; color: var(--muted); font-size: 14px; line-height: 1.5; }
.card p:last-child { margin-bottom: 0; }

.primary-button, .danger-button, .dialog-actions button {
  min-height: 44px;
  border-radius: 10px;
  font-weight: 800;
  cursor: pointer;
}
.primary-button { width: 100%; border: 0; color: #fff; background: var(--accent); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.13); }
.primary-button:hover { background: var(--accent-dark); }

.difficulty-list { display: grid; gap: 7px; }
.difficulty-list button {
  min-width: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 10px 11px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--panel-soft);
  cursor: pointer;
}
.difficulty-list button span { font-weight: 800; }
.difficulty-list button small { color: var(--muted); text-align: right; }
.difficulty-list button.active { border-color: var(--accent); background: var(--accent-soft); }
.keyboard-help { padding-top: 13px; border-top: 1px solid var(--border); font-size: 12px !important; }

.game-dialog {
  width: min(92vw, 420px);
  max-height: min(90dvh, 680px);
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 18px;
  color: var(--ink);
  background: var(--panel-raised);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.38);
}
.game-dialog::backdrop { background: rgba(3, 14, 25, 0.70); backdrop-filter: blur(3px); }
.game-dialog form { padding: 6px; text-align: center; }
.game-dialog h2 { margin: 7px 0 8px; }
.game-dialog p { color: var(--muted); line-height: 1.5; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 20px; }
.dialog-actions button { border: 1px solid var(--border); background: var(--button); }
.dialog-actions .danger-button { border-color: var(--error); color: #fff; background: #b42318; }
.dialog-actions.stacked { grid-template-columns: 1fr; }
.result-symbol { width: 66px; height: 66px; display: grid; place-items: center; margin: 5px auto 10px; border-radius: 50%; color: #fff; background: #2f8b57; font-size: 34px; font-weight: 900; }
.result-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 18px 0; }
.result-stats div { padding: 13px; border-radius: 11px; background: var(--panel-soft); }
.result-stats span { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; font-weight: 800; }
.result-stats strong { display: block; margin-top: 4px; font-size: 21px; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  35% { transform: translateX(-3px); }
  70% { transform: translateX(3px); }
}

@media (max-width: 940px) {
  .game-layout { grid-template-columns: minmax(0, 720px); }
  .side-panel { grid-template-columns: 1fr 1fr; }
  .help-card { grid-column: 1 / -1; }
}

@media (max-width: 650px) {
  .topbar {
    position: sticky;
    top: 0;
    min-height: 58px;
    grid-template-columns: 46px minmax(0, 1fr) auto;
    gap: 7px;
    padding: 7px max(8px, env(safe-area-inset-right)) 7px max(8px, env(safe-area-inset-left));
  }
  .home-button { width: 44px; min-height: 42px; padding: 0; }
  .home-label, .brand p { display: none; }
  .brand { justify-self: center; min-width: 0; gap: 8px; }
  .brand-mark { width: 36px; height: 36px; font-size: 21px; border-radius: 9px; }
  .brand h1 { font-size: 19px; white-space: nowrap; }
  .header-actions { gap: 5px; }
  .icon-button { width: 42px; min-height: 42px; font-size: 20px; }

  .game-layout { padding-top: 8px; padding-left: max(6px, env(safe-area-inset-left)); padding-right: max(6px, env(safe-area-inset-right)); gap: 10px; }
  .game-panel { padding: 8px; border-radius: 14px; }
  .statusbar { grid-template-columns: minmax(104px, 1.25fr) repeat(2, minmax(56px, 0.7fr)); gap: 5px; margin-bottom: 7px; }
  .record-item { display: none; }
  .difficulty-control, .status-item { min-height: 45px; border-radius: 8px; }
  .difficulty-control { padding: 5px 7px; gap: 5px; }
  .difficulty-control > span, .status-label { font-size: 9px; }
  .difficulty-control select { font-size: 13px; }
  .status-item strong { margin-top: 1px; font-size: 14px; }

  .sudoku-board { border-width: 2px; border-radius: 5px; }
  .cell { font-size: clamp(19px, 7.2vw, 31px); }
  .cell.box-right { border-right-width: 2px; }
  .cell.box-bottom { border-bottom-width: 2px; }
  .cell.selected { box-shadow: inset 0 0 0 2px var(--accent); }
  .notes-grid { inset: 2px; font-size: clamp(6px, 2.35vw, 10px); }

  .message-bar { min-height: 32px; margin: 6px 0 5px; padding: 4px 7px; border-radius: 7px; font-size: 11px; }
  .number-pad { gap: 3px; }
  .number-button { min-height: 40px; border-radius: 7px; font-size: clamp(18px, 6vw, 24px); }
  .main-actions { gap: 4px; margin-top: 6px; }
  .action-button { min-height: 57px; padding: 4px 1px; border-radius: 8px; font-size: 10px; }
  .action-button > span:first-child { font-size: 17px; }
  .action-button small { display: none; }

  .side-panel { grid-template-columns: 1fr; gap: 9px; }
  .help-card { grid-column: auto; }
  .compact-card, .help-card { display: none; }
  .card { padding: 12px; border-radius: 13px; }
  .card h2 { font-size: 16px; }
  .card p { margin-bottom: 10px; font-size: 12px; }
  .primary-button { min-height: 42px; }
}

@media (max-width: 390px) {
  .brand-mark { display: none; }
  .brand h1 { font-size: 18px; }
  .topbar { grid-template-columns: 44px minmax(0, 1fr) auto; }
  .icon-button { width: 39px; min-height: 40px; }
  .header-actions { gap: 4px; }
  .game-layout { padding-left: 4px; padding-right: 4px; }
  .game-panel { padding: 6px; }
  .number-button { min-height: 38px; }
  .action-button { min-height: 54px; font-size: 9px; }
}

@media (max-width: 320px) {
  .topbar { grid-template-columns: 40px minmax(0, 1fr) auto; padding-left: 4px; padding-right: 4px; }
  .home-button { width: 40px; }
  .icon-button { width: 36px; }
  .brand h1 { font-size: 16px; }
  .difficulty-control > span { display: none; }
  .statusbar { grid-template-columns: minmax(90px, 1.15fr) repeat(2, minmax(50px, 0.7fr)); }
  .action-button > span:nth-child(2) { font-size: 8px; }
}

@media (max-height: 780px) and (min-width: 941px) {
  .game-layout { padding-top: 14px; padding-bottom: 14px; }
  .game-panel { padding-top: 14px; padding-bottom: 14px; }
  .board-wrap { width: min(100%, 515px); }
  .message-bar { margin-top: 8px; margin-bottom: 7px; }
  .main-actions { margin-top: 7px; }
  .action-button { min-height: 60px; }
}

@media (orientation: landscape) and (max-height: 560px) and (max-width: 940px) {
  .topbar {
    position: static;
    min-height: 48px;
    padding-top: 3px;
    padding-bottom: 3px;
  }
  .home-button, .icon-button { min-height: 38px; }
  .brand-mark { width: 34px; height: 34px; font-size: 20px; }
  .brand p { display: none; }

  .game-layout {
    width: 100%;
    padding: 4px max(4px, env(safe-area-inset-right)) max(4px, env(safe-area-inset-bottom)) max(4px, env(safe-area-inset-left));
    display: block;
  }
  .game-panel {
    width: 100%;
    padding: 6px;
    display: grid;
    grid-template-columns: minmax(0, min(74dvh, 46vw, 420px)) minmax(250px, 1fr);
    grid-template-areas:
      "board status"
      "board message"
      "board numbers"
      "board actions";
    grid-template-rows: auto auto auto 1fr;
    align-items: start;
    column-gap: 8px;
    row-gap: 5px;
    border-radius: 12px;
  }
  .statusbar {
    grid-area: status;
    grid-template-columns: minmax(105px, 1.25fr) repeat(3, minmax(52px, 0.75fr));
    gap: 4px;
    margin: 0;
  }
  .difficulty-control, .status-item { min-height: 40px; border-radius: 7px; }
  .difficulty-control { padding: 4px 6px; }
  .difficulty-control > span, .status-label { font-size: 8px; }
  .difficulty-control select { font-size: 12px; }
  .status-item strong { margin-top: 0; font-size: 13px; }
  .record-item { display: flex; }

  .board-wrap { grid-area: board; width: 100%; margin: 0; align-self: start; }
  .sudoku-board { border-width: 2px; }
  .cell { font-size: clamp(18px, 4.4vw, 29px); }
  .cell.box-right { border-right-width: 2px; }
  .cell.box-bottom { border-bottom-width: 2px; }
  .notes-grid { inset: 2px; font-size: clamp(6px, 1.35vw, 9px); }

  .message-bar {
    grid-area: message;
    min-height: 28px;
    margin: 0;
    padding: 3px 7px;
    border-radius: 7px;
    font-size: 10px;
  }
  .number-pad {
    grid-area: numbers;
    width: 100%;
    margin: 0;
    gap: 3px;
  }
  .number-button {
    min-height: 36px;
    border-radius: 7px;
    font-size: 19px;
  }
  .main-actions {
    grid-area: actions;
    width: 100%;
    margin: 0;
    gap: 4px;
  }
  .action-button {
    min-height: 53px;
    padding: 3px 1px;
    border-radius: 7px;
    font-size: 9px;
  }
  .action-button > span:first-child { font-size: 16px; }
  .action-button small { display: none; }
  .side-panel { display: none; }
}

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

/* Mobilos indítóképernyő: a valódi fullscreen csak felhasználói érintésből kérhető. */
body.mobile-launch-open { overflow: hidden; }

.mobile-launch-overlay {
  position: fixed;
  z-index: 10000;
  inset: 0;
  min-height: 100vh;
  min-height: 100dvh;
  padding:
    max(18px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    max(18px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
  display: grid;
  place-items: center;
  overflow: auto;
  color: #f4f8fb;
  background:
    radial-gradient(circle at 50% 10%, rgba(230, 148, 82, 0.22), transparent 22rem),
    linear-gradient(160deg, #102f50 0%, #07192b 70%);
}
.mobile-launch-overlay[hidden] { display: none; }
.mobile-launch-card {
  width: min(100%, 420px);
  padding: clamp(24px, 7vw, 38px);
  border: 1px solid rgba(220, 234, 244, 0.20);
  border-radius: 24px;
  text-align: center;
  background: rgba(12, 40, 66, 0.92);
  box-shadow: 0 28px 80px rgba(0, 7, 18, 0.48);
  backdrop-filter: blur(12px);
}
.mobile-launch-mark {
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  margin: 0 auto 16px;
  border-radius: 20px;
  color: #fff;
  background: #cf7b3b;
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.14), 0 12px 30px rgba(0, 0, 0, 0.22);
  font-size: 42px;
  font-weight: 900;
}
.mobile-launch-card h2 {
  margin: 0;
  font-size: clamp(30px, 9vw, 42px);
  letter-spacing: 0.02em;
}
.mobile-launch-card p {
  margin: 11px auto 22px;
  color: #bfd0de;
  line-height: 1.5;
}
.mobile-launch-primary,
.mobile-launch-secondary {
  width: 100%;
  min-height: 54px;
  border-radius: 13px;
  cursor: pointer;
  font-weight: 800;
}
.mobile-launch-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1px solid #efaa72;
  color: #fff;
  background: #cf7b3b;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.22);
  font-size: 15px;
}
.mobile-launch-primary span:first-child { font-size: 22px; }
.mobile-launch-primary:active { transform: translateY(1px); }
.mobile-launch-secondary {
  margin-top: 10px;
  border: 1px solid rgba(220, 234, 244, 0.24);
  color: #eaf2f8;
  background: rgba(255, 255, 255, 0.07);
}
.mobile-launch-card small {
  display: block;
  margin-top: 16px;
  color: #91a9bc;
  font-size: 11px;
  line-height: 1.4;
}

@media (max-height: 500px) and (orientation: landscape) {
  .mobile-launch-overlay { place-items: start center; }
  .mobile-launch-card { padding: 16px 22px; }
  .mobile-launch-mark { width: 48px; height: 48px; margin-bottom: 7px; border-radius: 13px; font-size: 28px; }
  .mobile-launch-card h2 { font-size: 25px; }
  .mobile-launch-card p { margin: 5px auto 10px; font-size: 12px; }
  .mobile-launch-primary, .mobile-launch-secondary { min-height: 43px; }
  .mobile-launch-card small { margin-top: 8px; }
}

/* V4 – oldalsáv nélküli, teljesen reszponzív kezelőfelület */
.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.game-layout {
  width: min(820px, 100%);
  grid-template-columns: minmax(0, 760px);
  justify-content: center;
}

.game-toolbar,
.statusbar,
.number-pad,
.main-actions {
  width: min(100%, 610px);
  margin-left: auto;
  margin-right: auto;
}

.game-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 9px;
  margin-bottom: 9px;
}

.toolbar-button {
  min-width: 0;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 13px;
  border: 1px solid var(--border);
  border-radius: 11px;
  color: var(--ink);
  background: var(--button);
  font-weight: 800;
  cursor: pointer;
}
.toolbar-button:hover:not(:disabled) { background: var(--button-hover); }
.toolbar-button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.toolbar-button:disabled { opacity: 0.45; }
.new-puzzle-button {
  border-color: transparent;
  color: #fff;
  background: var(--accent);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.13);
}
.new-puzzle-button:hover:not(:disabled) { background: var(--accent-dark); }
.new-puzzle-button > span:first-child { font-size: 20px; }
.difficulty-menu-button { justify-content: flex-start; }
.difficulty-menu-button .toolbar-caption {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.difficulty-menu-button strong { margin-left: auto; }
.difficulty-menu-button > span:last-child { color: var(--muted); }

.statusbar {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 10px;
}

.dialog-heading-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  text-align: left;
}
.dialog-heading-row h2 { margin-top: 2px; }
.dialog-heading-row p { margin: 0 0 12px; }
.dialog-close-button {
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--ink);
  background: var(--button);
  font-size: 25px;
  line-height: 1;
  cursor: pointer;
}
.difficulty-dialog form { padding: 8px; }
.difficulty-dialog .difficulty-list button { min-height: 52px; }

.rules-page { min-height: 100dvh; }
.rules-topbar { grid-template-columns: minmax(90px, 1fr) auto minmax(90px, 1fr); }
.rules-content {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: clamp(18px, 4vw, 38px) max(12px, env(safe-area-inset-right)) max(28px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  display: grid;
  gap: 14px;
}
.rules-card {
  padding: clamp(18px, 4vw, 26px);
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: var(--shadow-soft);
}
.rules-card h2 { margin: 0 0 8px; font-size: 20px; }
.rules-card p { margin: 0; color: var(--muted); line-height: 1.65; }
.rules-back-button {
  min-height: 48px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  color: #fff;
  background: var(--accent);
  font-weight: 800;
  text-decoration: none;
}

@media (max-width: 650px) {
  .topbar {
    min-height: 50px;
    grid-template-columns: 40px minmax(0, 1fr) auto;
    padding-top: 4px;
    padding-bottom: 4px;
  }
  .home-button { width: 38px; min-height: 38px; }
  .icon-button { width: 38px; min-height: 38px; font-size: 19px; }
  .brand-mark { width: 32px; height: 32px; border-radius: 8px; font-size: 19px; }
  .brand h1 { font-size: 17px; }

  .game-layout {
    padding-top: 5px;
    padding-bottom: max(6px, env(safe-area-inset-bottom));
    gap: 0;
  }
  .game-panel { padding: 5px; border-radius: 11px; }
  .game-toolbar { gap: 4px; margin-bottom: 4px; }
  .toolbar-button { min-height: 38px; padding: 4px 7px; border-radius: 8px; font-size: 12px; }
  .new-puzzle-button > span:first-child { font-size: 16px; }
  .difficulty-menu-button .toolbar-caption { display: none; }
  .difficulty-menu-button strong { margin-left: 0; }

  .statusbar { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; margin-bottom: 4px; }
  .status-item { min-height: 36px; padding: 3px 2px; border-radius: 7px; }
  .status-label { font-size: 8px; }
  .status-item strong { margin-top: 0; font-size: 13px; }
  .record-item { display: flex; }

  .board-wrap {
    width: min(100%, max(270px, calc(100dvh - 275px)));
  }
  .message-bar { min-height: 26px; margin: 4px 0; padding: 2px 6px; font-size: 10px; }
  .number-pad { gap: 3px; }
  .number-button { min-height: 34px; border-radius: 6px; font-size: clamp(17px, 5.5vw, 22px); }
  .main-actions { gap: 3px; margin-top: 4px; }
  .action-button { min-height: 46px; padding: 2px 1px; border-radius: 7px; font-size: 9px; }
  .action-button > span:first-child { font-size: 15px; }
  .action-button small { display: none; }

  .difficulty-dialog { width: min(94vw, 390px); }
  .difficulty-dialog .difficulty-list button { min-height: 49px; }
  .rules-topbar { grid-template-columns: minmax(82px, 1fr) auto minmax(82px, 1fr); }
  .rules-topbar .brand-mark { display: none; }
  .rules-content { padding-top: 12px; }
}

@media (max-width: 390px) {
  .topbar { grid-template-columns: 38px minmax(0, 1fr) auto; }
  .header-actions { gap: 3px; }
  .icon-button { width: 35px; min-height: 36px; }
  .brand-mark { display: none; }
  .game-layout { padding-left: 3px; padding-right: 3px; }
  .game-panel { padding: 4px; }
  .toolbar-button { font-size: 11px; }
  .board-wrap { width: min(100%, max(264px, calc(100dvh - 269px))); }
}

@media (max-width: 330px) {
  .brand h1 { font-size: 15px; }
  .home-button { width: 35px; }
  .icon-button { width: 33px; }
  .toolbar-button { padding-left: 4px; padding-right: 4px; font-size: 10px; }
  .board-wrap { width: min(100%, max(250px, calc(100dvh - 264px))); }
  .action-button > span:nth-child(2) { font-size: 8px; }
}

@media (orientation: landscape) and (max-height: 560px) and (max-width: 940px) {
  .topbar { min-height: 44px; }
  .game-panel {
    grid-template-columns: minmax(0, min(80dvh, 48vw, 430px)) minmax(250px, 1fr);
    grid-template-areas:
      "board toolbar"
      "board status"
      "board message"
      "board numbers"
      "board actions";
    grid-template-rows: auto auto auto auto 1fr;
  }
  .game-toolbar { grid-area: toolbar; width: 100%; margin: 0; gap: 4px; }
  .toolbar-button { min-height: 36px; padding-top: 3px; padding-bottom: 3px; }
  .statusbar { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .board-wrap { width: 100%; }
  .number-button { min-height: 34px; }
  .action-button { min-height: 47px; }
}

:fullscreen .topbar,
:-webkit-full-screen .topbar {
  padding-top: max(3px, env(safe-area-inset-top));
}
