:root {
  --maxw: 1000px;

  --box: clamp(25px, 8vw, 70px);
  --box-font: clamp(1rem, 2.6vw, 1.6rem);

  --box-large: clamp(70px, 14vw, 110px);
  --box-large-font: clamp(1.3rem, 4vw, 2.4rem);

  --gap: 1rem;
  --panel: #171717;
  --text: #e5e7eb;
  --accent: #4f46e5;
}

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

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: radial-gradient(circle at top, #222 0%, #050505 60%);
  color: var(--text);
  min-height: 100vh;

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;

  padding-top: 3rem;
  overflow-x: hidden;
}

.app,
.infoSection {
  width: 100%;
  max-width: var(--maxw);
  padding: 1.25rem;
}

.infoSection {
  line-height: 1.5;
}

h1 {
  text-align: center;
  margin-bottom: 1.5rem;
  font-weight: 600;
}

.infoSection h2,
.infoSection h3,
h2 {
  padding-top: 1rem;
}

/* (behåller ditt beteende: p får bara padding i infoSection) */
.infoSection p {
  padding-top: 0.5rem;
}

.infoSection ul {
  padding-left: 1.25rem;
  margin-top: 0.5rem;
}

strong {
  font-weight: 600;
  color: #f9fafb;
}

.controls {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

label {
  font-size: 0.9rem;
  opacity: 0.9;
}

input[type="number"] {
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  border: 1px solid #555;
  background: #111;
  color: #f8f8f8;
  width: 120px;
}

button {
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  border: none;
  background: linear-gradient(135deg, #4f46e5, #6366f1);
  color: white;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5);
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
}

button:disabled {
  opacity: 0.3;
  cursor: default;
  box-shadow: none;
}

button:not(:disabled):hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.7);
}

.error {
  color: #f87171;
  text-align: center;
  min-height: 1.2em;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.primeCalc {
  border: 1px solid var(--text);
  background-color: var(--panel);
  border-radius: 20px;

  width: 100%;
  max-width: 100%;
  max-height: 70vh;

  padding: 1rem;

  overflow: auto; /* ersätter overflow-x + overflow-y */
}

/* Layer scene */
.scene {
  perspective: 1200px;
  margin-top: 1rem;
  min-height: 220px;
}

.layers {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: start;
}

.layer-row {
  display: flex;
  justify-content: center;
  gap: var(--gap);

  transform-style: preserve-3d;
  transform: rotateX(16deg) rotateY(-12deg) translateY(10px);

  animation: popInRow 0.3s ease-out;
}

.layer-row:not(:first-child) {
  margin-top: -15px;
  opacity: 0.95;
}

.number-box {
  position: relative;

  min-width: var(--box);
  min-height: var(--box);
  font-size: var(--box-font);

  padding: 0.6rem;
  border-radius: 14px;

  background: radial-gradient(
    circle at 10% 0%,
    #4f46e5 0%,
    #111827 55%,
    #020617 100%
  );
  box-shadow: 0 18px 35px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(148, 163, 184, 0.3);

  display: flex;
  align-items: center;
  justify-content: center;

  font-weight: 600;
  color: var(--text);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);

  transform-style: preserve-3d;
  animation: popIn 0.3s ease-out;
}

.number-box.large {
  min-width: var(--box-large);
  min-height: var(--box-large);
  font-size: var(--box-large-font);
}

.number-box::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(
    145deg,
    rgba(255, 255, 255, 0.22),
    transparent 40%
  );
  mix-blend-mode: screen;
  opacity: 0.7;
  pointer-events: none;
  transform: translateZ(1px);
}

.primeNumber {
  background: radial-gradient(
    circle at 10% 0%,
    #7a5c1e 0%,
    #c9a23f 45%,
    #f1d27a 60%,
    #a8832b 100%
  );
  border: 1px solid rgba(255, 220, 120, 0.35);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25),
    inset 0 -1px 0 rgba(0, 0, 0, 0.25), 0 2px 6px rgba(0, 0, 0, 0.5);
}

.equation {
  margin-top: 1.2rem;
  text-align: center;
  font-size: 1rem;
  opacity: 0.9;
  min-height: 1.3em;
}

.step-info {
  margin-top: 0.4rem;
  text-align: center;
  font-size: 0.9rem;
  opacity: 0.7;
  min-height: 1.2em;
}

.footer {
  position: static;
  margin-top: 1.5rem;

  width: 100%;
  text-align: center;
  padding: 1rem;

  display: flex;
  justify-content: center;
  gap: 0.5rem;
  flex-direction: column;

  font-size: smaller;
}

/* konsoliderar a + .footer a (samma regler) */
a {
  color: white;
  text-decoration: none;
}
a:hover {
  color: var(--accent);
}

/* Om du verkligen vill behålla "ingen färgändring" i button-länkar: */
button a:hover {
  color: inherit;
}

.privacyBackButton {
  border: 3px solid var(--accent);
  padding: 0.5rem;
  border-radius: 12%;
}

/* Animations */
@keyframes popIn {
  from {
    transform: translateY(12px) scale(0.85);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

@keyframes popInRow {
  from {
    transform: rotateX(16deg) rotateY(-12deg) translateY(40px);
    opacity: 0;
  }
  to {
    transform: rotateX(16deg) rotateY(-12deg) translateY(10px);
    opacity: 1;
  }
}

/* Desktop tweaks */
@media (min-width: 900px) {
  .app,
  .infoSection {
    padding: 2rem;
  }
  .layers {
    align-items: center;
  }
}

/* Phone tweaks */
@media (max-width: 600px) {
  h1 {
    font-size: 1.4rem;
    margin-bottom: 1rem;
  }

  .controls {
    flex-direction: column;
    align-items: stretch;
    gap: 0.6rem;
  }

  input[type="number"],
  button {
    width: 100%;
  }

  .scene {
    min-height: 180px;
    perspective: 800px;
  }

  .layer-row {
    gap: 0.6rem;
    transform: rotateX(10deg) rotateY(-6deg) translateY(6px);
  }
}

/* Stoppa iOS zoom-on-focus */
@media (max-width: 900px) {
  input,
  select,
  textarea {
    font-size: 16px;
  }
}
