* { margin:0; padding:0; box-sizing:border-box; -webkit-tap-highlight-color:transparent; }
html,body { width:100%; height:100%; overflow-x:hidden; }
body {
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Arial,sans-serif;
  background:radial-gradient(ellipse at center, #1a1f4b 0%, #0a0e27 60%, #050717 100%);
  color:#fff;
}

.screen { display:none; min-height:100vh; }
.screen.active { display:flex; flex-direction:column; }

/* ===== Auth ===== */
#auth-screen { align-items:center; justify-content:center; padding:20px; }
.auth-box {
  width:100%; max-width:380px;
  background:rgba(20,25,60,0.95);
  border:1px solid rgba(100,120,255,0.25);
  border-radius:24px; padding:36px 28px;
  box-shadow:0 0 60px rgba(60,80,200,0.2);
  text-align:center;
}
.auth-box h1 {
  font-size:42px; font-weight:800; letter-spacing:2px;
  background:linear-gradient(180deg,#ffd700,#ff8c00);
  -webkit-background-clip:text; -webkit-text-fill-color:transparent;
  margin-bottom:6px;
}
.auth-box > p { color:#8b92b9; font-size:14px; margin-bottom:28px; }
.tabs { display:flex; gap:10px; margin-bottom:20px; }
.tab-btn {
  flex:1; padding:12px; border-radius:12px; border:none;
  background:rgba(255,255,255,0.06); color:#8b92b9; font-size:15px; cursor:pointer;
}
.tab-btn.active { background:linear-gradient(90deg,#4a5af8,#8b5cf6); color:#fff; }
.tab-content { display:none; }
.tab-content.active { display:block; }
.tab-content input {
  width:100%; padding:14px 16px; margin-bottom:14px; border-radius:12px;
  border:1px solid rgba(255,255,255,0.1); background:rgba(0,0,0,0.25);
  color:#fff; font-size:15px; outline:none;
}
.tab-content input:focus { border-color:rgba(100,120,255,0.5); }
.btn-primary {
  width:100%; padding:15px; border-radius:14px; border:none;
  background:linear-gradient(90deg,#ffd700,#ff8c00); color:#1a1f4b;
  font-size:17px; font-weight:700; cursor:pointer;
}
#auth-msg { margin-top:14px; color:#ff5a5a; font-size:13px; min-height:18px; }

/* ===== Game Header ===== */
.game-header {
  display:flex; align-items:center; justify-content:space-between;
  padding:12px 16px; background:rgba(0,0,0,0.25); backdrop-filter:blur(8px);
  position:sticky; top:0; z-index:50;
}
.header-left { display:flex; align-items:center; gap:8px; }
#user-info { font-size:13px; color:#ffd700; font-weight:600; }
.btn-recharge {
  padding:5px 12px; border-radius:10px; border:none;
  background:linear-gradient(90deg,#ffd700,#ff8c00); color:#1a1f4b;
  font-size:12px; font-weight:700; cursor:pointer;
}
.btn-logout {
  padding:5px 12px; border-radius:10px; border:1px solid rgba(255,255,255,0.15);
  background:rgba(255,255,255,0.06); color:#8b92b9;
  font-size:12px; cursor:pointer;
}
.header-title { font-size:20px; font-weight:800; letter-spacing:3px; color:#ffd700; }

.sub-header {
  display:flex; justify-content:space-between; align-items:center;
  padding:10px 16px;
}
.rules-link { font-size:13px; color:#6b7fd7; cursor:pointer; }
.jackpot { font-size:13px; color:#ff5a5a; font-weight:700; }

/* ===== Game Main ===== */
.game-main { flex:1; display:flex; flex-direction:column; align-items:center; padding:10px 0 20px; }
.round-info { text-align:center; margin-bottom:16px; }
#round-number { font-size:13px; color:#8b92b9; margin-bottom:4px; }
#countdown { font-size:26px; font-weight:800; color:#ffd700; font-family:monospace; letter-spacing:2px; }

/* Compass */
.compass-area { width:100%; max-width:400px; display:flex; justify-content:center; padding:10px 0; }
.compass-ring {
  position:relative; width:320px; height:320px;
  border-radius:50%;
  border:1px solid rgba(255,215,0,0.12);
  background:radial-gradient(circle, rgba(30,40,100,0.3) 0%, transparent 70%);
}
.center-display {
  position:absolute; top:50%; left:50%; transform:translate(-50%,-50%);
  width:110px; height:110px; border-radius:50%;
  background:radial-gradient(circle, rgba(20,30,80,0.9) 0%, rgba(10,15,40,0.95) 100%);
  border:2px solid rgba(255,215,0,0.35);
  display:flex; flex-direction:column; align-items:center; justify-content:center;
  box-shadow:0 0 30px rgba(255,215,0,0.15);
  z-index:10;
}
.center-label { font-size:11px; color:#8b92b9; margin-bottom:3px; }
.center-timer { font-size:20px; font-weight:800; color:#ffd700; font-family:monospace; }

/* Element nodes */
.element-node {
  position:absolute; width:72px; height:72px; border-radius:50%;
  display:flex; flex-direction:column; align-items:center; justify-content:center;
  cursor:pointer; z-index:20;
  transition:transform .2s;
}
.element-node:active { transform:scale(0.92); }
.node-glow {
  position:absolute; width:100%; height:100%; border-radius:50%;
  filter:blur(12px); opacity:0.55; z-index:0;
}
.node-circle {
  position:relative; z-index:2;
  width:60px; height:60px; border-radius:50%;
  background:rgba(0,0,0,0.45);
  display:flex; align-items:center; justify-content:center;
  border:2.5px solid; box-shadow:0 0 20px rgba(0,0,0,0.4);
}
.node-text { font-size:28px; font-weight:800; color:#fff; }
.node-amount {
  position:absolute; bottom:-16px; left:50%; transform:translateX(-50%);
  font-size:11px; font-weight:700; color:#ffd700; white-space:nowrap;
  text-shadow:0 1px 3px rgba(0,0,0,0.8);
}

/* Positions - exact clock positions */
.wood-node { top:8px; left:50%; transform:translateX(-50%); }
.wood-node .node-glow { background:#00e676; box-shadow:0 0 30px #00e676; }
.wood-node .node-circle { border-color:#00e676; }

.fire-node { top:22%; right:6px; }
.fire-node .node-glow { background:#ff5722; box-shadow:0 0 30px #ff5722; }
.fire-node .node-circle { border-color:#ff5722; }

.earth-node { bottom:12%; right:18%; }
.earth-node .node-glow { background:#d4a574; box-shadow:0 0 30px #d4a574; }
.earth-node .node-circle { border-color:#d4a574; }

.metal-node { bottom:12%; left:18%; }
.metal-node .node-glow { background:#e0e0e0; box-shadow:0 0 30px #e0e0e0; }
.metal-node .node-circle { border-color:#e0e0e0; }

.water-node { top:22%; left:6px; }
.water-node .node-glow { background:#00b0ff; box-shadow:0 0 30px #00b0ff; }
.water-node .node-circle { border-color:#00b0ff; }

/* Active bet ring */
.element-node.has-bet .node-circle { box-shadow:0 0 0 3px rgba(255,215,0,0.4), 0 0 20px rgba(0,0,0,0.4); }
.element-node.top-bet .node-circle::after {
  content:""; position:absolute; inset:-6px; border-radius:50%;
  border:2px dashed rgba(255,215,0,0.6); animation:spin 6s linear infinite;
}
@keyframes spin { to { transform:rotate(360deg); } }

.my-bets-bar {
  margin-top:14px; padding:0 16px; width:100%; max-width:400px;
  display:flex; flex-wrap:wrap; gap:8px; justify-content:center;
  min-height:24px;
}
.my-bet-tag {
  padding:5px 12px; border-radius:20px; font-size:12px; font-weight:600;
  background:rgba(255,215,0,0.12); border:1px solid rgba(255,215,0,0.3); color:#ffd700;
}

/* ===== History ===== */
.history-area { padding:16px; width:100%; max-width:500px; margin:0 auto; }
.history-title { font-size:15px; color:#8b92b9; margin-bottom:12px; font-weight:600; }
.history-item {
  display:flex; align-items:center; justify-content:space-between;
  padding:12px 14px; background:rgba(255,255,255,0.04);
  border-radius:12px; margin-bottom:10px; border:1px solid rgba(255,255,255,0.06);
}
.history-meta { display:flex; flex-direction:column; }
.history-round { font-size:13px; color:#c5cae9; font-weight:600; }
.history-time { font-size:11px; color:#6b7394; margin-top:2px; }
.history-winner { display:flex; align-items:center; gap:8px; }
.winner-badge {
  width:30px; height:30px; border-radius:50%; display:flex;
  align-items:center; justify-content:center; font-size:15px; font-weight:800;
}

/* ===== Bottom Sheet ===== */
.bottom-sheet {
  position:fixed; inset:0; z-index:100; display:none; flex-direction:column; justify-content:flex-end;
  background:rgba(0,0,0,0.6); backdrop-filter:blur(4px);
}
.bottom-sheet.active { display:flex; }
.sheet-content {
  background:linear-gradient(180deg,#1a1f4b 0%,#0d1137 100%);
  border-radius:24px 24px 0 0;
  padding:12px 20px 28px; width:100%; max-width:500px; margin:0 auto;
  border-top:1px solid rgba(100,120,255,0.25);
  animation:slideUp .25s ease-out;
}
@keyframes slideUp { from { transform:translateY(100%); } to { transform:translateY(0); } }
.sheet-header { display:flex; align-items:center; justify-content:space-between; margin-bottom:16px; position:relative; }
.sheet-drag {
  position:absolute; top:-4px; left:50%; transform:translateX(-50%);
  width:40px; height:4px; border-radius:2px; background:rgba(255,255,255,0.2);
}
.sheet-header h3 { font-size:18px; color:#fff; }
.sheet-close { font-size:28px; color:#8b92b9; background:none; border:none; cursor:pointer; }

.sheet-body { display:flex; flex-direction:column; gap:14px; }
.selected-display {
  width:64px; height:64px; border-radius:50%; margin:0 auto;
  display:flex; align-items:center; justify-content:center;
  font-size:28px; font-weight:800; border:2px solid;
}
.avail-line { text-align:center; font-size:13px; color:#8b92b9; }
.avail-line span { color:#ffd700; font-weight:700; }

.input-row { display:flex; align-items:center; gap:12px; }
.btn-minus,.btn-plus {
  width:46px; height:46px; border-radius:50%; border:none;
  background:rgba(100,80,200,0.35); color:#fff; font-size:22px; cursor:pointer;
}
.amount-input-wrap {
  flex:1; display:flex; align-items:center; gap:8px;
  background:rgba(0,0,0,0.3); border:1px solid rgba(255,215,0,0.25);
  border-radius:14px; padding:10px 14px;
}
.f-mark {
  width:24px; height:24px; border-radius:50%;
  background:linear-gradient(135deg,#ffd700,#ff8c00); color:#1a1f4b;
  display:flex; align-items:center; justify-content:center;
  font-weight:800; font-size:13px;
}
.amount-input-wrap input {
  flex:1; background:transparent; border:none; color:#ffd700;
  font-size:22px; font-weight:800; outline:none; width:100%;
}
.quick-row { display:grid; grid-template-columns:repeat(4,1fr); gap:8px; }
.quick-row button {
  padding:12px; border-radius:10px; border:none;
  background:rgba(100,80,200,0.25); color:#fff; font-size:13px; cursor:pointer;
}
.quick-row button:hover { background:rgba(100,80,200,0.45); }
.btn-confirm-bet {
  width:100%; padding:16px; border-radius:14px; border:none;
  background:linear-gradient(90deg,#ffd700,#ff8c00); color:#1a1f4b;
  font-size:18px; font-weight:800; cursor:pointer; margin-top:4px;
}

/* ===== Rules Modal ===== */
.modal-overlay {
  position:fixed; inset:0; z-index:100; display:none; align-items:center; justify-content:center;
  background:rgba(0,0,0,0.7); backdrop-filter:blur(6px); padding:16px;
}
.modal-overlay.active { display:flex; }
.modal-box {
  background:linear-gradient(180deg,#1a1f4b 0%,#0d1137 100%);
  border:1px solid rgba(100,120,255,0.25); border-radius:20px;
  width:100%; max-width:420px; max-height:85vh; overflow:hidden;
  display:flex; flex-direction:column;
}
.modal-head {
  display:flex; align-items:center; justify-content:space-between;
  padding:16px 20px; border-bottom:1px solid rgba(255,255,255,0.06);
}
.modal-head h3 { font-size:18px; }
.modal-close { font-size:26px; color:#8b92b9; background:none; border:none; cursor:pointer; }
.modal-body { padding:16px 20px; overflow-y:auto; flex:1; }
.modal-body h4 { font-size:14px; color:#ffd700; margin:14px 0 6px; }
.modal-body p { font-size:13px; color:#b0b8d9; line-height:1.6; }
.ratio-grid { display:grid; grid-template-columns:1fr 1fr; gap:6px 16px; margin:8px 0; }
.ratio-grid span { font-size:13px; color:#b0b8d9; }
.ratio-grid span:nth-child(odd) { color:#ffd700; }
.btn-modal-ok {
  width:calc(100% - 40px); margin:0 20px 20px; padding:14px; border-radius:12px; border:none;
  background:linear-gradient(90deg,#ffd700,#ff8c00); color:#1a1f4b;
  font-size:16px; font-weight:800; cursor:pointer;
}

@media (max-width:380px) {
  .compass-ring { width:280px; height:280px; }
  .element-node { width:64px; height:64px; }
  .node-circle { width:54px; height:54px; }
  .node-text { font-size:24px; }
}

/* ===== Wallet Auth Styles ===== */
.auth-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 40px 32px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 24px;
  max-width: 360px;
  margin: auto;
  backdrop-filter: blur(20px);
}

.auth-logo {
  font-size: 48px;
  font-weight: 900;
  letter-spacing: 4px;
  background: linear-gradient(135deg, #e0c050, #00e676, #00b0ff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.auth-subtitle {
  font-size: 16px;
  color: #c0c8e8;
  letter-spacing: 2px;
}

.auth-desc {
  font-size: 13px;
  color: #7880a0;
  text-align: center;
  line-height: 1.8;
}

.btn-wallet {
  width: 100%;
  padding: 16px 24px;
  background: linear-gradient(135deg, #3b4fd8, #6c3fc5);
  color: #fff;
  border: none;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: opacity 0.2s, transform 0.1s;
  margin-top: 8px;
}

.btn-wallet:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-wallet:active { transform: translateY(0); opacity: 0.8; }

.auth-msg {
  font-size: 13px;
  color: #f0a040;
  text-align: center;
  min-height: 20px;
}

.auth-hint {
  font-size: 12px;
  color: #505878;
}
