/* ============================================================
   Qubee — neo-brutalist cubing app
   Design tokens + layout + components
   ============================================================ */
:root {
  --cream: #f4f1e9;
  --paper: #ffffff;
  --ink: #14130f;
  --ink-soft: #6f6a5e;

  --red: #ee3d34;
  --yellow: #ffcb1f;
  --blue: #177ee6;
  --orange: #f39a1a;
  --green: #23b34a;
  --green-play: #22b24b;

  --line: 3.5px;
  --radius: 26px;
  --radius-sm: 16px;
  --shadow: 6px 6px 0 var(--ink);
  --shadow-sm: 4px 4px 0 var(--ink);
  --shadow-press: 2px 2px 0 var(--ink);

  --font: "Helvetica Neue", "Arial", system-ui, sans-serif;
  --font-black: "Arial Black", "Helvetica Neue", system-ui, sans-serif;
  --letter: 0;

  --gap: 20px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* ---- font-style themes (offline system stacks) ---- */
:root[data-font="rounded"] {
  --font: "Chalkboard SE", "Comic Sans MS", "Marker Felt", system-ui, sans-serif;
  --font-black: "Chalkboard SE", "Comic Sans MS", "Marker Felt", system-ui, sans-serif;
}
:root[data-font="mono"] {
  --font: "SF Mono", "Menlo", "Consolas", "Courier New", monospace;
  --font-black: "SF Mono", "Menlo", "Consolas", "Courier New", monospace;
  --letter: -0.02em;
}
.brand__name, .home__title, .stage__move, .timer__display,
.notation, .steps__head, .panel__head, .btn { letter-spacing: var(--letter); }

html, body { height: 100%; }

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--cream);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

kbd {
  font-family: var(--font);
  font-weight: 800;
  background: var(--ink);
  color: var(--cream);
  border-radius: 6px;
  padding: 1px 6px;
  font-size: 0.85em;
}

/* ---------- Screens ---------- */
.screen { display: none; min-height: 100dvh; }
.screen.is-active { display: block; }
[hidden] { display: none !important; }

/* =========================================================
   HOME
   ========================================================= */
.home {
  position: relative;
  overflow: hidden;
  display: grid;
  place-items: center;
  padding: clamp(20px, 5vw, 64px);
}
.home__bg { position: absolute; inset: 0; z-index: 0; pointer-events: none; }
.floatie {
  position: absolute;
  border: var(--line) solid var(--ink);
  border-radius: 22px;
  box-shadow: var(--shadow-sm);
  opacity: 0.9;
  animation: bob 7s ease-in-out infinite;
}
.floatie.f1 { width: 92px; height: 92px; background: var(--red);    top: 10%;  left: 8%;  transform: rotate(-12deg); }
.floatie.f2 { width: 64px; height: 64px; background: var(--yellow); top: 22%;  right: 12%; animation-delay: .6s; transform: rotate(10deg); }
.floatie.f3 { width: 120px;height: 120px;background: var(--blue);   bottom: 12%; left: 14%; animation-delay: 1.2s; }
.floatie.f4 { width: 72px; height: 72px; background: var(--green);  bottom: 18%; right: 10%; animation-delay: .3s; transform: rotate(-8deg); }
.floatie.f5 { width: 54px; height: 54px; background: var(--orange); top: 54%;  left: 46%; animation-delay: .9s; transform: rotate(16deg); }
@keyframes bob { 0%,100% { transform: translateY(0) rotate(var(--r,0)); } 50% { transform: translateY(-18px) rotate(var(--r,0)); } }

.home__inner {
  position: relative; z-index: 1;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  align-items: center;
  gap: clamp(24px, 5vw, 72px);
  max-width: 1120px;
  width: 100%;
}
.home__cube { display: grid; place-items: center; }
.home__copy { display: flex; flex-direction: column; align-items: flex-start; gap: 18px; }

.home__title {
  font-family: var(--font-black);
  font-size: clamp(38px, 6vw, 76px);
  line-height: 0.96;
  letter-spacing: -0.02em;
}
.home__lede { font-size: clamp(15px, 1.5vw, 19px); line-height: 1.5; max-width: 46ch; color: #33302a; }
.home__hint { font-size: 13px; font-weight: 700; color: var(--ink-soft); }

/* =========================================================
   BRAND
   ========================================================= */
.brand {
  display: inline-flex; align-items: center; gap: 12px;
  background: none; border: none; cursor: pointer; color: var(--ink);
}
.brand__dots { display: inline-flex; gap: 5px; }
.brand__dots i {
  width: 26px; height: 26px; border-radius: 8px;
  border: 3px solid var(--ink); display: block;
}
.brand__dots i:nth-child(1) { background: var(--red); }
.brand__dots i:nth-child(2) { background: var(--yellow); }
.brand__dots i:nth-child(3) { background: var(--blue); }
.brand__name { font-family: var(--font-black); font-size: 26px; letter-spacing: -0.01em; }
.brand--xl .brand__name { font-size: 30px; }
.brand--xl .brand__dots i { width: 30px; height: 30px; }

/* =========================================================
   BUTTONS
   ========================================================= */
.btn {
  font-family: var(--font-black);
  font-size: 17px;
  border: var(--line) solid var(--ink);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  padding: 14px 26px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform .08s ease, box-shadow .08s ease;
}
.btn:hover { transform: translate(-1px,-1px); box-shadow: 7px 7px 0 var(--ink); }
.btn:active { transform: translate(4px,4px); box-shadow: var(--shadow-press); }
.btn--yellow { background: var(--yellow); }
.btn--jumbo { font-size: clamp(18px, 2.2vw, 24px); padding: 18px 34px; }

.iconbtn {
  width: 46px; height: 46px; border-radius: 50%;
  border: var(--line) solid var(--ink);
  background: var(--paper); color: var(--ink);
  cursor: pointer; display: grid; place-items: center;
  box-shadow: var(--shadow-sm); font-weight: 800; font-size: 16px;
  transition: transform .08s ease, box-shadow .08s ease;
}
.iconbtn:active { transform: translate(3px,3px); box-shadow: var(--shadow-press); }
.iconbtn--gear { background: var(--orange); }

.minibtn {
  font-family: var(--font); font-weight: 800; font-size: 12px;
  border: 2.5px solid var(--ink); border-radius: 999px;
  background: var(--paper); color: var(--ink); cursor: pointer;
  padding: 5px 12px; box-shadow: var(--shadow-press);
}
.minibtn:active { transform: translate(2px,2px); box-shadow: none; }
.minibtn--ghost { border-color: rgba(0,0,0,.25); box-shadow: none; background: rgba(255,255,255,.6); }

/* =========================================================
   APP LAYOUT
   ========================================================= */
.app { padding: clamp(12px, 2vw, 22px); max-width: 1400px; margin: 0 auto; }

.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  background: var(--paper);
  border: var(--line) solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px 18px;
  margin-bottom: var(--gap);
}
.topbar .brand { justify-self: start; }
.topbar .iconbtn--gear { justify-self: end; }

.modeswitch {
  position: relative;
  justify-self: center;
  display: inline-flex;
  border: var(--line) solid var(--ink);
  border-radius: 999px;
  background: var(--paper);
  padding: 5px;
}
.modeswitch__btn {
  position: relative; z-index: 1;
  font-family: var(--font-black); font-size: 16px;
  border: none; background: none; cursor: pointer;
  padding: 9px 26px; border-radius: 999px; color: var(--ink-soft);
  transition: color .2s ease;
}
.modeswitch__btn.is-active { color: var(--ink); }
.modeswitch__thumb {
  position: absolute; top: 5px; bottom: 5px; left: 5px;
  width: calc(50% - 5px);
  background: var(--yellow);
  border: 3px solid var(--ink);
  border-radius: 999px;
  transition: transform .25s cubic-bezier(.3,1.4,.5,1);
  z-index: 0;
}
.modeswitch.is-practice .modeswitch__thumb { transform: translateX(100%); }

/* ---------- View grid ---------- */
.view {
  display: grid;
  grid-template-columns: 1fr 400px;
  gap: var(--gap);
  align-items: start;
}
.view__main { display: flex; flex-direction: column; gap: var(--gap); min-width: 0; }
.view__side { display: flex; flex-direction: column; gap: var(--gap); }

/* =========================================================
   CARDS
   ========================================================= */
.card {
  background: var(--paper);
  border: var(--line) solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card--notation { padding: 20px 24px; text-align: center; position: relative; }
.pill {
  display: inline-block;
  font-family: var(--font-black); font-size: 12px; letter-spacing: .06em;
  border: 3px solid var(--ink); border-radius: 999px; padding: 6px 16px;
  background: var(--paper);
}
.pill--yellow { background: var(--yellow); }
.pill--ghost { background: var(--paper); }

.notation {
  margin-top: 14px;
  font-family: var(--font-black);
  font-size: clamp(20px, 2.6vw, 30px);
  letter-spacing: .02em;
  display: flex; flex-wrap: wrap; gap: 8px 12px; justify-content: center;
}
.notation--big { font-size: clamp(20px, 3vw, 34px); }

.scramble-strip {
  font-family: var(--font); font-weight: 800;
  font-size: clamp(13px, 1.5vw, 17px);
  color: var(--ink-soft); letter-spacing: .04em;
  margin-top: 10px; word-spacing: 4px;
}
.card--notation #learnNewScramble { margin-top: 14px; }
.move-tok {
  padding: 2px 4px; border-radius: 8px; transition: background .15s ease, color .15s ease;
}
.move-tok.done { color: var(--ink-soft); }
.move-tok.active {
  background: var(--yellow);
  border: 2.5px solid var(--ink);
  padding: 2px 8px;
}

/* ---------- Stage ---------- */
.stage--blue { border-color: var(--ink); }
.card--stage { overflow: hidden; }
.stage {
  position: relative;
  margin: 8px;
  border: var(--line) solid var(--ink);
  border-radius: 20px;
  background: var(--blue);
  padding: 0;
}
.stage::before { /* inner yellow field */
  content: ""; position: absolute; inset: 10px; border-radius: 12px;
  background: radial-gradient(120% 120% at 50% 20%, #ffe36b, var(--yellow));
  border: 3px solid var(--ink);
}
.cube-scene--stage {
  position: relative; z-index: 1;
  height: clamp(300px, 42vh, 460px);
  display: grid; place-items: center;
}
.speedbtn {
  position: absolute; top: 22px; right: 22px; z-index: 3;
  font-family: var(--font-black); font-size: 14px;
  border: 3px solid var(--ink); border-radius: 12px; background: var(--paper);
  padding: 6px 12px; cursor: pointer; box-shadow: var(--shadow-press);
}
.speedbtn:active { transform: translate(2px,2px); box-shadow: none; }

.transport {
  position: absolute; z-index: 3; bottom: 20px; left: 50%; transform: translateX(-50%);
  display: inline-flex; gap: 10px; align-items: center;
  background: var(--paper); border: var(--line) solid var(--ink);
  border-radius: 999px; padding: 8px 14px; box-shadow: var(--shadow-sm);
}
.transport__btn {
  width: 44px; height: 44px; border-radius: 50%;
  border: 3px solid var(--ink); background: var(--paper); color: var(--ink);
  cursor: pointer; display: grid; place-items: center;
  transition: transform .08s ease;
}
.transport__btn:active { transform: scale(.92); }
.transport__btn--play { background: var(--green-play); color: var(--ink); }
.transport__btn:disabled { opacity: .4; cursor: not-allowed; }

.stage__caption { padding: 18px 20px 22px; text-align: center; }
.stage__eyebrow { font-family: var(--font-black); font-size: 13px; letter-spacing: .12em; color: var(--ink-soft); }
.stage__move {
  font-family: var(--font-black);
  font-size: clamp(34px, 5vw, 56px);
  line-height: 1; margin: 6px 0 10px; letter-spacing: .04em;
}
.stage__desc { font-size: 15px; font-weight: 600; color: #35322b; max-width: 52ch; margin: 0 auto; min-height: 2.6em; }

/* =========================================================
   SIDE PANELS
   ========================================================= */
.card--selector { background: var(--orange); padding: 16px; }
.segbar {
  position: relative; display: grid; grid-template-columns: 1fr 1fr;
  background: var(--paper); border: 3px solid var(--ink); border-radius: 999px;
  padding: 4px; margin-bottom: 14px;
}
.segbar__btn {
  position: relative; z-index: 1; font-family: var(--font-black); font-size: 15px;
  border: none; background: none; cursor: pointer; padding: 9px; border-radius: 999px;
  color: var(--ink-soft); transition: color .2s;
}
.segbar__btn.is-active { color: var(--ink); }
.segbar__thumb {
  position: absolute; z-index: 0; top: 4px; bottom: 4px; left: 4px; width: calc(50% - 4px);
  background: var(--yellow); border: 3px solid var(--ink); border-radius: 999px;
  transition: transform .25s cubic-bezier(.3,1.4,.5,1);
}
.segbar.is-right .segbar__thumb { transform: translateX(100%); }

.chipgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.chip {
  font-family: var(--font-black); font-size: 13.5px; letter-spacing: .02em;
  border: 3px solid var(--ink); border-radius: 999px; background: var(--paper);
  color: var(--ink); cursor: pointer; padding: 13px 8px; box-shadow: var(--shadow-press);
  transition: transform .08s ease, box-shadow .08s ease;
}
.chip:hover { transform: translate(-1px,-1px); }
.chip:active { transform: translate(2px,2px); box-shadow: none; }
.chip.is-active { background: var(--yellow); box-shadow: none; transform: translate(2px,2px); }

/* ---------- Steps ---------- */
.card--steps { background: var(--green); padding: 18px; display: flex; flex-direction: column; min-height: 320px; }
.steps__head {
  font-family: var(--font-black); font-size: 20px; color: var(--ink);
  background: var(--paper); border: 3px solid var(--ink); border-radius: 14px;
  padding: 12px 16px; margin-bottom: 14px; box-shadow: var(--shadow-press);
}
.steps__list { display: flex; flex-direction: column; gap: 12px; flex: 1; }
.step {
  display: flex; align-items: center; gap: 12px;
  font-family: var(--font-black); font-size: 15px;
  background: var(--paper); border: 3px solid var(--ink); border-radius: 14px;
  padding: 14px 16px; cursor: pointer; text-align: left; color: var(--ink);
  box-shadow: var(--shadow-press);
  transition: transform .08s ease, background .15s ease;
}
.step:hover { transform: translate(-1px,-1px); }
.step.is-done { color: var(--ink-soft); }
.step.is-active { background: var(--yellow); }
.step__ico { width: 22px; height: 22px; flex: none; display: grid; place-items: center; }
.step__ico svg { width: 22px; height: 22px; }
.step.is-active .step__ico svg { animation: spin 1.4s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.steps__progress { display: flex; gap: 8px; margin-top: 16px; }
.steps__progress i {
  flex: 1; height: 12px; border-radius: 999px;
  border: 2.5px solid var(--ink); background: var(--paper);
}
.steps__progress i.done { background: var(--ink); }
.steps__progress i.active { background: var(--yellow); }

/* =========================================================
   PRACTICE
   ========================================================= */
.card--timer {
  position: relative; overflow: hidden;
  background: var(--blue);
  min-height: clamp(340px, 52vh, 520px);
  display: grid; place-content: center; justify-items: center; gap: 8px;
  cursor: pointer; outline: none;
}
.card--timer.is-holding { background: var(--red); }
.card--timer.is-running { background: var(--green); }
.card--timer .floatie { position: absolute; opacity: .5; animation: none; box-shadow: none; }
.card--timer .tf1 { width: 120px; height: 120px; background: rgba(255,255,255,.18); border-color: rgba(0,0,0,.25); top: 12%; left: 8%; transform: rotate(-10deg); }
.card--timer .tf2 { width: 150px; height: 150px; background: rgba(0,0,0,.08); border-color: rgba(0,0,0,.25); bottom: 8%; right: 8%; transform: rotate(12deg); }

.timer__display {
  position: relative; z-index: 1;
  font-family: var(--font-black);
  font-size: clamp(64px, 13vw, 150px);
  line-height: 1; letter-spacing: -0.02em;
  background: var(--paper); color: var(--ink);
  border: var(--line) solid var(--ink); border-radius: 24px;
  padding: 18px 40px; box-shadow: var(--shadow);
  font-variant-numeric: tabular-nums;
}
.timer__state {
  position: relative; z-index: 1;
  font-family: var(--font-black); font-size: 16px; letter-spacing: .1em;
  background: var(--paper); border: 3px solid var(--ink); border-radius: 999px;
  padding: 8px 22px; margin-top: 12px;
}
.timer__hint { position: relative; z-index: 1; font-weight: 700; font-size: 13px; color: rgba(0,0,0,.6); margin-top: 4px; }

/* ---------- Stats / History ---------- */
.card--stats { background: var(--orange); padding: 16px; }
.panel__head {
  font-family: var(--font-black); font-size: 18px;
  background: var(--paper); border: 3px solid var(--ink); border-radius: 12px;
  padding: 10px 14px; margin-bottom: 12px; box-shadow: var(--shadow-press);
  display: flex; justify-content: space-between; align-items: center;
}
.statrow, .history__row {
  display: flex; justify-content: space-between; align-items: center;
  font-family: var(--font-black); font-size: 16px;
  background: var(--paper); border: 3px solid var(--ink); border-radius: 12px;
  padding: 12px 16px; margin-bottom: 10px;
}
.statrow span { color: var(--ink-soft); letter-spacing: .04em; text-transform: uppercase; font-size: 13px; }
.statrow b { font-size: 20px; }

.card--history { background: var(--green); padding: 16px; display: flex; flex-direction: column; }
.history__list { display: flex; flex-direction: column; gap: 8px; max-height: 320px; overflow-y: auto; }
.history__row span { color: var(--ink-soft); }
.history__row.is-best { background: var(--yellow); }
.history__empty { font-weight: 700; color: rgba(0,0,0,.55); text-align: center; padding: 24px 0; }

/* =========================================================
   SETTINGS SHEET
   ========================================================= */
.sheet { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; }
.sheet__backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.35); }
.sheet__panel { position: relative; z-index: 1; width: min(420px, 100%); padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.sheet__head { display: flex; justify-content: space-between; align-items: center; font-family: var(--font-black); font-size: 22px; }
.setting { display: flex; justify-content: space-between; align-items: center; font-weight: 800; border: 3px solid var(--ink); border-radius: 12px; padding: 12px 14px; }
.setting select { font-family: var(--font); font-weight: 800; border: 2.5px solid var(--ink); border-radius: 8px; padding: 5px 8px; }
.setting input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--green); }
.sheet__foot { text-align: center; font-size: 12px; color: var(--ink-soft); font-weight: 700; }

/* =========================================================
   3D CUBE
   ========================================================= */
.cube-scene { perspective: 900px; }
.cube-scene--hero { width: clamp(220px, 32vw, 320px); height: clamp(220px, 32vw, 320px); }
.cube {
  position: relative; width: 0; height: 0;
  transform-style: preserve-3d;
  transform: rotateX(-27deg) rotateY(-38deg);
}
.cubie { position: absolute; transform-style: preserve-3d; }
.sticker {
  position: absolute;
  border: 3.5px solid #14130f;
  border-radius: 8px;
  backface-visibility: hidden;
}
.face-body { position: absolute; background: #14130f; border-radius: 9px; }

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 980px) {
  .view { grid-template-columns: 1fr; }
  .view__side { flex-direction: column; }
  .home__inner { grid-template-columns: 1fr; text-align: center; }
  .home__copy { align-items: center; }
  .home__cube { order: -1; }
  .chipgrid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 620px) {
  :root { --gap: 14px; --radius: 20px; --shadow: 5px 5px 0 var(--ink); }
  .topbar { grid-template-columns: auto 1fr auto; padding: 10px 12px; }
  .brand__name { font-size: 20px; }
  .brand__dots i { width: 18px; height: 18px; }
  .modeswitch__btn { padding: 8px 16px; font-size: 14px; }
  .notation { font-size: 18px; }
  .stage__move { font-size: 36px; }
  .cube-scene--stage { height: 40vh; }
  .chip { font-size: 12px; padding: 12px 6px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; }
}
