/**
 * Oct Game — аркада перевода восьмеричных чисел
 */

.page--oct-game .oct-game-main {
  width: min(56rem, 100%);
  margin: 0 auto;
  padding: 0 clamp(1rem, 3vw, 2rem) 1.25rem;
}

.oct-game-panel {
  position: relative;
  margin-top: 0.55rem;
  padding: clamp(1.05rem, 2.2vw, 1.55rem);
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background:
    radial-gradient(ellipse 80% 55% at 18% 0%, rgba(167, 139, 250, 0.12), transparent 52%),
    radial-gradient(ellipse 70% 50% at 88% 100%, rgba(99, 102, 241, 0.12), transparent 55%),
    linear-gradient(
      165deg,
      rgba(36, 42, 50, 0.94) 0%,
      rgba(20, 24, 29, 0.96) 55%,
      rgba(16, 20, 25, 0.94) 100%
    );
  box-shadow:
    0 18px 48px rgba(0, 0, 0, 0.34),
    0 1px 0 rgba(255, 255, 255, 0.08) inset,
    inset 0 -1px 0 rgba(129, 140, 248, 0.06);
  backdrop-filter: blur(16px) saturate(1.12);
  -webkit-backdrop-filter: blur(16px) saturate(1.12);
}

.oct-game-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(
    135deg,
    rgba(167, 139, 250, 0.55) 0%,
    rgba(255, 255, 255, 0.12) 38%,
    rgba(99, 102, 241, 0.45) 100%
  );
  -webkit-mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

[data-theme="light"] .oct-game-panel {
  border-color: rgba(15, 23, 42, 0.08);
  background:
    radial-gradient(ellipse 80% 55% at 18% 0%, rgba(167, 139, 250, 0.14), transparent 52%),
    radial-gradient(ellipse 70% 50% at 88% 100%, rgba(99, 102, 241, 0.1), transparent 55%),
    linear-gradient(
      165deg,
      rgba(255, 255, 255, 0.98) 0%,
      rgba(245, 243, 255, 0.96) 48%,
      rgba(238, 242, 255, 0.96) 100%
    );
  box-shadow:
    0 16px 40px rgba(15, 23, 42, 0.1),
    0 1px 0 rgba(255, 255, 255, 0.95) inset;
}

.oct-game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 13.5rem;
  gap: 1.15rem;
  align-items: stretch;
}

.oct-game-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.bg-weights,
.bg-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(5rem, 6.5rem);
  gap: 0.7rem;
  align-items: center;
}

.bg-weights {
  margin-bottom: 0.7rem;
  padding: 0.2rem 0.1rem 0.35rem;
  transition: opacity 0.35s ease;
}

.bg-coin {
  --coin-size: clamp(2.55rem, 6vw, 3.2rem);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--coin-size);
  height: var(--coin-size);
  margin: 0 auto;
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 28%, #ede9fe 0%, transparent 38%),
    radial-gradient(circle at 70% 78%, rgba(67, 56, 202, 0.4) 0%, transparent 45%),
    linear-gradient(145deg, #c4b5fd 0%, #8b5cf6 42%, #6366f1 72%, #4f46e5 100%);
  border: 2px solid rgba(221, 214, 254, 0.95);
  box-shadow:
    0 6px 14px rgba(79, 70, 229, 0.38),
    0 1px 0 rgba(255, 255, 255, 0.55) inset,
    0 -2px 4px rgba(49, 46, 129, 0.35) inset,
    0 0 0 1px rgba(67, 56, 202, 0.35);
  color: #312e81;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  letter-spacing: -0.02em;
  text-shadow: 0 1px 0 rgba(237, 233, 254, 0.55);
  animation: bg-coin-idle 3.6s ease-in-out infinite;
  transition:
    transform 0.22s ease,
    box-shadow 0.22s ease,
    opacity 0.35s ease;
}

.bg-coin:nth-child(2) { animation-delay: 0.18s; }
.bg-coin:nth-child(3) { animation-delay: 0.36s; }

.bg-coin::before {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  border: 1.5px dashed rgba(49, 46, 129, 0.3);
  pointer-events: none;
}

.bg-coin::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: linear-gradient(
    125deg,
    rgba(255, 255, 255, 0.55) 0%,
    rgba(255, 255, 255, 0.08) 28%,
    transparent 48%
  );
  pointer-events: none;
}

.bg-coin__face {
  position: relative;
  z-index: 1;
  font-size: clamp(0.78rem, 2vw, 0.95rem);
  line-height: 1;
}

.bg-weights__num {
  display: flex;
  align-items: center;
  justify-content: center;
  height: clamp(2.55rem, 6vw, 3.2rem);
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02));
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

[data-theme="light"] .bg-weights__num {
  border-color: rgba(15, 23, 42, 0.1);
  background: linear-gradient(160deg, #fff, #f8fafc);
}

.oct-game-stage.is-weights-hidden .bg-coin {
  opacity: 0;
  transform: scale(0.85) translateY(-4px);
  pointer-events: none;
}

@keyframes bg-coin-idle {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-2px);
  }
}

.bg-well {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 0.32rem;
  height: 24rem;
  min-height: 24rem;
  padding: 0.65rem;
  border-radius: 16px;
  background:
    radial-gradient(ellipse 90% 40% at 50% 100%, rgba(250, 204, 21, 0.06), transparent 60%),
    linear-gradient(180deg, rgba(8, 12, 16, 0.28), rgba(8, 12, 16, 0.58)),
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 27px,
      rgba(45, 212, 191, 0.04) 28px
    );
  box-shadow:
    inset 0 2px 18px rgba(0, 0, 0, 0.38),
    inset 0 0 0 1px rgba(255, 255, 255, 0.04);
  overflow: hidden;
}

.bg-well.is-danger {
  box-shadow:
    inset 0 0 0 1px rgba(248, 113, 113, 0.45),
    inset 0 2px 16px rgba(0, 0, 0, 0.35);
}

[data-theme="light"] .bg-well {
  background:
    linear-gradient(180deg, rgba(15, 23, 42, 0.04), rgba(15, 23, 42, 0.08)),
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 27px,
      rgba(13, 148, 136, 0.06) 28px
    );
  box-shadow: inset 0 2px 12px rgba(15, 23, 42, 0.06);
}

.bg-row {
  padding: 0.12rem 0;
}

.bg-row.is-entering {
  animation: bg-row-in 0.28s ease-out;
}

.bg-row.is-clearing {
  animation: bg-row-out 0.28s ease-in forwards;
}

.bg-row.is-shake .bg-digits {
  animation: bg-shake 0.38s ease;
}

@keyframes bg-row-in {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes bg-row-out {
  to {
    opacity: 0;
    transform: scale(0.92) translateX(12px);
  }
}

@keyframes bg-shake {
  20%,
  80% {
    transform: translateX(-4px);
  }
  40%,
  60% {
    transform: translateX(4px);
  }
  100% {
    transform: translateX(0);
  }
}

.bg-bit {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 2.35rem;
  border-radius: 11px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background:
    linear-gradient(165deg, rgba(42, 48, 56, 0.95), rgba(18, 22, 27, 0.98));
  color: rgba(226, 232, 240, 0.5);
  font-family: ui-monospace, "Cascadia Code", "SFMono-Regular", Menlo, monospace;
  font-size: 1.08rem;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  box-shadow:
    0 4px 10px rgba(0, 0, 0, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  transition:
    background 0.16s ease,
    color 0.16s ease,
    border-color 0.16s ease,
    box-shadow 0.16s ease,
    transform 0.12s ease;
}

.bg-bit:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: rgba(167, 139, 250, 0.45);
  box-shadow:
    0 6px 14px rgba(0, 0, 0, 0.22),
    0 0 0 1px rgba(139, 92, 246, 0.14);
}

.bg-bit:disabled {
  cursor: default;
}

.bg-bit.is-on {
  color: #312e81;
  background:
    radial-gradient(circle at 30% 25%, #ede9fe 0%, transparent 42%),
    linear-gradient(160deg, #c4b5fd, #8b5cf6 55%, #6366f1);
  border-color: rgba(221, 214, 254, 0.95);
  box-shadow:
    0 5px 16px rgba(99, 102, 241, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.55),
    inset 0 -2px 4px rgba(49, 46, 129, 0.25);
}

[data-theme="light"] .bg-bit {
  background: linear-gradient(165deg, #fff, #f1f5f9);
  border-color: rgba(15, 23, 42, 0.12);
  color: rgba(15, 23, 42, 0.4);
  box-shadow:
    0 3px 8px rgba(15, 23, 42, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

[data-theme="light"] .bg-bit.is-on {
  color: #312e81;
}

.bg-digits {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  height: 2.35rem;
  min-height: 2.35rem;
  padding: 0 0.35rem;
  border-radius: 11px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.08), rgba(0, 0, 0, 0.28));
  color: #f8fafc;
  font-variant-numeric: tabular-nums;
  font-weight: 750;
  line-height: 1;
  cursor: default;
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.bg-digits.is-problem {
  cursor: pointer;
  border-style: solid;
  border-color: rgba(167, 139, 250, 0.55);
  background: linear-gradient(165deg, rgba(167, 139, 250, 0.16), rgba(99, 102, 241, 0.05));
}

.bg-digits__main {
  font-size: 1.08rem;
}

.bg-digits__live {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: rgba(196, 181, 253, 0.95);
}

[data-theme="light"] .bg-digits {
  background: linear-gradient(165deg, #fff, #f8fafc);
  border-color: rgba(15, 23, 42, 0.12);
  color: #0f172a;
}

.bg-row.is-selected .bg-digits {
  box-shadow:
    0 0 0 2px rgba(167, 139, 250, 0.55),
    0 0 18px rgba(99, 102, 241, 0.28);
}

.bg-hud {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.bg-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.bg-stat {
  padding: 0.55rem 0.7rem;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background:
    linear-gradient(165deg, rgba(255, 255, 255, 0.07), rgba(0, 0, 0, 0.22));
  text-align: center;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    0 4px 12px rgba(0, 0, 0, 0.12);
}

[data-theme="light"] .bg-stat {
  background: linear-gradient(165deg, #fff, #f8fafc);
  border-color: rgba(15, 23, 42, 0.1);
}

.bg-stat__label {
  display: block;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.bg-stat__value {
  display: block;
  margin-top: 0.12rem;
  font-size: 1.28rem;
  font-weight: 780;
  line-height: 1.2;
  background: linear-gradient(135deg, #ede9fe, #c4b5fd 40%, #818cf8);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

[data-theme="light"] .bg-stat__value {
  background: linear-gradient(135deg, #5b21b6, #4338ca);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.bg-hud-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
}

.bg-hud-actions .bg-btn:last-child {
  grid-column: 1 / -1;
}

.bg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
  border: 1px solid rgba(45, 212, 191, 0.35);
  background: rgba(13, 148, 136, 0.12);
  color: #ecfdf5;
  font-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease,
    border-color 0.18s ease,
    background 0.18s ease,
    opacity 0.18s ease;
}

.bg-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: rgba(45, 212, 191, 0.65);
}

.bg-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.bg-btn--primary {
  background: linear-gradient(145deg, rgba(167, 139, 250, 0.5), rgba(79, 70, 229, 0.32));
  border-color: rgba(167, 139, 250, 0.55);
  color: #eef2ff;
  box-shadow:
    0 8px 24px rgba(79, 70, 229, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

[data-theme="light"] .bg-btn {
  color: #4338ca;
  background: rgba(224, 231, 255, 0.85);
  border-color: rgba(99, 102, 241, 0.3);
}

[data-theme="light"] .bg-btn--primary {
  color: #312e81;
  background: linear-gradient(145deg, #c4b5fd, #818cf8);
}

.bg-btn[aria-pressed="false"] {
  opacity: 0.7;
}

.bg-calc {
  padding: 0.75rem;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.2);
}

.bg-calc.is-idle {
  opacity: 0.55;
}

[data-theme="light"] .bg-calc {
  background: rgba(15, 23, 42, 0.03);
  border-color: rgba(15, 23, 42, 0.08);
}

.bg-calc__title {
  margin: 0 0 0.55rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.bg-calc__grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.38rem;
}

.bg-key {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 2.15rem;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  color: inherit;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition:
    background 0.14s ease,
    transform 0.12s ease;
}

.bg-key:hover {
  background: rgba(45, 212, 191, 0.18);
  transform: translateY(-1px);
}

.bg-key--util {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.bg-key--ok {
  background: linear-gradient(145deg, rgba(45, 212, 191, 0.4), rgba(13, 148, 136, 0.22));
  border-color: rgba(45, 212, 191, 0.4);
}

.bg-key--zero {
  grid-column: 1 / -1;
}

.bg-calc__hint {
  margin: 0.55rem 0 0;
  font-size: 0.72rem;
  line-height: 1.4;
  color: var(--text-muted);
}

.bg-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 1.6rem 1rem 1rem;
  border-radius: 14px;
  background: rgba(10, 12, 16, 0.72);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  z-index: 10;
}

.bg-overlay[hidden] {
  display: none;
}

.bg-overlay__card {
  width: min(22rem, 100%);
  padding: 1.15rem 1.2rem 1.05rem;
  border-radius: 18px;
  border: 1px solid rgba(167, 139, 250, 0.4);
  background:
    radial-gradient(ellipse 90% 60% at 20% 0%, rgba(167, 139, 250, 0.14), transparent 55%),
    linear-gradient(165deg, rgba(42, 48, 56, 0.98), rgba(22, 26, 32, 1));
  text-align: center;
  box-shadow:
    0 16px 40px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.bg-overlay__card--wide {
  width: min(28rem, 100%);
  text-align: left;
}

[data-theme="light"] .bg-overlay {
  background: rgba(238, 242, 255, 0.72);
}

[data-theme="light"] .bg-overlay__card {
  background:
    radial-gradient(ellipse 90% 60% at 20% 0%, rgba(167, 139, 250, 0.16), transparent 55%),
    linear-gradient(165deg, #fff, #eef2ff);
  border-color: rgba(99, 102, 241, 0.28);
}

.bg-overlay__kicker {
  margin: 0 0 0.35rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #a78bfa;
}

.bg-overlay__title {
  margin: 0 0 0.55rem;
  font-family: var(--font-heading);
  font-size: 1.45rem;
  font-weight: 700;
}

.bg-overlay__text {
  margin: 0 0 0.85rem;
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--text-muted);
}

.bg-overlay__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.55rem;
}

.bg-rules {
  margin: 0 0 1.1rem;
  padding-left: 1.15rem;
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--text-muted);
}

.bg-rules li + li {
  margin-top: 0.45rem;
}

.bg-rules kbd,
.oct-game-hint kbd {
  display: inline-block;
  margin: 0 0.08rem;
  padding: 0.08rem 0.35rem;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  font-family: inherit;
  font-size: 0.75rem;
}

.oct-game-hint {
  margin: 0.9rem 0 0;
  font-size: 0.8125rem;
  text-align: center;
  color: var(--text-muted);
}

@media (max-width: 840px) {
  .oct-game-layout {
    grid-template-columns: 1fr;
  }

  .bg-hud-actions {
    grid-template-columns: repeat(3, 1fr);
  }

  .bg-hud-actions .bg-btn:last-child {
    grid-column: auto;
  }

  .bg-well {
    height: 21rem;
    min-height: 21rem;
  }

  .bg-overlay {
    inset: 0;
  }
}

@media (max-width: 560px) {
  .bg-weights,
  .bg-row {
    gap: 0.4rem;
    grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(3.8rem, 4.8rem);
  }

  .bg-coin {
    --coin-size: 2.25rem;
  }

  .bg-coin__face {
    font-size: 0.72rem;
  }

  .bg-weights__num {
    height: 2.25rem;
    font-size: 0.62rem;
  }

  .bg-bit,
  .bg-digits {
    height: 2.35rem;
    min-height: 2.35rem;
  }

  .bg-bit,
  .bg-digits__main {
    font-size: 1rem;
  }
}
