.ssg-game,
.ssg-game * {
  box-sizing: border-box;
}

.ssg-game {
  --ssg-bg: #f7f1e7;
  --ssg-card: #fffaf2;
  --ssg-ink: #2f2a24;
  --ssg-muted: #6b6259;
  --ssg-border: #b8a78f;
  --ssg-heavy-border: #4d4338;
  --ssg-accent: #9b6b30;
  --ssg-success: #247a3d;
  --ssg-wrong: #b3261e;
  --ssg-note: #2f5f8f;
  --ssg-conflict-bg: #ffe1dc;
  --ssg-empty: #fffdf8;
  --ssg-fixed: #efe1cb;
  max-width: 760px;
  margin: 1.5rem auto;
  color: var(--ssg-ink);
  font-family: inherit;
}

.ssg-card {
  background: var(--ssg-card);
  border: 1px solid rgba(77, 67, 56, 0.18);
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 16px 40px rgba(47, 42, 36, 0.12);
}

.ssg-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.ssg-title {
  margin: 0 0 8px;
  font-size: clamp(1.35rem, 2.4vw, 2rem);
  line-height: 1.15;
}

.ssg-instructions {
  margin: 0;
  max-width: 58ch;
  color: var(--ssg-muted);
  line-height: 1.5;
}

.ssg-new,
.ssg-reset,
.ssg-submit,
.ssg-cancel {
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  padding: 10px 16px;
  transition: transform 0.15s ease, opacity 0.15s ease, box-shadow 0.15s ease;
}

.ssg-new:hover,
.ssg-reset:hover,
.ssg-submit:hover,
.ssg-cancel:hover,
.ssg-cell:hover {
  transform: translateY(-1px);
}

.ssg-new:focus-visible,
.ssg-reset:focus-visible,
.ssg-submit:focus-visible,
.ssg-cancel:focus-visible,
.ssg-cell:focus-visible,
.ssg-modal-x:focus-visible,
.ssg-modal input:focus-visible {
  outline: 3px solid rgba(155, 107, 48, 0.35);
  outline-offset: 2px;
}

.ssg-header-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
}

.ssg-new {
  background: var(--ssg-accent);
  color: white;
  white-space: nowrap;
}

.ssg-reset {
  background: var(--ssg-ink);
  color: white;
  white-space: nowrap;
}

.ssg-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 16px;
}

.ssg-stats span {
  background: var(--ssg-bg);
  border: 1px solid rgba(77, 67, 56, 0.14);
  border-radius: 999px;
  padding: 7px 12px;
  color: var(--ssg-muted);
}

.ssg-stats strong {
  color: var(--ssg-ink);
}

.ssg-grid-wrap {
  overflow-x: auto;
  padding: 4px;
}

.ssg-grid {
  display: grid;
  grid-template-columns: repeat(var(--ssg-size, 9), minmax(54px, 1fr));
  border: 3px solid var(--ssg-heavy-border);
  background: var(--ssg-heavy-border);
  gap: 1px;
  width: min(100%, 630px);
  margin: 0 auto;
}

.ssg-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 54px;
  aspect-ratio: 1 / 1;
  border: 0;
  background: var(--ssg-empty);
  color: var(--ssg-ink);
  cursor: pointer;
  font: inherit;
  font-size: clamp(0.67rem, 1.55vw, 1rem);
  font-weight: 800;
  letter-spacing: 0.01em;
  padding: 4px;
  text-align: center;
  text-transform: lowercase;
}

.ssg-cell.ssg-box-right {
  border-right: 2px solid var(--ssg-heavy-border);
}

.ssg-cell.ssg-box-bottom {
  border-bottom: 2px solid var(--ssg-heavy-border);
}

.ssg-size-6 .ssg-grid {
  width: min(100%, 540px);
}

.ssg-size-6 .ssg-cell {
  font-size: clamp(0.85rem, 2vw, 1.1rem);
}

.ssg-cell.ssg-fixed {
  background: var(--ssg-fixed);
  cursor: default;
}

.ssg-cell.ssg-filled:not(.ssg-fixed) {
  background: #eef3fb;
  color: var(--ssg-note);
}

.ssg-cell.ssg-numbered-line {
  background: #edf7ed;
  color: var(--ssg-success);
  font-size: clamp(1.05rem, 2.4vw, 1.55rem);
  font-weight: 900;
}

.ssg-cell.ssg-fixed.ssg-numbered-line {
  background: var(--ssg-fixed);
  color: #000;
}

.ssg-cell.ssg-fixed,
.ssg-cell.ssg-fixed.ssg-filled,
.ssg-cell.ssg-fixed.ssg-conflict,
.ssg-cell.ssg-fixed.ssg-numbered-line {
  color: #000;
}


.ssg-cell.ssg-completed-line-cell {
  text-transform: none;
}

.ssg-cell.ssg-completed-line-fixed {
  background: var(--ssg-fixed);
  color: #000;
  font-size: clamp(1.05rem, 2.4vw, 1.55rem);
  font-weight: 900;
}

.ssg-cell.ssg-conflict {
  background: var(--ssg-conflict-bg);
  color: var(--ssg-wrong);
  box-shadow: inset 0 0 0 3px rgba(179, 38, 30, 0.25);
}

.ssg-cell.ssg-fixed.ssg-conflict {
  background: #f3cfc7;
  color: #000;
}

.ssg-cell.ssg-empty::after {
  content: '+';
  color: rgba(47, 42, 36, 0.35);
  font-size: 1.25rem;
  font-weight: 700;
}

.ssg-feedback {
  min-height: 1.5em;
  margin: 16px 0 0;
  font-weight: 700;
  line-height: 1.4;
}

.ssg-feedback-success {
  color: var(--ssg-success);
}

.ssg-feedback-wrong {
  color: var(--ssg-wrong);
}

.ssg-feedback-neutral {
  color: var(--ssg-muted);
}

.ssg-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 999999;
  padding: 18px;
}

.ssg-modal[aria-hidden="false"] {
  display: grid;
  place-items: center;
}

.ssg-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(18, 16, 14, 0.62);
}

.ssg-modal-dialog {
  position: relative;
  z-index: 1;
  width: min(100%, 430px);
  background: #fffaf2;
  border-radius: 22px;
  padding: 24px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
}

.ssg-modal-dialog h3 {
  margin: 0 36px 8px 0;
  font-size: 1.35rem;
}

.ssg-modal-help {
  margin: 0 0 16px;
  color: var(--ssg-muted);
}

.ssg-modal input {
  width: 100%;
  border: 2px solid var(--ssg-border);
  border-radius: 14px;
  color: var(--ssg-ink);
  font: inherit;
  font-size: 1.15rem;
  padding: 12px 14px;
}

.ssg-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.ssg-submit {
  background: var(--ssg-accent);
  color: white;
}

.ssg-cancel {
  background: #eee4d6;
  color: var(--ssg-ink);
}

.ssg-modal-x {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: #eee4d6;
  color: var(--ssg-ink);
  cursor: pointer;
  font-size: 1.35rem;
  line-height: 1;
}

.ssg-complete .ssg-grid {
  box-shadow: 0 0 0 6px rgba(36, 122, 61, 0.14);
}

@media (max-width: 640px) {
  .ssg-card {
    padding: 14px;
    border-radius: 16px;
  }

  .ssg-header {
    display: block;
  }

  .ssg-header-actions {
    flex-direction: row;
    align-items: stretch;
    margin-top: 12px;
  }

  .ssg-new,
  .ssg-reset {
    flex: 1;
  }

  .ssg-grid {
    grid-template-columns: repeat(var(--ssg-size, 9), minmax(42px, 1fr));
  }

  .ssg-cell {
    min-width: 42px;
    font-size: 0.58rem;
  }

  .ssg-size-6 .ssg-cell {
    min-width: 48px;
    font-size: 0.78rem;
  }

  .ssg-modal-actions {
    flex-direction: column;
  }

  .ssg-submit,
  .ssg-cancel {
    width: 100%;
  }
}
