/* ── CSS Variables ── */
:root {
  --bg:          #FFFFFF;
  --bg2:         #F9FAFB;
  --bg3:         #F2F4F6;
  --card:        #FFFFFF;
  --card-border: #E5E8EB;
  --card-hover:  #F9FAFB;
  --accent:      #3182F6;
  --accent-bg:   #EBF3FE;
  --gold:        #FF9F0A;
  --gold-bg:     #FFF4D9;
  --success:     #00B900;
  --success-bg:  #E6F8E6;
  --danger:      #F04452;
  --danger-bg:   #FEECEE;
  --text:        #191F28;
  --text2:       #8B95A1;
  --text3:       #C4C9CF;
  --radius:      16px;
  --radius-sm:   12px;
  --shadow:      0 2px 12px rgba(0,0,0,0.08);
  --shadow-md:   0 4px 24px rgba(0,0,0,0.10);
}

/* ── Reset ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  background: var(--bg2);
  color: var(--text);
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-font-smoothing: antialiased;
}

[hidden] {
  display: none !important;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 28px;
  border-radius: 100px;
  border: none;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  transition: all 0.18s ease;
  min-height: 54px;
  position: relative;
  overflow: hidden;
  font-family: inherit;
  letter-spacing: -0.01em;
}
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.4; pointer-events: none; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(49,130,246,0.25);
}
.btn-primary:hover { background: #1b6ef3; }
.btn-primary:active { background: #1660e0; }

.btn-success {
  background: var(--success);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0,185,0,0.2);
}
.btn-success:hover { background: #009e00; }

.btn-gold {
  background: var(--gold);
  color: #fff;
  box-shadow: 0 2px 8px rgba(255,159,10,0.25);
  font-weight: 800;
}
.btn-gold:hover { background: #e88e00; }

.btn-ghost {
  background: var(--card);
  color: var(--text);
  border: 1.5px solid var(--card-border);
}
.btn-ghost:hover { background: var(--bg2); }

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1.5px solid rgba(240,68,82,0.2);
}
.btn-danger:hover { background: #fdd9dc; }

.btn-full { width: 100%; }
.btn-sm { padding: 10px 18px; font-size: 13px; min-height: 38px; }
.btn-icon { padding: 14px; min-height: 50px; width: 50px; border-radius: 50%; }

/* ── Toast ── */
.toast {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(-16px);
  background: var(--text);
  border-radius: 100px;
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  opacity: 0;
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
  white-space: nowrap;
  z-index: 9999;
  box-shadow: var(--shadow-md);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok { background: var(--success); }
.toast.err { background: var(--danger); }

/* ── Spinner / Loading ── */
.spinner {
  border-radius: 50%;
  border-style: solid;
  border-color: var(--card-border);
  border-top-color: var(--accent);
  animation: spin 0.75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 60px 24px;
  color: var(--text2);
  font-size: 15px;
  font-weight: 600;
}
.loading .spinner { width: 24px; height: 24px; border-width: 3px; }

/* ── Modal overlay ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 24px;
}
.modal-overlay.show { display: flex; }
.modal-box {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 24px;
  padding: 36px 28px;
  text-align: center;
  max-width: 360px;
  width: 100%;
  box-shadow: var(--shadow-md);
  animation: popIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes popIn {
  from { transform: scale(0.88); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}
.modal-icon  { font-size: 48px; margin-bottom: 16px; }
.modal-title { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; margin-bottom: 8px; color: var(--text); }
.modal-sub   { color: var(--text2); font-size: 14px; font-weight: 500; margin-bottom: 24px; }

/* ── Badge ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 700;
}
.badge-gold  { background: var(--gold-bg); color: var(--gold); }
.badge-muted { background: var(--bg3); color: var(--text3); }

/* ── Login Screen (shared by game + admin) ── */
#screen-login {
  min-height: 100vh;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px max(40px, calc(env(safe-area-inset-bottom) + 20px));
  text-align: center;
  background: var(--bg);
}
#screen-login:not(.screen),
#screen-login.screen.active {
  display: flex;
}
.login-icon {
  width: 96px;
  height: 96px;
  border-radius: 28px;
  margin-bottom: 28px;
  background: var(--accent-bg);
  border: 1px solid rgba(49,130,246,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 44px;
}
.login-title {
  font-size: 28px;
  font-weight: 900;
  letter-spacing: -0.03em;
  margin-bottom: 8px;
  color: var(--text);
}
.login-sub   { color: var(--text2); font-size: 15px; font-weight: 500; margin-bottom: 12px; }
.login-badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  background: var(--accent-bg);
  color: var(--accent);
  padding: 5px 14px;
  border-radius: 100px;
  margin-bottom: 40px;
}
.google-sign-in-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  background: #fff;
  color: #1a1a2e;
  padding: 16px 32px;
  border-radius: 100px;
  border: 1.5px solid var(--card-border);
  cursor: pointer;
  touch-action: manipulation;
  font-size: 16px;
  font-weight: 700;
  font-family: inherit;
  box-shadow: var(--shadow);
  transition: all 0.18s;
}
.google-sign-in-btn:hover  { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.google-sign-in-btn:active { transform: scale(0.96); }
.google-sign-in-btn svg    { width: 22px; height: 22px; flex-shrink: 0; }
.login-error {
  margin-top: 20px;
  padding: 14px 22px;
  background: var(--danger-bg);
  border: 1px solid rgba(240,68,82,0.2);
  border-radius: var(--radius-sm);
  color: var(--danger);
  font-size: 14px;
  font-weight: 600;
  display: none;
}
