:root {
  --bg: #120b08;
  --panel: rgba(28, 17, 12, 0.82);
  --panel-edge: rgba(242, 196, 109, 0.22);
  --gold: #f2c46d;
  --gold-2: #d9933d;
  --cream: #f6eedf;
  --muted: #b9a68c;
  --felt: #1aa463;
  --bad: #ff5d6c;
  --font: "Avenir Next", "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--cream); font-family: var(--font); }
body { user-select: none; -webkit-user-select: none; touch-action: none; }
#app { position: fixed; inset: 0; }
#gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.hidden { display: none !important; }
button { font-family: inherit; color: inherit; cursor: pointer; }
kbd { display: inline-block; min-width: 1.5em; padding: 0 0.35em; margin: 0 1px; border-radius: 5px; border: 1px solid rgba(255,255,255,0.25); border-bottom-width: 2px; font: 600 0.78em var(--font); text-align: center; background: rgba(255,255,255,0.06); }

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0; pointer-events: none; }
#hud > * { pointer-events: auto; }
.topbar { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); width: min(980px, calc(100% - 132px)); display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; pointer-events: none; }
.pcard { display: flex; align-items: center; gap: 10px; padding: 7px 12px 7px 7px; border-radius: 16px; background: var(--panel); border: 1px solid rgba(255,255,255,0.08); box-shadow: 0 6px 20px rgba(0,0,0,0.35); transition: box-shadow .3s, border-color .3s, transform .3s, opacity .3s; opacity: 0.72; min-width: 0; backdrop-filter: blur(6px); }
.pcard.right { flex-direction: row-reverse; padding: 7px 7px 7px 12px; text-align: right; }
.pcard.active { opacity: 1; border-color: var(--gold); box-shadow: 0 0 0 1px rgba(242,196,109,0.35), 0 0 26px rgba(242,196,109,0.28), 0 6px 20px rgba(0,0,0,0.4); transform: translateY(1px); }
.avatar { flex: 0 0 auto; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 17px; color: #1b100a; background: radial-gradient(circle at 35% 30%, #fff3d4, var(--gold) 45%, var(--gold-2)); box-shadow: inset 0 -3px 6px rgba(0,0,0,0.25); }
.pcard.ai .avatar { background: radial-gradient(circle at 35% 30%, #d8f3ff, #5fb5e6 45%, #2a6f9e); }
.pinfo { min-width: 0; }
.pname { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pname small { font-weight: 600; color: var(--muted); margin-left: 6px; font-size: 11px; letter-spacing: .04em; text-transform: uppercase; }
.pcard.right .pname small { margin: 0 6px 0 0; }
.tray { display: flex; gap: 3px; margin-top: 4px; }
.pcard.right .tray { justify-content: flex-end; }
.mini { width: 15px; height: 15px; border-radius: 50%; position: relative; display: grid; place-items: center; font-size: 8px; font-weight: 800; color: #111; box-shadow: inset -2px -2px 3px rgba(0,0,0,0.35), 0 1px 2px rgba(0,0,0,0.4); overflow: hidden; transition: opacity .3s, transform .3s; }
.mini::after { content: ""; position: absolute; left: 3px; top: 2px; width: 5px; height: 4px; border-radius: 50%; background: rgba(255,255,255,0.55); }
.mini i { position: relative; z-index: 1; width: 9px; height: 9px; border-radius: 50%; background: #f6f1e3; display: grid; place-items: center; font-style: normal; line-height: 1; }
.mini.gone { opacity: 0.18; transform: scale(0.85); }
.mini.empty { background: rgba(255,255,255,0.1); box-shadow: inset 0 0 0 1px rgba(255,255,255,0.12); }
.mini.empty::after { display: none; }
.status { padding: 8px 16px; border-radius: 999px; background: var(--panel); border: 1px solid var(--panel-edge); font-weight: 700; font-size: 13px; letter-spacing: .05em; text-transform: uppercase; white-space: nowrap; color: var(--gold); box-shadow: 0 6px 20px rgba(0,0,0,0.35); }

.corner-btns { position: absolute; top: 12px; right: 12px; display: flex; gap: 8px; flex-direction: column; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: 1px solid rgba(255,255,255,0.1); background: var(--panel); display: grid; place-items: center; padding: 0; color: var(--cream); transition: transform .15s, background .2s; }
.icon-btn:hover { background: rgba(60,38,26,0.9); }
.icon-btn:active { transform: scale(0.93); }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn .snd-off { display: none; }
.icon-btn.muted .snd-on { display: none; }
.icon-btn.muted .snd-off { display: block; }

#power { position: absolute; left: 14px; top: 50%; transform: translateY(-40%); width: 54px; height: min(330px, 58vh); display: flex; flex-direction: column; align-items: center; gap: 6px; touch-action: none; }
.ptrack { position: relative; flex: 1; width: 34px; border-radius: 17px; background: linear-gradient(180deg, rgba(0,0,0,0.6), rgba(30,18,12,0.85)); border: 1px solid rgba(255,255,255,0.12); overflow: hidden; box-shadow: inset 0 2px 10px rgba(0,0,0,0.6), 0 6px 20px rgba(0,0,0,0.35); cursor: ns-resize; }
.pfill { position: absolute; left: 0; right: 0; top: 0; height: 0%; background: linear-gradient(180deg, #ffe08a, #ff9f43 55%, #ff4d5e); opacity: 0.9; transition: height .05s linear; }
.pcue { position: absolute; left: 50%; width: 10px; margin-left: -5px; top: 6px; height: 160%; border-radius: 5px 5px 0 0; background: linear-gradient(180deg, #2d6fb0 0 6px, #f5f1e6 6px 16px, #e8cf9f 16px 55%, #2a1408 55% 70%, #1b1b1f 70%); box-shadow: 0 2px 6px rgba(0,0,0,0.5); transition: transform .05s linear; }
.plabel { font-size: 10px; font-weight: 800; letter-spacing: .14em; color: var(--muted); }
#power.disabled, #spinBtn.disabled { opacity: 0.35; pointer-events: none; }

#spinBtn { position: absolute; right: 14px; bottom: 14px; display: flex; flex-direction: column; align-items: center; gap: 4px; border: none; background: none; padding: 0; }
.sball { position: relative; width: 58px; height: 58px; border-radius: 50%; background: radial-gradient(circle at 36% 30%, #fff, #f1ead8 45%, #bdb39c 100%); box-shadow: 0 6px 18px rgba(0,0,0,0.5), 0 0 0 3px rgba(255,255,255,0.08); }
.sdot { position: absolute; left: 50%; top: 50%; width: 12px; height: 12px; margin: -6px; border-radius: 50%; background: var(--bad); box-shadow: 0 0 8px rgba(255,77,94,0.8); }
.slabel { font-size: 10px; font-weight: 800; letter-spacing: .14em; color: var(--muted); }
#spinPanel { position: absolute; right: 14px; bottom: 96px; width: 230px; padding: 16px; border-radius: 20px; background: var(--panel); border: 1px solid var(--panel-edge); box-shadow: 0 16px 40px rgba(0,0,0,0.5); backdrop-filter: blur(8px); text-align: center; }
.spbig { position: relative; width: 170px; height: 170px; margin: 0 auto; border-radius: 50%; background: radial-gradient(circle at 36% 30%, #fff, #f1ead8 45%, #b0a68e 100%); box-shadow: inset -8px -10px 24px rgba(0,0,0,0.25), 0 8px 22px rgba(0,0,0,0.5); cursor: crosshair; touch-action: none; }
.spcross { position: absolute; inset: 0; border-radius: 50%; background: linear-gradient(90deg, transparent calc(50% - 0.5px), rgba(0,0,0,0.18) calc(50% - 0.5px) calc(50% + 0.5px), transparent calc(50% + 0.5px)), linear-gradient(0deg, transparent calc(50% - 0.5px), rgba(0,0,0,0.18) calc(50% - 0.5px) calc(50% + 0.5px), transparent calc(50% + 0.5px)); }
.spcross::after { content: ""; position: absolute; inset: 10%; border-radius: 50%; border: 1px dashed rgba(0,0,0,0.2); }
.spdot { position: absolute; width: 22px; height: 22px; margin: -11px; left: 50%; top: 50%; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #ff9aa4, var(--bad)); box-shadow: 0 0 0 3px rgba(255,255,255,0.7), 0 3px 8px rgba(0,0,0,0.4); pointer-events: none; }
.sphelp { margin: 12px 0 10px; font-size: 12px; color: var(--muted); line-height: 1.4; }
.sprow { display: flex; gap: 8px; justify-content: center; }

#hint { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); padding: 8px 16px; border-radius: 999px; background: rgba(15,9,6,0.7); color: var(--cream); font-size: 13px; font-weight: 600; white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity .3s; max-width: calc(100% - 180px); overflow: hidden; text-overflow: ellipsis; }
#hint.show { opacity: 1; }
#toasts { position: absolute; left: 0; right: 0; top: 38%; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { font-family: var(--serif); font-weight: 700; font-style: italic; font-size: clamp(26px, 5vw, 48px); color: #fff; text-shadow: 0 3px 0 rgba(0,0,0,0.35), 0 0 30px rgba(242,196,109,0.6); animation: toast 1.8s cubic-bezier(.2,.9,.25,1) forwards; white-space: nowrap; }
.toast.sub { font-family: var(--font); font-style: normal; font-size: clamp(14px, 2.4vw, 20px); letter-spacing: .08em; text-transform: uppercase; color: var(--gold); text-shadow: 0 2px 10px rgba(0,0,0,0.6); }
.toast.bad { color: #ffd0d4; text-shadow: 0 3px 0 rgba(0,0,0,0.35), 0 0 30px rgba(255,77,94,0.7); }
@keyframes toast { 0% { opacity: 0; transform: translateY(14px) scale(0.85); } 12% { opacity: 1; transform: translateY(0) scale(1.04); } 20% { transform: scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-16px); } }

/* ---------- Screens ---------- */
.screen { position: absolute; inset: 0; display: flex; padding: 16px; overflow-y: auto; touch-action: pan-y; }
.screen > .panel { margin: auto; }
#title { background: radial-gradient(ellipse at 50% 40%, rgba(18,11,8,0.15), rgba(18,11,8,0.75) 75%); }
#pause, #over { background: rgba(10,6,4,0.55); backdrop-filter: blur(4px); }
.panel { background: var(--panel); border: 1px solid var(--panel-edge); border-radius: 24px; box-shadow: 0 30px 80px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.06); backdrop-filter: blur(10px); padding: 26px 28px; text-align: center; animation: pop .45s cubic-bezier(.2,.9,.25,1.2); }
@keyframes pop { from { opacity: 0; transform: translateY(16px) scale(0.96); } to { opacity: 1; transform: none; } }
.title-panel { width: min(480px, 100%); padding: 20px 24px; }
.small-panel { width: min(360px, 100%); display: flex; flex-direction: column; gap: 10px; }
.logo { display: flex; flex-direction: column; align-items: center; }
.logo-ball { width: 50px; height: 50px; border-radius: 50%; display: grid; place-items: center; background: radial-gradient(circle at 34% 28%, #6a6a72, #18181b 45%, #000 100%); box-shadow: 0 10px 26px rgba(0,0,0,0.6), inset -6px -8px 16px rgba(0,0,0,0.6); margin-bottom: 6px; animation: spinb 6s ease-in-out infinite; }
.logo-ball span { width: 30px; height: 30px; border-radius: 50%; background: #f6f1e3; color: #111; display: grid; place-items: center; font-weight: 900; font-size: 18px; }
@keyframes spinb { 0%,100% { transform: rotate(-8deg); } 50% { transform: rotate(8deg); } }
h1 { margin: 0; font-family: var(--serif); font-size: clamp(38px, 8vw, 56px); line-height: 1; letter-spacing: -0.01em; background: linear-gradient(180deg, #fff6df, var(--gold) 60%, var(--gold-2)); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 3px 0 rgba(0,0,0,0.35)); }
h1 em { font-style: italic; }
h2 { margin: 0 0 6px; font-family: var(--serif); font-size: 34px; color: var(--gold); }
.tag { margin: 6px 0 16px; color: var(--muted); font-size: 14px; letter-spacing: .02em; }
.modes { display: inline-flex; padding: 4px; border-radius: 999px; background: rgba(0,0,0,0.35); border: 1px solid rgba(255,255,255,0.08); margin-bottom: 10px; }
.mode { border: 0; background: none; padding: 8px 16px; border-radius: 999px; font-weight: 700; font-size: 14px; color: var(--muted); transition: background .2s, color .2s; }
.mode.on { background: var(--cream); color: #20130c; }
.levels { display: flex; gap: 8px; justify-content: center; margin-bottom: 14px; }
.lvl { flex: 1; max-width: 130px; border-radius: 14px; border: 1px solid rgba(255,255,255,0.1); background: rgba(255,255,255,0.04); padding: 8px 6px; display: flex; flex-direction: column; gap: 2px; transition: border-color .2s, background .2s, transform .15s; }
.lvl b { font-size: 15px; }
.lvl small { font-size: 11px; color: var(--muted); }
.lvl.on { border-color: var(--gold); background: rgba(242,196,109,0.12); }
.lvl:active { transform: scale(0.96); }
.btn { border: 0; border-radius: 14px; padding: 12px 20px; font-weight: 800; font-size: 16px; color: #24140a; background: linear-gradient(180deg, #ffe3a0, var(--gold) 50%, var(--gold-2)); box-shadow: 0 6px 0 #8a5a22, 0 12px 24px rgba(0,0,0,0.4); transition: transform .12s, box-shadow .12s, filter .2s; }
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #8a5a22, 0 6px 14px rgba(0,0,0,0.4); }
.btn.big { width: 100%; font-size: 20px; padding: 15px; letter-spacing: .02em; }
.btn.ghost { background: rgba(255,255,255,0.06); color: var(--cream); box-shadow: inset 0 0 0 1px rgba(255,255,255,0.14); }
.btn.ghost:active { transform: scale(0.97); }
.btn.small { padding: 8px 14px; font-size: 13px; border-radius: 10px; box-shadow: 0 3px 0 #8a5a22; }
.btn.small.ghost { box-shadow: inset 0 0 0 1px rgba(255,255,255,0.14); }
.cloths { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 16px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; font-weight: 700; }
#cloths { display: flex; gap: 8px; }
.sw { width: 26px; height: 26px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.2); padding: 0; position: relative; transition: transform .15s; }
.sw.on { border-color: var(--gold); transform: scale(1.12); box-shadow: 0 0 12px rgba(242,196,109,0.5); }
.sw.locked { filter: grayscale(0.7) brightness(0.5); cursor: help; }
.sw.locked::after { content: ""; position: absolute; inset: 7px 8px 6px; border-radius: 2px; background: #d8cbb5; }
.sw.locked::before { content: ""; position: absolute; left: 8px; right: 8px; top: 3px; height: 8px; border: 2px solid #d8cbb5; border-bottom: 0; border-radius: 6px 6px 0 0; }
.streak { margin-top: 10px; font-size: 13px; color: var(--muted); min-height: 1em; }
.howto { margin-top: 14px; text-align: left; font-size: 13px; color: #e5d8c3; background: rgba(0,0,0,0.25); border-radius: 14px; padding: 10px 14px; }
.howto summary { cursor: pointer; font-weight: 800; color: var(--gold); letter-spacing: .06em; text-transform: uppercase; font-size: 12px; }
.howto ul { margin: 8px 0 0; padding-left: 16px; line-height: 1.55; }
.howto b { color: var(--cream); margin-right: 4px; }
.hub-only { display: none; }
.in-hub .hub-only { display: inline-block; }
#btnLeaveTitle { margin-top: 12px; }
.over-kicker { font-size: 12px; font-weight: 800; letter-spacing: .16em; color: var(--muted); text-transform: uppercase; }
.over-reason { margin: 0 0 6px; color: var(--muted); }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 6px 0 8px; }
.stat { background: rgba(0,0,0,0.3); border-radius: 12px; padding: 8px; }
.stat b { display: block; font-size: 22px; color: var(--cream); }
.stat span { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.unlock { padding: 10px; border-radius: 12px; background: linear-gradient(90deg, rgba(242,196,109,0.18), rgba(242,196,109,0.05)); border: 1px solid var(--panel-edge); color: var(--gold); font-weight: 700; font-size: 14px; }

/* ---------- Small / portrait screens ---------- */
@media (max-width: 640px) {
  .topbar { top: 8px; width: calc(100% - 70px); left: 8px; transform: none; grid-template-columns: 1fr 1fr; gap: 6px; }
  .status { grid-column: 1 / -1; grid-row: 2; justify-self: center; padding: 5px 12px; font-size: 11px; }
  .pcard { padding: 5px 8px 5px 5px; gap: 6px; border-radius: 12px; }
  .pcard.right { padding: 5px 5px 5px 8px; }
  .avatar { width: 28px; height: 28px; font-size: 13px; }
  .pname { font-size: 12px; }
  .pname small { display: none; }
  .mini { width: 11px; height: 11px; font-size: 0; }
  .mini i { display: none; }
  .tray { gap: 2px; }
  .corner-btns { top: 8px; right: 8px; }
  .icon-btn { width: 36px; height: 36px; }
  #power { left: 8px; width: 44px; }
  .ptrack { width: 30px; }
  .sball { width: 50px; height: 50px; }
  #hint { bottom: 80px; max-width: calc(100% - 32px); font-size: 12px; }
  .panel { padding: 20px 18px; }
}
@media (max-height: 700px) {
  .screen { flex-direction: column; align-items: center; justify-content: safe center; }
  .screen > .panel { margin: 0 auto; width: min(480px, 100%); }
}
@media (max-height: 760px) {
  .howto ul { line-height: 1.4; font-size: 12px; }
  .tag { margin-bottom: 10px; }
  .cloths { margin-top: 12px; }
}
@media (max-height: 520px) {
  .howto { display: none; }
  .tag { margin-bottom: 8px; }
  .logo-ball { display: none; }
  #power { height: 54vh; }
  #spinPanel { bottom: auto; top: 50%; transform: translateY(-50%); }
  .spbig { width: 130px; height: 130px; }
}
@media (prefers-reduced-motion: reduce) {
  .toast, .panel, .logo-ball { animation-duration: 0.01s; }
  .toast { animation: toast 1.8s linear forwards; }
}
