:root {
  --bg-gradient: linear-gradient(135deg, #2a0845 0%, #6441ff 50%, #8e2de2 100%);
  --glass-bg: rgba(255, 255, 255, 0.14);
  --glass-border: rgba(255, 255, 255, 0.28);
  --text: #ffffff;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
  --accent: #ffb6ff;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0; height: 100%;
  font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text);
  overflow-x: hidden;
}

body {
  background: var(--bg-gradient);
  background-size: 300% 300%;
  animation: bgMove 18s ease infinite;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

@keyframes bgMove {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

#bg {
  position: fixed; inset: 0;
  background: radial-gradient(circle at 20% 20%, rgba(255,255,255,0.12) 0%, transparent 35%),
              radial-gradient(circle at 80% 80%, rgba(255,182,255,0.15) 0%, transparent 35%);
  pointer-events: none; z-index: 0;
}

main {
  position: relative; z-index: 1;
  max-width: 900px; margin: 0 auto;
  padding: 28px 20px 100px;
  min-height: 100vh;
}

header {
  display: flex; flex-wrap: wrap; gap: 18px;
  justify-content: space-between; align-items: center;
  margin-bottom: 28px;
}

.clock-card, .profile-card {
  background: var(--glass-bg);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--glass-border);
  border-radius: 26px;
  padding: 18px 24px;
  box-shadow: var(--shadow);
}

.clock-card { min-width: 160px; }
#clock { font-size: clamp(2.4rem, 9vw, 4.2rem); font-weight: 700; letter-spacing: -1px; line-height: 1; }
#date { font-size: 0.95rem; opacity: 0.9; margin-top: 6px; }

.profile-card { display: flex; align-items: center; gap: 14px; }
#avatar {
  width: 56px; height: 56px; border-radius: 50%;
  background: linear-gradient(135deg, #ffecd2, #fcb69f);
  display: grid; place-items: center; font-size: 2rem;
  box-shadow: 0 6px 18px rgba(0,0,0,0.2);
  border: 2px solid rgba(255,255,255,0.5);
}
#greeting { font-size: 1.05rem; font-weight: 600; }
#userName { color: var(--accent); }

h1 { font-size: 1.6rem; margin: 0 0 18px; text-shadow: 0 2px 8px rgba(0,0,0,0.2); }

.apps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 18px;
}

.app-tile {
  aspect-ratio: 1 / 1;
  border-radius: 26px;
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 10px; padding: 14px;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  text-decoration: none; color: var(--text);
  position: relative; overflow: hidden;
}

.app-tile::before {
  content: ''; position: absolute; inset: 0;
  background: var(--tile-accent, transparent);
  opacity: 0.08; pointer-events: none;
}

.app-tile:active { transform: scale(0.94); }
.app-tile:hover { transform: translateY(-4px); box-shadow: 0 18px 50px rgba(0,0,0,0.3); }

.app-tile img {
  width: 64%; height: 64%;
  object-fit: contain;
  filter: drop-shadow(0 4px 10px rgba(0,0,0,0.15));
}

.app-tile span {
  font-size: 0.9rem; font-weight: 600;
  text-align: center; text-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.fab {
  position: fixed;
  right: calc(22px + env(safe-area-inset-right));
  bottom: calc(22px + env(safe-area-inset-bottom));
  width: 62px; height: 62px; border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #ff9a9e, #fecfef);
  color: #6a1b9a; font-size: 2rem; font-weight: 700;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
  cursor: pointer; z-index: 10;
  display: grid; place-items: center;
  transition: transform 0.15s ease;
}
.fab:active { transform: scale(0.9); }

.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 20;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  opacity: 1; transition: opacity 0.2s ease;
}
.modal.hidden { display: none; }

.hidden { display: none; }
