:root { --bg: #1e130c; --panel: #2b1b12; --edge: #5c3d26; --paper: #f5e6c8; --text: #f3ead2; --muted: #b8a587; --accent: #ffca28; --leaf: #5fb341; --bad: #ff7a5c; --me: #e53935; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: 'Press Start 2P', monospace; font-size: 13px;
  overscroll-behavior: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.screen { display: none; min-height: 100%; padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom)); flex-direction: column; gap: 16px; }
.screen.on { display: flex; }
h1 { color: var(--accent); font-size: 30px; margin: 0; text-shadow: 3px 3px 0 #7d1d10; }
h2 { color: var(--accent); font-size: 15px; line-height: 1.6; text-align: center; }
.logo { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 12px; }
.logo canvas { width: 48px; image-rendering: pixelated; }
form { display: flex; flex-direction: column; gap: 16px; }
label { display: flex; flex-direction: column; gap: 8px; color: var(--muted); font-size: 11px; }
input { font: inherit; font-size: 16px; background: var(--paper); color: #2b1b12; border: 0; padding: 14px; box-shadow: inset 3px 3px 0 #c9b48e; text-transform: none; width: 100%; }
#code { text-transform: uppercase; letter-spacing: .3em; font-size: 22px; }
button { font: inherit; color: #12210b; background: var(--leaf); border: 0; padding: 14px; cursor: pointer;
  box-shadow: inset -4px -4px 0 #2e6b1f, inset 4px 4px 0 #a5e06a; touch-action: manipulation; }
button:disabled { opacity: .4; }
button.big { font-size: 16px; padding: 18px; }
button.alt { background: var(--paper); box-shadow: inset -4px -4px 0 #c9b48e; color: #2b1b12; }
.err { color: var(--bad); font-size: 11px; line-height: 1.6; min-height: 1em; margin: 0; text-align: center; }
.small { color: var(--muted); font-size: 10px; line-height: 1.6; }

.look { display: flex; flex-direction: column; gap: 12px; }
.swatches, .hats { display: flex; flex-wrap: wrap; gap: 8px; }
.sw { width: 40px; height: 40px; padding: 0; box-shadow: inset -4px -4px 0 rgba(0,0,0,.3); border: 3px solid transparent; }
.sw.sel { border-color: var(--text); }
.sw.taken { opacity: .2; }
.hat { background: var(--panel); box-shadow: none; border: 3px solid var(--edge); padding: 4px; width: 56px; height: 56px; }
.hat.sel { border-color: var(--accent); }
.hat canvas { width: 100%; image-rendering: pixelated; display: block; }

.me { display: flex; align-items: center; gap: 14px; font-size: 14px; line-height: 1.6; }
.me canvas { width: 72px; image-rendering: pixelated; }
.picker { display: flex; align-items: stretch; gap: 8px; }
.arrow { font-size: 20px; width: 64px; }
.lv { flex: 1; background: var(--panel); border: 3px solid var(--edge); padding: 12px; text-align: center; line-height: 1.8; }
.stars { color: var(--accent); letter-spacing: .2em; }
.stars .off { color: #5c4a35; }
.big-stars { font-size: 44px; text-align: center; }
details { color: var(--muted); font-size: 11px; }
details summary { padding: 8px 0; }
#r-score { text-align: center; font-size: 16px; margin-bottom: 8px; }
#msg-text { text-align: center; line-height: 1.8; }

/* gamepad */
.pad { flex-direction: row; padding: 0; height: 100vh; height: 100dvh; background: radial-gradient(circle at 25% 60%, color-mix(in srgb, var(--me) 35%, transparent), transparent 60%), var(--bg); position: relative; touch-action: none; }
#stick-zone { flex: 1.2; position: relative; touch-action: none; }
#stick-zone .hint { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); color: var(--muted); font-size: 9px; opacity: .6; }
#stick-base { position: absolute; width: 140px; height: 140px; border-radius: 50%; border: 4px solid color-mix(in srgb, var(--me) 70%, white);
  background: rgba(0,0,0,.25); transform: translate(-50%, -50%); left: 50%; top: 55%; pointer-events: none; }
#stick-knob { position: absolute; width: 64px; height: 64px; border-radius: 50%; background: var(--me); left: 50%; top: 50%;
  transform: translate(-50%, -50%); box-shadow: inset -6px -6px 0 rgba(0,0,0,.3), inset 6px 6px 0 rgba(255,255,255,.25); }
.btns { flex: 1; position: relative; }
.pbtn { position: absolute; border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; touch-action: none; }
.pbtn small { font-size: 8px; opacity: .7; }
.pbtn.grab { width: min(38vw, 40vh, 170px); height: min(38vw, 40vh, 170px); right: 6%; bottom: 14%; font-size: 15px; }
.pbtn.use { width: min(28vw, 30vh, 130px); height: min(28vw, 30vh, 130px); right: 52%; top: 12%; font-size: 13px; background: #ffca28; color: #3a2a00; box-shadow: inset -5px -5px 0 #b28a00, inset 5px 5px 0 #ffe082; }
.pbtn.down { filter: brightness(.8); transform: scale(.94); }
#pad-status { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); font-size: 10px; color: var(--text); text-align: center; pointer-events: none; white-space: nowrap; }
@media (orientation: portrait) {
  .pad { flex-direction: column-reverse; }
  .pbtn.use { right: auto; left: 8%; top: 20%; }
  .pbtn.grab { right: 8%; bottom: 10%; }
}
