:root {
  --bg-start: #f8fafc;
  --bg-end: #e2e8f0;
  --surface: rgba(255, 255, 255, 0.78);
  --surface-border: rgba(148, 163, 184, 0.35);
  --text-main: #0f172a;
  --text-muted: #475569;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --danger: #dc2626;
  --shadow-soft: 0 20px 40px rgba(15, 23, 42, 0.14);
  --shadow-strong: 0 14px 30px rgba(37, 99, 235, 0.32);
  --radius-lg: 22px;
  --radius-md: 14px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  padding: clamp(18px, 4vw, 40px);
  font-family: 'Segoe UI', 'Inter', 'SF Pro Text', Arial, sans-serif;
  color: var(--text-main);
  background:
    radial-gradient(circle at 10% 0%, rgba(59, 130, 246, 0.2), transparent 32%),
    radial-gradient(circle at 90% 100%, rgba(244, 114, 182, 0.24), transparent 34%),
    linear-gradient(145deg, var(--bg-start), var(--bg-end));
  display: grid;
  place-items: center;
}

#loginSection,
#appSection {
  width: min(100%, 620px);
  background: var(--surface);
  border: 1px solid var(--surface-border);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: clamp(20px, 3.4vw, 34px);
  animation: fade-in 450ms ease both;
}

#appSection {
  text-align: center;
}

#loginSection h2 {
  margin: 0 0 14px;
  color: #7c3aed;
  font-size: clamp(1.25rem, 2.4vw, 1.7rem);
}

#username {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-size: 1rem;
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.95);
  outline: none;
  transition:
    border-color 0.18s ease,
    box-shadow 0.18s ease;
}

#username:focus {
  border-color: #60a5fa;
  box-shadow: 0 0 0 4px rgba(96, 165, 250, 0.2);
}

h1 {
  margin: 0 0 40px;
}

h3 {
  margin: 0 0 10px;
}

h1 {
  font-size: clamp(1.4rem, 3vw, 2rem);
}

h3 {
  margin-top: 28px;
  color: var(--text-muted);
  font-size: 1rem;
  font-weight: 600;
}

button {
  appearance: none;
  border: 0;
  border-radius: 9px;
  padding: 11px 18px;
  font-size: 0.98rem;
  font-weight: 600;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(120deg, var(--accent), var(--accent-strong));
  box-shadow: var(--shadow-strong);
  transition:
    transform 0.14s ease,
    box-shadow 0.14s ease,
    filter 0.14s ease;
}

button:hover {
  transform: translateY(-1px);
  filter: brightness(1.04);
}

button:active {
  transform: translateY(0);
}

button:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  box-shadow: none;
}

#loginBtn {
  margin-top: 14px;
}

#spinBtn {
  display: block;
  margin: 32px auto 0;
  min-width: 220px;
}

#logoutBtn {
  background: linear-gradient(120deg, #ef4444, var(--danger));
  box-shadow: 0 14px 30px rgba(220, 38, 38, 0.28);
}

.actions {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.wheel {
  width: clamp(210px, 36vw, 290px);
  aspect-ratio: 1 / 1;
  margin: 0;
  border-radius: 50%;
  border: 10px solid #fff;
  background: conic-gradient(
    #facc15 0% 16.66%,
    #fb923c 16.66% 33.32%,
    #f97316 33.32% 49.98%,
    #ef4444 49.98% 66.64%,
    #dc2626 66.64% 83.3%,
    #64748b 83.3% 100%
  );
  box-shadow:
    inset 0 0 0 2px rgba(15, 23, 42, 0.25),
    0 20px 40px rgba(15, 23, 42, 0.22);
  transition: transform 4s cubic-bezier(0.33, 1, 0.68, 1);
  position: relative;
}

.wheel-wrap {
  width: fit-content;
  margin: 22px auto 6px;
  position: relative;
}

.wheel-wrap::before {
  content: '';
  position: absolute;
  left: 50%;
  top: -20px;
  transform: translateX(-50%);
  border-left: 14px solid transparent;
  border-right: 14px solid transparent;
  border-top: 24px solid #0f172a;
  filter: drop-shadow(0 6px 6px rgba(15, 23, 42, 0.25));
  z-index: 2;
  pointer-events: none;
}

.wheel::after {
  content: '';
  position: absolute;
  inset: 50%;
  width: 22px;
  height: 22px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: #0f172a;
  box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.9);
}

.color-blue {
  color: var(--accent);
}

#result {
  margin-top: 14px;
  text-align: center;
  min-height: 24px;
  color: #1e40af;
  font-size: 1.03rem;
  font-weight: 700;
}

#historyList {
  margin: 0;
  padding-left: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

#historyList li {
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(248, 250, 252, 0.9);
  border-radius: 10px;
  padding: 10px 12px;
  color: #1e293b;
}

@media (max-width: 640px) {
  body {
    padding: 14px;
  }

  #loginSection,
  #appSection {
    padding: 16px;
    border-radius: 16px;
  }

  #spinBtn,
  #installBtn,
  #clearHistoryBtn,
  #logoutBtn,
  #loginBtn {
    width: 100%;
  }

  .actions {
    gap: 8px;
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
  background-color: #fff;
  margin: 20% auto;
  padding: 20px;
  border-radius: 10px;
  width: 90%;
  max-width: 400px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.close {
  color: #aaa;
  float: right;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
}

.close:hover,
.close:focus {
  color: black;
}
