:root {
  --bg: #f4efe6;
  --panel: rgba(255, 252, 246, 0.9);
  --panel-strong: #fffaf0;
  --ink: #1e2b26;
  --muted: #57655f;
  --line: #b8aa93;
  --line-strong: #3b544a;
  --accent: #c96d4a;
  --accent-soft: #f4d8ca;
  --given: #e2efe8;
  --selected: #fff0bf;
  --hint: #d7efe4;
  --conflict: #ffd8d1;
  --mistake: #ffebe5;
  --shadow: 0 18px 45px rgba(53, 43, 26, 0.12);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "IBM Plex Sans KR", "Noto Sans KR", "Segoe UI", sans-serif;
  line-height: 1.5;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(232, 202, 177, 0.55), transparent 28%),
    linear-gradient(180deg, #f8f3ea 0%, var(--bg) 100%);
  padding: 24px;
}

body > * {
  width: min(100%, 1440px);
  margin-inline: auto;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  border-radius: 14px;
  cursor: pointer;
}

h1,
h2,
p,
dl,
dd,
dt,
ol {
  margin: 0;
}

ol,
ul {
  padding: 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.site-header,
.board-panel,
.info-card,
.site-footer {
  background: var(--panel);
  border: 1px solid rgba(59, 84, 74, 0.1);
  box-shadow: var(--shadow);
}

.site-header,
.site-footer {
  border-radius: 28px;
}

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

.header-copy {
  max-width: 700px;
}

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

h1 {
  font-size: clamp(2rem, 4vw, 3.3rem);
  line-height: 1.05;
  letter-spacing: -0.04em;
}

.intro {
  margin-top: 12px;
  max-width: 60ch;
  color: var(--muted);
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.top-actions button {
  padding: 12px 16px;
  min-height: 48px;
  background: var(--line-strong);
  color: #fff;
  font-weight: 700;
  transition: transform 0.15s ease, opacity 0.15s ease, background-color 0.15s ease;
}

.top-actions button:hover,
.top-actions button:focus-visible {
  transform: translateY(-1px);
  background: #2e443b;
  outline: 3px solid rgba(201, 109, 74, 0.24);
  outline-offset: 2px;
}

.top-actions button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.top-actions button[aria-pressed="true"] {
  background: var(--accent);
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(300px, 0.8fr);
  gap: 24px;
  align-items: start;
}

.layout > * {
  min-width: 0;
}

.board-panel,
.info-card {
  border-radius: 24px;
}

.board-panel {
  padding: 22px;
}

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

.panel-head h2,
.info-card h2 {
  font-size: 1.1rem;
}

.muted,
.status,
.hint-message,
.stats-grid dt,
.site-footer {
  color: var(--muted);
}

.status-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: #7a341f;
  font-size: 0.9rem;
  font-weight: 700;
}

.sudoku-shell {
  background: var(--panel-strong);
  border-radius: 20px;
  border: 1px solid rgba(59, 84, 74, 0.12);
  padding: 16px;
}

.sudoku-board {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  aspect-ratio: 1;
  width: min(100%, 720px);
  margin: 0 auto;
  border: 3px solid var(--line-strong);
  border-radius: 18px;
  overflow: hidden;
}

.cell {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  background: #fffdf8;
  color: var(--ink);
  text-align: center;
  font-size: clamp(1rem, 2vw, 1.65rem);
  font-weight: 600;
  outline: none;
  padding: 0;
}

.cell[readonly] {
  cursor: default;
}

.cell.edge-right {
  border-right: 3px solid var(--line-strong);
}

.cell.edge-bottom {
  border-bottom: 3px solid var(--line-strong);
}

.cell.is-given {
  background: var(--given);
  font-weight: 800;
}

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

.cell.is-hint {
  background: var(--hint);
  box-shadow: inset 0 0 0 2px rgba(59, 84, 74, 0.35);
}

.cell.is-conflict {
  background: var(--conflict);
  color: #8f2417;
}

.cell.is-mistake {
  box-shadow: inset 0 0 0 2px rgba(201, 109, 74, 0.8);
}

.cell:focus-visible {
  background: var(--selected);
  box-shadow: inset 0 0 0 2px var(--accent);
}

.side-panel {
  display: grid;
  gap: 16px;
}

.info-card {
  padding: 18px;
}

.hint-message {
  margin-top: 10px;
  min-height: 72px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 12px;
}

.stats-grid div {
  padding: 14px;
  border-radius: 16px;
  background: rgba(244, 239, 230, 0.85);
}

.stats-grid dt {
  font-size: 0.84rem;
}

.stats-grid dd {
  margin-top: 6px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
}

.log-list {
  list-style: none;
  margin-top: 12px;
  display: grid;
  gap: 10px;
}

.log-list li {
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(244, 239, 230, 0.85);
  color: var(--ink);
  overflow-wrap: anywhere;
}

.site-footer {
  margin-top: 24px;
  padding: 18px 22px;
  text-align: center;
}

@media (max-width: 980px) {
  .site-header,
  .panel-head {
    flex-direction: column;
  }

  .status-wrap {
    align-items: flex-start;
  }

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

  .sudoku-board {
    width: 100%;
  }
}

@media (max-width: 640px) {
  body {
    padding: 14px;
  }

  .site-header,
  .board-panel,
  .info-card,
  .site-footer {
    border-radius: 20px;
  }

  .site-header,
  .board-panel,
  .info-card {
    padding: 16px;
  }

  .top-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .top-actions button {
    flex: 1 1 calc(50% - 10px);
    min-width: 0;
  }

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

@media (max-width: 480px) {
  .top-actions button {
    flex-basis: 100%;
  }
}