/* Gram Buddies — crystal mine theme */
:root {
  --bg: #061321;
  --bg-elev: #0B1D2D;
  --card: #10283A;
  --card-2: #16364A;
  --line: #28536A;
  --text: #F7FBFF;
  --muted: #9AB4C6;
  --accent: #0EA5E9;
  --accent-2: #38D5FF;
  --accent-dark: #0877C9;
  --gold: #FFD229;
  --gem: #13C8FF;
  --danger: #E53935;
  --warn: #F48A19;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 10px 30px rgba(0,0,0,.45);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  overscroll-behavior-y: none;
}
.hidden { display: none !important; }
button { font-family: inherit; }
a { color: var(--accent-2); text-decoration: none; }
input, select, textarea {
  width: 100%; background: var(--card-2); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 12px 14px; font-size: 15px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
label { display: block; font-size: 12px; color: var(--muted); margin: 0 0 6px; text-transform: uppercase; letter-spacing: .04em; }

/* ---------- Splash ---------- */
.splash { position: fixed; inset: 0; background:
  radial-gradient(120% 80% at 50% -10%, #0B3452 0%, var(--bg) 62%);
  display: flex; align-items: center; justify-content: center; z-index: 90;
  transition: opacity .5s ease, transform .5s ease; }
.splash.leaving { opacity: 0; transform: translateY(-24px); }
.splash-inner { text-align: center; padding: 24px; width: 100%; max-width: 340px; }
.splash-inner > * { animation: dropIn 1s cubic-bezier(.16,.9,.3,1) both; }
.splash-inner > *:nth-child(1) { animation-delay: .05s; }
.splash-inner > *:nth-child(2) { animation-delay: .35s; }
.splash-inner > *:nth-child(3) { animation-delay: .65s; }
.splash-inner > *:nth-child(4) { animation-delay: .95s; }
.splash-inner > *:nth-child(5) { animation-delay: 1.15s; }
@keyframes dropIn { from { opacity: 0; transform: translateY(-70px) scale(.94); filter: blur(6px); }
  to { opacity: 1; transform: none; filter: none; } }
.splash-logo { width: 174px; height: 174px; margin: 0 auto 18px; border-radius: 50%; overflow: hidden; border: 5px solid var(--gold); background: var(--card); box-shadow: 0 0 0 5px rgba(19,200,255,.16), 0 18px 54px rgba(0,0,0,.5); }
.splash-logo img { display: block; width: 100%; height: 100%; object-fit: cover; animation: splashFloat 2.4s ease-in-out .9s infinite; }
@keyframes splashFloat { 0%,100% { transform: scale(1); } 50% { transform: scale(1.035); } }
.splash-title { margin: 0; font-size: 30px; font-weight: 800; letter-spacing: -.02em; }
.splash-tag { color: var(--muted); margin: 6px 0 22px; font-size: 13px; letter-spacing: .12em; text-transform: uppercase; }
.splash-bar { height: 5px; background: var(--card-2); border-radius: 99px; overflow: hidden; }
.splash-bar span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent-dark), var(--accent-2)); transition: width .3s linear; }
.splash-tip { color: var(--muted); font-size: 13px; margin-top: 14px; min-height: 20px; }
.splash-error { margin-top: 16px; color: var(--danger); }

@keyframes swing { 0%,100% { transform: rotate(-14deg);} 50% { transform: rotate(16deg);} }

/* ---------- Shell ---------- */
.shell { display: flex; flex-direction: column; min-height: 100vh; }
.view { flex: 1; padding: 12px 14px calc(86px + var(--safe-b)); }

/* ---------- Header ---------- */
.header {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; background: rgba(6,19,33,.92); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.avatar { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; background: var(--card-2);
  display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--accent-2); flex: 0 0 auto; }
.hd-name { font-weight: 700; font-size: 14px; display: flex; align-items: center; gap: 6px; }
.hd-sub { font-size: 11px; color: var(--muted); }
.hd-pills { margin-left: auto; display: flex; gap: 6px; }
.pill { display: flex; align-items: center; gap: 5px; background: var(--card); border: 1px solid var(--line);
  border-radius: 99px; padding: 6px 11px; font-size: 13px; font-weight: 700; }
.pill.points i { color: var(--gold); }
.pill.gems i { color: var(--gem); }
.badge-vip { background: linear-gradient(90deg, #FFC107, #FF8F00); color: #221a00; font-size: 9px;
  font-weight: 800; padding: 2px 6px; border-radius: 5px; letter-spacing: .06em; }

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: flex; background: rgba(11,29,45,.96); backdrop-filter: blur(14px);
  border-top: 1px solid var(--line); padding-bottom: var(--safe-b);
}
.tabbar button {
  flex: 1; background: none; border: 0; color: var(--muted);
  padding: 9px 2px 8px; font-size: 10px; display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.tabbar button i { font-size: 17px; }
.tabbar button.active { color: var(--accent-2); }
.tabbar button.active i { transform: translateY(-1px); }

/* ---------- Cards & type ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.card.tight { padding: 12px; }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin: 18px 4px 8px; font-weight: 700; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.big { font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.center { text-align: center; }
.empty { text-align: center; color: var(--muted); padding: 26px 10px; font-size: 13px; }
.empty i { display: block; font-size: 26px; margin-bottom: 8px; opacity: .5; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0;
  border-radius: var(--radius-sm); padding: 13px 16px; font-size: 15px; font-weight: 700; color: var(--text);
  background: var(--card-2); cursor: pointer; transition: transform .08s ease, opacity .15s ease; }
.btn:active { transform: scale(.97); }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn-block { width: 100%; }
.btn-primary { background: linear-gradient(180deg, var(--accent-2), var(--accent-dark)); color: #03131F; }
.btn-gold { background: linear-gradient(180deg, #FFD24D, #F0A500); color: #241900; }
.btn-gem { background: linear-gradient(180deg, #26C6DA, #0097A7); color: #012027; }
.btn-ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
.btn-danger { background: var(--danger); }
.btn-sm { padding: 8px 12px; font-size: 13px; border-radius: 9px; }
.btn-pulse { animation: pulse 1.5s ease-in-out infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(14,165,233,.55);} 50% { box-shadow: 0 0 0 14px rgba(14,165,233,0);} }

/* ---------- Pills / chips ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: 0 0 auto; background: var(--card); border: 1px solid var(--line); color: var(--muted);
  border-radius: 99px; padding: 8px 14px; font-size: 13px; font-weight: 600; }
.chip.active { background: var(--accent-dark); border-color: var(--accent); color: #fff; }
.tag { font-size: 10px; font-weight: 800; padding: 3px 7px; border-radius: 6px; letter-spacing: .04em; text-transform: uppercase; }
.tag-green { background: rgba(14,165,233,.18); color: var(--accent-2); }
.tag-orange { background: rgba(251,140,0,.18); color: var(--warn); }
.tag-gem { background: rgba(0,188,212,.16); color: var(--gem); }
.tag-grey { background: rgba(255,255,255,.07); color: var(--muted); }
.tag-red { background: rgba(229,57,53,.18); color: #EF5350; }

/* ---------- Progress ---------- */
.bar { height: 8px; background: var(--card-2); border-radius: 99px; overflow: hidden; }
.bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent-dark), var(--accent-2)); border-radius: 99px; transition: width .4s ease; }

/* ---------- Mining rig ---------- */
.rig { position: relative; height: 168px; border-radius: var(--radius); overflow: hidden;
  background: radial-gradient(120% 90% at 50% 0%, #0B2D49 0%, #101214 70%); display: flex; align-items: center; justify-content: center; }
.rig .gear { position: absolute; color: #17445E; }
.rig .gear.g1 { font-size: 66px; left: 16px; bottom: 12px; animation: spin 6s linear infinite; }
.rig .gear.g2 { font-size: 44px; right: 22px; top: 18px; animation: spin 4s linear infinite reverse; }
.rig .core { font-size: 62px; color: var(--accent); filter: drop-shadow(0 0 18px rgba(14,165,233,.5)); }
.rig.active .core { animation: swing .8s ease-in-out infinite; }
.rig.ready .core { color: var(--gem); animation: bounce 1s ease-in-out infinite; }
.rig .sparks { position: absolute; inset: 0; background:
  radial-gradient(2px 2px at 30% 60%, rgba(255,193,7,.8), transparent),
  radial-gradient(2px 2px at 65% 40%, rgba(56,213,255,.8), transparent),
  radial-gradient(2px 2px at 50% 75%, rgba(0,188,212,.7), transparent);
  animation: flicker 1.6s steps(3) infinite; opacity: .8; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes bounce { 0%,100% { transform: translateY(0);} 50% { transform: translateY(-8px);} }
@keyframes flicker { 0%,100% { opacity: .25;} 50% { opacity: .85;} }

.timer { font-variant-numeric: tabular-nums; font-size: 34px; font-weight: 800; letter-spacing: -.02em; }

/* ---------- Slider ---------- */
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 26px; background: transparent; padding: 0; border: 0; }
input[type=range]::-webkit-slider-runnable-track { height: 8px; background: var(--card-2); border-radius: 99px; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 26px; height: 26px; margin-top: -9px;
  border-radius: 50%; background: radial-gradient(circle at 35% 30%, #B9F6CA, var(--accent-2) 60%);
  border: 3px solid #061827; box-shadow: 0 0 0 0 rgba(56,213,255,.55), 0 0 18px 4px rgba(56,213,255,.75);
  animation: thumbGlow 1.6s ease-in-out infinite; cursor: grab; }
input[type=range]:active::-webkit-slider-thumb { animation: none; box-shadow: 0 0 22px 8px rgba(56,213,255,.85); cursor: grabbing; }
@keyframes thumbGlow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(56,213,255,.55), 0 0 14px 3px rgba(56,213,255,.6); }
  50%      { box-shadow: 0 0 0 10px rgba(56,213,255,0), 0 0 26px 8px rgba(56,213,255,.95); }
}
.range-hint { display: flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 12px; color: var(--accent-2); margin-top: 4px; }
.range-hint i { animation: nudge 1.4s ease-in-out infinite; }
@keyframes nudge { 0%,100% { transform: translateX(-4px);} 50% { transform: translateX(4px);} }
input[type=range]::-moz-range-track { height: 8px; background: var(--card-2); border-radius: 99px; }
input[type=range]::-moz-range-thumb { width: 24px; height: 24px; border-radius: 50%; background: var(--accent-2);
  border: 3px solid #061827; box-shadow: 0 0 18px 4px rgba(56,213,255,.8); }

/* ---------- Wheel ---------- */
.wheel-wrap { position: relative; width: 268px; max-width: 82vw; margin: 6px auto 12px; }
.wheel-wrap canvas { width: 100%; height: auto; display: block; border-radius: 50%;
  border: 6px solid #202428; box-shadow: 0 0 0 3px #0c0d0f, var(--shadow); }
.wheel-pin { position: absolute; top: -6px; left: 50%; transform: translateX(-50%); color: var(--gold); font-size: 26px; z-index: 2;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,.6)); }
.wheel-hub { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); width: 54px; height: 54px;
  border-radius: 50%; background: var(--card); border: 3px solid #2a2f34; display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: var(--accent-2); }
#wheelCanvas { transition: transform 4s cubic-bezier(0.17,0.67,0.12,0.99); }

/* ---------- Streak ---------- */
.streak { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.streak div { background: var(--card-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 2px; text-align: center; font-size: 10px; color: var(--muted); }
.streak div.done { background: rgba(14,165,233,.16); border-color: var(--accent-dark); color: var(--accent-2); }
.streak div.today { border-color: var(--gold); color: var(--gold); }
.streak b { display: block; font-size: 12px; color: inherit; }

/* ---------- Lists ---------- */
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.icon-circle { width: 40px; height: 40px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
  background: var(--card-2); color: var(--accent-2); flex: 0 0 auto; font-size: 16px; }
.icon-circle.orange { color: var(--warn); }
.icon-circle.gold { color: var(--gold); }
.icon-circle.gem { color: var(--gem); }
.flex1 { flex: 1; min-width: 0; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.rank { width: 26px; text-align: center; font-weight: 800; color: var(--muted); }
.rank.top1 { color: #FFD54F; } .rank.top2 { color: #CFD8DC; } .rank.top3 { color: #D7A06A; }

/* ---------- Modal & toast ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.72); display: flex; align-items: flex-end; justify-content: center; z-index: 80; }
.modal { width: 100%; max-width: 520px; background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: 20px 20px 0 0; padding: 18px 16px calc(20px + var(--safe-b)); animation: up .22s ease; max-height: 88vh; overflow-y: auto; }
@keyframes up { from { transform: translateY(24px); opacity: .4; } to { transform: none; opacity: 1; } }
.modal h3 { margin: 0 0 4px; font-size: 18px; }
.modal-close { position: absolute; }
.toast-root { position: fixed; left: 0; right: 0; bottom: calc(94px + var(--safe-b)); z-index: 99; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { background: #22262B; border: 1px solid var(--line); color: var(--text); padding: 10px 16px; border-radius: 99px;
  font-size: 13px; box-shadow: var(--shadow); animation: up .2s ease; max-width: 90vw; }
.toast.ok { border-color: var(--accent-dark); }
.toast.err { border-color: #6d2b2a; }

/* ---------- Gem shower ---------- */
.gem-shower { position: fixed; inset: 0; pointer-events: none; z-index: 95; overflow: hidden; }
.gem-shower i { position: absolute; top: -30px; color: var(--gem); font-size: 20px; animation: fall 1.5s linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(360deg); opacity: .2; } }

/* ---------- Admin ---------- */
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; }
.stat b { display: block; font-size: 19px; }
.stat span { font-size: 11px; color: var(--muted); }
.table { width: 100%; border-collapse: collapse; font-size: 12px; }
.table th, .table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { color: var(--muted); font-weight: 600; text-transform: uppercase; font-size: 10px; letter-spacing: .06em; }
.scroll-x { overflow-x: auto; }
.field { margin-bottom: 10px; }

/* ---------- Admin icon picker ---------- */
.icon-preview { display: flex; align-items: center; gap: 10px; background: var(--card-2);
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 8px; }
.icon-preview i { font-size: 20px; color: var(--accent-2); width: 24px; text-align: center; }
.icon-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px;
  max-height: 190px; overflow-y: auto; padding: 8px; background: var(--card-2);
  border: 1px solid var(--line); border-radius: var(--radius-sm); }
.icon-opt { height: 42px; border-radius: 10px; border: 1px solid transparent; background: var(--card);
  color: var(--muted); font-size: 16px; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.icon-opt:active { transform: scale(.94); }
.icon-opt.active { background: rgba(14,165,233,.18); border-color: var(--accent); color: var(--accent-2); }
