:root {
  --bg-top: #f0f2e9;
  --bg-bottom: #dde7d8;
  --panel: #fcfbf8;
  --line: rgba(52, 65, 71, 0.14);
  --text: #24323a;
  --muted: #5b6970;
  --accent: #1d6f75;
  --accent-dark: #14555a;
  --board-bg: #f7fafc;
  --board-line: #4f6476;
  --board-soft: #b7c6d1;
  --selected: #d9eff8;
  --peer: #edf5fa;
  --error: #ffd8dc;
  --fixed: #1f2e39;
  --value: #0f6bb8;
  --shadow: 0 14px 34px rgba(33, 48, 58, 0.1);
  --radius: 26px;
  --board-radius: 28px;
  --cell-size: min(7.9vh, 86px);
  --font-main: "Trebuchet MS", "Segoe UI", Tahoma, sans-serif;
  --font-display: Georgia, "Times New Roman", serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  font-family: var(--font-main);
  color: var(--text);
  background: linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
}

body {
  min-height: 100vh;
  overflow: hidden;
}

.reload-hotspot {
  position: fixed;
  top: 0;
  right: 0;
  width: 96px;
  height: 96px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  opacity: 0.01;
  z-index: 20;
}

.page-shell {
  width: min(1920px, 100vw);
  min-height: 100vh;
  margin: 0 auto;
  padding: 10px 10px 32px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(315px, 390px) minmax(0, 1fr);
  gap: 12px;
  min-height: calc(100vh - 32px);
}

.panel-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 16px;
}

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: auto;
}

.side-main {
  display: grid;
  gap: 12px;
  align-content: start;
}

.eyebrow {
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent-dark);
  font-size: 0.85rem;
  font-weight: 700;
}

.brand-block h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 3.8vw, 4.2rem);
  line-height: 0.9;
}

button {
  border: none;
  border-radius: 18px;
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  padding: 15px 16px;
  transition: transform 0.14s ease, box-shadow 0.14s ease, filter 0.14s ease;
}

button:hover,
button:focus-visible {
  transform: translateY(-1px);
  filter: brightness(1.02);
  outline: none;
}

.primary-button {
  background: linear-gradient(180deg, var(--accent), var(--accent-dark));
  color: #fff;
  box-shadow: 0 16px 26px rgba(25, 114, 120, 0.25);
}

.secondary-button {
  background: #ffffff;
  color: var(--text);
  border: 1px solid var(--line);
  box-shadow: 0 8px 18px rgba(33, 48, 58, 0.06);
}

.exit-link {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: auto;
  min-height: 66px;
  border-radius: 18px;
  background: linear-gradient(180deg, #455560, #29353d);
  color: #ffffff;
  text-decoration: none;
  font-size: 1.15rem;
  font-weight: 700;
  box-shadow: 0 12px 22px rgba(33, 48, 58, 0.2);
}

.exit-link:hover,
.exit-link:focus-visible {
  filter: brightness(1.04);
  outline: none;
}

.actions-block {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.action-wide {
  grid-column: 1 / -1;
}

.stats-card h2,
.info-card h2 {
  font-size: 1.1rem;
  margin: 0 0 8px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.stat-box {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #ffffff;
  padding: 10px 12px;
  min-width: 0;
}

.stat-label {
  display: block;
  color: var(--muted);
  margin-bottom: 4px;
}

.stat-box strong {
  font-size: 1.45rem;
  line-height: 1;
}

.info-card p,
.status-message {
  margin: 0;
  color: var(--muted);
  line-height: 1.4;
}

.info-card p + p {
  margin-top: 8px;
}

.board-panel {
  display: grid;
  align-items: start;
  justify-items: center;
  overflow: hidden;
}

.board-wrap {
  display: grid;
  grid-template-columns: auto minmax(188px, 225px);
  align-items: center;
  gap: 18px;
  justify-items: center;
  width: 100%;
  padding-top: 25px;
  padding-right: 25px;
}

.board {
  display: grid;
  grid-template-columns: repeat(9, var(--cell-size));
  grid-template-rows: repeat(9, var(--cell-size));
  background: var(--board-bg);
  border-radius: var(--board-radius);
  overflow: hidden;
  border: 4px solid var(--board-line);
  box-shadow: 0 18px 28px rgba(23, 39, 55, 0.14);
}

.cell {
  position: relative;
  width: var(--cell-size);
  height: var(--cell-size);
  border: 1px solid var(--board-soft);
  background: #ffffff;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 0;
  color: var(--value);
  font-size: clamp(2rem, 4.1vh, 2.9rem);
  font-weight: 700;
}

.cell.fixed {
  color: var(--fixed);
  background: #f7fafc;
}

.cell.selected {
  background: var(--selected);
}

.cell.peer {
  background: var(--peer);
}

.cell.error {
  background: var(--error);
}

.cell.same-value {
  color: #0b5087;
}

.cell.border-right {
  border-right: 4px solid var(--board-line);
}

.cell.border-bottom {
  border-bottom: 4px solid var(--board-line);
}

.cell-notes {
  position: absolute;
  inset: 5px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 1px;
  font-size: clamp(0.55rem, 1.1vh, 0.82rem);
  color: #5c7a91;
  pointer-events: none;
}

.note {
  display: grid;
  place-items: center;
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  width: min(100%, 225px);
}

.keypad-button {
  width: 100%;
  aspect-ratio: 1 / 1;
  min-height: 0;
  background: linear-gradient(180deg, #ffffff, #eff5f8);
  border: 1px solid rgba(79, 100, 118, 0.18);
  color: var(--text);
  box-shadow: 0 10px 18px rgba(33, 48, 58, 0.08);
  font-size: 1.8rem;
  font-weight: 800;
  display: grid;
  place-items: center;
}

.keypad-button:disabled {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  cursor: default;
}

.keypad-button svg {
  width: 40px;
  height: 40px;
}

.keypad-button.active {
  background: linear-gradient(180deg, #d9eff8, #bfe1ee);
}

@media (max-width: 1400px) {
  :root {
    --cell-size: min(7.1vh, 76px);
  }
}

@media (max-width: 1080px) {
  .layout {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .board-wrap {
    grid-template-columns: 1fr;
  }

  .keypad {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    width: min(100%, calc(var(--cell-size) * 5));
  }

  .actions-block,
  .stat-grid {
    grid-template-columns: 1fr;
  }
}
