:root {
  --bg1: #2b2370; --bg2: #4a2a86; --mango: #ffb627; --pink: #ff5fa2; --cream: #fff7e6; --ink: #2a1a12; --teal: #18b7a0;
  font-size: clamp(11px, min(2.3vh, 1.7vw) + 4px, 24px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  font-family: "Noto Sans Thai", "Leelawadee UI", "Leelawadee", Tahoma, "Thonburi", sans-serif;
  color: var(--cream); user-select: none; -webkit-user-select: none; touch-action: none;
  background: radial-gradient(circle at 20% 10%, #5a3aa0 0, transparent 45%), radial-gradient(circle at 90% 90%, #7a2a7a 0, transparent 40%), linear-gradient(160deg, var(--bg1), var(--bg2));
}
body::before { content: ""; position: fixed; inset: 0; pointer-events: none; opacity: .08;
  background-image: radial-gradient(circle, #fff 1.2px, transparent 1.6px); background-size: 22px 22px; }
.hidden { display: none !important; }
button { font: inherit; cursor: pointer; border: 0; color: inherit; }
#app { position: fixed; inset: 0; display: flex; flex-direction: column; }
#hud { display: flex; align-items: center; gap: .5rem; padding: .4rem .6rem; flex: none; }
.tb { width: 2.6rem; height: 2.6rem; border-radius: .8rem; background: #ffffff1f; display: grid; place-items: center; position: relative; flex: none; box-shadow: inset 0 -3px 0 #0003; }
.tb svg { width: 1.4rem; height: 1.4rem; }
.tb:active { transform: translateY(1px); }
.tb.hint { background: var(--mango); color: var(--ink); }
.tb.hint i { position: absolute; right: -.3rem; top: -.3rem; background: var(--pink); color: #fff; font-style: normal; font-weight: 700; font-size: .7rem; border-radius: 1rem; min-width: 1.1rem; height: 1.1rem; display: grid; place-items: center; }
.tb.hint.empty { opacity: .45; }
#mute .x { display: none; } #mute.off .x { display: block; } #mute.off .on { display: none; }
.mid { flex: 1; min-width: 0; }
.row1 { display: flex; justify-content: space-between; align-items: center; gap: .4rem; font-weight: 700; font-size: .95rem; white-space: nowrap; }
.row1 #lvName { overflow: hidden; text-overflow: ellipsis; }
#dots { display: flex; gap: .25rem; }
#dots i { width: .8rem; height: .8rem; border-radius: 50%; background: #ffffff33; border: 2px solid #ffffff66; }
#dots i.on { background: var(--teal); border-color: #b8fff1; transform: scale(1.15); transition: transform .2s; }
.tbar { position: relative; height: .9rem; background: #00000040; border-radius: 1rem; margin-top: .25rem; overflow: hidden; }
#tfill { position: absolute; inset: 0; width: 100%; background: linear-gradient(90deg, var(--mango), var(--pink)); border-radius: 1rem; transform-origin: left; }
#tfill.low { background: #ff4d4d; }
.tbar b { position: absolute; right: .4rem; top: 50%; transform: translateY(-50%); font-size: .7rem; color: #fff; text-shadow: 0 1px 2px #000a; }
#instr { margin: 0 .6rem .2rem; font-size: .8rem; text-align: center; color: #ffe9b8; flex: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#board { flex: 1; min-height: 0; position: relative; }
#cv { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
#revealBar { flex: none; display: flex; gap: .5rem; align-items: center; justify-content: center; flex-wrap: wrap; padding: .35rem .6rem .5rem; font-size: .85rem; color: #ffd9a0; }
.pill { background: var(--mango); color: var(--ink); font-weight: 700; border-radius: 2rem; padding: .4rem 1rem; box-shadow: inset 0 -3px 0 #0002; }
.pill.alt { background: #ffffff26; color: #fff; }
#toast { position: fixed; left: 50%; top: 4.2rem; transform: translateX(-50%); background: #000000b0; color: #fff; padding: .4rem .9rem; border-radius: 2rem; font-size: .85rem; pointer-events: none; z-index: 30; white-space: nowrap; }

.ov { position: fixed; inset: 0; display: grid; place-items: center; background: #160f3ccc; z-index: 20; padding: .6rem; }
.card { background: var(--cream); color: var(--ink); border-radius: 1.4rem; padding: 1.1rem 1.3rem; max-width: 30rem; width: 100%; max-height: 96vh; overflow: auto; text-align: center; box-shadow: 0 10px 0 #0003, 0 0 0 4px var(--mango); position: relative; }
.card::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: .55rem; border-radius: 1.4rem 1.4rem 0 0;
  background: repeating-linear-gradient(90deg, var(--pink) 0 1.2rem, var(--mango) 1.2rem 2.4rem, var(--teal) 2.4rem 3.6rem); }
#start .card { max-width: 34rem; }
.chang { width: 6.5rem; height: auto; display: block; margin: .2rem auto 0; filter: drop-shadow(0 4px 0 #0002); }
h1 { margin: .2rem 0 .2rem; font-size: 2rem; line-height: 1.15; color: #6a2bb0; }
h1 span { display: block; font-size: .95rem; color: #d6306f; font-weight: 700; }
.lead { margin: .3rem 0 .6rem; font-size: .9rem; line-height: 1.45; }
.big { display: block; width: 100%; background: linear-gradient(180deg, #ff74b0, var(--pink)); color: #fff; font-weight: 800; font-size: 1.35rem; border-radius: 1rem; padding: .6rem; box-shadow: inset 0 -5px 0 #0003; }
.big.alt { background: #efe2f9; color: #4a2a86; font-size: 1rem; padding: .45rem; box-shadow: inset 0 -3px 0 #0001; }
.row2 { display: flex; gap: .5rem; margin-top: .5rem; }
.mid2 { flex: 1; background: #efe2f9; color: #4a2a86; border-radius: .9rem; padding: .45rem .3rem; box-shadow: inset 0 -3px 0 #0001; }
.mid2 b { display: block; font-size: 1rem; } .mid2 small { display: block; font-size: .72rem; opacity: .8; }
.mid2.hot { background: var(--mango); color: var(--ink); }
.keys { font-size: .72rem; margin: .55rem 0 0; line-height: 1.9; color: #5b4a63; }
kbd { background: #fff; border: 1px solid #c9b8d8; border-bottom-width: 3px; border-radius: .35rem; padding: 0 .3rem; font-family: inherit; font-size: .7rem; color: #4a2a86; }
.chead { display: flex; justify-content: space-between; align-items: center; }
.chead h2 { margin: 0; color: #6a2bb0; }
.chead .tb { background: #efe2f9; color: #4a2a86; }
.card.wide { max-width: 46rem; text-align: left; }
#mList { margin-top: .4rem; }
.chap { margin: .5rem 0 .2rem; font-weight: 800; color: #d6306f; font-size: .95rem; }
.lvrow { display: grid; grid-template-columns: repeat(5, 1fr); gap: .4rem; }
.lv { background: #efe2f9; color: #4a2a86; border-radius: .8rem; padding: .35rem 0 .25rem; font-weight: 800; font-size: 1.05rem; box-shadow: inset 0 -3px 0 #0001; }
.lv small { display: block; font-size: .7rem; color: #e39a00; letter-spacing: 1px; min-height: .9rem; }
.lv.lock { opacity: .4; cursor: default; }
.lv.cur { box-shadow: 0 0 0 3px var(--pink); }
.res h2 { margin: .3rem 0 0; font-size: 1.8rem; color: #6a2bb0; }
.bigstars { font-size: 2.4rem; letter-spacing: .3rem; color: #e0d3ea; margin: .1rem 0; }
.bigstars b { color: #ffb627; text-shadow: 0 2px 0 #c97f00; }
.rtxt { margin: .2rem 0 .7rem; font-size: .95rem; line-height: 1.5; }
.btns { display: grid; gap: .45rem; }
.btns .big.alt { display: inline-block; }

@media (min-width: 700px) and (max-height: 560px) {
  #start .card { max-width: 44rem; display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; align-items: center; text-align: left; padding: .9rem 1.1rem; }
  #start .chang { width: 4.6rem; float: left; margin: 0 .6rem .2rem 0; }
  h1 { font-size: 1.6rem; }
  .res .btns { grid-template-columns: 1fr 1fr 1fr; }
  .res .btns .big { font-size: 1rem; padding: .5rem .3rem; }
}
@media (max-height: 420px) {
  :root { font-size: clamp(10px, 3vh, 14px); }
  #instr { display: none; }
  .chang { display: none !important; }
  .bigstars { font-size: 1.8rem; }
  .card { padding: .7rem .9rem; }
  .lead { margin: .2rem 0 .3rem; }
}
@media (max-width: 699px) and (max-height: 560px) {
  #start .card, .res { max-width: 36rem; }
  .chang { display: none !important; }
}
