/* ==============================
   GLOBAL
============================== */
html, body {
  margin: 0;
  padding: 0;
  font-family: 'Segoe UI', Roboto, Arial, sans-serif;
  background: #e2e8f0;
  color: #0f172a;
}

button, select, input {
  font-family: inherit;
  font-size: 1rem;
}

/* ==============================
   HEADER / NAVIGATION
============================== */
.topbar {
  background: #0f172a;
  color: #f8fafc;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.topbar h1 {
  margin: 0;
  font-size: 1.4rem;
}

.navUser {
  display: flex;
  align-items: center;
  gap: 10px;
}

.navUser span {
  font-size: 0.95rem;
}

.navUser button {
  background: #1e3a8a;
  border: none;
  color: #fff;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
}

.navUser button:hover {
  background: #2563eb;
}
/* ==============================
   TIMER IN NAVBAR
============================== */
.navCenter {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
}

#navbar-timer {
  font-size: 1.1rem;
  font-weight: 600;
  color: #FFD700; /* Gold */
  text-shadow: 0 0 4px rgba(0,0,0,0.4);
}

#timer {
  color: #FFD700;
}

/* ==============================
   MAIN LAYOUT
============================== */
.boardWrapDrag {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.2rem;
  padding: 1.5rem;
}

.boardArea,
.piecesArea {
  background: #f8fafc;
  border-radius: 10px;
  padding: 15px;
  box-shadow: 0 0 8px rgba(0,0,0,0.1);
}

/* ==============================
   CONTROLS
============================== */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 10px;
  transition: opacity 0.3s ease;
}

.controls label {
  font-weight: 600;
  margin-right: 5px;
}

.controls select,
.controls button {
  padding: 6px 10px;
  border: 1px solid #94a3b8;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}

.controls select:disabled,
.controls button:disabled {
  background: #e5e7eb;
  cursor: not-allowed;
  opacity: 0.7;
}

.controls button {
  background: #1e40af;
  color: white;
  border: none;
}

.controls button:hover:not(:disabled) {
  background: #2563eb;
}

/* ==============================
   TIMER
============================== */
#timer {
  color: #fff;
  font-weight: bold;
  margin-left: auto;
}

/* ==============================
   PUZZLE VORSCHAU
============================== */
.previewBox {
  text-align: center;
  margin-bottom: 10px;
}

#previewImg {
  max-width: 160px;
  max-height: 100px;
  border-radius: 6px;
  border: 1px solid #94a3b8;
  box-shadow: 0 0 4px rgba(0,0,0,0.2);
}

@media (max-width: 600px) {
  #previewImg {
    max-width: 120px;
    max-height: 80px;
  }
}

/* ==============================
   PUZZLE FELD / RASTER
============================== */
#board {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 2px;
  background: #cbd5e1;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: inset 0 0 8px rgba(0,0,0,0.2);
  margin: 0 auto;
}

.slot {
  background: rgba(255,255,255,0.3);
  border: 1px dashed rgba(15,23,42,0.2);
  border-radius: 3px;
  width: 100%;
  height: 100%;
  position: relative;
  transition: background 0.2s ease;
}

.slot.over {
  background: rgba(59,130,246,0.2);
  outline: 2px dashed #3b82f6;
  outline-offset: -3px;
}

/* ==============================
   PUZZLE TEILE
============================== */
#pieces {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-content: flex-start;
  gap: 8px;
  min-height: 320px;
  background: #e2e8f0;
  border-radius: 8px;
  padding: 10px;
  box-shadow: inset 0 0 6px rgba(0,0,0,0.1);
}

.piece {
  border: 1px solid #1f2937;
  border-radius: 4px;
  cursor: grab;
  transition: transform 0.25s ease, left 0.25s ease, top 0.25s ease;
  touch-action: none;
  background-repeat: no-repeat;
}

.piece.dragging {
  opacity: 0.85;
  transform: scale(1.05);
  z-index: 10;
}

#finishMsg {
  font-weight: bold;
  color: #059669;
  margin-top: 10px;
}

#statusMsg {
  color: #374151;
  margin-top: 5px;
}

/* ==============================
   MODAL BOXEN (Login / Register / Forgot)
============================== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  animation: fadeIn 0.3s ease forwards;
}

.modal.hidden {
  display: none;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.auth-container {
  background: #f8fafc;
  color: #0f172a;
  border-radius: 12px;
  padding: 25px 30px;
  width: 340px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.3);
  animation: scaleIn 0.25s ease-out forwards;
}

@keyframes scaleIn {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.auth-header {
  text-align: center;
  margin-bottom: 15px;
}

.auth-header h2 {
  margin: 0;
  font-size: 1.3rem;
  color: #1e3a8a;
}

.auth-form {
  display: none;
  flex-direction: column;
  transition: opacity 0.25s ease;
}

.auth-form.active {
  display: flex;
}

.auth-form input {
  margin-bottom: 10px;
  padding: 10px;
  border: 1px solid #94a3b8;
  border-radius: 6px;
  font-size: 0.95rem;
  transition: border-color 0.2s ease;
}

.auth-form input:focus {
  border-color: #2563eb;
  outline: none;
}

.auth-form button {
  background: #1e40af;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 10px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.2s ease;
}

.auth-form button:hover {
  background: #2563eb;
}

.auth-alt {
  text-align: center;
  font-size: 0.9rem;
}

.auth-alt a {
  color: #1d4ed8;
  text-decoration: none;
}

.auth-alt a:hover {
  text-decoration: underline;
}

#authMsg {
  color: #b91c1c;
  font-size: 0.9rem;
  text-align: center;
  margin-top: 8px;
}

/* Responsive Modal */
@media (max-width: 500px) {
  .auth-container {
    width: 90%;
    padding: 20px;
  }
}

/* ==============================
   RESPONSIVE DESIGN
============================== */

/* Tablets */
@media (max-width: 900px) {
  .boardWrapDrag {
    grid-template-columns: 1fr;
    gap: 0.8rem;
    padding: 1rem;
  }

  #board {
    width: 95%;
    min-height: 50vw;
  }

  #pieces {
    min-height: 45vw;
    gap: 5px;
    padding: 6px;
  }

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

  .controls select,
  .controls button {
    font-size: 0.9rem;
    padding: 5px 8px;
  }

  #timer {
    font-size: 0.9rem;
  }
}

/* Smartphones */
@media (max-width: 600px) {
  body {
    font-size: 0.9rem;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.4rem;
    padding: 8px 12px;
  }

  .navUser {
    width: 100%;
    justify-content: space-between;
  }

  .boardWrapDrag {
    padding: 0.8rem;
  }

  #board {
    width: 100%;
    min-height: 70vw;
  }

  #pieces {
    min-height: 55vw;
    gap: 4px;
  }

  .piece {
    transform: scale(0.9);
  }

  .controls label {
    font-size: 0.85rem;
  }

  .controls select,
  .controls button {
    font-size: 0.85rem;
    padding: 4px 6px;
  }

  #timer {
    font-size: 0.85rem;
  }
}


/* ==============================
   FEEDBACK TOOLTIP
============================== */
#authMsg {
  font-size: 0.9rem;
  text-align: center;
  margin-top: 8px;
  border-radius: 6px;
  padding: 8px 10px;
  opacity: 0;
  transition: opacity 0.4s ease;
}

#authMsg.show {
  opacity: 1;
}

#authMsg.success {
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #10b981;
}

#authMsg.error {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #dc2626;
}


/* ==============================
   GAME-END TOOLTIP
============================== */
#gameToast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #10b981;
  color: white;
  padding: 10px 20px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  font-weight: 600;
  z-index: 2000;
  opacity: 0;
  transition: opacity 0.5s ease, transform 0.5s ease;
}

#gameToast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(5px);
}
