* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; background: #1a0f2e; font-family: system-ui, -apple-system, sans-serif; color: #fff; touch-action: none; user-select: none; -webkit-user-select: none; }
#game-canvas { position: fixed; inset: 0; width: 100%; height: 100%; touch-action: none; }
.hidden { display: none !important; }
.dim { color: #a99fc9; font-size: 13px; }
.ok { color: #4dff88; }
.center { text-align: center; }

/* HUD */
#topbar { position: fixed; top: max(8px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); display: flex; gap: 10px; align-items: center; background: rgba(20,12,40,.8); border: 1px solid #b15cff55; padding: 8px 16px; border-radius: 20px; z-index: 5; backdrop-filter: blur(6px); }
#cash { font-weight: 800; color: #ffd94d; font-size: 17px; }
#ipm { color: #4dff88; font-size: 13px; font-weight: 600; }
#floor-ind { color: #a99fc9; font-size: 12px; border-left: 1px solid #444; padding-left: 10px; }
#carried { position: fixed; top: max(52px, calc(env(safe-area-inset-top) + 44px)); left: 50%; transform: translateX(-50%); font-size: 15px; z-index: 5; }
#sidebtns { position: fixed; right: 8px; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; gap: 7px; z-index: 5; }
#sidebtns button { position: relative; width: 56px; height: 52px; border-radius: 14px; border: 1px solid #ffffff22; background: rgba(20,12,40,.82); color: #fff; font-size: 20px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
#sidebtns button span { font-size: 8px; letter-spacing: .5px; color: #a99fc9; }
.badge { position: absolute; top: -4px; right: -4px; background: #ff4d6d; border-radius: 50%; width: 18px; height: 18px; font-size: 11px; line-height: 18px; text-align: center; font-weight: 700; }
#tutorial { position: fixed; bottom: 150px; left: 50%; transform: translateX(-50%); max-width: 86vw; background: rgba(20,12,40,.9); border: 1px solid #ffd94d88; padding: 10px 14px; border-radius: 12px; font-size: 13px; z-index: 6; text-align: center; }
#toast { position: fixed; top: 96px; left: 50%; transform: translateX(-50%); background: rgba(20,12,40,.92); border: 1px solid #4dfff355; padding: 9px 16px; border-radius: 14px; font-size: 14px; z-index: 30; max-width: 86vw; text-align: center; }

/* joystick + buttons */
#joystick { position: fixed; left: 18px; bottom: 26px; width: 110px; height: 110px; border-radius: 50%; background: rgba(255,255,255,.07); border: 1px solid #ffffff22; z-index: 5; }
#joy-knob { position: absolute; left: 50%; top: 50%; margin: -22px 0 0 -22px; width: 44px; height: 44px; border-radius: 50%; background: rgba(177,92,255,.55); border: 1px solid #b15cff; }
#jump-btn { position: fixed; right: 18px; bottom: 96px; width: 58px; height: 58px; border-radius: 50%; border: 1px solid #ffffff33; background: rgba(20,12,40,.8); color: #fff; font-size: 24px; z-index: 5; }
#action-btn { position: fixed; right: 16px; bottom: 26px; min-width: 110px; height: 58px; padding: 0 16px; border-radius: 16px; border: 1px solid #ffd94d; background: linear-gradient(160deg,#b15cff,#7a2ee0); color: #fff; font-size: 15px; font-weight: 800; z-index: 5; box-shadow: 0 4px 18px #b15cff66; }

/* panel */
#panel { position: fixed; inset: 0; background: rgba(8,4,18,.72); z-index: 20; display: flex; align-items: flex-end; justify-content: center; backdrop-filter: blur(3px); }
#panel-card { width: 100%; max-width: 560px; max-height: 82vh; background: #191030; border: 1px solid #b15cff44; border-radius: 22px 22px 0 0; display: flex; flex-direction: column; }
#panel-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid #ffffff14; }
#panel-title { font-weight: 800; font-size: 17px; }
#panel-close { background: none; border: none; color: #a99fc9; font-size: 20px; padding: 4px 8px; }
#panel-body { padding: 14px 16px calc(16px + env(safe-area-inset-bottom)); overflow-y: auto; }
#panel-body h2 { margin: 6px 0; }
#panel-body p { margin: 8px 0; font-size: 14px; line-height: 1.45; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid #ffffff0d; }
.row input, .row select { background: #0e0920; color: #fff; border: 1px solid #ffffff2a; border-radius: 8px; padding: 8px; font-size: 14px; }
button.big { width: 100%; padding: 14px; margin-top: 10px; border: none; border-radius: 14px; background: linear-gradient(160deg,#b15cff,#7a2ee0); color: #fff; font-size: 16px; font-weight: 800; }
button.big.warm { background: linear-gradient(160deg,#ff8a3d,#e04d2e); }
button.big:disabled { opacity: .4; }
button.ghost { width: 100%; padding: 11px; margin-top: 8px; border: 1px solid #ffffff2a; border-radius: 12px; background: none; color: #cfd; font-size: 14px; }
button.ghost.small { width: auto; padding: 7px 10px; font-size: 12px; margin: 4px 4px 0 0; color: #a99fc9; }
button.buy { padding: 9px 14px; border: none; border-radius: 10px; background: #2a8a4d; color: #fff; font-weight: 700; font-size: 13px; white-space: nowrap; }
button.buy:disabled { background: #333; color: #777; }
.tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.tabs button { flex: 1; padding: 10px 2px; border-radius: 10px; border: 1px solid #ffffff1e; background: #0e0920; color: #a99fc9; font-size: 11px; font-weight: 700; }
.tabs button.on { background: #b15cff; color: #fff; border-color: #b15cff; }
.ore-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; padding: 4px 0; }
.ore-dot { width: 14px; height: 14px; border-radius: 4px; display: inline-block; box-shadow: 0 0 8px currentColor; }
.chip { font-size: 10px; padding: 2px 7px; border: 1px solid; border-radius: 8px; font-weight: 700; }
.offer { text-align: center; padding: 10px 0; }
.offer-ore { width: 84px; height: 84px; margin: 0 auto 10px; border-radius: 18px; box-shadow: 0 0 30px currentColor; clip-path: polygon(50% 0, 100% 35%, 82% 100%, 18% 100%, 0 35%); }

/* wheel */
.wheel-wrap { position: relative; width: min(78vw, 300px); margin: 4px auto; }
#wheel-cv { width: 100%; height: auto; }
.wheel-ptr { position: absolute; top: -6px; left: 50%; transform: translateX(-50%); width: 0; height: 0; border-left: 12px solid transparent; border-right: 12px solid transparent; border-top: 20px solid #ffd94d; filter: drop-shadow(0 2px 4px #000); }
#spin-result { text-align: center; margin-top: 8px; min-height: 30px; }

/* login / loading */
#login, #loading { position: fixed; inset: 0; background: radial-gradient(120% 100% at 50% 0%, #2a1a4e 0%, #1a0f2e 55%, #0d0718 100%); z-index: 40; display: flex; align-items: center; justify-content: center; }
.login-card, .load-inner { width: min(88vw, 380px); text-align: center; }
.login-card h1, .load-inner h1 { font-size: 30px; letter-spacing: 1px; background: linear-gradient(90deg,#ffd94d,#b15cff,#4dfff3); -webkit-background-clip: text; background-clip: text; color: transparent; }
.tag { color: #a99fc9; font-size: 12px; letter-spacing: 2px; margin: 6px 0 22px; }
.login-card input { width: 100%; padding: 13px; margin: 6px 0; border-radius: 12px; border: 1px solid #ffffff2a; background: #0e0920; color: #fff; font-size: 16px; text-align: center; }
#login-err { color: #ff6a6a; font-size: 13px; min-height: 18px; margin-top: 6px; }
.madeby { margin-top: 26px; color: #6a5f8a; font-size: 12px; letter-spacing: 1px; }
.load-logo { font-size: 54px; animation: pulse 1.4s ease-in-out infinite; }
.load-bar { height: 5px; background: #ffffff18; border-radius: 4px; overflow: hidden; margin-top: 18px; }
.load-bar div { height: 100%; width: 40%; background: linear-gradient(90deg,#b15cff,#4dfff3); border-radius: 4px; animation: slide 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.12); } }
@keyframes slide { 0% { margin-left: -40%; } 100% { margin-left: 100%; } }

/* landscape phones */
@media (orientation: landscape) and (max-height: 500px) {
  #topbar { top: 6px; padding: 5px 12px; font-size: 13px; }
  #sidebtns { right: 6px; gap: 5px; }
  #sidebtns button { width: 50px; height: 44px; font-size: 17px; border-radius: 11px; }
  #sidebtns button span { font-size: 7px; }
  #joystick { width: 92px; height: 92px; left: 14px; bottom: 16px; }
  #joy-knob { width: 38px; height: 38px; margin: -19px 0 0 -19px; }
  #jump-btn { right: 14px; bottom: 78px; width: 50px; height: 50px; }
  #action-btn { right: 12px; bottom: 16px; height: 50px; min-width: 96px; font-size: 13px; }
  #tutorial { bottom: 118px; font-size: 12px; max-width: 60vw; padding: 8px 12px; }
  #panel { align-items: center; justify-content: center; }
  #panel-card { max-width: 480px; max-height: 92vh; border-radius: 18px; }
  .login-card { max-height: 94vh; overflow-y: auto; padding: 18px 20px; }
  .login-card h1 { font-size: 22px; }
  #carried { top: 44px; }
}

/* ore tile art */
.ore-art { width: 30px; height: 30px; border-radius: 8px; flex: 0 0 auto; image-rendering: auto; }
.offer-art { width: 110px; height: 110px; border-radius: 18px; margin: 4px auto 8px; display: block; filter: drop-shadow(0 4px 14px rgba(0,0,0,.5)); }
