:root {
  --bg: #121110;
  --bg-2: #181715;
  --panel: #1d1c19;
  --panel-2: #26241f;
  --panel-3: #322f2a;
  --line: #ffffff12;
  --text: #f3f1ea;
  --muted: #9d988e;
  --ivory: #ece9e1;
  --ink: #141311;
  --accent: #81b64c;
  --accent-dark: #5d8a32;
  --accent-glow: #81b64c55;
  --danger: #e2533f;
  --gold: #f5b83d;
  --radius: 16px;

  --light: #ebecd0;
  --dark: #739552;
  --last-light: #f5f682;
  --last-dark: #b9ca43;
  --hint: rgba(64, 160, 255, 0.55);

  --board-size: min(94vw, calc(100vh - 250px), 720px);
  --font: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* Màu bàn cờ */
body[data-board="brown"] { --light: #f0d9b5; --dark: #b58863; --last-light: #cdd26a; --last-dark: #aaa23a; }
body[data-board="blue"] { --light: #dee3e6; --dark: #8ca2ad; --last-light: #c3d888; --last-dark: #92b166; }
body[data-board="purple"] { --light: #efe6f7; --dark: #9479b8; --last-light: #e7d27a; --last-dark: #c3a24c; }
body[data-board="night"] { --light: #9fa8b5; --dark: #4f5b6c; --last-light: #c8c36b; --last-dark: #8f8a3c; }
body[data-board="marble"] { --light: #e8e6e1; --dark: #7a7a7a; --last-light: #d4e08a; --last-dark: #a8b04a; }
body[data-board="red"] { --light: #f5d6d0; --dark: #b3544a; --last-light: #e8d070; --last-dark: #c0a030; }
body[data-board="emerald"] { --light: #d4f0e0; --dark: #2e7d5b; --last-light: #c8e070; --last-dark: #8fad3a; }
body[data-board="wood"] { --light: #e8c9a0; --dark: #8b5a2b; --last-light: #d4c060; --last-dark: #a89030; }

/* Bàn cờ gradient */
body[data-board="gradient"] {
  --light: #1a1a2e; --dark: #16213e;
  --last-light: #e9456055; --last-dark: #e9456088;
}
body[data-board="gradient"] .sq.light { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
body[data-board="gradient"] .sq.dark { background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%); }
body[data-board="gradient"] .sq.last.light { background: linear-gradient(135deg, #a8e063 0%, #56ab2f 100%); }
body[data-board="gradient"] .sq.last.dark { background: linear-gradient(135deg, #f7971e 0%, #ffd200 100%); }

body[data-board="sunset"] {
  --light: #2c1810; --dark: #1a0f0a;
  --last-light: #ff9a3c55; --last-dark: #ff6b3588;
}
body[data-board="sunset"] .sq.light { background: linear-gradient(160deg, #ff9a3c 0%, #ff6b35 50%, #e85d04 100%); }
body[data-board="sunset"] .sq.dark { background: linear-gradient(160deg, #7209b7 0%, #3a0ca3 50%, #240046 100%); }
body[data-board="sunset"] .sq.last.light { background: linear-gradient(160deg, #90e0ef 0%, #00b4d8 100%); }
body[data-board="sunset"] .sq.last.dark { background: linear-gradient(160deg, #48cae4 0%, #0077b6 100%); }

body[data-board="ocean"] {
  --light: #0a1628; --dark: #061018;
  --last-light: #00f5d455; --last-dark: #00bbf988;
}
body[data-board="ocean"] .sq.light { background: linear-gradient(145deg, #00f5d4 0%, #00bbf9 100%); }
body[data-board="ocean"] .sq.dark { background: linear-gradient(145deg, #0096c7 0%, #023e8a 100%); }
body[data-board="ocean"] .sq.last.light { background: linear-gradient(145deg, #fee440 0%, #f15bb5 100%); }
body[data-board="ocean"] .sq.last.dark { background: linear-gradient(145deg, #9b5de5 0%, #f15bb5 100%); }

/* Bàn cờ có hoạ tiết (Băng giá, Dung nham, Rừng rêu, Thiên hà, Hoàng kim): hoạ tiết vẽ một lần trên nền bàn,
   các ô trong suốt một phần để hoạ tiết hiện qua — liền mạch cả bàn thay vì lặp từng ô. Sinh bằng tools/ (xem README) */
:root {
  --tex-frost: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='400' viewBox='0 0 400 400'%3E%3Cpath d='M130 60L126 47L117 36L109 25L107 11M86 34L78 46L72 59L62 68L56 81L55 95M251 379L237 380L224 386L211 390L201 400L192 411L183 421L172 431M224 273L234 283L245 292L255 301L269 303L282 299L293 289L305 283L317 275M126 234L114 242L106 254L95 262L90 275L87 289L85 303M137 180L124 177L110 175L97 169L83 169M196 16L190 3L190 -11L188 -25L188 -39L190 -53L194 -66L197 -80L205 -91M378 190L374 176L368 164L362 151L360 137M178 287L182 273L185 260L183 246L174 235L162 229L151 220M52 99L47 112L42 125L37 138L27 148L14 152L0 151L-14 153M166 144L172 131L172 117L168 103L160 92L151 81M236 105L250 106L263 109L277 109L290 102L304 102L316 108L327 118M296 183L304 171L311 159L311 145L314 131L309 118L298 109L285 105L271 106M136 21L150 22L162 30L172 39L186 42L200 40M150 254L163 248L172 237L184 230L198 232L212 233L226 234L239 228L247 217M137 106L144 94L146 80L155 69L162 57L172 47M366 303L358 315L355 329L354 343L358 356M309 213L314 200L320 188L331 178L343 173L353 163L360 150M160 321L167 334L179 340L193 339L206 335L218 326L230 321L244 323M179 375L191 367L197 355L203 342L207 329L210 315L221 306M244 1L258 -2L268 -11L281 -18L295 -18L308 -14L319 -5M191 71L188 58L192 44L199 33L206 20L216 11L220 -3M64 397L75 406L82 418L93 426L101 438L100 452L97 466L97 480L95 493M52 6L66 4L79 9L93 13L103 22M330 84L330 98L326 112L324 126L322 139L314 151L313 165M296 359L288 348L286 334L284 320L282 306L281 292L273 281L264 271L251 265' fill='none' stroke='%23fff' stroke-opacity='.6' stroke-width='1.6' stroke-linecap='round'/%3E%3Cpath d='M2 320L8 320M5 320L7 321M5 320L7 318M2 320L5 325M3 323L3 325M3 323L5 324M2 320L-2 325M0 323L-2 324M0 323L0 325M2 320L-5 320M-2 320L-4 318M-2 320L-4 321M2 320L-2 314M0 316L0 314M0 316L-2 316M2 320L5 314M3 316L5 316M3 316L3 314M189 290L198 290M195 290L197 292M195 290L197 288M189 290L194 298M192 295L192 298M192 295L195 296M189 290L185 298M187 295L184 296M187 295L187 298M189 290L181 290M184 290L182 288M184 290L182 292M189 290L185 282M187 285L187 282M187 285L184 284M189 290L194 282M192 285L195 284M192 285L192 282M130 207L139 207M136 207L138 209M136 207L138 205M130 207L135 215M133 212L133 215M133 212L136 213M130 207L126 215M128 212L125 213M128 212L128 215M130 207L122 207M125 207L123 205M125 207L123 209M130 207L126 200M128 203L128 200M128 203L125 202M130 207L135 200M133 203L136 202M133 203L133 200M314 42L323 42M319 42L321 44M319 42L321 40M314 42L318 50M316 47L316 50M316 47L319 48M314 42L309 50M311 47L308 48M311 47L312 50M314 42L305 42M308 42L306 40M308 42L306 44M314 42L309 35M311 38L312 35M311 38L308 37M314 42L318 35M316 38L319 37M316 38L316 35M99 111L110 111M106 111L108 113M106 111L108 108M99 111L105 120M103 116L102 120M103 116L106 117M99 111L94 120M96 116L93 117M96 116L97 120M99 111L89 111M93 111L90 108M93 111L90 113M99 111L94 102M96 105L97 102M96 105L93 104M99 111L105 102M103 105L106 104M103 105L102 102M203 225L213 225M209 225L212 227M209 225L212 222M203 225L208 234M206 230L206 234M206 230L210 231M203 225L198 234M200 230L197 231M200 230L201 234M203 225L193 225M197 225L194 222M197 225L194 227M203 225L198 216M200 219L201 216M200 219L197 218M203 225L208 216M206 219L210 218M206 219L206 216M365 177L374 177M371 177L373 179M371 177L373 175M365 177L370 185M368 182L367 185M368 182L371 183M365 177L360 185M362 182L359 183M362 182L363 185M365 177L356 177M359 177L357 175M359 177L357 179M365 177L360 169M362 172L363 169M362 172L359 171M365 177L370 169M368 172L371 171M368 172L367 169M202 205L212 205M208 205L211 207M208 205L211 203M202 205L207 213M205 210L205 213M205 210L208 211M202 205L197 213M199 210L196 211M199 210L200 213M202 205L192 205M196 205L194 203M196 205L194 207M202 205L197 196M199 200L200 196M199 200L196 199M202 205L207 196M205 200L208 199M205 200L205 196M181 213L189 213M186 213L188 215M186 213L188 211M181 213L185 221M183 218L183 221M183 218L186 219M181 213L177 221M178 218L176 219M178 218L179 221M181 213L173 213M176 213L174 211M176 213L174 215M181 213L177 206M178 209L179 206M178 209L176 208M181 213L185 206M183 209L186 208M183 209L183 206M377 280L388 280M383 280L386 282M383 280L386 277M377 280L382 289M380 285L379 289M380 285L384 287M377 280L371 289M373 285L370 287M373 285L374 289M377 280L365 280M370 280L367 277M370 280L367 282M377 280L371 270M373 274L374 270M373 274L370 273M377 280L382 270M380 274L384 273M380 274L379 270M377 104L386 104M382 104L385 106M382 104L385 102M377 104L381 112M380 108L379 112M380 108L382 110M377 104L372 112M374 108L371 110M374 108L375 112M377 104L368 104M372 104L369 102M372 104L369 106M377 104L372 96M374 99L375 96M374 99L371 98M377 104L381 96M380 99L382 98M380 99L379 96M377 336L383 336M381 336L382 337M381 336L382 335M377 336L380 341M379 339L379 341M379 339L381 340M377 336L374 341M376 339L374 340M376 339L376 341M377 336L371 336M374 336L372 335M374 336L372 337M377 336L374 331M376 333L376 331M376 333L374 332M377 336L380 331M379 333L381 332M379 333L379 331M49 177L54 177M52 177L53 178M52 177L53 176M49 177L51 182M50 180L50 182M50 180L52 180M49 177L46 182M47 180L45 180M47 180L47 182M49 177L43 177M45 177L44 176M45 177L44 178M49 177L46 172M47 174L47 172M47 174L45 173M49 177L51 172M50 174L52 173M50 174L50 172M96 29L106 29M102 29L105 31M102 29L105 27M96 29L101 38M99 34L99 38M99 34L102 35M96 29L91 38M93 34L90 35M93 34L94 38M96 29L87 29M90 29L88 27M90 29L88 31M96 29L91 21M93 24L94 21M93 24L90 23M96 29L101 21M99 24L102 23M99 24L99 21' fill='none' stroke='%23fff' stroke-opacity='.75' stroke-width='1.2' stroke-linecap='round'/%3E%3C/svg%3E") 0 0 / 50% 50%, linear-gradient(160deg, #e8f7ff, #8fc0e6 60%, #4f86b8);
  --tex-lava: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='400' viewBox='0 0 400 400'%3E%3Cpath d='M181 224L200 213L222 211L241 201L263 199L285 196L307 197L328 189M179 57L159 48L140 36L120 28L99 20L81 7L67 -10L55 -29L53 -50L39 -67M14 352L-6 343L-25 332L-47 330L-68 335L-88 345L-97 365L-94 387M262 163L244 150L223 143L201 143L180 149M28 307L12 322L-9 326L-30 320L-51 328L-67 343L-88 347M188 392L169 404L157 422L140 436L127 454M124 6L113 25L98 40L94 62L92 84M195 273L210 288L221 308L239 320L254 336L276 342L297 346L319 342L338 331M388 321L389 343L393 365L387 386L377 406M40 396L57 410L72 426L78 447L88 467L106 479L128 483M255 6L241 23L220 29L199 36L177 41L156 35L134 38L116 50L94 52M327 100L332 121L335 143L332 165L333 187L335 209L347 227L368 235L390 231L412 229M102 296L81 302L59 304L39 313L24 329L5 340L-5 360L-7 382M224 341L203 334L189 317L181 296L164 283L145 272L123 267M19 113L-2 120L-17 136L-31 153L-41 173L-57 188M209 379L190 368L169 360L147 358L128 369M239 30L261 34L276 50L297 57L318 64L335 77L343 98M295 281L297 260L303 239L320 224L341 219L362 211L384 212M345 229L328 216L306 216L287 228L277 248L278 270L286 291L296 310M132 374L123 354L123 332L112 313L108 291L92 276L78 259L63 242M92 279L70 275L49 271L32 257L13 246L-9 245L-31 241L-52 236L-71 224M137 372L116 377L94 378L73 387L54 397L32 400' fill='none' stroke='%23ff4d00' stroke-opacity='.55' stroke-width='7' stroke-linecap='round' stroke-linejoin='round'/%3E%3Cpath d='M181 224L200 213L222 211L241 201L263 199L285 196L307 197L328 189M179 57L159 48L140 36L120 28L99 20L81 7L67 -10L55 -29L53 -50L39 -67M14 352L-6 343L-25 332L-47 330L-68 335L-88 345L-97 365L-94 387M262 163L244 150L223 143L201 143L180 149M28 307L12 322L-9 326L-30 320L-51 328L-67 343L-88 347M188 392L169 404L157 422L140 436L127 454M124 6L113 25L98 40L94 62L92 84M195 273L210 288L221 308L239 320L254 336L276 342L297 346L319 342L338 331M388 321L389 343L393 365L387 386L377 406M40 396L57 410L72 426L78 447L88 467L106 479L128 483M255 6L241 23L220 29L199 36L177 41L156 35L134 38L116 50L94 52M327 100L332 121L335 143L332 165L333 187L335 209L347 227L368 235L390 231L412 229M102 296L81 302L59 304L39 313L24 329L5 340L-5 360L-7 382M224 341L203 334L189 317L181 296L164 283L145 272L123 267M19 113L-2 120L-17 136L-31 153L-41 173L-57 188M209 379L190 368L169 360L147 358L128 369M239 30L261 34L276 50L297 57L318 64L335 77L343 98M295 281L297 260L303 239L320 224L341 219L362 211L384 212M345 229L328 216L306 216L287 228L277 248L278 270L286 291L296 310M132 374L123 354L123 332L112 313L108 291L92 276L78 259L63 242M92 279L70 275L49 271L32 257L13 246L-9 245L-31 241L-52 236L-71 224M137 372L116 377L94 378L73 387L54 397L32 400' fill='none' stroke='%23ffb347' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") 0 0 / 50% 50%, radial-gradient(circle at 30% 70%, #ff4d0055, transparent 55%), radial-gradient(circle at 75% 25%, #ff8c0040, transparent 50%), #160806;
  --tex-moss: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='400' viewBox='0 0 400 400'%3E%3Ccircle cx='297' cy='318' r='19' fill='%232e5e1f' fill-opacity='0'/%3E%3Ccircle cx='336' cy='310' r='8' fill='%239fd35a' fill-opacity='0'/%3E%3Ccircle cx='45' cy='188' r='8' fill='%235f9e3a' fill-opacity='0'/%3E%3Ccircle cx='5' cy='87' r='8' fill='%235f9e3a' fill-opacity='0'/%3E%3Ccircle cx='64' cy='319' r='6' fill='%23c7e57a' fill-opacity='0'/%3E%3Ccircle cx='53' cy='389' r='4' fill='%235f9e3a' fill-opacity='0'/%3E%3Ccircle cx='349' cy='116' r='19' fill='%235f9e3a' fill-opacity='0'/%3E%3Ccircle cx='73' cy='387' r='7' fill='%235f9e3a' fill-opacity='0'/%3E%3Ccircle cx='120' cy='144' r='7' fill='%23c7e57a' fill-opacity='0'/%3E%3Ccircle cx='133' cy='327' r='13' fill='%239fd35a' fill-opacity='0'/%3E%3Ccircle cx='26' cy='142' r='9' fill='%232e5e1f' fill-opacity='0'/%3E%3Ccircle cx='192' cy='282' r='5' fill='%235f9e3a' fill-opacity='0'/%3E%3Ccircle cx='380' cy='143' r='10' fill='%239fd35a' fill-opacity='0'/%3E%3Ccircle cx='146' cy='231' r='4' fill='%23c7e57a' fill-opacity='0'/%3E%3Ccircle cx='249' cy='382' r='6' fill='%235f9e3a' fill-opacity='0'/%3E%3Ccircle cx='138' cy='142' r='12' fill='%23c7e57a' fill-opacity='0'/%3E%3Ccircle cx='236' cy='312' r='10' fill='%239fd35a' fill-opacity='0'/%3E%3Ccircle cx='378' cy='36' r='9' fill='%23c7e57a' fill-opacity='0'/%3E%3Ccircle cx='136' cy='370' r='13' fill='%235f9e3a' fill-opacity='0'/%3E%3Ccircle cx='122' cy='320' r='14' fill='%232e5e1f' fill-opacity='0'/%3E%3Ccircle cx='399' cy='65' r='5' fill='%232e5e1f' fill-opacity='0'/%3E%3Ccircle cx='13' cy='296' r='10' fill='%23c7e57a' fill-opacity='0'/%3E%3Ccircle cx='58' cy='392' r='14' fill='%23c7e57a' fill-opacity='0'/%3E%3Ccircle cx='335' cy='52' r='16' fill='%232e5e1f' fill-opacity='0'/%3E%3Ccircle cx='43' cy='174' r='6' fill='%23c7e57a' fill-opacity='0'/%3E%3Ccircle cx='56' cy='369' r='14' fill='%232e5e1f' fill-opacity='0'/%3E%3Ccircle cx='384' cy='276' r='9' fill='%23c7e57a' fill-opacity='0'/%3E%3Ccircle cx='162' cy='59' r='10' fill='%23c7e57a' fill-opacity='0'/%3E%3Ccircle cx='251' cy='200' r='9' fill='%235f9e3a' fill-opacity='0'/%3E%3Ccircle cx='206' cy='219' r='12' fill='%232e5e1f' fill-opacity='0'/%3E%3Ccircle cx='278' cy='266' r='16' fill='%232e5e1f' fill-opacity='0'/%3E%3Ccircle cx='334' cy='106' r='20' fill='%232e5e1f' fill-opacity='0'/%3E%3Ccircle cx='260' cy='232' r='4' fill='%232e5e1f' fill-opacity='0'/%3E%3Ccircle cx='130' cy='109' r='9' fill='%232e5e1f' fill-opacity='0'/%3E%3Ccircle cx='139' cy='258' r='16' fill='%232e5e1f' fill-opacity='0'/%3E%3Ccircle cx='369' cy='69' r='18' fill='%232e5e1f' fill-opacity='0'/%3E%3Ccircle cx='383' cy='207' r='12' fill='%232e5e1f' fill-opacity='0'/%3E%3Ccircle cx='375' cy='191' r='15' fill='%232e5e1f' fill-opacity='0'/%3E%3Ccircle cx='69' cy='312' r='13' fill='%23c7e57a' fill-opacity='0'/%3E%3Ccircle cx='121' cy='221' r='18' fill='%23c7e57a' fill-opacity='0'/%3E%3Ccircle cx='78' cy='235' r='14' fill='%239fd35a' fill-opacity='0'/%3E%3Ccircle cx='252' cy='17' r='12' fill='%235f9e3a' fill-opacity='0'/%3E%3Ccircle cx='357' cy='44' r='19' fill='%239fd35a' fill-opacity='0'/%3E%3Ccircle cx='166' cy='140' r='15' fill='%239fd35a' fill-opacity='0'/%3E%3Ccircle cx='95' cy='361' r='4' fill='%235f9e3a' fill-opacity='0'/%3E%3Ccircle cx='342' cy='347' r='15' fill='%232e5e1f' fill-opacity='0'/%3E%3Ccircle cx='220' cy='121' r='9' fill='%239fd35a' fill-opacity='0'/%3E%3Ccircle cx='383' cy='327' r='11' fill='%232e5e1f' fill-opacity='0'/%3E%3Ccircle cx='187' cy='63' r='10' fill='%232e5e1f' fill-opacity='0'/%3E%3Ccircle cx='387' cy='243' r='10' fill='%235f9e3a' fill-opacity='0'/%3E%3Ccircle cx='153' cy='130' r='19' fill='%239fd35a' fill-opacity='0'/%3E%3Ccircle cx='252' cy='357' r='10' fill='%232e5e1f' fill-opacity='0'/%3E%3Ccircle cx='197' cy='192' r='15' fill='%235f9e3a' fill-opacity='0'/%3E%3Ccircle cx='238' cy='104' r='20' fill='%235f9e3a' fill-opacity='0'/%3E%3Ccircle cx='8' cy='378' r='9' fill='%23c7e57a' fill-opacity='0'/%3E%3Ccircle cx='191' cy='49' r='14' fill='%235f9e3a' fill-opacity='0'/%3E%3Ccircle cx='16' cy='55' r='10' fill='%232e5e1f' fill-opacity='0'/%3E%3Ccircle cx='97' cy='190' r='5' fill='%232e5e1f' fill-opacity='0'/%3E%3Ccircle cx='289' cy='114' r='12' fill='%235f9e3a' fill-opacity='0'/%3E%3Ccircle cx='6' cy='50' r='9' fill='%239fd35a' fill-opacity='0'/%3E%3Cpath transform='translate(245 293) rotate(10)' d='M0 0C5 -6 14 -6 20 0C14 6 5 6 0 0Z' fill='%23d9f08a' fill-opacity='.35'/%3E%3Cpath transform='translate(140 273) rotate(293)' d='M0 0C5 -6 14 -6 20 0C14 6 5 6 0 0Z' fill='%23d9f08a' fill-opacity='.35'/%3E%3Cpath transform='translate(53 1) rotate(199)' d='M0 0C5 -6 14 -6 20 0C14 6 5 6 0 0Z' fill='%23d9f08a' fill-opacity='.35'/%3E%3Cpath transform='translate(274 43) rotate(247)' d='M0 0C5 -6 14 -6 20 0C14 6 5 6 0 0Z' fill='%23d9f08a' fill-opacity='.35'/%3E%3Cpath transform='translate(76 172) rotate(291)' d='M0 0C5 -6 14 -6 20 0C14 6 5 6 0 0Z' fill='%23d9f08a' fill-opacity='.35'/%3E%3Cpath transform='translate(238 276) rotate(343)' d='M0 0C5 -6 14 -6 20 0C14 6 5 6 0 0Z' fill='%23d9f08a' fill-opacity='.35'/%3E%3Cpath transform='translate(260 343) rotate(303)' d='M0 0C5 -6 14 -6 20 0C14 6 5 6 0 0Z' fill='%23d9f08a' fill-opacity='.35'/%3E%3Cpath transform='translate(190 273) rotate(259)' d='M0 0C5 -6 14 -6 20 0C14 6 5 6 0 0Z' fill='%23d9f08a' fill-opacity='.35'/%3E%3Cpath transform='translate(360 186) rotate(273)' d='M0 0C5 -6 14 -6 20 0C14 6 5 6 0 0Z' fill='%23d9f08a' fill-opacity='.35'/%3E%3Cpath transform='translate(121 1) rotate(280)' d='M0 0C5 -6 14 -6 20 0C14 6 5 6 0 0Z' fill='%23d9f08a' fill-opacity='.35'/%3E%3Cpath transform='translate(233 259) rotate(170)' d='M0 0C5 -6 14 -6 20 0C14 6 5 6 0 0Z' fill='%23d9f08a' fill-opacity='.35'/%3E%3Cpath transform='translate(124 66) rotate(250)' d='M0 0C5 -6 14 -6 20 0C14 6 5 6 0 0Z' fill='%23d9f08a' fill-opacity='.35'/%3E%3Cpath transform='translate(355 389) rotate(194)' d='M0 0C5 -6 14 -6 20 0C14 6 5 6 0 0Z' fill='%23d9f08a' fill-opacity='.35'/%3E%3Cpath transform='translate(170 217) rotate(17)' d='M0 0C5 -6 14 -6 20 0C14 6 5 6 0 0Z' fill='%23d9f08a' fill-opacity='.35'/%3E%3Cpath transform='translate(293 107) rotate(31)' d='M0 0C5 -6 14 -6 20 0C14 6 5 6 0 0Z' fill='%23d9f08a' fill-opacity='.35'/%3E%3Cpath transform='translate(25 377) rotate(120)' d='M0 0C5 -6 14 -6 20 0C14 6 5 6 0 0Z' fill='%23d9f08a' fill-opacity='.35'/%3E%3C/svg%3E") 0 0 / 50% 50%, linear-gradient(170deg, #5a8f3a, #2f5a22);
  --tex-cosmos: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='400' viewBox='0 0 400 400'%3E%3Ccircle cx='95' cy='218' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='250' cy='26' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='104' cy='94' r='2' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='335' cy='191' r='1' fill='%23fff' fill-opacity='0'/%3E%3Ccircle cx='254' cy='347' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='269' cy='26' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='121' cy='12' r='2' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='288' cy='352' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='158' cy='320' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='352' cy='39' r='1' fill='%23fff' fill-opacity='0'/%3E%3Ccircle cx='386' cy='174' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='203' cy='154' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='234' cy='362' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='343' cy='396' r='1' fill='%23fff' fill-opacity='0'/%3E%3Ccircle cx='344' cy='386' r='2' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='286' cy='84' r='2' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='114' cy='25' r='2' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='35' cy='320' r='1' fill='%23fff' fill-opacity='0'/%3E%3Ccircle cx='118' cy='308' r='2' fill='%23fff' fill-opacity='0'/%3E%3Ccircle cx='246' cy='18' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='352' cy='392' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='124' cy='31' r='1' fill='%23fff' fill-opacity='0'/%3E%3Ccircle cx='79' cy='163' r='1' fill='%23fff' fill-opacity='0'/%3E%3Ccircle cx='17' cy='347' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='359' cy='151' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='258' cy='238' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='376' cy='203' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='95' cy='120' r='2' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='219' cy='5' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='8' cy='246' r='1' fill='%23fff' fill-opacity='0'/%3E%3Ccircle cx='251' cy='187' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='283' cy='295' r='1' fill='%23fff' fill-opacity='0'/%3E%3Ccircle cx='270' cy='385' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='237' cy='128' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='148' cy='238' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='309' cy='11' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='124' cy='89' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='75' cy='174' r='1' fill='%23fff' fill-opacity='0'/%3E%3Ccircle cx='129' cy='134' r='2' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='342' cy='68' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='354' cy='180' r='1' fill='%23fff' fill-opacity='0'/%3E%3Ccircle cx='212' cy='76' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='73' cy='111' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='323' cy='138' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='318' cy='108' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='168' cy='164' r='2' fill='%23fff' fill-opacity='0'/%3E%3Ccircle cx='2' cy='377' r='2' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='174' cy='380' r='2' fill='%23fff' fill-opacity='0'/%3E%3Ccircle cx='298' cy='335' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='116' cy='136' r='1' fill='%23fff' fill-opacity='0'/%3E%3Ccircle cx='235' cy='115' r='1' fill='%23fff' fill-opacity='0'/%3E%3Ccircle cx='361' cy='277' r='2' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='360' cy='231' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='69' cy='120' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='166' cy='376' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='101' cy='345' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='141' cy='79' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='69' cy='317' r='2' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='329' cy='3' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='20' cy='109' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='169' cy='189' r='1' fill='%23fff' fill-opacity='0'/%3E%3Ccircle cx='22' cy='51' r='1' fill='%23fff' fill-opacity='0'/%3E%3Ccircle cx='390' cy='342' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='126' cy='126' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='235' cy='144' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='50' cy='222' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='32' cy='71' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='313' cy='152' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='173' cy='149' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='168' cy='278' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='214' cy='278' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='170' cy='352' r='2' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='359' cy='316' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='49' cy='325' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='317' cy='267' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='41' cy='235' r='1' fill='%23fff' fill-opacity='0'/%3E%3Ccircle cx='310' cy='18' r='1' fill='%23fff' fill-opacity='0'/%3E%3Ccircle cx='352' cy='72' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='49' cy='338' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='381' cy='232' r='1' fill='%23fff' fill-opacity='0'/%3E%3Ccircle cx='307' cy='205' r='1' fill='%23fff' fill-opacity='0'/%3E%3Ccircle cx='300' cy='374' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='226' cy='331' r='1' fill='%23fff' fill-opacity='0'/%3E%3Ccircle cx='100' cy='246' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='147' cy='159' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='33' cy='200' r='2' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='299' cy='64' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='270' cy='207' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='359' cy='60' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='367' cy='207' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='74' cy='107' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='126' cy='93' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='118' cy='282' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='234' cy='107' r='1' fill='%23fff' fill-opacity='0'/%3E%3Ccircle cx='192' cy='153' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='129' cy='310' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='192' cy='240' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='329' cy='223' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='343' cy='160' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='187' cy='92' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='270' cy='383' r='2' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='76' cy='103' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='343' cy='360' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='125' cy='169' r='1' fill='%23fff' fill-opacity='0'/%3E%3Ccircle cx='37' cy='334' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='232' cy='270' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='174' cy='194' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='382' cy='156' r='1' fill='%23fff' fill-opacity='0'/%3E%3Ccircle cx='110' cy='266' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='364' cy='39' r='2' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='309' cy='303' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='262' cy='322' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='385' cy='269' r='1' fill='%23fff' fill-opacity='0'/%3E%3Ccircle cx='198' cy='141' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='227' cy='73' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='72' cy='356' r='1' fill='%23fff' fill-opacity='0'/%3E%3Ccircle cx='373' cy='57' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='239' cy='222' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='125' cy='71' r='1' fill='%23fff' fill-opacity='1'/%3E%3Ccircle cx='302' cy='217' r='1' fill='%23fff' fill-opacity='1'/%3E%3Cpath d='M106 147Q106 153 113 153Q106 153 106 160Q106 153 100 153Q106 153 106 147Z' fill='%23fff'/%3E%3Cpath d='M17 198Q17 202 21 202Q17 202 17 206Q17 202 13 202Q17 202 17 198Z' fill='%23fff'/%3E%3Cpath d='M308 137Q308 142 312 142Q308 142 308 146Q308 142 303 142Q308 142 308 137Z' fill='%23fff'/%3E%3Cpath d='M161 211Q161 217 167 217Q161 217 161 223Q161 217 155 217Q161 217 161 211Z' fill='%23fff'/%3E%3Cpath d='M141 335Q141 339 145 339Q141 339 141 342Q141 339 138 339Q141 339 141 335Z' fill='%23fff'/%3E%3Cpath d='M108 36Q108 40 112 40Q108 40 108 43Q108 40 105 40Q108 40 108 36Z' fill='%23fff'/%3E%3Cpath d='M312 287Q312 291 315 291Q312 291 312 295Q312 291 308 291Q312 291 312 287Z' fill='%23fff'/%3E%3Cpath d='M76 161Q76 167 82 167Q76 167 76 173Q76 167 70 167Q76 167 76 161Z' fill='%23fff'/%3E%3C/svg%3E") 0 0 / 50% 50%, radial-gradient(circle at 25% 30%, #ff5fd266, transparent 45%), radial-gradient(circle at 75% 72%, #3ad1ff55, transparent 50%), radial-gradient(circle at 62% 12%, #7b5cff66, transparent 40%), #0a0620;
  --tex-gilded: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200' viewBox='0 0 200 200'%3E%3Cpath d='M0 50L50 0L100 50L50 100ZM100 50L150 0L200 50L150 100ZM0 150L50 100L100 150L50 200ZM100 150L150 100L200 150L150 200Z' fill='none' stroke='%23d4af37' stroke-opacity='.45' stroke-width='1.4'/%3E%3Cg fill='%23f2d16b' fill-opacity='.7'%3E%3Ccircle cx='50' cy='50' r='3'/%3E%3Ccircle cx='150' cy='50' r='3'/%3E%3Ccircle cx='50' cy='150' r='3'/%3E%3Ccircle cx='150' cy='150' r='3'/%3E%3Ccircle cx='100' cy='100' r='2'/%3E%3Ccircle cx='0' cy='0' r='2'/%3E%3Ccircle cx='200' cy='0' r='2'/%3E%3Ccircle cx='0' cy='200' r='2'/%3E%3Ccircle cx='200' cy='200' r='2'/%3E%3C/g%3E%3C/svg%3E") 0 0 / 25% 25%, radial-gradient(circle at 50% 40%, #2c2a36, #0e0e14);
}
body[data-board="frost"] { --light: #f2faff; --dark: #5b8fc0; --last-light: #c8f1ff; --last-dark: #3aa6d8; --la: 84%; --da: 72%; --tex: var(--tex-frost); }
body[data-board="lava"] { --light: #d4bc9f; --dark: #2c1a15; --last-light: #ffc46b; --last-dark: #e8590c; --la: 95%; --da: 58%; --tex: var(--tex-lava); }
body[data-board="moss"] { --light: #efe6c4; --dark: #4c7a32; --last-light: #e9ef8a; --last-dark: #9cc13a; --la: 88%; --da: 70%; --tex: var(--tex-moss); }
body[data-board="cosmos"] { --light: #d6ccf5; --dark: #24185a; --last-light: #ffe08a; --last-dark: #8a6cff; --la: 86%; --da: 55%; --tex: var(--tex-cosmos); }
body[data-board="gilded"] { --light: #f4e7c3; --dark: #22222c; --last-light: #ffe08a; --last-dark: #b8860b; --la: 94%; --da: 78%; --tex: var(--tex-gilded); }
body:is([data-board="frost"], [data-board="lava"], [data-board="moss"], [data-board="cosmos"], [data-board="gilded"]) .board { background: var(--tex); }
body:is([data-board="frost"], [data-board="lava"], [data-board="moss"], [data-board="cosmos"], [data-board="gilded"]) .board .sq.light { background: color-mix(in srgb, var(--light) var(--la), transparent); }
body:is([data-board="frost"], [data-board="lava"], [data-board="moss"], [data-board="cosmos"], [data-board="gilded"]) .board .sq.dark { background: color-mix(in srgb, var(--dark) var(--da), transparent); }
body:is([data-board="frost"], [data-board="lava"], [data-board="moss"], [data-board="cosmos"], [data-board="gilded"]) .board .sq.light:is(.last, .selected) { background: color-mix(in srgb, var(--last-light) 82%, transparent); }
body:is([data-board="frost"], [data-board="lava"], [data-board="moss"], [data-board="cosmos"], [data-board="gilded"]) .board .sq.dark:is(.last, .selected) { background: color-mix(in srgb, var(--last-dark) 78%, transparent); }
body[data-board="gilded"] .board .sq { box-shadow: inset 0 0 0 max(1px, calc(var(--board-size) / 500)) #d4af3766; }
body[data-board="lava"] .board .sq.dark .coord { color: #ffb347; }
/* Ô xem trước trong bảng chọn skin */
.theme span[data-tex="frost"] { background: linear-gradient(135deg, color-mix(in srgb, #f2faff 84%, transparent) 50%, color-mix(in srgb, #5b8fc0 72%, transparent) 50%), var(--tex-frost); background-size: auto, 200% 200%; }
.theme span[data-tex="lava"] { background: linear-gradient(135deg, color-mix(in srgb, #d4bc9f 95%, transparent) 50%, color-mix(in srgb, #2c1a15 58%, transparent) 50%), var(--tex-lava); background-size: auto, 200% 200%; }
.theme span[data-tex="moss"] { background: linear-gradient(135deg, color-mix(in srgb, #efe6c4 88%, transparent) 50%, color-mix(in srgb, #4c7a32 70%, transparent) 50%), var(--tex-moss); background-size: auto, 200% 200%; }
.theme span[data-tex="cosmos"] { background: linear-gradient(135deg, color-mix(in srgb, #d6ccf5 86%, transparent) 50%, color-mix(in srgb, #24185a 55%, transparent) 50%), var(--tex-cosmos); background-size: auto, 200% 200%; }
.theme span[data-tex="gilded"] { background: linear-gradient(135deg, color-mix(in srgb, #f4e7c3 94%, transparent) 50%, color-mix(in srgb, #22222c 78%, transparent) 50%), var(--tex-gilded); background-size: auto, 200% 200%; }

/* Bàn Neon: dải gradient hồng → tím → xanh chảy chậm dưới các ô kính (chỉ dịch bằng transform, card đồ hoạ tự làm),
   lưới neon mảnh giữa các ô, ô vừa đi viền neon phát sáng; thêm viền toả sáng và vệt sáng lướt của nhóm bàn gradient */
body[data-board="neon"] {
  --light: #3b2f86; --dark: #120b30; --last-light: #19f6ff; --last-dark: #ff2bd6;
  --glow-1: #19f6ff; --glow-2: #ff2bd6;
}
body[data-board="neon"] .board { background: #0a0620; }
body[data-board="neon"] .board::before {
  content: "";
  position: absolute;
  left: 0; right: 0; top: -100%; height: 200%;
  z-index: 0;
  pointer-events: none;
  background: linear-gradient(180deg, #ff2bd6 0%, #7b2bff 12.5%, #19c8ff 25%, #7b2bff 37.5%, #ff2bd6 50%, #7b2bff 62.5%, #19c8ff 75%, #7b2bff 87.5%, #ff2bd6 100%);
  animation: neon-flow 14s linear infinite;
  will-change: transform;
}
@keyframes neon-flow { to { transform: translateY(50%); } }
body[data-board="neon"] .board .sq { box-shadow: inset 0 0 0 max(0.5px, calc(var(--board-size) / 900)) #b9f6ff26; }
body[data-board="neon"] .board .sq.light { background: linear-gradient(135deg, #ffffff26, #ffffff00 55%), #2a1f6ab3; }
body[data-board="neon"] .board .sq.dark { background: linear-gradient(135deg, #ffffff0d, #ffffff00 55%), #0b0722eb; }
body[data-board="neon"] .board .sq.light:is(.last, .selected) {
  background: linear-gradient(135deg, #19f6ff59, #19f6ff1a), #2a1f6ab3;
  box-shadow: inset 0 0 0 max(1.5px, calc(var(--board-size) / 260)) #19f6ff, inset 0 0 calc(var(--board-size) / 40) #19f6ffb0;
}
body[data-board="neon"] .board .sq.dark:is(.last, .selected) {
  background: linear-gradient(135deg, #ff2bd659, #ff2bd61a), #0b0722eb;
  box-shadow: inset 0 0 0 max(1.5px, calc(var(--board-size) / 260)) #ff2bd6, inset 0 0 calc(var(--board-size) / 40) #ff2bd6b0;
}
body[data-board="neon"] .sq.light .coord { color: #9ff8ff; }
body[data-board="neon"] .sq.dark .coord { color: #ff8be8; }
body[data-board="neon"] .board-wrap.tilt .board::before { top: 0; height: 100%; animation: none; }
@media (prefers-reduced-motion: reduce) { body[data-board="neon"] .board::before { animation: none; } }
.theme span[data-tex="neon"] {
  background: linear-gradient(135deg, #2a1f6ab3 50%, #0b0722eb 50%), linear-gradient(160deg, #ff2bd6, #7b2bff 50%, #19c8ff);
  box-shadow: 0 0 8px #19f6ff, 0 0 16px #ff2bd666, 0 2px 6px #0006;
}
/* Quân Neon: quân đang chọn sáng rực hơn */
body[data-pieces="neon"] .board .sq.selected .piece { filter: brightness(1.18) saturate(1.25); }

/* Bàn cờ nổi 3D: bóng quân rõ hơn (đặt trước phần skin để bộ lọc màu của skin vẫn được ưu tiên) */
body[data-relief="on"] .board .piece {
  filter: drop-shadow(0 calc(var(--board-size) / 95) calc(var(--board-size) / 150) #000000a0) drop-shadow(0 1px 0 #00000059);
  transition: transform 0.18s cubic-bezier(0.25, 0.8, 0.35, 1), translate 0.18s cubic-bezier(0.25, 0.8, 0.35, 1);
}

/* Skin quân cờ */

/* Skin Cyber (bộ quân SVG riêng): thân tối, viền neon phát sáng theo màu bên */
body[data-pieces="cyber"] .board .piece[src*="/wK"], body[data-pieces="cyber"] .board .piece[src*="/wQ"],
body[data-pieces="cyber"] .board .piece[src*="/wR"], body[data-pieces="cyber"] .board .piece[src*="/wB"],
body[data-pieces="cyber"] .board .piece[src*="/wN"], body[data-pieces="cyber"] .board .piece[src*="/wP"],
body[data-pieces="cyber"] .drag-ghost[src*="/w"] {
  filter: drop-shadow(0 0 3px #2ff5dccc) drop-shadow(0 0 8px #2ff5dc66);
}
body[data-pieces="cyber"] .board .piece[src*="/bK"], body[data-pieces="cyber"] .board .piece[src*="/bQ"],
body[data-pieces="cyber"] .board .piece[src*="/bR"], body[data-pieces="cyber"] .board .piece[src*="/bB"],
body[data-pieces="cyber"] .board .piece[src*="/bN"], body[data-pieces="cyber"] .board .piece[src*="/bP"],
body[data-pieces="cyber"] .drag-ghost[src*="/b"] {
  filter: drop-shadow(0 0 3px #ff3fd8cc) drop-shadow(0 0 8px #ff3fd866);
}
.piece-preview[data-pieces="cyber"] img:first-child { filter: drop-shadow(0 0 3px #2ff5dc); }
.piece-preview[data-pieces="cyber"] img:last-child { filter: drop-shadow(0 0 3px #ff3fd8); }

/* Bàn gradient toả sáng: viền phát sáng đổi màu nhịp nhàng, vệt sáng lướt qua bàn, ô vừa đi sáng lên */
body[data-board="gradient"] { --glow-1: #8f6bff; --glow-2: #ff5fa2; }
body[data-board="sunset"] { --glow-1: #ff8a3d; --glow-2: #9d4edd; }
body[data-board="ocean"] { --glow-1: #00f5d4; --glow-2: #3a86ff; }
/* Toả sáng: lớp .board-glow riêng nằm ngay dưới bàn cờ (app.js đặt đúng vị trí, kích thước của bàn), không gắn vào
   khối bao cả thanh đánh giá (nếu không khe giữa thanh và bàn thành một dải tối nối hai bên).
   Hiệu năng: trước đây quầng sáng đổi box-shadow của chính bàn cờ mỗi khung hình → trình duyệt vẽ lại cả 64 ô và quân cờ
   liên tục kể cả khi không ai làm gì (máy yếu bị lag). Giờ quầng sáng màu 1 đứng yên, quầng màu 2 hiện / mờ bằng opacity
   (card đồ hoạ tự làm, không phải vẽ lại). */
.board-glow { display: none; position: absolute; z-index: 0; pointer-events: none; border-radius: 8px; }
body:is([data-board="gradient"], [data-board="sunset"], [data-board="ocean"], [data-board="neon"]) .board-glow {
  display: block;
  box-shadow: 0 0 14px 1px var(--glow-1), 0 0 36px 6px color-mix(in srgb, var(--glow-2) 45%, transparent);
}
body:is([data-board="gradient"], [data-board="sunset"], [data-board="ocean"], [data-board="neon"]) .board-glow::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: 0 0 22px 3px var(--glow-2), 0 0 56px 12px color-mix(in srgb, var(--glow-1) 50%, transparent);
  opacity: 0;
  animation: board-glow-fade 3.6s ease-in-out infinite;
  will-change: opacity;
}
/* Bàn nổi: quầng sáng nằm ngoài khung bàn */
body[data-relief="on"]:is([data-board="gradient"], [data-board="sunset"], [data-board="ocean"], [data-board="neon"]) .board-glow {
  box-shadow: 0 0 calc(var(--frame) + 14px) calc(var(--frame) + 1px) var(--glow-1), 0 0 calc(var(--frame) + 36px) calc(var(--frame) + 6px) color-mix(in srgb, var(--glow-2) 45%, transparent);
}
body[data-relief="on"]:is([data-board="gradient"], [data-board="sunset"], [data-board="ocean"], [data-board="neon"]) .board-glow::after {
  box-shadow: 0 0 calc(var(--frame) + 22px) calc(var(--frame) + 3px) var(--glow-2), 0 0 calc(var(--frame) + 56px) calc(var(--frame) + 12px) color-mix(in srgb, var(--glow-1) 50%, transparent);
}
@keyframes board-glow-fade { 50% { opacity: 1; } }
/* Bóng đổ tĩnh của bàn toả sáng khi không bật bàn nổi (bàn nổi đã có khung riêng) */
body:not([data-relief="on"]):is([data-board="gradient"], [data-board="sunset"], [data-board="ocean"], [data-board="neon"]) .board { box-shadow: 0 0 0 1px #0006, 0 18px 50px #000a; }
body:is([data-board="gradient"], [data-board="sunset"], [data-board="ocean"], [data-board="neon"]) .board { position: relative; }
/* Vệt sáng lướt qua bàn: dải gradient trượt bằng transform (trước đây đổi background-position + mix-blend-mode
   nên phải vẽ lại cả bàn mỗi khung hình) */
body:is([data-board="gradient"], [data-board="sunset"], [data-board="ocean"], [data-board="neon"]) .board::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 300%;
  z-index: 4;
  pointer-events: none;
  background: linear-gradient(115deg, transparent 38%, #ffffff22 48%, #ffffff0c 53%, transparent 62%);
  transform: translateX(-61%);
  animation: board-sheen 7s ease-in-out infinite;
  will-change: transform;
}
@keyframes board-sheen {
  0% { transform: translateX(-61%); }
  45%, 100% { transform: translateX(-1%); }
}
/* Bàn nghiêng 3D không cắt phần thừa (overflow: visible) nên dải sáng sẽ lòi ra ngoài: tắt ở góc nhìn này */
body:is([data-board="gradient"], [data-board="sunset"], [data-board="ocean"], [data-board="neon"]) .board-wrap.tilt .board::after { display: none; }
body:is([data-board="gradient"], [data-board="sunset"], [data-board="ocean"], [data-board="neon"]) .sq.last {
  box-shadow: inset 0 0 calc(var(--board-size) / 30) #ffffffb0, inset 0 0 0 1px #ffffff80;
}
.theme.glow span { box-shadow: 0 0 8px #b388ff, 0 0 16px #ff5fa266, 0 2px 6px #0006; }
@media (prefers-reduced-motion: reduce) {
  body .board-wrap, body .board, body .board-glow::after { animation: none !important; }
  body .board::after { animation: none !important; display: none; }
}

/* Ô xem trước bộ quân SVG: hiện cả quân Trắng và quân Đen */
.piece-preview.pair { grid-template-columns: 1fr 1fr; gap: 0; padding: 0 4%; }
.piece-preview.pair img { width: 100%; height: 70%; }

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  color: var(--text);
  font-family: var(--font);
  background:
    radial-gradient(1200px 600px at 20% -10%, #3a4a2a55, transparent 60%),
    radial-gradient(900px 500px at 110% 10%, #2b3a4a44, transparent 60%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

.ic {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- Thanh trên cùng ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  background: #1b1a17cc;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  text-decoration: none;
  font-weight: 800;
  font-size: 1.3rem;
  letter-spacing: -0.3px;
}
.brand img { width: 34px; height: 34px; filter: drop-shadow(0 2px 4px #0008); }

.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  box-shadow: none;
}
.tab:hover { background: var(--panel-2); color: var(--text); }
.tab[aria-selected="true"] {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 10px var(--accent-glow);
}

.topbar-right { display: flex; justify-content: flex-end; align-items: center; gap: 8px; }
.icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: var(--muted);
}
.icon-btn:hover { color: var(--gold); background: var(--panel); }
.profile-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 12px 4px 4px;
  border-radius: 999px;
  background: var(--panel);
  box-shadow: none;
  text-align: left;
}
.profile-text { display: flex; flex-direction: column; line-height: 1.15; }
.profile-text b { font-size: 0.9rem; max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-text small { color: var(--accent); font-weight: 700; font-size: 0.75rem; }

/* Icon rank trên header — luôn hiện, kể cả mobile */
.header-rank-icon {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  flex: none;
}
.header-rank-icon .rb-medal {
  width: 26px;
  height: 26px;
  filter: drop-shadow(0 1px 4px #0008);
}
.header-rank-icon .rb-medal svg { width: 100%; height: 100%; display: block; }
.header-rank-btn {
  gap: 6px;
}
.header-rank-btn .header-rank-icon + span { font-weight: 700; }

.header-rank-badge {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  flex: none;
  margin-right: -2px;
}
.header-rank-badge .rb-medal {
  width: 22px;
  height: 22px;
  filter: drop-shadow(0 1px 3px #0009);
}
.header-rank-badge .rb-medal svg { width: 100%; height: 100%; display: block; }
.header-rank-badge:empty { display: none; }

.me-rank-line {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  vertical-align: middle;
}
.me-rank-line .rb-medal {
  width: 13px;
  height: 13px;
  flex: none;
  vertical-align: middle;
}
.me-rank-line .rb-medal svg { width: 100%; height: 100%; display: block; }


.avatar {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 8px;
  background: var(--panel-3);
  color: #fff;
  font-weight: 800;
  font-size: 1rem;
  overflow: hidden;
  box-shadow: inset 0 -2px 0 #0003;
}
.avatar img { width: 85%; height: 85%; }
.avatar.bot { background: linear-gradient(135deg, #4b6b8a, #2f4458); }
.avatar.piece-av { background: var(--panel-3); }
.avatar.photo { background: none; overflow: hidden; }
.avatar.photo img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
#profileAvatar { cursor: pointer; }
.avatar-actions { display: flex; gap: 8px; margin-top: 12px; }
.avatar-actions button { display: inline-flex; align-items: center; gap: 6px; }
.avatar-actions button[hidden] { display: none; }
.avatar.sm { width: 26px; height: 26px; font-size: 0.8rem; border-radius: 6px; }
.avatar.xl { width: 64px; height: 64px; font-size: 1.8rem; border-radius: 14px; }

/* ---------- Bố cục ---------- */
.layout {
  flex: 1;
  display: flex;
  gap: 24px;
  justify-content: center;
  align-items: flex-start;
  align-content: flex-start;
  padding: 18px 16px;
  flex-wrap: wrap;
}

/* ---------- Bàn cờ ---------- */
.board-area { width: var(--board-size); }
.board-wrap {
  padding: 0;
  border-radius: 8px;
  box-shadow: 0 0 0 1px #0006, 0 18px 50px #000a, 0 2px 0 #ffffff10 inset;
}
.board {
  width: var(--board-size);
  height: var(--board-size);
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  border-radius: 8px;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.sq { position: relative; }
.sq.light { background: var(--light); }
.sq.dark { background: var(--dark); }
.sq.light.last, .sq.light.selected { background: var(--last-light); }
.sq.dark.last, .sq.dark.selected { background: var(--last-dark); }
.sq.check::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, #ff2a2a 0%, #e81010b3 38%, #e8101000 72%);
  box-shadow: inset 0 0 0 max(1.5px, calc(var(--board-size) / 320)) #ff3b3bcc;
}
.sq.hint::before, .sq.marked::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--hint);
}
.sq.marked::before { background: rgba(235, 97, 80, 0.8); }
.sq.drag-over::before {
  content: "";
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 0 calc(var(--board-size) / 160 + 2px) #ffffffaa;
  z-index: 3;
}
.sq.target::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 32%;
  height: 32%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: var(--dot, #0000002a);
  z-index: 2;
  pointer-events: none;
}
.sq.capture::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: calc(var(--board-size) / 110) solid var(--dot, #0000002a);
  z-index: 2;
  pointer-events: none;
}
.sq.target:hover::after { background: var(--dot-hover, #00000045); }
/* Bàn tối / nhiều màu: chấm đen gần như không thấy, đổi sang chấm sáng ở những ô tối */
body:is([data-board="gradient"], [data-board="sunset"], [data-board="ocean"], [data-board="neon"]) .sq,
body:is([data-board="cosmos"], [data-board="lava"], [data-board="gilded"], [data-board="night"]) .sq.dark {
  --dot: #ffffff73;
  --dot-hover: #ffffffb0;
}
/* Quân đi trước (premove): tô tím cả ô đi và ô đến cho tới khi tới lượt */
.board .sq.pre { box-shadow: inset 0 0 0 999px #7b61ff73 !important; }

.piece {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  cursor: grab;
  transition: transform 0.18s cubic-bezier(0.25, 0.8, 0.35, 1), translate 0.18s cubic-bezier(0.25, 0.8, 0.35, 1);
  filter: drop-shadow(0 calc(var(--board-size) / 260) calc(var(--board-size) / 260) #0005);
  -webkit-user-drag: none;
}
.piece.moving { z-index: 4; }
.piece.dragging { opacity: 0.3; }
.drag-ghost {
  position: fixed;
  z-index: 100;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(1.12);
  filter: drop-shadow(0 8px 10px #0008);
  cursor: grabbing;
}

.star {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 2;
  font-size: calc(var(--board-size) / 8 * 0.5);
  color: var(--gold);
  text-shadow: 0 2px 6px #0009;
  pointer-events: none;
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 50% { transform: scale(1.15); } }

.coord {
  position: absolute;
  z-index: 2;
  font-size: calc(var(--board-size) / 48);
  font-weight: 700;
  pointer-events: none;
}
.coord.rank { top: 3%; left: 4%; }
.coord.file { bottom: 2%; right: 5%; }
.sq.light .coord { color: var(--dark); }
.sq.dark .coord { color: var(--light); }

/* ---------- Thẻ người chơi ---------- */
.player {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 54px;
  padding: 0 4px;
  margin: 4px 0;
}
.player-info { flex: 1; min-width: 0; }
.player-line { display: flex; align-items: baseline; gap: 6px; }
.player-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-rating { color: var(--muted); font-size: 0.85rem; }
.captured { display: flex; align-items: center; height: 20px; }
.captured img { width: 20px; height: 20px; margin-left: -9px; }
.captured img:first-child { margin-left: 0; }
.captured img.group { margin-left: -2px; }
.captured b { margin-left: 6px; font-size: 0.8rem; color: var(--muted); }
.turn-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: transparent;
  margin-right: 6px;
}
.player.active .turn-dot { position: relative; background: var(--accent); box-shadow: 0 0 0 4px var(--accent-glow); }
.player.active .avatar { box-shadow: 0 0 0 2px var(--accent); }
@keyframes blink { 50% { box-shadow: 0 0 0 7px #81b64c00; } }

/* ---------- Bảng điều khiển ---------- */
.panel {
  width: min(94vw, 370px);
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 18px 40px #0006;
}

.status {
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--panel-3);
  font-weight: 700;
  text-align: center;
  transition: background 0.2s;
}
.status.in-check { background: #7a2e26; }
.status.over { background: linear-gradient(135deg, var(--accent), var(--accent-dark)); color: #fff; }
.status.thinking { color: var(--muted); }
.status.thinking::after { content: ""; display: inline-block; width: 1em; animation: dots 1.2s steps(4) infinite; text-align: left; }
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }

.controls { display: flex; flex-direction: column; gap: 10px; }
.controls[hidden], .controls > [hidden] { display: none; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
label { display: flex; flex-direction: column; gap: 5px; font-size: 0.8rem; font-weight: 600; color: var(--muted); }

select, button, input {
  font: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
}
select { cursor: pointer; width: 100%; min-width: 0; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input { width: 100%; }
button {
  cursor: pointer;
  font-weight: 600;
  box-shadow: 0 3px 0 #0005;
  transition: background 0.15s, transform 0.05s, filter 0.15s;
}
button:hover { background: var(--panel-3); }
button:active { transform: translateY(2px); box-shadow: 0 1px 0 #0005; }
button:disabled { opacity: 0.45; cursor: default; transform: none; }
button.primary {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 4px 0 var(--accent-dark);
}
button.primary:hover { filter: brightness(1.08); background: var(--accent); }
button.primary:active { box-shadow: 0 1px 0 var(--accent-dark); }
button.big {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px;
  font-size: 1.1rem;
  font-weight: 800;
}
button.ghost { background: transparent; box-shadow: none; display: flex; align-items: center; justify-content: center; gap: 6px; color: var(--muted); }
button.ghost:hover { color: var(--danger); }

.tool-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.tool-row.three { grid-template-columns: repeat(3, 1fr); }
.tool-row button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 9px 4px;
  font-size: 0.75rem;
  color: var(--muted);
}
.tool-row button:hover { color: var(--text); }
.tool-row .ic { width: 20px; height: 20px; }
.buttons { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.buttons.two { grid-template-columns: repeat(2, 1fr); }

.rated-note { margin: 0; text-align: center; font-size: 0.78rem; color: var(--accent); font-weight: 600; }
.rated-note.off { color: var(--muted); font-weight: 400; }
.muted { margin: 0; color: var(--muted); font-size: 0.85rem; }
.muted:empty { display: none; }

h2 { margin: 0; font-size: 0.95rem; color: var(--muted); font-weight: 700; }
h2 small { font-weight: 500; font-size: 0.8rem; margin-left: 6px; }

body[data-mode="learn"] .player,
body[data-mode="learn"] .record { display: none; }
.record { display: flex; flex-direction: column; gap: 10px; }

/* Biên bản */
.moves {
  max-height: 260px;
  min-height: 80px;
  overflow-y: auto;
  border-radius: 8px;
  background: #00000022;
  font-size: 0.92rem;
}
.move-row { display: grid; grid-template-columns: 3em 1fr 1fr; padding: 2px 6px; }
.move-row:nth-child(odd) { background: #ffffff06; }
.move-row .num { color: var(--muted); padding: 4px 0; }
.move-row .mv { padding: 4px 8px; border-radius: 5px; font-weight: 600; }
.move-row .mv.current { background: var(--panel-3); box-shadow: inset 0 -2px 0 var(--accent); }
.empty { margin: 0; padding: 16px; text-align: center; color: var(--muted); font-size: 0.85rem; }

/* ---------- Online ---------- */
#roomCode { text-transform: uppercase; letter-spacing: 3px; }
.join-row { display: flex; gap: 8px; }
.join-row input { flex: 1; min-width: 0; }
.divider { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 0.78rem; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.room-code {
  padding: 14px;
  border-radius: 10px;
  background: #00000033;
  border: 1px dashed var(--accent);
  text-align: center;
  font: 800 2.1rem ui-monospace, Menlo, Consolas, monospace;
  letter-spacing: 8px;
  color: var(--accent);
  user-select: all;
}
#inviteLink { font-size: 0.78rem; color: var(--muted); }
.offer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border-radius: 10px;
  background: #3b4a2a;
  border: 1px solid var(--accent);
  text-align: center;
  font-weight: 700;
}
.chat-log {
  height: 150px;
  overflow-y: auto;
  padding: 10px;
  border-radius: 8px;
  background: #00000026;
  font-size: 0.88rem;
}
.chat-log p { margin: 0 0 5px; overflow-wrap: anywhere; }
.chat-log p.system { color: var(--muted); font-style: italic; font-size: 0.8rem; }
.chat-form { display: flex; gap: 6px; }
.chat-form button { padding: 9px 12px; display: grid; place-items: center; }

.progress { height: 8px; border-radius: 99px; background: #00000040; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent-dark), var(--accent)); transition: width 0.4s; }

/* ---------- Hộp thoại ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: #000000a0;
  backdrop-filter: blur(3px);
  animation: fade 0.15s;
}
.modal[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: scale(0.92); opacity: 0; } }
.modal-box {
  position: relative;
  width: min(100%, 440px);
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  padding: 24px;
  border-radius: 16px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  box-shadow: 0 30px 80px #000c;
  animation: pop 0.2s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.modal-box.small { width: auto; text-align: center; }
.modal-title { margin: 0 0 14px; font-weight: 700; }
.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 6px;
  display: grid;
  place-items: center;
  background: transparent;
  border: none;
  box-shadow: none;
  color: var(--muted);
}
.promo-choices { display: flex; gap: 10px; }
.promo-choices button {
  width: 76px;
  height: 76px;
  padding: 6px;
  background: var(--light);
  box-shadow: 0 4px 0 var(--dark);
}
.promo-choices button:hover { background: var(--last-light); }
.promo-choices img { width: 100%; height: 100%; }

/* Kết quả */
.result-box { text-align: center; width: min(100%, 380px); }
.result-icon {
  width: 72px;
  height: 72px;
  margin: 4px auto 10px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--panel-3);
}
.result-icon .ic { width: 36px; height: 36px; }
.result-icon.win { background: linear-gradient(135deg, var(--gold), #d98c1f); color: #fff; box-shadow: 0 0 30px #f5b83d66; }
.result-icon.loss { background: #5a2a24; color: #ff9b8c; }
.result-icon.draw { background: #3a4048; color: #cfd6df; }
.result-title { margin: 0; font-size: 1.8rem; color: var(--text); font-weight: 800; }
.result-reason { margin: 4px 0 14px; color: var(--muted); }
.result-rating {
  margin-bottom: 18px;
  padding: 10px;
  border-radius: 10px;
  background: #00000030;
  font-size: 1.05rem;
}
.result-rating:empty { display: none; }
.delta { margin-left: 6px; padding: 2px 8px; border-radius: 99px; font-weight: 800; background: var(--panel-3); }
.delta.up { color: #b5e37a; background: #81b64c2a; }
.delta.down { color: #ff8f7e; background: #e2533f2a; }

/* Rank */
.rank-box { width: min(100%, 620px); padding: 22px 18px; }
.rank-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; padding-right: 36px; }
.rank-head > div { flex: 1; }
.rank-head h2 { color: var(--text); font-size: 1.3rem; }
.big-ic { width: 36px; height: 36px; color: var(--gold); }

.rank-current {
  text-align: center;
  padding: 20px 14px 14px;
  margin-bottom: 12px;
  border-radius: 14px;
  background:
    radial-gradient(ellipse at 50% 0%, color-mix(in srgb, var(--rk) 18%, transparent), transparent 55%),
    #00000030;
  border: 1px solid color-mix(in srgb, var(--rk) 28%, transparent);
  box-shadow: inset 0 1px 0 #ffffff0a;
}
/* Huy hiệu rank kiểu classic / kim loại */
.rank-badge {
  --rk: #f5b83d;
  --rk2: #c48a1a;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 0;
  background: transparent;
  box-shadow: none;
  color: var(--text);
}
.rank-badge .rb-medal {
  position: relative;
  width: 72px;
  height: 72px;
  filter: drop-shadow(0 4px 12px color-mix(in srgb, var(--rk) 45%, transparent));
}
.rank-badge .rb-medal svg {
  width: 100%;
  height: 100%;
  display: block;
}
.rank-badge .rb-name {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--rk);
  text-shadow: 0 0 18px color-mix(in srgb, var(--rk) 40%, transparent);
}
.rank-badge.sm {
  flex-direction: row;
  gap: 6px;
}
.rank-badge.sm .rb-medal { width: 22px; height: 22px; filter: drop-shadow(0 1px 3px #0008); }
.rank-badge.sm .rb-name { font-size: 0.85rem; font-weight: 700; text-shadow: none; }
.rank-badge.md .rb-medal { width: 36px; height: 36px; }
.rank-badge.md .rb-name { font-size: 0.95rem; }

.rk-stars { margin: 10px 0 10px; font-size: 1.9rem; letter-spacing: 6px; color: #ffffff2a; }
.rk-stars .on { color: var(--gold); text-shadow: 0 0 10px #f5b83d88; }
.rank-current .muted { margin: 8px 0 0; font-size: 0.82rem; }

/* Danh sách rank trong modal */
.rank-tiers li { gap: 12px; }
.rank-tiers .rb-medal {
  width: 28px;
  height: 28px;
  flex: none;
  filter: drop-shadow(0 2px 4px #0006);
}
.rank-tiers .rb-medal svg { width: 100%; height: 100%; display: block; }
.rank-tiers .locked .rb-medal { opacity: 0.35; filter: grayscale(0.6); }
.rank-tiers .cur .rb-medal { filter: drop-shadow(0 0 8px color-mix(in srgb, var(--rk) 55%, transparent)); }
.rank-tiers .dot { display: none; }

/* Huy hiệu nhỏ trên bảng xếp hạng / hồ sơ */
.rank-tier {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 0.85rem;
}
.rank-tier .rb-medal { width: 18px; height: 18px; flex: none; }
.rank-tier .rb-medal svg { width: 100%; height: 100%; display: block; }


.me-rank-line {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.me-rank-line .rb-medal { width: 16px; height: 16px; flex: none; }
.me-rank-line .rb-medal svg { width: 100%; height: 100%; display: block; }

.player-rank {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.player-rank .rb-medal { width: 14px; height: 14px; flex: none; }
.player-rank .rb-medal svg { width: 100%; height: 100%; display: block; }

.rank-rules { display: flex; gap: 8px; margin-bottom: 12px; }
.rank-rules span { flex: 1; text-align: center; padding: 8px 4px; border-radius: 10px; background: #00000030; font-size: 0.78rem; color: var(--muted); text-transform: uppercase; }
.rank-rules b { display: block; font-size: 1.2rem; color: var(--text); }
.rank-rules .up b { color: #a6d36b; }
.rank-rules .down b { color: #ff8f7e; }
.rank-tiers { list-style: none; margin: 0; padding: 0; border-radius: 10px; overflow: hidden; background: #00000022; }
.rank-tiers li { display: flex; align-items: center; gap: 10px; padding: 9px 14px; font-size: 0.92rem; border-bottom: 1px solid #ffffff08; }
.rank-tiers .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--rk); }
.rank-tiers small { margin-left: auto; color: var(--muted); }
.rank-tiers .cur { background: #ffffff10; box-shadow: inset 3px 0 0 var(--rk); }
.rank-tiers .locked b { color: var(--muted); }
.rank-tiers .locked .dot { opacity: 0.4; }
.rank-up, .rank-down { margin-top: 6px; font-weight: 800; }
.rank-up { color: var(--gold); }
.rank-down { color: #ff8f7e; }

/* Bảng xếp hạng toàn thế giới */
.lb-box { width: min(100%, 700px); padding: 22px 18px; }
.rank-table { border-radius: 10px; overflow: hidden; background: #00000022; }
#lbList { max-height: 55vh; overflow-y: auto; }
.rank-row {
  display: grid;
  grid-template-columns: 2.6em 1fr 8.5em 3.6em 3.8em 6.5em;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  font-size: 0.9rem;
  border-bottom: 1px solid #ffffff08;
}
.rank-header { color: var(--muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 700; background: #00000030; }
.rank-row.me { background: #81b64c22; box-shadow: inset 3px 0 0 var(--accent); }
.rank-no { font-weight: 800; text-align: center; }
.rank-name { display: flex; align-items: center; gap: 8px; min-width: 0; font-weight: 600; }
.rank-name .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-tier { font-weight: 700; font-size: 0.85rem; }
.rank-elo { font-weight: 800; color: var(--gold); }
.wdl { color: var(--muted); font-size: 0.82rem; }
.wdl i { font-style: normal; font-weight: 700; }
.wdl .w { color: #a6d36b; }
.wdl .l { color: #ff8f7e; }

/* Đăng nhập */
.auth-box { width: min(100%, 400px); padding: 26px 22px; }
.auth-brand { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 18px; }
.auth-brand img { width: 40px; height: 40px; }
.auth-brand h1 { margin: 0; font-size: 1.6rem; color: var(--text); }
.auth-tabs { display: flex; gap: 6px; padding: 4px; margin-bottom: 14px; border-radius: 999px; background: #00000030; }
.auth-tabs button { flex: 1; border-radius: 999px; border-color: transparent; background: transparent; box-shadow: none; color: var(--muted); font-weight: 700; }
.auth-tabs button.on { background: var(--accent); color: #fff; }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form label[hidden] { display: none; }
.auth-msg { margin: 0; min-height: 1.2em; color: var(--danger); font-size: 0.85rem; }
.auth-box .muted { margin: 12px 0 0; text-align: center; font-size: 0.78rem; }

/* Hồ sơ */
.themes { display: grid; grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); gap: 8px; }
.theme { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px; background: transparent; box-shadow: none; border: 1px solid transparent; border-radius: 8px; cursor: pointer; }
.theme span { width: 100%; aspect-ratio: 1; border-radius: 6px; box-shadow: 0 2px 6px #0006; }
.theme small { font-size: 0.68rem; color: var(--muted); text-align: center; line-height: 1.15; }
.theme.on { border-color: var(--accent); background: #81b64c1a; }
.skin-section { margin-top: 4px; }
.skin-section h4 { margin: 12px 0 8px; font-size: 0.85rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.piece-preview {
  width: 100%; aspect-ratio: 1; border-radius: 6px; box-shadow: 0 2px 6px #0006;
  background: linear-gradient(135deg, #ebecd0 50%, #739552 50%);
  display: grid; place-items: center; overflow: hidden;
}
.piece-preview img { width: 78%; height: 78%; object-fit: contain; }
.switch { flex-direction: row; align-items: center; gap: 10px; margin: 16px 0 12px; font-size: 0.9rem; color: var(--text); cursor: pointer; }
.switch input { width: 18px; height: 18px; accent-color: var(--accent); }

.footer { text-align: center; padding: 14px; color: #6f6b64; font-size: 0.75rem; }

/* ---------- Màn hình nhỏ ---------- */
@media (max-width: 900px) {
  .topbar { grid-template-columns: auto 1fr; padding: 8px 12px; }
  .tabs { grid-column: 1 / -1; grid-row: 2; justify-self: stretch; justify-content: space-between; }
  .tab { flex: 1; justify-content: center; }
  .icon-btn span:not(.header-rank-icon):not(.ic) { display: none; }
  .profile-text small { display: none; }
  .header-rank-icon { width: 28px; height: 28px; }
  .header-rank-icon .rb-medal { width: 28px; height: 28px; }
  .header-rank-badge { width: 24px; height: 24px; }
  .header-rank-badge .rb-medal { width: 24px; height: 24px; }
}
@media (max-width: 700px) {
  :root { --board-size: min(100vw - 16px, 720px); }
  .layout { padding: 8px; gap: 12px; }
  .panel { width: var(--board-size); min-width: min(100%, 360px); }
  .brand span { display: none; }
  .profile-text b { max-width: 90px; }
  .rank-row { grid-template-columns: 2.2em 1fr 7.6em 3.4em; }
  .rank-row > :nth-child(4), .rank-row > :nth-child(6) { display: none; }
}

/* ---------- Elo ---------- */
.elo-current { text-align: center; padding: 12px 14px; margin-bottom: 10px; border-radius: 12px; background: #00000030; }
.elo-big { font-size: 2.4rem; font-weight: 800; line-height: 1.1; color: var(--text); }
.elo-big small { margin-left: 6px; font-size: 0.9rem; font-weight: 600; color: var(--muted); }
.elo-current .muted { margin-top: 6px; font-size: 0.8rem; }
.elo-rules { display: flex; gap: 8px; margin-bottom: 12px; }
.elo-rules span { flex: 1; text-align: center; padding: 8px 4px; border-radius: 10px; background: #00000030; font-size: 0.78rem; font-weight: 700; color: var(--text); }
.elo-rules b { display: block; font-size: 0.85rem; font-weight: 700; color: var(--muted); }
.elo-rules b.up { color: #a6d36b; }
.elo-rules b.down { color: #ff8f7e; }
.elo-line { margin-top: 6px; }
.rank-elo2 { font-weight: 800; color: var(--text); }

/* Chọn trình độ lần đầu */
.place-box { width: min(100%, 460px); padding: 26px 22px; }
.place-sub { margin: 0 0 16px; text-align: center; color: var(--muted); font-size: 0.88rem; line-height: 1.5; }
.place-choices { display: flex; flex-direction: column; gap: 10px; }
.place-opt {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  text-align: left;
  background: var(--panel-2);
}
.place-opt:hover { border-color: var(--accent); background: #81b64c1a; }
.po-main { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.po-main b { font-size: 1rem; }
.po-main small { color: var(--muted); font-size: 0.78rem; font-weight: 400; line-height: 1.35; }
.po-elo { font-weight: 800; color: var(--gold); white-space: nowrap; }

/* ---------- Admin ---------- */
.tab[hidden], .tool-row button[hidden], .role-badge[hidden] { display: none; }
.role-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  background: #f5b83d26;
  color: var(--gold);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}
.admin-box { width: min(100%, 560px); padding: 22px 18px; display: flex; flex-direction: column; gap: 10px; }
.admin-box .rank-head { margin-bottom: 0; }
.admin-hint { line-height: 1.45; }
.admin-msg { margin: 0; color: var(--accent); font-size: 0.85rem; font-weight: 600; }
.admin-msg:empty { display: none; }
.admin-msg.err { color: var(--danger); }
.admin-table { border-radius: 10px; overflow: hidden; background: #00000022; }
#adminList { max-height: 50vh; overflow-y: auto; }
.admin-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid #ffffff08; }
.admin-row.me { background: #81b64c22; box-shadow: inset 3px 0 0 var(--accent); }
.admin-name { display: flex; flex-direction: column; flex: 1; min-width: 0; line-height: 1.25; }
.admin-name b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.92rem; }
.admin-name small { color: var(--muted); font-size: 0.75rem; }
.admin-row button { padding: 6px 12px; font-size: 0.8rem; white-space: nowrap; }

/* ---------- Tìm trận & Contest ---------- */
.center { text-align: center; }
.contest-box [hidden], #onlineSearching[hidden], .contest-create[hidden], .contest-form[hidden] { display: none !important; }

.searching {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 18px 12px;
  border-radius: 12px;
  background: #00000030;
  font-weight: 700;
}
.spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 3px solid var(--panel-3);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.search-time { margin-left: 6px; color: var(--gold); font-variant-numeric: tabular-nums; }

.contest-box { width: min(100%, 620px); padding: 22px 18px; display: flex; flex-direction: column; gap: 10px; }
.contest-box .rank-head { margin-bottom: 0; }
.contest-create { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.contest-form { display: flex; flex-direction: column; gap: 10px; padding: 12px; border-radius: 12px; background: #00000030; }
.contest-group { margin: 12px 0 2px; font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px; font-weight: 700; }
.contest-list { display: flex; flex-direction: column; gap: 8px; max-height: 50vh; overflow-y: auto; }
.contest-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; text-align: left; background: var(--panel-2); }
.contest-item:hover { border-color: var(--accent); background: #81b64c1a; }
.ci-main { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.ci-main b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ci-main small { color: var(--muted); font-size: 0.75rem; font-weight: 400; }
.ci-badge { padding: 2px 9px; border-radius: 99px; font-size: 0.7rem; font-weight: 800; white-space: nowrap; background: #ffffff14; color: var(--muted); }
.contest-item.live .ci-badge { background: #81b64c33; color: #a6d36b; }
.contest-item.upcoming .ci-badge { background: #f5b83d26; color: var(--gold); }
.contest-item.ended { opacity: 0.75; }

button.back { justify-content: flex-start; width: fit-content; padding: 4px 6px; }
.contest-info h3 { margin: 0 0 4px; font-size: 1.2rem; color: var(--text); }
.contest-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 6px; padding: 8px 12px; border-radius: 10px; background: #00000030; font-size: 0.85rem; color: var(--muted); }
.contest-meta b { color: var(--gold); font-variant-numeric: tabular-nums; }
.contest-actions { display: flex; flex-direction: column; gap: 8px; }
.contest-actions:empty { display: none; }

.contest-row {
  display: grid;
  grid-template-columns: 2.6em 1fr 3.6em 3.2em 6.5em;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  font-size: 0.9rem;
  border-bottom: 1px solid #ffffff08;
}
.contest-header { color: var(--muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 700; background: #00000030; }
.contest-row.me { background: #81b64c22; box-shadow: inset 3px 0 0 var(--accent); }
.contest-row .pts { font-weight: 800; color: var(--gold); }
#contestBoard { max-height: 40vh; overflow-y: auto; }

@media (max-width: 700px) {
  .contest-row { grid-template-columns: 2.2em 1fr 3.2em 2.8em; }
  .contest-row > :nth-child(5) { display: none; }
}
@media (max-width: 520px) {
  .tab { padding: 7px 6px; gap: 4px; font-size: 0.78rem; }
}

/* ---------- Học cờ: cấu trúc Duolingo, đồ hoạ kiểu chess.com ---------- */
.learn-home { display: none; }
body[data-mode="learn"] #status,
body[data-mode="learn"] .player,
body[data-mode="learn"] .record { display: none; }
body[data-mode="learn"][data-learn="home"] .learn-home { display: grid; }
body[data-mode="learn"][data-learn="home"] .board-area,
body[data-mode="learn"][data-learn="home"] .panel { display: none; }
body[data-mode="learn"][data-learn="lesson"] .board-area { padding-top: 8px; }

.learn-home {
  width: min(100%, 1060px);
  grid-template-columns: 1fr 330px;
  gap: 28px;
  align-items: start;
}
.lh-path { display: flex; flex-direction: column; gap: 22px; min-width: 0; }
.lh-side { position: sticky; top: 76px; display: flex; flex-direction: column; gap: 12px; max-height: calc(100vh - 92px); overflow-y: auto; scrollbar-width: thin; padding-bottom: 8px; }

.lh-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.lh-stat {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 6px;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid #ffffff0d;
  font-size: 1.1rem;
  font-weight: 800;
}
.lh-stat .ic { width: 22px; height: 22px; fill: currentColor; stroke-width: 1.5; }
.lh-stat b { color: var(--text); }
.lh-stat.streak { color: #f0883e; }
.lh-stat.xp { color: #e8b93b; }
.lh-stat.crowns { color: #a98ae0; }
.lh-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid #ffffff0d;
  background: var(--panel);
  box-shadow: 0 2px 0 #0004;
}
.lh-card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 0.95rem; }
.lh-card-head small { color: var(--muted); font-weight: 700; }
.lh-meter { height: 10px; border-radius: 99px; background: #0000004d; overflow: hidden; }
.lh-meter > div { height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, #d9a42a, #f0c64e); transition: width 0.6s; }
.lh-meter.blue > div { background: linear-gradient(90deg, var(--accent-dark), var(--accent)); }
.lh-tip { margin: 0; color: var(--muted); font-size: 0.84rem; line-height: 1.45; }
.lh-legend p { margin: 0; color: var(--muted); font-size: 0.82rem; line-height: 1.55; }
.lh-legend p b { color: var(--text); }
button.lh-ghost { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 10px; border-radius: 10px; font-weight: 700; }

.lh-chart { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; height: 110px; }
.ch-col { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.ch-val { height: 14px; font-size: 0.68rem; font-weight: 700; color: var(--muted); }
.ch-bar { flex: 1; width: 100%; max-width: 26px; display: flex; align-items: flex-end; border-radius: 6px; background: #0000003d; overflow: hidden; }
.ch-bar i { display: block; width: 100%; border-radius: 6px 6px 0 0; background: #6b6862; transition: height 0.5s; }
.ch-col.goal .ch-bar i { background: var(--accent); }
.ch-col small { font-size: 0.68rem; color: var(--muted); font-weight: 600; }
.ch-col.today small { color: var(--text); }

.lh-toc { display: flex; flex-direction: column; gap: 2px; }
.toc-item {
  display: grid;
  grid-template-columns: 26px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border: none;
  border-radius: 8px;
  background: transparent;
  box-shadow: none;
  text-align: left;
  font-weight: 600;
}
.toc-item:hover { background: #ffffff0a; }
.toc-item:active { transform: none; }
.toc-item img { width: 26px; height: 26px; }
.toc-item.locked { opacity: 0.5; }
.toc-item.cur { background: #81b64c1a; }
.toc-name { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.toc-name b { font-size: 0.82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toc-name i { display: block; height: 3px; border-radius: 3px; background: var(--uc); max-width: 100%; }
.toc-item small { color: var(--muted); font-size: 0.72rem; font-variant-numeric: tabular-nums; }
.toc-item.full small { color: var(--accent); }

/* Đầu mỗi phần */
.unit { --uc: #81b64c; --us: #5d8a32; display: flex; flex-direction: column; gap: 16px; scroll-margin-top: 80px; }
.unit-head {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 14px 16px 18px;
  border-radius: 14px;
  overflow: hidden;
  background: linear-gradient(100deg, color-mix(in srgb, var(--uc) 22%, var(--panel)) 0%, var(--panel) 65%);
  border: 1px solid #ffffff10;
  box-shadow: 0 3px 0 #0005;
}
.uh-icon {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 12px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--uc) 80%, #fff), var(--uc));
  box-shadow: 0 4px 0 var(--us), inset 0 1px 0 #ffffff40;
}
.uh-icon img { width: 40px; height: 40px; filter: drop-shadow(0 2px 2px #0005); }
.unit-head.locked .uh-icon { background: #3a3835; box-shadow: 0 4px 0 #272523; }
.unit-head.locked .uh-icon img { filter: grayscale(1) opacity(0.5); }
.uh-text { min-width: 0; }
.uh-text small { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px; color: var(--uc); }
.unit-head.locked .uh-text small { color: var(--muted); }
.uh-text h3 { margin: 2px 0; font-size: 1.15rem; font-weight: 800; color: var(--text); }
.uh-text p { margin: 0; font-size: 0.84rem; color: var(--muted); line-height: 1.4; }
.uh-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: #0000004d; }
.uh-bar i { display: block; height: 100%; background: var(--uc); }
.uh-count { display: inline-grid; place-items: center; min-width: 46px; padding: 6px 10px; border-radius: 99px; background: #0000003d; font-weight: 800; font-size: 0.85rem; white-space: nowrap; }
.uh-count.full { background: var(--accent); color: #fff; }
.uh-count .ic { width: 18px; height: 18px; stroke-width: 3; }
.uh-jump { padding: 9px 14px; border-radius: 10px; font-weight: 800; font-size: 0.82rem; white-space: nowrap; }

/* Lộ trình bài học */
.unit-path { position: relative; display: flex; flex-direction: column; align-items: center; gap: 22px; padding: 4px 0 10px; }
.node-wrap { position: relative; transform: translateX(var(--x)); display: flex; flex-direction: column; align-items: center; }
.node-wrap:has(.node-start) { margin-top: 30px; }
.node-wrap:has(.node-pop) { z-index: 30; }
.node {
  position: relative;
  width: 68px;
  height: 64px;
  padding: 0;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 50%;
  background: linear-gradient(180deg, color-mix(in srgb, var(--uc) 78%, #fff) 0%, var(--uc) 55%);
  box-shadow: 0 6px 0 var(--us), inset 0 0 0 3px #ffffff1f, 0 10px 18px #0006;
  color: #fff;
  transition: transform 0.08s, filter 0.15s;
}
.node:hover { background: linear-gradient(180deg, color-mix(in srgb, var(--uc) 70%, #fff) 0%, var(--uc) 55%); filter: brightness(1.05); }
.node:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--us), inset 0 0 0 3px #ffffff1f; }
.node img { width: 42px; height: 42px; filter: drop-shadow(0 2px 1px #0005); }
.node .ic { width: 26px; height: 26px; stroke-width: 2.5; }
.node.locked { background: linear-gradient(180deg, #45423d, #3a3835 55%); box-shadow: 0 6px 0 #282624, inset 0 0 0 3px #ffffff0a; color: #75716a; }
.node.locked img { opacity: 0.3; filter: grayscale(1); }
.node.current { box-shadow: 0 6px 0 var(--us), inset 0 0 0 3px #ffffff30, 0 10px 18px #0006; }
@keyframes ringPulse {
  0% { box-shadow: 0 6px 0 var(--us), inset 0 0 0 3px #ffffff30, 0 0 0 0 color-mix(in srgb, var(--uc) 60%, transparent); }
  100% { box-shadow: 0 6px 0 var(--us), inset 0 0 0 3px #ffffff30, 0 0 0 14px transparent; }
}
.node.review:not(.locked) .ic { width: 30px; height: 30px; }
.node-badge {
  position: absolute;
  right: -4px;
  bottom: -2px;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--bg), 0 2px 0 var(--accent-dark);
}
.node-badge .ic { width: 14px; height: 14px; stroke-width: 3.5; }
.node-start {
  position: absolute;
  bottom: calc(100% + 12px);
  padding: 6px 12px;
  border-radius: 8px;
  background: var(--uc);
  color: #fff;
  font-weight: 800;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
  box-shadow: 0 3px 0 var(--us);
  pointer-events: none;
}
.node-start::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 100%;
  border: 6px solid transparent;
  border-top-color: var(--uc);
  transform: translateX(-50%);
}
.node-stars { margin-top: 10px; font-size: 0.8rem; letter-spacing: 1px; }
.node-stars i { font-style: normal; color: #ffffff1f; }
.node-stars i.on { color: #e8b93b; }

.node-pop {
  position: absolute;
  top: calc(100% + 14px);
  z-index: 10;
  width: 270px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 16px 16px;
  border-radius: 14px;
  border: 1px solid #ffffff14;
  border-top: 4px solid var(--uc);
  background: var(--panel-2);
  color: var(--text);
  box-shadow: 0 16px 36px #000a;
  animation: pop 0.15s ease-out;
}
.node-pop::before {
  content: "";
  position: absolute;
  bottom: 100%;
  left: 50%;
  margin-bottom: 4px;
  border: 9px solid transparent;
  border-bottom-color: var(--uc);
  transform: translateX(-50%);
}
.node-pop b { font-size: 1.02rem; }
.node-pop small { font-size: 0.84rem; color: var(--muted); line-height: 1.4; }
.node-pop button {
  margin-top: 6px;
  padding: 11px;
  border: none;
  border-radius: 10px;
  background: var(--uc);
  color: #fff;
  font-weight: 800;
  box-shadow: 0 4px 0 var(--us);
}
.node-pop button:hover { background: var(--uc); filter: brightness(1.08); }
.node-pop.locked { border-top-color: #4a4844; }
.node-pop.locked::before { border-bottom-color: #4a4844; }
.node-pop.locked button { background: #3a3835; color: #8f8a82; box-shadow: 0 4px 0 #272523; }

/* Nút chính */
button.ls-main {
  width: 100%;
  padding: 13px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(180deg, #8fc55a, var(--accent));
  color: #fff;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.3px;
  box-shadow: 0 5px 0 #45753c;
}
button.ls-main:hover { filter: brightness(1.06); background: linear-gradient(180deg, #8fc55a, var(--accent)); }
button.ls-main:active { transform: translateY(4px); box-shadow: 0 1px 0 #45753c; }
button.ls-main:disabled { background: #3a3835; color: #77736b; box-shadow: 0 5px 0 #272523; opacity: 1; filter: none; }
button.ls-main.bad { background: linear-gradient(180deg, #e8685b, #d6503f); box-shadow: 0 5px 0 #a33a2d; }
button.ls-main[hidden] { display: none; }

/* Bảng bài học */
#learnPanel { --uc: #81b64c; gap: 12px; }
.ls-top { display: flex; align-items: center; gap: 12px; }
.ls-x { padding: 4px; border: none; background: transparent; box-shadow: none; color: var(--muted); display: grid; place-items: center; }
.ls-x:hover { background: transparent; color: var(--text); }
.ls-x .ic { width: 22px; height: 22px; }
.ls-bar { flex: 1; height: 12px; border-radius: 99px; background: #0000004d; overflow: hidden; }
.ls-bar > div { height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--accent-dark), var(--accent)); transition: width 0.45s ease; }
.ls-hearts { display: flex; align-items: center; gap: 4px; font-weight: 800; color: #e2533f; font-size: 1.05rem; }
.ls-hearts .ic { width: 20px; height: 20px; fill: currentColor; stroke-width: 1.5; }
.ls-hearts.lost { animation: shake 0.45s; }
@keyframes shake { 20%, 60% { transform: translateX(-4px); } 40%, 80% { transform: translateX(4px); } }
.ls-unit { font-size: 0.72rem; font-weight: 800; color: var(--uc); text-transform: uppercase; letter-spacing: 0.6px; }

.ls-coach { display: flex; align-items: flex-start; gap: 10px; }
.ls-mascot { width: 52px; height: 52px; flex: none; padding: 6px; border-radius: 12px; background: var(--panel-2); border: 1px solid #ffffff10; }
.ls-bubble {
  position: relative;
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid #ffffff12;
  background: var(--panel-2);
}
.ls-bubble::before {
  content: "";
  position: absolute;
  top: 18px;
  right: 100%;
  border: 7px solid transparent;
  border-right-color: #ffffff1c;
}
.ls-bubble b { display: block; margin-bottom: 4px; font-size: 1rem; }
.ls-bubble p { margin: 0; line-height: 1.5; font-size: 0.9rem; color: #d6d2c9; }

.ls-quiz { display: flex; flex-direction: column; gap: 8px; }
.ls-quiz[hidden] { display: none; }
.ls-opt {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 12px;
  text-align: left;
  border: 1px solid #ffffff14;
  border-radius: 10px;
  background: var(--panel-2);
  box-shadow: 0 3px 0 #0005;
  font-weight: 600;
}
.ls-opt:hover:not(:disabled) { background: var(--panel-3); }
.ls-key { display: grid; place-items: center; width: 24px; height: 24px; flex: none; border-radius: 6px; background: #0000003d; font-size: 0.75rem; color: var(--muted); }
.ls-opt.picked { border-color: #5b9bd5; background: #5b9bd51f; color: #a9cdf0; }
.ls-opt.picked .ls-key { background: #5b9bd5; color: #fff; }
.ls-opt.right { border-color: var(--accent); background: #81b64c24; color: #b7df8b; opacity: 1; }
.ls-opt.right .ls-key { background: var(--accent); color: #fff; }
.ls-opt.wrong { border-color: #e2533f; background: #e2533f24; color: #f3a99f; opacity: 1; }
.ls-opt.wrong .ls-key { background: #e2533f; color: #fff; }
.ls-opt:disabled:not(.right):not(.wrong) { opacity: 0.35; }

.ls-tools { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ls-tools button { display: flex; align-items: center; justify-content: center; gap: 6px; border-radius: 10px; color: var(--muted); font-weight: 700; }
.ls-tools button:hover:not(:disabled) { color: var(--text); }
.ls-tools button[hidden] { display: none; }
.ls-tools:has(button[hidden]) { grid-template-columns: 1fr; }

.ls-feedback { padding: 12px 14px; border-radius: 12px; border: 1px solid transparent; animation: pop 0.2s ease-out; }
.ls-feedback[hidden] { display: none; }
.ls-feedback.ok { background: #81b64c1f; border-color: #81b64c4d; color: #b7df8b; }
.ls-feedback.bad { background: #e2533f1f; border-color: #e2533f4d; color: #f3a99f; }
.lf-head { display: flex; align-items: center; gap: 8px; font-size: 1.05rem; }
.lf-icon { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; color: #fff; }
.lf-icon .ic { width: 15px; height: 15px; stroke-width: 3.2; }
.ls-feedback.ok .lf-icon { background: var(--accent); }
.ls-feedback.bad .lf-icon { background: #e2533f; }
.ls-feedback p { margin: 6px 0 0; font-size: 0.87rem; line-height: 1.45; }
.ls-feedback p:empty { display: none; }

/* Ô trên bàn cờ trong bài học */
.sq.focus::before { content: ""; position: absolute; inset: 0; box-shadow: inset 0 0 0 calc(var(--board-size) / 160 + 2px) #5b9bd5; background: #5b9bd526; z-index: 2; pointer-events: none; }
.sq.tap-ok::before { content: ""; position: absolute; inset: 0; background: #81b64cb3; z-index: 2; pointer-events: none; }
.sq.tap-bad::before { content: ""; position: absolute; inset: 0; background: #e2533fb3; z-index: 2; pointer-events: none; animation: shake 0.4s; }
body[data-mode="learn"] .board { cursor: pointer; }

/* Hoàn thành bài */
.ld-box { width: min(100%, 420px); text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 28px 22px 22px; }
.ld-mascot { width: 88px; height: 88px; padding: 10px; border-radius: 22px; background: var(--panel-2); border: 1px solid #ffffff12; }
.ld-title { margin: 0; color: var(--text); font-size: 1.6rem; font-weight: 800; }
#learnDone.fail .ld-mascot { filter: grayscale(0.7); }
#learnDone.fail .ld-title { color: #f3a99f; }
.ld-stars { font-size: 2.4rem; letter-spacing: 6px; }
.ld-stars:empty { display: none; }
.ld-stars span { color: #ffffff1a; display: inline-block; }
.ld-stars span.on { color: #e8b93b; animation: starIn 0.45s cubic-bezier(0.3, 1.5, 0.5, 1) backwards; }
.ld-stars span.on:nth-child(2) { animation-delay: 0.12s; }
.ld-stars span.on:nth-child(3) { animation-delay: 0.24s; }
@keyframes starIn { from { transform: scale(0); } }
.ld-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: 100%; }
.ld-cards[hidden] { display: none; }
.ld-card { --c: #e8b93b; display: flex; flex-direction: column; gap: 2px; padding: 10px 4px; border-radius: 12px; background: var(--panel-2); border: 1px solid #ffffff10; border-top: 3px solid var(--c); }
.ld-card span { font-size: 0.68rem; font-weight: 700; text-transform: uppercase; color: var(--muted); }
.ld-card b { color: var(--c); font-size: 1.3rem; }
.ld-card.acc { --c: var(--accent); }
.ld-card.time { --c: #5b9bd5; }
.ld-note { margin: 0; color: var(--muted); font-size: 0.88rem; line-height: 1.45; }
.ld-box button.ghost { width: 100%; }
.ld-box button.ghost[hidden] { display: none; }

@media (max-width: 900px) {
  .learn-home { grid-template-columns: 1fr; gap: 18px; }
  .lh-side { position: static; max-height: none; overflow: visible; order: -1; }
  .lh-legend, .lh-side .lh-card:has(.lh-toc) { display: none; }
}
@media (max-width: 520px) {
  .node-wrap { transform: translateX(calc(var(--x) * 0.7)); }
  .unit-head { grid-template-columns: auto 1fr; }
  .uh-side { grid-column: 1 / -1; justify-self: start; }
}

/* ---------- Banner contest & thông báo ---------- */
.contest-banner {
  position: sticky;
  top: 58px;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 8px 16px;
  background: linear-gradient(90deg, #3b4a2a, #2c3a22);
  border-bottom: 1px solid #81b64c55;
  font-size: 0.9rem;
  font-weight: 600;
}
.contest-banner[hidden] { display: none; }
.contest-banner .ic { color: var(--gold); }
.contest-banner.soon { background: linear-gradient(90deg, #4a3d20, #3a301a); border-color: #f5b83d55; }
.contest-banner.paused { background: linear-gradient(90deg, #3a3835, #2a2825); border-color: var(--line); }
.contest-banner button { padding: 5px 12px; font-size: 0.82rem; }
.contest-banner button[hidden] { display: none; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 80;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(92vw, 520px);
  padding: 12px 18px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  box-shadow: 0 16px 40px #000a;
  font-weight: 600;
  transform: translateX(-50%);
  animation: toastIn 0.3s cubic-bezier(0.3, 1.4, 0.5, 1);
}
.toast[hidden] { display: none; }
@keyframes toastIn { from { transform: translate(-50%, 30px); opacity: 0; } }

.contest-item.joined { border-color: #81b64c88; }
.contest-item.joined .ci-main b::after { content: " · Đã đăng ký ✓"; color: #a6d36b; font-size: 0.78rem; font-weight: 700; }

/* ---------- Huy chương contest (SVG có dây đeo, xem medalSVG trong app.js) ---------- */
.medal {
  display: inline-block;
  width: 22px;
  height: 26px;
  flex: none;
  vertical-align: middle;
  filter: drop-shadow(0 1px 2px #0008);
}
.medal svg { display: block; width: 100%; height: 100%; overflow: visible; }
.medal-chip { display: inline-flex; align-items: center; gap: 1px; }
.medal-chip b { font-size: 0.72rem; font-weight: 800; color: var(--muted); }
.medals { display: inline-flex; align-items: center; gap: 6px; margin-left: 2px; flex: none; }
.rank-no .medal { width: 24px; height: 29px; }
.toast .medal { width: 26px; height: 31px; }

#onlineTools { grid-auto-flow: column; grid-template-columns: none; grid-auto-columns: 1fr; }

/* =========================================================
   Giao diện v10: tông mực đen – giấy ngà theo logo
   ========================================================= */
body {
  background:
    radial-gradient(1100px 520px at 50% -12%, #ece9e10f, transparent 65%),
    radial-gradient(800px 500px at 100% 100%, #81b64c0a, transparent 60%),
    var(--bg);
  background-attachment: fixed;
}
/* Hạt nhiễu nhẹ như nền giấy của logo */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.06;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
::selection { background: var(--ivory); color: var(--ink); }

/* Thanh trên cùng */
.topbar { background: #121110d9; border-bottom-color: #ffffff0d; padding: 10px 22px; }
.brand { gap: 12px; font-size: 1.45rem; font-weight: 800; }
.brand img {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  filter: none;
  box-shadow: 0 0 0 1px #ffffff26, 0 6px 16px #0008;
  transition: transform 0.25s cubic-bezier(0.3, 1.5, 0.5, 1);
}
.brand:hover img { transform: rotate(-6deg) scale(1.05); }
.tabs { background: #ffffff08; border-color: #ffffff0f; padding: 5px; }
.tab { padding: 8px 16px; transition: background 0.15s, color 0.15s; }
.tab:hover { background: #ffffff0d; }
.tab[aria-selected="true"] { background: var(--accent); color: #fff; box-shadow: 0 2px 10px var(--accent-glow); }
.profile-chip { background: #ffffff08; border-color: #ffffff0f; }
.profile-chip:hover { background: #ffffff10; }
.icon-btn:hover { background: #ffffff0a; }

/* Bàn cờ: khung như một tấm bảng gỗ tối */
.board-wrap {
  padding: 0;
  border-radius: 10px;
  box-shadow: 0 0 0 6px #201e1b, 0 0 0 7px #ffffff14, 0 24px 60px #000c;
}
.board { border-radius: 6px; }

/* Bảng điều khiển */
.panel {
  background: linear-gradient(180deg, #ffffff07, #ffffff02), var(--panel);
  border-color: #ffffff10;
  border-radius: 20px;
  padding: 18px;
  box-shadow: inset 0 1px 0 #ffffff0d, 0 24px 50px #0008;
}
.status { border-radius: 12px; background: #ffffff0a; border: 1px solid #ffffff0d; }
.status.over { background: var(--ivory); color: var(--ink); border-color: transparent; }
select, button, input { border-radius: 10px; border-color: #ffffff12; }
button { background: #ffffff0a; }
button:hover { background: #ffffff14; }
button.primary { background: linear-gradient(180deg, #8cc256, var(--accent)); }
button.big { border-radius: 12px; }
.tool-row button { border-radius: 12px; }
.moves { border-radius: 12px; background: #0000002e; border: 1px solid #ffffff0a; }
h2 { letter-spacing: 0.3px; }

/* Hộp thoại */
.modal { background: #0a0a09b8; backdrop-filter: blur(6px); }
.modal-box {
  border-radius: 22px;
  border-color: #ffffff12;
  background: linear-gradient(180deg, #ffffff08, #ffffff02), var(--panel);
  box-shadow: inset 0 1px 0 #ffffff10, 0 40px 90px #000d;
}
.auth-brand { flex-direction: column; gap: 12px; }
.auth-brand img { width: 76px; height: 76px; border-radius: 20px; box-shadow: 0 0 0 1px #ffffff26, 0 12px 30px #000a; }
.auth-brand h1 { font-size: 1.9rem; }
.result-icon.win { background: var(--ivory); color: var(--ink); box-shadow: 0 0 34px #ece9e140; }

/* Hạng 1–3 trên bảng xếp hạng */
.podium {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--ink);
  background: var(--ivory);
}
.podium.p1 { background: linear-gradient(135deg, #ffe27a, #e0a325); }
.podium.p2 { background: linear-gradient(135deg, #ffffff, #aeb7bf); }
.podium.p3 { background: linear-gradient(135deg, #ffcf9e, #b9733a); }

/* Học cờ: icon SVG thay cho emoji */

.footer { color: #5f5b54; }

/* Chữ thương hiệu "Royal Gambit" */
.wordmark {
  font-family: "Cinzel", serif;
  font-weight: 700;
  letter-spacing: 0.12em;
  background: linear-gradient(180deg, #ffffff 10%, #d9d4c7 60%, #a9a294);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: none;
}
.brand .wordmark { font-size: 1.22rem; line-height: 1; }
.auth-brand h1.wordmark { font-family: "Cinzel", serif; font-size: 1.75rem; letter-spacing: 0.12em; }

/* =========================================================
   Giao diện v2: phong cách chess.com cho toàn web
   ========================================================= */
:root {
  --bg: #312e2b;
  --bg-2: #2b2926;
  --panel: #262421;
  --panel-2: #3c3a37;
  --panel-3: #4b4845;
  --line: #ffffff14;
  --text: #ffffff;
  --muted: #989795;
  --accent: #81b64c;
  --accent-dark: #45753c;
  --accent-glow: #81b64c40;
  --nav-w: 200px;
  --board-size: min(94vw, calc(100vh - 170px), 760px);
}
body { background: var(--bg); color: var(--text); }
body::before { display: none; }

/* Nút kiểu chess.com: khối nổi, chữ đậm */
select, input {
  background: #1f1e1b;
  border: 1px solid #45423e;
  border-radius: 6px;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -2px; border-color: transparent; }
button {
  background: var(--panel-2);
  border: none;
  border-radius: 8px;
  color: #fff;
  font-weight: 700;
  box-shadow: 0 4px 0 #1f1e1c;
}
button:hover { background: #45423f; }
button:active { transform: translateY(3px); box-shadow: 0 1px 0 #1f1e1c; }
button.primary {
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  text-shadow: 0 1px 0 #0003;
  box-shadow: 0 5px 0 var(--accent-dark);
}
button.primary:hover { background: #95c45f; filter: none; }
button.primary:active { box-shadow: 0 2px 0 var(--accent-dark); }
button.big { padding: 15px; font-size: 1.2rem; border-radius: 10px; }
button.ghost { box-shadow: none; background: transparent; }
button.ghost:hover { background: #ffffff0d; }
.icon-btn, .modal-close, .ls-x, .toc-item, .tab { box-shadow: none; }

/* Thanh điều hướng dọc bên trái (màn hình rộng) */
@media (min-width: 1000px) {
  body { padding-left: var(--nav-w); }
  .topbar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    width: var(--nav-w);
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding: 14px 10px;
    background: #262421;
    border: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    overflow-y: auto;
  }
  .brand { padding: 4px 8px 16px; gap: 10px; }
  .brand img { width: 36px; height: 36px; border-radius: 9px; }
  .brand .wordmark { font-size: 0.98rem; letter-spacing: 0.08em; }
  .tabs {
    flex-direction: column;
    gap: 2px;
    padding: 0;
    background: none;
    border: none;
    border-radius: 0;
  }
  .tab {
    justify-content: flex-start;
    gap: 12px;
    padding: 11px 12px;
    border-radius: 6px;
    color: #c3c2c1;
    font-size: 1rem;
    font-weight: 700;
  }
  .tab .ic { width: 22px; height: 22px; }
  .tab:hover { background: #1f1e1c; color: #fff; }
  .tab[aria-selected="true"] { background: var(--accent); color: #fff; box-shadow: 0 3px 0 var(--accent-dark); }
  .topbar-right {
    margin-top: auto;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding-top: 12px;
    border-top: 1px solid #ffffff10;
  }
  .icon-btn { justify-content: flex-start; gap: 12px; padding: 10px 12px; color: #c3c2c1; font-weight: 700; }
  .icon-btn:hover { background: #1f1e1c; color: var(--gold); }
  .profile-chip { width: 100%; padding: 6px 8px; border-radius: 8px; background: #1f1e1c; border: none; }
  .profile-chip:hover { background: #191816; }
  .contest-banner { top: 0; }
  .toast { left: calc(50% + var(--nav-w) / 2); }
  .lh-side { top: 18px; max-height: calc(100vh - 36px); }
  .unit { scroll-margin-top: 18px; }
}

/* Thanh trên cùng (màn hình hẹp) */
@media (max-width: 999px) {
  .topbar { background: #262421; border-bottom: 1px solid #00000040; backdrop-filter: none; }
  .tabs { background: #1f1e1c; border: none; }
  .tab[aria-selected="true"] { background: var(--accent); color: #fff; box-shadow: 0 2px 0 var(--accent-dark); }
  .profile-chip { background: #1f1e1c; border: none; }
}

/* Bố cục chính */
.layout { padding: 22px 20px; gap: 22px; }
/* Bóng đổ đặt riêng cho bàn và thanh đánh giá, không đặt cho cả khối .board-wrap: thanh đánh giá bị ẩn (ván Online)
   vẫn giữ chỗ, nên bóng của cả khối hiện thành một dải xám trống bên trái bàn cờ */
.board-wrap { border-radius: 4px; box-shadow: none; }
.board { border-radius: 4px; box-shadow: 0 6px 18px #0006; }
.eval-bar:not(.concealed) { box-shadow: inset 0 0 0 1px #0006, 0 6px 18px #0006; }
.player { height: 50px; margin: 6px 0; }
.player-name { font-size: 0.98rem; }
.player-rating { color: var(--muted); }
.avatar { border-radius: 4px; box-shadow: none; }

/* Bảng điều khiển bên phải */
.panel {
  width: min(94vw, 400px);
  background: var(--panel);
  border: none;
  border-radius: 10px;
  padding: 16px;
  gap: 14px;
  box-shadow: 0 4px 14px #0004;
}
.status {
  padding: 14px;
  border: none;
  border-radius: 8px;
  background: #1f1e1c;
  font-size: 1.02rem;
  font-weight: 800;
}
.status.in-check { background: #8c2f25; }
.status.over { background: var(--accent); color: #fff; box-shadow: 0 4px 0 var(--accent-dark); }
label { color: #c3c2c1; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.4px; }
.tool-row { gap: 6px; }
.tool-row button { background: #1f1e1c; color: #c3c2c1; box-shadow: none; border-radius: 8px; padding: 10px 4px; font-size: 0.74rem; }
.tool-row button:hover { background: #191816; color: #fff; }
.tool-row button:active { transform: none; }
.rated-note { font-size: 0.76rem; }
h2 { color: #c3c2c1; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.5px; }
.divider { color: #8b8987; }

/* Biên bản kiểu chess.com */
.moves { border: none; border-radius: 8px; background: #1f1e1c; max-height: 300px; }
.move-row { padding: 0 6px; }
.move-row:nth-child(odd) { background: #2b2926; }
.move-row .num { color: #8b8987; font-weight: 600; }
.move-row .mv { color: #e0dfde; }
.move-row .mv.current { background: #4b4845; color: #fff; box-shadow: inset 0 -2px 0 var(--accent); }
.empty { color: #8b8987; }

/* Online */
.searching { background: #1f1e1c; border-radius: 8px; }
.room-code { background: #1f1e1c; border-radius: 8px; border-color: var(--accent); }
.offer { background: #2e3a24; border-radius: 8px; }
.chat-log { background: #1f1e1c; border-radius: 8px; }

/* Hộp thoại */
.modal { background: #000000b0; backdrop-filter: none; }
.modal-box {
  background: var(--panel);
  border: none;
  border-radius: 10px;
  box-shadow: 0 20px 60px #000c;
}
.auth-brand img { border-radius: 16px; }
.auth-tabs { background: #1f1e1c; border-radius: 8px; }
.auth-tabs button { border-radius: 6px; box-shadow: none; }
.auth-tabs button.on { background: var(--accent); box-shadow: 0 3px 0 var(--accent-dark); }
.rank-table, .admin-table, .rank-tiers, .medal-list { background: #1f1e1c; border-radius: 8px; }
.rank-row, .contest-row, .admin-row { border-bottom-color: #ffffff0a; }
.rank-header, .contest-header { background: #2b2926; color: #8b8987; }
.rank-row:nth-child(even):not(.rank-header):not(.me) { background: #23211f; }
.rank-row.me, .contest-row.me, .admin-row.me { background: #81b64c1f; }
.rank-current, .elo-current, .rank-rules span, .elo-rules span, .stats div, .medal-card, .result-rating, .contest-meta, .contest-form { background: #1f1e1c; border-radius: 8px; }
.contest-item, .place-opt { background: #1f1e1c; border: 1px solid transparent; border-radius: 8px; box-shadow: none; }
.contest-item:hover, .place-opt:hover { background: #2b2926; border-color: var(--accent); }
.theme { box-shadow: none; }
.theme.on { background: #81b64c1f; border: 1px solid var(--accent); }
.result-icon.win { background: var(--accent); color: #fff; box-shadow: 0 0 30px #81b64c55; }

/* Banner contest & thông báo */
.contest-banner { background: #2e3a24; border-bottom: 1px solid #81b64c40; }
.contest-banner.soon { background: #3d3424; }
.contest-banner.paused { background: #262421; }
.toast { background: #3c3a37; border: none; border-radius: 10px; }

.footer { color: #6f6d6a; }

@media (max-width: 700px) {
  :root { --board-size: min(100vw - 16px, 720px); }
  .layout { padding: 8px; gap: 12px; }
  .panel { width: var(--board-size); }
}
@media (min-width: 1000px) {
  .brand .wordmark { font-size: 0.86rem; letter-spacing: 0.06em; white-space: nowrap; }
  .profile-text { min-width: 0; }
  .profile-text b, .profile-text small { max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
@media (max-width: 999px) {
  .tabs { overflow-x: auto; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { flex: none; }
}

/* Mute chat */
.mute-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 0.68rem;
  font-weight: 700;
  background: #e2533f33;
  color: #ff8f7e;
  white-space: nowrap;
}
.mute-badge[hidden] { display: none; }
.admin-row.muted-user { background: #e2533f12; }
button.danger-outline {
  background: transparent;
  border: 1px solid #e2533f88;
  color: #ff8f7e;
}
button.danger-outline:hover { background: #e2533f22; }
.mute-opp {
  width: 100%;
  margin-top: 4px;
  font-size: 0.8rem;
  color: #ff8f7e;
  border-color: #e2533f55;
}
.mute-opp:hover { background: #e2533f18; }
.chat-input-muted {
  opacity: 0.55;
  pointer-events: none;
}

/* Nhận xét sau ván */
.result-box { width: min(100%, 420px); }
.result-review {
  text-align: left;
  margin: 12px 0 4px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #00000030;
  border: 1px solid var(--line);
}
.result-review h3 {
  margin: 0 0 8px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.result-review p {
  margin: 0 0 8px;
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--text);
}
.result-review p:last-child { margin-bottom: 0; }
.result-review .rv-tag {
  display: inline-block;
  margin: 0 6px 6px 0;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 0.72rem;
  font-weight: 700;
  background: var(--panel-3);
  color: var(--muted);
}
.result-review .rv-tag.good { background: #81b64c33; color: #b5e37a; }
.result-review .rv-tag.bad { background: #e2533f33; color: #ff8f7e; }
.result-review .rv-tag.mid { background: #f5b83d33; color: #f5b83d; }
.result-review .rv-move {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--gold);
  font-weight: 600;
}

/* Biên bản: PGN / FEN / xem lại nước */
.record-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.record-head h2 { margin: 0; }
.record-actions { display: flex; gap: 4px; }
button.tiny {
  padding: 4px 10px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  border-radius: 6px;
}
.nav-row {
  display: flex;
  gap: 4px;
  margin-top: 8px;
}
.nav-row button {
  flex: 1;
  padding: 6px 0;
  font-size: 0.85rem;
  background: var(--panel-3);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
}
.nav-row button:hover { background: var(--panel-2); color: var(--accent); }
.nav-row button:disabled { opacity: 0.35; cursor: default; }
.view-hint {
  margin: 6px 0 0;
  font-size: 0.75rem;
  color: var(--gold);
  text-align: center;
}
.moves .mv {
  cursor: pointer;
  border-radius: 4px;
  padding: 1px 4px;
}
.moves .mv:hover { background: #ffffff12; }
.moves .mv.viewing {
  background: color-mix(in srgb, var(--accent) 28%, transparent);
  color: var(--accent);
  font-weight: 700;
}
.toast-copy {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 200;
  padding: 10px 18px;
  border-radius: 10px;
  background: #1d1c19ee;
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: 0 8px 24px #0008;
  pointer-events: none;
  animation: fadeUp 1.6s ease forwards;
}
@keyframes fadeUp {
  0% { opacity: 0; transform: translateX(-50%) translateY(8px); }
  15% { opacity: 1; transform: translateX(-50%) translateY(0); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translateX(-50%) translateY(-6px); }
}

/* Thư viện khai cuộc */
.lib-box { width: min(100%, 720px); max-height: min(90vh, 820px); display: flex; flex-direction: column; }
.lib-filters { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 12px; }
.lib-filter {
  padding: 6px 12px;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: var(--panel-3);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}
.lib-filter.on, .lib-filter:hover {
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
}
.lib-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  overflow: auto;
  padding: 2px 2px 12px;
  min-height: 200px;
}
.lib-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #00000028;
  text-align: left;
  cursor: pointer;
  color: var(--text);
  transition: border-color 0.15s, transform 0.1s;
}
.lib-card:hover {
  border-color: color-mix(in srgb, var(--accent) 50%, transparent);
  transform: translateY(-2px);
}
.lib-card-board, .lib-board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  aspect-ratio: 1;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 2px 8px #0005;
  /* Cô lập khỏi skin/theme toàn trang */
  filter: none !important;
  background: #779556;
}
.lb-sq {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  position: relative;
}
.lb-sq.l { background: #ebecd0; }
.lb-sq.d { background: #779556; }
.lb-sq .lb-piece, .lb-sq img {
  width: 92%;
  height: 92%;
  object-fit: contain;
  pointer-events: none;
  filter: none !important;
  /* không để skin/drop-shadow toàn cục làm méo quân */
  image-rendering: auto;
}
.lib-card-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.lib-card-meta b { font-size: 0.88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-card-meta small { color: var(--muted); font-size: 0.72rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-tag {
  align-self: flex-start;
  margin-top: 4px;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 0.68rem;
  font-weight: 700;
  background: #ffffff12;
  color: var(--muted);
}
.lib-tag.gambit { background: #e2533f28; color: #ff8f7e; }
.lib-tag.open { background: #81b64c28; color: #b5e37a; }
.lib-tag.semi { background: #5aa9ff28; color: #8ec5ff; }
.lib-tag.endgame { background: #f5b83d28; color: #f5b83d; }

.lib-detail { margin-top: 4px; }
.lib-detail-body {
  display: grid;
  grid-template-columns: minmax(160px, 220px) 1fr;
  gap: 16px;
  margin-top: 10px;
  align-items: start;
}
.lib-board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 4px 14px #0006;
}
.lib-info h3 { margin: 0 0 8px; font-size: 1.15rem; }
.lib-moves {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9rem;
  color: var(--gold);
  margin: 0 0 10px;
  font-weight: 600;
}
.lib-detail-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
@media (max-width: 560px) {
  .lib-detail-body { grid-template-columns: 1fr; }
  .lib-board-wrap { max-width: 240px; margin: 0 auto; }
}

/* Nút Rank: ngôi sao vàng */
.header-rank-icon .rank-star-ic {
  width: 20px;
  height: 20px;
  color: var(--gold);
  filter: drop-shadow(0 0 6px #f5b83d66);
}
.header-rank-btn { color: var(--gold); }
.header-rank-btn:hover { color: #ffe08a; }

/* Huy hiệu khiên rank */
.rb-medal svg { overflow: visible; }
.rank-badge .rb-medal {
  filter: drop-shadow(0 3px 8px color-mix(in srgb, var(--rk) 40%, transparent));
}

/* Logo không nền */
.brand img {
  background: transparent !important;
  border-radius: 0;
  box-shadow: none;
  filter: drop-shadow(0 1px 3px #000a);
}
.auth-brand img {
  background: transparent !important;
  border-radius: 0;
  box-shadow: none;
}

/* Thanh đánh giá thế cờ */
.board-wrap {
  display: flex;
  align-items: stretch;
  gap: 6px;
  position: relative;
}
.board-wrap .board { flex: 1; min-width: 0; }
.eval-bar {
  width: 14px;
  flex: none;
  display: flex;
  flex-direction: column-reverse;
  border-radius: 6px;
  overflow: hidden;
  position: relative;
  box-shadow: inset 0 0 0 1px #0006;
  background: #1a1916;
}
.eval-bar[hidden] { display: none; }
.eval-white {
  background: linear-gradient(180deg, #f0f0f0, #d8d8d8);
  transition: flex 0.35s ease;
  min-height: 0;
}
.eval-black {
  background: linear-gradient(180deg, #2a2a2a, #111);
  transition: flex 0.35s ease;
  min-height: 0;
}
.eval-label {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.55rem;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 1px 2px #000c;
  pointer-events: none;
  white-space: nowrap;
  writing-mode: horizontal-tb;
  background: #0008;
  padding: 1px 3px;
  border-radius: 3px;
}
.tool-row button.on {
  color: var(--accent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 45%, transparent);
}
.tool-row button:disabled {
  opacity: 0.35;
  cursor: default;
}
@media (max-width: 700px) {
  .eval-bar { width: 10px; }
  .eval-label { font-size: 0.45rem; }
}

/* Câu đố & Nhật ký */
.puzzle-box, .hist-box { width: min(100%, 520px); max-height: min(90vh, 720px); display: flex; flex-direction: column; }
.puzzle-list, .hist-list { overflow: auto; display: flex; flex-direction: column; gap: 8px; margin-top: 10px; padding-bottom: 8px; }
.puzzle-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-rows: auto auto;
  gap: 2px 10px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #00000028;
  text-align: left;
  color: var(--text);
  cursor: pointer;
}
.puzzle-card:hover { border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.puzzle-card b { grid-column: 2; font-size: 0.95rem; }
.puzzle-card small { grid-column: 2; }
.pz-lv {
  grid-row: 1 / span 2;
  align-self: center;
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 0.72rem;
  font-weight: 800;
  background: #81b64c33;
  color: #b5e37a;
}
.pz-theme {
  grid-row: 1 / span 2;
  align-self: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--gold);
}
/* Câu đố: thanh công cụ trong panel — không đè lên bàn cờ */
.puzzle-banner-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #00000033;
  border: 1px solid color-mix(in srgb, var(--gold, #f5b83d) 35%, transparent);
  margin-bottom: 4px;
}
.puzzle-banner-panel .pz-ban-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.puzzle-banner-panel .pz-ban-text b { font-size: 0.9rem; color: var(--gold, #f5b83d); }
.puzzle-banner-panel .pz-ban-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.puzzle-banner-panel .pz-ban-actions button {
  width: 100%;
  justify-content: center;
}
/* Gỡ banner fixed cũ nếu còn sót trong DOM */
.puzzle-banner {
  display: none !important;
}

.hist-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 10px;
  background: #00000028;
  border: 1px solid var(--line);
}
.hist-main { min-width: 0; }
.hist-main b { display: block; font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hist-res { font-weight: 800; font-size: 0.8rem; }
.hist-res.win { color: #b5e37a; }
.hist-res.loss { color: #ff8f7e; }
.hist-res.draw { color: var(--gold); }
.hist-actions { display: flex; gap: 4px; }
@media (max-width: 560px) {
  .hist-row { grid-template-columns: 1fr auto; }
  .hist-moves { display: none; }
}

/* Danh hiệu GM / IM / CM … */
.title-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  padding: 1px 6px;
  border-radius: 4px;
  background: linear-gradient(135deg, #f5b83d55, #f5b83d22);
  color: var(--gold, #f5b83d);
  border: 1px solid #f5b83d66;
  vertical-align: middle;
  margin-right: 2px;
  line-height: 1.4;
}
.title-select {
  padding: 4px 6px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background-color: var(--panel);
  color: var(--text);
  font-size: 0.78rem;
  max-width: 108px;
}
#meName .title-badge, .player-name .title-badge, .pf-name .title-badge {
  margin-right: 4px;
}
#adminCsv[hidden], .admin-hint[hidden] { display: none; }

/* =========================================================
   Giao diện v11: trang hồ sơ, bục trao giải, thanh đánh giá
   ========================================================= */

/* Bảng xếp hạng / bảng điểm: cả hàng bấm được để xem hồ sơ */
.lb-box { width: min(100%, 780px); }
.rank-row { grid-template-columns: 2.6em minmax(0, 1fr) 10.5em 3.6em 3.8em 6.5em; }
.rank-tier { white-space: nowrap; }
.rank-name .nm { min-width: 0; }
.rank-row.clickable, .contest-row.clickable {
  display: grid;
  width: 100%;
  margin: 0;
  border: none;
  border-bottom: 1px solid #ffffff0a;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
  color: var(--text);
  font-weight: 400;
  text-align: left;
  transition: background 0.12s;
}
.rank-row.clickable:active, .contest-row.clickable:active { transform: none; box-shadow: none; }
#lbList .rank-row.clickable:hover, #contestBoard .contest-row.clickable:hover { background: #ffffff0d; }
#lbList .rank-row.me.clickable:hover, #contestBoard .contest-row.me.clickable:hover { background: #81b64c2e; }
#contestPlain:not(:empty) { margin: 12px 0 0; }

/* Danh sách contest: tên nhà vô địch */
.ci-badge.champ { display: inline-flex; align-items: center; gap: 5px; max-width: 45%; overflow: hidden; text-overflow: ellipsis; background: #f5c03d1f; color: var(--gold); }
.ci-badge.champ .medal { width: 15px; height: 18px; }

/* Bục trao giải contest */
.podium-stage[hidden] { display: none; }
.podium-stage {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 8px;
  padding: 14px 8px 0;
  border-radius: 8px;
  background: radial-gradient(ellipse at 50% 100%, #f5c03d1a, transparent 70%), #1f1e1c;
}
.podium-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  width: 31%;
  max-width: 150px;
  min-width: 0;
  padding: 0;
  border: none;
  background: transparent;
  box-shadow: none;
  font-weight: 400;
}
.podium-step:hover { background: transparent; }
.podium-step:hover .ps-block { filter: brightness(1.12); }
.podium-step:active { transform: none; box-shadow: none; }
.podium-step .avatar { width: 44px; height: 44px; border-radius: 22%; font-size: 1.1rem; box-shadow: 0 0 0 3px var(--tone); } /* bo góc trùng lỗ trong của khung avatar */
.podium-step.gold .avatar { width: 52px; height: 52px; }
.ps-name { max-width: 100%; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.9rem; }
.podium-step small { color: var(--muted); font-size: 0.72rem; }
.ps-block {
  display: grid;
  justify-items: center;
  align-content: start;
  width: 100%;
  margin-top: 6px;
  padding-top: 10px;
  border-radius: 8px 8px 0 0;
  background: linear-gradient(180deg, color-mix(in srgb, var(--tone) 55%, #262421), color-mix(in srgb, var(--tone) 18%, #1f1e1c));
  box-shadow: inset 0 1px 0 #ffffff30;
  transition: filter 0.15s;
}
.ps-block .medal { width: 30px; height: 36px; }
.podium-step.gold { --tone: #f5c03d; }
.podium-step.silver { --tone: #c9d1d9; }
.podium-step.bronze { --tone: #d08a4c; }
.podium-step.gold .ps-block { height: 92px; }
.podium-step.silver .ps-block { height: 70px; }
.podium-step.bronze .ps-block { height: 54px; }
.podium-step.me .ps-name { color: #a6d36b; }

/* Thanh đánh giá: số nằm ở đầu bên đang hơn, như chess.com */
.eval-bar { width: 20px; }
.eval-bar.flipped { flex-direction: column; }
.eval-bar.off { visibility: hidden; }
.eval-label {
  top: auto;
  bottom: 4px;
  transform: translateX(-50%);
  padding: 0;
  background: none;
  text-shadow: none;
  font-size: 0.56rem;
  letter-spacing: -0.02em;
  color: #312e2b;
}
.eval-label.b { top: 4px; bottom: auto; color: #e8e6e1; }
.eval-bar.flipped .eval-label { top: 4px; bottom: auto; }
.eval-bar.flipped .eval-label.b { top: auto; bottom: 4px; }
body[data-mode="learn"] .eval-bar { display: none; }
@media (max-width: 700px) {
  .eval-bar { width: 10px; }
  .eval-label { display: none; }
}

/* ---------- Trang hồ sơ ---------- */
body[data-page="profile"] .layout { display: none; }
.pf-page[hidden] { display: none; }
.pf-page {
  width: min(100%, 1120px);
  margin: 0 auto;
  padding: 16px 20px 40px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.pf-page [hidden] { display: none !important; }
.pf-bar { display: flex; align-items: center; justify-content: space-between; }
.pf-back { padding: 6px 10px 6px 4px; color: #c3c2c1; font-weight: 700; }
button.pf-back:hover { color: #fff; background: #ffffff0d; }

.pf-hero {
  --rk: var(--gold);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 26px;
  border-radius: 12px;
  overflow: hidden;
  background:
    radial-gradient(ellipse 60% 120% at 0% 0%, color-mix(in srgb, var(--rk) 26%, transparent), transparent 70%),
    linear-gradient(180deg, #2b2926, #262421);
  box-shadow: inset 0 1px 0 #ffffff12, 0 4px 14px #0004;
}
/* hoạ tiết bàn cờ mờ ở góc phải */
.pf-hero::after {
  content: "";
  position: absolute;
  inset: 0 0 0 auto;
  width: 46%;
  pointer-events: none;
  background: repeating-conic-gradient(#ffffff 0 25%, transparent 0 50%) 0 0 / 44px 44px;
  opacity: 0.035;
  mask-image: linear-gradient(90deg, transparent, #000 60%);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 60%);
}
.pf-hero > * { position: relative; z-index: 1; }
.pf-hero-main { display: flex; align-items: center; gap: 20px; min-width: 0; }
.pf-avatar-wrap { position: relative; flex: none; }
.avatar.pf-avatar {
  width: 104px;
  height: 104px;
  border-radius: 18px;
  font-size: 2.8rem;
  box-shadow: 0 0 0 3px #262421, 0 0 0 5px var(--rk), 0 10px 24px #0008;
}
.avatar.pf-avatar.editable { cursor: pointer; }
.pf-avatar-edit {
  position: absolute;
  right: -8px;
  bottom: -8px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 50%;
  background: #3c3a37;
  box-shadow: 0 0 0 3px #262421;
  color: #fff;
}
.pf-avatar-edit:hover { background: var(--accent); }
.pf-avatar-edit:active { transform: none; box-shadow: 0 0 0 3px #262421; }
.pf-ident { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.pf-name-line { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 10px; }
.pf-name {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #fff;
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.01em;
}
.pf-name .title-badge { font-size: 0.9rem; padding: 2px 7px; vertical-align: 0.3em; }
.pf-chips { display: inline-flex; gap: 6px; }
.pf-chip { padding: 2px 9px; border-radius: 99px; background: #81b64c26; color: #a6d36b; font-size: 0.75rem; font-weight: 800; }
.pf-rank-line { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; color: #c3c2c1; font-size: 0.9rem; }
.pf-rank-line .rb-medal { width: 26px; height: 26px; flex: none; }
.pf-rank-line .rb-medal svg { width: 100%; height: 100%; display: block; }
.pf-rank-line b { font-weight: 800; }
.pf-stars { letter-spacing: 2px; color: #ffffff2e; }
.pf-stars .on { color: var(--gold); }
.pf-stars small { margin-left: 2px; color: var(--gold); font-weight: 800; letter-spacing: 0; }
.pf-dot { color: #ffffff40; }
.pf-medal-strip { display: flex; flex-wrap: wrap; gap: 8px; }
.pf-medal-strip:empty { display: none; }
.pf-medal-strip .medal { width: 24px; height: 29px; }
.pf-medal-strip .medal-chip b { font-size: 0.8rem; color: #e0dfde; }

.pf-elo-block { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; text-align: right; }
.pf-elo-label { color: var(--muted); font-size: 0.72rem; font-weight: 800; letter-spacing: 1.5px; text-transform: uppercase; }
.pf-elo { color: #fff; font-size: 3.4rem; font-weight: 800; line-height: 0.95; font-variant-numeric: tabular-nums; }
.pf-elo-class { padding: 3px 10px; border-radius: 99px; background: #81b64c26; color: #a6d36b; font-size: 0.75rem; font-weight: 800; }

.pf-error { margin: 0; padding: 30px 16px; border-radius: 10px; background: #262421; color: var(--muted); text-align: center; }

.pf-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.pf-col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.pf-card { padding: 16px; border-radius: 10px; background: #262421; box-shadow: 0 4px 14px #0003; }
.pf-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.pf-card-head h2 { margin: 0; color: #c3c2c1; }
.pf-card-head small { color: #8b8987; font-size: 0.75rem; text-align: right; }
.pf-card-head .ghost { padding: 2px 6px; font-size: 0.78rem; }
.pf-card-head button.ghost:hover { color: #fff; }
.pf-empty { margin: 2px 0; color: #8b8987; font-size: 0.88rem; line-height: 1.5; }

.pf-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.pf-tile { display: flex; flex-direction: column; gap: 2px; padding: 14px; border-radius: 10px; background: #262421; box-shadow: 0 4px 14px #0003; min-width: 0; }
.pf-tile span { color: #8b8987; font-size: 0.7rem; font-weight: 800; letter-spacing: 0.5px; text-transform: uppercase; }
.pf-tile b { color: #fff; font-size: 1.7rem; font-weight: 800; line-height: 1.15; font-variant-numeric: tabular-nums; }
.pf-tile small { color: #8b8987; font-size: 0.74rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.pf-wdl-bar { display: flex; gap: 2px; height: 12px; border-radius: 99px; overflow: hidden; background: #1f1e1c; }
.pf-wdl-bar .win { background: #81b64c; }
.pf-wdl-bar .draw { background: #8b8987; }
.pf-wdl-bar .loss { background: #e2533f; }
.pf-wdl-legend { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.pf-wdl-legend span { display: flex; align-items: baseline; gap: 6px; padding: 8px 10px; border-radius: 8px; background: #1f1e1c; color: #c3c2c1; font-size: 0.8rem; }
.pf-wdl-legend i { align-self: center; width: 9px; height: 9px; border-radius: 3px; background: currentColor; }
.pf-wdl-legend .win i { background: #81b64c; }
.pf-wdl-legend .draw i { background: #8b8987; }
.pf-wdl-legend .loss i { background: #e2533f; }
.pf-wdl-legend b { margin-left: auto; color: #fff; font-size: 1.05rem; }
.pf-wdl-legend small { color: #8b8987; font-size: 0.72rem; min-width: 2.6em; text-align: right; }

.pf-chart { position: relative; }
.pf-chart svg { display: block; width: 100%; height: auto; overflow: visible; touch-action: pan-y; }
.pf-chart .grid { stroke: #ffffff10; stroke-width: 1; }
.pf-chart .axis { fill: #8b8987; font-size: 11px; font-family: var(--font); }
.pf-chart .ln { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.pf-chart .end, .pf-chart .hot { fill: var(--accent); stroke: #262421; stroke-width: 2; }
.pf-chart .cross { stroke: #ffffff45; stroke-width: 1; stroke-dasharray: 3 3; }
.pf-tip {
  position: absolute;
  z-index: 2;
  display: flex;
  flex-direction: column;
  padding: 6px 10px;
  border-radius: 8px;
  background: #3c3a37;
  box-shadow: 0 6px 16px #0008;
  color: #fff;
  font-size: 0.8rem;
  white-space: nowrap;
  pointer-events: none;
}
.pf-tip small { color: #c3c2c1; font-size: 0.72rem; }
.pf-tip .up { color: #a6d36b; font-weight: 800; }
.pf-tip .down { color: #ff8f7e; font-weight: 800; }

.pf-medal-counts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pf-medal-count {
  --tone: #f5c03d;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 14px 6px 12px;
  border-radius: 10px;
  background: radial-gradient(ellipse at 50% 0%, color-mix(in srgb, var(--tone) 16%, transparent), transparent 70%), #1f1e1c;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--tone) 30%, transparent);
}
.pf-medal-count.silver { --tone: #c9d1d9; }
.pf-medal-count.bronze { --tone: #d08a4c; }
.pf-medal-count .medal { width: 40px; height: 48px; margin-bottom: 4px; }
.pf-medal-count b { color: #fff; font-size: 1.5rem; line-height: 1.1; }
.pf-medal-count span { color: #8b8987; font-size: 0.7rem; font-weight: 800; letter-spacing: 0.5px; text-transform: uppercase; }
.pf-medal-count.none { opacity: 0.4; box-shadow: none; background: #1f1e1c; }
.pf-medal-count.none .medal { filter: grayscale(1); }

.pf-medals { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; margin-top: 12px; }
.pf-medals > .pf-empty { grid-column: 1 / -1; }
.pf-medal-tile {
  --tone: #f5c03d;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 12px;
  border: 1px solid color-mix(in srgb, var(--tone) 22%, transparent);
  border-radius: 10px;
  background: linear-gradient(100deg, color-mix(in srgb, var(--tone) 10%, #1f1e1c), #1f1e1c 60%);
  box-shadow: none;
  font-weight: 400;
  text-align: left;
  transition: border-color 0.15s, transform 0.15s, background 0.15s;
}
.pf-medal-tile.silver { --tone: #c9d1d9; }
.pf-medal-tile.bronze { --tone: #d08a4c; }
.pf-medal-tile:hover { border-color: color-mix(in srgb, var(--tone) 65%, transparent); background: linear-gradient(100deg, color-mix(in srgb, var(--tone) 16%, #262421), #262421 60%); transform: translateY(-1px); }
.pf-medal-tile:active { transform: none; box-shadow: none; }
.pf-medal-tile .medal { width: 34px; height: 41px; }
.pf-mt-main, .pf-cr-main, .pf-g-main { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.pf-mt-main b, .pf-cr-main b, .pf-g-main b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #fff; font-weight: 700; }
.pf-mt-main small, .pf-cr-main small, .pf-g-main small { color: #8b8987; font-size: 0.76rem; }
.pf-go { width: 18px; height: 18px; color: #8b8987; }

.pf-contests { display: flex; flex-direction: column; gap: 6px; }
.pf-contest-row {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto 3.4em 6.2em 18px;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: 8px;
  background: #1f1e1c;
  box-shadow: none;
  font-weight: 400;
  text-align: left;
}
.pf-contest-row:hover { background: #2b2926; }
.pf-contest-row:hover .pf-go { color: #fff; }
.pf-contest-row:active { transform: none; box-shadow: none; }
.pf-cr-place { display: grid; place-items: center; color: #c3c2c1; font-weight: 800; }
.pf-cr-place .medal { width: 26px; height: 31px; }
.pf-cr-pts { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.1; }
.pf-cr-pts b { color: var(--gold); font-size: 1.05rem; }
.pf-cr-pts small { color: #8b8987; font-size: 0.68rem; }
.pf-tag { padding: 2px 9px; border-radius: 99px; background: #ffffff10; color: #c3c2c1; font-size: 0.72rem; font-weight: 800; white-space: nowrap; }
.pf-tag.live { background: #81b64c33; color: #a6d36b; }
.pf-tag.soon { background: #f5b83d26; color: var(--gold); }

.pf-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 12px;
  padding: 10px;
  border-radius: 8px;
  background: #1f1e1c;
  box-shadow: none;
  color: #e0dfde;
  font-size: 0.88rem;
}
.pf-link:hover { background: #2b2926; color: #fff; }
.pf-link:active { transform: none; box-shadow: none; }

.pf-rank-card { background: radial-gradient(ellipse at 50% 0%, color-mix(in srgb, var(--rk) 14%, transparent), transparent 60%), #262421; }
.pf-rank-body { text-align: center; }
.pf-rank-body .rank-badge .rb-medal { width: 84px; height: 84px; }
.pf-rank-body .rk-stars { margin: 8px 0 10px; }
.pf-rank-body .rk-stars small { margin-left: 4px; font-size: 1.1rem; color: var(--gold); letter-spacing: 0; }
.pf-rank-note { margin: 10px 0 0; color: #8b8987; font-size: 0.8rem; line-height: 1.45; text-align: center; }

.pf-vs { display: flex; align-items: center; justify-content: space-around; gap: 10px; }
.pf-vs div { display: flex; flex-direction: column; align-items: center; min-width: 0; }
.pf-vs span { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #8b8987; font-size: 0.75rem; font-weight: 700; }
.pf-vs b { color: #fff; font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.pf-vs .ic { width: 26px; height: 26px; color: var(--gold); }
.pf-vs-bar { height: 8px; margin-top: 12px; border-radius: 99px; overflow: hidden; background: #e2533f66; }
.pf-vs-bar span { display: block; height: 100%; background: var(--accent); border-right: 2px solid #262421; }
#pfVsCard .elo-rules { margin: 12px 0 0; }
#pfVsCard .pf-card-head h2 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.pf-learn { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.pf-learn span { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 4px; border-radius: 8px; background: #1f1e1c; text-align: center; }
.pf-learn .ic { width: 22px; height: 22px; }
.pf-learn .flame { color: #ff9600; fill: #ff960033; }
.pf-learn .bolt { color: var(--gold); fill: #f5b83d33; }
.pf-learn .target { color: #5aa9ff; }
.pf-learn b { color: #fff; font-size: 1.05rem; }
.pf-learn small { color: #8b8987; font-size: 0.66rem; line-height: 1.2; }

.pf-games { display: flex; flex-direction: column; }
.pf-game { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid #ffffff0a; }
.pf-game:last-child { border-bottom: none; }
.pf-res { flex: none; width: 3.6em; padding: 3px 0; border-radius: 6px; background: #ffffff10; color: #c3c2c1; font-size: 0.72rem; font-weight: 800; text-align: center; }
.pf-res.win { background: #81b64c2e; color: #a6d36b; }
.pf-res.loss { background: #e2533f2e; color: #ff8f7e; }

.pf-settings .avatar-actions { margin-top: 0; }
.pf-settings .skin-section h4 { margin-top: 14px; }
.pf-msg { margin: 8px 0 0; color: var(--danger); font-size: 0.85rem; }
.pf-msg:empty { display: none; }
button.pf-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 4px;
  border: 1px solid #e2533f66;
  background: transparent;
  box-shadow: none;
  color: #ff8f7e;
}
button.pf-logout:hover { background: #e2533f1f; }

@media (max-width: 960px) {
  .pf-grid { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .pf-page { padding: 10px 8px 32px; gap: 12px; }
  .pf-hero { flex-direction: column; align-items: stretch; gap: 16px; padding: 18px 16px; }
  .pf-hero-main { gap: 14px; }
  .avatar.pf-avatar { width: 76px; height: 76px; font-size: 2rem; border-radius: 14px; }
  .pf-name { font-size: 1.45rem; }
  .pf-elo-block { flex-direction: row; align-items: baseline; justify-content: flex-start; gap: 10px; padding-top: 14px; border-top: 1px solid #ffffff12; }
  .pf-elo { font-size: 2.2rem; order: -1; }
  .pf-elo-label { order: -1; }
  .pf-elo-class { margin-left: auto; }
  .pf-tiles { grid-template-columns: repeat(2, 1fr); }
  .pf-tile b { font-size: 1.4rem; }
  .pf-contest-row { grid-template-columns: 30px minmax(0, 1fr) 3em 16px; gap: 10px; }
  .pf-contest-row .pf-tag, .pf-contest-row .pf-cr-wdl { display: none; }
  .pf-medals { grid-template-columns: 1fr; }
  .pf-wdl-legend span { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 0 6px; }
  .pf-wdl-legend b, .pf-wdl-legend small { grid-column: 1 / -1; margin-left: 0; text-align: left; }
  .rank-row { grid-template-columns: 2.2em minmax(0, 1fr) 4.6em 3.2em; }
  .rank-row .medals, .rank-tier .rt-name { display: none; }
}

/* Logo khiên (img/logo.svg): to hơn chút để thấy rõ quân Vua */
.brand img { width: 40px; height: 40px; }
.auth-brand img { width: 92px; height: 92px; filter: drop-shadow(0 10px 22px #000a); }
@media (min-width: 1000px) { .brand img { width: 42px; height: 42px; } }

/* =========================================================
   Giao diện v12: trau chuốt toàn web + đồng hồ, khai cuộc, câu đố
   ========================================================= */

/* Chung: vòng focus khi dùng bàn phím, thanh cuộn tối, chuyển động mượt */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button:focus:not(:focus-visible) { outline: none; }
* { scrollbar-width: thin; scrollbar-color: #4b4845 transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #4b4845; border-radius: 99px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: #5c5955; }
::-webkit-scrollbar-track { background: transparent; }
button, .tab, select, input { transition: background 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.05s; }
kbd {
  display: inline-block;
  min-width: 1.7em;
  padding: 2px 6px;
  border-radius: 5px;
  background: #3c3a37;
  box-shadow: inset 0 -2px 0 #1f1e1c;
  color: #fff;
  font: 700 0.78rem/1.4 var(--font);
  text-align: center;
}

/* Hộp thoại: tiêu đề chữ thường, icon trong ô màu, viền mảnh */
.modal { background: #000000a8; backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); }
.modal-box { box-shadow: 0 0 0 1px #ffffff10, 0 24px 70px #000c; }
.rank-head { gap: 14px; }
.rank-head h2 { margin: 0; color: #fff; font-size: 1.3rem; font-weight: 800; letter-spacing: -0.01em; text-transform: none; }
.rank-head p.muted { margin: 2px 0 0; font-size: 0.82rem; }
.rank-head .big-ic {
  box-sizing: content-box;
  width: 24px;
  height: 24px;
  padding: 10px;
  flex: none;
  border-radius: 12px;
  background: #f5b83d1a;
  box-shadow: inset 0 0 0 1px #f5b83d33;
}
.modal-close { border-radius: 8px; }
.modal-close:hover { background: #ffffff12; color: #fff; }
label.switch { text-transform: none; letter-spacing: 0; }

/* Ô trạng thái: chấm màu bên tới lượt */
.status[data-turn="w"]::before, .status[data-turn="b"]::before {
  content: "";
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 10px;
  border-radius: 50%;
  vertical-align: -1px;
  box-shadow: 0 0 0 2px #00000055;
}
.status[data-turn="w"]::before { background: #f4f3ef; }
.status[data-turn="b"]::before { background: #111; box-shadow: 0 0 0 2px #ffffff40; }

/* Tên khai cuộc */
.opening-name[hidden] { display: none; }
.opening-name {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: -6px;
  padding: 8px 12px;
  border-radius: 8px;
  background: #1f1e1c;
  animation: fade 0.2s;
}
.opening-name .ic { width: 18px; height: 18px; color: var(--gold); }
.opening-name span { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.opening-name b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #fff; font-size: 0.88rem; }
.opening-name small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #8b8987; font-size: 0.72rem; }

/* Đồng hồ cờ trên thanh người chơi */
.clock[hidden] { display: none; }
.clock {
  min-width: 4.6em;
  padding: 7px 12px;
  border-radius: 6px;
  background: #1f1e1c;
  color: #8b8987;
  font: 800 1.2rem/1 var(--font);
  font-variant-numeric: tabular-nums;
  text-align: right;
  transition: background 0.2s, color 0.2s;
}
.clock.running { background: #ecebe8; color: #262421; }
.clock.low { color: #ff8f7e; }
.clock.low.running { background: #e2533f; color: #fff; }
.clock.flag { background: #7a2e26; color: #fff; }
.clock:not([hidden]) + .turn-dot { display: none; }
@media (max-width: 700px) { .clock { font-size: 1.05rem; padding: 6px 9px; } }

/* Tuỳ chọn bàn cờ */
body[data-coords="off"] .board .coord { display: none; }
body[data-dots="off"] .board .sq.target::after, body[data-dots="off"] .board .sq.capture::after { display: none; }

/* Pháo giấy */
.confetti { position: fixed; inset: 0; z-index: 200; pointer-events: none; }

/* Cài đặt trong trang hồ sơ */
.pf-switches { display: flex; flex-direction: column; }
.pf-switches .switch { margin: 0; padding: 9px 0; border-bottom: 1px solid #ffffff0a; color: #e0dfde; font-size: 0.88rem; font-weight: 500; }
.pf-switches .switch:last-child { border-bottom: none; }

/* Phím tắt */
.keys-box { width: min(100%, 460px); }
.keys-list { display: grid; grid-template-columns: auto 1fr; gap: 10px 16px; align-items: center; margin: 4px 0 0; }
.keys-list dt { text-align: right; color: #c3c2c1; font-size: 0.85rem; white-space: nowrap; }
.keys-list dd { margin: 0; color: #e0dfde; font-size: 0.9rem; }

/* Thanh câu đố trong bảng điều khiển */
.puzzle-banner-panel { gap: 10px; padding: 12px; border-radius: 10px; background: #1f1e1c; border: 1px solid #f5b83d40; }
.pz-ban-head { display: flex; align-items: center; gap: 10px; }
.pz-ban-side { width: 22px; height: 22px; flex: none; border-radius: 50%; background: #f4f3ef; box-shadow: 0 0 0 2px #00000066; }
.pz-ban-side.b { background: #111; box-shadow: 0 0 0 2px #ffffff40; }
.puzzle-banner-panel .pz-ban-text b { color: #fff; font-size: 0.98rem; }
.puzzle-banner-panel .pz-ban-text .muted { font-size: 0.76rem; }
.pz-ban-msg { margin: 0; padding: 8px 10px; border-radius: 8px; background: #2b2926; color: #e0dfde; font-size: 0.86rem; font-weight: 600; line-height: 1.4; }
.pz-ban-msg:empty { display: none; }
.pz-ban-msg.ok { background: #81b64c26; color: #b5e37a; }
.pz-ban-msg.bad { background: #e2533f26; color: #ff8f7e; animation: shake 0.3s; }
.pz-ban-msg.hint { background: #f5b83d1f; color: #f8d27a; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.puzzle-banner-panel .pz-ban-actions { grid-template-columns: repeat(4, 1fr); }
.puzzle-banner-panel .pz-ban-actions button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 2px;
  border-radius: 8px;
  background: #2b2926;
  box-shadow: none;
  color: #c3c2c1;
  font-size: 0.72rem;
}
.puzzle-banner-panel .pz-ban-actions button:hover { background: #3c3a37; color: #fff; }
.puzzle-banner-panel .pz-ban-actions button.primary { background: var(--accent); color: #fff; }

/* Sảnh Online: nhóm lựa chọn rõ ràng hơn */
#onlineLobby .divider { margin: 4px 0; font-weight: 600; }
#onlineLobby > p.muted { margin: -4px 0 0; font-size: 0.78rem; }
.join-row input { letter-spacing: 0.3em; font-weight: 800; text-transform: uppercase; }
.join-row input::placeholder { letter-spacing: 0.1em; font-weight: 600; }

/* Thanh điều hướng bên trái: chỉ báo mục đang mở */
@media (min-width: 1000px) {
  .tab { position: relative; }
  .tab:not([aria-selected="true"]):hover .ic { color: var(--gold); }
}

/* =========================================================
   Giao diện v13: Thư viện khai cuộc & Câu đố
   ========================================================= */

/* Bàn cờ thu nhỏ có khung gỗ tối, ô nước vừa đi */
.lib-frame { border: 4px solid #1a1916; border-radius: 8px; box-shadow: 0 0 0 1px #ffffff14, 0 8px 18px #0007; }
.lib-frame.gold { border-color: #a8772a; box-shadow: 0 0 0 1px #f5c03d66, 0 10px 24px #000a, 0 0 30px #f5c03d22; }
.lb-sq.hl.l { background: #f5f682; }
.lb-sq.hl.d { background: #b9ca43; }

/* ---------- Thư viện ---------- */
.lib-box { width: min(100%, 900px); max-height: min(92vh, 900px); }
.lib-search {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
  padding: 0 12px;
  border-radius: 10px;
  background: #1f1e1c;
  box-shadow: inset 0 0 0 1px #ffffff12;
  text-transform: none;
  letter-spacing: 0;
}
.lib-search[hidden] { display: none; }
.lib-search:focus-within { box-shadow: inset 0 0 0 2px var(--accent); }
.lib-search .ic { color: #8b8987; }
.lib-search input { flex: 1; padding: 11px 0; border: none; outline: none; background: transparent; color: #fff; font-size: 0.92rem; }
.lib-search input:focus { outline: none; }
.lib-filters { gap: 6px; margin: 12px 0 14px; }
.lib-filters[hidden] { display: none; }
.lib-filter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: none;
  border-radius: 99px;
  background: #1f1e1c;
  box-shadow: none;
  color: #c3c2c1;
  font-size: 0.8rem;
  font-weight: 700;
}
.lib-filter span { padding: 0 6px; border-radius: 99px; background: #ffffff14; color: #8b8987; font-size: 0.7rem; }
.lib-filter:hover { background: #2b2926; color: #fff; }
.lib-filter.on { background: var(--accent); color: #fff; box-shadow: 0 3px 0 var(--accent-dark); }
.lib-filter.on span { background: #00000030; color: #fff; }
.lib-filter:active { transform: none; }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(178px, 1fr)); gap: 12px; overflow-y: auto; padding: 2px 2px 8px; }
.lib-grid > .empty { grid-column: 1 / -1; }
.lib-card { gap: 10px; padding: 10px; border: 1px solid transparent; border-radius: 12px; background: #1f1e1c; box-shadow: none; font-weight: 400; }
.lib-card:hover { border-color: #81b64c99; background: #262421; transform: translateY(-2px); }
.lib-card:active { transform: none; box-shadow: none; }
.lib-card-meta { gap: 3px; }
.lib-card-meta .lib-tag { align-self: flex-start; margin-bottom: 2px; }
.lib-card-meta b { color: #fff; font-size: 0.92rem; }
.lib-card-moves { color: #8b8987; font-size: 0.72rem; }
.lib-tag { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 0.66rem; font-weight: 800; letter-spacing: 0.3px; }
.lib-tag.closed { background: #c77dff26; color: #d6a6ff; }
.lib-tag.indian { background: #4fd1c526; color: #7fe3da; }
.lib-tag.flank { background: #ffffff14; color: #d6d4cf; }

.lib-back { align-self: flex-start; padding: 6px 10px 6px 4px; color: #c3c2c1; font-weight: 700; }
button.lib-back:hover { color: #fff; background: #ffffff0d; }
.lib-detail { display: flex; flex-direction: column; overflow-y: auto; }
.lib-detail[hidden] { display: none; }
.lib-detail-body { grid-template-columns: minmax(220px, 340px) 1fr; gap: 22px; margin-top: 8px; }
.lib-board-col { display: flex; flex-direction: column; gap: 10px; }
.lib-board { border-radius: 8px; }
.lib-step { display: grid; grid-template-columns: auto auto 1fr auto auto; align-items: center; gap: 6px; }
.lib-step[hidden] { display: none; }
.lib-step button { padding: 7px 10px; border-radius: 8px; background: #1f1e1c; box-shadow: none; color: #c3c2c1; font-size: 0.8rem; }
.lib-step button:hover:not(:disabled) { background: #3c3a37; color: #fff; }
.lib-step button:disabled { opacity: 0.35; }
.lib-step span { color: #8b8987; font-size: 0.78rem; font-weight: 700; text-align: center; }
.lib-info { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.lib-info .lib-tag { align-self: flex-start; }
.lib-info h3 { margin: 4px 0 0; color: #fff; font-size: 1.5rem; font-weight: 800; line-height: 1.2; }
.lib-name-en { margin: 0; color: #8b8987; font-size: 0.88rem; }
.lib-moves {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin: 8px 0 4px;
  padding: 10px;
  border-radius: 10px;
  background: #1f1e1c;
  color: #c3c2c1;
  font: 600 0.88rem/1.4 var(--font);
}
.lib-no { margin-left: 4px; color: #6f6d6a; font-size: 0.8rem; }
.lib-no:first-child { margin-left: 0; }
.lib-mv { padding: 3px 7px; border: none; border-radius: 6px; background: transparent; box-shadow: none; color: #e0dfde; font-size: 0.86rem; font-weight: 700; }
.lib-mv:hover { background: #3c3a37; }
.lib-mv.on { background: #4b4845; color: #fff; box-shadow: inset 0 -2px 0 var(--accent); }
.lib-mv:active { transform: none; }
.lib-turn { display: inline-block; width: 12px; height: 12px; margin-right: 8px; border-radius: 50%; background: #f4f3ef; vertical-align: -1px; }
.lib-turn.b { background: #111; box-shadow: 0 0 0 2px #ffffff40; }
.lib-desc { margin: 4px 0 0; color: #d6d4cf; font-size: 0.92rem; line-height: 1.6; }
.lib-detail-actions { gap: 10px; margin-top: 12px; }
.lib-detail-actions button { display: inline-flex; align-items: center; gap: 8px; padding: 11px 16px; }
.lib-hint { margin: 2px 0 0; color: #6f6d6a; font-size: 0.75rem; }
@media (max-width: 640px) {
  .lib-detail-body { grid-template-columns: 1fr; }
  .lib-board-col { max-width: 320px; width: 100%; margin: 0 auto; }
  .lib-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .lib-info h3 { font-size: 1.25rem; }
  .lib-detail-actions button { flex: 1; justify-content: center; }
}

/* ---------- Câu đố ---------- */
.puzzle-box { width: min(100%, 880px); max-height: min(92vh, 900px); }
.puzzle-list { display: block; padding-right: 2px; }
.pz-hero { display: grid; grid-template-columns: minmax(0, 1fr) 200px; gap: 14px; }
.pz-daily {
  position: relative;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 18px;
  overflow: hidden;
  border: 1px solid #f5c03d55;
  border-radius: 14px;
  background:
    radial-gradient(ellipse 70% 120% at 0% 0%, #f5c03d2a, transparent 60%),
    radial-gradient(ellipse 50% 80% at 100% 100%, #81b64c1a, transparent 70%),
    #1f1e1c;
  box-shadow: none;
  font-weight: 400;
  text-align: left;
}
.pz-daily::after {
  content: "";
  position: absolute;
  inset: 0 0 0 auto;
  width: 40%;
  pointer-events: none;
  background: repeating-conic-gradient(#ffffff 0 25%, transparent 0 50%) 0 0 / 32px 32px;
  opacity: 0.03;
  mask-image: linear-gradient(90deg, transparent, #000);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000);
}
.pz-daily:hover { border-color: #f5c03daa; }
.pz-daily:hover .pz-go { filter: brightness(1.1); }
.pz-daily:active { transform: none; box-shadow: none; }
.pz-daily-board { flex: none; width: 176px; }
.pz-daily-main { position: relative; z-index: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.pz-ribbon { display: inline-flex; align-items: center; gap: 6px; align-self: flex-start; padding: 4px 10px; border-radius: 99px; background: #f5c03d26; color: #f8d27a; font-size: 0.72rem; font-weight: 800; letter-spacing: 0.4px; text-transform: uppercase; }
.pz-ribbon .ic { width: 14px; height: 14px; fill: currentColor; }
.pz-daily-main b { color: #fff; font-size: 1.45rem; font-weight: 800; line-height: 1.15; }
.pz-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.pz-chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 99px; background: #ffffff10; color: #d6d4cf; font-size: 0.74rem; font-weight: 700; }
.pz-daily-theme { color: #8b8987; font-size: 0.82rem; }
.pz-go { align-self: flex-start; margin-top: 6px; padding: 10px 18px; border-radius: 10px; background: var(--accent); box-shadow: 0 4px 0 var(--accent-dark); color: #fff; font-weight: 800; font-size: 0.92rem; }
.pz-daily.done .pz-go { background: #81b64c26; box-shadow: none; color: #a6d36b; }
.pz-side { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: #f4f3ef; box-shadow: 0 0 0 1.5px #00000066; vertical-align: -1px; }
.pz-side.b { background: #111; box-shadow: 0 0 0 1.5px #ffffff55; }

.pz-progress-card { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 16px 12px; border-radius: 14px; background: #1f1e1c; }
.pz-progress-card p { margin: 0; color: #8b8987; font-size: 0.78rem; }
.pz-ring-wrap { position: relative; width: 96px; height: 96px; }
.pz-ring { width: 100%; height: 100%; }
.pz-ring .track { fill: none; stroke: #ffffff12; stroke-width: 8; }
.pz-ring .fill { fill: none; stroke: var(--accent); stroke-width: 8; stroke-linecap: round; }
.pz-ring-wrap > span { position: absolute; inset: 0; display: grid; place-content: center; grid-auto-flow: column; align-items: baseline; }
.pz-ring-wrap b { color: #fff; font-size: 1.6rem; font-weight: 800; }
.pz-ring-wrap small { color: #8b8987; font-size: 0.85rem; font-weight: 700; }
.pz-mini-stats { display: flex; flex-direction: column; gap: 6px; width: 100%; margin-top: 8px; }
.pz-mini-stats > span { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 8px; background: #262421; color: #8b8987; font-size: 0.78rem; }
.pz-mini-stats b { color: #fff; font-size: 0.95rem; }
.pz-mini-stats .flame { width: 16px; height: 16px; color: #ff9600; fill: #ff960033; }
.pz-star { color: var(--gold); font-size: 1rem; line-height: 1; }

.pz-tabs { display: flex; gap: 4px; margin: 16px 0 6px; padding: 4px; overflow-x: auto; border-radius: 12px; background: #1f1e1c; scrollbar-width: none; }
.pz-tab { flex: 1; padding: 8px 12px; border: none; border-radius: 8px; background: transparent; box-shadow: none; color: #8b8987; font-size: 0.82rem; font-weight: 700; white-space: nowrap; }
.pz-tab:hover { color: #fff; background: #ffffff0a; }
.pz-tab.on { background: #3c3a37; color: #fff; box-shadow: inset 0 -2px 0 var(--accent); }
.pz-tab:active { transform: none; }

.pz-section { margin-top: 16px; }
.pz-section header { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.pz-sec-ic { display: grid; place-items: center; width: 36px; height: 36px; flex: none; border-radius: 10px; }
.pz-sec-ic .ic { width: 20px; height: 20px; }
.pz-sec-ic.m1 { background: #f5b83d1f; color: var(--gold); }
.pz-sec-ic.m2 { background: #e2533f1f; color: #ff8f7e; }
.pz-sec-ic.tac { background: #5aa9ff1f; color: #8ec5ff; }
.pz-sec-title { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.pz-sec-title b { color: #fff; font-size: 1rem; }
.pz-sec-title small { color: #8b8987; font-size: 0.76rem; }
.pz-sec-count { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; color: #8b8987; font-size: 0.78rem; font-weight: 700; }
.pz-sec-count b { color: #fff; }
.pz-sec-bar { display: block; width: 72px; height: 5px; border-radius: 99px; background: #ffffff12; overflow: hidden; }
.pz-sec-bar i { display: block; height: 100%; background: var(--accent); }
.pz-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin: 0; }
.pz-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0;
  border: none;
  border-radius: 12px;
  background: transparent;
  box-shadow: none;
  font-weight: 400;
  text-align: left;
}
.pz-card:hover { background: transparent; }
.pz-card:active { transform: none; box-shadow: none; }
.pz-thumb { position: relative; display: block; transition: transform 0.18s; }
.pz-card:hover .pz-thumb { transform: translateY(-3px); }
.pz-card:hover .lib-frame { border-color: #81b64c; }
.pz-thumb .pz-lv { position: absolute; left: 8px; top: 8px; padding: 2px 8px; border-radius: 99px; box-shadow: 0 2px 6px #0008; font-size: 0.66rem; font-weight: 800; }
.pz-lv.lv-1 { background: #3d5a26; color: #c9ef9a; }
.pz-lv.lv-2 { background: #6b5014; color: #ffe08a; }
.pz-lv.lv-3 { background: #6e2720; color: #ffb3a7; }
.pz-chips .pz-lv { padding: 3px 9px; border-radius: 99px; font-size: 0.74rem; font-weight: 800; }
.pz-check { position: absolute; right: -6px; top: -6px; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px #262421; color: #fff; font-size: 0.82rem; font-weight: 800; }
.pz-card.solved .pz-board { filter: saturate(0.55) brightness(0.8) !important; }
.pz-play {
  position: absolute;
  inset: 4px;
  display: grid;
  place-items: center;
  border-radius: 4px;
  background: #00000055;
  opacity: 0;
  transition: opacity 0.15s;
}
.pz-play .ic { width: 44px; height: 44px; padding: 12px; box-sizing: border-box; border-radius: 50%; background: var(--accent); color: #fff; box-shadow: 0 6px 16px #0009; }
.pz-card:hover .pz-play, .pz-card:focus-visible .pz-play { opacity: 1; }
.pz-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; padding: 0 2px; }
.pz-meta b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #fff; font-size: 0.9rem; }
.pz-meta small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #c3c2c1; font-size: 0.74rem; }
.pz-meta small .pz-side { margin-right: 4px; }
.pz-theme { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #8b8987; font-size: 0.72rem; }
.pz-all-done { margin: 30px 0; color: #c3c2c1; text-align: center; font-size: 1rem; }
@media (max-width: 680px) {
  .pz-hero { grid-template-columns: 1fr; }
  .pz-daily { flex-direction: column; align-items: stretch; gap: 14px; padding: 14px; }
  .pz-daily-board { width: 100%; max-width: 240px; margin: 0 auto; }
  .pz-daily-main b { font-size: 1.25rem; }
  .pz-progress-card { flex-direction: row; flex-wrap: wrap; gap: 10px 14px; }
  .pz-ring-wrap { width: 72px; height: 72px; }
  .pz-ring-wrap b { font-size: 1.2rem; }
  .pz-progress-card p { display: none; }
  .pz-mini-stats { flex: 1; width: auto; margin-top: 0; }
  .pz-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
}

.lib-search { flex-direction: row; }
.lib-grid[hidden] { display: none; }
.pz-sec-count > span:first-child { white-space: nowrap; }
.pz-meta .pz-theme { grid-row: auto; align-self: stretch; font-weight: 500; }

/* =========================================================
   Giao diện v14: bảng Đấu máy / Online, Sổ luyện lỗi
   ========================================================= */

/* Nút chia đoạn (segmented) dùng chung */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; border-radius: 10px; background: #1f1e1c; }
.seg button {
  display: flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 8px; border: none; border-radius: 7px; background: transparent; box-shadow: none;
  color: #8b8987; font-size: 0.86rem; font-weight: 700; white-space: nowrap;
}
.seg button:hover { color: #fff; background: #ffffff0a; }
.seg button.on { background: #3c3a37; color: #fff; box-shadow: 0 2px 0 #00000055; }
.seg button:active { transform: none; }
.seg button .ic { width: 17px; height: 17px; }
.seg.small button { padding: 7px 6px; font-size: 0.8rem; }
.pz-side.r { background: linear-gradient(90deg, #f4f3ef 50%, #111 50%); box-shadow: 0 0 0 1.5px #ffffff40; }

.setup { display: flex; flex-direction: column; gap: 12px; }
.setup[hidden], .live-card[hidden], .bot-cards[hidden], .setup-row[hidden] { display: none; }
.setup-hidden { display: none; }
.setup-row { display: flex; flex-direction: column; gap: 6px; }
.setup-label { color: #8b8987; font-size: 0.72rem; font-weight: 800; letter-spacing: 0.5px; text-transform: uppercase; }

.bot-cards { display: flex; flex-direction: column; gap: 6px; }
.bot-card {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 12px;
  border: 1px solid transparent; border-radius: 10px; background: #1f1e1c; box-shadow: none;
  font-weight: 400; text-align: left;
}
.bot-card:hover { background: #2b2926; }
.bot-card.on { border-color: var(--accent); background: linear-gradient(90deg, #81b64c1f, #1f1e1c 70%); }
.bot-card:active { transform: none; }
.bot-av { display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 10px; }
.bot-av img { width: 30px; height: 30px; filter: drop-shadow(0 1px 1px #0008); }
.bot-av.lv1 { background: linear-gradient(135deg, #a6d36b, #5d8a32); }
.bot-av.lv2 { background: linear-gradient(135deg, #f8d27a, #c48a1a); }
.bot-av.lv3 { background: linear-gradient(135deg, #ff8f7e, #a3322a); }
.bot-av.lv4 { background: linear-gradient(135deg, #8fb8ff, #3a2a9e); }
.bot-meta { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.bot-meta b { color: #fff; font-size: 0.95rem; }
.bot-meta small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #8b8987; font-size: 0.74rem; }
.bot-elo { padding: 3px 9px; border-radius: 99px; background: #ffffff10; color: #e0dfde; font-size: 0.78rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.bot-card.on .bot-elo { background: var(--accent); color: #fff; }

.tc-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.tc-chip {
  display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 7px 4px;
  border: 1px solid transparent; border-radius: 9px; background: #1f1e1c; box-shadow: none; font-weight: 400;
}
.tc-chip b { color: #fff; font-size: 1rem; line-height: 1.1; }
.tc-chip small { color: #8b8987; font-size: 0.66rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; }
.tc-chip:hover { background: #2b2926; }
.tc-chip.on { border-color: var(--accent); background: #81b64c1f; }
.tc-chip:active { transform: none; }

.live-card { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 10px; background: linear-gradient(90deg, #81b64c1a, #1f1e1c 60%); box-shadow: inset 3px 0 0 var(--accent); }
.live-card .avatar { width: 42px; height: 42px; border-radius: 10px; }
.live-main { display: flex; flex-direction: column; min-width: 0; }
.live-main b { color: #fff; font-size: 0.95rem; }
.live-main small { color: #8b8987; font-size: 0.78rem; }

/* ---------- Online ---------- */
.ol-hero {
  position: relative; display: flex; flex-direction: column; gap: 8px; padding: 16px; overflow: hidden;
  border-radius: 12px; background: radial-gradient(ellipse 90% 120% at 100% 0%, #81b64c30, transparent 60%), #1f1e1c;
  box-shadow: inset 0 0 0 1px #81b64c33;
}
.ol-hero::after {
  content: ""; position: absolute; right: -24px; top: -24px; width: 120px; height: 120px; pointer-events: none;
  background: url("pieces/wN.svg") center / contain no-repeat; opacity: 0.07; transform: rotate(-12deg);
}
.ol-hero-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ol-live { display: inline-flex; align-items: center; gap: 6px; color: #a6d36b; font-size: 0.72rem; font-weight: 800; letter-spacing: 0.6px; text-transform: uppercase; }
.ol-live i { position: relative; width: 8px; height: 8px; border-radius: 50%; background: #81b64c; }
@keyframes livePulse { 70% { box-shadow: 0 0 0 8px #81b64c00; } 100% { box-shadow: 0 0 0 0 #81b64c00; } }
.ol-me { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 4px; border-radius: 99px; background: #ffffff0d; font-size: 0.78rem; font-weight: 700; }
.ol-me .rb-medal { width: 20px; height: 20px; }
.ol-me .rb-medal svg { width: 100%; height: 100%; display: block; }
.ol-me b { color: #fff; }
.ol-title { color: #fff; font-size: 1.3rem; font-weight: 800; }
.ol-sub { margin: 0; color: #8b8987; font-size: 0.8rem; line-height: 1.4; }
.ol-hero button.big { margin-top: 4px; }
.ol-card { display: flex; flex-direction: column; gap: 10px; padding: 14px; border-radius: 12px; background: #1f1e1c; }
.ol-card .seg, .ol-card input { background: #262421; }
.ol-card-head { display: flex; align-items: center; gap: 8px; color: #fff; }
.ol-card-head .ic { color: var(--gold); }
.ol-card button.big { font-size: 1rem; padding: 12px; }
#onlineLobby .divider { margin: 0; }
.ol-room { align-items: stretch; text-align: center; }
.ol-room .room-code { margin: 0; padding: 14px; border: 2px dashed #81b64c88; border-radius: 10px; background: #262421; color: #fff; font-size: 2rem; letter-spacing: 0.3em; }
.ol-room p { margin: 0; font-size: 0.8rem; }
#onlineWaiting .buttons button { display: flex; align-items: center; justify-content: center; gap: 6px; }

/* Đang tìm trận: radar */
.radar { position: relative; width: 150px; height: 150px; margin: 6px auto 0; }
.radar span { position: absolute; inset: 0; border-radius: 50%; border: 2px solid #81b64c; opacity: 0; animation: radar 2.4s linear infinite; }
.radar span:nth-child(2) { animation-delay: 0.8s; }
.radar span:nth-child(3) { animation-delay: 1.6s; }
.radar img { position: absolute; inset: 0; margin: auto; width: 64px; height: 64px; padding: 12px; box-sizing: content-box; border-radius: 50%; background: #1f1e1c; box-shadow: 0 0 0 3px #81b64c, 0 8px 24px #0008; animation: bob 2s ease-in-out infinite; }
@keyframes radar { 0% { transform: scale(0.45); opacity: 0.9; } 100% { transform: scale(1.15); opacity: 0; } }
@keyframes bob { 50% { transform: translateY(-4px); } }
#onlineSearching .searching { flex-direction: column; gap: 2px; padding: 4px; background: none; }
#onlineSearching .search-time { margin: 0; font-size: 1.4rem; font-weight: 800; }

/* Chat dạng bong bóng */
.chat-log { display: flex; flex-direction: column; gap: 6px; min-height: 110px; max-height: 210px; padding: 10px; }
.chat-log p { max-width: 85%; margin: 0; padding: 7px 11px; border-radius: 14px; line-height: 1.35; font-size: 0.86rem; }
.chat-log p b { display: block; margin-bottom: 1px; font-size: 0.68rem; opacity: 0.75; }
.chat-log p.opp { align-self: flex-start; border-bottom-left-radius: 4px; background: #3c3a37; color: #fff; }
.chat-log p.me { align-self: flex-end; border-bottom-right-radius: 4px; background: #4b6b2f; color: #fff; }
.chat-log p.me b { display: none; }
.chat-log p.system { align-self: center; max-width: 100%; padding: 2px 8px; background: none; color: #8b8987; font-size: 0.74rem; font-style: normal; text-align: center; }
.chat-form input { border-radius: 99px; padding-left: 14px; }
.chat-form button { border-radius: 99px; background: var(--accent); box-shadow: none; }

/* Huy hiệu số trên tab Câu đố */
.nav-badge { margin-left: auto; min-width: 20px; padding: 1px 6px; border-radius: 99px; background: #e2533f; color: #fff; font-size: 0.7rem; font-weight: 800; text-align: center; line-height: 1.5; }
.nav-badge[hidden] { display: none; }
@media (max-width: 999px) { .nav-badge { margin-left: 2px; } }

/* ---------- Sổ luyện lỗi ---------- */
.coach-card {
  display: flex; flex-direction: column; gap: 14px; margin-bottom: 14px; padding: 16px; border-radius: 14px;
  background: radial-gradient(ellipse 70% 140% at 0% 0%, #5aa9ff26, transparent 60%), #1f1e1c;
  box-shadow: inset 0 0 0 1px #5aa9ff40;
}
.coach-card.empty { flex-direction: row; align-items: flex-start; }
.coach-card.empty p { margin: 4px 0 0; color: #8b8987; font-size: 0.84rem; line-height: 1.5; }
.coach-card.empty b { color: #fff; }
.coach-main { display: flex; align-items: center; gap: 14px; }
.coach-ic { display: grid; place-items: center; width: 44px; height: 44px; flex: none; border-radius: 12px; background: #5aa9ff26; color: #8ec5ff; }
.coach-ic .ic { width: 24px; height: 24px; }
.coach-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.coach-text small { color: #8ec5ff; font-size: 0.7rem; font-weight: 800; letter-spacing: 0.5px; text-transform: uppercase; }
.coach-text b { color: #fff; font-size: 1.15rem; }
.coach-text p { margin: 0; color: #8b8987; font-size: 0.8rem; }
.coach-main .primary { flex: none; padding: 11px 16px; }
.coach-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.coach-mini { display: flex; align-items: center; gap: 10px; padding: 8px; border: 1px solid transparent; border-radius: 10px; background: #262421; box-shadow: none; font-weight: 400; text-align: left; }
.coach-mini:hover { border-color: #5aa9ff88; }
.coach-mini:active { transform: none; }
.coach-mini .pz-board { width: 64px; flex: none; border-width: 2px; }
.coach-mini-meta { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.coach-mini-meta b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #fff; font-size: 0.84rem; }
.coach-mini-meta small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #8b8987; font-size: 0.72rem; }
.k-blunder { color: #ff8f7e !important; }
.k-mistake { color: #f8b26a !important; }
.k-inaccuracy { color: #f5d76e !important; }
.puzzle-banner-panel.coach { border-color: #5aa9ff66; }
@media (max-width: 680px) {
  .coach-main { flex-wrap: wrap; }
  .coach-main .primary { width: 100%; }
}

/* Kết quả ván: báo cáo của huấn luyện viên */
.result-coach[hidden] { display: none; }
.result-coach { display: flex; flex-direction: column; gap: 10px; margin: 0 0 12px; padding: 12px 14px; border-radius: 12px; background: #1f1e1c; text-align: left; }
.rc-loading { display: flex; align-items: center; gap: 10px; color: #c3c2c1; font-size: 0.84rem; }
.rc-loading b { margin-left: auto; color: #fff; }
.rc-row { display: flex; align-items: center; gap: 14px; }
.rc-ring { position: relative; width: 64px; height: 64px; flex: none; }
.rc-ring svg { width: 100%; height: 100%; }
.rc-ring .track { fill: none; stroke: #ffffff14; stroke-width: 7; }
.rc-ring .fill { fill: none; stroke-width: 7; stroke-linecap: round; }
.rc-ring.great .fill { stroke: #81b64c; }
.rc-ring.good .fill { stroke: #a6d36b; }
.rc-ring.ok .fill { stroke: #f5b83d; }
.rc-ring.low .fill { stroke: #e2533f; }
.rc-ring b { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: 1.15rem; }
.rc-main { display: flex; flex-direction: column; gap: 6px; }
.rc-main > b { color: #fff; font-size: 1rem; }
.rc-counts { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 0.8rem; font-weight: 700; }
.rc-counts i { display: inline-block; width: 8px; height: 8px; margin-right: 5px; border-radius: 50%; background: currentColor; }
.rc-note { margin: 0; color: #c3c2c1; font-size: 0.84rem; line-height: 1.45; }
.rc-note b { color: #a6d36b; }
.rc-train { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 10px; border-radius: 9px; background: #5aa9ff26; box-shadow: none; color: #cfe5ff; font-size: 0.86rem; }
.rc-train:hover { background: #5aa9ff40; }

/* ---------- Ngôn ngữ ---------- */
.lang-btn { gap: 8px; }
.lang-btn span { font-weight: 700; }
.auth-lang { display: flex; justify-content: center; gap: 4px; margin: -6px auto 12px; padding: 3px; width: fit-content; border-radius: 99px; background: #1f1e1c; }
.auth-lang button { padding: 5px 12px; border: none; border-radius: 99px; background: transparent; box-shadow: none; color: #8b8987; font-size: 0.78rem; font-weight: 700; }
.auth-lang button.on { background: #3c3a37; color: #fff; }
.auth-lang button:active { transform: none; }
.lang-row { display: flex; flex-direction: row; align-items: center; justify-content: space-between; gap: 10px; margin: 14px 0 0; text-transform: none; letter-spacing: 0; color: #e0dfde; font-size: 0.88rem; font-weight: 500; }
.lang-row select { width: auto; min-width: 140px; }
.view-row { flex-wrap: wrap; }
.view-row .seg { flex: 1; max-width: 300px; min-width: 230px; }
.lang-note { display: none; margin: 0; padding: 10px 12px; border-radius: 10px; background: #5aa9ff1f; color: #cfe5ff; font-size: 0.8rem; line-height: 1.45; }
html[data-lang="en"] .lang-note { display: block; }
html[data-lang="en"] .lib-card-meta small, html[data-lang="en"] #libNameEn, html[data-lang="en"] .opening-name small { display: none; }
html[data-lang="en"] .contest-item.joined .ci-main b::after { content: " · Registered ✓"; }
@media (max-width: 999px) { .lang-btn span { display: none; } }
.coach-card.empty { text-align: left; }

/* Nút chọn thời gian: icon theo loại (Bullet / Blitz / Rapid / Không giới hạn) */
.tc-chip { --tc: #8b8987; gap: 3px; padding: 9px 4px 8px; }
.tc-chip.free { --tc: #5aa9ff; }
.tc-chip.bullet { --tc: #f29b38; }
.tc-chip.blitz { --tc: #f5c03d; }
.tc-chip.rapid { --tc: #81b64c; }
.tc-top { display: inline-flex; align-items: center; gap: 6px; }
.tc-ic { width: 18px; height: 18px; color: var(--tc); fill: var(--tc); fill-opacity: 0.18; transition: transform 0.15s; }
.tc-chip:hover .tc-ic { transform: scale(1.12); }
.tc-chip small { color: color-mix(in srgb, var(--tc) 55%, #8b8987); }
.tc-chip.on { border-color: var(--tc); background: color-mix(in srgb, var(--tc) 14%, #1f1e1c); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--tc) 35%, transparent); }
.tc-chip.on small { color: var(--tc); }
.tc-chip.on .tc-ic { fill-opacity: 0.35; }
.tc-chip:focus-visible { outline-offset: 1px; }

/* =========================================================
   Giao diện v15: Contest, Nhật ký, Xếp hạng, Quản trị
   ========================================================= */

/* ---------- Thanh thông báo toàn web ---------- */
.announce-bar[hidden] { display: none; }
.announce-bar {
  --an: #5aa9ff;
  position: sticky; top: 0; z-index: 16;
  display: flex; align-items: center; gap: 12px; padding: 9px 16px;
  background: linear-gradient(90deg, color-mix(in srgb, var(--an) 22%, #262421), #262421 80%);
  border-bottom: 1px solid color-mix(in srgb, var(--an) 45%, transparent);
  color: #fff; font-size: 0.9rem; font-weight: 600; line-height: 1.4;
}
.announce-bar .ic { flex: none; color: var(--an); }
.announce-bar span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.announce-bar.warn { --an: #f29b38; }
.announce-bar.event { --an: #81b64c; }
.announce-bar .icon-btn { flex: none; padding: 4px; color: #c3c2c1; }
.announce-bar.preview { position: static; border-radius: 10px; border: 1px solid color-mix(in srgb, var(--an) 45%, transparent); }

/* ---------- Nhật ký ---------- */
.hist-box { width: min(100%, 760px); max-height: min(92vh, 900px); display: flex; flex-direction: column; gap: 10px; }
.hist-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.hs-tile { display: flex; flex-direction: column; gap: 1px; padding: 10px 12px; border-radius: 10px; background: #1f1e1c; }
.hs-tile b { color: #fff; font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.hs-tile b.up { color: #a6d36b; }
.hs-tile b.down { color: #ff8f7e; }
.hs-tile span { color: #8b8987; font-size: 0.72rem; }
.hs-bar { grid-column: 1 / -1; display: flex; gap: 2px; height: 6px; border-radius: 99px; overflow: hidden; background: #1f1e1c; }
.hs-bar .win { background: #81b64c; } .hs-bar .draw { background: #8b8987; } .hs-bar .loss { background: #e2533f; }
.hist-tools { display: flex; gap: 8px; }
.hist-tools .lib-search { flex: 1; margin: 0; }
.hist-tools select { width: auto; min-width: 140px; }
.hist-filters { margin: 0; }
.hist-list { display: flex; flex-direction: column; gap: 6px; margin: 0; overflow-y: auto; min-height: 120px; }
.hist-day { margin: 8px 2px 0; color: #8b8987; font-size: 0.72rem; font-weight: 800; letter-spacing: 0.5px; text-transform: uppercase; }
.hist-row {
  display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; align-items: center; gap: 12px;
  padding: 8px 10px; border: none; border-radius: 10px; background: #1f1e1c; box-shadow: inset 3px 0 0 #4b4845;
}
.hist-row.win { box-shadow: inset 3px 0 0 #81b64c; }
.hist-row.loss { box-shadow: inset 3px 0 0 #e2533f; }
.hist-row.draw { box-shadow: inset 3px 0 0 #8b8987; }
.hist-row:hover { background: #262421; }
.hist-board { width: 56px; border-width: 2px; }
.hist-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.hist-title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.hist-title b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #fff; font-size: 0.92rem; }
.hist-res { flex: none; padding: 1px 8px; border-radius: 6px; background: #ffffff10; font-size: 0.72rem; }
.hist-res.win { background: #81b64c2e; } .hist-res.loss { background: #e2533f2e; } .hist-res.draw { background: #f5b83d1f; }
.hist-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #8b8987; font-size: 0.76rem; }
.hist-chips { display: flex; gap: 6px; }
.hist-chips:empty { display: none; }
.hist-chip { padding: 1px 7px; border-radius: 99px; background: #ffffff10; color: #c3c2c1; font-size: 0.7rem; font-weight: 800; }
.hist-chip.up { background: #81b64c26; color: #a6d36b; } .hist-chip.down { background: #e2533f26; color: #ff8f7e; }
.hist-chip.acc { background: #5aa9ff26; color: #8ec5ff; }
.hist-actions { display: flex; gap: 4px; }
.hist-actions button { display: inline-flex; align-items: center; gap: 5px; padding: 7px 10px; border-radius: 8px; background: #2b2926; box-shadow: none; color: #e0dfde; font-size: 0.78rem; }
.hist-actions button:hover { background: #3c3a37; color: #fff; }
.hist-actions button:active { transform: none; }
.hist-actions button.icon { padding: 7px; color: #8b8987; }
.hist-actions .hist-load { background: #81b64c26; color: #b5e37a; }
.hist-actions .hist-an { background: #5aa9ff1f; color: #8ec5ff; }
.hist-actions .hist-del:hover { color: #ff8f7e; }
.hist-actions .ic { width: 16px; height: 16px; }
.hist-empty { margin: 20px 0; color: #8b8987; text-align: center; line-height: 1.6; }
.hist-foot { display: flex; justify-content: space-between; gap: 8px; }
.hist-foot button { display: inline-flex; align-items: center; gap: 6px; font-size: 0.82rem; padding: 8px 12px; }
@media (max-width: 640px) {
  .hist-summary { grid-template-columns: repeat(2, 1fr); }
  .hist-row { grid-template-columns: 44px minmax(0, 1fr); }
  .hist-board { width: 44px; }
  .hist-actions { grid-column: 1 / -1; justify-content: flex-end; }
  .hist-tools select { min-width: 0; }
}

/* ---------- Bảng xếp hạng ---------- */
.lb-box { width: min(100%, 820px); max-height: min(92vh, 900px); display: flex; flex-direction: column; gap: 10px; }
.lb-box .rank-head { margin-bottom: 0; }
.lb-tools { display: flex; gap: 10px; flex-wrap: wrap; }
.lb-tools .seg { flex: 1.3; min-width: 280px; }
.lb-tools .lib-search { flex: 1; min-width: 180px; margin: 0; }
.lb-podium { display: flex; justify-content: center; align-items: flex-end; gap: 8px; padding: 12px 8px 0; border-radius: 10px; background: radial-gradient(ellipse at 50% 100%, #f5c03d1a, transparent 70%), #1f1e1c; }
.lb-podium:empty { display: none; }
.lb-podium .podium-step small { color: #c3c2c1; }
.lb-me { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 10px; background: #81b64c1a; box-shadow: inset 3px 0 0 var(--accent); cursor: pointer; }
.lb-me[hidden] { display: none; }
.lb-me-pos { color: #a6d36b; font-size: 1.1rem; font-weight: 800; min-width: 2.4em; }
.lb-me-main { display: flex; flex-direction: column; }
.lb-me-main b { color: #fff; font-size: 0.88rem; }
.lb-me-main small { color: #8b8987; font-size: 0.76rem; }
.lb-box .rank-table { display: flex; flex-direction: column; min-height: 0; }
#lbList { max-height: none; flex: 1; overflow-y: auto; }
.rank-row.medal-mode { grid-template-columns: 2.6em minmax(0, 1fr) 4.2em 4.2em 4.2em 3.6em; }
.mt-cell { display: inline-flex; align-items: center; gap: 4px; color: #fff; font-weight: 800; }
.mt-cell .medal { width: 18px; height: 22px; }
.mt-cell i { color: #4b4845; font-style: normal; }
.rank-elo.hot, .rank-elo2.hot { color: var(--gold); }
.rank-elo:not(.hot) { color: #e0dfde; }
@media (max-width: 700px) {
  .rank-row.medal-mode { grid-template-columns: 2.2em minmax(0, 1fr) 3.2em 3.2em 3.2em; }
  .rank-row.medal-mode > :nth-child(6) { display: none; }
  .lb-tools .seg { min-width: 100%; }
}

/* ---------- Bảng quản trị ---------- */
.admin-box { width: min(100%, 860px); max-height: min(92vh, 920px); }
.admin-pane { display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.admin-pane[hidden] { display: none; }
.admin-stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.as-tile { display: flex; flex-direction: column; gap: 1px; padding: 10px 12px; border-radius: 10px; background: #1f1e1c; }
.as-tile .ic { width: 16px; height: 16px; color: var(--gold); margin-bottom: 2px; }
.as-tile b { color: #fff; font-size: 1.25rem; }
.as-tile span { color: #8b8987; font-size: 0.72rem; }
.admin-tools { display: flex; gap: 8px; }
.admin-tools .lib-search { flex: 1; margin: 0; }
.admin-tools select { width: auto; }
.admin-tools button { display: inline-flex; align-items: center; gap: 6px; }
#adminFilters { margin: 0; }
#adminList { max-height: 46vh; }
.admin-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; padding: 8px 12px; }
.admin-who { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 0; border: none; background: transparent; box-shadow: none; font-weight: 400; text-align: left; }
.admin-who:hover { background: transparent; }
.admin-who:hover b { text-decoration: underline; }
.admin-who:active { transform: none; }
.admin-who .avatar { width: 36px; height: 36px; border-radius: 8px; }
.admin-name b { display: flex; align-items: center; gap: 6px; color: #fff; }
.admin-name b .role-badge { font-size: 0.62rem; }
.admin-mute-info { color: #ff8f7e !important; }
.admin-mute-info[hidden] { display: none; }
.admin-actions { display: flex; align-items: center; gap: 6px; }
.admin-actions button, .mute-form button { display: inline-flex; align-items: center; gap: 5px; padding: 6px 10px; border-radius: 8px; box-shadow: none; font-size: 0.78rem; }
.admin-actions .ic { width: 15px; height: 15px; }
.act-danger { background: transparent; border: 1px solid #e2533f77; color: #ff8f7e; }
.act-danger:hover { background: #e2533f22; }
.act-on { background: #81b64c2e; color: #b5e37a; }
.act-on:hover { background: #81b64c45; }
.act-plain { background: #2b2926; color: #c3c2c1; }
.mute-form { display: flex; gap: 6px; padding: 8px 12px 10px 58px; background: #e2533f0f; border-bottom: 1px solid #ffffff0a; }
.mute-form input { flex: 1; }
.mute-form select { width: auto; }
.ann-current { display: flex; flex-direction: column; gap: 6px; }
.ann-current p { margin: 0; }
#adminAnnounce textarea { width: 100%; padding: 10px; border: 1px solid #45423e; border-radius: 8px; background: #1f1e1c; color: #fff; font: inherit; resize: vertical; }
#adminAnnounce label { text-transform: none; letter-spacing: 0; }
#adminAnnounce .buttons button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
@media (max-width: 700px) {
  .admin-stats { grid-template-columns: repeat(3, 1fr); }
  .admin-row { grid-template-columns: 1fr; }
  .admin-actions { justify-content: flex-end; flex-wrap: wrap; }
  .mute-form { flex-wrap: wrap; padding-left: 12px; }
}

/* ---------- Contest ---------- */
.contest-box { width: min(100%, 720px); max-height: min(92vh, 920px); }
.contest-tabs { margin: 0; }
.contest-list { max-height: 56vh; gap: 6px; }
.contest-group { margin: 10px 2px 0; }
.contest-group.live { color: #a6d36b; }
.contest-item { position: relative; display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 12px; padding: 12px; overflow: hidden; }
.ci-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; background: #ffffff0d; color: #8b8987; }
.contest-item.live .ci-icon { background: #81b64c2e; color: #a6d36b; }
.contest-item.upcoming .ci-icon { background: #f5b83d1f; color: var(--gold); }
.contest-item.ended .ci-icon { background: #ffffff0d; color: #c3c2c1; }
.contest-item.ended { opacity: 1; }
.ci-main b { color: #fff; }
.ci-extra { display: inline-flex; align-items: center; gap: 5px; margin-top: 2px; color: #c3c2c1; font-size: 0.76rem; }
.ci-extra:empty { display: none; }
.ci-extra .medal { width: 15px; height: 18px; }
.contest-item.joined .ci-extra { color: #a6d36b; }
.contest-item.joined .ci-main b::after { content: none; }
.ci-side { display: flex; flex-direction: column; align-items: flex-end; justify-content: center; gap: 4px; }
.ci-count { padding: 3px 9px; border-radius: 99px; background: #ffffff10; color: #c3c2c1; font-size: 0.74rem; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.contest-item.live .ci-count { background: #81b64c33; color: #a6d36b; }
.contest-item.upcoming .ci-count { background: #f5b83d26; color: var(--gold); }
.ci-people { display: inline-flex; align-items: center; gap: 4px; color: #8b8987; font-size: 0.74rem; font-weight: 700; }
.ci-people .ic { width: 14px; height: 14px; }
.ci-prog { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: #ffffff0a; }
.ci-prog i { display: block; height: 100%; background: #81b64c; }
.cf-title { color: #fff; }

.cd-hero { position: relative; display: flex; flex-direction: column; gap: 6px; padding: 16px; border-radius: 12px; background: radial-gradient(ellipse 80% 140% at 0% 0%, var(--cdc, #ffffff10), transparent 60%), #1f1e1c; }
.cd-hero.live { --cdc: #81b64c2e; }
.cd-hero.upcoming { --cdc: #f5b83d24; }
.cd-hero.ended { --cdc: #c77dff1f; }
.cd-phase { align-self: flex-start; padding: 2px 10px; border-radius: 99px; background: #ffffff14; color: #c3c2c1; font-size: 0.7rem; font-weight: 800; letter-spacing: 0.4px; text-transform: uppercase; }
.cd-hero.live .cd-phase { background: #81b64c33; color: #a6d36b; }
.cd-hero.upcoming .cd-phase { background: #f5b83d26; color: var(--gold); }
.cd-hero h3 { margin: 0; color: #fff; font-size: 1.4rem; }
.cd-hero p { margin: 0; }
.cd-hero .contest-meta { margin-top: 4px; background: #00000030; }
.cd-progress { height: 5px; border-radius: 99px; background: #ffffff10; overflow: hidden; }
.cd-progress i { display: block; height: 100%; background: var(--accent); transition: width 1s linear; }
.cd-hero.upcoming .cd-progress { display: none; }
.cd-tools { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.cd-tools button { display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px; border-radius: 8px; background: #ffffff0d; box-shadow: none; color: #e0dfde; font-size: 0.78rem; }
.cd-tools button:hover { background: #ffffff1a; }
.cd-tools button[hidden] { display: none; }
.cd-tools .ic { width: 15px; height: 15px; }
.cd-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.cd-stats:empty { display: none; }
.cd-stat { display: flex; flex-direction: column; gap: 1px; min-width: 0; padding: 10px 12px; border-radius: 10px; background: #1f1e1c; }
.cd-stat .ic { width: 16px; height: 16px; color: var(--gold); }
.cd-stat b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #fff; font-size: 1.05rem; }
.cd-stat span { color: #8b8987; font-size: 0.72rem; }
.cd-mine { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 14px; padding: 10px 14px; border-radius: 10px; background: #81b64c1a; box-shadow: inset 3px 0 0 var(--accent); }
.cd-mine[hidden] { display: none; }
.cd-mine-place { color: #a6d36b; font-size: 1.2rem; font-weight: 800; }
.cd-mine-place .medal { width: 28px; height: 34px; }
.cd-mine-main { display: flex; flex-direction: column; }
.cd-mine-main b { color: #fff; font-size: 0.9rem; }
.cd-mine-main small { color: #8b8987; font-size: 0.76rem; }
.cd-mine-pts { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.1; }
.cd-mine-pts b { color: var(--gold); font-size: 1.2rem; }
.cd-mine-pts small { color: #8b8987; font-size: 0.68rem; }
@media (max-width: 640px) {
  .cd-stats { grid-template-columns: repeat(2, 1fr); }
  .cd-mine { grid-template-columns: auto minmax(0, 1fr) auto; }
  .cd-mine .wdl { display: none; }
}
.admin-box > *, .admin-pane > * { flex-shrink: 0; }
@media (max-width: 700px) {
  .admin-tools { flex-wrap: wrap; }
  .admin-tools .lib-search { flex: 1 1 100%; }
  .admin-tools select { flex: 1; }
  #adminList { max-height: none; }
  .hist-tools { flex-wrap: wrap; }
  .hist-tools .lib-search { flex: 1 1 100%; }
  .hist-tools select { flex: 1; }
}

/* =========================================================
   v25: Trang chủ + ô chọn (select) kiểu mới
   ========================================================= */

/* ---------- Ô chọn: mũi tên riêng, nền tối, bo góc ---------- */
select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 34px;
  background-color: #1f1e1b;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23b9b6ae' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  background-size: 14px;
  font-weight: 600;
}
select:hover { border-color: #5a5650; }
select option { background: #262421; color: #fff; font-weight: 500; }
.title-select { padding-right: 22px; background-position: right 5px center; background-size: 11px; }

/* Ô chọn có icon + nhãn (Sắp xếp, Chế độ…) */
label.select-pill {
  position: relative;
  flex-direction: row;
  align-items: center;
  gap: 0;
  min-width: 0;
  border: 1px solid #45423e;
  border-radius: 10px;
  background: #1f1e1b;
  color: var(--muted);
  font-size: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
label.select-pill:hover { border-color: #5f5b54; }
label.select-pill:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.select-pill > .ic { flex: none; width: 17px; height: 17px; margin-left: 12px; color: var(--gold); pointer-events: none; }
.select-pill .sp-cap {
  flex: none;
  margin-left: 8px;
  padding-right: 9px;
  border-right: 1px solid #ffffff1a;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  color: #9d988e;
  pointer-events: none;
}
.select-pill select {
  flex: 1;
  width: auto;
  min-width: 0;
  border: none;
  background-color: transparent;
  padding-left: 10px;
  color: #fff;
  font-weight: 700;
  box-shadow: none;
}
.select-pill select:focus { outline: none; }
.admin-tools .select-pill, .hist-tools .select-pill { flex: none; }
@media (max-width: 700px) {
  .admin-tools .select-pill, .hist-tools .select-pill { flex: 1 1 0; }
  .select-pill .sp-cap { display: none; }
}

/* ---------- Trang chủ ---------- */
body[data-page="home"] .layout { display: none; }
.home-page[hidden], .home-page [hidden] { display: none !important; }
.home-page {
  width: min(100%, 1120px);
  margin: 0 auto;
  padding: 16px 20px 40px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.home-page h1, .home-page h2 { margin: 0; }

/* Hero: lời chào + rank + số liệu */
.hm-hero {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 18px 24px;
  padding: 24px 26px;
  border-radius: 14px;
  overflow: hidden;
  background:
    radial-gradient(ellipse 55% 140% at 0% 0%, #81b64c30, transparent 70%),
    radial-gradient(ellipse 40% 120% at 100% 100%, #f5b83d1c, transparent 70%),
    linear-gradient(180deg, #2b2926, #262421);
  box-shadow: inset 0 1px 0 #ffffff12, 0 4px 14px #0004;
}
.hm-hero::after {
  content: "";
  position: absolute;
  inset: 0 0 0 auto;
  width: 52%;
  pointer-events: none;
  background: repeating-conic-gradient(#ffffff 0 25%, transparent 0 50%) 0 0 / 46px 46px;
  opacity: 0.035;
  mask-image: linear-gradient(90deg, transparent, #000 70%);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 70%);
}
.hm-hero > * { position: relative; z-index: 1; }
.hm-hero-main { display: flex; align-items: center; gap: 18px; min-width: 0; flex: 1 1 320px; }
.avatar.hm-avatar {
  flex: none;
  width: 84px;
  height: 84px;
  border-radius: 16px;
  font-size: 2.3rem;
  box-shadow: 0 0 0 3px #262421, 0 0 0 5px var(--accent), 0 10px 24px #0008;
}
.hm-hello { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.hm-greet { color: #a6d36b; font-size: 0.82rem; font-weight: 800; letter-spacing: 0.5px; text-transform: uppercase; }
.hm-name { font-size: 1.85rem; font-weight: 800; color: #fff; line-height: 1.15; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hm-rank { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-top: 4px; }
.hm-rank-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 3px 12px 3px 4px;
  border-radius: 99px;
  background: #00000030;
  box-shadow: inset 0 0 0 1px #ffffff14;
}
.hm-rank-btn:hover { background: #00000050; }
.hm-rank-btn .rb-medal { width: 30px; height: 30px; display: inline-grid; }
.hm-rank-btn .rb-medal svg { width: 100%; height: 100%; }
.hm-rank-text { display: inline-flex; align-items: center; gap: 8px; font-size: 0.92rem; }
.hm-rank-text .rk-stars { margin: 0; font-size: 0.9rem; letter-spacing: 1px; }
.hm-exp { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 0.76rem; font-weight: 700; }
.hm-exp-bar { width: 120px; height: 7px; border-radius: 99px; background: #ffffff14; overflow: hidden; }
.hm-exp-bar i { display: block; height: 100%; border-radius: inherit; box-shadow: 0 0 8px currentColor; }

.hm-stats { display: grid; grid-template-columns: repeat(5, 96px); gap: 8px; flex: none; }
.hm-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 12px 10px 10px;
  border-radius: 12px;
  background: #00000033;
  box-shadow: inset 0 0 0 1px #ffffff0f;
  text-align: center;
}
.hm-stat .ic { width: 18px; height: 18px; color: #c3c0b8; margin-bottom: 2px; }
.hm-stat b { font-size: 1.35rem; font-weight: 800; color: #fff; font-variant-numeric: tabular-nums; line-height: 1.1; }
.hm-stat b small { font-size: 0.72rem; color: var(--muted); font-weight: 700; }
.hm-stat > small { font-size: 0.7rem; color: var(--muted); font-weight: 700; white-space: nowrap; }
.hm-stat.gold .ic, .hm-stat.gold b { color: var(--gold); }
.hm-stat.green .ic { color: #a6d36b; }
.hm-stat.flame .ic { color: #ff8a3d; }
.hm-stat.blue .ic { color: #6cb4ee; }

/* Ván đang dở */
.hm-resume {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  background: linear-gradient(90deg, #81b64c26, #262421 60%);
  box-shadow: inset 0 0 0 1px #81b64c55;
}
.hm-resume-board { width: 64px; flex: none; border-width: 2px; }
.hm-resume-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.hm-resume-main b { color: #fff; font-size: 1rem; display: inline-flex; align-items: center; gap: 8px; }
.hm-resume-main small { color: var(--muted); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hm-resume-main { position: relative; padding-left: 16px; }
.hm-resume-main > .hm-live-dot { position: absolute; left: 0; top: 7px; }
.hm-resume-go { flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 10px 18px; }
.hm-live-dot { position: relative; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #e2533f; }
@keyframes hmPulse { 70% { box-shadow: 0 0 0 7px #e2533f00; } 100% { box-shadow: 0 0 0 0 #e2533f00; } }

/* Bắt đầu nhanh */
.hm-quick { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.hm-act {
  --c: var(--accent);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-radius: 14px;
  text-align: left;
  background: linear-gradient(160deg, color-mix(in srgb, var(--c) 18%, #2b2926), #262421 70%);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c) 30%, transparent), 0 4px 0 #0000004d;
  transition: transform 0.15s, box-shadow 0.15s, filter 0.15s;
}
.hm-act:hover { transform: translateY(-2px); filter: brightness(1.08); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c) 55%, transparent), 0 8px 20px #0006; }
.hm-act:active { transform: translateY(1px); }
.hm-act.online { --c: #4aa3df; }
.hm-act.puzzle { --c: var(--gold); }
.hm-act.learn { --c: #b07ce8; }
.hm-act-ic {
  flex: none;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: var(--c);
  color: #fff;
  box-shadow: 0 3px 0 color-mix(in srgb, var(--c) 55%, #000), 0 0 18px color-mix(in srgb, var(--c) 35%, transparent);
}
.hm-act.puzzle .hm-act-ic { color: #2b2105; }
.hm-act-ic .ic { width: 24px; height: 24px; }
.hm-act-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.hm-act-text b { color: #fff; font-size: 1rem; }
.hm-act-text small { color: #b3b0a8; font-weight: 500; font-size: 0.78rem; line-height: 1.3; }

/* Lưới thẻ */
.hm-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.hm-col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.hm-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border-radius: 14px;
  background: #262421;
  box-shadow: inset 0 1px 0 #ffffff0d, 0 4px 14px #0003;
}
.hm-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.hm-card-head h2 { display: inline-flex; align-items: center; gap: 8px; font-size: 1rem; font-weight: 800; color: #fff; }
.hm-card-head h2 .ic { width: 18px; height: 18px; color: var(--gold); }
.hm-card-head > small { color: var(--muted); font-weight: 700; font-size: 0.85rem; }
.hm-card-head > small b { color: #a6d36b; }
.hm-link {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 4px 6px 4px 10px;
  border-radius: 8px;
  background: transparent;
  box-shadow: none;
  color: #a6d36b;
  font-size: 0.8rem;
  font-weight: 700;
}
.hm-link:hover { background: #81b64c1a; color: #c3e88f; }
.hm-link .ic { width: 15px; height: 15px; }
.hm-muted { margin: 0; color: var(--muted); font-size: 0.88rem; }
.hm-empty { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 14px 8px; text-align: center; color: var(--muted); }
.hm-empty p { margin: 0; font-size: 0.9rem; }
.hm-empty .ic { width: 28px; height: 28px; opacity: 0.6; }
.hm-empty button { display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; }

/* Câu đố hôm nay */
.hm-card.hm-daily { padding: 0; overflow: hidden; background: linear-gradient(135deg, #3a2e17, #262421 55%); box-shadow: inset 0 0 0 1px #f5c03d33, 0 4px 14px #0004; }
.hm-daily-btn {
  display: flex;
  align-items: center;
  gap: 18px;
  width: 100%;
  padding: 16px;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  text-align: left;
}
.hm-daily-btn:hover { background: #ffffff06; }
.hm-daily-btn:active { transform: none; }
.hm-daily-btn .pz-board { width: 148px; flex: none; }
.hm-daily-main { display: flex; flex-direction: column; gap: 8px; min-width: 0; flex: 1; }
.hm-daily-title { font-size: 1.22rem; color: #fff; }
.hm-daily-theme { color: #c9c4b8; font-size: 0.84rem; font-weight: 500; }
.hm-daily-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.hm-daily-foot .pz-go { margin-top: 2px; }
.hm-daily-btn:hover .pz-go { filter: brightness(1.1); }
.hm-daily-btn.done .pz-go { background: #81b64c26; box-shadow: none; color: #a6d36b; }
.hm-daily-streak { display: inline-flex; align-items: center; gap: 5px; color: #d6d4cf; font-size: 0.85rem; font-weight: 600; }
.hm-daily-streak .ic { width: 17px; height: 17px; color: #ff8a3d; fill: #ff8a3d55; }
.hm-daily-streak b { color: #fff; }

/* Việc hôm nay */
.hm-todo { display: flex; flex-direction: column; gap: 6px; }
.hm-todo-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 10px 10px 12px;
  border-radius: 10px;
  background: #ffffff07;
  box-shadow: none;
  text-align: left;
}
.hm-todo-item:hover { background: #ffffff10; }
.hm-check {
  flex: none;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #ffffff0d;
  box-shadow: inset 0 0 0 2px #ffffff1f;
  color: #c3c0b8;
}
.hm-check .ic { width: 17px; height: 17px; }
.hm-todo-item.done .hm-check { background: var(--accent); box-shadow: 0 2px 0 var(--accent-dark); color: #fff; }
.hm-todo-item.done .hm-check .ic { stroke-width: 3; }
.hm-todo-text { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; }
.hm-todo-text b { color: #fff; font-size: 0.92rem; }
.hm-todo-item.done .hm-todo-text b { color: #b9b6ae; text-decoration: line-through; text-decoration-color: #81b64c99; }
.hm-todo-text small { color: var(--muted); font-size: 0.78rem; font-weight: 600; }
.hm-mini-bar { height: 5px; border-radius: 99px; background: #ffffff12; overflow: hidden; max-width: 220px; }
.hm-mini-bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #f5b83d, #ffd36b); }
.hm-chev { flex: none; width: 16px; height: 16px; color: #6f6b64; }
.hm-card.all-done .hm-card-head h2 .ic { color: #a6d36b; }

/* Ván gần đây */
.hm-recent { display: flex; flex-direction: column; gap: 4px; }
.hm-game {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: transparent;
  box-shadow: none;
  text-align: left;
}
.hm-game:hover { background: #ffffff0a; }
.hm-res {
  flex: none;
  min-width: 52px;
  padding: 4px 8px;
  border-radius: 7px;
  text-align: center;
  font-size: 0.74rem;
  font-weight: 800;
  background: #ffffff14;
  color: #d6d4cf;
}
.hm-res.win { background: #81b64c2e; color: #a6d36b; }
.hm-res.loss { background: #e2533f26; color: #f08a7a; }
.hm-res.draw { background: #ffffff14; color: #c9c6be; }
.hm-game-main { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.hm-game-main b { color: #fff; font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hm-game-main small { display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: 0.75rem; font-weight: 600; white-space: nowrap; overflow: hidden; }
.hm-game-main small .ic { width: 13px; height: 13px; flex: none; }
.hm-elo { flex: none; font-weight: 800; font-size: 0.82rem; font-variant-numeric: tabular-nums; }
.hm-elo.up { color: #a6d36b; }
.hm-elo.down { color: #f08a7a; }
.hm-when { flex: none; color: #7d7a73; font-size: 0.74rem; font-weight: 600; min-width: 74px; text-align: right; }

/* Contest */
.hm-contest { display: flex; flex-direction: column; gap: 8px; }
.hm-ct {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 12px 14px;
  border-radius: 12px;
  text-align: left;
  background: linear-gradient(135deg, #f5b83d1f, #ffffff05 70%);
  box-shadow: inset 0 0 0 1px #f5b83d33;
}
.hm-ct.live { background: linear-gradient(135deg, #e2533f26, #ffffff05 70%); box-shadow: inset 0 0 0 1px #e2533f55; }
.hm-ct:hover { filter: brightness(1.12); }
.hm-ct > b { color: #fff; font-size: 0.98rem; }
.hm-ct-badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 99px; background: #f5b83d26; color: var(--gold); font-size: 0.68rem; font-weight: 800; letter-spacing: 0.4px; text-transform: uppercase; }
.hm-ct.live .hm-ct-badge { background: #e2533f2e; color: #ff8f7d; }
.hm-ct.live .hm-live-dot { width: 7px; height: 7px; }
.hm-ct-time { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: 0.8rem; font-weight: 600; }
.hm-ct-time .ic { width: 14px; height: 14px; }
.hm-ct-time b { color: #fff; font-variant-numeric: tabular-nums; }

/* Top kỳ thủ */
.hm-top { display: flex; flex-direction: column; gap: 2px; }
.hm-top-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 10px;
  background: transparent;
  box-shadow: none;
  text-align: left;
}
.hm-top-row:hover { background: #ffffff0a; }
.hm-top-row.me { background: #81b64c1f; box-shadow: inset 0 0 0 1px #81b64c55; }
.hm-top-pos {
  flex: none;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 0.78rem;
  font-weight: 800;
  color: #b9b6ae;
  background: #ffffff0d;
}
.hm-top-row.p1 .hm-top-pos { background: linear-gradient(135deg, #ffe08a, #e0a526); color: #3b2a00; }
.hm-top-row.p2 .hm-top-pos { background: linear-gradient(135deg, #f1f1f1, #a9adb3); color: #2a2c30; }
.hm-top-row.p3 .hm-top-pos { background: linear-gradient(135deg, #f0b27a, #b06a2c); color: #2f1806; }
.hm-top-row .avatar { width: 30px; height: 30px; flex: none; font-size: 0.9rem; border-radius: 8px; }
.hm-top-name { flex: 1; min-width: 0; color: #fff; font-weight: 700; font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hm-top-elo { flex: none; color: var(--gold); font-weight: 800; font-variant-numeric: tabular-nums; }
.hm-top-gap { text-align: center; color: #6f6b64; line-height: 1; }

/* Khai cuộc hôm nay */
.hm-open-btn {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 0;
  background: transparent;
  box-shadow: none;
  text-align: left;
}
.hm-open-btn:hover { background: transparent; }
.hm-open-btn:hover b { color: #c3e88f; }
.hm-open-btn:active { transform: none; }
.hm-open-btn .lib-card-board { width: 112px; flex: none; }
.hm-open-main { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-width: 0; }
.hm-open-main b { color: #fff; font-size: 1rem; transition: color 0.15s; }
.hm-open-en { color: var(--muted); font-size: 0.78rem; font-weight: 600; }
.hm-open-moves { padding: 2px 7px; border-radius: 6px; background: #00000040; color: #e7d9b5; font-size: 0.78rem; }
.hm-open-desc {
  color: #b3b0a8;
  font-size: 0.8rem;
  font-weight: 500;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

@media (max-width: 1180px) {
  .hm-stats { grid-template-columns: repeat(5, minmax(0, 1fr)); width: 100%; flex: 1 1 100%; }
}
@media (max-width: 900px) {
  .hm-quick { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hm-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 700px) {
  .home-page { padding: 10px 8px 32px; gap: 12px; }
  .hm-hero { padding: 16px; gap: 14px; }
  .avatar.hm-avatar { width: 62px; height: 62px; font-size: 1.7rem; border-radius: 13px; }
  .hm-name { font-size: 1.35rem; }
  .hm-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .hm-stat { padding: 9px 4px 8px; }
  .hm-stat b { font-size: 1.1rem; }
  .hm-stat > small { font-size: 0.64rem; white-space: normal; }
  .hm-quick { gap: 8px; }
  .hm-act { flex-direction: column; align-items: flex-start; gap: 8px; padding: 12px; }
  .hm-act-ic { width: 40px; height: 40px; }
  .hm-act-text small { font-size: 0.72rem; }
  .hm-daily-btn { gap: 12px; padding: 12px; }
  .hm-daily-btn .pz-board { width: 108px; }
  .hm-daily-title { font-size: 1.02rem; }
  .hm-when { min-width: 0; }
  .hm-resume { flex-wrap: wrap; }
  .hm-resume-go { width: 100%; justify-content: center; }
  .hm-open-btn .lib-card-board { width: 92px; }
}
html[data-lang="en"] .hm-open-en { display: none; } /* tên tiếng Anh đã hiện ở dòng trên */

/* =========================================================
   v26: Nâng cấp Học cờ
   ========================================================= */
.lh-main { display: flex; flex-direction: column; gap: 22px; min-width: 0; }

/* Phần đầu lộ trình */
.lh-hero {
  --uc: #81b64c; --us: #5d8a32;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 22px 22px 18px;
  border-radius: 18px;
  overflow: hidden;
  background:
    radial-gradient(ellipse 70% 120% at 0% 0%, color-mix(in srgb, var(--uc) 38%, transparent), transparent 70%),
    linear-gradient(160deg, #2e2c28, #24221f);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--uc) 35%, transparent), 0 6px 0 #0000004d, 0 14px 30px #0005;
}
.lh-hero::after {
  content: "";
  position: absolute;
  inset: 0 0 0 auto;
  width: 45%;
  pointer-events: none;
  background: repeating-conic-gradient(#fff 0 25%, transparent 0 50%) 0 0 / 40px 40px;
  opacity: 0.035;
  mask-image: linear-gradient(90deg, transparent, #000 70%);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 70%);
}
.lh-hero > * { position: relative; z-index: 1; }
.lhh-top { display: flex; align-items: center; gap: 16px; }
.lhh-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 74px;
  height: 74px;
  border-radius: 18px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--uc) 78%, #fff), var(--uc));
  box-shadow: 0 5px 0 var(--us), inset 0 1px 0 #ffffff50, 0 0 26px color-mix(in srgb, var(--uc) 45%, transparent);
}
.lhh-icon img { width: 54px; height: 54px; filter: drop-shadow(0 3px 2px #0006); }
.lhh-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.lhh-text small { color: color-mix(in srgb, var(--uc) 70%, #fff); font-size: 0.74rem; font-weight: 800; letter-spacing: 0.6px; text-transform: uppercase; }
.lhh-text h2 { margin: 0; font-size: 1.55rem; font-weight: 800; color: #fff; line-height: 1.15; text-transform: none; letter-spacing: 0; }
.lhh-next { margin: 2px 0 0; color: #c9c5bc; font-size: 0.9rem; }
.lhh-next b { color: #fff; }
.lhh-ring { flex: none; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.lhh-ring > span { position: relative; display: grid; place-items: center; width: 84px; height: 84px; }
.lhh-ring svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.lhh-ring circle { fill: none; stroke-width: 8; }
.lhh-ring .track { stroke: #00000055; }
.lhh-ring .fill { stroke: var(--uc); stroke-linecap: round; filter: drop-shadow(0 0 6px color-mix(in srgb, var(--uc) 60%, transparent)); }
.lhh-ring b { font-size: 1.15rem; font-weight: 800; color: #fff; }
.lhh-ring small { color: var(--muted); font-size: 0.72rem; font-weight: 700; }

.lhh-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.lhh-stats .lh-stat {
  flex-direction: column;
  gap: 1px;
  padding: 10px 6px 8px;
  background: #00000038;
  border: none;
  box-shadow: inset 0 0 0 1px #ffffff0f;
  font-size: 1.15rem;
}
.lhh-stats .lh-stat small { font-size: 0.68rem; font-weight: 700; color: var(--muted); white-space: nowrap; }
.lhh-stats .lh-stat .ic { width: 20px; height: 20px; }
.lh-stat.stars { color: #e8b93b; }
.lhh-goal { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; border-radius: 12px; background: #00000030; box-shadow: inset 0 0 0 1px #ffffff0d; }
.lhh-goal .lh-card-head b { display: inline-flex; align-items: center; gap: 7px; }
.lhh-goal .lh-card-head .ic { width: 17px; height: 17px; color: #e8b93b; }
.lh-hero.goal-done .lhh-goal { box-shadow: inset 0 0 0 1px #81b64c66; background: #81b64c1a; }
.lh-hero.goal-done .lh-meter > div { background: linear-gradient(90deg, var(--accent-dark), var(--accent)); }
.lhh-actions { display: grid; grid-template-columns: 1.6fr 1fr; gap: 10px; }
.lhh-actions button { display: flex; align-items: center; justify-content: center; gap: 8px; }
.lhh-actions .ic { width: 19px; height: 19px; }
.lhh-actions button.ls-main {
  background: linear-gradient(180deg, color-mix(in srgb, var(--uc) 80%, #fff), var(--uc));
  box-shadow: 0 5px 0 var(--us);
}
.lhh-actions button.ls-main:active { box-shadow: 0 1px 0 var(--us); }
.lhh-actions button.lh-ghost { background: #ffffff10; box-shadow: inset 0 0 0 1px #ffffff1a, 0 4px 0 #0000004d; }
.lhh-actions button.lh-ghost:hover:not(:disabled) { background: #ffffff1c; }
.lhh-actions:has(.ls-main[hidden]) { grid-template-columns: 1fr; }
.lhh-tip { margin-top: -6px; font-size: 0.78rem; text-align: right; }

/* Đầu mỗi phần: thêm số sao */
.uh-side { display: flex; align-items: center; gap: 8px; }
.uh-stars { padding: 5px 10px; border-radius: 99px; background: #e8b93b1f; color: #f0c95a; font-weight: 800; font-size: 0.8rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.unit-head { border-left: 4px solid var(--uc); }
.unit-head.locked { border-left-color: #4a4844; }

/* Nút bài: bóng sáng + nút hiện tại nhún nhảy */
.node::after {
  content: "";
  position: absolute;
  top: 9px;
  left: 18px;
  width: 22px;
  height: 9px;
  border-radius: 50%;
  background: #ffffff38;
  transform: rotate(-20deg);
  pointer-events: none;
}
.node.locked::after { background: #ffffff0d; }
.node-start { animation: lhBob 1.6s ease-in-out infinite; }
@keyframes lhBob { 50% { transform: translateY(-5px); } }
.node.current { width: 76px; height: 72px; }

/* Cúp cuối phần */
.unit-trophy { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-top: 6px; }
.ut-cup {
  display: grid;
  place-items: center;
  width: 84px;
  height: 84px;
  border-radius: 24px;
  background: linear-gradient(180deg, #45423d, #36332f);
  box-shadow: 0 6px 0 #262421, inset 0 0 0 3px #ffffff0a;
  color: #6f6b64;
  transform: rotate(45deg);
}
.ut-cup .ic { width: 36px; height: 36px; transform: rotate(-45deg); }
.unit-trophy small { color: var(--muted); font-size: 0.75rem; font-weight: 700; margin-top: 8px; }
.unit-trophy.won .ut-cup { background: linear-gradient(180deg, #ffe08a, #e0a526); box-shadow: 0 6px 0 #a8741a, inset 0 0 0 3px #ffffff55, 0 0 28px #f5b83d66; color: #6b4300; }
.unit-trophy.won small { color: #f0c95a; }

/* Thành tích */
.lh-badges { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px 6px; }
.lh-badge { display: flex; flex-direction: column; align-items: center; gap: 5px; text-align: center; cursor: default; }
.lb-ic {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: #00000040;
  box-shadow: inset 0 0 0 2px #ffffff12;
  color: #5f5b55;
}
.lb-ic .ic { width: 20px; height: 20px; }
.lh-badge small { font-size: 0.66rem; font-weight: 700; color: #6f6b64; line-height: 1.2; }
.lh-badge.on .lb-ic { background: radial-gradient(circle at 35% 30%, #ffe9a8, #e8a92a 70%); box-shadow: 0 3px 0 #a8741a, 0 0 14px #f5b83d55; color: #5a3800; }
.lh-badge.on small { color: #e7e2d6; }

/* Bài học: số thử thách + màn trắc nghiệm rộng */
.ls-step { flex: none; font-size: 0.78rem; font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums; }
.ls-bar > div { background: linear-gradient(90deg, var(--us, var(--accent-dark)), var(--uc, var(--accent))); box-shadow: inset 0 3px 0 #ffffff33; }
.ls-mascot { background: linear-gradient(180deg, color-mix(in srgb, var(--uc) 35%, var(--panel-2)), var(--panel-2)); border-color: color-mix(in srgb, var(--uc) 40%, transparent); }
body[data-mode="learn"][data-learn="lesson"][data-lstep="quiz"] .board-area { display: none; }
body[data-mode="learn"][data-learn="lesson"][data-lstep="quiz"] .panel { width: min(100%, 680px); padding: 22px; }
body[data-lstep="quiz"] .ls-coach { flex-direction: column; align-items: center; text-align: center; gap: 14px; margin: 8px 0 4px; }
body[data-lstep="quiz"] .ls-mascot { width: 96px; height: 96px; padding: 12px; border-radius: 24px; box-shadow: 0 5px 0 #0000004d; }
body[data-lstep="quiz"] .ls-bubble { width: 100%; padding: 16px 18px; }
body[data-lstep="quiz"] .ls-bubble::before { top: auto; bottom: 100%; right: auto; left: 50%; transform: translateX(-50%); border: 8px solid transparent; border-bottom-color: #ffffff1c; }
body[data-lstep="quiz"] .ls-bubble b { font-size: 1.15rem; }
body[data-lstep="quiz"] .ls-bubble p { font-size: 1.02rem; color: #fff; }
body[data-lstep="quiz"] .ls-quiz { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
body[data-lstep="quiz"] .ls-opt { padding: 16px 14px; font-size: 1rem; min-height: 64px; }
@media (max-width: 560px) {
  body[data-lstep="quiz"] .ls-quiz { grid-template-columns: 1fr; }
  body[data-lstep="quiz"] .ls-opt { min-height: 0; padding: 13px 12px; }
}

/* Hoàn thành bài: vầng sáng + tiến độ phần */
.ld-burst { position: relative; display: grid; place-items: center; width: 130px; height: 110px; }
.ld-burst::before {
  content: "";
  position: absolute;
  inset: -10px;
  background: repeating-conic-gradient(#f5b83d2e 0 12deg, transparent 12deg 30deg);
  border-radius: 50%;
  mask-image: radial-gradient(circle, #000 30%, transparent 70%);
  -webkit-mask-image: radial-gradient(circle, #000 30%, transparent 70%);
  animation: ldSpin 14s linear infinite;
}
#learnDone.fail .ld-burst::before { display: none; }
@keyframes ldSpin { to { transform: rotate(360deg); } }
.ld-mascot { position: relative; animation: ldPop 0.5s cubic-bezier(0.3, 1.6, 0.5, 1) backwards; }
@keyframes ldPop { from { transform: scale(0.3) rotate(-12deg); opacity: 0; } }
.ld-unit { --uc: var(--accent); width: 100%; display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; border-radius: 12px; background: var(--panel-2); border: 1px solid #ffffff10; }
.ld-unit[hidden] { display: none; }
.ld-unit-head { display: flex; justify-content: space-between; gap: 8px; font-size: 0.82rem; font-weight: 700; color: #d6d2c9; text-align: left; }
.ld-unit-head b { color: var(--uc); }
.ld-unit .lh-meter > div { background: var(--uc); transition: width 0.9s cubic-bezier(0.3, 1, 0.4, 1) 0.2s; }

@media (max-width: 900px) {
  .learn-home .lh-main { display: contents; }
  .lh-hero { order: -2; }
  .lh-side { order: -1; }
  .lh-side .lh-card:has(.lh-chart) { display: none; }
}
@media (max-width: 560px) {
  .lh-hero { padding: 16px 14px 14px; gap: 12px; border-radius: 14px; }
  .lhh-icon { width: 56px; height: 56px; border-radius: 14px; }
  .lhh-icon img { width: 40px; height: 40px; }
  .lhh-text h2 { font-size: 1.2rem; }
  .lhh-ring > span { width: 64px; height: 64px; }
  .lhh-ring b { font-size: 0.9rem; }
  .lhh-stats { gap: 6px; }
  .lhh-stats .lh-stat { font-size: 1rem; padding: 8px 2px 6px; }
  .lhh-stats .lh-stat small { font-size: 0.6rem; }
  .lhh-tip { text-align: left; }
}

/* v27: Xoá contest */
.ci-del {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  color: #a7a29a;
  background: #ffffff0a;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.ci-del .ic { width: 16px; height: 16px; }
.ci-del:hover, .ci-del:focus-visible { background: #e2533f26; color: #ff8f7d; outline: none; }
.cd-tools button.cd-del { color: #f08a7a; }
.cd-tools button.cd-del:hover { background: #e2533f26; color: #ffb1a5; }
.contest-list > * { flex-shrink: 0; }
.ci-side:has(.ci-del) { display: grid; grid-template-columns: auto auto; align-items: center; justify-items: end; gap: 4px 8px; }
.ci-side:has(.ci-del) .ci-count { grid-column: 1 / -1; }
@media (max-width: 560px) {
  .contest-item .ci-count { white-space: normal; text-align: center; max-width: 96px; line-height: 1.25; }
}

/* ---------- Phân tích ván kiểu chess.com ---------- */
.mvc {
  --c: #97af8b;
  display: inline-grid; place-items: center; flex: none;
  width: 1.35em; height: 1.35em; border-radius: 50%;
  background: var(--c); color: #fff;
  font-size: 0.78rem; font-weight: 800; line-height: 1;
  box-shadow: 0 1px 2px #0006;
}
.mvc i { font-style: normal; letter-spacing: -0.08em; }
.mvc svg { width: 72%; height: 72%; }
.mvc-brilliant { --c: #26c2a3; }
.mvc-great { --c: #5c8bb0; }
.mvc-best { --c: #81b64c; }
.mvc-excellent { --c: #96bc4b; }
.mvc-good { --c: #97af8b; }
.mvc-book { --c: #a88865; }
.mvc-inaccuracy { --c: #f0b730; }
.mvc-mistake { --c: #e58f2a; }
.mvc-miss { --c: #ee6b55; }
.mvc-blunder { --c: #ca3431; }
.mvc-forced { --c: #8b8987; }
.mvc.sm { font-size: 0.6rem; margin-right: 4px; vertical-align: -0.15em; }
.mvc.lg { font-size: 1rem; }
/* Biểu tượng ở góc ô đích trên bàn cờ */
.mvc.mv-badge {
  position: absolute; top: 3%; right: 3%; z-index: 5;
  width: 36%; height: 36%;
  font-size: calc(var(--board-size) / 42);
  box-shadow: 0 1px 4px #000a, 0 0 0 2px #ffffffd0;
  pointer-events: none;
  animation: mvc-pop 0.25s ease-out;
}
@keyframes mvc-pop { from { transform: scale(0.3); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.moves .mv { display: inline-flex; align-items: center; }

/* Bảng tổng kết trong hộp kết quả */
.rv-acc { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
.rv-acc-side { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.rv-who { display: flex; align-items: center; gap: 5px; max-width: 100%; overflow: hidden; padding: 1px 3px; color: #e0dfde; font-size: 0.8rem; font-weight: 700; white-space: nowrap; text-overflow: ellipsis; }
.rv-acc-label { color: #8b8987; font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; text-align: center; }
.rv-ring { position: relative; width: 58px; height: 58px; }
.rv-ring svg { width: 100%; height: 100%; }
.rv-ring .track { fill: none; stroke: #ffffff14; stroke-width: 6; }
.rv-ring .fill { fill: none; stroke-width: 6; stroke-linecap: round; }
.rv-acc-side.w .rv-ring .fill { stroke: #f1efe8; }
.rv-acc-side.b .rv-ring .fill { stroke: #6f6c66; }
.rv-ring b { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: 1.05rem; }
.rv-table { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
.rv-table td { padding: 3px 4px; }
.rv-table td.n { width: 3em; text-align: center; font-weight: 800; color: #fff; }
.rv-table td.k { display: flex; align-items: center; gap: 8px; color: #d4d2cc; font-weight: 600; }
.rv-table tr.zero { opacity: 0.38; }
.rv-table tr:nth-child(odd) td { background: #ffffff05; }
.rv-graph { display: block; width: 100%; height: 64px; border-radius: 8px; cursor: pointer; overflow: hidden; }
.rv-graph .blk { fill: #403d39; }
.rv-graph .wht { fill: #f1efe8; }
.rv-graph .mid { stroke: #8b898755; stroke-width: 1; }
.rv-graph .cur { stroke: #81b64c; stroke-width: 2.5; }
.rc-review { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 11px; border-radius: 9px; font-size: 0.92rem; }

/* Khung nhận xét nước đang xem (cạnh biên bản) */
.review-box[hidden] { display: none; }
.review-box { display: flex; flex-direction: column; gap: 8px; margin: 0 0 8px; padding: 10px 12px; border-radius: 10px; background: #1f1e1c; border: 1px solid #ffffff10; }
.rvb-head { display: flex; align-items: center; gap: 8px; }
.rvb-head > b { color: #fff; font-size: 0.86rem; }
.rvb-acc { display: flex; align-items: center; gap: 4px; margin-left: auto; color: #c3c2c1; font-size: 0.78rem; font-weight: 700; }
.rvb-close { padding: 4px; border: none; background: transparent; box-shadow: none; color: #8b8987; }
.rvb-close:hover { color: #fff; }
.rvb-close .ic { width: 14px; height: 14px; }
.rvb-move { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; color: #e0dfde; font-size: 0.88rem; }
.rvb-move > b { color: #fff; }
.rvb-say { margin: 0; color: #c3c2c1; font-size: 0.84rem; }
.rvb-move.mvc-text-brilliant .rvb-say { color: #26c2a3; font-weight: 700; }
.rvb-move.mvc-text-great .rvb-say { color: #7fa9cf; font-weight: 700; }
.rvb-move.mvc-text-best .rvb-say, .rvb-move.mvc-text-excellent .rvb-say { color: #a6d36b; }
.rvb-move.mvc-text-inaccuracy .rvb-say { color: #f0b730; }
.rvb-move.mvc-text-mistake .rvb-say { color: #e58f2a; }
.rvb-move.mvc-text-miss .rvb-say, .rvb-move.mvc-text-blunder .rvb-say { color: #ee6b55; font-weight: 700; }
.rvb-eval { margin-left: auto; padding: 2px 7px; border-radius: 5px; font-size: 0.76rem; font-weight: 800; }
.rvb-eval.w { background: #f1efe8; color: #262421; }
.rvb-eval.b { background: #403d39; color: #fff; }
.rvb-best { margin: 0; color: #c3c2c1; font-size: 0.84rem; }
.rvb-best b { color: #a6d36b; }
.hist-actions .hist-rev { color: #26c2a3; }
.rv-who .pz-side { flex: none; }

/* ---------- Bàn cờ nổi 3D (Hồ sơ › Cài đặt, mặc định bật) ---------- */
/* Khung bàn vẽ bằng bóng đổ nên không chiếm chỗ: chừa đúng khoảng trống bằng độ dày khung (--frame) ở trên, dưới
   và giữa bàn với thanh đánh giá, để khung không đè lên tên người chơi / thanh đánh giá */
body[data-relief="on"] { --frame: calc(var(--board-size) / 60); --frame-depth: calc(var(--board-size) / 55 + 3px); }
body[data-relief="on"] .board-wrap {
  box-shadow: none;
  gap: calc(var(--frame) + var(--eval-gap));
  margin: calc(var(--frame) + 6px) 0 calc(var(--frame) + var(--frame-depth) + 8px);
}
body[data-relief="on"] .board {
  position: relative;
  /* khung bàn có độ dày: mép trong sáng, khung tối, cạnh trên bắt sáng, thành bàn phía dưới, bóng đổ xuống mặt bàn */
  box-shadow:
    0 0 0 calc(var(--board-size) / 160) #57504a,
    0 0 0 var(--frame) #2c2823,
    0 calc(var(--board-size) / -300) 0 var(--frame) #ffffff26,
    0 calc(var(--board-size) / 55) 0 var(--frame) #1a1714,
    0 var(--frame-depth) 0 var(--frame) #0b0a08,
    0 calc(var(--board-size) / 18) calc(var(--board-size) / 14) #000000c8;
}
/* mỗi ô có cạnh vát: sáng ở góc trên trái, tối ở góc dưới phải */
body[data-relief="on"] .board .sq {
  box-shadow:
    inset calc(var(--board-size) / 260) calc(var(--board-size) / 260) 0 #ffffff40,
    inset calc(var(--board-size) / -260) calc(var(--board-size) / -260) 0 #00000047,
    inset 0 0 calc(var(--board-size) / 60) #00000014;
}
/* ánh sáng phủ cả bàn (bàn gradient đã có vệt sáng riêng) */
body[data-relief="on"]:not([data-board="gradient"]):not([data-board="sunset"]):not([data-board="ocean"], [data-board="neon"]) .board::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  border-radius: inherit;
  background:
    radial-gradient(120% 90% at 18% 0%, #ffffff24, transparent 55%),
    linear-gradient(160deg, transparent 50%, #00000030);
}
/* quân nhấc lên khi rê chuột / khi được chọn */
body[data-relief="on"] .board .sq:hover .piece:not(.moving):not(.dragging) { translate: 0 -3%; }
body[data-relief="on"] .board .sq.selected .piece:not(.moving) {
  translate: 0 -6%;
  filter: drop-shadow(0 calc(var(--board-size) / 45) calc(var(--board-size) / 90) #000000a6);
}
body[data-relief="on"] .drag-ghost { filter: drop-shadow(0 14px 12px #000a); }

/* ---------- Góc nhìn nghiêng 3D (tuỳ chọn): bàn nghiêng ra sau, quân đứng thẳng ---------- */
/* Class .tilt do app.js gắn thẳng lên khối bàn (render): Safari không cập nhật kiểu khi chỉ đổi data-tilt trên <body>
   nên bật/tắt góc nhìn này trước đây có lúc không ăn (bàn vẫn nghiêng sau khi tắt, hoặc vẫn phẳng sau khi bật) */
html body .board-wrap.tilt {
  transform: perspective(calc(var(--board-size) * 2.4)) rotateX(26deg) scale(0.93);
  transform-origin: 50% 70%;
  transform-style: preserve-3d;
  margin: calc(var(--board-size) / -9) 0 calc(var(--frame, 0px) + var(--frame-depth, 0px) + 6px);
}
html body .board-wrap.tilt .board { overflow: visible; transform-style: preserve-3d; }
html body .board-wrap.tilt .board .sq { transform-style: preserve-3d; }
html body .board-wrap.tilt .board .piece {
  rotate: x -26deg;
  transform-origin: 50% 92%;
}
html body .board-wrap.tilt .board .sq:hover .piece:not(.moving) { translate: 0 -2% 4px; }

/* ---------- Mũi tên (chuột phải kéo) ---------- */
.arrow-layer { position: absolute; z-index: 6; pointer-events: none; overflow: visible; }
.arrow-layer polygon { filter: drop-shadow(0 1px 1px #0005); }

/* ---------- Nhật ký: nhập PGN, kết quả ván 2 người ---------- */
.hist-import-btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 10px; background: #5aa9ff1f; box-shadow: none; color: #8ec5ff; font-size: 0.82rem; white-space: nowrap; }
.hist-import-btn:hover { background: #5aa9ff33; }
.hist-import[hidden] { display: none; }
.hist-import { display: flex; flex-direction: column; gap: 8px; padding: 10px; border-radius: 10px; background: #1f1e1c; border: 1px solid #5aa9ff33; }
.hist-import textarea { width: 100%; min-height: 110px; resize: vertical; padding: 10px; border-radius: 8px; border: 1px solid #ffffff1a; background: #161513; color: #e0dfde; font: 0.8rem/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; }
.hist-import-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; color: #c3c2c1; font-size: 0.84rem; }
.hist-import-row select { width: auto; min-width: 170px; }
.hist-import-row .primary { margin-left: auto; }
.hist-import .admin-msg:empty { display: none; }
.hist-res.side, .hm-res.side, .pf-res.side { width: auto; padding: 1px 8px; background: #ffffff14; color: #d4d2cc; white-space: nowrap; }
.hist-row.side { box-shadow: inset 3px 0 0 #5c5a56; }
@media (max-width: 600px) {
  .hist-tools { flex-wrap: wrap; }
  .hist-import-btn { flex: 1; justify-content: center; }
  .hist-tools .select-pill { flex: 1; min-width: 0; }
  .hist-tools .select-pill select { min-width: 0; width: 100%; }
}

/* Thẻ khai cuộc / câu đố là <button>: kiểu nút chung căn giữa nội dung nên phần chữ không giãn theo thẻ và tràn ra ngoài
   (tên dài như "Phản gambit Falkbeer" bị cắt ngang trên điện thoại). Cho nội dung giãn đúng bề rộng thẻ và tự rút gọn "…". */
.lib-card, .pz-card { align-items: stretch; min-width: 0; }
.lib-card-meta, .pz-meta { width: 100%; }
.lib-card-moves { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Thanh đánh giá cách bàn cờ một khoảng rõ ràng (≈ 16px trên máy tính, tối thiểu 10px).
   Bàn luôn vuông: trước đây chiều cao cố định bằng --board-size còn chiều rộng bị thanh đánh giá chiếm bớt,
   nên ô cờ hơi dài theo chiều dọc (bàn 690 × 730). */
:root { --eval-gap: max(10px, calc(var(--board-size) / 45)); }
.board-wrap { gap: var(--eval-gap); }
.board-wrap .board { height: auto; aspect-ratio: 1 / 1; }

/* Thanh đánh giá nổi (theo tuỳ chọn "Bàn cờ nổi 3D"): khung có độ dày như khung bàn, hai nửa trắng / đen tô như khối trụ,
   lớp sáng bóng như ống thuỷ tinh. Khung vẽ bằng bóng đổ nên khoảng hở với bàn được cộng thêm độ dày khung (--eval-frame). */
body[data-relief="on"] { --eval-frame: max(3px, calc(var(--board-size) / 160)); }
body[data-relief="on"] .board-wrap { gap: calc(var(--frame) + var(--eval-gap) + var(--eval-frame)); }
body[data-relief="on"] .eval-bar {
  border-radius: 6px;
  box-shadow:
    0 0 0 var(--eval-frame) #2c2823,
    0 0 0 calc(var(--eval-frame) + 1px) #ffffff1f,
    0 calc(var(--board-size) / -300) 0 var(--eval-frame) #ffffff21,
    0 calc(var(--board-size) / 110) 0 var(--eval-frame) #171512,
    0 calc(var(--board-size) / 110 + 2px) 0 var(--eval-frame) #0b0a08,
    0 calc(var(--board-size) / 25) calc(var(--board-size) / 22) #000000b0;
}
body[data-relief="on"] .eval-white { background: linear-gradient(90deg, #c9c9c6 0%, #ffffff 38%, #f1f0ec 62%, #d2d1cc 100%); }
body[data-relief="on"] .eval-black { background: linear-gradient(90deg, #070707 0%, #3b3a38 38%, #232220 62%, #0c0c0b 100%); }
body[data-relief="on"] .eval-bar::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  border-radius: inherit;
  /* bóng sáng dọc thân + viền tối bên trong như mặt cong */
  background: linear-gradient(90deg, #00000040 0%, transparent 22%, #ffffff38 34%, transparent 52%, #00000030 100%);
  box-shadow: inset 0 0 0 1px #00000080, inset 0 2px 3px #ffffff26, inset 0 -2px 3px #00000059;
}
body[data-relief="on"] .eval-label { z-index: 2; }

/* Online: thanh đánh giá chỉ hiện khi xem lại ván (xem renderEval trong app.js); ẩn nhưng giữ chỗ để bàn không co giãn */
.eval-bar.concealed { visibility: hidden; }
/* Quầng sáng của bàn (bàn vẽ sau thanh đánh giá) không phủ lên thanh */
.board-wrap .eval-bar { z-index: 1; }

/* Màn hình rộng (bàn cờ và khung bên phải nằm cạnh nhau):
   • khung bên phải ngang tầm cột bàn cờ: mép trên ngang tên người chơi phía trên, mép dưới ngang tên phía dưới;
     phần Biên bản giãn ra lấp chỗ trống (ván dài thì cuộn bên trong) thay vì để khung ngắn lửng lơ;
   • hai khối cách nhau rõ hơn: khoảng hở thấy được ≈ 30px (cộng thêm độ dày khung bàn nổi, vì khung vẽ tràn ra ngoài). */
@media (min-width: 1000px) {
  .layout { align-items: stretch; column-gap: calc(var(--frame, 0px) + 30px); }
  .board-area { align-self: flex-start; }
  .panel { align-self: stretch; }
  body:not([data-mode="learn"]) .panel .record { flex: 1 1 auto; min-height: 0; }
  body:not([data-mode="learn"]) .panel .moves { flex: 1 1 0; min-height: 140px; max-height: none; overflow-y: auto; }
}

/* Nhật ký: dòng trạng thái đồng bộ với tài khoản (bấm để đồng bộ ngay) */
.hist-sync[hidden] { display: none; }
.hist-sync { display: inline-flex; align-items: flex-start; gap: 5px; margin: 4px 0 0; padding: 0; border: none; background: none; box-shadow: none; color: #8b8987; font-size: 0.74rem; font-weight: 600; line-height: 1.4; text-align: left; cursor: pointer; }
.hist-sync:hover { background: none; text-decoration: underline; }
.hist-sync .ic { width: 14px; height: 14px; margin-top: 1px; }
.hist-sync.ok { color: #a6d36b; }
.hist-sync.syncing { color: #8ec5ff; }
.hist-sync.error { color: #f0b730; }

/* Đăng nhập bằng Google / chế độ khách */
.auth-alt[hidden], .auth-form[hidden] { display: none; }
.auth-alt { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.auth-alt .divider { margin: 0; }
.auth-google { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; background: #fff; color: #1f1f1f; font-weight: 700; box-shadow: 0 2px 0 #c9c9c9; }
.auth-google:hover { background: #f1f1f1; }
.auth-google svg { width: 20px; height: 20px; }
.auth-google.busy { opacity: .7; cursor: progress; }
.auth-inapp[hidden] { display: none; }
.auth-inapp { border: 1px solid rgba(240, 180, 60, .45); background: rgba(240, 180, 60, .1); border-radius: 10px; padding: 10px 12px; font-size: 13px; line-height: 1.45; }
.auth-inapp p { margin: 0 0 8px; }
.auth-inapp-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.auth-inapp-btns button { flex: 1 1 140px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.auth-guest { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; }
.auth-guest-note { margin: -2px 0 0; color: #8b8987; font-size: 0.74rem; line-height: 1.45; text-align: center; }
.auth-name-intro { margin: 0 0 4px; color: #c3c2c1; font-size: 0.86rem; line-height: 1.5; }
.auth-name-intro b { color: #fff; }
.hm-guest-chip { display: inline-block; padding: 4px 10px; border-radius: 99px; background: #ffffff14; color: #d4d2cc; font-size: 0.78rem; font-weight: 700; }
.hm-guest[hidden] { display: none; }
.hm-guest { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 0 0 12px; padding: 12px 14px; border-radius: 12px; background: #5aa9ff1a; border: 1px solid #5aa9ff40; }
.hm-guest > span { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 200px; }
.hm-guest b { color: #fff; font-size: 0.92rem; }
.hm-guest small { color: #c3c2c1; font-size: 0.78rem; line-height: 1.4; }
.small-note { margin: -6px 0 8px 28px; font-size: 0.76rem; }
.auth-name-email { margin: -4px 0 4px; color: #8ec5ff; font-size: 0.84rem; font-weight: 700; word-break: break-all; }

/* Nút điều hướng nước đi dùng biểu tượng vẽ (ký tự ⏮ ◀ ▶ ⏭ bị điện thoại đổi thành emoji) */
.nav-row button .ic, .lib-step button .ic { width: 16px; height: 16px; stroke-width: 2.4; }

/* ================= Màn hình đăng nhập / đăng ký (nâng cấp) ================= */
#authModal {
  background:
    radial-gradient(900px 600px at 15% 10%, #81b64c26, transparent 60%),
    radial-gradient(800px 600px at 90% 90%, #5aa9ff1f, transparent 60%),
    repeating-conic-gradient(#ffffff05 0 25%, transparent 0 50%) 0 0 / 64px 64px,
    #121110;
  backdrop-filter: none;
  overflow-y: auto;
  align-items: safe center;
}
.auth-shell { display: flex; align-items: stretch; width: min(100%, 980px); margin: auto; border-radius: 26px; box-shadow: 0 30px 80px #000c, 0 0 0 1px #ffffff12; overflow: hidden; }
.auth-hero { display: none; }
#authModal .auth-box { width: min(100%, 420px); margin: 0 auto; max-height: none; border-radius: 26px; padding: 26px 26px 22px; background: linear-gradient(180deg, #2a2825, #1f1e1b); border: none; box-shadow: none; }
@media (min-width: 900px) {
  .auth-hero {
    display: flex; flex-direction: column; gap: 18px; flex: 1.15; padding: 34px 34px 30px;
    background: linear-gradient(160deg, #2f3d22 0%, #1d2416 55%, #161913 100%);
    border-right: 1px solid #ffffff0f;
  }
  #authModal .auth-box { flex: 1; width: auto; border-radius: 0; padding: 34px 34px 26px; }
  #authModal .auth-box .auth-brand { display: none; } /* logo đã ở cột trái */
}
.ah-brand { display: flex; align-items: center; gap: 12px; }
.ah-brand img { width: 46px; height: 46px; filter: drop-shadow(0 6px 14px #000a); }
.ah-brand .wordmark { font-family: "Cinzel", serif; font-size: 1.35rem; letter-spacing: 0.12em; color: #f3f1ea; }
.ah-title { margin: 0; color: #fff; font-size: 1.55rem; line-height: 1.3; font-weight: 800; }
.ah-board { width: min(100%, 300px); align-self: center; border-width: 4px; border-radius: 10px; box-shadow: 0 18px 40px #000b; transform: perspective(900px) rotateX(10deg); }
.ah-feats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: auto 0 0; padding: 0; list-style: none; }
.ah-feats li { display: flex; align-items: flex-start; gap: 10px; padding: 10px; border-radius: 12px; background: #ffffff0a; border: 1px solid #ffffff0d; }
.ah-feats .ic { flex: none; width: 20px; height: 20px; color: #a6d36b; margin-top: 2px; }
.ah-feats span { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ah-feats b { color: #fff; font-size: 0.84rem; }
.ah-feats small { color: #b9c2ad; font-size: 0.72rem; line-height: 1.35; }

.auth-welcome { margin: -4px 0 14px; color: #c3c2c1; font-size: 0.9rem; text-align: center; line-height: 1.45; }
@media (min-width: 900px) { .auth-welcome { text-align: left; font-size: 0.95rem; } }

/* Tab có viên trượt */
.auth-tabs { position: relative; padding: 4px; border-radius: 12px; background: #161513; }
.auth-tabs button { position: relative; z-index: 1; background: transparent !important; box-shadow: none !important; color: #8b8987; transition: color 0.2s; }
.auth-tabs button.on { color: #fff; }
.auth-tab-pill { position: absolute; z-index: 0; top: 4px; bottom: 4px; left: 4px; width: calc(50% - 7px); border-radius: 9px; background: linear-gradient(180deg, #8cc256, var(--accent)); box-shadow: 0 3px 0 var(--accent-dark); transition: transform 0.25s cubic-bezier(0.3, 0.8, 0.3, 1); }
.auth-tabs.reg .auth-tab-pill { transform: translateX(calc(100% + 6px)); }

/* Ô nhập có biểu tượng */
.auth-form { gap: 8px; }
.auth-form.swap { animation: auth-swap 0.25s ease; }
@keyframes auth-swap { from { opacity: 0.4; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.auth-field-label { margin: 6px 0 0; color: #c3c2c1; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.02em; }
.auth-group { display: flex; flex-direction: column; gap: 8px; }
.auth-group[hidden] { display: none; }
.auth-field { position: relative; display: flex; align-items: center; }
.auth-field > .ic { position: absolute; left: 13px; width: 18px; height: 18px; color: #8b8987; pointer-events: none; transition: color 0.15s; }
.auth-field input { width: 100%; padding: 13px 44px 13px 42px; border-radius: 12px; border: 1px solid #ffffff1a; background: #161513; color: #fff; font-size: 0.95rem; transition: border-color 0.15s, box-shadow 0.15s; }
.auth-field input::placeholder { color: #6f6b64; }
.auth-field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px #81b64c33; }
.auth-field:focus-within > .ic { color: #a6d36b; }
.auth-eye { position: absolute; right: 6px; display: grid; place-items: center; width: 34px; height: 34px; padding: 0; border: none; border-radius: 8px; background: transparent !important; box-shadow: none !important; color: #8b8987; }
.auth-eye:hover { color: #fff; }
.auth-ok { position: absolute; right: 12px; display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: #81b64c; color: #fff; }
.auth-ok[hidden] { display: none; }
.auth-ok .ic { width: 13px; height: 13px; stroke-width: 3; }
.auth-hint { margin: 0; min-height: 1.1em; color: #8b8987; font-size: 0.74rem; }
.auth-hint.good { color: #a6d36b; }
.auth-hint.bad { color: #f0907e; }
.auth-hint:empty { min-height: 0; }

/* Độ mạnh mật khẩu */
.auth-strength { display: flex; align-items: center; gap: 10px; }
.auth-strength[hidden] { display: none; }
.as-bar { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; flex: 1; }
.as-bar i { height: 5px; border-radius: 99px; background: #ffffff14; transition: background 0.2s; }
.auth-strength small { flex: none; color: #8b8987; font-size: 0.72rem; font-weight: 700; }
.auth-strength[data-lv="1"] .as-bar i:nth-child(-n+1) { background: #e2533f; }
.auth-strength[data-lv="2"] .as-bar i:nth-child(-n+2) { background: #f0b730; }
.auth-strength[data-lv="3"] .as-bar i:nth-child(-n+3) { background: #a6d36b; }
.auth-strength[data-lv="4"] .as-bar i { background: #81b64c; }
.auth-strength[data-lv="0"] small { color: #f0907e; }

.auth-caps { margin: 0; color: #f0b730; font-size: 0.76rem; font-weight: 700; }
.auth-caps[hidden] { display: none; }
.auth-caps::before { content: "⇪ "; }
.auth-submit { margin-top: 6px; }
.auth-submit.busy { opacity: 0.8; cursor: progress; }
.auth-switch { margin: 4px 0 0; text-align: center; color: #8b8987; font-size: 0.84rem; }
.auth-link { display: inline; padding: 0; border: none; background: none !important; box-shadow: none !important; color: #a6d36b; font-weight: 800; font-size: inherit; cursor: pointer; }
.auth-link:hover { text-decoration: underline; }
.auth-box.shake { animation: auth-shake 0.35s ease; }
@keyframes auth-shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
@media (prefers-reduced-motion: reduce) { .auth-box.shake, .auth-form.swap { animation: none; } .auth-tab-pill { transition: none; } }
@media (max-width: 420px) { #authModal .auth-box { padding: 22px 18px 18px; } #authGoogle, #authGuest { font-size: 1rem; white-space: nowrap; } }
/* Đổi mật khẩu */
.pw-box { width: min(100%, 420px); }
.pw-box .auth-form { margin-top: 14px; }
.pw-box .auth-field input { padding-right: 44px; }
.pw-box .small-note { margin: 2px 0 0; text-align: center; font-size: 0.76rem; }
.pw-box.shake { animation: auth-shake 0.35s ease; }
#pwBtn[hidden] { display: none; }

/* Quên mật khẩu & Gmail khôi phục */
.auth-label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-top: 6px; }
.auth-label-row .auth-field-label { margin: 0; }
.auth-forgot { font-size: 0.78rem; font-weight: 700; }
.auth-forgot[hidden], #authWelcome[hidden], #authForgot[hidden] { display: none; }
.auth-msg.ok { color: #a6d36b; }
.af-head { display: flex; align-items: center; gap: 8px; }
.af-head h2 { margin: 0; font-size: 1.25rem; color: #fff; }
.af-back { display: grid; place-items: center; width: 34px; height: 34px; padding: 0; border-radius: 10px; background: #161513 !important; box-shadow: none !important; color: #c3c2c1; }
.af-back:hover { color: #fff; }
.af-steps { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 6px 0 2px; padding: 0; list-style: none; counter-reset: af; }
.af-steps li { counter-increment: af; display: flex; align-items: center; gap: 8px; padding-top: 8px; border-top: 3px solid #ffffff14; color: #8b8987; font-size: 0.74rem; font-weight: 700; }
.af-steps li::before { content: counter(af); display: grid; place-items: center; flex: none; width: 20px; height: 20px; border-radius: 50%; background: #ffffff14; font-size: 0.7rem; }
.af-steps li.on { border-color: var(--accent); color: #fff; }
.af-steps li.on::before { background: var(--accent); color: #fff; }
.af-steps li.done { border-color: #81b64c80; color: #a6d36b; }
.af-steps li.done::before { content: "✓"; background: #81b64c55; }
.af-text, .af-help { margin: 0; color: #a3a19e; font-size: 0.82rem; line-height: 1.45; }
.af-help { margin-top: 4px; font-size: 0.74rem; text-align: center; color: #8b8987; }
.af-sent { margin: 0; padding: 9px 12px; border-radius: 10px; background: #81b64c1a; border: 1px solid #81b64c40; color: #cfe8ad; font-size: 0.82rem; line-height: 1.4; }
.af-sent[hidden] { display: none; }
.af-resend { margin: 0; color: #8b8987; font-size: 0.76rem; }
.af-resend .auth-link:disabled { color: #8b8987; cursor: default; text-decoration: none; }
.auth-field input.code-input { letter-spacing: 0.45em; font-size: 1.15rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.rec-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; margin: 6px 0; border-radius: 12px; background: #1f1e1c; border: 1px solid #ffffff0d; }
.rec-row[hidden] { display: none; }
.rec-row > .ic { flex: none; width: 20px; height: 20px; color: #8b8987; }
.rec-row.set > .ic { color: #a6d36b; }
.rec-info { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.rec-info b { color: #fff; font-size: 0.86rem; }
.rec-info small { color: #8b8987; font-size: 0.74rem; overflow-wrap: anywhere; }
.rec-row.set .rec-info small { color: #cfe8ad; }
#recRemove[hidden], #annMailRow[hidden] { display: none; }
.rec-box.shake { animation: auth-shake 0.35s ease; }
.auth-tabs[hidden] { display: none; }

/* ---------- Bảng phân tích Stockfish 19 trực tiếp ---------- */
.engine-card { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; border-radius: 10px; background: #1f1e1c; border: 1px solid #ffffff10; }
.engine-card[hidden], .engine-body[hidden] { display: none; }
.engine-head { display: flex; align-items: center; gap: 8px; }
.engine-title { display: inline-flex; align-items: center; gap: 6px; color: #fff; font-size: 0.86rem; }
.engine-title .ic { width: 16px; height: 16px; color: #4d9cff; }
.engine-depth { margin-left: auto; color: #8b8987; font-size: 0.74rem; font-variant-numeric: tabular-nums; }
.engine-toggle { position: relative; flex: none; width: 38px; height: 22px; padding: 0; border: none; border-radius: 99px; background: #3c3a37; box-shadow: none; }
.engine-toggle span { position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #c3c2c1; transition: transform 0.15s, background 0.15s; }
.engine-toggle.on { background: #4d9cff; }
.engine-toggle.on span { transform: translateX(16px); background: #fff; }
.engine-toggle:active { transform: none; }
.engine-body { display: flex; flex-direction: column; gap: 4px; }
.engine-line { display: flex; align-items: baseline; gap: 8px; min-width: 0; font-size: 0.8rem; }
.engine-ev { flex: none; min-width: 46px; padding: 2px 6px; border-radius: 5px; text-align: center; font-weight: 800; font-variant-numeric: tabular-nums; }
.engine-ev.w { background: #ece9e1; color: #1d1c19; }
.engine-ev.b { background: #121110; color: #ece9e1; box-shadow: inset 0 0 0 1px #ffffff1f; }
.engine-pv { overflow: hidden; color: #c3c2c1; text-overflow: ellipsis; white-space: nowrap; }
.engine-note { display: flex; align-items: center; gap: 8px; margin: 0; color: #8b8987; font-size: 0.8rem; }
.engine-note .spinner { width: 14px; height: 14px; }



/* Bảng phím tắt: dòng chỉ hiện với một số tài khoản (giữ nguyên lưới 2 cột dt / dd) */
.keys-list .key-row { display: contents; }
.keys-list .key-row[hidden] { display: none; }

/* Máy Elo tuỳ chỉnh (công cụ chủ web) */
.bot-av.lv5 { background: linear-gradient(135deg, #f5c03d, #7a3fd6); }
.custom-elo { padding: 10px 12px; border-radius: 10px; background: #1f1e1c; border: 1px solid #f5c03d33; }
.custom-elo[hidden] { display: none; }
.custom-elo .setup-label b { color: #f5c03d; font-size: 0.85rem; }
.custom-elo input[type="range"] { width: 100%; accent-color: #f5c03d; }
.custom-elo-scale { display: flex; justify-content: space-between; color: #8b8987; font-size: 0.7rem; font-variant-numeric: tabular-nums; }

/* Bảng phân tích: công cụ chủ web (số biến, đe doạ) */
.engine-opts { display: flex; align-items: center; gap: 8px; }
.engine-opts[hidden] { display: none; }
.engine-opts .seg { flex: 1; }
.engine-chip { display: inline-flex; align-items: center; gap: 5px; flex: none; padding: 6px 10px; border: 1px solid #ffffff1a; border-radius: 8px; background: transparent; box-shadow: none; color: #c3c2c1; font-size: 0.78rem; font-weight: 700; }
.engine-chip .ic { width: 14px; height: 14px; }
.engine-chip:hover { background: #ffffff0a; color: #fff; }
.engine-chip.on { border-color: #e2533f99; background: #e2533f1f; color: #ff8f7e; }
.engine-chip:active { transform: none; }
.engine-line.threat { margin-top: 2px; padding-top: 6px; border-top: 1px dashed #ffffff14; }
.engine-ev.t { background: #e2533f26; color: #ff8f7e; box-shadow: inset 0 0 0 1px #e2533f55; font-size: 0.72rem; }
.engine-pv .muted { color: #8b8987; }
/* PGN có chú thích (chủ web) */
.pgn-an { color: #f5c03d; }
.pgn-an[hidden] { display: none; }

/* ---------- Trạng thái trống / lỗi: khung viền nét đứt + biểu tượng thay cho dòng chữ trơn ---------- */
.hist-empty, .pf-empty:not(.pf-medals > .pf-empty), .moves > .empty, .empty.error, .hm-muted.error {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  margin: 6px 0; padding: 18px 16px; border: 1px dashed #ffffff17; border-radius: 12px; background: #ffffff05;
  color: #9d988e; text-align: center; line-height: 1.55;
}
.hist-empty::before, .pf-empty:not(.pf-medals > .pf-empty)::before, .moves > .empty::before, .empty.error::before, .hm-muted.error::before {
  content: ""; flex: none; width: 38px; height: 38px; border-radius: 50%;
  background: #ffffff0d url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a29f9a' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='7' r='3'/%3E%3Cpath d='M9.5 10.5c0 2.5-1.5 4.5-2.5 6.5h10c-1-2-2.5-4-2.5-6.5M6 20h12'/%3E%3C/svg%3E") center / 20px no-repeat; box-shadow: inset 0 0 0 1px #ffffff12;
}
.hist-empty::before { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a29f9a' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 7v5l3 2'/%3E%3C/svg%3E"); }
.pf-empty:not(.pf-medals > .pf-empty)::before { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a29f9a' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 19h16M6 15l4-5 3 3 5-7'/%3E%3C/svg%3E"); }
.empty.error, .hm-muted.error { border-color: #e2533f40; background: #e2533f0a; color: #d9a39b; }
.empty.error::before, .hm-muted.error::before { background-color: #e2533f1a; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ff8f7e' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 4 2.5 20h19L12 4Z'/%3E%3Cpath d='M12 10v4M12 17v.01'/%3E%3C/svg%3E"); box-shadow: inset 0 0 0 1px #e2533f40; }
.moves > .empty { height: calc(100% - 12px); min-height: 110px; margin: 6px; }
.hm-muted.error { flex-direction: row; justify-content: flex-start; padding: 10px 12px; text-align: left; }
.hm-muted.error::before { width: 30px; height: 30px; background-size: 16px; }

/* ---------- Đang giải câu đố: ẩn các nút của ván đấu máy (bị khoá khi giải câu đố) và dòng ghi chú Elo ---------- */
body[data-puzzle="on"] #playPanel > #newGame,
body[data-puzzle="on"] #playPanel > .tool-row,
body[data-puzzle="on"] #playPanel > #ratedNote { display: none; }

/* ---------- Điện thoại: khung nổi của bàn cờ (vẽ bằng bóng đổ) không chạm mép phải màn hình ---------- */
@media (max-width: 700px) {
  body[data-relief="on"] .board-wrap { padding-right: var(--frame); }
  /* Thanh đánh giá đang ẩn (ván Online): trên điện thoại bỏ hẳn chỗ của nó để bàn cờ nằm giữa màn hình */
  .eval-bar.concealed { display: none; }
}

/* Phòng chờ Online: thời gian của ván (chủ phòng chọn) */
.room-time { margin: -4px 0 0; color: #f5c03d; font-size: 0.86rem; font-weight: 700; text-align: center; }
.room-time:empty { display: none; }

/* Màn rộng vừa (laptop 1180–1440px): thu nhỏ bàn cờ cho khung bên phải luôn nằm cạnh bàn, khỏi phải cuộn xuống mới thấy
   các nút (trước đây ở cỡ ~1300px khung bị đẩy xuống dưới bàn cờ).
   700px = thanh bên 200 + khung phải 400 + lề trang 40 + khoảng hở giữa hai khối ~41 + dư một chút. */
@media (min-width: 1180px) {
  :root { --board-size: min(94vw, calc(100vh - 170px), 760px, calc(100vw - 700px)); }
}

/* Ván đấu máy tính Elo bình thường: không có dòng ghi chú */
.rated-note:empty { display: none; }

/* ---------- Hiệu ứng nhấp nháy nhẹ máy: vòng phụ phóng to + mờ dần bằng transform / opacity ----------
   Trước đây các chấm "đang tới lượt", "Online", "ván đang dở" và nút bài học hiện tại đổi box-shadow mỗi khung hình,
   buộc trình duyệt vẽ lại liên tục (chấm cạnh tên người chơi chạy suốt ván). */
.player.active .turn-dot::after, .ol-live i::after, .hm-live-dot::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: currentColor;
  pointer-events: none;
  animation: dot-ping 1.6s ease-out infinite;
  will-change: transform, opacity;
}
.player.active .turn-dot::after { color: var(--accent); }
.ol-live i::after { color: #81b64c; animation-duration: 1.8s; }
.hm-live-dot::after { color: #e2533f; }
@keyframes dot-ping { 0% { transform: scale(1); opacity: 0.55; } 70%, 100% { transform: scale(2.6); opacity: 0; } }
.node.current::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--uc) 60%, transparent);
  pointer-events: none;
  animation: node-ring 2s ease-out infinite;
  will-change: transform, opacity;
}
@keyframes node-ring { 0% { transform: scale(1); opacity: 1; } 100% { transform: scale(1.35); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .player.active .turn-dot::after, .ol-live i::after, .hm-live-dot::after, .node.current::before, .node-start { animation: none; }
}

/* ======================================================================
   Ứng dụng (PWA): nút / thẻ cài đặt, thanh cập nhật, thanh điều hướng dưới đáy trên điện thoại
   ====================================================================== */
.install-btn[hidden], .hm-install[hidden], .update-bar[hidden], .more-sheet[hidden], .hm-ai[hidden] { display: none; }
.install-btn { color: var(--gold); }
.hm-install {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px;
  background: linear-gradient(135deg, #2f2a1c, #262421 60%); box-shadow: inset 0 0 0 1px #f5c03d33, 0 4px 14px #0004;
}
.hm-install-ic img { width: 44px; height: 44px; display: block; }
.hm-install-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.hm-install-text small { color: var(--muted); line-height: 1.4; }
.hm-install .primary { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
@media (max-width: 520px) { .hm-install { flex-wrap: wrap; } .hm-install-text { flex-basis: calc(100% - 100px); } .hm-install .primary { flex: 1; justify-content: center; } }

.update-bar {
  position: fixed; left: 50%; top: 12px; transform: translateX(-50%); z-index: 90;
  display: flex; align-items: center; gap: 10px; max-width: min(94vw, 520px);
  padding: 8px 8px 8px 14px; border-radius: 12px; background: #2c2a26; color: var(--text);
  box-shadow: 0 10px 30px #000a, inset 0 0 0 1px #ffffff14; font-weight: 600;
}
.update-bar > .ic { width: 18px; height: 18px; color: var(--accent); flex: none; }
.update-bar span { flex: 1; }
@media (min-width: 1000px) { .update-bar { left: calc(50% + var(--nav-w) / 2); } }

html.offline body::after {
  content: "Đang mất mạng · vẫn chơi được với máy, câu đố và học cờ"; position: fixed; left: 0; right: 0; top: 0; z-index: 95;
  padding: 3px 10px; background: #7a5a14; color: #fff; font: 600 12px/1.4 var(--font); text-align: center;
}

.mobile-dock, .more-sheet { display: none; }
.kbd { display: inline-block; min-width: 1.4em; padding: 0 4px; border-radius: 5px; background: #ffffff14; text-align: center; }

@media (max-width: 700px) {
  :root { --dock-h: 62px; }
  body { padding-bottom: calc(var(--dock-h) + env(safe-area-inset-bottom)); }
  .topbar .tabs { display: none; }
  .topbar { grid-template-columns: auto 1fr; padding-top: max(8px, env(safe-area-inset-top)); }
  .topbar-right { justify-content: flex-end; }
  .mobile-dock {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
    height: calc(var(--dock-h) + env(safe-area-inset-bottom)); padding: 4px 4px env(safe-area-inset-bottom);
    background: #1f1e1cf2; border-top: 1px solid #ffffff12; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  }
  .dock-item {
    position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    min-width: 0; padding: 4px 2px; border: none; border-radius: 10px; background: none; box-shadow: none;
    color: #a9a6a0; font-size: 0.68rem; font-weight: 700; line-height: 1.1;
  }
  .dock-item[hidden] { display: none; }
  .dock-item .ic { width: 23px; height: 23px; }
  .dock-item span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .dock-item.on { color: #fff; }
  .dock-item.on .ic { color: var(--accent); }
  .dock-item.on::before { content: ""; position: absolute; top: 0; left: 28%; right: 28%; height: 3px; border-radius: 0 0 3px 3px; background: var(--accent); }
  .dock-item .nav-badge { position: absolute; top: 2px; left: calc(50% + 6px); margin: 0; }
  .dock-more .ic { fill: currentColor; stroke: none; }
  body.more-open .mobile-dock { z-index: 61; }
  .more-sheet { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; background: #000a; }
  .more-sheet[hidden] { display: none; }
  .more-box {
    width: 100%; padding: 8px 12px calc(var(--dock-h) + env(safe-area-inset-bottom) + 10px);
    border-radius: 18px 18px 0 0; background: var(--panel-2); box-shadow: 0 -10px 40px #000a; animation: sheet-up 0.18s ease-out;
  }
  .more-grab { display: block; width: 40px; height: 4px; margin: 2px auto 10px; border-radius: 4px; background: #ffffff30; }
  .more-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .more-item {
    display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 4px; border-radius: 12px;
    background: #ffffff08; border: 1px solid #ffffff0d; box-shadow: none; color: var(--text); font-size: 0.8rem; font-weight: 700; text-align: center;
  }
  .more-item .ic { width: 24px; height: 24px; color: var(--gold); }
  .more-item .nav-badge { margin: 0; }
  .toast, .toast-copy { bottom: calc(var(--dock-h) + env(safe-area-inset-bottom) + 12px); }
  /* Đang làm bài học: ẩn thanh dưới để tập trung (như Duolingo) */
  body[data-mode="learn"][data-learn="lesson"] .mobile-dock { display: none; }
  body[data-mode="learn"][data-learn="lesson"] { padding-bottom: env(safe-area-inset-bottom); }
  .footer { display: none; }
}
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .more-box { animation: none; } }

/* Ứng dụng đã cài: không cần nút cài, chừa vùng tai thỏ khi xoay ngang */
html.standalone .install-btn, html.standalone .hm-install { display: none; }
/* Chỉ trên điện thoại / máy tính bảng: màn hình rộng có thanh bên trái, padding-left phải giữ đúng bằng --nav-w */
@media (max-width: 999px) {
  html.standalone body { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
}

.install-box { width: min(100%, 520px); }
.install-steps { display: grid; gap: 12px; margin-top: 8px; }
.install-steps section { padding: 12px 14px; border-radius: 12px; background: #00000030; }
.install-steps h3 { margin: 0 0 6px; font-size: 0.95rem; }
.install-steps ol { margin: 0; padding-left: 20px; line-height: 1.6; color: #d8d5cd; }

/* ======================================================================
   Trợ lý AI (assistant.js)
   ====================================================================== */
.ai-box { width: min(100%, 760px); }
.ai-body { display: flex; flex-direction: column; gap: 14px; margin-top: 6px; }
.ai-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.ai-stats > div { display: flex; flex-direction: column; gap: 2px; padding: 10px; border-radius: 12px; background: #00000030; text-align: center; }
.ai-stats b { font-size: 1.35rem; font-weight: 800; }
.ai-stats small { color: var(--muted); font-size: 0.75rem; }
.ai-stats .up { color: #a6d36b; } .ai-stats .down { color: #ff8f7e; }
@media (max-width: 560px) { .ai-stats { grid-template-columns: repeat(2, 1fr); } }
.ai-note { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; background: #f5b83d14; box-shadow: inset 0 0 0 1px #f5b83d33; font-size: 0.88rem; line-height: 1.45; }
.ai-note span { flex: 1; }
.ai-note button { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
@media (max-width: 560px) { .ai-note { flex-direction: column; align-items: stretch; } }
.ai-sec { display: flex; flex-direction: column; gap: 8px; }
.ai-sec h3 { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 1rem; }
.ai-sec h3 .ic { width: 18px; height: 18px; color: var(--gold); }
.ai-road { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.ai-road li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: #ffffff07; border: 1px solid #ffffff0d; }
.ai-step-n { flex: none; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: #fff; font-size: 0.75rem; font-weight: 800; }
.ai-step-ic { flex: none; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: #00000035; }
.ai-step-ic .ic { width: 19px; height: 19px; color: var(--gold); }
.ai-step-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ai-step-text small { color: var(--muted); line-height: 1.4; }
.ai-road button { flex: none; white-space: nowrap; }
@media (max-width: 560px) { .ai-road li { flex-wrap: wrap; } .ai-step-text { flex-basis: calc(100% - 80px); } .ai-road button { flex: 1; } }
.ai-bar { display: block; height: 8px; border-radius: 8px; background: #00000040; overflow: hidden; }
.ai-bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #f5b83d, #e2533f); }
.ai-bar.err i { background: linear-gradient(90deg, #f5b83d, #e2533f); }
.ai-weak { display: flex; flex-direction: column; gap: 8px; }
.ai-weak-row { display: grid; grid-template-columns: minmax(150px, 220px) 1fr; align-items: center; gap: 4px 12px; padding: 8px 10px; border-radius: 10px; background: #ffffff05; }
.ai-weak-row small { grid-column: 1 / -1; color: var(--muted); }
.ai-weak-row.hot { box-shadow: inset 3px 0 0 #e2533f; } .ai-weak-row.warm { box-shadow: inset 3px 0 0 #f5b83d; }
.ai-weak-name { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; }
.ai-weak-name .ic { width: 16px; height: 16px; color: var(--muted); }
.ai-phase { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ai-phase > div { display: flex; flex-direction: column; gap: 6px; padding: 10px; border-radius: 10px; background: #00000030; }
.ai-phase small { color: var(--muted); font-size: 0.78rem; }
@media (max-width: 560px) { .ai-phase { grid-template-columns: 1fr; } }
.ai-ops { display: flex; flex-direction: column; gap: 6px; }
.ai-op { display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 2px 10px; padding: 8px 10px; border-radius: 10px; background: #ffffff05; }
.ai-op small { grid-column: 2; grid-row: 2; color: var(--muted); }
.ai-op .pz-side { grid-row: 1 / 3; }
.ai-op .ai-score { grid-row: 1 / 3; font-weight: 800; }
.ai-op button { grid-row: 1 / 3; padding: 6px 12px; }
.ai-score.good { color: #a6d36b; } .ai-score.bad { color: #ff8f7e; }
.ai-chat { display: flex; flex-direction: column; gap: 8px; max-height: 340px; overflow-y: auto; padding: 4px; }
.ai-msg { margin: 0; max-width: 88%; padding: 9px 12px; border-radius: 14px; line-height: 1.5; font-size: 0.9rem; }
.ai-msg.me { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.ai-msg.bot { align-self: flex-start; background: #ffffff0d; border-bottom-left-radius: 4px; }
.ai-msg ol, .ai-msg ul { margin: 6px 0 0; padding-left: 20px; }
.ai-msg li { margin-bottom: 6px; }
.ai-inline { display: inline-flex; margin: 6px 6px 0 0; padding: 5px 10px; font-size: 0.8rem; border-radius: 99px; }
.ai-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ai-chips button { padding: 6px 12px; border-radius: 99px; font-size: 0.82rem; background: #ffffff0a; border: 1px solid #ffffff14; box-shadow: none; }
.ai-form { display: flex; gap: 8px; }
.ai-form input { flex: 1; min-width: 0; }
.ai-form button { display: grid; place-items: center; padding: 0 14px; }
.ai-privacy { margin: 0; color: var(--muted); font-size: 0.75rem; }
.ai-msg.bot p { margin: 0 0 6px; } .ai-msg.bot p:last-child { margin-bottom: 0; }
.ai-msg code { padding: 0 4px; border-radius: 4px; background: #00000040; font-size: 0.85em; }
.ai-acts { display: flex; flex-wrap: wrap; }
.ai-refs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin-top: 8px; }
.ai-refs small { color: var(--muted); }
.ai-ref-chip { padding: 2px 8px; border-radius: 99px; font-size: 0.74rem; background: #ffffff08; border: 1px solid #ffffff14; box-shadow: none; color: var(--muted); }
.ai-ref { margin-top: 8px; padding: 8px 10px; border-radius: 10px; background: #00000026; }
.ai-ref p { margin: 4px 0 0; color: #d8d5cd; }
.ai-stop { background: #ffffff10; box-shadow: none; }
.ai-steps { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.ai-steps span { padding: 2px 8px; border-radius: 99px; font-size: 0.72rem; color: var(--muted); background: #00000030; }
.ai-steps span::before { content: '✓ '; color: var(--accent); }
.ai-typing { display: flex; gap: 4px; padding: 4px 0; }
.ai-typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: ai-dot 1s infinite ease-in-out; }
.ai-typing span:nth-child(2) { animation-delay: 0.15s; } .ai-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes ai-dot { 0%, 80%, 100% { opacity: 0.25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .ai-typing span { animation: none; opacity: 0.6; } }
.ai-engine { margin-bottom: 4px; }
.ai-engine-note { margin: 0; padding: 10px 12px; border-radius: 10px; background: #ffffff08; color: var(--muted); font-size: 0.82rem; line-height: 1.5; }
.ai-engine-on { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 12px; background: #81b64c14; box-shadow: inset 0 0 0 1px #81b64c40; }
.ai-engine-on > span:nth-child(2) { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ai-engine-on small { color: var(--muted); font-size: 0.75rem; }
.ai-engine-on.warn { background: #f5b83d14; box-shadow: inset 0 0 0 1px #f5b83d40; }
.ai-engine-on.warn .ai-dot { background: #f5b83d; box-shadow: 0 0 0 3px #f5b83d33; }
.ai-dot { width: 9px; height: 9px; border-radius: 50%; background: #81b64c; box-shadow: 0 0 0 3px #81b64c33; flex: none; }
.ai-kb { display: flex; flex-direction: column; gap: 8px; }
.kb-search input { width: 100%; }
.kb-topics button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.kb-list { display: flex; flex-direction: column; gap: 6px; max-height: 360px; overflow-y: auto; }
.kb-item { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 9px 12px; border-radius: 10px; background: #ffffff06; border: 1px solid #ffffff0f; box-shadow: none; text-align: left; color: var(--text); }
.kb-item small { color: var(--muted); font-weight: 500; line-height: 1.4; }
.kb-article { display: flex; flex-direction: column; gap: 6px; padding: 12px; border-radius: 12px; background: #ffffff06; }
.kb-article h4 { margin: 0; font-size: 1.05rem; }
.kb-article p { margin: 0; line-height: 1.6; color: #d8d5cd; }
.kb-topic { color: var(--accent); font-weight: 700; text-transform: uppercase; font-size: 0.7rem; letter-spacing: 0.04em; }
.kb-back { align-self: flex-start; display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; }
.kb-acts { display: flex; flex-wrap: wrap; }
.hm-ai { background: linear-gradient(135deg, #1f2a3a, #262421 60%); box-shadow: inset 0 0 0 1px #6aa0ff33, 0 4px 14px #0004; }
.hm-ai-text { margin: 0; color: #d8d5cd; line-height: 1.5; font-size: 0.9rem; }
.hm-ai-step { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border-radius: 12px; background: #00000030; border: 1px solid #ffffff10; box-shadow: none; text-align: left; color: var(--text); }
.hm-ai-step > span:nth-child(2) { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.hm-ai-step small { color: var(--muted); font-weight: 500; }
.hm-ai-step > .ic { width: 18px; height: 18px; color: var(--muted); }

/* ======================================================================
   Thanh bên trái tự cân đối (màn hình rộng ≥ 1000px)
   • Bàn cờ lấy đúng phần còn trống: rộng cửa sổ − thanh bên − khung bên phải − khoảng hở, để hai khối luôn nằm cạnh nhau
     (không còn bị thanh bên che mất cột a, b).
   • Cửa sổ 1000–1199px: thanh bên thu gọn thành cột biểu tượng (rê chuột để xem tên), nhường chỗ cho bàn cờ.
   • Màn hình thấp: các mục trong thanh bên sít lại để không phải cuộn.
   ====================================================================== */
@media (min-width: 1000px) {
  :root {
    --side-w: 400px;
    --board-size: min(calc(100vh - 170px), 760px, max(420px, calc(100vw - var(--nav-w) - var(--side-w) - 112px)));
  }
  .panel { width: var(--side-w); }
  .topbar { scrollbar-width: thin; scrollbar-color: #ffffff22 transparent; }
  .topbar::-webkit-scrollbar { width: 6px; }
  .topbar::-webkit-scrollbar-thumb { background: #ffffff22; border-radius: 6px; }
  .tab { position: relative; }
}
@media (min-width: 1000px) and (max-width: 1279px) {
  :root { --side-w: 340px; }
}
@media (min-width: 1000px) and (max-width: 1199px) {
  :root { --nav-w: 76px; }
  .topbar { padding: 12px 8px; align-items: center; }
  .brand { padding: 2px 0 12px; justify-content: center; }
  .brand .wordmark { display: none; }
  .topbar .tabs { width: 100%; }
  .topbar .tab { justify-content: center; padding: 11px 0; }
  .topbar .tab > span:not(.nav-badge) { display: none; }
  .topbar .tab .nav-badge { position: absolute; top: 3px; right: 6px; margin: 0; padding: 0 4px; min-width: 16px; font-size: 0.62rem; }
  .topbar-right { width: 100%; align-items: center; }
  .topbar .icon-btn { justify-content: center; padding: 10px 0; width: 100%; }
  .topbar .icon-btn > span:not(.header-rank-icon):not(.ic) { display: none; }
  .topbar .profile-chip { justify-content: center; padding: 6px 0; }
  .topbar .profile-chip .profile-text, .topbar .profile-chip .header-rank-badge { display: none; }
}
@media (min-width: 1000px) and (max-height: 820px) {
  .topbar { gap: 2px; padding-top: 10px; padding-bottom: 10px; }
  .brand { padding-bottom: 8px; }
  .brand img { width: 30px; height: 30px; }
  .tab { padding-top: 7px; padding-bottom: 7px; font-size: 0.95rem; }
  .topbar-right { gap: 2px; padding-top: 8px; }
  .icon-btn { padding-top: 7px; padding-bottom: 7px; }
}
@media (min-width: 1000px) and (max-height: 660px) {
  .tab { padding-top: 5px; padding-bottom: 5px; }
  .tab .ic { width: 20px; height: 20px; }
}

/* ======================================================================
   Chữ logo "Royal Gambit": ROYAL (Cinzel Decorative, vàng như huy hiệu) trên GAMBIT (giãn chữ, bạc)
   ====================================================================== */
.wordmark.wm-logo {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1;
  background: none;
  color: inherit;
  -webkit-background-clip: border-box;
  background-clip: border-box;
  letter-spacing: 0;
}
.wm-logo .wm-a, .wordmark.wm-inline {
  font-family: "Cinzel Decorative", "Cinzel", serif;
  font-weight: 900;
  letter-spacing: 0.05em;
  background: linear-gradient(180deg, #fbe7a1 0%, #e2b54f 42%, #b07e24 74%, #eccb73 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 1px 0 #0009);
}
.wm-logo .wm-a { font-size: 1.32em; }
.wm-logo .wm-b {
  font-family: "Cinzel", serif;
  font-weight: 700;
  font-size: 0.6em;
  letter-spacing: 0.52em;
  margin-top: 0.22em;
  padding-left: 0.1em;
  background: linear-gradient(180deg, #ffffff 10%, #cfc9bb 60%, #9f988a);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.auth-brand .wordmark.wm-logo { align-items: center; font-size: 1.55rem; }
.auth-brand .wm-logo .wm-b { padding-left: 0.52em; }

/* ======================================================================
   Trang Trợ lý Royal Gambit: gọn, một phần mỗi lúc (Trò chuyện · Lộ trình · Ván đấu · Kiến thức)
   ====================================================================== */
.brand .wordmark.wm-logo { font-size: 1.3rem; }
.brand .wm-logo .wm-b { font-size: 0.56em; letter-spacing: 0.6em; }
@media (min-width: 1000px) and (max-width: 1199px) { .brand .wordmark { display: none; } .brand { justify-content: center; } }

body[data-page="coach"] .layout { display: none; }
.coach-page[hidden], .coach-page [hidden] { display: none !important; }
.coach-page {
  --cp-w: 880px;
  width: min(100%, 1100px);
  margin: 0 auto;
  padding: 18px 20px 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.coach-page h1, .coach-page h2, .coach-page h3 { margin: 0; }

/* Đầu trang mỏng */
.cp-head { display: flex; align-items: center; gap: 14px; }
.cp-crest { width: 48px; height: 48px; flex: none; border-radius: 13px; box-shadow: 0 0 0 1px #f5b83d4d, 0 6px 16px #0008; }
.cp-head-text { flex: 1; min-width: 0; }
.cp-title { font-size: 1.4rem; font-weight: 800; color: #fff; line-height: 1.15; }
.cp-title .wm-inline { font-size: 0.92em; }
.cp-status { margin: 4px 0 0; display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 0.8rem; font-weight: 600; }
.cp-status .ai-dot { width: 8px; height: 8px; background: #8b867c; box-shadow: 0 0 0 3px #8b867c26; }
.cp-status.on { color: #b9dc8f; }
.cp-status.on .ai-dot { background: #81b64c; box-shadow: 0 0 0 3px #81b64c33; }
.cp-status.warn { color: #f5c76a; }
.cp-status.warn .ai-dot { background: #f5b83d; box-shadow: 0 0 0 3px #f5b83d33; }
.cp-mini { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.cp-mini span { padding: 6px 11px; border-radius: 99px; background: #ffffff0a; box-shadow: inset 0 0 0 1px #ffffff0f; color: var(--muted); font-size: 0.8rem; font-weight: 600; white-space: nowrap; }
.cp-mini b { color: #fff; font-weight: 800; font-variant-numeric: tabular-nums; }

/* Thanh thẻ */
.cp-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 14px;
  background: #1d1c19;
  box-shadow: inset 0 0 0 1px #ffffff0d;
  position: sticky;
  top: 0;
  z-index: 5;
}
.cp-tabs button {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 8px;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--muted);
  background: transparent;
  box-shadow: none;
  transition: background 0.15s, color 0.15s;
}
.cp-tabs button:hover { color: var(--text); background: #ffffff08; }
.cp-tabs button .ic { width: 17px; height: 17px; }
.cp-tabs button[aria-selected="true"] { color: #fff; background: #2f2c28; box-shadow: inset 0 0 0 1px #ffffff14, 0 2px 6px #0005; }
.cp-tabs button[aria-selected="true"] .ic { color: var(--gold); }

/* Mỗi lúc một phần */
.cp-pane { display: none; flex-direction: column; gap: 14px; width: 100%; max-width: var(--cp-w); margin: 0 auto; min-width: 0; }
.coach-page[data-pane="chat"] [data-cp-pane="chat"],
.coach-page[data-pane="plan"] [data-cp-pane="plan"],
.coach-page[data-pane="games"] [data-cp-pane="games"],
.coach-page[data-pane="kb"] [data-cp-pane="kb"] { display: flex; }
.coach-page[data-pane="kb"] [data-cp-pane="kb"] { max-width: 1060px; }

.cp-card { display: flex; flex-direction: column; gap: 12px; min-width: 0; padding: 18px; border-radius: 16px; background: #262421; box-shadow: inset 0 1px 0 #ffffff0d, 0 4px 14px #0003; }
.cp-card-title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 1rem; font-weight: 800; color: #fff; }
.cp-card-title .ic { width: 18px; height: 18px; color: var(--gold); }
.cp-card-title small { flex-basis: 100%; color: var(--muted); font-weight: 500; font-size: 0.82rem; }
.cp-card-title small:empty { display: none; }
.cp-sub { font-size: 0.78rem; color: var(--muted); font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; }
.cp-empty { margin: 0; font-size: 0.88rem; line-height: 1.55; }
.cp-two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: start; }

/* Trò chuyện */
.cp-chat-pane { height: calc(100dvh - 196px); min-height: 480px; gap: 10px; }
.cp-chat { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 22px; padding: 8px 4px 12px; scroll-behavior: smooth; scrollbar-width: thin; }
.cp-chat.empty { justify-content: center; }
.cp-chat .ai-msg { margin: 0; font-size: 0.95rem; line-height: 1.65; }
.cp-chat .ai-msg.me { align-self: flex-end; max-width: 78%; padding: 10px 15px; border-radius: 18px 18px 4px 18px; background: var(--accent); color: #fff; }
.cp-chat .ai-msg.me p { margin: 0; white-space: pre-wrap; }
.cp-chat .ai-msg.bot { display: flex; align-items: flex-start; gap: 12px; max-width: 100%; padding: 0; background: none; }
.cp-avatar { flex: none; width: 32px; height: 32px; margin-top: 2px; border-radius: 10px; overflow: hidden; box-shadow: 0 0 0 1px #f5b83d40; }
.cp-avatar img { width: 100%; height: 100%; display: block; }
.cp-msg-body { flex: 1; min-width: 0; color: #e7e3da; }
.cp-msg-body p { margin: 0 0 8px; }
.cp-msg-body p:last-child { margin-bottom: 0; }
.cp-msg-body ul, .cp-msg-body ol { margin: 4px 0 10px; padding-left: 20px; }
.cp-msg-body li { margin-bottom: 5px; }
.cp-msg-body b { color: #fff; }
.cp-msg-body p > b:only-child { display: inline-block; margin-top: 4px; font-size: 1.02rem; }

/* Lời chào khi chưa có cuộc trò chuyện */
.cp-hello { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 12px 4px; }
.cp-hello-crest { width: 60px; height: 60px; border-radius: 16px; box-shadow: 0 0 0 1px #f5b83d55, 0 10px 26px #000a; }
.cp-hello h2 { margin-top: 6px; font-size: 1.35rem; font-weight: 800; color: #fff; line-height: 1.3; }
.cp-hello p { margin: 0; max-width: 520px; color: var(--muted); font-size: 0.92rem; line-height: 1.55; }
.cp-suggest { width: 100%; max-width: 640px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 14px; }
.cp-suggest button {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 12px;
  row-gap: 2px;
  align-items: center;
  padding: 14px 16px;
  border-radius: 14px;
  text-align: left;
  color: var(--text);
  background: #262421;
  border: 1px solid #ffffff12;
  box-shadow: none;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
}
.cp-suggest button:hover { border-color: #f5b83d66; background: #2c2925; transform: translateY(-1px); }
.cp-suggest .ic { grid-row: 1 / 3; width: 34px; height: 34px; padding: 8px; border-radius: 10px; color: var(--gold); background: #f5b83d17; }
.cp-suggest b { font-size: 0.92rem; font-weight: 800; }
.cp-suggest small { color: var(--muted); font-size: 0.78rem; font-weight: 500; line-height: 1.35; }
.cp-suggest small:empty { display: none; }

/* Ô nhập */
.cp-dock { display: flex; flex-direction: column; gap: 8px; }
.cp-quick { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; mask-image: linear-gradient(90deg, #000 90%, transparent); -webkit-mask-image: linear-gradient(90deg, #000 90%, transparent); padding-right: 28px; }
.cp-quick::-webkit-scrollbar { display: none; }
.cp-quick button {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 99px;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
  background: #ffffff09;
  border: 1px solid #ffffff14;
  box-shadow: none;
  color: var(--text);
}
.cp-quick button:hover { border-color: #f5b83d66; }
.cp-quick .ic { width: 14px; height: 14px; color: var(--gold); }
.cp-quick .cp-new { color: var(--muted); }
.cp-quick .cp-new .ic { color: var(--muted); }
.cp-composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 6px 6px 6px 18px;
  border-radius: 22px;
  background: #262421;
  border: 1px solid #ffffff17;
  box-shadow: 0 6px 18px #0004;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.cp-composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow), 0 6px 18px #0004; }
.cp-composer textarea {
  flex: 1;
  min-width: 0;
  height: 42px;
  min-height: 0;
  max-height: 160px;
  resize: none;
  padding: 10px 0;
  border: 0;
  outline: none;
  background: transparent;
  box-shadow: none;
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  line-height: 1.45;
}
.cp-composer button { width: 42px; height: 42px; flex: none; display: grid; place-items: center; padding: 0; border-radius: 50%; }
.cp-dock .ai-privacy { text-align: center; font-size: 0.72rem; line-height: 1.45; }

/* Các bước tra cứu, bàn cờ minh hoạ, nút gợi ý trong câu trả lời */
.ai-steps { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.ai-steps span { white-space: nowrap; padding: 3px 9px; border-radius: 99px; font-size: 0.72rem; color: var(--muted); background: #ffffff08; }
.ai-steps span::before { content: '✓ '; color: var(--accent); }
.cp-boards { display: flex; flex-wrap: wrap; gap: 14px; margin: 12px 0 4px; }
.cp-board { margin: 0; width: min(240px, 100%); display: flex; flex-direction: column; gap: 6px; }
.cp-board figcaption { color: var(--muted); font-size: 0.78rem; line-height: 1.35; }
.cp-board button { align-self: flex-start; display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; font-size: 0.76rem; }
.cp-board .ic { width: 13px; height: 13px; }
.cp-msg-body .ai-acts { display: flex; flex-wrap: wrap; margin-top: 4px; }
.cp-msg-body .ai-refs { margin-top: 10px; }

/* Lộ trình */
.cp-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.cp-stats div { padding: 14px 10px; border-radius: 14px; background: #262421; box-shadow: inset 0 1px 0 #ffffff0d; text-align: center; min-width: 0; }
.cp-stats b { display: block; font-size: 1.4rem; font-weight: 800; color: #fff; font-variant-numeric: tabular-nums; }
.cp-stats small { color: var(--muted); font-size: 0.76rem; font-weight: 600; }
.cp-stats .up { color: #a6d36b; } .cp-stats .down { color: #ff8f7e; }

/* Ván đấu */
.cp-games { display: flex; flex-direction: column; gap: 8px; }
.cp-game { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; background: #ffffff06; border: 1px solid #ffffff0a; }
.cp-res { flex: none; min-width: 52px; padding: 5px 0; border-radius: 8px; text-align: center; font-size: 0.76rem; font-weight: 800; background: #ffffff12; color: var(--muted); }
.cp-res.win { background: #81b64c2b; color: #a6d36b; }
.cp-res.loss { background: #e2533f2b; color: #ff8f7e; }
.cp-game-text { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.cp-game-text b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.93rem; }
.cp-game-text small { color: var(--muted); font-size: 0.78rem; }
.cp-game-btns { display: flex; gap: 6px; flex: none; }
.cp-game-btns button { display: inline-flex; align-items: center; gap: 5px; padding: 7px 12px; font-size: 0.8rem; }
.cp-game-btns .ic { width: 14px; height: 14px; }

/* Thư viện kiến thức */
.ai-kb { gap: 12px; }
.kb-search { position: relative; }
.kb-search .ic { position: absolute; left: 14px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.kb-search input { width: 100%; padding-left: 42px; border-radius: 12px; }
.kb-topics { display: flex; flex-wrap: wrap; gap: 6px; }
.kb-topics button { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 99px; font-size: 0.82rem; font-weight: 700; background: #ffffff09; border: 1px solid #ffffff14; box-shadow: none; color: var(--text); }
.kb-topics button small { color: var(--muted); font-weight: 700; font-size: 0.72rem; }
.kb-topics button .ic { width: 14px; height: 14px; color: var(--gold); }
.kb-topics button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.kb-topics button.on small, .kb-topics button.on .ic { color: #fff; }
.kb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.kb-grid .kb-item { display: flex; flex-direction: column; align-items: flex-start; gap: 5px; padding: 14px 16px; border-radius: 12px; background: #ffffff06; border: 1px solid #ffffff10; box-shadow: none; text-align: left; color: var(--text); transition: border-color 0.15s, transform 0.15s, background 0.15s; }
.kb-grid .kb-item:hover { border-color: #f5b83d55; background: #f5b83d0b; transform: translateY(-1px); }
.kb-grid .kb-item b { font-size: 0.95rem; line-height: 1.35; }
.kb-grid .kb-item span { color: var(--muted); font-size: 0.82rem; line-height: 1.45; font-weight: 500; }
.kb-topic { display: inline-flex; align-items: center; gap: 5px; color: var(--gold); font-weight: 800; text-transform: uppercase; font-size: 0.68rem; letter-spacing: 0.05em; }
.kb-topic .ic { width: 13px; height: 13px; }
.kb-article { max-width: 760px; display: flex; flex-direction: column; gap: 10px; }
.kb-article h3 { font-size: 1.35rem; color: #fff; }
.kb-article p { margin: 0; font-size: 1rem; line-height: 1.8; color: #e2ded5; }
.kb-back { align-self: flex-start; display: inline-flex; align-items: center; gap: 4px; padding: 5px 12px; }
.kb-acts { display: flex; flex-wrap: wrap; }
.kb-acts .ai-inline { display: inline-flex; align-items: center; gap: 6px; }
.kb-acts .ic { width: 14px; height: 14px; }
.kb-related { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding-top: 10px; border-top: 1px solid #ffffff10; }
.kb-related small { color: var(--muted); font-weight: 700; margin-right: 4px; }

/* Cửa sổ hẹp / điện thoại */
@media (max-width: 999px) {
  .coach-page { padding: 12px 12px 16px; gap: 10px; }
  .cp-crest { width: 40px; height: 40px; border-radius: 11px; }
  .cp-title { font-size: 1.15rem; }
  .cp-mini { display: none; }
  .cp-tabs button { flex-direction: column; gap: 3px; padding: 7px 4px; font-size: 0.72rem; }
  .cp-chat-pane { height: calc(100dvh - 250px); min-height: 400px; }
  .cp-chat { gap: 18px; }
  .cp-chat .ai-msg { font-size: 0.93rem; }
  .cp-chat .ai-msg.me { max-width: 86%; }
  .cp-avatar { width: 28px; height: 28px; border-radius: 8px; }
  .cp-chat .ai-msg.bot { gap: 10px; }
  .cp-hello h2 { font-size: 1.15rem; }
  .cp-hello p { font-size: 0.86rem; }
  .cp-suggest { grid-template-columns: minmax(0, 1fr); gap: 8px; margin-top: 8px; }
  .cp-suggest button { padding: 11px 13px; }
  .cp-suggest .ic { width: 30px; height: 30px; padding: 7px; }
  .cp-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .cp-two { grid-template-columns: minmax(0, 1fr); }
  .cp-card { padding: 14px; }
  .cp-game { flex-wrap: wrap; gap: 8px 10px; }
  .cp-game-btns { width: 100%; }
  .cp-game-btns button { flex: 1; justify-content: center; }
  .kb-grid { grid-template-columns: minmax(0, 1fr); }
}
.cp-hello h2, .cp-card-title { text-transform: none; letter-spacing: 0; }
@media (max-width: 999px) {
  .cp-chat-pane { height: calc(100dvh - 268px); min-height: 380px; }
  .cp-dock .ai-privacy { font-size: 0.68rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
}

/* ======================================================================
   Chỉ còn hai kiểu thanh điều hướng:
   • Điện thoại (≤ 700px): thanh dưới đáy (Trang chủ, Chơi, Học cờ, Câu đố, Trợ lý, Khác). Hồ sơ, Rank, Ngôn ngữ, Cài ứng dụng
     nằm trong "Khác", nên bỏ hẳn thanh trên cùng.
   • Từ 701px trở lên: thanh bên trái. 701–1199px thu gọn thành cột biểu tượng (rê chuột để xem tên), ≥ 1200px đầy đủ.
   Không còn kiểu thanh thẻ nằm ngang trên đầu.
   ====================================================================== */
@media (max-width: 700px) {
  .topbar { display: none; }
  body { padding-top: env(safe-area-inset-top); }
  .contest-banner { top: 0; }
}
@media (min-width: 701px) and (max-width: 999px) {
  :root { --nav-w: 76px; --board-size: min(calc(100vw - var(--nav-w) - 92px), calc(100vh - 200px), 720px); } /* trừ thêm thanh đánh giá cạnh bàn */
  body, html.standalone body { padding-left: var(--nav-w); }
  .topbar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    width: var(--nav-w);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px 8px;
    background: #262421;
    border: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    overflow-y: auto;
    scrollbar-width: none;
  }
  .topbar::-webkit-scrollbar { display: none; }
  .brand { padding: 2px 0 12px; justify-content: center; }
  .brand img { width: 40px; height: 40px; border-radius: 10px; }
  .brand .wordmark { display: none; }
  .topbar .tabs {
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 2px;
    padding: 0;
    overflow: visible;
    background: none;
    border: none;
    border-radius: 0;
    grid-column: auto;
    grid-row: auto;
  }
  .topbar .tab { position: relative; flex: none; width: 100%; justify-content: center; padding: 11px 0; border-radius: 6px; color: #c3c2c1; }
  .topbar .tab .ic { width: 22px; height: 22px; }
  .topbar .tab > span:not(.nav-badge) { display: none; }
  .topbar .tab .nav-badge { position: absolute; top: 3px; right: 6px; margin: 0; padding: 0 4px; min-width: 16px; font-size: 0.62rem; }
  .topbar .tab:hover { background: #1f1e1c; color: #fff; }
  .topbar .tab[aria-selected="true"] { background: var(--accent); color: #fff; box-shadow: 0 3px 0 var(--accent-dark); }
  .topbar-right { width: 100%; margin-top: auto; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 6px; padding-top: 12px; border-top: 1px solid #ffffff10; }
  .topbar .icon-btn { width: 100%; justify-content: center; padding: 10px 0; color: #c3c2c1; }
  .topbar .icon-btn > span:not(.header-rank-icon):not(.ic) { display: none; }
  .topbar .icon-btn:hover { background: #1f1e1c; color: var(--gold); }
  .topbar .profile-chip { width: 100%; justify-content: center; padding: 6px 0; border-radius: 8px; background: #1f1e1c; border: none; }
  .topbar .profile-chip .profile-text, .topbar .profile-chip .header-rank-badge { display: none; }
  .contest-banner { top: 0; }
  .toast, .update-bar { left: calc(50% + var(--nav-w) / 2); }
}

/* Thư viện kiến thức: xem lại từng nước của ván cờ nổi tiếng */
.kb-game { display: grid; grid-template-columns: minmax(220px, 300px) minmax(0, 1fr); gap: 16px; align-items: start; padding: 12px; border-radius: 14px; background: #00000026; }
.kb-game-board { display: flex; flex-direction: column; gap: 8px; }
.kg-nav { display: flex; align-items: center; gap: 4px; }
.kg-nav button { padding: 5px 9px; font-size: 0.8rem; }
.kg-nav span { flex: 1; text-align: center; font-size: 0.82rem; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.kb-game-side { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.kg-meta { font-size: 0.88rem; color: var(--muted); }
.kg-meta b { color: #fff; }
.kg-moves { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 3px; max-height: 260px; overflow-y: auto; padding: 8px; border-radius: 10px; background: #00000030; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.84rem; scrollbar-width: thin; }
.kg-no { color: var(--muted); margin-left: 4px; }
.kg-mv { padding: 1px 5px; border-radius: 5px; background: none; border: none; box-shadow: none; color: var(--text); font: inherit; }
.kg-mv:hover { background: #ffffff12; }
.kg-mv.on { background: var(--accent); color: #fff; }
.kg-acts button { display: inline-flex; align-items: center; gap: 5px; padding: 6px 12px; font-size: 0.8rem; }
.kg-acts .ic { width: 14px; height: 14px; }
@media (max-width: 700px) { .kb-game { grid-template-columns: minmax(0, 1fr); } .kb-game-board { max-width: 340px; margin: 0 auto; width: 100%; } }
a.ai-ref-chip { text-decoration: none; }
a.ai-ref-chip:hover { color: var(--text); border-color: #ffffff30; }
/* Bảng kết quả sau ván: nút Trợ lý thành thẻ riêng, tách hẳn khỏi hai nút Ván mới / Xem bàn cờ */
.result-ask { margin: 18px 0 0; }
.result-ask[hidden] { display: none; }
.result-coach-ask {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; border-radius: 14px; text-align: left; color: #fff;
  background: linear-gradient(135deg, #3b321d, #2a2722 70%); border: 1px solid #f5b83d59; box-shadow: 0 6px 18px #0006;
  transition: border-color 0.15s, transform 0.15s;
}
.result-coach-ask:hover { border-color: var(--gold); transform: translateY(-1px); }
.rca-ic { flex: none; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; background: #f5b83d24; box-shadow: inset 0 0 0 1px #f5b83d40; }
.rca-ic .ic { width: 20px; height: 20px; color: var(--gold); }
.rca-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.rca-text b { font-size: 0.95rem; font-weight: 800; }
.rca-text small { color: var(--muted); font-size: 0.76rem; font-weight: 500; line-height: 1.35; }
.rca-go { flex: none; width: 18px; height: 18px; color: var(--gold); }
.result-ask:not([hidden]) + .buttons.two { margin-top: 18px; padding-top: 18px; border-top: 1px solid #ffffff14; }
#resultModal .buttons.two { gap: 10px; }
/* Vòng quay luôn tròn: không bị dòng chữ dài bên cạnh ép co lại */
.spinner { flex: none; box-sizing: border-box; aspect-ratio: 1; }
.rc-loading .spinner { width: 20px; height: 20px; border-width: 3px; }
.result-coach { padding: 14px 16px; border-radius: 14px; background: #1f1e1c; box-shadow: inset 0 0 0 1px #ffffff0d; }
.rc-loading { line-height: 1.4; }
.result-coach .progress { height: 6px; border-radius: 99px; overflow: hidden; background: #00000040; }
.result-coach .progress-bar { border-radius: 99px; }
.result-review { padding: 14px 16px; border-radius: 14px; background: #00000033; border: 1px solid #ffffff10; }
.result-review p { font-size: 0.9rem; line-height: 1.55; }
.result-review .rv-tag { padding: 3px 10px; font-size: 0.74rem; }
.hist-ai .ic { color: var(--gold); }

/* ---------- Bảng nhận xét sau ván (bản đẹp hơn) ---------- */
.result-review { padding: 16px 18px; border-radius: 16px; background: linear-gradient(180deg, #2a2824, #22201d); border: 1px solid #ffffff12; box-shadow: inset 0 1px 0 #ffffff0d; }
.result-review h3 { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; font-size: 0.82rem; letter-spacing: 0.06em; color: #b9dc8f; }
.rv-h-ic { width: 28px; height: 28px; flex: none; display: grid; place-items: center; border-radius: 9px; background: #81b64c26; }
.rv-h-ic .ic { width: 16px; height: 16px; color: var(--accent); }
.rv-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.result-review .rv-tag { display: inline-flex; align-items: center; gap: 6px; margin: 0; padding: 4px 11px; border-radius: 99px; font-size: 0.76rem; font-weight: 700; background: #ffffff10; color: var(--muted); }
.result-review .rv-tag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.result-review .rv-tag.good { background: #81b64c26; color: #b5e37a; }
.result-review .rv-tag.bad { background: #e2533f26; color: #ff8f7e; }
.result-review .rv-tag.mid { background: #f5b83d24; color: #f5c76a; }
.result-review .rv-lead { margin: 0 0 10px; font-size: 1rem; font-weight: 700; color: #fff; line-height: 1.5; }
.rv-points { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.rv-points li { position: relative; padding-left: 18px; font-size: 0.88rem; line-height: 1.55; color: #dcd8cf; }
.rv-points li::before { content: ""; position: absolute; left: 3px; top: 0.6em; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px #81b64c26; }
.rv-tip { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 12px; background: #f5b83d14; border: 1px solid #f5b83d33; }
.rv-tip > .ic { flex: none; width: 18px; height: 18px; margin-top: 2px; color: var(--gold); }
.rv-tip span { font-size: 0.86rem; line-height: 1.5; color: #e9e3d4; }
.rv-tip b { display: block; margin-bottom: 1px; font-size: 0.72rem; letter-spacing: 0.05em; text-transform: uppercase; color: var(--gold); }

/* ---------- Ô ghi chú trong Lộ trình: thẻ vàng có biểu tượng, cách hẳn danh sách bên dưới ---------- */
#cpPlan { display: flex; flex-direction: column; gap: 16px; }
.ai-note {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: 14px;
  background: linear-gradient(135deg, #3a301a, #2a2620 75%); box-shadow: inset 0 0 0 1px #f5b83d4d, 0 6px 16px #0004;
}
.ai-note-ic { flex: none; width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; background: #f5b83d22; box-shadow: inset 0 0 0 1px #f5b83d45; }
.ai-note-ic .ic { width: 21px; height: 21px; color: var(--gold); }
.ai-note-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.ai-note-text b { color: #fff; font-size: 0.95rem; }
.ai-note-text b::first-letter { text-transform: uppercase; }
.ai-note-text small { color: #c9c2b2; font-size: 0.82rem; line-height: 1.45; }
.ai-note-btn {
  flex: none; display: inline-flex; align-items: center; gap: 7px; padding: 10px 16px; border: none; border-radius: 11px; white-space: nowrap;
  font-weight: 800; color: #2b1f04; background: linear-gradient(180deg, #ffd36b, #f0b33a); box-shadow: 0 3px 0 #a87a1a, 0 6px 14px #f5b83d33;
  transition: transform 0.12s, filter 0.12s;
}
.ai-note-btn:hover { filter: brightness(1.06); transform: translateY(-1px); }
.ai-note-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #a87a1a; }
.ai-note-btn:disabled { filter: grayscale(0.4) brightness(0.85); cursor: default; transform: none; }
.ai-note-btn .ic { width: 17px; height: 17px; }
@media (max-width: 560px) { .ai-note { flex-wrap: wrap; } .ai-note-text { flex-basis: calc(100% - 60px); } .ai-note-btn { flex: 1; justify-content: center; } }
/* Ô biểu tượng không được giãn theo quy tắc cũ ".ai-note span { flex: 1 }"; điện thoại giữ hàng ngang (biểu tượng + chữ), nút xuống dòng */
.ai-note .ai-note-ic { flex: none; width: 42px; height: 42px; }
.ai-note .ai-note-text { flex: 1 1 0; }
@media (max-width: 560px) {
  .ai-note { flex-direction: row; flex-wrap: wrap; align-items: center; }
  .ai-note .ai-note-text { flex: 1 1 calc(100% - 60px); }
  .ai-note .ai-note-btn { flex: 1 1 100%; justify-content: center; }
}

/* Studio giao diện: chọn bàn + quân, xem trước bằng chính CSS của bàn thật */
.skin-box { max-width: 640px; width: 100%; }
.skin-preview {
  --board-size: min(56vw, 264px);
  --frame: 0px;
  position: sticky; /* cuộn xuống chọn quân vẫn thấy xem trước */
  top: 0;
  z-index: 5;
  width: var(--board-size);
  height: calc(var(--board-size) * 0.75);
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(3, 1fr);
  margin: 4px auto 18px;
  touch-action: auto;
  flex: none;
}
.skin-preview .piece { cursor: default; }
.skin-combos { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; margin-bottom: 8px; }
.theme.combo { width: 100%; }
.theme.combo span {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: auto; aspect-ratio: 16 / 10;
  border-radius: 10px; overflow: hidden;
}
.theme.combo span img { width: 46%; height: auto; display: block; }
#skinBody .themes { margin-bottom: 8px; }
.result-share { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; margin-top: 10px; }

/* Bàn rất tối: quân đen thường (không tự phát sáng) có viền sáng mảnh để không chìm vào ô tối */
body:is([data-board="neon"], [data-board="cosmos"], [data-board="lava"], [data-board="gilded"]):not([data-pieces="neon"], [data-pieces="ice"], [data-pieces="fire"], [data-pieces="gold"], [data-pieces="galaxy"], [data-pieces="cyber"]) .board .piece[src*="/b"] {
  filter: drop-shadow(0 0 max(0.6px, calc(var(--board-size) / 500)) #ffffffd9) drop-shadow(0 0 max(0.6px, calc(var(--board-size) / 500)) #ffffff80);
}
.contest-retry { display: block; margin: 10px auto 0; }
/* Bàn nổi 3D đặt position: relative cho .board: phần xem trước vẫn phải dính ở đầu hộp */
#skinModal .board.skin-preview { position: sticky; top: 0; z-index: 5; }
.search-elo { margin: 0; color: var(--gold); font-size: 13px; font-weight: 600; min-height: 1.3em; }
@media (max-width: 700px) { #onlineSearching .radar, #onlineSearching > p.muted { display: none; } } /* điện thoại: để khoảng Elo và nút Hủy không bị đẩy khỏi màn hình */

/* Khung avatar: ảnh SVG đè lên avatar, lớn hơn 50% (không làm xô lệch bố cục), quầng sáng thở nhẹ phía sau */
/* Đeo khung thì tắt viền màu quanh avatar: khung thay cho viền đó, nếu không viền sẽ ló ra ngoài các khung mảnh */
.avatar.framed { position: relative; overflow: visible; box-shadow: none !important; }
.avatar.framed img.av-frame {
  position: absolute; left: -25%; top: -25%; width: 150%; height: 150%; max-width: none;
  border-radius: 0; object-fit: fill; pointer-events: none; z-index: 2;
}
.avatar.framed .av-glow {
  position: absolute; inset: -8%; border-radius: 26%; pointer-events: none; z-index: 1;
  box-shadow: 0 0 12px 1px var(--fg);
  opacity: .3;
  animation: av-glow 3.2s ease-in-out infinite;
}
@keyframes av-glow { 50% { opacity: .8; } }
@media (prefers-reduced-motion: reduce) { .avatar.framed .av-glow { animation: none; } }
.frame-box { margin: 12px 0; }
.frame-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 10px; }
.frame-opt {
  display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0;
  padding: 22px 6px 10px; border-radius: 12px; background: var(--panel-2); border: 1.5px solid transparent;
  box-shadow: none; color: var(--text); text-align: center;
}
.frame-opt:hover { background: var(--panel-3); }
.frame-opt.on { border-color: var(--accent); background: #81b64c1f; }
.frame-opt .avatar { width: 60px; height: 60px; font-size: 1.5rem; border-radius: 13px; margin-bottom: 18px; }
.frame-opt b { font-size: .86rem; line-height: 1.2; }
.frame-opt small { color: var(--muted); font-size: .72rem; line-height: 1.25; font-weight: 500; }
.frame-opt.on small { color: var(--accent); }
.frame-modal-box { max-width: 560px; width: 100%; }
.frame-revoke { display: block; margin: 12px auto 0; }
.frame-revoke[hidden] { display: none; }
.pf-avatar-wrap .pf-avatar-edit { z-index: 3; } /* nút đổi ảnh luôn nằm trên khung avatar */
.pf-avatar-wrap:has(.avatar.framed) { margin: 12px 18px 12px 14px; } /* ô avatar lớn: chừa chỗ để khung không sát mép thẻ, không chạm tên */
.avatar.hm-avatar.framed { margin: 12px 18px 12px 14px; }
/* Danh sách: chừa chỗ để khung không sát số thứ hạng và tên */
/* Áp dụng cho mọi avatar trong danh sách, có khung hay không, để tên luôn thẳng hàng */
.rank-name .avatar, .admin-who .avatar, .hm-top-row .avatar, .avatar.sm.framed, .profile-chip .avatar.framed { margin-inline: 6px; }
.podium-step .avatar.framed { margin-block: 6px 10px; box-shadow: none; } /* có khung thì không cần viền màu huy chương */

/* Chọn khung avatar: sân khấu xem khung đang đeo, bên dưới là bộ sưu tập */
.frame-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.frame-count { color: var(--muted); font-size: .78rem; font-weight: 600; }
.frame-picker { display: grid; gap: 12px; }
.frame-stage {
  --fc: #9d988e;
  position: relative;
  display: flex;
  align-items: center;
  gap: 28px;
  min-height: 132px;
  padding: 22px 16px 22px 32px;
  border-radius: 16px;
  overflow: hidden;
  background:
    radial-gradient(110% 150% at 14% 50%, color-mix(in srgb, var(--fc) 34%, transparent), transparent 64%),
    linear-gradient(135deg, #2b2924, #1b1a17);
  border: 1px solid color-mix(in srgb, var(--fc) 40%, #ffffff10);
  transition: border-color .25s;
}
/* Ô cờ mờ ở góc phải, cùng ngôn ngữ với thẻ hồ sơ */
.frame-stage::after {
  content: "";
  position: absolute;
  inset: 0 0 0 45%;
  background: repeating-conic-gradient(#ffffff0a 0 25%, transparent 0 50%) 0 0 / 28px 28px;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000);
  mask-image: linear-gradient(90deg, transparent, #000);
  pointer-events: none;
}
.frame-stage .avatar { width: 76px; height: 76px; font-size: 2rem; border-radius: 17px; }
.frame-stage.pop .avatar { animation: frame-pop .32s cubic-bezier(.2, 1.3, .4, 1); }
@keyframes frame-pop { from { transform: scale(.86); } to { transform: none; } }
.fs-text { position: relative; z-index: 1; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.fs-text small { color: var(--fc); font-size: .7rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; transition: color .25s; }
.fs-text b { font-size: 1.22rem; line-height: 1.2; color: var(--text); }
.fs-text span { color: #c9c5bb; font-size: .82rem; line-height: 1.35; }
.frame-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.frame-tiles[data-saving] { cursor: progress; }
.frame-tile {
  --fc: #9d988e;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 13px;
  min-width: 0;
  padding: 19px 4px 9px;
  border-radius: 14px;
  background: #24221e;
  border: 1.5px solid #ffffff0d;
  box-shadow: none;
  color: #c9c5bb;
  transition: transform .15s, border-color .15s, background .15s, color .15s;
}
.frame-tile:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--fc) 60%, transparent); background: #2b2925; color: var(--text); }
.frame-tile:active { transform: none; box-shadow: none; }
.frame-tile:focus-visible { outline: 2px solid var(--fc); outline-offset: 2px; }
.frame-tile .avatar { width: 46px; height: 46px; font-size: 1.15rem; border-radius: 10px; }
.frame-tile:not(.on) .avatar:not(.framed) { opacity: .75; }
.frame-tile b { font-size: .76rem; line-height: 1.2; font-weight: 700; text-align: center; }
.frame-tile.on {
  border-color: var(--fc);
  color: var(--text);
  background: radial-gradient(95% 80% at 50% 38%, color-mix(in srgb, var(--fc) 26%, transparent), transparent 80%), #24221e;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--fc) 22%, transparent);
}
/* Dấu tích ô đang đeo */
.frame-tile.on::after {
  content: "";
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 3;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--fc) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23141311' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12.5 4.500 4.500L19 7.500'/%3E%3C/svg%3E") center / 13px no-repeat;
  box-shadow: 0 1px 3px #0008;
}
@media (prefers-reduced-motion: reduce) {
  .frame-stage.pop .avatar { animation: none; }
  .frame-tile { transition: none; }
}
