:root {
  --bg: #15110e;
  --panel: #211b16;
  --panel2: #2d251e;
  --line: #3d3128;
  --ink: #f4ece1;
  --muted: #b9a993;
  --red: #e53935;
  --gold: #ffb300;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); overscroll-behavior: none; }
body { font-family: 'Hind Siliguri', 'Noto Sans Bengali', system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
button { font-family: inherit; color: inherit; }

#app {
  max-width: 560px; margin: 0 auto; height: 100vh; height: 100dvh;
  display: flex; flex-direction: column; overflow: hidden;
  padding-bottom: env(safe-area-inset-bottom);
}

#topbar { display: flex; align-items: center; justify-content: space-between; padding: 6px 10px; }
.brand { font-family: 'Galada', serif; font-size: 22px; color: #fff; text-shadow: 2px 2px 0 var(--red); }
.icon-btn { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; width: 38px; height: 38px; font-size: 17px; cursor: pointer; }

#stage { position: relative; flex: 0 0 auto; display: flex; justify-content: center; align-items: flex-start; min-height: 0; }
#cv { display: block; touch-action: none; user-select: none; -webkit-user-select: none; border-radius: 6px; }

/* Overlay cards */
#overlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  padding: 14px; background: rgba(10, 8, 6, .55); overflow-y: auto; z-index: 5;
}
#overlay[hidden] { display: none; }
#overlay.title { background: linear-gradient(transparent 35%, rgba(10,8,6,.9)); align-items: flex-end; }
#overlay.bottom { background: transparent; align-items: flex-end; }
#overlay.results { align-items: flex-start; background: rgba(10,8,6,.75); }
.ov-card {
  width: 100%; max-width: 420px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; padding: 16px; display: flex; flex-direction: column; gap: 10px;
  animation: pop .25s ease-out; box-shadow: 0 10px 30px rgba(0,0,0,.5);
  margin: auto; /* centers when it fits, scrolls from the top when it doesn't */
}
#overlay.title .ov-card, #overlay.bottom .ov-card { margin: auto auto 0; }
#overlay.results .ov-card { margin: 0 auto auto; }
#overlay.title .ov-card { background: transparent; border: 0; box-shadow: none; text-align: center; }
#overlay.bottom .ov-card { background: rgba(33,27,22,.94); }
@keyframes pop { from { transform: scale(.9); opacity: 0; } }
.ov-card h2 { font-family: 'Galada', serif; font-weight: 400; font-size: 34px; margin: 0; color: var(--gold); line-height: 1.2; }
.ov-card p { margin: 0; line-height: 1.6; }
.ov-btns { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.round-k { color: var(--muted); font-size: 14px; letter-spacing: .05em; }
.how { margin: 0; padding-left: 18px; line-height: 1.6; font-size: 15px; }
.how li { margin: 3px 0; }
.lesson { border-left: 4px solid var(--gold); padding-left: 10px; color: #e6dccd; }
.q { font-weight: 700; }
.logo {
  font-family: 'Galada', serif; font-weight: 400; font-size: clamp(48px, 14vw, 72px); margin: 0;
  color: #fff; text-shadow: 4px 4px 0 var(--red), 0 8px 20px rgba(0,0,0,.7); transform: rotate(-3deg);
}
.tagline { color: #f0e6d8; text-shadow: 0 2px 6px #000; }
.best { color: var(--gold); font-weight: 700; }
.fine { font-size: 12px; color: #a99a88; }

.btn {
  font-size: 18px; font-weight: 700; padding: 12px; border-radius: 12px; cursor: pointer;
  background: var(--panel2); border: 1px solid var(--line); width: 100%; position: relative; overflow: hidden;
}
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; box-shadow: 0 4px 0 #8e1c1a; }
.btn.primary:active { transform: translateY(2px); box-shadow: 0 2px 0 #8e1c1a; }
.btn.ghost { background: transparent; }
.btn.hold { touch-action: none; user-select: none; }
.btn.hold .fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: #ff80ab; transition: width .05s linear; }
.btn.hold .lbl { position: relative; }

.ev-list { display: flex; flex-wrap: wrap; gap: 6px; }
.ev-list span { padding: 4px 10px; border-radius: 99px; font-size: 14px; }
.ev-list .on { background: #0d3b52; color: #b3e5fc; }
.ev-list .off { background: #2a2420; color: #6d6156; text-decoration: line-through; }
.mult { font-size: 20px; } .mult b { color: #69f0ae; font-size: 26px; }

.help { background: #10261f; border: 1px solid #1f5a45; border-radius: 12px; padding: 10px 12px; font-size: 14px; line-height: 1.7; }
.help b { color: #80cbc4; display: block; }
.help a { color: #fff; font-weight: 700; font-size: 17px; text-decoration: none; }
.help small { display: block; color: var(--muted); margin-top: 4px; }

/* Results */
.rank { font-size: 56px; text-align: center; line-height: 1; }
.rank-name { font-family: 'Galada', serif; font-size: 34px; text-align: center; color: #fff; text-shadow: 3px 3px 0 var(--red); }
.score { text-align: center; color: var(--gold); font-weight: 700; font-size: 18px; }
.paper {
  background: #f3ead7; color: #1b1410; border-radius: 4px; padding: 12px; font-family: 'Hind Siliguri', serif;
  transform: rotate(-1.5deg); animation: paper .6s ease-out; box-shadow: 0 6px 18px rgba(0,0,0,.5);
}
@keyframes paper { from { transform: rotate(-200deg) scale(.1); opacity: 0; } }
.mast { font-family: 'Galada', serif; font-size: 28px; text-align: center; border-bottom: 3px double #1b1410; }
.dateline { font-size: 11px; text-align: center; margin: 2px 0 6px; }
.headline { font-weight: 700; font-size: 21px; line-height: 1.3; }
.sub { font-size: 13px; margin: 4px 0 8px; color: #4e342e; }
.cols { display: grid; grid-template-columns: 2fr 1fr; gap: 10px; font-size: 13px; line-height: 1.5; border-top: 1px solid #8d6e63; padding-top: 6px; }
.ad { border: 1px dashed #5d4037; padding: 6px; text-align: center; font-size: 12px; }

/* Controls */
#controls { flex: 0 0 auto; padding: 6px 10px 10px; display: flex; flex-direction: column; gap: 6px; }
#hint { font-size: 13px; color: var(--muted); text-align: center; line-height: 1.4; min-height: 1.4em; }
#hint[hidden], #cards[hidden], #movebar[hidden], #action[hidden] { display: none; }
#movebar { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
#movebar::-webkit-scrollbar { display: none; }
#movebar button, .card-btn {
  flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 0; min-width: 66px;
  background: var(--panel2); border: 2px solid var(--line); border-radius: 12px; padding: 5px 6px;
  font-size: 11.5px; font-weight: 600; cursor: pointer; line-height: 1.3;
}
#movebar button .ic, .card-btn .ic { font-size: 22px; line-height: 1.2; }
#movebar button.next { border-color: #69f0ae; border-style: dashed; }
#movebar button.on { border-color: var(--gold); background: #4a3418; box-shadow: 0 0 12px rgba(255,179,0,.4); }
#wave-btn { border-color: #e040fb !important; background: linear-gradient(135deg, #6a1b9a, #ad1457) !important; animation: glow .6s infinite alternate; }
@keyframes glow { to { box-shadow: 0 0 18px #e040fb; } }
#cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.card-btn { min-width: 0; padding: 8px 2px; font-size: 11px; }
.card-btn .pips { font-size: 10px; color: #ffca28; letter-spacing: 1px; min-height: 1.2em; }
.card-btn.glow { animation: cardglow 1.1s ease-out 2; }
@keyframes cardglow { 0%,100% { box-shadow: none; } 40% { box-shadow: 0 0 0 3px #69f0ae, 0 0 18px #69f0ae; border-color: #69f0ae; } }
.card-btn.locked { opacity: .35; cursor: not-allowed; }
.card-btn:not(.locked):active { transform: scale(.95); border-color: var(--gold); }
#action {
  width: 100%; font-size: 22px; font-weight: 700; padding: 16px; border-radius: 14px; border: 0;
  background: var(--red); color: #fff; cursor: pointer; touch-action: none; user-select: none; -webkit-user-select: none;
  box-shadow: 0 5px 0 #8e1c1a; transition: transform .05s;
}
#action.down { transform: translateY(4px) scale(.98); box-shadow: 0 1px 0 #8e1c1a; background: #ff5252; }
#action.act-kiss { background: #d81b60; box-shadow: 0 5px 0 #880e4f; }
#action.act-suplex, #action.act-press { background: #ef6c00; box-shadow: 0 5px 0 #a64700; }
#action.act-pond { background: #0277bd; box-shadow: 0 5px 0 #01497c; }
#action.act-uthbos { background: #6a1b9a; box-shadow: 0 5px 0 #3d0f5a; }
#action.act-tread { background: #2e7d32; box-shadow: 0 5px 0 #1b4d1e; }

/* Share sheet */
.top-r { display: flex; gap: 6px; }
#sheet { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.6); display: flex; align-items: flex-end; justify-content: center; animation: fadeIn .2s; }
@keyframes fadeIn { from { opacity: 0; } }
.sheet-card { width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; background: var(--panel); border-radius: 18px 18px 0 0; padding: 14px 14px calc(16px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 10px; animation: up .25s ease-out; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet-head { display: flex; justify-content: space-between; align-items: center; font-size: 17px; }
.sheet-x { background: none; border: 0; font-size: 20px; cursor: pointer; padding: 4px 8px; }
.sheet-prev { display: flex; justify-content: center; min-height: 120px; align-items: center; }
.sheet-prev img { max-height: 38vh; max-width: 100%; border-radius: 10px; box-shadow: 0 6px 18px rgba(0,0,0,.5); }
.sheet-spin { color: var(--muted); }
.sheet-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; }
.sh { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 4px; border-radius: 12px; background: var(--panel2); border: 1px solid var(--line); color: var(--ink); text-decoration: none; font-size: 13px; font-weight: 600; cursor: pointer; }
.sh span { font-size: 24px; }
.sh.fb { background: #1877f2; border-color: #1877f2; color: #fff; }
.sh.wa { background: #1fa855; border-color: #1fa855; color: #fff; }
.sh[hidden] { display: none; }
.sheet-tip { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.5; }

/* Round 3: one set of hold-to-intensify move buttons */
#movebar.hold-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; overflow: visible; padding-bottom: 0; }
#movebar.hold-grid button {
  position: relative; overflow: hidden; min-width: 0; padding: 10px 4px 8px; font-size: 12px;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
#movebar.hold-grid button .fill {
  position: absolute; left: 0; top: 0; bottom: 0; width: calc(var(--p, 0) * 100%);
  background: linear-gradient(90deg, rgba(255,202,40,.35), rgba(229,57,53,.55)); pointer-events: none;
}
#movebar.hold-grid button .ic, #movebar.hold-grid button .nm { position: relative; }
#movebar.hold-grid button .ic { font-size: 26px; }
#movebar.hold-grid button.holding { border-color: #ffca28; transform: scale(.96); box-shadow: 0 0 14px rgba(255,202,40,.5); }
#movebar.hold-grid button.deny { animation: deny .3s; }
@keyframes deny { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
