*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --green: #00A651; --green-dark: #008A43; --green-light: #E8F5E9;
  --blue: #4db8ff; --blue-dark: #0a3d8f;
  --bg: #0a0a1a; --card: #151528; --card2: #1e1e36;
  --text: #e0e0e0; --text-dim: #888; --radius: 10px;
}
html, body { height: 100%; overflow: hidden; }
body { font-family: 'Inter', system-ui, sans-serif; background: var(--bg); color: var(--text); }

/* ── VIEWS ──────────────────────────────── */
.view { display: none; position: absolute; inset: 0; overflow-y: auto; }
.view.active { display: flex; flex-direction: column; }

/* ── WARP ────────────────────────────────── */
#warpView { background: #000; align-items: center; justify-content: center; }
#warpCanvas { width: 100%; height: 100%; }
.skip-btn { position: absolute; bottom: 30px; right: 30px; background: rgba(255,255,255,.15); color: #fff;
  border: 1px solid rgba(255,255,255,.3); padding: 10px 24px; border-radius: 20px; cursor: pointer; font-size: 14px; z-index: 5; }

/* ── AUTH ─────────────────────────────────── */
#authView { align-items: center; justify-content: center; background: linear-gradient(160deg, #0d1b2a 0%, var(--bg) 60%); }
.auth-box { background: var(--card); padding: 40px; border-radius: 16px; width: 90%; max-width: 400px; text-align: center; }
.auth-box h2 { color: var(--green); margin-bottom: 8px; font-size: 28px; }
.auth-box p { color: var(--text-dim); margin-bottom: 24px; }
.auth-box input { width: 100%; padding: 12px 16px; margin-bottom: 12px; border-radius: 8px; border: 1px solid #333;
  background: #0d0d20; color: #fff; font-size: 15px; }
.auth-box input:focus { border-color: var(--green); outline: none; }
.auth-err { color: #ef5350; font-size: 13px; margin-bottom: 10px; min-height: 20px; }
.auth-toggle { color: var(--blue); cursor: pointer; font-size: 14px; margin-top: 12px; }
.auth-toggle:hover { text-decoration: underline; }

/* ── LOBBY ────────────────────────────────── */
#lobbyView { background: var(--bg); }
.lobby-top { display: flex; justify-content: space-between; align-items: center; padding: 8px 16px; background: rgba(0,0,0,.5); z-index: 5; }
.lobby-top .logo { font-size: 18px; font-weight: 700; }
.lobby-top .logo .g { color: var(--green); }
.lobby-user { display: flex; align-items: center; gap: 10px; }
.lobby-user span { font-size: 13px; color: var(--text-dim); }
.lobby-user button { background: rgba(255,255,255,.1); border: none; color: #fff; padding: 6px 14px; border-radius: 6px; cursor: pointer; font-size: 12px; }
.canvas-wrap { flex: 1; position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.canvas-wrap canvas { image-rendering: pixelated; }

/* ── CHAT ─────────────────────────────────── */
.chat-panel { position: absolute; bottom: 0; left: 0; width: 320px; max-height: 260px; background: rgba(10,10,26,.9);
  border-top: 1px solid #333; border-right: 1px solid #333; display: flex; flex-direction: column; z-index: 10; }
.chat-messages { flex: 1; overflow-y: auto; padding: 8px; font-size: 13px; }
.chat-msg { margin-bottom: 4px; }
.chat-name { font-weight: 600; margin-right: 6px; }
.chat-me .chat-name { color: var(--green); }
.chat-input-row { display: flex; border-top: 1px solid #333; }
.chat-input-row input { flex: 1; background: #111; border: none; padding: 10px; color: #fff; font-size: 13px; }
.chat-input-row button { background: var(--green); border: none; color: #fff; padding: 10px 16px; cursor: pointer; font-weight: 600; }

/* ── POKE ─────────────────────────────────── */
.poke-popup { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); background: var(--card2);
  color: #fff; padding: 14px 28px; border-radius: 10px; border: 2px solid var(--blue); z-index: 200;
  animation: pokeIn .3s ease; font-size: 15px; }
.poke-sent { border-color: var(--green); }
.poke-popup-fade { opacity: 0; transition: opacity .4s; }
@keyframes pokeIn { from { opacity: 0; transform: translateX(-50%) translateY(-20px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }
.poke-shake { animation: shake .4s ease; }
@keyframes shake { 0%,100%{transform:translateX(0)} 20%{transform:translateX(-8px)} 40%{transform:translateX(8px)} 60%{transform:translateX(-4px)} 80%{transform:translateX(4px)} }

/* NPC context menu */
.npc-menu { position: fixed; background: var(--card2); border: 1px solid #444; border-radius: 8px; padding: 6px; z-index: 100; }
.npc-menu button { display: block; width: 100%; background: none; border: none; color: #fff; padding: 8px 16px; cursor: pointer; font-size: 13px; text-align: left; border-radius: 4px; }
.npc-menu button:hover { background: rgba(255,255,255,.1); }

/* ── BUTTONS ──────────────────────────────── */
.btn-fv { display: inline-block; padding: 12px 28px; border-radius: 10px; font-weight: 600; font-size: 15px;
  cursor: pointer; border: none; transition: all .2s; margin: 6px; }
.btn-fv.btn-primary, .btn-fv.btn-quiz-start, .btn-fv.btn-buy, .btn-fv.btn-buy-item { background: var(--green); color: #fff; }
.btn-fv.btn-primary:hover, .btn-fv.btn-quiz-start:hover, .btn-fv.btn-buy:hover, .btn-fv.btn-buy-item:hover { background: var(--green-dark); }
.btn-fv.btn-secondary { background: rgba(255,255,255,.1); color: #fff; }
.btn-fv.btn-secondary:hover { background: rgba(255,255,255,.2); }

/* ── SUB-VIEWS (quiz, store, etc.) ────────── */
#subView { background: var(--bg); padding: 24px; align-items: center; }
#subContent { width: 100%; max-width: 800px; }

/* ── QUIZ ─────────────────────────────────── */
.quiz-menu, .quiz-results { text-align: center; padding: 40px 0; }
.quiz-menu h2, .quiz-results h2 { font-size: 32px; color: var(--blue); margin-bottom: 10px; }
.quiz-info { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin: 24px 0; }
.qi { background: var(--card); padding: 12px 20px; border-radius: 8px; font-size: 14px; }
.quiz-status, .token-status { color: #ffa726; margin-top: 12px; font-size: 14px; min-height: 20px; }
.quiz-game { max-width: 600px; margin: 0 auto; }
.quiz-hud { display: flex; justify-content: space-between; padding: 12px; background: var(--card); border-radius: 8px; margin-bottom: 20px; font-size: 15px; }
.quiz-timer { color: #ff7043; font-weight: 700; font-size: 20px; }
.quiz-question { font-size: 20px; font-weight: 600; margin-bottom: 20px; text-align: center; line-height: 1.4; }
.quiz-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 20px; }
.quiz-opt { background: var(--card); border: 2px solid #333; color: #fff; padding: 16px; border-radius: 10px;
  font-size: 15px; cursor: pointer; transition: .2s; }
.quiz-opt:hover { border-color: var(--blue); }
.quiz-opt.selected { border-color: var(--blue); background: rgba(77,184,255,.15); }
.quiz-opt.correct { border-color: var(--green); background: rgba(0,166,81,.2); }
.quiz-opt.wrong { border-color: #ef5350; background: rgba(239,83,80,.15); }
.quiz-players { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; }
.qp { background: var(--card); padding: 6px 14px; border-radius: 6px; font-size: 13px; }
.quiz-final-scores { margin: 20px 0; }
.qfs { display: flex; justify-content: space-between; padding: 12px 20px; margin: 6px 0; background: var(--card); border-radius: 8px; }
.qfs-winner { border: 2px solid gold; background: rgba(255,215,0,.08); }
.quiz-winnings { font-size: 18px; color: var(--green); margin: 16px 0; }

/* ── LEADERBOARDS ─────────────────────────── */
.lb-wrapper { padding: 20px 0; }
.lb-wrapper h2 { font-size: 28px; text-align: center; margin-bottom: 16px; }
.lb-tabs { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 20px; }
.lb-tab { background: var(--card); border: 1px solid #333; color: var(--text-dim); padding: 8px 16px; border-radius: 8px; cursor: pointer; font-size: 13px; }
.lb-tab-active { border-color: var(--green); color: #fff; background: rgba(0,166,81,.15); }
.lb-board-title { font-size: 18px; font-weight: 600; margin-bottom: 12px; text-align: center; }
.lb-table { max-width: 600px; margin: 0 auto; }
.lb-row { display: flex; align-items: center; padding: 10px 16px; border-bottom: 1px solid #222; }
.lb-header { font-weight: 700; color: var(--text-dim); font-size: 13px; }
.lb-row-me { background: rgba(0,166,81,.1); border-left: 3px solid var(--green); }
.lb-rank { width: 50px; }
.lb-name { flex: 1; }
.lb-val { width: 80px; text-align: right; font-weight: 600; }
.lb-note { text-align: center; color: var(--text-dim); margin-top: 12px; font-size: 13px; }

/* ── TOKEN SHOP ───────────────────────────── */
.token-shop { text-align: center; padding: 20px 0; }
.token-shop h2 { font-size: 28px; color: #fdd835; margin-bottom: 8px; }
.token-balance { font-size: 16px; margin: 16px 0; padding: 12px; background: var(--card); border-radius: 8px; }
.token-packages { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin: 20px 0; }
.token-pkg { background: var(--card); border: 2px solid #333; border-radius: 12px; padding: 24px 16px; text-align: center; transition: .2s; }
.token-pkg:hover { border-color: #fdd835; }
.pkg-amount { font-size: 28px; font-weight: 700; color: #fdd835; }
.pkg-unit { font-size: 14px; color: var(--text-dim); }
.pkg-bonus { color: var(--green); font-size: 13px; font-weight: 600; margin: 4px 0; }
.pkg-price { font-size: 16px; margin: 8px 0; }

/* ── SWAG STORE ───────────────────────────── */
.store-wrapper { padding: 20px 0; }
.store-wrapper h2 { font-size: 28px; text-align: center; color: #e91e63; margin-bottom: 8px; }
.store-categories { display: flex; gap: 8px; justify-content: center; margin: 16px 0; flex-wrap: wrap; }
.store-cat { background: var(--card); border: 1px solid #333; color: var(--text-dim); padding: 8px 16px; border-radius: 8px; cursor: pointer; font-size: 13px; }
.store-cat-active { border-color: #e91e63; color: #fff; }
.store-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin: 16px 0; }
.store-item { background: var(--card); border: 1px solid #222; border-radius: 12px; padding: 20px; text-align: center; }
.store-emoji { font-size: 40px; margin-bottom: 8px; }
.store-item-name { font-weight: 600; margin-bottom: 4px; }
.store-item-desc { font-size: 12px; color: var(--text-dim); margin-bottom: 8px; }
.store-item-price { font-size: 18px; font-weight: 700; color: var(--green); margin-bottom: 10px; }

/* ── DEPFARMS ─────────────────────────────── */
.depfarms-wrapper { display: flex; flex-direction: column; height: 100%; }
.depfarms-header { padding: 12px; text-align: center; }
.depfarms-header h2 { color: #ff9800; }
.depfarms-frame-container { flex: 1; }
.depfarms-iframe { width: 100%; height: 100%; border: none; border-radius: 8px; }

/* ── PROFILE ──────────────────────────────── */
.profile-card { max-width: 600px; margin: 0 auto; }
.profile-header { display: flex; align-items: center; gap: 16px; margin-bottom: 24px; }
.profile-avatar { width: 60px; height: 60px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 700; color: #fff; }
.profile-name { font-size: 24px; font-weight: 700; }
.profile-email { color: var(--text-dim); font-size: 14px; }
.profile-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat-box { background: var(--card); padding: 16px; border-radius: 10px; text-align: center; }
.stat-val { font-size: 24px; font-weight: 700; color: var(--green); }
.stat-streak .stat-val { color: #ff7043; }
.stat-label { font-size: 12px; color: var(--text-dim); margin-top: 4px; }
.profile-section { margin-top: 24px; }
.profile-section h3 { font-size: 18px; margin-bottom: 12px; color: var(--blue); }
.streak-calendar { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; }
.streak-day { width: 100%; aspect-ratio: 1; background: #1a1a2e; border-radius: 4px; display: flex; align-items: center;
  justify-content: center; font-size: 11px; color: var(--text-dim); }
.streak-active { background: var(--green); color: #fff; font-weight: 600; }
.swag-collection { display: flex; flex-wrap: wrap; gap: 8px; }
.swag-badge { background: var(--card); padding: 6px 14px; border-radius: 6px; font-size: 13px; border: 1px solid #333; }

/* ── RESPONSIVE ───────────────────────────── */
@media (max-width: 768px) {
  .chat-panel { width: 100%; max-height: 180px; }
  .quiz-opts { grid-template-columns: 1fr; }
  .token-packages { grid-template-columns: 1fr 1fr; }
}
