/* Root variables */
:root {
  --max-wheel-size: 520px;
  --card-bg: rgba(0,0,0,0.55);
  --card-border: rgba(255,255,255,0.12);
  --text: #fff;
  --accent: #ff7a3d;
  /* khoảng cách đẩy nhóm nút xuống dưới để không che chữ nền */
  --actions-offset: clamp(16px, 8vh, 100px);
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: var(--text);
  background: #000 url('../images/bghalo.png') center/cover no-repeat fixed;
  position: relative;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: radial-gradient(60% 60% at 50% 35%, rgba(0,0,0,0.1), rgba(0,0,0,0.75));
  pointer-events: none;
}

.page {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: clamp(8px, 2vh, 16px) 16px clamp(12px, 3vh, 24px);
  gap: 10px;
}

header.page-header { width: min(1100px, 96vw); text-align: center; }
.title { margin: 0 0 6px; font-size: clamp(20px, 2.6vw + 8px, 34px); font-weight: 800; letter-spacing: .3px; text-shadow: 0 4px 20px rgba(0,0,0,.35); }
.subtitle { margin: 0; opacity: .85; font-size: clamp(13px, 1.2vw + 10px, 16px); }

.info-grid { width: min(1100px, 96vw); display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 768px) { .info-grid { grid-template-columns: repeat(3, 1fr); } }

.card { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 14px; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); overflow: hidden; }
.card details { padding: 12px 14px; }
.card summary { cursor: pointer; list-style: none; user-select: none; font-weight: 700; display: flex; align-items: center; gap: 8px; font-size: 16px; }
.card summary::-webkit-details-marker { display: none; }
.card .content { padding: 8px 2px 6px 0; opacity: .95; font-size: 14px; }
.pill { display:inline-block; padding: 4px 10px; border-radius: 999px; background: rgba(255,255,255,0.08); border: 1px solid var(--card-border); font-size: 12px; }
.list { margin: 6px 0 0 18px; }

.wheel-section { width: min(1100px, 96vw); display: grid; grid-template-columns: 1fr; place-items: center; gap: 10px; order: 2; }

.wheel-wrap { position: relative; width: min(90vw, var(--max-wheel-size)); aspect-ratio: 1/1; max-width: var(--max-wheel-size); filter: drop-shadow(0 18px 30px rgba(0,0,0,0.45)); }

canvas#wheel, img.outwheel { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; pointer-events: none; }

/* Spin button */
.spin-btn { width: clamp(120px, 28vw, 200px); aspect-ratio: 1/1; display: grid; place-items: center; background: transparent; border: 0; padding: 0; cursor: pointer; border-radius: 50%; position: relative; filter: drop-shadow(0 6px 14px rgba(0,0,0,0.35)); transition: transform .15s ease; animation: glowPulse 2.4s ease-in-out infinite; user-select: none; -webkit-tap-highlight-color: transparent; outline: none; }
.spin-btn img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.spin-btn:hover { transform: translateY(-2px) scale(1.05) rotate(-2deg); }
.spin-btn:active { transform: translateY(0) scale(0.97); }
.spin-btn::after { content: ""; position: absolute; inset: -6px; border-radius: 50%; border: 2px solid rgba(255,122,61,.45); animation: ping 1.8s ease-out infinite; pointer-events: none; }
@keyframes glowPulse { 0%, 100% { filter: drop-shadow(0 6px 14px rgba(0,0,0,.35)) drop-shadow(0 0 0 rgba(255,122,61,0)); } 50% { filter: drop-shadow(0 6px 14px rgba(0,0,0,.35)) drop-shadow(0 0 18px rgba(255,122,61,.55)); } }
@keyframes ping { from { transform: scale(.9); opacity:.6; } to { transform: scale(1.25); opacity: 0; } }

.note { opacity: .8; font-size: 13px; text-align: center; }

.tabs { display: none !important; }

/* Actions 3D buttons above wheel */
.actions {
  /* dùng biến để dễ chỉnh độ cao của nhóm nút */
  margin: var(--actions-offset) auto 6px;
  width: min(1100px, 96vw); display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: center; order: 1; }
.ui3d { --bg1: #ff9666; --bg2: #ff5a2d; --edge: #c74625; --glow: rgba(255,122,61,.55); position: relative; appearance: none; padding: 10px 16px; border-radius: 14px; border: none; color: #fff; font-weight: 800; letter-spacing: .2px; cursor: pointer; background: linear-gradient(180deg, var(--bg1), var(--bg2)); box-shadow: 0 14px 24px rgba(0,0,0,.35), 0 2px 0 var(--edge), inset 0 1px 0 rgba(255,255,255,.35); transition: transform .15s ease, box-shadow .2s ease, filter .2s ease; user-select: none; -webkit-tap-highlight-color: transparent; isolation: isolate; }
.ui3d:hover { transform: translateY(-2px); box-shadow: 0 18px 28px rgba(0,0,0,.38), 0 3px 0 var(--edge), inset 0 1px 0 rgba(255,255,255,.35); }
.ui3d:active { transform: translateY(1px); box-shadow: 0 10px 18px rgba(0,0,0,.3), 0 1px 0 var(--edge) inset; }
.ui3d:focus-visible { outline: 2px solid var(--glow); outline-offset: 2px; }
.ui3d::after { content: ""; position: absolute; inset: -2px; border-radius: inherit; z-index: -1; background: conic-gradient(from 0deg, rgba(255,122,61,0), var(--glow), rgba(255,122,61,0) 60%); filter: blur(10px); opacity: 0; transition: opacity .25s ease; pointer-events: none; }
.ui3d:hover::after { opacity: .9; animation: spinGlow 1.6s linear infinite; }
@keyframes spinGlow { to { transform: rotate(360deg); } }

/* Modal */
.modal { position: fixed; inset: 0; display: none; z-index: 500; }
.modal.open { display: grid; place-items: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.6); backdrop-filter: blur(3px); animation: fadeIn .2s ease; }
.modal-dialog { position: relative; width: min(92vw, 620px); background: rgba(18,18,18,.92); border: 1px solid var(--card-border); border-radius: 16px; padding: 16px 16px 12px; box-shadow: 0 24px 60px rgba(0,0,0,.55), 0 0 0 1px rgba(255,255,255,0.06) inset; transform: translateY(8px) scale(.98); opacity: 0; animation: popIn .22s ease forwards; }
.modal-body { max-height: min(68vh, 560px); overflow: auto; padding-right: 4px; }
.modal-close { position: absolute; top: 8px; right: 8px; width: 36px; height: 36px; border-radius: 10px; border: none; cursor: pointer; color: #fff; font-size: 18px; font-weight: 900; background: linear-gradient(180deg,#2b2b2b,#1b1b1b); box-shadow: 0 10px 18px rgba(0,0,0,.4), inset 0 1px 0 rgba(255,255,255,.1); transition: transform .12s ease, filter .2s ease; }
.modal-close:hover { transform: translateY(-1px); filter: drop-shadow(0 0 10px rgba(255,255,255,.1)); }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { to { transform: translateY(0) scale(1); opacity: 1; } }

/* Spin counter styles */
.spin-counter { 
  font-weight: 900;
  font-size: clamp(16px, 1.3vw + 12px, 22px);
  padding: 8px 14px;
  border-radius: 12px;
  background: rgba(255,255,255,.1);
  border: 1px solid var(--card-border);
  text-shadow: 0 2px 8px rgba(0,0,0,.35);
  letter-spacing: .2px;
  box-shadow: 0 8px 18px rgba(0,0,0,.28), inset 0 1px 0 rgba(255,255,255,.06);
  margin: 0;
}

/* Simple form styles inside modal */
.form-row { margin: 8px 0 10px; }
.form-row input[type="text"], .form-row input[type="email"], .form-row input[type="password"] {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--card-border);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  outline: none;
}
.form-row input::placeholder { color: rgba(255,255,255,.6); }
.form-row input:focus { border-color: rgba(255,255,255,.25); box-shadow: 0 0 0 3px rgba(255,255,255,.08) inset; }
.form-error { color: #ffb4b4; min-height: 18px; font-size: 13px; margin: 4px 2px 6px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; }
/* Responsive enhancements */
.ui3d { font-size: clamp(13px, 1.1vw + 10px, 16px); }

@media (max-width: 420px) {
  .actions { gap: 8px; }
  .ui3d { padding: 8px 12px; font-size: 13px; }
  .spin-counter { font-size: clamp(14px, 1.4vw + 10px, 18px); padding: 6px 12px; }
  .wheel-section { gap: 8px; }
}

@media (max-height: 620px) {
  :root { --actions-offset: 16px; }
  .spin-btn { width: clamp(96px, 22vw, 160px); }
  .wheel-wrap { width: min(88vw, var(--max-wheel-size)); }
  .wheel-section { gap: 8px; }
}

@media (orientation: landscape) and (max-height: 480px) {
  :root { --actions-offset: 12px; }
  .page { justify-content: flex-start; padding-top: 12px; }
  .wheel-section { gap: 6px; }
  .spin-btn { width: clamp(90px, 18vw, 140px); }
}

@media (min-width: 1280px) { :root { --max-wheel-size: 600px; } }

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
  .spin-btn, .spin-btn::after, .ui3d::after { animation: none !important; }
}

@supports (padding: max(0px)) {
  .page { padding-top: max(env(safe-area-inset-top), 8px); padding-bottom: max(env(safe-area-inset-bottom), 12px); }
}

/* Login overlay - minimal modern */
.login-modal { position: fixed; inset: 0; display: none; place-items: center; z-index: 600; }
.login-modal::before { content: ""; position: absolute; inset: 0; background: radial-gradient(80% 60% at 50% 30%, rgba(0,0,0,.15), rgba(0,0,0,.8)); }
.login-modal.open { display: grid; }
.login-card { position: relative; width: min(92vw, 420px); border-radius: 16px; padding: 18px 16px 14px; background: rgba(20,20,20,.78); border: 1px solid rgba(255,255,255,.12); box-shadow: 0 24px 60px rgba(0,0,0,.55), 0 0 0 1px rgba(255,255,255,0.06) inset; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.login-title { margin: 0 0 8px; font-size: clamp(18px, 1.1vw + 14px, 22px); font-weight: 800; letter-spacing: .2px; }
#loginForm { display: grid; gap: 12px; }
.input-wrap { position: relative; }
.input-wrap::before { content: "@"; position: absolute; left: 10px; top: 50%; transform: translateY(-50%); opacity: .6; font-weight: 800; }
#loginForm input { width: 100%; padding: 12px 12px 12px 28px; border-radius: 12px; border: 1px solid var(--card-border); background: rgba(255,255,255,.06); color: var(--text); outline: none; font-size: 16px; transition: border-color .15s ease, box-shadow .15s ease, background .2s ease; }
#loginForm input:hover { background: rgba(255,255,255,.08); }
#loginForm input:focus { border-color: rgba(255,255,255,.35); box-shadow: 0 0 0 3px rgba(255,255,255,.08) inset; }
.btn-primary { appearance: none; border: 0; border-radius: 12px; padding: 10px 14px; font-weight: 800; cursor: pointer; color: #fff; background: linear-gradient(180deg, #6dd36d, #2fb62f); box-shadow: 0 12px 24px rgba(0,0,0,.35), 0 2px 0 #1c7a1c; transition: transform .12s ease, box-shadow .18s ease, filter .18s ease; }
.btn-primary:hover { filter: brightness(1.05); box-shadow: 0 16px 28px rgba(0,0,0,.4), 0 3px 0 #1c7a1c; }
.btn-primary:active { transform: translateY(1px); box-shadow: 0 8px 18px rgba(0,0,0,.28); }
.form-error { color: #ffb4b4; min-height: 18px; font-size: 13px; margin: -2px 2px 4px; }
@media (max-width: 420px) { .login-card { width: min(96vw, 360px); padding: 14px 12px; } #loginForm input { font-size: 15px; } }
@media (prefers-reduced-motion: reduce) { .login-modal { backdrop-filter: none; } }
