/* ===== Base Reset & Variables ===== */
:root {
  --color-primary: #6C5CE7;
  --color-primary-light: #A29BFE;
  --color-accent: #00D2FF;
  --color-accent-secondary: #FF6B9D;
  --color-surface: rgba(15, 12, 41, 0.75);
  --color-surface-light: rgba(255, 255, 255, 0.08);
  --color-border: rgba(255, 255, 255, 0.15);
  --color-text: #F0F0F5;
  --color-text-muted: rgba(255, 255, 255, 0.6);
  --color-input-bg: rgba(255, 255, 255, 0.07);
  --color-input-focus: rgba(108, 92, 231, 0.3);
  --radius: 12px;
  --radius-lg: 20px;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body, html {
  font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
  height: 100%;
  overflow-x: hidden;
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
}

/* ===== Background ===== */
.background-image-container {
  position: fixed;
  inset: 0;
  background-image: url('public/background.png');
  background-size: cover;
  background-position: center top;
  z-index: -2;
}

.background-image-container::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(15, 12, 41, 0.85) 0%,
    rgba(15, 12, 41, 0.6) 40%,
    rgba(15, 12, 41, 0.75) 100%
  );
  z-index: 1;
}

/* ===== Floating Stars ===== */
.stars {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
}

.star {
  position: absolute;
  width: 3px;
  height: 3px;
  background: white;
  border-radius: 50%;
  animation: twinkle var(--duration, 3s) ease-in-out infinite alternate;
  opacity: 0;
}

.star:nth-child(1)  { top: 8%;  left: 15%; --duration: 2.5s; animation-delay: 0s; }
.star:nth-child(2)  { top: 12%; left: 75%; --duration: 3.2s; animation-delay: 0.5s; }
.star:nth-child(3)  { top: 25%; left: 42%; --duration: 2.8s; animation-delay: 1s; }
.star:nth-child(4)  { top: 5%;  left: 90%; --duration: 3.5s; animation-delay: 1.5s; }
.star:nth-child(5)  { top: 18%; left: 55%; --duration: 2.2s; animation-delay: 0.3s; }
.star:nth-child(6)  { top: 35%; left: 8%;  --duration: 3.8s; animation-delay: 0.8s; }
.star:nth-child(7)  { top: 3%;  left: 30%; --duration: 2.6s; animation-delay: 1.2s; }
.star:nth-child(8)  { top: 22%; left: 85%; --duration: 3.1s; animation-delay: 0.2s; }
.star:nth-child(9)  { top: 40%; left: 65%; --duration: 2.9s; animation-delay: 1.8s; }
.star:nth-child(10) { top: 15%; left: 22%; --duration: 3.4s; animation-delay: 0.7s; }
.star:nth-child(11) { top: 30%; left: 50%; --duration: 2.3s; animation-delay: 1.4s; }
.star:nth-child(12) { top: 10%; left: 60%; --duration: 3.6s; animation-delay: 0.6s; }

@keyframes twinkle {
  0%   { opacity: 0; transform: scale(0.5); }
  100% { opacity: 0.8; transform: scale(1.2); }
}

/* ===== Page Layout ===== */
.page-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px 20px 40px;
}

/* ===== Language Selector ===== */
.language-selector {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--color-surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 6px 10px;
  transition: border-color var(--transition);
}

.language-selector:hover {
  border-color: var(--color-primary-light);
}

.language-icon {
  width: 16px;
  height: 16px;
  color: var(--color-text-muted);
  flex-shrink: 0;
}

#language-dropdown {
  background: transparent;
  border: none;
  color: var(--color-text);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  outline: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  padding-right: 4px;
}

#language-dropdown option {
  background: #1a1a2e;
  color: var(--color-text);
}

/* ===== Game Logo ===== */
.logo-area {
  margin-bottom: 24px;
  animation: fadeSlideDown 0.6s ease-out;
}

.game-logo {
  height: 80px;
  width: auto;
  filter: drop-shadow(0 4px 20px rgba(108, 92, 231, 0.4));
  transition: transform var(--transition);
}

.game-logo:hover {
  transform: scale(1.05);
}

/* ===== Coupon Container (Glassmorphism) ===== */
.coupon-container {
  width: 100%;
  max-width: 420px;
  padding: 36px 32px 32px;
  background: var(--color-surface);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
  animation: fadeSlideUp 0.6s ease-out;
}

h1 {
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 28px;
  letter-spacing: -0.02em;
}

/* ===== Form Groups ===== */
.form-group {
  margin-bottom: 18px;
}

label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-muted);
  letter-spacing: 0.02em;
}

/* ===== Inputs ===== */
.input-wrapper,
.select-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  left: 12px;
  width: 18px;
  height: 18px;
  color: var(--color-text-muted);
  pointer-events: none;
  transition: color var(--transition);
}

.select-arrow {
  position: absolute;
  right: 12px;
  width: 16px;
  height: 16px;
  color: var(--color-text-muted);
  pointer-events: none;
}

input[type="text"] {
  width: 100%;
  padding: 12px 14px 12px 40px;
  background: var(--color-input-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  color: var(--color-text);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
}

input[type="text"]::placeholder {
  color: var(--color-text-muted);
  font-size: 14px;
}

input[type="text"]:focus {
  border-color: var(--color-primary-light);
  background: var(--color-input-focus);
  box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.15);
}

input[type="text"]:focus ~ .input-icon,
.input-wrapper:focus-within .input-icon {
  color: var(--color-primary-light);
}

select#server-dropdown {
  width: 100%;
  padding: 12px 36px 12px 14px;
  background: var(--color-input-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  color: var(--color-text);
  font-size: 15px;
  font-family: inherit;
  cursor: pointer;
  outline: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
}

select#server-dropdown:focus {
  border-color: var(--color-primary-light);
  background: var(--color-input-focus);
  box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.15);
}

select#server-dropdown option {
  background: #1a1a2e;
  color: var(--color-text);
  padding: 8px;
}

/* ===== Redeem Button ===== */
#redeem-button {
  width: 100%;
  padding: 14px;
  margin-top: 8px;
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-light) 100%);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  letter-spacing: 0.02em;
  transition: transform var(--transition), box-shadow var(--transition), opacity var(--transition);
  box-shadow: 0 4px 16px rgba(108, 92, 231, 0.35);
}

#redeem-button:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(108, 92, 231, 0.5);
}

#redeem-button:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(108, 92, 231, 0.3);
}

#redeem-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ===== Modal ===== */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  background-color: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease-out;
}

.modal-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90%;
  max-width: 380px;
  background: linear-gradient(145deg, rgba(30, 27, 60, 0.98), rgba(20, 18, 45, 0.98));
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 32px 28px 28px;
  text-align: center;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4);
  animation: modalSlideIn 0.3s ease-out;
}

.modal-content h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 8px;
}

.close-button {
  position: absolute;
  top: 12px;
  right: 16px;
  color: var(--color-text-muted);
  font-size: 24px;
  font-weight: bold;
  cursor: pointer;
  line-height: 1;
  transition: color var(--transition);
}

.close-button:hover {
  color: var(--color-text);
}

#modal-message {
  font-size: 15px;
  line-height: 1.6;
  margin: 16px 0 24px;
  color: var(--color-text-muted);
  white-space: pre-wrap;
}

#modal-close-button {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-light) 100%);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
  box-shadow: 0 4px 12px rgba(108, 92, 231, 0.3);
}

#modal-close-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(108, 92, 231, 0.45);
}

/* ===== Animations ===== */
@keyframes fadeSlideUp {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeSlideDown {
  from {
    opacity: 0;
    transform: translateY(-16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translate(-50%, -48%);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%);
  }
}

/* ===== Responsive ===== */
@media (max-width: 480px) {
  .page-wrapper {
    padding: 24px 16px 32px;
    justify-content: flex-start;
    padding-top: 60px;
  }

  .coupon-container {
    padding: 28px 20px 24px;
    border-radius: 16px;
  }

  h1 {
    font-size: 20px;
    margin-bottom: 22px;
  }

  .game-logo {
    height: 64px;
  }

  .language-selector {
    top: 12px;
    right: 12px;
  }
}

@media (max-height: 700px) {
  .page-wrapper {
    justify-content: flex-start;
    padding-top: 50px;
  }

  .logo-area {
    margin-bottom: 16px;
  }
}

/* ===== Scrollbar (webkit) ===== */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}
