/* ============================================================
   BŰVÖS KOCKA - Rubik's cube solver
   Design: 1980s Hungary - cream paper, tricolor, chunky print,
   offset "misregistered" shadows, amber pocket-radio display.
   ============================================================ */
:root {
  --paper: #f4ecd8;
  --panel: #fdf7e6;
  --card: #fffdf4;
  --ink: #26201b;
  --ink-soft: rgba(38, 32, 27, 0.22);
  --red: #c9282d;
  --green: #2e7d43;
  --mustard: #e3a71f;
  --orange: #e46b1d;
  --blue: #2456a6;
  --font-display: 'Archivo Black', 'Arial Black', 'Segoe UI', sans-serif;
  --font-body: 'Archivo', 'Segoe UI', Arial, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, Consolas, monospace;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(rgba(38, 32, 27, 0.055) 1.2px, transparent 1.3px) 0 0 / 22px 22px,
    var(--paper);
}
.page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 22px 46px;
}
::selection { background: var(--mustard); color: var(--ink); }
/* ------------------------------------------------ masthead */
.topbar {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 16px;
}
.lang-switch {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-decoration: none;
  color: var(--ink);
  border: 2px solid var(--ink);
  border-radius: 7px;
  padding: 5px 11px;
  background: var(--card);
  box-shadow: 3px 3px 0 var(--ink-soft);
  transition: transform 60ms;
}
.lang-switch:hover {
  background: var(--mustard);
  transform: translate(-1px, -1px);
}
.xlink {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--ink);
  border: 2px solid var(--ink);
  border-radius: 8px;
  padding: 6px 12px;
  background: var(--card);
  box-shadow: 3px 3px 0 var(--ink-soft);
  transition: transform 60ms, box-shadow 60ms, background 60ms;
}
.xlink svg { width: 15px; height: 15px; flex: none; }
.xlink b { font-weight: 700; }
.xlink:hover {
  background: var(--mustard);
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 var(--ink-soft);
}
.lang-menu { position: relative; z-index: 70; }
.lang-menu summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--ink);
  border: 2px solid var(--ink);
  border-radius: 7px;
  padding: 5px 11px;
  background: var(--card);
  box-shadow: 3px 3px 0 var(--ink-soft);
}
.lang-menu summary::-webkit-details-marker { display: none; }
.lang-menu summary:hover { background: var(--mustard); }
.lang-menu[open] summary { background: var(--mustard); }
.lang-menu .caret { font-size: 9px; opacity: 0.7; }
.lang-list {
  position: absolute;
  right: 0;
  top: calc(100% + 7px);
  min-width: 180px;
  background: var(--card);
  border: 3px solid var(--ink);
  border-radius: 12px;
  box-shadow: 6px 6px 0 var(--ink-soft);
  padding: 7px;
  display: grid;
  gap: 2px;
}
.lang-list a {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 10px;
  border-radius: 7px;
  text-decoration: none;
  color: var(--ink);
  font-weight: 700;
  font-size: 12.5px;
}
.lang-list a:hover { background: var(--mustard); }
.lang-list a.active { background: var(--ink); color: var(--paper); }
.flag {
  display: inline-flex;
  width: 21px;
  height: 15px;
  border: 1px solid rgba(38, 32, 27, 0.45);
  border-radius: 2px;
  overflow: hidden;
  flex: none;
}
.flag svg { width: 100%; height: 100%; display: block; }
.masthead {
  position: relative;
  display: flex;
  align-items: center;
  gap: 26px;
  padding: 12px 150px 20px 4px;
  flex-wrap: wrap;
}
.logo-link {
  flex: none;
  display: inline-flex;
  border-radius: 9px;
  text-decoration: none;
}
.logo-link:focus-visible {
  outline: 3px solid var(--mustard);
  outline-offset: 4px;
}
.logo-cube {
  display: grid;
  grid-template-columns: repeat(3, 20px);
  grid-template-rows: repeat(3, 20px);
  gap: 3px;
  padding: 6px;
  background: var(--ink);
  border-radius: 9px;
  transform: rotate(-8deg);
  box-shadow: 5px 5px 0 var(--ink-soft);
  flex: none;
  transition: transform 90ms, box-shadow 90ms;
}
.logo-link:hover .logo-cube {
  transform: rotate(-8deg) translate(-1px, -1px);
  box-shadow: 7px 7px 0 var(--ink-soft);
}
.logo-cube span { border-radius: 3px; }
.masthead-text { min-width: 260px; }
.overline {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 4px;
  text-transform: uppercase;
  opacity: 0.75;
  margin-bottom: 2px;
}
.title {
  font-family: var(--font-display);
  font-size: clamp(42px, 6.4vw, 76px);
  line-height: 1.02;
  margin: 0;
  letter-spacing: 1px;
  text-transform: uppercase;
  text-shadow: 3px 3px 0 var(--mustard), 6px 6px 0 var(--red);
}
.subtitle {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 3px;
  text-transform: uppercase;
}
.subtitle em {
  font-style: normal;
  color: #fff;
  background: var(--red);
  border: 2px solid var(--ink);
  border-radius: 5px;
  padding: 1px 7px;
  box-shadow: 2px 2px 0 var(--ink-soft);
  white-space: nowrap;
}
.subtitle em .hl {
  color: var(--ink);
  background: var(--mustard);
  border-radius: 3px;
  padding: 0 3px;
  margin: 0 1px;
  box-shadow: 0 0 0 1px var(--ink) inset;
}
.disclaimer {
  margin-top: 9px;
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1.55;
  letter-spacing: 0.2px;
  opacity: 0.72;
  max-width: none;
}
.badge {
  position: absolute;
  right: 4px;
  top: 50%;
  width: 118px;
  height: 118px;
  border-radius: 50%;
  border: 3px dashed var(--red);
  color: var(--red);
  display: grid;
  place-items: center;
  text-align: center;
  font-weight: 900;
  font-size: 12.5px;
  line-height: 1.5;
  letter-spacing: 1.5px;
  transform: translateY(-50%) rotate(9deg);
  background: rgba(201, 40, 45, 0.05);
}
@media (max-width: 980px) {
  .badge { display: none; }
  .masthead { padding-right: 4px; }
}
.tricolor {
  height: 16px;
  border: 3px solid var(--ink);
  border-radius: 99px;
  background: linear-gradient(180deg, #c9282d 0 33%, #f6f1e2 33% 67%, #2e7d43 67% 100%);
  box-shadow: 4px 4px 0 var(--ink-soft);
  margin: 4px 0 30px;
}
/* ------------------------------------------------ layout & panels */
main.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
}
.panel {
  background: var(--panel);
  border: 3px solid var(--ink);
  border-radius: 18px;
  padding: 20px 22px 22px;
  box-shadow: 9px 9px 0 var(--sc, var(--ink-soft));
}
.panel--controls { grid-column: 1 / -1; --sc: var(--mustard); }
.panel--net { --sc: var(--green); }
.panel--3d { --sc: var(--blue); }
.panel--solution { grid-column: 1 / -1; --sc: var(--red); }
.panel-tag {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 400;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--paper);
  background: var(--ink);
  border-radius: 7px;
  padding: 5px 13px;
  margin: 0 0 16px;
  transform: rotate(-1.2deg);
  box-shadow: 3px 3px 0 var(--sc, var(--ink-soft));
}
.panel-tag span {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 2px;
  opacity: 0.75;
}
.hint {
  font-size: 11.5px;
  line-height: 1.55;
  opacity: 0.8;
  margin: 10px 0 0;
}
/* ------------------------------------------------ controls panel */
.controls-flex {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 28px;
  align-items: start;
}
.palette-block, .buttons-block, .display-block { min-width: 0; }
/* palette */
#palette {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  gap: 9px;
}
.swatch {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  padding: 6px 8px;
  border: 2px solid var(--ink);
  border-radius: 9px;
  background: var(--card);
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.5px;
  color: var(--ink);
  box-shadow: 3px 3px 0 var(--ink-soft);
  transition: transform 60ms;
}
.sw-name {
  flex: 1;
  min-width: 0;
  font-size: 10.5px;
  letter-spacing: 0.2px;
  text-align: left;
  overflow-wrap: anywhere;
}
.swatch:hover { transform: translate(-1px, -1px); }
.swatch.selected {
  background: var(--ink);
  color: var(--paper);
  box-shadow: 3px 3px 0 var(--mustard);
}
.sw-chip {
  width: 20px;
  height: 20px;
  border: 2px solid var(--ink);
  border-radius: 5px;
  flex: none;
}
.sw-count {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  border: 2px solid currentColor;
  border-radius: 6px;
  min-width: 23px;
  text-align: center;
  padding: 1px 2px;
  opacity: 0.85;
}
.sw-count[data-state="over"] { background: var(--red); border-color: var(--red); color: #fff; opacity: 1; }
.sw-count[data-state="full"] { background: var(--green); border-color: var(--green); color: #fff; opacity: 1; }
/* buttons */
.btn-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 0;
  padding: 10px 8px;
  border: 3px solid var(--ink);
  border-radius: 11px;
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
  font-family: var(--font-body);
  box-shadow: 4px 4px 0 var(--ink);
  transition: transform 70ms, box-shadow 70ms;
}
.btn svg {
  width: 17px;
  height: 17px;
  flex: none;
}
.btn b {
  min-width: 0;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  overflow-wrap: break-word;
}
.btn i {
  font-style: normal;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 2.2px;
  text-transform: uppercase;
  opacity: 0.72;
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--ink); }
.btn:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.btn:disabled { opacity: 0.55; cursor: wait; transform: none; box-shadow: 4px 4px 0 var(--ink); }
.btn--mustard { background: var(--mustard); }
.btn--green { background: var(--green); color: #fff; }
.btn--green i { opacity: 0.85; }
.btn--red { background: var(--red); color: #fff; }
.btn--red i { opacity: 0.85; }
/* amber display */
.status {
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.6;
  background: #2a241c;
  color: var(--mustard);
  border: 3px solid var(--ink);
  border-radius: 10px;
  padding: 13px 15px;
  min-height: 76px;
  box-shadow: inset 0 0 0 2px rgba(227, 167, 31, 0.14), inset 0 0 22px rgba(0, 0, 0, 0.55);
  word-break: break-word;
}
.status[data-kind="err"] { color: #ff7a68; }
.status[data-kind="ok"] { color: #8be28b; }
.status[data-kind="busy"] { color: #ffd23f; }
/* algorithm input */
.alg-row {
  display: flex;
  gap: 9px;
  margin-top: 11px;
}
#alg-input {
  flex: 1;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 8px 11px;
  border: 3px solid var(--ink);
  border-radius: 9px;
  background: var(--card);
  color: var(--ink);
  box-shadow: inset 2px 2px 0 var(--ink-soft);
}
#alg-input:focus {
  outline: 3px solid var(--mustard);
  outline-offset: -1px;
}
#alg-input::placeholder { color: rgba(38, 32, 27, 0.4); }
/* full-width instruction strip between the tricolor bar and the panels */
.hint--unified {
  margin: -10px 0 28px;
  padding: 12px 18px;
  border: 2px dashed var(--ink-soft);
  border-radius: 12px;
  background: rgba(253, 247, 230, 0.72);
  font-size: 12px;
  line-height: 1.7;
  opacity: 0.95;
}
.hint--unified span { display: block; }
.hint--unified .kw {
  font-weight: 900;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  background: var(--ink);
  color: var(--paper);
  border-radius: 4px;
  padding: 0 6px;
  margin-right: 5px;
  font-size: 10px;
}
/* ------------------------------------------------ unfolded net */
#net {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 14px;
  max-width: 540px;
  margin: 8px auto 4px;
}
.net-face {
  position: relative;
  aspect-ratio: 1;
  background: var(--ink);
  border-radius: 9px;
  padding: 6px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 4px;
  box-shadow: 4px 4px 0 var(--ink-soft);
}
.face-tag {
  position: absolute;
  top: -10px;
  left: 7px;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 1.2px;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 5px;
  padding: 0 6px;
  z-index: 2;
  white-space: nowrap;
}
.sticker {
  position: relative;
  border-radius: 4px;
  border: 1px solid rgba(0, 0, 0, 0.28);
  cursor: pointer;
}
.sticker:hover { outline: 3px solid var(--mustard); outline-offset: -1px; z-index: 1; }
.sticker.center { cursor: not-allowed; }
.sticker.center::after {
  content: attr(data-letter);
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: clamp(9px, 1.6vw, 13px);
  color: rgba(0, 0, 0, 0.45);
  text-shadow: 0 0 3px rgba(255, 255, 255, 0.45);
}
/* ------------------------------------------------ 3-D view */
#viewport3d {
  position: relative;
  height: 430px;
  perspective: 1150px;
  display: grid;
  place-items: center;
  cursor: grab;
  touch-action: none;
  border-radius: 14px;
  background: radial-gradient(circle at 50% 58%, rgba(38, 32, 27, 0.09), transparent 62%);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}
/* current move during playback */
#move-indicator {
  position: absolute;
  left: 14px;
  bottom: 12px;
  font-family: var(--font-mono);
  font-size: 30px;
  font-weight: 700;
  line-height: 1;
  min-width: 58px;
  text-align: center;
  padding: 9px 14px 11px;
  background: var(--ink);
  color: var(--mustard);
  border-radius: 11px;
  box-shadow: 4px 4px 0 var(--ink-soft);
  pointer-events: none;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 130ms, transform 130ms;
}
#move-indicator.show {
  opacity: 1;
  transform: none;
}
#viewport3d.dragging { cursor: grabbing; }
#cubeRoot {
  width: 0;
  height: 0;
  transform-style: preserve-3d;
}
.cubie {
  position: absolute;
  left: -32px;
  top: -32px;
  width: 64px;
  height: 64px;
  transform-style: preserve-3d;
}
.c-face {
  position: absolute;
  inset: 0;
  border: 3px solid #17120e;
  border-radius: 6px;
  background: #241f19;
  box-shadow: inset 0 0 7px rgba(0, 0, 0, 0.2);
}
.c-face.f-F { transform: translateZ(32px); }
.c-face.f-B { transform: rotateY(180deg) translateZ(32px); }
.c-face.f-R { transform: rotateY(90deg) translateZ(32px); }
.c-face.f-L { transform: rotateY(-90deg) translateZ(32px); }
.c-face.f-U { transform: rotateX(90deg) translateZ(32px); }
.c-face.f-D { transform: rotateX(-90deg) translateZ(32px); }
.sticker3d { cursor: pointer; }
.sticker3d:hover { filter: brightness(1.12); }
/* ------------------------------------------------ solution */
#sol-empty {
  padding: 18px 14px;
  border: 2px dashed var(--ink-soft);
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.4px;
  opacity: 0.78;
  text-align: center;
}
#sol-meta {
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 1.2px;
  opacity: 0.85;
}
#sol-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0 16px;
}
.chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 14px;
  border: none;
  border-radius: 12px;
  padding: 7px 7px 5px;
  min-width: 74px;
  text-align: center;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: transform 60ms, background 80ms;
}
.chip-cube {
  display: block;
  width: 60px;
  height: 60px;
}
.chip:hover { transform: translateY(-2px); background: var(--card); }
.chip.done { background: var(--green); color: #fff; opacity: 0.9; }
.chip.current {
  background: var(--mustard);
  transform: translateY(-2px);
  box-shadow: 2px 4px 0 rgba(38, 32, 27, 0.35);
}
#sol-controls { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.speed-group {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-left: auto;
  flex-wrap: wrap;
}
.speed-caption {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  opacity: 0.75;
  margin-right: 2px;
}
.sbtn {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  padding: 6px 9px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--ink-soft);
  transition: transform 60ms;
}
.sbtn:hover { transform: translate(-1px, -1px); }
.sbtn.selected {
  background: var(--mustard);
  box-shadow: 2px 2px 0 var(--ink);
}
.pbtn {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 8px 14px;
  border: 3px solid var(--ink);
  border-radius: 9px;
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
  box-shadow: 4px 4px 0 var(--ink);
  transition: transform 60ms, box-shadow 60ms;
}
.pbtn:hover:not(:disabled) { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--ink); }
.pbtn:active:not(:disabled) { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.pbtn:disabled { opacity: 0.4; cursor: default; }
.pbtn--wide { background: var(--mustard); min-width: 110px; }
/* ------------------------------------------------ article (retro infographic) */
.panel--article { grid-column: 1 / -1; --sc: var(--green); }
.art-title {
  font-family: var(--font-display);
  font-size: clamp(24px, 3.6vw, 38px);
  font-weight: 400;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin: 8px 0 12px;
  text-shadow: 2px 2px 0 var(--mustard), 4px 4px 0 var(--red);
}
.art-lead {
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.75;
  max-width: 82ch;
  margin: 0 0 8px;
}
.article-body h3 {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 400;
  letter-spacing: 2px;
  text-transform: uppercase;
  margin: 30px 0 12px;
  padding-bottom: 4px;
  border-bottom: 4px solid var(--red);
}
.article-body p {
  font-size: 13.5px;
  line-height: 1.8;
  max-width: 84ch;
  margin: 0 0 12px;
}
.article-body a {
  color: var(--red);
  font-weight: 800;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}
.article-body a:hover { background: var(--mustard); color: var(--ink); }
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 15px;
  margin: 18px 0 8px;
}
.stat {
  display: flex;
  flex-direction: column;
  gap: 7px;
  border: 3px solid var(--ink);
  border-radius: 12px;
  background: var(--card);
  padding: 15px 17px;
  box-shadow: 6px 6px 0 var(--sc, var(--ink-soft));
}
.stat-num {
  font-family: var(--font-display);
  font-size: 23px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  line-height: 1.1;
}
.stat-label {
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.55;
  opacity: 0.85;
}
.timeline {
  list-style: none;
  margin: 14px 0 6px;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 13px;
}
.timeline li {
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: 10px;
  padding: 11px 13px;
  box-shadow: 3px 3px 0 var(--ink-soft);
  font-size: 12px;
  line-height: 1.55;
}
.timeline b {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 1px;
  background: var(--ink);
  color: var(--paper);
  border-radius: 5px;
  padding: 1px 9px;
  margin-bottom: 7px;
}
.timeline span { display: block; font-weight: 600; opacity: 0.9; }
.faq-item {
  border-top: 2px dashed var(--ink-soft);
  padding: 11px 0 3px;
  max-width: 86ch;
}
.faq-item h4 {
  margin: 4px 0 7px;
  font-size: 13.5px;
  letter-spacing: 0.3px;
}
.faq-item p { margin: 0 0 10px; }
/* ------------------------------------------------ back to top */
#to-top {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  width: 60px;
  padding: 7px 7px 5px;
  background: var(--ink);
  border: 3px solid var(--ink);
  border-radius: 13px;
  cursor: pointer;
  box-shadow: 4px 4px 0 var(--ink-soft);
  opacity: 0;
  transform: translateY(14px);
  pointer-events: none;
  transition: opacity 160ms, transform 160ms;
}
#to-top.visible {
  opacity: 0.55;
  transform: none;
  pointer-events: auto;
}
#to-top.visible:hover { opacity: 1; transform: translateY(-3px); }
#to-top.visible:active { opacity: 1; transform: translateY(0); }
.top-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
}
.top-grid span {
  aspect-ratio: 1;
  border-radius: 3px;
}
.top-grid span:not([data-col]) { background: #3d362e; }
.top-label {
  display: block;
  margin-top: 5px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--paper);
}
/* ------------------------------------------------ footer */
footer {
  margin-top: 38px;
  text-align: center;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.6px;
  line-height: 2;
  opacity: 0.85;
}
footer a {
  color: var(--ink);
  font-weight: 800;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}
footer a:hover { background: var(--mustard); }
.foot-langs {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 7px 14px;
  max-width: 780px;
  margin: 16px auto 0;
  padding-top: 14px;
  border-top: 2px dashed var(--ink-soft);
  line-height: 1.4;
}
.foot-langs a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  text-decoration: none;
  font-weight: 700;
  font-size: 12px;
}
.foot-langs a:hover { background: transparent; color: var(--red); }
.foot-langs a[aria-current="page"] { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }
.foot-langs .flag { width: 20px; height: 14px; }
.mini-flag {
  display: inline-block;
  width: 20px;
  height: 13px;
  border: 2px solid var(--ink);
  border-radius: 3px;
  vertical-align: -2px;
  margin: 0 6px;
  background: linear-gradient(180deg, #c9282d 0 33%, #f6f1e2 33% 67%, #2e7d43 67% 100%);
}
/* ------------------------------------------------ simulator page */
.sim-controls {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  align-items: stretch;
}
.sim-btns {
  display: grid;
  gap: 12px;
  align-content: stretch;
  flex: 0 0 auto;
  min-width: 200px;
}
.sim-controls .status {
  flex: 1 1 260px;
  min-width: 0;
}
.sim-stage { grid-column: 1 / -1; }
.sim-stage #viewport3d { height: 560px; perspective: 1500px; }
@media (max-width: 880px) {
  .sim-stage #viewport3d { height: 450px; }
}
@media (max-width: 480px) {
  .sim-stage #viewport3d { height: 350px; perspective: 1100px; }
}
/* ------------------------------------------------ cube sticker colours
   (kept last so they win over .c-face's plastic background) */
[data-col="0"] { background: #fdfcf3; }
[data-col="1"] { background: #d02b20; }
[data-col="2"] { background: #1e9e4f; }
[data-col="3"] { background: #ffd23f; }
[data-col="4"] { background: #f07d1a; }
[data-col="5"] { background: #2456a6; }
[data-col="e"] {
  background: repeating-linear-gradient(45deg, #ded3ba 0 5px, #cbc0a7 5px 10px);
}
/* ------------------------------------------------ responsive */
@media (max-width: 880px) {
  main.grid { grid-template-columns: 1fr; }
  #viewport3d { height: 380px; }
  .panel { padding: 16px 16px 18px; }
}
@media (max-width: 480px) {
  #viewport3d { height: 320px; perspective: 900px; }
  #net { gap: 10px; }
  .btn-grid { grid-template-columns: 1fr; }
}
