@font-face { font-family: 'Fredoka'; src: url('fonts/fredoka.woff2') format('woff2'); font-weight: 300 700; font-display: swap; }
@font-face { font-family: 'Chewy'; src: url('fonts/chewy.woff2') format('woff2'); font-weight: 400; font-display: swap; }

:root {
  --navy: #16233f; --ink: #2b2a3a; --cream: #f6efe2; --cream2: #efe5d2; --stitch: #c7b299;
  --red: #e2504c; --blue: #3f7fd9; --yellow: #f2b632; --green: #2f9e58;
  --felt-noise: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' seed='4'/><feColorMatrix values='0 0 0 0 0.3  0 0 0 0 0.25  0 0 0 0 0.2  0 0 0 0.09 0'/></filter><rect width='120' height='120' filter='url(%23n)'/></svg>");
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--navy); font-family: 'Fredoka', system-ui, sans-serif; color: var(--navy); -webkit-font-smoothing: antialiased; user-select: none; -webkit-user-select: none; touch-action: none; }
button { font-family: inherit; color: inherit; cursor: pointer; border: 0; }
kbd { display: inline-block; min-width: 20px; padding: 1px 6px; margin: 0 1px; border-radius: 6px; background: var(--navy); color: #fff; font: 600 12px 'Fredoka', sans-serif; text-align: center; box-shadow: 0 2px 0 rgba(0,0,0,.35); }
.hidden { display: none !important; }

#boot { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; background: var(--navy); z-index: 100; color: #fff; font: 600 18px 'Fredoka', system-ui, sans-serif; letter-spacing: .04em; }
.boot-ball { width: 54px; height: 54px; border-radius: 50%; background: var(--red); outline: 2px dashed rgba(255,255,255,.55); outline-offset: -7px; animation: spin 1.4s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

#cv { position: fixed; inset: 0; display: block; }
body.building #cv { cursor: crosshair; }

.felt { background-color: var(--cream); background-image: var(--felt-noise); border-radius: 18px; outline: 2px dashed var(--stitch); outline-offset: -6px; box-shadow: 0 4px 0 rgba(22,35,63,.28), 0 10px 24px rgba(22,35,63,.22); }
.pill, .round, .big { background: var(--navy); color: #fff; font-weight: 600; border-radius: 999px; box-shadow: 0 3px 0 rgba(0,0,0,.3); transition: transform .08s, filter .15s; }
.pill { padding: 7px 14px; font-size: 14px; position: relative; }
.pill kbd { background: rgba(255,255,255,.2); box-shadow: none; }
.round { width: 34px; height: 34px; font-size: 17px; }
.big { padding: 13px 28px; font-size: 20px; background: var(--red); letter-spacing: .01em; outline: 2px dashed rgba(255,255,255,.55); outline-offset: -6px; }
.pill:hover, .round:hover, .big:hover { filter: brightness(1.12); transform: translateY(-1px); }
.pill:active, .round:active, .big:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0,0,0,.3); }
.big:disabled { filter: grayscale(.6) brightness(.9); cursor: default; }

/* ------------------------------------------------------------------ top bar */
#top { position: fixed; top: 10px; left: 10px; right: 10px; display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; pointer-events: none; z-index: 5; }
#top > * { pointer-events: auto; }
#pot { display: flex; align-items: center; gap: 8px; padding: 12px 20px 12px 14px; font-size: 30px; font-weight: 700; min-width: 132px; }
#pot img { width: 38px; height: 38px; }
#potN.bump { animation: bump .35s; }
@keyframes bump { 30% { transform: scale(1.25); color: var(--green); } }
#meter { flex: 1; max-width: 760px; padding: 10px 18px 9px; }
.meter-row { display: flex; justify-content: space-between; align-items: baseline; font-size: 15px; gap: 12px; }
.meter-row b { font-weight: 700; }
#chName b { font-family: 'Chewy', 'Fredoka', sans-serif; font-weight: 400; font-size: 21px; letter-spacing: .02em; margin-left: 4px; }
#lenTxt b { font-size: 21px; }
.meter-bar { margin: 2px 0 1px; }
#meterC { width: 100%; height: 30px; display: block; }
.meter-row.sub { font-size: 13px; opacity: .92; min-height: 20px; align-items: center; }
.crave { color: #fff; padding: 2px 10px; border-radius: 999px; font-weight: 600; animation: pulse 1s infinite alternate; }
.crave.aurora { background: linear-gradient(90deg, #32c98a, #5a8cf0, #c46ae8); }
@keyframes pulse { to { filter: brightness(1.18); transform: scale(1.03); } }
#sys { display: flex; align-items: center; gap: 8px; padding: 10px 14px; font-size: 14px; font-weight: 500; }
#online .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--green); margin-right: 6px; }
#shopDot { position: absolute; top: -3px; right: -3px; width: 13px; height: 13px; border-radius: 50%; background: var(--yellow); border: 2px solid #fff; display: none; animation: pulse .7s infinite alternate; }
#shopDot.on { display: block; }
#soundPanel { position: fixed; top: 74px; right: 10px; padding: 14px 18px; display: flex; flex-direction: column; gap: 8px; font-size: 14px; z-index: 6; }
#soundPanel label { display: flex; justify-content: space-between; gap: 12px; align-items: center; }

/* ------------------------------------------------------------------ quest */
#quest { position: fixed; left: 10px; top: 112px; width: 282px; padding: 14px 16px 12px; font-size: 14px; z-index: 4; }
.q-head { display: flex; align-items: center; gap: 9px; font-family: 'Chewy', sans-serif; font-size: 22px; }
.q-head b { font-weight: 400; }
.q-num { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--red); color: #fff; font-size: 18px; outline: 1.5px dashed rgba(255,255,255,.7); outline-offset: -4px; }
#quest ul { list-style: none; margin: 9px 0 8px; padding: 0; display: flex; flex-direction: column; gap: 7px; }
#quest li { display: flex; gap: 8px; align-items: flex-start; line-height: 1.25; }
#quest li i { flex: none; width: 17px; height: 17px; margin-top: 1px; border-radius: 6px; border: 2px solid var(--navy); background: #fff; position: relative; }
#quest li.done { opacity: .55; text-decoration: line-through; text-decoration-color: rgba(22,35,63,.4); }
#quest li.done i { background: var(--green); border-color: var(--green); }
#quest li.done i::after { content: ''; position: absolute; left: 4px; top: 0px; width: 4px; height: 9px; border: solid #fff; border-width: 0 2.5px 2.5px 0; transform: rotate(45deg); }
.q-goal { border-top: 2px dashed var(--stitch); padding-top: 7px; font-size: 13px; }

/* ------------------------------------------------------------------ toolbar */
#toolbar { position: fixed; bottom: 12px; left: 50%; transform: translateX(-50%); display: flex; gap: 7px; z-index: 5; }
.slot { position: relative; width: 64px; height: 76px; padding: 0; border-radius: 16px; background-color: var(--cream); background-image: var(--felt-noise); outline: 2px dashed var(--stitch); outline-offset: -5px; box-shadow: 0 4px 0 rgba(22,35,63,.28), 0 8px 18px rgba(22,35,63,.2); transition: transform .1s; }
.slot:hover { transform: translateY(-3px); }
.slot > img { width: 44px; height: 44px; margin-top: 6px; pointer-events: none; }
.slot kbd { position: absolute; top: -7px; left: -5px; }
.slot .cost { position: absolute; left: 0; right: 0; bottom: 6px; display: flex; align-items: center; justify-content: center; gap: 3px; font-size: 13px; font-weight: 600; }
.slot .cost img { width: 14px; height: 14px; }
.slot .lock { display: none; position: absolute; inset: 0; align-items: center; justify-content: center; font-size: 22px; background: rgba(22,35,63,.55); border-radius: 16px; }
.slot.locked .lock { display: flex; }
.slot.locked > img, .slot.locked .cost { opacity: .35; }
.slot.poor .cost { color: var(--red); }
.slot.sel { transform: translateY(-9px); outline-color: #fff; background-color: #ffe9a0; box-shadow: 0 0 0 4px var(--yellow), 0 12px 20px rgba(22,35,63,.3); }
.slot.remove .xicon { display: block; font-size: 26px; color: var(--red); margin-top: 6px; }
.slot.remove.sel { background-color: #ffd0cc; box-shadow: 0 0 0 4px var(--red), 0 12px 20px rgba(22,35,63,.3); }
#tip { position: fixed; width: 260px; padding: 12px 15px; font-size: 13.5px; line-height: 1.35; z-index: 20; pointer-events: none; }
#tip b { font-size: 15px; }
#tip i { opacity: .7; }
#carry { position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 9px; padding: 7px 16px; font-size: 14px; font-weight: 600; z-index: 4; border-radius: 999px; }
#carry .cap { background: var(--navy); color: #fff; padding: 1px 9px; border-radius: 999px; }
#carry .ci { display: inline-flex; align-items: center; gap: 2px; }
#carry .ci img { width: 24px; height: 24px; }
#carry .hint { opacity: .65; font-weight: 500; }

/* ------------------------------------------------------------------ workshop */
#shop { position: fixed; right: 10px; top: 84px; width: 344px; max-height: calc(100vh - 290px); display: flex; flex-direction: column; padding: 14px 14px 12px; z-index: 6; }
.shop-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; padding: 0 44px 8px 4px; position: relative; }
.shop-head b { font-family: 'Chewy', sans-serif; font-weight: 400; font-size: 23px; }
.shop-head span { font-size: 12px; opacity: .7; }
.shop-head .round { position: absolute; right: 0; top: -2px; }
#shopList { overflow-y: auto; display: flex; flex-direction: column; gap: 7px; padding: 2px 2px 4px; }
.up { display: flex; align-items: center; gap: 10px; background: rgba(255,255,255,.6); border-radius: 13px; padding: 8px 10px; font-size: 13px; line-height: 1.3; }
.up-txt { flex: 1; }
.up-txt b { font-size: 15px; }
.up-txt span { opacity: .8; }
.up-txt em { font-style: normal; font-weight: 600; color: #7a4a22; }
.up.locked { opacity: .5; }
.pips { margin-left: 7px; }
.pips i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--navy); margin-right: 2px; }
.pips i.on { background: var(--green); border-color: var(--green); }
.buy { flex: none; min-width: 78px; padding: 9px 10px; border-radius: 12px; background: var(--green); color: #fff; font-weight: 700; font-size: 15px; display: flex; align-items: center; justify-content: center; gap: 4px; box-shadow: 0 3px 0 rgba(0,0,0,.25); }
.buy img { width: 17px; height: 17px; }
.buy:disabled { background: #b9b2a6; cursor: default; box-shadow: none; }
.buy:not(:disabled):hover { filter: brightness(1.1); }
.buy:not(:disabled):active { transform: translateY(2px); box-shadow: none; }

/* ------------------------------------------------------------------ toasts + banner */
#toasts { position: fixed; top: 118px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 7; pointer-events: none; width: min(560px, 92vw); }
.toast { padding: 9px 18px; font-size: 15px; text-align: center; animation: drop .35s cubic-bezier(.2,1.5,.4,1); border-radius: 999px; }
.toast.major { font-size: 16.5px; padding: 11px 24px; background: var(--navy); color: #fff; outline-color: rgba(255,255,255,.4); }
.toast.major kbd { background: #fff; color: var(--navy); }
.toast.gold { background-color: #ffe9a0; outline-color: #d9a43a; }
.toast.buy { background-color: #d8f0dc; outline-color: #8cc79a; }
.toast.crave-R { background-color: var(--red); color: #fff; outline-color: rgba(255,255,255,.6); }
.toast.crave-B { background-color: var(--blue); color: #fff; outline-color: rgba(255,255,255,.6); }
.toast.crave-Y { background-color: var(--yellow); outline-color: rgba(255,255,255,.7); }
.toast.out { opacity: 0; transform: translateY(-10px); transition: all .35s; }
@keyframes drop { from { opacity: 0; transform: translateY(-18px) scale(.9); } }
#banner { position: fixed; left: 0; right: 0; top: 24%; display: flex; justify-content: center; z-index: 8; pointer-events: none; }
.b-in { text-align: center; color: #fff; padding: 22px 60px 24px; background: linear-gradient(90deg, rgba(22,35,63,0), rgba(22,35,63,.88) 18%, rgba(22,35,63,.88) 82%, rgba(22,35,63,0)); min-width: min(900px, 100vw); }
#banner.low { top: auto; bottom: 110px; }
#banner.show .b-in { animation: bannerIn 5.2s both; }
.b-title { font-family: 'Chewy', sans-serif; font-size: clamp(34px, 5vw, 62px); letter-spacing: .02em; text-shadow: 0 4px 0 rgba(0,0,0,.3); color: #ffe9a0; }
.b-sub { font-size: 18px; font-weight: 500; margin-top: 4px; }
.b-sub span { opacity: .8; font-size: 15px; }
@keyframes bannerIn { 0% { opacity: 0; transform: scale(.85); } 7% { opacity: 1; transform: scale(1.03); } 11% { transform: scale(1); } 88% { opacity: 1; } 100% { opacity: 0; } }

/* ------------------------------------------------------------------ chat + minimap */
#chat { position: fixed; left: 10px; bottom: 12px; width: 300px; z-index: 4; }
#chatLog { display: flex; flex-direction: column; gap: 3px; margin-bottom: 6px; pointer-events: none; }
#chatLog .line { align-self: flex-start; background: rgba(22,35,63,.72); color: #fff; padding: 3px 11px; border-radius: 12px; font-size: 13.5px; max-width: 100%; word-break: break-word; transition: opacity 1.5s; }
#chatLog .line.sys { background: rgba(22,35,63,.45); font-style: italic; }
#chatLog .line.old { opacity: 0; }
#chatIn { width: 100%; padding: 8px 14px; border-radius: 999px; border: 0; outline: 0; background: rgba(22,35,63,.55); color: #fff; font: 500 14px 'Fredoka', sans-serif; user-select: text; -webkit-user-select: text; }
#chatIn::placeholder { color: rgba(255,255,255,.7); }
#chatIn:focus { background: #fff; color: var(--navy); box-shadow: 0 0 0 3px var(--yellow); }
#miniWrap { position: fixed; right: 10px; bottom: 12px; padding: 9px; z-index: 4; line-height: 0; }
#mini { width: 176px; height: 120px; border-radius: 10px; }
#miniWrap span { position: absolute; right: 14px; bottom: 12px; font-size: 10.5px; line-height: 1; background: rgba(22,35,63,.6); color: #fff; padding: 2px 6px; border-radius: 6px; }

#status { position: fixed; top: 46%; left: 50%; transform: translate(-50%, -50%); background: var(--navy); color: #fff; padding: 12px 26px; border-radius: 999px; font-size: 18px; font-weight: 600; z-index: 60; box-shadow: 0 8px 30px rgba(0,0,0,.4); }

/* ------------------------------------------------------------------ overlays */
.overlay { position: fixed; inset: 0; background: rgba(22,35,63,.6); display: flex; align-items: center; justify-content: center; z-index: 30; padding: 16px; }
.sheet { position: relative; width: min(940px, 100%); max-height: 94vh; overflow-y: auto; padding: 26px 32px; }
.sheet .close { position: absolute; right: 16px; top: 16px; }
.sheet h1, .sheet h2 { font-family: 'Chewy', sans-serif; font-weight: 400; margin: 0 0 8px; letter-spacing: .02em; }
.sheet h1 { font-size: 52px; color: var(--red); text-align: center; }
.sheet h2 { font-size: 32px; }
.sheet h3 { margin: 14px 0 4px; font-size: 17px; }
.sheet p { margin: 4px 0; line-height: 1.45; font-size: 14.5px; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
.chain { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.chain img, .vals img { width: 26px; height: 26px; vertical-align: middle; }
.vals td { padding: 1px 10px 1px 0; font-size: 14px; }
.vals td:last-child { font-weight: 700; }
.keys td { padding: 4px 10px 4px 0; font-size: 14px; vertical-align: top; }
.keys td:first-child { white-space: nowrap; }
.winsheet .sub { text-align: center; font-size: 17px; }
.scarfbar { display: flex; height: 34px; border-radius: 17px; overflow: hidden; margin: 14px 0; outline: 2px dashed rgba(60,40,60,.35); outline-offset: -5px; }
.scarfbar i { display: block; min-width: 3px; }
#winChart { width: 100%; height: auto; }
.awards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.award { display: flex; gap: 10px; align-items: center; background: rgba(255,255,255,.6); border-radius: 14px; padding: 9px 12px; font-size: 13.5px; line-height: 1.3; }
.award b { font-size: 15px; color: #7a4a22; }
.award em { font-style: normal; opacity: .7; }
.medal { flex: none; width: 30px; height: 30px; border-radius: 50%; outline: 2px dashed rgba(255,255,255,.75); outline-offset: -5px; box-shadow: 0 3px 0 rgba(0,0,0,.2); }
.winbtns { display: flex; gap: 14px; justify-content: center; align-items: center; margin-top: 20px; }
#voteLine { text-align: center; font-size: 13px; opacity: .75; margin-top: 8px; min-height: 18px; }

/* ------------------------------------------------------------------ title */
#title { position: fixed; inset: 0; z-index: 50; transition: opacity .7s, transform .7s; }
#title.gone { opacity: 0; transform: scale(1.06); pointer-events: none; }
#titleC { position: absolute; inset: 0; width: 100%; height: 100%; }
.title-card { position: absolute; left: clamp(16px, 8vw, 130px); top: 50%; transform: translateY(-50%); width: min(430px, calc(100vw - 32px)); display: flex; flex-direction: column; gap: 14px; }
.logo { font-family: 'Chewy', sans-serif; line-height: .92; color: #fff; text-shadow: 0 5px 0 rgba(22,35,63,.55), 0 12px 30px rgba(22,35,63,.5); transform: rotate(-3deg); margin-bottom: 4px; }
.logo .l1 { display: block; font-size: clamp(54px, 8vw, 92px); color: #ffe9a0; }
.logo .l2 { display: block; font-size: clamp(40px, 6vw, 66px); }
.tag { color: #fff; font-size: 17px; line-height: 1.4; margin: 0; padding: 10px 16px; background: rgba(22,35,63,.72); border-radius: 16px; }
.join { padding: 20px 22px 18px; display: flex; flex-direction: column; gap: 7px; }
.join label { font-size: 13px; font-weight: 600; opacity: .75; text-transform: uppercase; letter-spacing: .06em; }
#nameIn { font: 600 20px 'Fredoka', sans-serif; padding: 10px 14px; border-radius: 12px; border: 2px solid var(--stitch); outline: 0; background: #fff; color: var(--navy); user-select: text; -webkit-user-select: text; }
#nameIn:focus { border-color: var(--blue); }
#hats { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 8px; }
.hat { width: 31px; height: 31px; border-radius: 50%; outline: 1.5px dashed rgba(255,255,255,.75); outline-offset: -4px; box-shadow: 0 3px 0 rgba(0,0,0,.22); transition: transform .1s; }
.hat:hover { transform: scale(1.12); }
.hat.sel { box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--navy); transform: scale(1.1); }
.roomline { font-size: 12.5px; opacity: .7; text-align: center; min-height: 0; }
.howto { display: flex; flex-wrap: wrap; gap: 6px; }
.howto div { background: rgba(22,35,63,.7); color: #fff; font-size: 13px; padding: 5px 11px; border-radius: 999px; }
.howto b { color: #ffe9a0; }

/* ------------------------------------------------------------------ touch */
#touch { display: none; }
body.touch #touch { display: block; }
#tAct, #tToss { position: fixed; right: 22px; width: 76px; height: 76px; border-radius: 50%; background: var(--red); color: #fff; font: 700 26px 'Fredoka', sans-serif; z-index: 9; box-shadow: 0 5px 0 rgba(0,0,0,.3); outline: 2px dashed rgba(255,255,255,.6); outline-offset: -7px; }
#tAct { bottom: 170px; }
#tToss { bottom: 260px; right: 30px; width: 58px; height: 58px; font-size: 20px; background: var(--blue); }
body.touch #miniWrap, body.touch #chat { display: none; }

@media (max-width: 1180px) { #quest { width: 240px; font-size: 13px; } #sys #online { display: none; } }
@media (max-width: 900px) {
  #quest { display: none; }
  #pot { font-size: 22px; min-width: 0; padding: 9px 14px 9px 10px; } #pot img { width: 28px; height: 28px; }
  .slot { width: 50px; height: 62px; } .slot > img { width: 34px; height: 34px; }
  .cols { grid-template-columns: 1fr; }
  #sys .pill kbd { display: none; }
}
@media (max-height: 760px) { #quest { top: 104px; } #shop { max-height: calc(100vh - 210px); } }

/* ------------------------------------------------------------------ phones */
@media (max-width: 640px) {
  #top { flex-wrap: wrap; gap: 6px; top: 6px; left: 6px; right: 6px; }
  #pot { order: 1; font-size: 20px; padding: 7px 12px 7px 9px; min-width: 0; }
  #pot img { width: 26px; height: 26px; }
  #sys { order: 2; padding: 6px 9px; margin-left: auto; }
  #meter { order: 3; flex-basis: 100%; max-width: none; padding: 7px 12px 6px; }
  .meter-row { font-size: 12.5px; }
  #chName b { font-size: 16px; }
  #lenTxt b { font-size: 16px; }
  #meterC { height: 22px; }
  #rate, #eta { display: none; }
  .meter-row.sub { min-height: 0; justify-content: center; }
  #toasts { top: 132px; }
  .toast { font-size: 13px; }
  #toolbar { left: 0; right: 0; transform: none; overflow-x: auto; padding: 10px 8px 2px; gap: 6px; bottom: 6px; -webkit-overflow-scrolling: touch; }
  .slot { flex: none; width: 50px; height: 60px; border-radius: 13px; }
  .slot > img { width: 32px; height: 32px; margin-top: 4px; }
  .slot .cost { font-size: 11px; bottom: 4px; }
  #carry { bottom: 82px; font-size: 12px; }
  #carry .hint { display: none; }
  #shop { left: 6px; right: 6px; width: auto; top: 128px; max-height: calc(100vh - 230px); }
  .sheet { padding: 18px 16px; }
  .sheet h1 { font-size: 34px; }
  #tAct { bottom: 120px; right: 14px; }
  #tToss { bottom: 206px; right: 22px; }
}
