* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #1a0f2e; color: #fff; font-family: "Trebuchet MS", "Arial Rounded MT Bold", Arial, sans-serif; user-select: none; -webkit-user-select: none; touch-action: none; }
#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }
button { font: inherit; cursor: pointer; border: 0; color: inherit; }

#top { position: fixed; top: max(10px, env(safe-area-inset-top)); left: 10px; right: 10px; display: flex; align-items: center; justify-content: space-between; gap: 8px; z-index: 5; pointer-events: none; }
#top > * { pointer-events: auto; }
.round { width: 46px; height: 46px; border-radius: 50%; background: rgba(255,255,255,.18); display: flex; align-items: center; justify-content: center; font-size: 22px; color: #fff; text-decoration: none; }
#steps { display: flex; gap: 6px; background: rgba(0,0,0,.35); padding: 5px; border-radius: 30px; }
#steps button { padding: 8px 14px; border-radius: 24px; background: transparent; font-weight: bold; font-size: 15px; opacity: .65; }
#steps button.on { background: #ff8a1f; opacity: 1; box-shadow: 0 3px 0 #b8530a; }

.panel { position: fixed; left: 50%; bottom: max(10px, env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(640px, calc(100% - 20px)); background: rgba(30, 14, 50, .88); border: 3px solid rgba(255,255,255,.25); border-radius: 22px; padding: 10px 12px; z-index: 5; }
.row { display: flex; align-items: center; gap: 8px; margin: 6px 0; flex-wrap: wrap; justify-content: center; }
.lbl { width: 62px; font-weight: bold; color: #ffcf8a; text-align: right; }
.panel .row button[data-part] { width: 54px; height: 50px; border-radius: 14px; background: rgba(255,255,255,.12); font-size: 24px; color: #ffb347; }
.panel .row button[data-part].on { background: #ff8a1f; color: #fff; box-shadow: 0 3px 0 #b8530a; transform: translateY(-2px); }
.foot { justify-content: space-between; margin-top: 10px; flex-wrap: nowrap; }
.tabs { display: flex; gap: 6px; justify-content: center; margin-bottom: 4px; }
.tabs button { padding: 8px 16px; border-radius: 14px; background: rgba(255,255,255,.1); font-weight: bold; font-size: 16px; }
.tabs button.on { background: #7b2fbe; box-shadow: 0 3px 0 #4a1677; }
.row.scroll { flex-wrap: nowrap; overflow-x: auto; justify-content: flex-start; padding-bottom: 4px; -webkit-overflow-scrolling: touch; touch-action: pan-x; }
.row.scroll button { flex: 0 0 auto; }
#emojiGrid { display: flex; flex-wrap: wrap; gap: 4px; max-height: 128px; overflow-y: auto; justify-content: center; touch-action: pan-y; }
#emojiGrid button { width: 46px; height: 46px; border-radius: 12px; background: rgba(255,255,255,.08); font-size: 28px; padding: 0; }
#emojiGrid button.on { background: #ff8a1f; box-shadow: 0 3px 0 #b8530a; }
.panel .row button[data-brush] { width: 54px; height: 50px; border-radius: 14px; background: rgba(255,255,255,.12); font-size: 22px; color: #ffb347; }
.panel .row button[data-brush].wide { width: auto; padding: 0 14px; font-size: 16px; color: #fff; }
.panel .row button[data-brush].on { background: #ff8a1f; color: #fff; box-shadow: 0 3px 0 #b8530a; }
#undoBtn:disabled { opacity: .4; }
.hint { font-size: 14px; opacity: .85; }
.go { background: linear-gradient(#ffb347, #ff7b00); color: #2a1200; font-weight: bold; font-size: 20px; padding: 12px 24px; border-radius: 16px; box-shadow: 0 5px 0 #a84d00; }
.go:active { transform: translateY(3px); box-shadow: 0 2px 0 #a84d00; }
.soft { background: rgba(255,255,255,.16); padding: 10px 16px; border-radius: 14px; font-weight: bold; }

.lights { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.lights button { background: rgba(255,255,255,.1); border-radius: 16px; padding: 10px 4px; font-weight: bold; display: flex; flex-direction: column; align-items: center; gap: 2px; border: 3px solid transparent; }
.lights button b { font-size: 38px; line-height: 1.1; }
.lights button small { font-weight: normal; opacity: .75; font-size: 12px; }
.lights button.on { border-color: #ffcf4a; background: rgba(255, 207, 74, .22); }

#launchHud { position: fixed; inset: 0; pointer-events: none; z-index: 4; }
#goal { position: absolute; top: calc(max(10px, env(safe-area-inset-top)) + 58px); left: 50%; transform: translateX(-50%); background: rgba(0,0,0,.45); padding: 8px 18px; border-radius: 16px; font-size: 20px; font-weight: bold; white-space: nowrap; text-shadow: 0 2px 2px #000; }
#best { position: absolute; left: 12px; bottom: max(14px, env(safe-area-inset-bottom)); background: rgba(0,0,0,.45); padding: 8px 14px; border-radius: 14px; font-weight: bold; font-size: 16px; }
#stars { position: absolute; top: calc(max(10px, env(safe-area-inset-top)) + 104px); left: 50%; transform: translateX(-50%); font-size: 22px; letter-spacing: 4px; }
.btns { position: absolute; right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); display: flex; gap: 8px; pointer-events: auto; }
.pill { background: rgba(30, 14, 50, .85); border: 3px solid rgba(255,255,255,.35); padding: 12px 18px; border-radius: 30px; font-weight: bold; font-size: 17px; }
.pill.glow { border-color: #ffcf4a; box-shadow: 0 0 18px #ffcf4a; animation: pulse 1s infinite alternate; }
@keyframes pulse { to { transform: scale(1.08); } }
#pullHint { position: absolute; left: 50%; bottom: 80px; transform: translateX(-50%); background: rgba(0,0,0,.5); padding: 10px 18px; border-radius: 16px; font-size: 18px; font-weight: bold; animation: bob 1.2s infinite alternate; white-space: nowrap; }
@keyframes bob { to { transform: translate(-50%, -8px); } }

.modal { position: fixed; inset: 0; background: rgba(10, 0, 25, .55); display: flex; align-items: center; justify-content: center; z-index: 10; padding: 16px; }
.card { background: linear-gradient(#3b1d63, #22103d); border: 4px solid #ffcf4a; border-radius: 26px; padding: 22px 26px; text-align: center; max-width: 440px; width: 100%; animation: popIn .3s; }
@keyframes popIn { from { transform: scale(.6); opacity: 0; } }
.card h2 { margin: 6px 0; color: #ffcf4a; }
.card p { font-size: 18px; margin: 8px 0 16px; }
.bigEmoji { font-size: 72px; line-height: 1; }
#fwList { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
#fwList button { background: rgba(255,255,255,.1); border-radius: 14px; padding: 10px 4px; font-weight: bold; font-size: 13px; border: 3px solid transparent; display: flex; flex-direction: column; align-items: center; }
#fwList button b { font-size: 34px; }
#fwList button.on { border-color: #ffcf4a; }

#toast { position: fixed; top: 34%; left: 50%; transform: translate(-50%, -50%); font-size: clamp(28px, 6vw, 52px); font-weight: bold; color: #ffcf4a; text-shadow: 0 4px 0 #a84d00, 0 8px 20px #000; pointer-events: none; opacity: 0; transition: opacity .25s; z-index: 6; white-space: nowrap; }
#toast.show { opacity: 1; }

@media (max-width: 560px) {
  #steps button { padding: 7px 9px; font-size: 13px; }
  .lights { grid-template-columns: repeat(2, 1fr); }
  .panel .row button[data-part] { width: 46px; height: 44px; font-size: 20px; }
  .lbl { width: 48px; font-size: 13px; }
  #goal { font-size: 16px; }
}
