:root {
  --bg: #241a63; --bg2: #2f2380; --ink: #17123d; --cream: #fff6e3; --cream2: #f3e6c8; --lav: #c9c2f2; --lav2: #a79ee6;
  --g: #34b86a; --g-d: #1f8a4b; --y: #f5b62b; --y-d: #c58710; --x: #5d5888; --x-d: #403b6a; --coral: #ff6f61; --coral-d: #d64a3d;
  --sun: #ffd447; --white: #fff;
  --font: "Trebuchet MS", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --tile: 54px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  position: fixed; inset: 0; overscroll-behavior: none; touch-action: none; color: var(--white); font-family: var(--font);
  background: var(--bg) url(img/bg.webp) repeat; background-size: 256px 256px;
  user-select: none; -webkit-user-select: none;
}
body::before { content: ""; position: fixed; inset: 0; pointer-events: none; background: radial-gradient(ellipse at 50% 0%, rgba(140, 110, 255, .35), transparent 60%), radial-gradient(ellipse at 50% 110%, rgba(255, 111, 97, .18), transparent 55%); }
button { font-family: inherit; cursor: pointer; color: inherit; }
.hidden { display: none !important; }
#app { position: relative; height: 100%; display: flex; flex-direction: column; max-width: 560px; margin: 0 auto; padding: 8px 12px 10px; }

/* header */
#top { display: flex; align-items: center; gap: 7px; flex: 0 0 auto; }
.ib { width: 42px; height: 42px; flex: 0 0 auto; border-radius: 13px; border: 3px solid var(--ink); background: var(--cream); color: var(--ink); padding: 7px; box-shadow: 0 3px 0 var(--ink); }
.ib svg { width: 100%; height: 100%; display: block; }
.ib:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
#brand { flex: 1 1 auto; min-width: 0; line-height: 1.05; }
#brand b { display: block; font-size: 23px; font-weight: 900; letter-spacing: .5px; text-shadow: 0 3px 0 var(--ink); }
#brand b span, h1 span { color: var(--sun); }
#brand small { display: block; font-size: 12px; font-weight: 700; color: var(--lav); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

#tabs { display: flex; gap: 6px; margin: 8px 0 4px; background: rgba(10, 6, 40, .45); border-radius: 16px; padding: 4px; flex: 0 0 auto; }
.tab { flex: 1 1 0; border: 0; border-radius: 12px; background: transparent; color: var(--lav); font-weight: 900; font-size: 14px; padding: 8px 4px; white-space: nowrap; }
.tab.on { background: var(--cream); color: var(--ink); box-shadow: 0 2px 0 var(--ink); }

#main { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.view { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.headline { text-align: center; margin: 4px 0 6px; }
.headline b { display: block; font-size: 20px; font-weight: 900; text-shadow: 0 2px 0 var(--ink); }
.headline span { display: block; font-size: 13px; font-weight: 700; color: var(--lav); margin-top: 2px; }

/* board */
#board { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 6px; }
.row { display: flex; gap: 6px; }
.row.shake { animation: shake .45s; }
@keyframes shake { 15%, 55% { transform: translateX(-9px); } 35%, 75% { transform: translateX(9px); } }
.t { width: var(--tile); height: var(--tile); border-radius: 12px; border: 3px solid rgba(201, 194, 242, .35); background: rgba(10, 6, 40, .6); display: grid; place-items: center; font-weight: 900; font-size: calc(var(--tile) * .52); text-transform: uppercase; color: var(--ink); position: relative; }
.t.f { background: var(--cream); border-color: var(--ink); box-shadow: 0 4px 0 var(--ink); animation: pop .12s; }
@keyframes pop { 50% { transform: scale(1.1); } }
.t.g, .t.y, .t.x { color: #fff; border-color: var(--ink); text-shadow: 0 2px 0 rgba(0, 0, 0, .25); }
.t.g { background: var(--g); box-shadow: 0 4px 0 var(--g-d), 0 4px 0 2px var(--ink); }
.t.y { background: var(--y); box-shadow: 0 4px 0 var(--y-d), 0 4px 0 2px var(--ink); }
.t.x { background: var(--x); box-shadow: 0 4px 0 var(--x-d), 0 4px 0 2px var(--ink); }
.t.flip { animation: flip .5s ease-in-out; }
@keyframes flip { 0% { transform: rotateX(0); } 50% { transform: rotateX(90deg); } 100% { transform: rotateX(0); } }
.t.jump { animation: jump .55s ease; }
@keyframes jump { 30% { transform: translateY(-22px) scale(1.06); } 60% { transform: translateY(3px); } }
.legend { display: flex; justify-content: center; gap: 12px; font-size: 12px; font-weight: 700; color: var(--lav); margin: 6px 0 4px; flex-wrap: wrap; }
.lg { display: inline-block; width: 13px; height: 13px; border-radius: 4px; vertical-align: -2px; margin-right: 4px; border: 2px solid var(--ink); }
.lg.g { background: var(--g); } .lg.y { background: var(--y); } .lg.x { background: var(--x); }

/* keyboard */
.kb { flex: 0 0 auto; margin-top: auto; display: flex; flex-direction: column; gap: 6px; padding-top: 4px; }
.kr { display: flex; gap: 5px; justify-content: center; }
.k { flex: 1 1 0; max-width: 46px; height: 52px; border-radius: 10px; border: 2px solid var(--ink); background: var(--lav); color: var(--ink); font-weight: 900; font-size: 18px; box-shadow: 0 3px 0 var(--ink); padding: 0; text-transform: uppercase; }
.k.w { max-width: 72px; flex: 1.6 1 0; font-size: 13px; }
.k.w svg { width: 26px; height: 26px; vertical-align: middle; }
.k:active, .k.press { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.k.g { background: var(--g); color: #fff; } .k.y { background: var(--y); color: #fff; } .k.x { background: var(--x); color: #c9c4ea; }
.k.ent { background: var(--sun); }

/* packs (clue menu) */
#packs, #cats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; overflow-y: auto; padding: 4px 2px 10px; touch-action: pan-y; align-content: start; }
.pack { display: flex; align-items: center; gap: 10px; text-align: left; border: 3px solid var(--ink); border-radius: 18px; background: var(--cream); color: var(--ink); padding: 8px; box-shadow: 0 4px 0 var(--ink); min-height: 78px; }
.pack:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--ink); }
.ico { width: 54px; height: 54px; flex: 0 0 auto; border-radius: 50%; background: #fff url(img/icons.webp) no-repeat; background-size: 900% 100%; border: 2px solid var(--ink); }
.pack b { display: block; font-size: 15px; font-weight: 900; line-height: 1.1; }
.pack small { display: block; font-size: 12px; font-weight: 700; color: #6b6290; margin-top: 3px; }
.pack .stars { color: var(--y-d); font-weight: 900; font-size: 13px; }
.st { display: inline-block; width: 22px; height: 22px; background: var(--sun); clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%); vertical-align: middle; }

/* clue play */
.clueTop { display: flex; align-items: center; gap: 10px; margin: 2px 0 6px; }
.clueTop img { width: 46px; height: auto; flex: 0 0 auto; }
.clueTop > div:nth-child(2) { flex: 1 1 auto; min-width: 0; }
.clueTop b { display: block; font-size: 18px; font-weight: 900; text-shadow: 0 2px 0 var(--ink); }
.clueTop span { display: block; font-size: 13px; color: var(--lav); font-weight: 700; }
#cStars { display: flex; align-items: center; gap: 5px; background: rgba(10, 6, 40, .5); border-radius: 20px; padding: 4px 12px 4px 8px; font-size: 18px; font-weight: 900; }
#clues { flex: 0 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 7px; overflow-y: auto; touch-action: pan-y; }
.clue { display: flex; gap: 10px; align-items: flex-start; border: 3px solid var(--ink); border-radius: 16px; background: var(--cream); color: var(--ink); padding: 9px 12px; font-size: 16px; font-weight: 700; line-height: 1.3; box-shadow: 0 3px 0 var(--ink); }
.clue i { flex: 0 0 auto; width: 26px; height: 26px; border-radius: 50%; background: var(--coral); color: #fff; font-style: normal; font-weight: 900; display: grid; place-items: center; font-size: 14px; border: 2px solid var(--ink); }
.clue.new { animation: drop .35s ease; }
@keyframes drop { 0% { transform: translateY(-10px) scale(.96); opacity: 0; } 100% { transform: none; opacity: 1; } }
.clue.lock { background: rgba(10, 6, 40, .35); border-style: dashed; border-color: rgba(201, 194, 242, .45); color: var(--lav); box-shadow: none; }
.clue.lock i { background: var(--x); }
#cSlots { display: flex; flex-wrap: wrap; justify-content: center; gap: 5px; margin: 8px 0 6px; flex: 0 0 auto; }
#cSlots .t { --tile: var(--ctile, 40px); }
#cSlots .gap { width: 12px; }
#cSlots.shake { animation: shake .45s; }
#cSlots .t.rv { background: var(--y); color: #fff; border-color: var(--ink); }
#cBtns { display: flex; gap: 8px; justify-content: center; margin-bottom: 4px; flex: 0 0 auto; }

/* party */
.partyHead { display: flex; align-items: center; gap: 10px; margin: 2px 0 8px; }
.partyHead img { width: 54px; height: auto; flex: 0 0 auto; }
.partyHead b { display: block; font-size: 20px; font-weight: 900; text-shadow: 0 2px 0 var(--ink); }
.partyHead span { display: block; font-size: 13px; font-weight: 700; color: var(--lav); line-height: 1.3; }
#cats { flex: 1 1 auto; min-height: 0; }
#pOpts { display: flex; gap: 10px; justify-content: space-between; flex-wrap: wrap; padding: 8px 4px 2px; flex: 0 0 auto; }
.opt { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 14px; color: var(--lav); }
.seg { display: flex; background: rgba(10, 6, 40, .5); border-radius: 12px; padding: 3px; }
.seg button { border: 0; background: transparent; color: var(--lav); font-weight: 900; padding: 6px 10px; border-radius: 9px; font-size: 14px; }
.seg button.on { background: var(--cream); color: var(--ink); }
.toggle { width: 54px; height: 30px; border-radius: 16px; border: 2px solid var(--ink); background: var(--x); position: relative; padding: 0; }
.toggle i { position: absolute; top: 2px; left: 2px; width: 22px; height: 22px; border-radius: 50%; background: var(--cream); transition: left .15s; }
.toggle[aria-pressed="true"] { background: var(--g); }
.toggle[aria-pressed="true"] i { left: 26px; }

#partyPlay { gap: 10px; }
#pBar { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
#pTime { position: relative; width: 58px; height: 58px; flex: 0 0 auto; }
#pTime svg { width: 100%; height: 100%; transform: rotate(-90deg); }
#pTime .trk { fill: rgba(10, 6, 40, .5); stroke: rgba(201, 194, 242, .3); stroke-width: 5; }
#pTime .ring { fill: none; stroke: var(--sun); stroke-width: 5; stroke-linecap: round; stroke-dasharray: 119.4; stroke-dashoffset: 0; transition: stroke-dashoffset .25s linear; }
#pTime.low .ring { stroke: var(--coral); }
#pTime b { position: absolute; inset: 0; display: grid; place-items: center; font-size: 20px; font-weight: 900; }
#pCat { flex: 1 1 auto; font-size: 18px; font-weight: 900; text-shadow: 0 2px 0 var(--ink); }
#pScore { text-align: center; background: var(--g); border: 3px solid var(--ink); border-radius: 14px; padding: 2px 12px; box-shadow: 0 3px 0 var(--ink); }
#pScore b { display: block; font-size: 24px; font-weight: 900; line-height: 1.1; }
#pScore span { font-size: 11px; font-weight: 800; }
#pCard { flex: 1 1 auto; min-height: 0; border: 4px solid var(--ink); border-radius: 26px; background: var(--cream); color: var(--ink); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 16px; box-shadow: 0 6px 0 var(--ink); text-align: center; transition: background .15s; }
#pCard.okf { background: #b9f0c9; } #pCard.passf { background: #ffd9a8; }
#pWord { font-size: clamp(36px, 11vw, 76px); font-weight: 900; line-height: 1.05; word-break: break-word; }
#pWord.in { animation: wordIn .3s ease; }
@keyframes wordIn { 0% { transform: scale(.6); opacity: 0; } 70% { transform: scale(1.06); } 100% { transform: none; opacity: 1; } }
#pTip { font-size: 14px; font-weight: 700; color: #6b6290; margin-top: 12px; }
#pBtns { display: flex; gap: 10px; flex: 0 0 auto; }
.pbtn { flex: 1 1 0; border: 3px solid var(--ink); border-radius: 20px; padding: 14px 6px 10px; color: #fff; box-shadow: 0 5px 0 var(--ink); }
.pbtn b { display: block; font-size: 24px; font-weight: 900; letter-spacing: 1px; text-shadow: 0 2px 0 rgba(0, 0, 0, .25); }
.pbtn small { display: block; font-size: 11px; font-weight: 700; opacity: .9; margin-top: 2px; }
.pbtn.ok { background: var(--g); } .pbtn.pass { background: var(--y); }
.pbtn:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--ink); }
@media (orientation: landscape) and (max-height: 500px) {
  #tabs { display: none; }
  #partyPlay { display: grid; grid-template-columns: 1fr 3fr 1fr; grid-template-rows: auto 1fr; }
  #partyPlay.hidden { display: none !important; }
  #pBar { grid-column: 1 / 4; }
  #pBtns { display: contents; }
  #pPass { grid-row: 2; grid-column: 1; }
  #pCard { grid-row: 2; grid-column: 2; }
  #pOkBtn { grid-row: 2; grid-column: 3; }
}

/* buttons */
.btn { border: 3px solid var(--ink); border-radius: 16px; background: var(--coral); color: #fff; font-weight: 900; font-size: 18px; padding: 11px 18px; box-shadow: 0 4px 0 var(--ink); text-shadow: 0 2px 0 rgba(0, 0, 0, .2); }
.btn:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--ink); }
.btn.big { font-size: 22px; padding: 15px 26px; width: 100%; max-width: 330px; animation: breathe 1.8s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(1.04); } }
.btn.alt { background: var(--lav); color: var(--ink); text-shadow: none; }
.btn.small { font-size: 14px; padding: 8px 12px; border-radius: 13px; }
.btn.ghost { background: rgba(10, 6, 40, .4); color: var(--lav); border-color: rgba(201, 194, 242, .5); box-shadow: none; text-shadow: none; }
.btn:disabled { opacity: .45; }

/* overlays */
.overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 12px; background: rgba(14, 9, 45, .72); z-index: 10; overflow-y: auto; touch-action: pan-y; }
.panel { position: relative; width: 100%; max-width: 420px; margin: auto; background: var(--cream); color: var(--ink); border: 4px solid var(--ink); border-radius: 26px; padding: 16px 18px 18px; text-align: center; box-shadow: 0 8px 0 var(--ink); animation: panelIn .3s ease; }
@keyframes panelIn { 0% { transform: translateY(20px) scale(.95); opacity: 0; } 100% { transform: none; opacity: 1; } }
.panel h1 { margin: 0; font-size: 42px; font-weight: 900; line-height: 1; color: var(--bg2); }
.panel h1 span { color: var(--coral); }
.panel h2 { margin: 2px 0 6px; font-size: 28px; font-weight: 900; color: var(--bg2); }
.panel .tag { margin: 2px 0 6px; font-weight: 900; color: var(--coral-d); font-size: 15px; }
.panel .intro { margin: 0 0 12px; font-size: 14px; line-height: 1.4; font-weight: 700; color: #4a4270; }
.cilBig { width: 118px; height: auto; margin: -6px 0 2px; animation: bob 2.4s ease-in-out infinite; }
.cilMid { width: 96px; height: auto; margin: -4px 0 0; }
@keyframes bob { 50% { transform: translateY(-6px) rotate(-2deg); } }
.modes { display: flex; gap: 8px; margin-top: 12px; }
.modeCard { flex: 1 1 0; display: flex; align-items: center; gap: 6px; text-align: left; border: 3px solid var(--ink); border-radius: 16px; background: #fff; color: var(--ink); padding: 6px 8px; box-shadow: 0 3px 0 var(--ink); }
.modeCard img { width: 34px; height: auto; flex: 0 0 auto; }
.modeCard b { display: block; font-size: 14px; font-weight: 900; line-height: 1.1; }
.modeCard small { display: block; font-size: 11px; font-weight: 700; color: #6b6290; }
.ctl { display: flex; flex-wrap: wrap; gap: 6px 12px; justify-content: center; margin-top: 12px; font-size: 12px; font-weight: 700; color: #6b6290; }
kbd { display: inline-block; min-width: 22px; padding: 1px 5px; border: 2px solid var(--ink); border-bottom-width: 3px; border-radius: 6px; background: #fff; color: var(--ink); font-family: inherit; font-weight: 900; font-size: 11px; margin-right: 2px; }
@media (hover: hover) and (pointer: fine) { .touchOnly { display: none; } }
.xbtn { position: absolute; top: 8px; right: 10px; width: 36px; height: 36px; border-radius: 50%; border: 2px solid var(--ink); background: #fff; font-size: 22px; font-weight: 900; line-height: 1; color: var(--ink); }
.sm { font-size: 13px; font-weight: 700; color: #6b6290; margin: 8px 0 4px; }
#rWord { display: flex; gap: 5px; justify-content: center; margin: 4px 0 10px; }
#rWord .t { --tile: 40px; }
#rStats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
#rStats div { background: #fff; border: 2px solid var(--ink); border-radius: 12px; padding: 6px 2px; }
#rStats b { display: block; font-size: 22px; font-weight: 900; }
#rStats span { font-size: 11px; font-weight: 700; color: #6b6290; }
#rDist { display: flex; flex-direction: column; gap: 3px; text-align: left; }
.dr { display: flex; align-items: center; gap: 6px; font-weight: 900; font-size: 13px; }
.dr i { font-style: normal; height: 20px; min-width: 24px; border-radius: 6px; background: var(--x); color: #fff; padding: 0 7px; display: flex; align-items: center; justify-content: flex-end; }
.dr.me i { background: var(--g); }
#rNext { font-size: 14px; font-weight: 800; margin: 10px 0 8px; color: var(--bg2); }
.row2 { display: flex; gap: 8px; justify-content: center; margin-top: 8px; }
.row2 .btn { flex: 1 1 0; }
.big { font-size: 26px; font-weight: 900; margin: 0 0 6px; color: var(--bg2); }
#peList { max-height: 34vh; overflow-y: auto; display: flex; flex-wrap: wrap; gap: 5px; justify-content: center; touch-action: pan-y; }
#peList span { border: 2px solid var(--ink); border-radius: 10px; padding: 3px 8px; font-weight: 800; font-size: 14px; }
#peList .ok { background: var(--g); color: #fff; } #peList .no { background: #e9e3f7; color: #7d76a0; text-decoration: line-through; }
#ceStars { display: flex; justify-content: center; gap: 6px; align-items: center; font-size: 30px; font-weight: 900; color: var(--bg2); }
#ceStars .st { width: 34px; height: 34px; }

#toast { position: absolute; left: 50%; top: 34%; transform: translateX(-50%); background: var(--ink); color: #fff; font-weight: 900; padding: 9px 16px; border-radius: 14px; z-index: 20; font-size: 15px; box-shadow: 0 4px 0 rgba(0, 0, 0, .3); white-space: nowrap; animation: toastIn .2s ease; }
@keyframes toastIn { 0% { transform: translate(-50%, -8px); opacity: 0; } }
#fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 30; }

@media (max-height: 700px) {
  .k { height: 46px; }
  .legend { display: none; }
  .headline span { font-size: 12px; }
  .headline b { font-size: 17px; }
}
@media (max-height: 600px) { .cilBig { width: 80px; } .panel h1 { font-size: 34px; } }
