/* ============================================================
   Code Breaker — Mastermind-style deduction game
   ============================================================ */

.cb-controls {
  display: flex;
  justify-content: center;
}

.cb-toggle {
  display: inline-flex;
  border: 2px solid var(--ink);
  border-radius: 999px;
  overflow: hidden;
}
.cb-toggle button {
  border: none;
  background: var(--surface);
  color: var(--ink-soft);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 800;
  padding: 8px 16px;
}
.cb-toggle button.active {
  background: var(--ink);
  color: #fff;
}

.cb-status {
  color: var(--ink-soft);
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0;
  min-height: 1.4em;
  text-align: center;
}

.cb-secret,
.cb-guess-slots {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(4, 54px);
  justify-content: center;
}

.cb-slot,
.cb-peg {
  align-items: center;
  background: var(--surface);
  border: 3px solid var(--ink);
  border-radius: 50%;
  box-shadow: 0 4px 0 rgba(34, 49, 74, 0.14);
  color: var(--ink-soft);
  display: inline-flex;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 800;
  height: 54px;
  justify-content: center;
  width: 54px;
}
.cb-slot.is-hidden {
  background: repeating-linear-gradient(
    45deg,
    var(--surface),
    var(--surface) 7px,
    var(--bg-soft) 7px,
    var(--bg-soft) 14px
  );
}
.cb-slot.has-color,
.cb-peg {
  background: var(--peg-color);
}

.cb-board {
  width: min(100%, 560px);
}
.cb-history {
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  min-height: 150px;
  width: 100%;
}
.cb-history:empty::before {
  background: var(--surface);
  border: 2px dashed var(--line);
  border-radius: var(--radius-md);
  color: var(--ink-soft);
  content: "Your guesses will appear here.";
  display: block;
  font-weight: 800;
  padding: 34px 16px;
  text-align: center;
}
.cb-row {
  align-items: center;
  background: var(--surface);
  border: 2px solid var(--ink);
  border-radius: var(--radius-md);
  display: grid;
  gap: 12px;
  grid-template-columns: 44px 1fr 56px;
  padding: 10px 12px;
}
.cb-row-number {
  color: var(--ink-soft);
  font-family: var(--font-score);
  font-size: 0.72rem;
}
.cb-row-pegs {
  display: flex;
  gap: 8px;
  justify-content: center;
}
.cb-row-pegs .cb-peg {
  border-width: 2px;
  box-shadow: none;
  height: 34px;
  width: 34px;
}
.cb-clues {
  display: grid;
  gap: 4px;
  grid-template-columns: repeat(2, 10px);
  justify-content: center;
}
.cb-clue {
  background: #D8E8F5;
  border: 1.5px solid #A8BED3;
  border-radius: 50%;
  height: 10px;
  width: 10px;
}
.cb-clue.exact {
  background: var(--ink);
  border-color: var(--ink);
}
.cb-clue.near {
  background: #fff;
  border-color: var(--ink);
  box-shadow: inset 0 0 0 2px #fff, 0 0 0 2px rgba(34, 49, 74, 0.18);
}
.cb-clue-guide {
  display: grid;
  gap: 6px;
}
.cb-clue-guide span {
  align-items: center;
  display: inline-flex;
  justify-content: center;
}
.cb-example-clue {
  border: 2px solid var(--ink);
  border-radius: 50%;
  display: inline-flex;
  flex: 0 0 14px;
  height: 14px;
  margin-right: 8px;
  width: 14px;
}
.cb-example-clue.exact {
  background: var(--ink);
}
.cb-example-clue.near {
  background: #fff;
  box-shadow: inset 0 0 0 2px #fff, 0 0 0 2px rgba(34, 49, 74, 0.18);
}

.cb-current {
  display: grid;
  gap: 18px;
  justify-items: center;
  width: 100%;
}
.cb-guess-slots .cb-slot {
  cursor: pointer;
}
.cb-guess-slots .cb-slot:disabled {
  cursor: default;
}
.cb-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  max-width: 470px;
}
.cb-color-btn {
  background: var(--peg-color);
  border: 3px solid var(--ink);
  border-radius: 50%;
  box-shadow: 0 4px 0 rgba(34, 49, 74, 0.14);
  cursor: pointer;
  height: 44px;
  padding: 0;
  transition: transform 0.08s ease;
  width: 44px;
}
.cb-color-btn:hover {
  transform: translateY(-2px);
}
.cb-color-btn:active {
  box-shadow: none;
  transform: translateY(2px);
}
.cb-color-btn.active {
  outline: 4px solid rgba(126, 95, 196, 0.26);
  outline-offset: 2px;
}

.cb-result-animation {
  align-items: center;
  background: var(--surface);
  border: 3px solid var(--ink);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 0 rgba(34, 49, 74, 0.14);
  display: flex;
  gap: 12px;
  justify-content: center;
  left: 50%;
  min-width: min(300px, calc(100vw - 48px));
  opacity: 0;
  padding: 14px 18px;
  pointer-events: none;
  position: fixed;
  top: 50%;
  transform: translate(-50%, -50%) scale(0.82);
  visibility: hidden;
  z-index: 45;
}
.cb-result-animation[aria-hidden="false"] {
  visibility: visible;
}
.cb-result-animation.is-solved {
  animation: cb-result-solved 3.5s ease both;
}
.cb-result-animation.is-not-solved {
  animation: cb-result-not-solved 3.5s ease both;
}
.cb-result-icon {
  align-items: center;
  border: 3px solid var(--ink);
  border-radius: 50%;
  display: inline-flex;
  flex: 0 0 46px;
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 800;
  height: 46px;
  justify-content: center;
  width: 46px;
}
.cb-result-text {
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 800;
}
.cb-result-animation.is-solved .cb-result-icon {
  background: var(--simon-green);
  color: #fff;
}
.cb-result-animation.is-not-solved .cb-result-icon {
  background: var(--pink);
  color: #fff;
}

@keyframes cb-result-solved {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.82); }
  18% { opacity: 1; transform: translate(-50%, -50%) scale(1.08); }
  34% { transform: translate(-50%, -50%) scale(1); }
  72% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(0.94); }
}

@keyframes cb-result-not-solved {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.86); }
  16% { opacity: 1; transform: translate(calc(-50% - 8px), -50%) scale(1); }
  25% { transform: translate(calc(-50% + 8px), -50%) scale(1); }
  34% { transform: translate(calc(-50% - 5px), -50%) scale(1); }
  43% { transform: translate(calc(-50% + 5px), -50%) scale(1); }
  55% { transform: translate(-50%, -50%) scale(1); }
  76% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(0.94); }
}

#game-stage:fullscreen,
#game-stage.is-ios-fullscreen {
  border: none;
  border-radius: 0;
  height: 100vh;
  height: 100dvh;
  height: calc(var(--obg-vh, 1vh) * 100);
  justify-content: flex-start;
  overflow-y: auto;
  width: 100vw;
}

@media (max-width: 560px) {
  .cb-secret,
  .cb-guess-slots {
    gap: 8px;
    grid-template-columns: repeat(4, 46px);
  }
  .cb-slot {
    height: 46px;
    width: 46px;
  }
  .cb-row {
    grid-template-columns: 34px 1fr 46px;
    gap: 8px;
    padding: 9px;
  }
  .cb-row-pegs {
    gap: 5px;
  }
  .cb-row-pegs .cb-peg {
    height: 28px;
    width: 28px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cb-result-animation.is-solved,
  .cb-result-animation.is-not-solved {
    animation-duration: 0.6s;
  }
}
