:root {
  --deep: #061a33; --ocean: #0a3d6b; --cyan: #22d3ee; --turq: #2dd4bf; --foam: #eafcff; --coral: #ff6b4a; --sun: #ffc23d;
  --glass: rgba(7, 30, 58, .94); --line: rgba(34, 211, 238, .35);
  --font: "Nirmala UI", "Noto Sans Bengali", "Hind Siliguri", "Trebuchet MS", system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--deep); color: var(--foam); font-family: var(--font); }
body { touch-action: none; user-select: none; -webkit-user-select: none; }
canvas#game { position: fixed; inset: 0; display: block; }
button, select, input { font-family: inherit; }

#ui { position: fixed; inset: 0; pointer-events: none; }
.screen { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; padding: 16px; overflow-y: auto; pointer-events: auto; }
.screen.show { display: flex; animation: fadein .25s ease-out; }
#menu.show, #pick.show, #levels.show, #party.show, #custom.show, #settings.show, #credits.show, #studio.show, #result.show, #pause.show {
  background: radial-gradient(ellipse at 50% 30%, rgba(6, 26, 51, .35), rgba(6, 26, 51, .78)); }
@keyframes fadein { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.center-col { text-align: center; }
.logo { margin: 0; font-size: clamp(42px, 9vw, 88px); font-weight: 900; letter-spacing: 2px; line-height: .95;
  background: linear-gradient(180deg, #fff 0%, #9ff3ff 45%, #22d3ee 60%, #0a7fb5 100%); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 4px 0 #04121f) drop-shadow(0 0 24px rgba(34, 211, 238, .45)); font-family: "Impact", "Arial Black", var(--font); }
.logo-drop { font-size: 64px; animation: bob 1.2s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-10px) rotate(-6deg); } }
.sub { margin: 6px 0 0; font-size: clamp(15px, 2.6vw, 20px); font-weight: 700; color: var(--sun); text-shadow: 0 2px 0 #04121f; }
.muted { color: #9fc3dc; } .tiny { font-size: 12px; } .err { color: var(--coral); }
.loadbar { width: min(320px, 80vw); height: 12px; border-radius: 8px; background: rgba(255, 255, 255, .12); margin: 14px auto; overflow: hidden; }
.loadbar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--cyan), var(--turq)); transition: width .2s; }

/* Menu */
.menu-wrap { width: min(760px, 100%); display: flex; flex-direction: column; align-items: center; gap: 22px; }
.menu-head { text-align: center; }
.menu-faces { display: flex; justify-content: center; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.menu-faces .face { animation: bob 1.6s ease-in-out infinite; border-radius: 50%; box-shadow: 0 4px 0 #04121f; }
.menu-faces .face.target { outline: 3px solid var(--cyan); }
.menu-faces .face.chaser { outline: 3px solid var(--coral); }
.menu-btns { width: min(560px, 100%); display: flex; flex-direction: column; gap: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.btn { pointer-events: auto; cursor: pointer; border: 0; border-radius: 16px; padding: 12px 16px; font-size: 17px; font-weight: 800; color: var(--foam);
  background: linear-gradient(180deg, rgba(20, 80, 130, .92), rgba(10, 50, 92, .92)); box-shadow: 0 4px 0 #04121f, inset 0 1px 0 rgba(255, 255, 255, .2);
  border: 1px solid var(--line); transition: transform .08s, filter .15s; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; line-height: 1.15; }
.btn small { font-size: 12px; font-weight: 600; opacity: .75; }
.btn:hover { filter: brightness(1.15); transform: translateY(-1px); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #04121f; }
.btn.big { font-size: 24px; padding: 16px; }
.btn.primary { background: linear-gradient(180deg, #3fe6f7, #0fa3c4); color: #032036; border-color: #9ff3ff; text-shadow: 0 1px 0 rgba(255, 255, 255, .4); }
.btn.coral { background: linear-gradient(180deg, #ff8a6b, #e0492b); border-color: #ffc1ad; }
.btn.danger { background: linear-gradient(180deg, #e8505b, #a51d2a); }
.btn.ghost { background: rgba(255, 255, 255, .06); }
.btn.small { font-size: 13px; padding: 8px 10px; }

.panel { pointer-events: auto; width: min(860px, 100%); max-height: 100%; overflow-y: auto; background: var(--glass); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line); border-radius: 24px; padding: 20px; box-shadow: 0 20px 60px rgba(0, 0, 0, .45); display: flex; flex-direction: column; gap: 12px; }
.panel.narrow { width: min(560px, 100%); }
.panel.wide { width: min(1100px, 100%); }
.panel.center { align-items: stretch; text-align: center; }
.panel h2 { margin: 0; font-size: 26px; font-weight: 900; color: #fff; }
.row, .row2, .row3 { display: flex; gap: 10px; align-items: center; }
.row2 > *, .row3 > * { flex: 1; }
label.row { justify-content: space-between; }

/* pick + levels */
.pick-list { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pick-card { cursor: pointer; border: 2px solid var(--line); background: rgba(255, 255, 255, .06); border-radius: 20px; padding: 16px 10px; color: var(--foam);
  display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 18px; transition: transform .1s, border-color .1s; }
.pick-card:hover { transform: translateY(-3px) rotate(-1deg); border-color: var(--cyan); }
.pick-card small { color: #9fc3dc; font-size: 12px; }
.seg { display: flex; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); }
.seg button { flex: 1; border: 0; padding: 10px; background: rgba(255, 255, 255, .05); color: var(--foam); font-weight: 700; cursor: pointer; }
.seg button.on { background: var(--sun); color: #2a1a00; }
.level-list { display: flex; flex-direction: column; gap: 10px; }
.level-card { cursor: pointer; text-align: left; display: flex; gap: 14px; align-items: center; border: 1px solid var(--line); border-radius: 18px; padding: 12px 14px;
  background: linear-gradient(90deg, rgba(34, 211, 238, .14), rgba(255, 255, 255, .04)); color: var(--foam); position: relative; }
.level-card:hover { border-color: var(--cyan); }
.level-card b { font-size: 19px; } .level-card em { display: block; font-size: 13px; color: var(--cyan); font-style: normal; }
.level-card small { display: block; color: #b9d6ea; font-size: 13px; margin-top: 2px; }
.lv-num { font-size: 34px; font-weight: 900; color: var(--sun); width: 44px; text-align: center; font-family: Impact, var(--font); }
.lv-meta { display: block; font-size: 13px; color: var(--sun); margin-top: 4px; }
.level-card.locked { opacity: .5; filter: grayscale(.6); } .lock { position: absolute; right: 14px; font-size: 26px; }

/* dialogue */
#dialog.show { align-items: flex-end; padding-bottom: 6vh; background: linear-gradient(0deg, rgba(6, 26, 51, .85), transparent 60%); }
.dialog { pointer-events: auto; cursor: pointer; width: min(760px, 100%); display: flex; gap: 14px; align-items: flex-end; position: relative; }
.dlg-face .face { border-radius: 50%; animation: bob 1.4s ease-in-out infinite; filter: drop-shadow(0 6px 0 #04121f); }
.narrator { width: 92px; height: 92px; border-radius: 50%; background: var(--sun); display: grid; place-items: center; font-size: 46px; }
.dlg-bubble { flex: 1; background: #fff; color: var(--deep); border-radius: 22px; padding: 14px 18px; box-shadow: 0 6px 0 #04121f; position: relative; }
.dlg-bubble::before { content: ''; position: absolute; left: -12px; bottom: 26px; border: 12px solid transparent; border-right-color: #fff; border-left: 0; }
.dlg-bubble b { font-size: 15px; color: var(--ocean); } .dlg-bubble b.chaser { color: #d9381e; } .dlg-bubble b.target { color: #0b7da0; }
.dlg-bubble p { margin: 6px 0 8px; font-size: clamp(17px, 2.6vw, 22px); font-weight: 700; line-height: 1.45; }
.dlg-foot { display: flex; justify-content: space-between; font-size: 12px; color: #567; }
.skip { position: absolute; right: 0; top: -54px; }

/* studio */
.studio-head { display: flex; justify-content: space-between; align-items: center; }
.studio-body { display: grid; grid-template-columns: 230px 1fr; gap: 16px; }
.st-list { display: flex; flex-direction: column; gap: 8px; }
.st-card { cursor: pointer; display: flex; gap: 10px; align-items: center; text-align: left; border: 2px solid transparent; border-radius: 16px; padding: 8px; background: rgba(255, 255, 255, .06); color: var(--foam); }
.st-card span { display: flex; flex-direction: column; } .st-card small { color: #9fc3dc; font-size: 12px; }
.st-card.on { border-color: var(--cyan); background: rgba(34, 211, 238, .16); }
.st-card.chaser.on { border-color: var(--coral); background: rgba(255, 107, 74, .16); }
.role-tag { margin: 0; font-weight: 800; color: var(--sun); }
.st-photo { display: grid; grid-template-columns: auto 1fr; gap: 14px; }
.drop { border: 2px dashed var(--line); border-radius: 18px; padding: 8px; text-align: center; }
.drop.over { border-color: var(--sun); background: rgba(255, 194, 61, .12); }
.drop canvas { width: 260px; height: 260px; border-radius: 14px; touch-action: none; cursor: grab; display: block; }
.drop small { display: block; font-size: 11px; color: #9fc3dc; margin-top: 6px; }
.st-side { display: flex; flex-direction: column; gap: 10px; }
.st-previews { display: flex; gap: 10px; align-items: flex-end; }
.st-previews > div { text-align: center; } .st-previews small { display: block; font-size: 11px; color: #9fc3dc; }
#stFace { width: 100px; height: 100px; border-radius: 50%; border: 3px solid var(--cyan); background: #061a33; }
#stPreview { width: 160px; height: 176px; border-radius: 14px; border: 1px solid var(--line); }
.file { position: relative; overflow: hidden; } .file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.st-form, .form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.form { grid-template-columns: 1fr; }
.st-form label, .form label, .lbl { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 700; color: #b9d6ea; }
.st-form .full { grid-column: 1 / -1; }
input:not([type]), input[type=text], select { background: rgba(4, 18, 31, .7); color: var(--foam); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font-size: 15px; }
input[type=color] { width: 100%; height: 36px; border: 1px solid var(--line); border-radius: 10px; background: transparent; }
input[type=range] { accent-color: var(--cyan); width: 100%; }
label.chk { flex-direction: row; align-items: center; gap: 8px; } .chks { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.swatches button { width: 28px; height: 28px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .4); cursor: pointer; }
.swatches button.on { border-color: var(--sun); transform: scale(1.15); }
.st-actions { display: flex; gap: 10px; margin-top: 4px; }
.privacy { font-size: 12px; color: #9fc3dc; margin: 0; }

/* party */
.party-list { display: flex; flex-direction: column; gap: 8px; }
.party-row { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 14px; background: rgba(255, 255, 255, .05); border-left: 4px solid var(--cyan); }
.party-row.chaser { border-left-color: var(--coral); }
.pr-name { flex: 1; display: flex; flex-direction: column; } .pr-name small { font-size: 12px; color: #9fc3dc; }
.party-row select { width: 46%; }

/* results */
.res-title { font-size: 32px !important; color: var(--sun) !important; } .res-title.win { text-shadow: 0 0 20px rgba(255, 194, 61, .6); }
.stars { font-size: 46px; letter-spacing: 6px; color: #3b5068; } .stars .on { color: var(--sun); text-shadow: 0 0 14px rgba(255, 194, 61, .8); }
.res-faces { display: flex; justify-content: center; } .res-faces .face { border-radius: 50%; animation: bob 1s ease-in-out infinite; }
.res-stats { display: flex; justify-content: center; gap: 22px; } .res-stats div { display: flex; flex-direction: column; } .res-stats small { color: #9fc3dc; } .res-stats b { font-size: 24px; }
.quote { font-style: italic; font-size: 17px; } .quote small { color: #9fc3dc; font-style: normal; }
.newbest { color: var(--turq); font-weight: 900; } .trophy { font-size: 22px; font-weight: 900; color: var(--sun); }
.paper { background: #f4ecd8; color: #1d1a14; border-radius: 6px; padding: 14px 16px; text-align: left; transform: rotate(-1.2deg); box-shadow: 0 10px 30px rgba(0, 0, 0, .5); font-family: Georgia, "Nirmala UI", serif; }
.paper-top { display: flex; justify-content: space-between; font-size: 12px; color: #6b5f4b; }
.paper-name { text-align: center; font-size: 36px !important; color: #1d1a14 !important; margin: 4px 0 !important; font-weight: 900; }
.paper-rule { border-top: 3px double #1d1a14; margin-bottom: 8px; }
.headline { font-size: 22px; margin: 0 0 10px; line-height: 1.3; color: #b3121b; }
.paper-body { display: flex; gap: 12px; align-items: flex-start; } .paper-body p { margin: 0; font-size: 14px; line-height: 1.5; }
.paper-photo { display: flex; flex-direction: column; gap: 6px; align-items: center; padding: 6px; background: #ddd3bb; border: 1px solid #b6a988; }
.paper-photo .face { border-radius: 50%; filter: grayscale(.55) contrast(1.15); }
.paper .quote { color: #3c3324; margin: 10px 0 0; } .paper .quote small { color: #6b5f4b; }
.winner { display: flex; flex-direction: column; align-items: center; } .crown { font-size: 34px; margin-bottom: -10px; z-index: 1; animation: bob 1s infinite; }
.winner-name { font-size: 20px; margin: 4px 0; }
.board { width: 100%; border-collapse: collapse; text-align: left; font-size: 14px; }
.board td { padding: 6px; border-bottom: 1px solid rgba(255, 255, 255, .08); }
.board td small { display: block; color: #9fc3dc; font-size: 11px; } .board .sc { text-align: right; font-weight: 900; color: var(--sun); font-size: 17px; }
.board .fc .face { border-radius: 50%; }

/* in-game DOM */
#pauseBtn { position: fixed; top: calc(10px + env(safe-area-inset-top)); right: 10px; width: 44px; height: 44px; border-radius: 14px; border: 1px solid var(--line);
  background: rgba(6, 26, 51, .7); color: #fff; font-weight: 900; font-size: 16px; display: none; cursor: pointer; z-index: 5; }
body.playing #pauseBtn { display: block; }
#touch { position: fixed; inset: auto 0 30px 0; height: 190px; display: none; justify-content: space-between; align-items: flex-end; padding: 0 18px calc(8px + env(safe-area-inset-bottom)); pointer-events: none; z-index: 4; }
body.playing.touch-on #touch { display: flex; }
#stick { pointer-events: auto; width: 150px; height: 150px; border-radius: 50%; background: rgba(255, 255, 255, .08); border: 2px solid rgba(34, 211, 238, .4); position: relative; touch-action: none; }
#knob { position: absolute; left: 50%; top: 50%; width: 62px; height: 62px; margin: -31px; border-radius: 50%; background: rgba(34, 211, 238, .55); box-shadow: 0 0 18px rgba(34, 211, 238, .5); }
.tbtns { display: grid; grid-template-columns: auto auto; grid-template-rows: auto auto; gap: 10px; align-items: end; pointer-events: auto; }
.tb { width: 70px; height: 70px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .35); background: rgba(255, 107, 74, .55); color: #fff; font-size: 28px; touch-action: none; }
.tb.big { width: 92px; height: 92px; background: rgba(34, 211, 238, .55); font-size: 38px; grid-row: 1 / 3; grid-column: 2; }
.tb.small { width: 54px; height: 54px; font-size: 22px; background: rgba(255, 194, 61, .5); justify-self: end; }
.tb.on { transform: scale(.92); filter: brightness(1.3); }
#toast { position: fixed; left: 50%; bottom: 46px; transform: translate(-50%, 30px); background: rgba(6, 26, 51, .95); border: 1px solid var(--cyan); padding: 10px 16px; border-radius: 14px;
  opacity: 0; transition: .25s; pointer-events: none; z-index: 10; max-width: 90vw; text-align: center; font-weight: 700; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 760px) {
  .studio-body { grid-template-columns: 1fr; }
  .st-list { flex-direction: row; overflow-x: auto; } .st-card { min-width: 150px; }
  .st-photo { grid-template-columns: 1fr; justify-items: center; }
  .drop canvas { width: min(260px, 70vw); height: min(260px, 70vw); }
  .st-form { grid-template-columns: 1fr; }
  .btn.big { font-size: 20px; }
  .panel { padding: 14px; border-radius: 18px; }
}
@media (max-height: 560px) { .menu-faces .face { width: 38px !important; height: 38px !important; } .menu-wrap { gap: 10px; } .btn { padding: 8px 12px; } }
