html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  overflow-x: hidden;
}

.nback-body {
  background: var(--color-page-bg, #0b1220);
  color: var(--color-page-text, #e5e7eb);
  min-height: 100dvh;
  overflow-x: hidden;
}

.page {
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0,1fr);
}

.nb-wrap {
  display: grid;
  grid-template-rows: auto minmax(0,1fr) auto;
  gap: 10px;
  height: 100%;
  width: 60vw;
  max-width: 600px;
  margin: 0 auto;
  padding: 0 16px 10px 16px;
  box-sizing: border-box;
  overflow-x: hidden;
}
@media (max-width:900px) {
  .nb-wrap { width: 100vw; max-width: 100vw; padding-left: 8px; padding-right: 8px; }
}
@media (max-width:600px) {
  .nb-wrap { padding-left: 4px; padding-right: 4px; }
}

.nb-top {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}

.nb-levels {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  margin: 8px 0 2px 0;
  padding: 0;
  overflow: hidden;
}

.nb-level-btn,
.nb-info {
  width: 28px;
  height: 28px;
  min-width: 28px;
  min-height: 28px;
  max-width: 28px;
  max-height: 28px;
  border-radius: 50%;
  background: var(--color-cell-bg, #1f2937);
  color: var(--color-cell-text, #e5e7eb);
  border: 1.5px solid var(--color-header-border, #333333);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s, box-shadow 0.16s;
  padding: 0; margin: 0; box-sizing: border-box;
}
.nb-level-btn.is-active {
  background: var(--color-cell-hover-bg, #3b82f6);
  color: var(--color-cell-hover-text, #ffffff);
  border-color: var(--color-cell-hover-bg, #3b82f6);
}

/* --- i indicator: always blue border, blue text, never oval, always circular --- */
.nb-info {
  background: var(--color-grid-area-bg, #020617);
  color: #3b82f6;
  border: 2px solid #bae6fd !important;  /* soft blue border */
  font-weight: 900;
  font-size: 16px;
  box-shadow: none;
}
.nb-info:hover, .nb-info:focus {
  border-color: #38bdf8; /* blue-400 */
  color: #2563eb;
  outline: none;
}
.nb-info:active {
  border-color: #0ea5e9; /* blue-500 pressed */
  color: #0ea5e9;
}
@media (max-width:720px) {
  .nb-level-btn, .nb-info {
    width: 22px; height: 22px; min-width:22px; min-height:22px; max-width:22px; max-height:22px;
    font-size: 11px;
  }
  .nb-levels { margin: 4px 0 2px 0; }
}

/* --- Status/Stats --- */
.nb-status {
  background: var(--color-grid-area-bg, #020617);
  border: 1px solid var(--color-header-border, #333333);
  border-radius: 14px;
  padding: 8px 10px 8px 10px;
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nb-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 3px;
}
.nb-title {
  font-family: "Oswald", system-ui, sans-serif;
  font-size: 17px;
  font-weight: 700;
  min-width: 0;
  flex: 1 1 auto;
}

/* --- 2x2 stats --- */
.nb-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto auto;
  gap: 6px 12px;
  width: 100%;
}
.nb-stat {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  background: var(--color-cell-bg, #1f2937);
  color: var(--color-cell-text, #e5e7eb);
  border-radius: 10px;
  font-size: 15px;
  padding: 2px 6px;
  gap: 6px;
}
.nb-stat .k {
  font-size: 13px;
  opacity: 0.78;
  margin-right: 3px;
}
.nb-stat .v {
  font-size: 15px;
  font-weight: 700;
}

.nb-message {
  min-height: 18px;
  font-size: 14px;
}
.nb-message.is-ok { color: #86efac; }
.nb-message.is-bad { color: #fca5a5; }

/* --- Board area: Final SQUARE solution --- */
.nb-board-area {
  position: relative;
  min-height: 0;
  min-width: 0;
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.nb-board {
  position: absolute;
  inset: 0;
  margin: auto;
  aspect-ratio: 1 / 1;
  max-width: 100%;
  max-height: 100%;
  width: 100%;
  height: 100%;
  display: grid;
  background: var(--color-grid-area-bg, #020617);
  border: 1px solid var(--color-header-border, #333333);
  border-radius: 18px;
  box-sizing: border-box;
  gap: 10px;
  padding: 10px;
}

.nb-cell {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  border-radius: 13px;
  background: var(--color-cell-bg, #1f2937);
  color: var(--color-cell-text, #e5e7eb);
  border: 1px solid var(--color-header-border, #333333);
  transition: transform 120ms, background 120ms, border-color 120ms, color 120ms;
  display: flex;
  align-items: center;
  justify-content: center;
}
.nb-cell.is-lit {
  background: var(--color-cell-hover-bg, #3b82f6);
  color: var(--color-cell-hover-text, #ffffff);
  border-color: var(--color-cell-hover-bg, #3b82f6);
  transform: scale(1.03);
}

.nb-controls {
  display: grid;
  gap: 8px;
  min-height: 0;
}

.nb-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.nb-btn,
.nb-answer,
.stats-btn,
.nb-info-btn {
  height: 42px;
  border-radius: 12px;
  background: var(--color-cell-bg, #1f2937);
  color: var(--color-cell-text, #e5e7eb);
  border: 1px solid var(--color-header-border, #333333);
  font-weight: 800;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.nb-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.nb-btn:active,
.nb-answer:active,
.stats-btn:active,
.nb-info-btn:active {
  background: var(--color-cell-hover-bg, #3b82f6);
  color: var(--color-cell-hover-text, #ffffff);
}

.nb-answers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.nb-answer {
  height: 56px;
  border-radius: 14px;
  font-size: 16px;
  letter-spacing: 0.4px;
}

/* --- Modal --- */
.stats-modal,
.nb-info-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-items: center;
  background: rgba(0,0,0,0.70);
  z-index: 9999;
  padding-left: 16px;
  padding-right: 16px;
}
.stats-modal.is-open,
.nb-info-modal.is-open { display: grid; }
.stats-modal-content,
.nb-info-content {
  width: min(560px, 100%);
  background: var(--color-grid-area-bg, #111827);
  color: var(--color-page-text, #e5e7eb);
  border: 1px solid var(--color-header-border, #333333);
  border-radius: 16px;
  padding: 18px 14px;
}
.stats-modal-content h2,
.nb-info-content h2 {
  margin-top: 6px;
  margin-bottom: 10px;
  font-family: "Oswald", system-ui, sans-serif;
}
.stats-list { display: grid; gap: 6px; margin-bottom: 12px; }
.stats-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stats-message {
  margin-top: 10px;
  min-height: 18px;
  font-size: 13px;
  opacity: 0.85;
}
