.omni-memory-board {
  display: grid;
  /* Osobne zmienne na odstępy w osi X i Y */
  grid-template-columns: repeat(
    var(--omni-cols, 3),
    calc((100% - (var(--omni-cols,3) + 1) * var(--omni-gap-x, 1%)) / var(--omni-cols, 3))
  );
  column-gap: var(--omni-gap-x, 1%);
  row-gap: var(--omni-gap-y, var(--omni-gap-x, 1%));
  padding-left: var(--omni-gap-x, 1%);
  padding-right: var(--omni-gap-x, 1%);
  padding-top: var(--omni-gap-y, var(--omni-gap-x, 1%));
  padding-bottom: var(--omni-gap-y, var(--omni-gap-x, 1%));
  margin: 20px auto;
  width: 100%;
  user-select: none;
}
.omni-memory-card {
  background: var(--omni-memory-card, #c7e3bf);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2em;
  cursor: pointer;
  border-radius: 12px;
  transition: background 0.3s, box-shadow 0.3s, border-color 0.3s;
  user-select: none;
  position: relative;
  box-sizing: border-box;
  border: 2px solid var(--omni-memory-card, #c7e3bf);
  perspective: 800px;
  padding: 0;
  aspect-ratio: 1/1;
  min-width: 0;
  min-height: 0;
  max-width: none;
  max-height: none;
  box-shadow: none;
  overflow: hidden;
}
.omni-memory-card:hover {
  box-shadow: 0 4px 16px #457b9d55;
  border-color: #457b9d;
}
.omni-memory-card.flipped {
  background: #ffe066;
  border-color: #457b9d;
  box-shadow: 0 4px 20px #ffe06699;
}
.omni-memory-card.flipped {
  background: #ffe066;
  border-color: #457b9d;
}
.omni-memory-card-inner {
  position: absolute;
  top:0;left:0;width:100%;height:100%;
  transform-style: preserve-3d;
  transition: transform 0.5s cubic-bezier(.4,2,.6,1);
  will-change: transform;
}
.omni-memory-card.flipped .omni-memory-card-inner {
  transform: rotateY(180deg);
}
.omni-memory-card-front, .omni-memory-card-back {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2em;
  border-radius: 12px;
  transition: background 0.3s, color 0.3s;
  overflow: hidden;
}
.omni-memory-card-front {
  background: #fff;
  color: #222;
  transform: rotateY(180deg);
  z-index: 2;
  width: 100%;
  height: 100%;
  margin: 0;
  font-size: clamp(1rem, calc(11.5vw / var(--omni-cols, 4)), 2.4rem);
  line-height: 1.15;
  justify-content: center;
  align-items: center;
  display: flex;
  box-shadow: 0 2px 8px #ffe06633;
  text-align: center;
  word-break: break-word;
  hyphens: auto;
  padding: 3%;
}
/* Keep front rotated 180deg; when parent flips 180deg it becomes visible */
.omni-memory-card.flipped .omni-memory-card-front { transform: rotateY(180deg); }
.omni-memory-card-back {
  background: var(--omni-memory-card, #c7e3bf);
  color: var(--omni-memory-card, #c7e3bf);
  transform: rotateY(0deg);
  z-index: 1;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.omni-memory-card-front img {
  max-width: 100%;
  max-height: 100%;
  display: block;
  margin: auto;
  padding: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 10px;
}
.omni-memory-card[disabled], .omni-memory-card-matched {
  opacity: .5;
  pointer-events: none;
  background: #d1ffd1;
}

.omni-memory-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 520px;
  margin: 0 auto 12px auto;
  padding: 8px 18px 8px 18px;
  background: #f5f5f5;
  border-radius: 10px 10px 0 0;
  box-shadow: 0 2px 8px #eee;
}
.omni-memory-timer {
  font-size: 1.3em;
  font-weight: 500;
  color: #457b9d;
  letter-spacing: 1px;
}
.omni-memory-game-container {
  background: #fff !important;
}

.omni-memory-popup {
  position: fixed;
  left: 0; top: 0; width: 100vw; height: 100vh;
  z-index: 9999;
  background: rgba(0,0,0,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .4s;
}
.omni-memory-popup.show {
  opacity: 1;
  pointer-events: all;
}
.omni-memory-popup-inner {
  position: relative;
  z-index: 2;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 6px 32px #2222;
  padding: 38px 36px 28px 36px;
  min-width: 280px;
  max-width: 95vw;
  text-align: center;
  animation: omni-popup-in .5s cubic-bezier(.6,2,.4,1);
}
@keyframes omni-popup-in {
  0% { transform: scale(.8) translateY(40px); opacity:0; }
  100% { transform: scale(1) translateY(0); opacity:1; }
}
.omni-memory-popup-title {
  font-size: 2.1em;
  font-weight: bold;
  color: #4f883d;
  margin-bottom: 10px;
}
.omni-memory-popup-text {
  font-size: 1.15em;
  margin-bottom: 22px;
  color: #333;
}
.omni-memory-popup-btn {
  background: #4f883d;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 9px 32px;
  font-size: 1.1em;
  cursor: pointer;
  box-shadow: 0 1px 4px #4f883d33;
  transition: background .2s;
}

.omni-memory-popup-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.omni-memory-popup-btn--outline {
  background: #fff;
  color: #4f883d;
  border: 2px solid #4f883d;
  box-shadow: none;
}

.omni-memory-popup-btn--outline:hover {
  background: #f1f5f9;
}
.omni-memory-popup-btn:hover {
  background: #6bb94a;
}
.omni-memory-confetti {
  position: fixed;
  left: 0; top: 0; width: 100vw; height: 100vh;
  z-index: 1;
  pointer-events: none;
  display: block;
}

/* Increase text size and wrap long words in fullscreen */
#omni-game.omni-fullscreen .omni-memory-card-front {
  /* Larger font when in fullscreen; tweak clamp to your liking */
  font-size: clamp(1.4rem, calc(24vw / var(--omni-cols, 4)), 3.4rem);
  line-height: 1.2;
  /* Better long-word breaking */
  overflow-wrap: anywhere;
  word-break: break-word;
  hyphens: auto;
}

@media (max-width: 600px) {
  .omni-memory-card {
    font-size: 1em;
  }
  .omni-memory-card-front, .omni-memory-card-back {
    font-size: 1em;
  }
}

/* Save result section (Memory) */
.omni-save-result-section {
  max-width: 400px;
  margin: 18px auto 0;
  padding: 20px;
  background: #fdfdfd;
  border: 1px solid #eee;
  border-radius: 12px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.05);
  text-align: center;
}

.omni-save-checkbox-label {
  display: block;
  cursor: pointer;
  font-size: 1.1em;
  font-weight: 600;
  color: #4f883d;
}

.omni-save-checkbox-label input {
  margin-right: 8px;
  transform: scale(1.2);
  vertical-align: middle;
}

.omni-learner-name-field {
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid #e0e0e0;
}

.omni-learner-name-field > label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: #555;
  margin-bottom: 8px;
  text-align: center;
}

.omni-learner-name-input {
  width: 100%;
  padding: 18px 20px;
  font-size: 16px;
  line-height: 1.45;
  border: 1px solid #ddd;
  border-radius: 8px;
  box-sizing: border-box;
  transition: border-color 0.2s, box-shadow 0.2s;
  min-height: 54px;
}

.omni-learner-name-input:focus {
  outline: none;
  border-color: #4f883d;
  box-shadow: 0 0 0 3px rgba(79, 136, 61, 0.15);
}

.omni-learner-name-input:read-only,
.omni-learner-name-input:disabled {
  background: #f0f0f0;
  cursor: not-allowed;
}

.omni-save-result-btn {
  display: block;
  width: 100%;
  padding: 14px 24px;
  margin: 8px 0 12px;
  background: linear-gradient(135deg, #4f883d 0%, #3e6c31 100%);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1.1em;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.omni-save-result-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(79, 136, 61, 0.3);
}

.omni-save-result-btn.saved {
  background-color: #4f883d !important;
  cursor: default;
}

.omni-save-result-btn:disabled {
  opacity: 0.7;
}

.omni-privacy-note {
  margin: 0 0 10px;
  font-size: 12px;
  color: #1e1e1e;
  font-style: italic;
  text-align: center;
}

.omni-save-result-message {
  margin-top: 15px;
  padding: 12px 16px;
  border-radius: 6px;
  font-size: 0.9em;
  font-weight: 500;
  text-align: center;
}

.omni-save-result-message.success {
  background: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.omni-save-result-message.error {
  background: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

@media (max-width: 600px) {
  .omni-save-result-section {
    max-width: 100%;
    padding: 15px;
  }
}
