* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
  background-color: #0f172a;
  color: #f8fafc;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 16px;
}

.game-container {
  width: 100%;
  max-width: 520px;
  text-align: center;
}

.profile-card {
  background: #1e293b;
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  border: 1px solid #334155;
}

.profile-auth {
  display: flex;
  align-items: center;
  gap: 6px;
}

.profile-auth label {
  font-size: 0.85rem;
  color: #94a3b8;
}

.profile-auth input {
  padding: 6px 10px;
  background: #0f172a;
  border: 1px solid #475569;
  color: #fff;
  border-radius: 6px;
  font-size: 0.85rem;
  outline: none;
}

.profile-auth input:focus {
  border-color: #38bdf8;
}

.profile-stats {
  display: flex;
  gap: 14px;
  font-size: 0.85rem;
  color: #94a3b8;
}

.profile-stats strong {
  color: #38bdf8;
}

.game-header {
  margin-bottom: 12px;
}

.stats-bar {
  display: flex;
  justify-content: space-around;
  background: #1e293b;
  padding: 10px 16px;
  border-radius: 8px;
  margin-bottom: 12px;
  font-weight: 600;
  font-size: 0.95rem;
  border: 1px solid #334155;
}

.stat-box span {
  color: #38bdf8;
}

.btn {
  background: #2563eb;
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s;
}

.btn:hover { background: #1d4ed8; }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }

/* 4x4 Grid Board */
.game-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-gap: 10px;
  background: #1e293b;
  padding: 12px;
  border-radius: 12px;
  perspective: 1000px;
  user-select: none;
  border: 1px solid #334155;
}

/* 3D Tile Structure */
.tile {
  aspect-ratio: 1 / 1;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
}

.tile.flipped {
  transform: rotateY(180deg);
}

.tile.matched {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease, visibility 0.35s ease;
}

.tile-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  border-radius: 8px;
  padding: 8px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
}

/* Front Face */
.tile-front {
  color: #ffffff;
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

/* Back Face */
.tile-back {
  background: #ffffff;
  color: #0f172a;
  font-size: 0.85rem;
  font-weight: 700;
  border: 2px solid #38bdf8;
  transform: rotateY(180deg);
  word-break: break-word;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: #1e293b;
  color: #fff;
  padding: 24px;
  border-radius: 12px;
  width: 90%;
  max-width: 320px;
  text-align: center;
  border: 1px solid #334155;
}

.modal-content h2 {
  margin-bottom: 12px;
  color: #38bdf8;
}

.modal-content p {
  margin-bottom: 8px;
  font-size: 0.95rem;
}