.mastermind-game {
  width: min(100%, 650px);
}

.mastermind-brand {
  display: grid;
  width: 2.7rem;
  height: 2.7rem;
  flex: 0 0 auto;
  grid-template-columns: repeat(2, 1fr);
  align-content: center;
  justify-items: center;
  gap: 0.16rem;
  border-radius: 50%;
  background: #6e4730;
  box-shadow: 0 2px 4px rgb(30 42 58 / 16%);
}

.mastermind-brand span {
  width: 0.73rem;
  height: 0.73rem;
  border: 2px solid #fff4e6;
  border-radius: 50%;
}

.mastermind-brand span:nth-child(1) { background: #dc4054; }
.mastermind-brand span:nth-child(2) { background: #e7c43c; }
.mastermind-brand span:nth-child(3) { background: #35a879; }
.mastermind-brand span:nth-child(4) { background: #3986cb; }

.mastermind-game .status-bar {
  flex-wrap: wrap;
}

.mastermind-game .status-bar[data-state="success"] .status-indicator {
  background: #38856d;
}

.mastermind-game .status-bar[data-state="error"] .status-indicator {
  background: #c6534b;
}

.turn-counter {
  margin-left: auto;
  color: #817c74;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.board-frame {
  margin-top: 0.8rem;
  padding: 0.55rem clamp(0.55rem, 3vw, 1rem) 0.7rem;
  border: 1px solid #a67853;
  border-radius: 0.9rem;
  background: linear-gradient(135deg, #9e6d48, #805536);
  box-shadow: 0 6px 0 #5d402d, 0 11px 18px rgb(43 49 60 / 14%);
}

.board-head {
  display: grid;
  grid-template-columns: 1fr auto;
  padding: 0.1rem 0.25rem 0.42rem;
  color: #f1ddc2;
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.09em;
}

.mastermind-board {
  display: grid;
  gap: 0.25rem;
  padding: 0.35rem;
  border: 2px solid #142630;
  border-radius: 0.6rem;
  background: #263845;
  box-shadow: inset 0 3px 8px rgb(14 27 36 / 30%);
}

.board-row {
  display: grid;
  min-height: clamp(2rem, 7vw, 2.65rem);
  grid-template-columns: 1.5rem minmax(0, 1fr) minmax(3rem, 4.1rem);
  align-items: center;
  gap: clamp(0.3rem, 2vw, 0.8rem);
  padding: 0 0.35rem;
  border-radius: 0.3rem;
  background: #2c4350;
}

.board-row:nth-child(even) {
  background: #293e4b;
}

.row-number {
  color: #b8c8cf;
  font: 700 0.65rem Consolas, "Courier New", monospace;
  text-align: center;
}

.guess-pegs,
.feedback-pegs {
  display: grid;
  justify-content: center;
  align-items: center;
}

.guess-pegs {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(0.25rem, 2.5vw, 0.8rem);
  padding: 0.12rem;
  border: 1px solid transparent;
  border-radius: 0.4rem;
}

.guess-pegs.is-current {
  border-color: #78cfb3;
  background: rgb(120 207 179 / 8%);
}

.guess-peg {
  display: block;
  width: clamp(1.25rem, 5vw, 1.75rem);
  aspect-ratio: 1;
  justify-self: center;
  border: 1px solid #14242e;
  border-radius: 50%;
  box-shadow: inset 0 2px 3px rgb(255 255 255 / 28%), 0 2px 2px rgb(0 0 0 / 28%);
}

.guess-peg.is-filled {
  background: radial-gradient(circle at 35% 27%, rgb(255 255 255 / 85%), var(--peg-color) 38%, var(--peg-color) 75%);
}

.guess-peg.is-empty {
  border: 2px solid #405866;
  background: #14242e;
  box-shadow: inset 0 2px 3px rgb(0 0 0 / 30%);
}

.feedback-pegs {
  grid-template-columns: repeat(2, 0.7rem);
  grid-template-rows: repeat(2, 0.7rem);
  gap: 0.18rem;
  justify-content: center;
}

.feedback-dot {
  display: block;
  width: 0.58rem;
  aspect-ratio: 1;
  border: 1px solid #526874;
  border-radius: 50%;
  background: #14242e;
}

.feedback-dot.is-exact {
  border-color: #080b0d;
  background: #171b20;
  box-shadow: 0 0 0 1px #aab8bf, inset 0 1px 1px rgb(255 255 255 / 18%);
}

.feedback-dot.is-color-only {
  border-color: #f5ddb0;
  background: #fff2d6;
}

.feedback-dot.is-empty {
  background: #14242e;
}

.palette-panel {
  margin-top: 1.05rem;
  padding: 0.75rem;
  border: 1px solid #eee7db;
  border-radius: 0.75rem;
  background: #faf6ef;
}

.panel-label {
  margin: 0;
  color: #817c74;
  font-size: 0.67rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-align: center;
  text-transform: uppercase;
}

.palette {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.4rem;
  margin-top: 0.6rem;
}

.color-choice {
  display: grid;
  min-width: 0;
  justify-items: center;
  gap: 0.25rem;
  padding: 0.35rem 0.1rem;
  border: 1px solid #e5ddd0;
  border-radius: 0.5rem;
  background: #fffdf9;
  color: #34445a;
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, background-color 120ms ease;
}

.color-choice:not(:disabled):hover {
  transform: translateY(-2px);
  border-color: #c2ad94;
  background: white;
}

.color-choice:disabled {
  cursor: default;
  opacity: 0.58;
}

.color-choice:focus-visible,
.game-action:focus-visible {
  outline: 3px solid #70aab7;
  outline-offset: 2px;
}

.color-swatch {
  width: clamp(1.35rem, 6vw, 2rem);
  aspect-ratio: 1;
  border: 1px solid #18232a;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 27%, rgb(255 255 255 / 85%), var(--peg-color) 38%, var(--peg-color) 75%);
  box-shadow: 0 2px 3px rgb(0 0 0 / 20%);
}

.color-name {
  overflow: hidden;
  max-width: 100%;
  font-size: clamp(0.53rem, 2.1vw, 0.68rem);
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.actions {
  display: flex;
  justify-content: center;
  gap: 0.55rem;
  margin-top: 0.85rem;
}

.game-action {
  min-height: 2.55rem;
  padding: 0.55rem 0.9rem;
  border: 0;
  border-radius: 0.55rem;
  color: white;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 750;
}

.game-action:disabled {
  cursor: default;
  opacity: 0.55;
}

.primary-action {
  background: #337a8e;
  box-shadow: 0 3px 0 #245766;
}

.primary-action:not(:disabled):hover {
  background: #245766;
}

.secondary-action {
  background: #805536;
  box-shadow: 0 3px 0 #5d402d;
}

.secondary-action:not(:disabled):hover {
  background: #70482f;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.45rem 1rem;
  margin-top: 1rem;
  color: #817c74;
  font-size: 0.68rem;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.legend .feedback-dot {
  width: 0.62rem;
}

.mastermind-game .page-footer {
  line-height: 1.5;
}

@media (max-width: 420px) {
  .actions {
    gap: 0.4rem;
  }

  .game-action {
    padding-right: 0.65rem;
    padding-left: 0.65rem;
    font-size: 0.72rem;
  }

  .board-row {
    grid-template-columns: 1.2rem minmax(0, 1fr) minmax(2.6rem, 3rem);
    gap: 0.25rem;
    padding: 0 0.2rem;
  }
}
