:root {
  --np-cream: #fffaf0;
  --np-brown: #4a3728;
  --np-green: #257836;
  --np-green-soft: #e7f2df;
  --np-terracotta: #c86e4a;
  --np-border: #efe7d9;
  --np-muted: #6f6258;
  --np-line: #d9cdb8;
  --np-line-strong: #8c7a63;
  --np-shadow:
    0 1px 2px rgba(74, 55, 40, 0.05),
    0 4px 14px rgba(74, 55, 40, 0.07),
    0 14px 30px rgba(74, 55, 40, 0.05);
  --np-heading-font: "Zen Maru Gothic", "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic", "Noto Sans JP", sans-serif;
}

* {
  box-sizing: border-box;
}

.app-shell {
  width: min(100% - 24px, 960px);
  margin: 0 auto;
  padding: clamp(18px, 4vw, 40px) 0 48px;
  display: flex;
  flex-direction: column;
  gap: clamp(14px, 2.6vw, 22px);
}

.app-header,
.control-bar,
.stage,
.note {
  border: 1px solid var(--np-border);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--np-shadow);
}

.app-header {
  padding: clamp(18px, 4vw, 32px);
}

.app-header h1 {
  margin: 4px 0 8px;
  font-family: var(--np-heading-font);
  font-size: clamp(1.7rem, 5vw, 2.4rem);
  line-height: 1.3;
  color: var(--np-brown);
}

.app-header .eyebrow {
  margin: 0;
  color: var(--np-green);
  font-weight: 700;
  font-size: 0.92rem;
  letter-spacing: 0.06em;
}

.app-header .lead {
  margin: 0;
  color: var(--np-muted);
}

.control-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: clamp(12px, 2.4vw, 18px);
}

.level-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  width: 100%;
}

.action-button,
.level-button {
  flex: 1 1 auto;
  min-width: 8.5rem;
  min-height: 52px;
  padding: 10px 16px;
  border: 2px solid var(--np-green);
  border-radius: 999px;
  background: #fff;
  color: var(--np-green);
  font-family: var(--np-heading-font);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.4;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.12s ease, background-color 0.12s ease;
}

.action-button:hover,
.level-button:hover {
  background: var(--np-green-soft);
}

.action-button:active,
.level-button:active {
  transform: translateY(1px);
}

.action-button.primary {
  background: var(--np-green);
  color: #fff;
}

.action-button.primary:hover {
  background: #2f9e44;
}

.action-button.quiet {
  border-color: var(--np-border);
  color: var(--np-muted);
}

.action-button.quiet[aria-pressed="true"] {
  border-color: var(--np-terracotta);
  background: #fdf0e8;
  color: var(--np-terracotta);
}

.level-button {
  border-color: var(--np-border);
  color: var(--np-muted);
}

.level-button[aria-pressed="true"] {
  border-color: var(--np-green);
  background: var(--np-green);
  color: #fff;
}

.stage {
  position: relative;
  padding: clamp(14px, 3vw, 26px);
  overflow: hidden;
}

.stage-title {
  margin: 0 0 12px;
  font-family: var(--np-heading-font);
  font-size: clamp(1.05rem, 3.2vw, 1.35rem);
  font-weight: 700;
  color: var(--np-brown);
  text-align: center;
}

.board-wrap {
  display: flex;
  justify-content: center;
}

.board {
  --np-size: 9;
  display: grid;
  grid-template-columns: repeat(var(--np-size), 1fr);
  width: min(100%, 460px);
  aspect-ratio: 1 / 1;
  border: 3px solid var(--np-line-strong);
  border-radius: 14px;
  overflow: hidden;
  background: var(--np-line);
  gap: 1px;
  user-select: none;
  -webkit-user-select: none;
}

.board.is-busy {
  opacity: 0.5;
}

.cell {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: #fffdf8;
  color: var(--np-green);
  font-family: var(--np-heading-font);
  font-size: clamp(0.95rem, 4.4vw, 1.6rem);
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.board[data-size="4"] .cell,
.board[data-size="6"] .cell {
  font-size: clamp(1.2rem, 7vw, 2.2rem);
}

/* 太い区切り線（わくの境目） */
.cell.is-box-right {
  box-shadow: inset -2px 0 0 var(--np-line-strong);
}

.cell.is-box-bottom {
  box-shadow: inset 0 -2px 0 var(--np-line-strong);
}

.cell.is-box-right.is-box-bottom {
  box-shadow: inset -2px 0 0 var(--np-line-strong), inset 0 -2px 0 var(--np-line-strong);
}

.cell.is-given {
  background: #f5efe3;
  color: var(--np-brown);
  cursor: default;
}

.cell.is-peer {
  background: #f3f8ee;
}

.cell.is-given.is-peer {
  background: #eee9dc;
}

.cell.is-same {
  background: var(--np-green-soft);
}

.cell.is-selected {
  background: #fdf0e8;
  outline: 3px solid var(--np-terracotta);
  outline-offset: -3px;
  z-index: 2;
}

.cell.is-error {
  background: #fdeaea;
  color: #c0392b;
}

.cell:focus-visible {
  outline: 3px solid var(--np-terracotta);
  outline-offset: -3px;
  z-index: 3;
}

.cell__memo {
  display: grid;
  gap: 0;
  width: 100%;
  height: 100%;
  padding: 2px;
  color: var(--np-muted);
  font-size: 0.5em;
  font-weight: 600;
}

.cell__memo span {
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.pad {
  margin-top: clamp(14px, 3vw, 20px);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pad__numbers {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.pad__tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.pad-number,
.pad-tool {
  min-width: 3.2rem;
  min-height: 52px;
  padding: 8px 14px;
  border: 2px solid var(--np-green);
  border-radius: 16px;
  background: #fff;
  color: var(--np-green);
  font-family: var(--np-heading-font);
  font-size: 1.3rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.12s ease, background-color 0.12s ease;
}

.pad-tool {
  min-width: 6.5rem;
  border-color: var(--np-border);
  color: var(--np-muted);
  font-size: 1rem;
}

.pad-number:hover,
.pad-tool:hover {
  background: var(--np-green-soft);
}

.pad-number:active,
.pad-tool:active {
  transform: translateY(1px);
}

.pad-number.is-done {
  border-color: var(--np-border);
  background: #f7f4ee;
  color: #b3a795;
}

.pad-tool[aria-pressed="true"] {
  border-color: var(--np-terracotta);
  background: #fdf0e8;
  color: var(--np-terracotta);
}

.celebration {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(255, 250, 240, 0.9);
}

.celebration[hidden] {
  display: none;
}

.celebration__card {
  width: min(100%, 420px);
  padding: clamp(18px, 4vw, 30px);
  border: 1px solid var(--np-border);
  border-radius: 24px;
  background: #fff;
  box-shadow: var(--np-shadow);
  text-align: center;
}

.celebration__stars {
  margin: 0;
  font-size: 1.6rem;
}

.celebration__card h2 {
  margin: 6px 0 8px;
  font-family: var(--np-heading-font);
  font-size: clamp(1.4rem, 4vw, 1.8rem);
  line-height: 1.3;
  color: var(--np-brown);
}

.celebration__card p {
  margin: 0;
  color: var(--np-muted);
}

.celebration__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.feedback {
  margin: 0;
  padding: 14px 18px;
  border: 1px solid var(--np-border);
  border-radius: 18px;
  background: var(--np-green-soft);
  color: var(--np-brown);
  font-family: var(--np-heading-font);
  font-size: 1.02rem;
  line-height: 1.5;
  text-align: center;
}

.note {
  padding: clamp(14px, 3vw, 22px);
  color: var(--np-muted);
  font-size: 0.9rem;
}

.note p {
  margin: 0 0 6px;
}

.note p:last-child {
  margin-bottom: 0;
}

@media (max-width: 480px) {
  .action-button,
  .level-button {
    min-width: 7rem;
    font-size: 0.94rem;
  }

  .pad-number {
    min-width: 2.7rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .action-button,
  .level-button,
  .pad-number,
  .pad-tool {
    transition: none;
  }
}
