:root {
  --page-background: #f4f7fb;
  --panel: #ffffff;
  --pattern-white: #ffffff; /* Matches the white edge pixels of the target cube PNG files. */
  --ink: #16233a;
  --muted: #6b778b;
  --line: #dfe7f2;
  --primary: #2369da;
  --primary-dark: #1754b6;
  --primary-soft: #edf4ff;
  --shadow: 0 18px 45px rgba(30, 56, 94, 0.12);
  --small-shadow: 0 7px 20px rgba(30, 56, 94, 0.08);
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(104, 163, 255, 0.15), transparent 31rem),
    radial-gradient(circle at bottom right, rgba(156, 207, 255, 0.16), transparent 29rem),
    var(--page-background);
  font-family: "Nunito Sans", Arial, sans-serif;
}

button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.app-shell {
  width: min(100% - 32px, 860px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 54px 0 28px;
}

.brand-header,
.panel-heading,
.game-meta,
.app-footer { text-align: center; }

.eyebrow,
.step-label,
.choice-card-topline,
.timer-label {
  margin: 0;
  color: var(--primary);
  font-family: "Montserrat", Arial, sans-serif;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.13em;
}

.brand-header h1,
.panel-heading h2,
.game-meta h2 {
  margin: 8px 0 0;
  font-family: "Montserrat", Arial, sans-serif;
  font-weight: 800;
  line-height: 1.16;
}

.brand-header h1 { font-size: clamp(1.9rem, 4vw, 2.8rem); }
.panel-heading h2,
.game-meta h2 { font-size: clamp(1.45rem, 3vw, 2rem); }

.brand-subtitle,
.panel-heading > p:not(.step-label),
.game-meta > p:not(.step-label) {
  max-width: 590px;
  margin: 13px auto 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.55;
}

.step-panel,
.game-screen {
  margin-top: 34px;
  padding: clamp(24px, 5vw, 42px);
  background: var(--panel);
  border: 1px solid rgba(214, 225, 240, 0.85);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.is-hidden { display: none !important; }

.choice-grid {
  display: grid;
  gap: 16px;
  margin-top: 28px;
}

.level-choice-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.size-choice-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.choice-input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.choice-card {
  position: relative;
  display: flex;
  min-height: 168px;
  padding: 23px 20px;
  overflow: hidden;
  color: var(--ink);
  cursor: pointer;
  background: #fbfcff;
  border: 2px solid var(--line);
  border-radius: 18px;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.choice-card:hover {
  transform: translateY(-3px);
  border-color: #aec8f4;
  box-shadow: var(--small-shadow);
}

.choice-card:focus-visible,
.choice-input:focus-visible + .choice-card {
  outline: 3px solid rgba(35, 105, 218, 0.32);
  outline-offset: 3px;
}

.choice-input:checked + .choice-card {
  background: var(--primary-soft);
  border-color: var(--primary);
  box-shadow: 0 10px 25px rgba(35, 105, 218, 0.16);
}

.choice-check {
  position: absolute;
  top: 14px;
  right: 14px;
  display: grid;
  width: 23px;
  height: 23px;
  place-items: center;
  color: transparent;
  font-size: 0.85rem;
  font-weight: 900;
  background: #ffffff;
  border: 1px solid #bfcbdb;
  border-radius: 50%;
}

.choice-input:checked + .choice-card .choice-check {
  color: #ffffff;
  background: var(--primary);
  border-color: var(--primary);
}

.level-card {
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  gap: 7px;
}

.level-card strong,
.size-card strong {
  font-family: "Montserrat", Arial, sans-serif;
  font-size: 1.15rem;
  font-weight: 800;
}

.level-card > span:last-child,
.size-card > span:last-child {
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.45;
}

.size-card {
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 224px;
  padding: 20px 14px;
  text-align: center;
}

.size-preview {
  display: block;
  width: min(100%, 104px);
  height: auto;
  margin: 0 auto 13px;
  object-fit: contain;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 12px 21px;
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  font-family: "Montserrat", Arial, sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  transition: transform 160ms ease, background 160ms ease, box-shadow 160ms ease, color 160ms ease;
}

.button:hover { transform: translateY(-2px); }
.button:focus-visible,
.text-button:focus-visible {
  outline: 3px solid rgba(35, 105, 218, 0.3);
  outline-offset: 3px;
}

.button-primary {
  color: #ffffff;
  background: var(--primary);
  box-shadow: 0 9px 18px rgba(35, 105, 218, 0.22);
}
.button-primary:hover { background: var(--primary-dark); }

.button-secondary {
  color: var(--primary-dark);
  background: #eef4fd;
}
.button-secondary:hover { background: #e1edfc; }

.button-wide {
  width: min(100%, 360px);
  margin: 25px auto 0;
}

.form-actions,
.game-actions,
.navigation-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
}

.form-actions { margin-top: 26px; }
.game-actions { margin-top: 20px; }
.navigation-actions { margin-top: 22px; }

.game-meta { margin-bottom: 21px; }

.pattern-card {
  display: flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  max-width: 100%;
  margin: 0 auto;
  padding: clamp(14px, 3vw, 26px);
  background: var(--pattern-white);
  border: 1px solid #e6ecf3;
  border-radius: 20px;
  box-shadow: 0 14px 30px rgba(30, 56, 94, 0.09);
}

/*
  Important game-design rule:
  - Only the complete pattern matrix is framed.
  - Individual cubes have zero gap, zero border, zero shadow, and zero rounded corners.
  - This white surface is #ffffff because the outer pixels in the supplied cube PNG files are #ffffff.
*/
.cube-matrix {
  display: grid;
  gap: 0;
  background: var(--pattern-white);
  line-height: 0;
}

.cube-cell {
  width: var(--cell-size);
  height: var(--cell-size);
  overflow: hidden;
  background: var(--pattern-white);
}

.cube-cell img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform-origin: center;
  transition: transform 180ms ease-in-out;
}

.timer-panel { margin-top: 22px; text-align: center; }
.timer-label { display: block; color: var(--muted); }

#timer {
  margin-top: 4px;
  color: var(--ink);
  font-family: "Montserrat", Arial, sans-serif;
  font-size: clamp(2rem, 6vw, 2.9rem);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

.text-button {
  padding: 4px;
  color: var(--muted);
  cursor: pointer;
  background: transparent;
  border: 0;
  font-family: "Nunito Sans", Arial, sans-serif;
  font-size: 0.92rem;
  font-weight: 700;
}
.text-button:hover { color: var(--primary-dark); }

.app-footer {
  margin-top: 28px;
  color: #7c889a;
  font-size: 0.82rem;
}

@media (max-width: 620px) {
  .app-shell { width: min(100% - 22px, 860px); padding-top: 31px; }
  .step-panel, .game-screen { margin-top: 25px; border-radius: 20px; }
  .level-choice-grid, .size-choice-grid { grid-template-columns: 1fr; }
  .choice-card { min-height: 142px; }
  .size-card { min-height: 158px; }
  .size-preview { width: 76px; margin-bottom: 8px; }
  .form-actions, .game-actions { flex-direction: column-reverse; }
  .form-actions .button, .game-actions .button { width: 100%; }
  .navigation-actions { flex-direction: column; gap: 8px; }
}
