html {
  overflow: hidden;
  height: 100%;
}

body {
  margin: 0;
  font-family: system-ui, sans-serif;
  background: #1e1e1e;
  color: white;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  touch-action: manipulation;
}

#game-bar {
  padding: 0.6rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#back-btn {
  background: none;
  border: none;
  color: #5a9a5a;
  font-size: 1rem;
  cursor: pointer;
  padding: 0;
}

#scoreboard {
  text-align: center;
  font-size: 1.1rem;
  opacity: 0.85;
}

main {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* --- Korttrave --- */

.card-stack {
  position: relative;
  width: 85vw;
  max-width: 320px;
  padding-top: 18px;
}

/* Bakre kort */
.card-stack::before {
  content: '';
  position: absolute;
  top: 0;
  left: 14px;
  right: 14px;
  height: 200px;
  background: #202220;
  border-radius: 14px;
  z-index: 0;
}

/* Mellersta kort */
.card-stack::after {
  content: '';
  position: absolute;
  top: 8px;
  left: 7px;
  right: 7px;
  height: 200px;
  background: #252725;
  border-radius: 15px;
  z-index: 1;
}

.card {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 200px;
  perspective: 1000px;
  touch-action: none;
  user-select: none;
}

.card-inner {
  width: 100%;
  height: 100%;
  background: #2a2a2a;
  border-radius: 16px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.5rem;
  text-align: center;
  transition: transform 0.3s ease;
  transform-style: preserve-3d;
}

.card.flipped .card-inner {
  transform: rotateY(180deg);
}

.card-front,
.card-back {
  position: absolute;
  backface-visibility: hidden;
  padding: 1rem;
}

.card-back {
  transform: rotateY(180deg);
  opacity: 0.8;
}

footer {
  padding: 1rem;
  text-align: center;
  font-size: 0.9rem;
  opacity: 0.7;
}

/* Snap-back när man släpper utan att ha svept tillräckligt */
.card.snapping {
  transition: transform 0.25s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* --- Kortanimationer --- */

@keyframes fly-out-right {
  from { transform: translateX(0) rotate(0deg);    opacity: 1; }
  to   { transform: translateX(140%) rotate(8deg); opacity: 0; }
}
@keyframes fly-out-left {
  from { transform: translateX(0) rotate(0deg);     opacity: 1; }
  to   { transform: translateX(-140%) rotate(-8deg); opacity: 0; }
}
@keyframes fly-out-up {
  from { transform: translateY(0)    scale(1);    opacity: 1; }
  to   { transform: translateY(-130%) scale(0.9); opacity: 0; }
}
@keyframes card-emerge {
  from { transform: scale(0.88) translateY(8px); opacity: 0.3; }
  to   { transform: scale(1)    translateY(0);   opacity: 1; }
}
@keyframes undo-out {
  from { transform: scale(1)    translateY(0);   opacity: 1; }
  to   { transform: scale(0.88) translateY(8px); opacity: 0; }
}
@keyframes undo-in {
  from { transform: translateX(-60%) scale(0.9); opacity: 0; }
  to   { transform: translateX(0)    scale(1);   opacity: 1; }
}

.card.fly-out-right  { animation: fly-out-right 0.22s ease forwards; }
.card.fly-out-left   { animation: fly-out-left  0.22s ease forwards; }
.card.fly-out-up     { animation: fly-out-up    0.22s ease forwards; }
.card.card-emerge    { animation: card-emerge   0.28s ease forwards; }
.card.undo-out       { animation: undo-out      0.18s ease forwards; }
.card.undo-in        { animation: undo-in       0.28s ease forwards; }

/* --- Swipe-feedback --- */

#swipe-feedback {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(1);
  font-size: 5rem;
  pointer-events: none;
  opacity: 0;
  z-index: 100;
}

#swipe-feedback.show {
  animation: feedback-pop 0.6s ease forwards;
}

@keyframes feedback-pop {
  0%   { opacity: 1; transform: translate(-50%, -50%) scale(1.6); }
  50%  { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
}

/* --- Lektionsväljare --- */

#lesson-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 2rem;
  height: 100%;
  box-sizing: border-box;
}

#lesson-screen h1 {
  font-size: 2rem;
  margin: 0;
}

.lesson-subtitle {
  opacity: 0.7;
  margin: 0;
}

.lesson-rows {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
  max-width: 320px;
}

.lesson-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem 0.8rem;
  border-radius: 12px;
  border: 2px solid #444;
  background: #2a2a2a;
  color: #aaa;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  user-select: none;
}

.lesson-row.active {
  background: #2d4a2d;
  color: white;
  border-color: #5a9a5a;
}

.all-row {
  font-weight: bold;
  margin-bottom: 0.2rem;
}

.lesson-check {
  font-size: 1rem;
  width: 1.4rem;
  text-align: center;
  opacity: 0.4;
  flex-shrink: 0;
}

.lesson-row.active .lesson-check {
  opacity: 1;
}

.lesson-label {
  flex: 1;
  font-size: 0.95rem;
}

.lesson-view {
  background: none;
  border: none;
  color: inherit;
  font-size: 1.3rem;
  padding: 0 0.2rem;
  cursor: pointer;
  opacity: 0.5;
  flex-shrink: 0;
  line-height: 1;
}

.lesson-row.active .lesson-view {
  opacity: 0.8;
}

#start-btn {
  padding: 1rem 2rem;
  border-radius: 14px;
  border: none;
  background: #5a9a5a;
  color: white;
  font-size: 1.1rem;
  font-weight: bold;
  width: 100%;
  max-width: 320px;
  cursor: pointer;
  margin-top: 0.5rem;
}

#change-lesson-btn {
  display: block;
  margin-top: 0.4rem;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: underline;
}

/* --- Grattis-skärm --- */

#congrats-screen {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.2rem;
  height: 100%;
  text-align: center;
  padding: 2rem;
  box-sizing: border-box;
}

.congrats-emoji {
  font-size: 5rem;
}

.congrats-title {
  margin: 0;
  font-size: 1.8rem;
}

.congrats-sub {
  margin: 0;
  opacity: 0.7;
}

#congrats-done-btn {
  padding: 1rem 2.5rem;
  border-radius: 14px;
  border: none;
  background: #5a9a5a;
  color: white;
  font-size: 1.1rem;
  font-weight: bold;
  cursor: pointer;
  margin-top: 0.5rem;
}

/* --- Ordlistevy --- */

#word-list-screen {
  display: none;
  flex-direction: column;
  height: 100%;
  box-sizing: border-box;
}

#word-list-header {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 1rem;
  border-bottom: 1px solid #333;
  flex-shrink: 0;
}

#word-list-back {
  background: none;
  border: none;
  color: #5a9a5a;
  font-size: 1rem;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}

#word-list-title {
  margin: 0;
  font-size: 1rem;
  font-weight: normal;
  opacity: 0.85;
}

#word-list-body {
  overflow-y: auto;
  flex: 1;
  padding: 0.5rem 1rem 1rem;
}

.word-row {
  display: flex;
  justify-content: space-between;
  padding: 0.7rem 0;
  border-bottom: 1px solid #2a2a2a;
  font-size: 0.95rem;
}

.word-sv {
  color: white;
}

.word-de {
  color: #aaa;
  text-align: right;
}
