:root {
  --maxw: 1024px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-size: 16px;
  line-height: 1.6;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
.ghost {
  min-height: 44px;
  appearance: none;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--card);
  color: var(--fg);
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 16px;
  transition:
    border-color 180ms ease,
    background-color 180ms ease,
    color 180ms ease,
    transform 180ms ease;
}

button:hover,
button:focus-visible {
  border-color: var(--accent);
  transform: translateY(-1px);
}

button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--canvas-deep);
}

button.ghost {
  color: var(--muted);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  transform: none;
}

.skip-link {
  position: fixed;
  z-index: 2000;
  top: 10px;
  left: 10px;
  padding: 10px 14px;
  border-radius: 6px;
  background: var(--accent);
  color: var(--canvas-deep);
  font-weight: 700;
  text-decoration: none;
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: translateY(0);
}

.app-brand-name {
  display: inline-flex;
  align-items: baseline;
}

.app-header-actions {
  flex: 0 0 auto;
}

.app-site-header .language-switcher {
  border-color: var(--border-strong);
  background: rgba(11, 23, 30, 0.8);
}

.app-intro .lead {
  max-width: 900px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: clamp(14px, 2vw, 17px);
  line-break: strict;
  line-height: 1.8;
  text-wrap: pretty;
  word-break: normal;
}

.lead-sentence {
  display: block;
}

.card {
  margin-bottom: 24px;
}

.template-picker {
  display: grid;
  grid-template-columns: minmax(200px, 0.8fr) auto minmax(220px, 1.2fr);
  align-items: end;
  gap: 12px;
  margin-bottom: 22px;
  padding: 16px;
  border: 1px solid rgba(120, 246, 207, 0.22);
  border-radius: 12px;
  background: rgba(120, 246, 207, 0.045);
}

.template-picker .form-group {
  min-width: 0;
}

.template-picker p {
  align-self: center;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.control-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(160px, 0.7fr) minmax(210px, 0.85fr);
  gap: 18px;
  align-items: end;
}

.form-group label,
.form-label {
  display: block;
  margin-bottom: 8px;
  color: var(--fg);
  font-size: 14px;
  font-weight: 650;
}

.form-group input,
.form-group select {
  width: 100%;
  min-height: 46px;
  padding: 10px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: rgba(4, 10, 14, 0.74);
  color: var(--fg);
}

.form-group select {
  padding-right: 40px;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 17px) 20px,
    calc(100% - 12px) 20px;
  background-repeat: no-repeat;
  background-size: 5px 5px, 5px 5px;
}

.free-toggle {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
}

.free-toggle input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
}

.board-toolbar,
.board-actions,
.board-action-buttons {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.board-toolbar {
  justify-content: space-between;
  margin: 22px 0 16px;
}

.board-actions {
  justify-content: space-between;
  margin-top: 20px;
}

.seg {
  display: inline-flex;
  min-width: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--card);
}

.seg label {
  display: flex;
  min-height: 44px;
  align-items: center;
  padding: 8px 16px;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
}

.seg input:checked + label {
  background: var(--accent);
  color: var(--canvas-deep);
  font-weight: 700;
}

.seg input:focus-visible + label {
  outline: 2px solid var(--accent);
  outline-offset: -3px;
}

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

.board-frame {
  width: min(100%, 680px);
  margin-inline: auto;
  outline: 0;
}

.board-frame[data-size="3"]:not(.is-preview) {
  width: min(100%, 560px);
}

.board-frame[data-size="5"]:not(.is-preview) {
  width: min(100%, 680px);
}

.preview-title {
  display: none;
}

.board-frame.is-preview {
  width: min(100%, 680px);
  padding: clamp(22px, 5vw, 52px) clamp(18px, 4vw, 42px) clamp(18px, 4vw, 42px);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
}

.board-frame.is-preview .preview-title {
  display: block;
  margin: 0 0 clamp(16px, 3vw, 30px);
  overflow-wrap: anywhere;
  color: #111;
  font-size: clamp(22px, 4.5vw, 38px);
  font-weight: var(--preview-font-weight, 600);
  line-height: 1.25;
  text-align: center;
}

.board-frame.is-preview .grid {
  gap: 0;
  border-top: 2px solid #222;
  border-left: 2px solid #222;
}

.board-frame.is-preview .cell,
.board-frame.is-preview .cell.filled,
.board-frame.is-preview .cell.free-cell {
  border: 0;
  border-right: 2px solid #222;
  border-bottom: 2px solid #222;
  border-radius: 0;
  background: #fff;
}

.board-frame.is-preview .cell.free-cell {
  background: #f1f3f4;
}

.preview-cell-label {
  z-index: 1;
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  padding: 10%;
  overflow: hidden;
  color: #111;
  font-size: clamp(13px, 2.4vw, 22px);
  font-weight: var(--preview-font-weight, 600);
  line-height: 1.25;
  overflow-wrap: anywhere;
  text-align: center;
}

.board-frame.is-preview .grid[data-size="5"] .preview-cell-label {
  font-size: clamp(8px, 1.55vw, 14px);
}

.cell {
  position: relative;
  display: grid;
  min-width: 0;
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: rgba(4, 10, 14, 0.78);
  transition:
    border-color 180ms ease,
    background-color 180ms ease,
    box-shadow 180ms ease;
}

.cell.filled {
  border-color: rgba(120, 246, 207, 0.42);
  background: rgba(120, 246, 207, 0.055);
}

.cell.focused,
.cell[role="button"]:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(120, 246, 207, 0.18);
  outline: 0;
}

.cell[role="button"] {
  cursor: pointer;
}

.cell.free-cell {
  border-color: rgba(90, 169, 255, 0.5);
  background: rgba(90, 169, 255, 0.1);
}

.cell textarea {
  z-index: 1;
  width: 100%;
  height: 100%;
  min-height: 0;
  resize: none;
  overflow: hidden;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--fg);
  font-family: inherit;
  font-size: 16px;
  font-weight: 650;
  line-height: 1.35;
  padding: 10px;
  text-align: center;
  line-break: strict;
  overflow-wrap: anywhere;
  word-break: normal;
}

.cell-input-mirror {
  position: absolute;
  top: 0;
  right: 10px;
  left: 10px;
  display: block;
  visibility: hidden;
  color: transparent;
  font-family: inherit;
  font-size: 16px;
  font-weight: 650;
  line-break: strict;
  line-height: 1.35;
  overflow-wrap: anywhere;
  pointer-events: none;
  text-align: center;
  white-space: pre-wrap;
  word-break: normal;
}

.grid[data-size="5"] .cell {
  border-radius: 8px;
}

.grid[data-size="5"] .cell textarea {
  padding: 7px;
  font-size: 11px;
  line-height: 1.25;
}

.grid[data-size="5"] .cell-input-mirror {
  right: 7px;
  left: 7px;
  font-size: 11px;
  line-height: 1.25;
}

.cell textarea:disabled {
  pointer-events: none;
  opacity: 1;
  -webkit-text-fill-color: var(--fg);
}

.mark {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}

.cell.marked .mark {
  opacity: 1;
}

.mark::before {
  width: 68%;
  aspect-ratio: 1;
  border: clamp(3px, 0.55vw, 6px) solid #ff5252;
  border-radius: 50%;
  box-shadow: 0 4px 12px rgba(255, 82, 82, 0.4);
  content: "";
  transform: rotate(-12deg);
}

.board-status {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.board-status.has-bingo {
  color: var(--accent);
  font-weight: 700;
}

.print-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 20px;
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.print-tools h3,
.print-tools p {
  margin: 0;
}

.print-tools h3 {
  margin-bottom: 3px;
  font-size: 16px;
}

.print-tools p {
  max-width: 660px;
  color: var(--muted);
  font-size: 12px;
}

.print-controls {
  display: grid;
  grid-template-columns: auto auto;
  align-items: end;
  gap: 7px 10px;
}

.print-controls label {
  grid-column: 1 / -1;
  color: var(--fg);
  font-size: 12px;
  font-weight: 650;
}

.print-controls select {
  min-height: 44px;
  padding: 9px 36px 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  appearance: none;
  background-color: rgba(4, 10, 14, 0.74);
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 16px) 19px,
    calc(100% - 11px) 19px;
  background-repeat: no-repeat;
  background-size: 5px 5px, 5px 5px;
  color: var(--fg);
}

.toast {
  position: fixed;
  z-index: 1200;
  bottom: 24px;
  left: 50%;
  max-width: min(90vw, 460px);
  padding: 12px 18px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface-raised);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.34);
  color: var(--fg);
  opacity: 0;
  pointer-events: none;
  text-align: center;
  transform: translate(-50%, 12px);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.modal-overlay {
  position: fixed;
  z-index: 1300;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.68);
  backdrop-filter: blur(4px);
}

.modal-overlay.show {
  display: flex;
}

.modal-dialog {
  width: min(100%, 420px);
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  background: var(--surface-raised);
  box-shadow: 0 18px 56px rgba(0, 0, 0, 0.5);
}

.modal-header,
.modal-body,
.modal-footer {
  padding: 18px 22px;
}

.modal-header,
.modal-footer {
  border-color: var(--border);
}

.modal-header {
  border-bottom: 1px solid var(--border);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  border-top: 1px solid var(--border);
}

.modal-header h2,
.modal-body p {
  margin: 0;
}

.modal-header h2 {
  font-size: 18px;
}

.modal-body p {
  color: var(--muted);
}

.related-service {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 18px;
  margin: 26px 0 0;
  padding: 16px 18px;
  border: 1px solid var(--border);
  background: rgba(90, 169, 255, 0.045);
}

.related-service p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.related-service__category {
  display: inline-block;
  margin-bottom: 7px;
  padding: 3px 7px;
  border: 1px solid rgba(120, 246, 207, 0.28);
  border-radius: 999px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 1.2;
}

.related-service strong {
  display: block;
  margin-bottom: 3px;
  color: var(--fg);
  font-size: 14px;
}

.related-service a {
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.related-service a:hover,
.related-service a:focus-visible {
  text-decoration: underline;
}

.related-apps {
  margin: 18px 0 0;
  padding: clamp(20px, 4vw, 30px);
  border: 1px solid rgba(120, 246, 207, 0.2);
  border-radius: 14px;
  background:
    radial-gradient(circle at 100% 0, rgba(120, 246, 207, 0.1), transparent 42%),
    rgba(4, 10, 14, 0.5);
}

.related-apps__heading {
  max-width: 720px;
  margin-bottom: 18px;
}

.related-apps__heading h2,
.related-apps__heading p {
  margin: 0;
}

.related-apps__heading h2 {
  margin-bottom: 4px;
  font-size: clamp(20px, 3vw, 26px);
}

.related-apps__heading p:not(.related-apps__eyebrow) {
  color: var(--muted);
  font-size: 13px;
}

.related-apps__eyebrow {
  margin-bottom: 4px !important;
  color: var(--accent);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.related-apps__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.related-app-card {
  display: grid;
  height: 100%;
  grid-template-columns: 58px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(11, 23, 30, 0.8);
  color: var(--fg);
  text-decoration: none;
  transition:
    border-color 180ms ease,
    background-color 180ms ease,
    transform 180ms ease;
}

.related-app-card:hover,
.related-app-card:focus-visible {
  border-color: var(--accent);
  background: rgba(120, 246, 207, 0.07);
  outline: 0;
  transform: translateY(-2px);
}

.related-app-card img {
  width: 58px;
  height: 58px;
  border-radius: 12px;
  object-fit: cover;
}

.related-app-card span,
.related-app-card strong,
.related-app-card small,
.related-app-card b {
  display: block;
}

.related-app-card strong {
  margin-bottom: 2px;
  font-size: 14px;
}

.related-app-card small {
  min-height: 3em;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.related-app-card b {
  margin-top: 7px;
  color: var(--accent);
  font-size: 11px;
}

.app-about p,
.app-about ol,
.app-about ul {
  margin: 0 0 20px;
}

.app-about ol,
.app-about ul {
  padding-left: 22px;
}

.app-about li + li {
  margin-top: 6px;
}

.app-about .use-case-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 0;
  list-style: none;
}

.app-about .use-case-list li {
  margin: 0;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(4, 10, 14, 0.48);
}

.print-sheets {
  display: none;
}

canvas {
  display: none;
}

@media (max-width: 820px) {
  .control-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-group:first-child {
    grid-column: 1 / -1;
  }

  .related-apps__grid {
    grid-template-columns: 1fr;
  }

  .related-app-card small {
    min-height: 0;
  }

  .template-picker {
    grid-template-columns: minmax(180px, 1fr) auto;
  }

  .template-picker p {
    grid-column: 1 / -1;
  }

  .print-tools {
    grid-template-columns: 1fr;
  }

  .print-controls {
    justify-content: start;
  }
}

@media (max-width: 560px) {
  .app-site-header__inner {
    gap: 10px;
  }

  .app-header-actions {
    gap: 6px;
  }

  .app-site-header .language-switcher {
    gap: 5px;
    padding: 5px 8px;
    font-size: 10px;
  }

  .control-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

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

  .template-picker p {
    grid-column: auto;
  }

  .form-group:first-child {
    grid-column: auto;
  }

  .board-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .board-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .board-action-buttons {
    align-items: stretch;
  }

  .board-action-buttons button {
    flex: 1 1 auto;
  }

  .board-status {
    text-align: left;
  }

  .grid {
    gap: 6px;
  }

  .cell textarea {
    padding: 7px 5px;
    font-size: 12px;
  }

  .cell-input-mirror {
    right: 5px;
    left: 5px;
    font-size: 12px;
  }

  .grid[data-size="5"] {
    gap: 4px;
  }

  .grid[data-size="5"] .cell textarea {
    padding: 4px 2px;
    font-size: 8px;
  }

  .grid[data-size="5"] .cell-input-mirror {
    right: 2px;
    left: 2px;
    font-size: 8px;
  }

  .board-frame.is-preview {
    padding: 20px 16px 16px;
  }

  .board-frame.is-preview .preview-title {
    margin-bottom: 16px;
  }

  .related-service {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .print-controls {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .print-controls select {
    min-width: 0;
    width: 100%;
  }

  .app-about .use-case-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 370px) {
  .app-brand-name {
    display: none;
  }
}

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

@media print {
  @page {
    size: A4 portrait;
    margin: 12mm;
  }

  html,
  body {
    margin: 0 !important;
    background: #fff !important;
    color: #111 !important;
  }

  body > *:not(.print-sheets) {
    display: none !important;
  }

  body > .print-sheets {
    display: block !important;
  }

  .print-card {
    display: flex;
    min-height: 273mm;
    flex-direction: column;
    justify-content: center;
    break-after: page;
    page-break-after: always;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  .print-card:last-child {
    break-after: auto;
    page-break-after: auto;
  }

  .print-card h1 {
    margin: 0 0 6mm;
    color: #111;
    font-size: 24pt;
    line-height: 1.25;
    overflow-wrap: anywhere;
    text-align: center;
  }

  .print-card__number {
    margin: -4mm 0 4mm;
    color: #555;
    font-size: 9pt;
    text-align: center;
  }

  .print-grid {
    display: grid;
    width: 100%;
    max-width: 180mm;
    grid-template-columns: repeat(var(--print-board-size, 3), minmax(0, 1fr));
    align-self: center;
    border-top: 0.5mm solid #222;
    border-left: 0.5mm solid #222;
  }

  .print-cell {
    display: grid;
    aspect-ratio: 1;
    place-items: center;
    padding: 3mm;
    overflow: hidden;
    border-right: 0.5mm solid #222;
    border-bottom: 0.5mm solid #222;
    color: #111;
    font-size: 15pt;
    font-weight: 600;
    line-height: 1.25;
    overflow-wrap: anywhere;
    text-align: center;
  }

  .print-grid[data-size="5"] .print-cell {
    padding: 2mm;
    font-size: 9pt;
  }

  .print-cell.free-cell {
    background: #eceff1 !important;
  }
}
