* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: #1a1b2e;
  color: #e8e9f3;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}
header h1 {
  font-size: 22px;
  letter-spacing: 4px;
  padding: 18px 0 8px;
  color: #f9c74f;
  text-shadow: 0 2px 8px rgba(249, 199, 79, .3);
}
#langRow { display: flex; gap: 6px; justify-content: center; padding-bottom: 6px; }
#langRow button { flex: none; padding: 4px 12px; font-size: 11px; background: #262741; color: #9a9cc0; }
#langRow button.on { background: #577590; color: #fff; }

/* lobby */
#lobby {
  margin-top: 60px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 320px;
}
#lobby .row { display: flex; gap: 8px; }
input, button {
  font: inherit;
  border: none;
  border-radius: 8px;
  padding: 10px 14px;
}
input { background: #262741; color: #e8e9f3; width: 100%; }
select {
  font: inherit; border: none; border-radius: 8px; padding: 10px 12px;
  background: #262741; color: #e8e9f3; cursor: pointer; flex: 1;
}
input::placeholder { color: #6a6c8f; }
button { background: #577590; color: #fff; cursor: pointer; font-weight: 600; flex: 1; }
button:hover { background: #6b8cae; }
#codeInput { width: 90px; flex: none; text-transform: uppercase; text-align: center; }
#statsBox { background: #12141f; border: 1px solid #2a2f4a; border-radius: 8px; padding: 8px 12px; margin-top: 8px; font-size: 12px; }
#statsBox .srow { display: flex; justify-content: space-between; padding: 2px 0; color: #8a90b8; }
#statsBox .srow b { color: #cfd3f0; font-weight: 600; }
#statsBox .srow:first-child span, #statsBox .srow:first-child b { color: #5fd97a; }
img.flag { width: 17px; height: auto; border-radius: 2px; vertical-align: -3px; margin-right: 4px; }
.flag-btn { margin-top: 6px; display: flex; align-items: center; justify-content: center; gap: 5px; }
.flag-btn img.flag { width: 20px; margin: 0; }
.fg-none { color: #6a6c8f; font-size: 11px; }
#flagGrid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; margin: 10px 0; max-height: 300px; overflow-y: auto; }
.fg-cell { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 7px 2px; background: #171a2b; border: 1px solid #2a2f4a; border-radius: 6px; cursor: pointer; color: #8a90b8; font-size: 10px; }
.fg-cell:hover { border-color: #7a86d8; }
.fg-cell img { width: 26px; border-radius: 2px; }
.fg-cell.none { justify-content: center; color: #8a8fb8; }
#lobbyStatus { text-align: center; color: #90be6d; min-height: 22px; font-size: 14px; }
#lobbyStatus .code { font-size: 24px; letter-spacing: 6px; color: #f9c74f; font-weight: 700; }
#profileBox {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 20px;
  background: #23243d;
  border: 1px solid #2e3050;
  border-radius: 14px;
  padding: 14px;
}
#statGrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.stat-group { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; padding: 6px; background: rgba(255,255,255,.03); border: 1px solid rgba(255,255,255,.07); border-radius: 10px; }
.stat-group.two { grid-column: span 2; grid-template-columns: repeat(2, 1fr); }
.sg-head { grid-column: 1 / -1; text-align: center; font-size: 11px; letter-spacing: 2px; color: #8b8fb8; margin-bottom: 2px; }
.sg-head b { color: #f9c74f; font-size: 16px; font-variant-numeric: tabular-nums; margin-left: 6px; }
.stat { background: #262741; border: 1px solid #2e3050; border-radius: 8px; padding: 8px 2px; text-align: center; }
.statV { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.statV.sm { font-size: 11px; line-height: 19px; }
.statV.win { color: #90be6d; }
.statV.draw { color: #9a9cc0; }
.statV.loss { color: #f94144; }
.statL { font-size: 10px; color: #6a6c8f; margin-top: 3px; }
#myCode { font-size: 12px; color: #9a9cc0; text-align: center; }
#myCode b { color: #f9c74f; letter-spacing: 2px; font-family: monospace; font-size: 15px; }
#restoreInput, #pwInput, #pwCur, #restorePw { font-size: 12px; padding: 8px 10px; }
#restorePw, #pwCur { flex: none; width: 80px; }
.restore-btn { flex: none; padding: 8px 14px; font-size: 13px; background: #3a3b5e; }
.restore-btn:hover { background: #4a4b75; }

#lbBox {
  margin-top: 14px;
  background: #23243d;
  border: 1px solid #2e3050;
  border-radius: 14px;
  padding: 14px;
}
#lbTitle { font-size: 13px; font-weight: 700; letter-spacing: 2px; color: #8b8fb8; text-align: center; margin-bottom: 10px; }
#lbTabs { display: flex; gap: 6px; justify-content: center; margin-bottom: 10px; }
.lb-tab { padding: 5px 12px; font-size: 11px; border-radius: 99px; background: #262741; border: 1px solid #2e3050; color: #9a9cc0; }
.lb-tab:hover { background: #2e3050; }
.lb-tab.on { background: #3a4b75; color: #e8e9f5; border-color: #4a5b8e; }
.lb-row { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; font-size: 12px; }
.lb-row:nth-child(odd) { background: rgba(255,255,255,.025); }
.lb-row.me { background: rgba(249,199,79,.08); outline: 1px solid rgba(249,199,79,.3); }
.lb-rank { width: 20px; text-align: right; color: #6a6c8f; font-weight: 700; font-variant-numeric: tabular-nums; }
.lb-row:nth-child(1) .lb-rank { color: #f9c74f; }
.lb-row:nth-child(2) .lb-rank { color: #c9cadf; }
.lb-row:nth-child(3) .lb-rank { color: #c98d5e; }
#lbPages { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; margin-top: 8px; }
.lb-pg { padding: 3px 8px; border-radius: 6px; font-size: 11px; color: #8b8fb8; cursor: pointer; background: rgba(255,255,255,.04); }
.lb-pg:hover { background: rgba(255,255,255,.09); }
.lb-pg.on { color: #f9c74f; background: rgba(249,199,79,.12); outline: 1px solid rgba(249,199,79,.35); }
.lb-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #d6d8ee; }
.lb-val { font-variant-numeric: tabular-nums; color: #9a9cc0; font-weight: 600; }
.lb-val .w { color: #90be6d; } .lb-val .d { color: #9a9cc0; } .lb-val .l { color: #f94144; }
.lb-empty { text-align: center; color: #6a6c8f; font-size: 12px; padding: 14px 4px; }
.statV.rtg { color: #f9c74f; }
.statV.stk { color: #f3722c; }

#recentBox {
  margin-top: 14px;
  background: #23243d;
  border: 1px solid #2e3050;
  border-radius: 14px;
  padding: 12px 14px;
}
#recentTitle { font-size: 12px; font-weight: 700; letter-spacing: 2px; color: #8b8fb8; text-align: center; margin-bottom: 8px; }
.rc-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 7px; font-size: 12px; }
.rc-row:nth-child(odd) { background: rgba(255,255,255,.025); }
.rc-date { color: #6a6c8f; font-variant-numeric: tabular-nums; flex: none; }
.rc-vs { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #d6d8ee; }
.rc-score { color: #6a6c8f; font-variant-numeric: tabular-nums; margin-left: 6px; }
.rc-res { flex: none; font-weight: 700; }
.rc-res .w { color: #90be6d; }
.rc-res .d { color: #9a9cc0; }
.rc-res .l { color: #f94144; }
.rc-mode { flex: none; font-size: 9px; padding: 2px 6px; border-radius: 4px; letter-spacing: 1px; }
.rc-mode.q { background: rgba(249,199,79,.12); color: #f9c74f; }
.rc-mode.r { background: rgba(255,255,255,.05); color: #8b8fb8; }
.rc-rd { margin-left: 6px; font-variant-numeric: tabular-nums; color: #9a9cc0; }
.rc-rd.up { color: #90be6d; }
.rc-rd.dn { color: #f94144; }

#termsLink { font-size: 11px; color: #6a6c8f; text-align: center; text-decoration: none; }
#termsLink:hover { color: #9a9cc0; }

/* game */
#game { display: flex; gap: 20px; padding: 12px; }
.board-wrap { background: #23243d; border-radius: 12px; padding: 4px; }
#cv { display: block; border-radius: 10px; touch-action: none; }
aside { width: 190px; display: flex; flex-direction: column; gap: 12px; }
#timer {
  font-size: 34px;
  font-weight: 700;
  text-align: center;
  font-variant-numeric: tabular-nums;
  color: #90be6d;
}
#timer.urgent { color: #f94144; }
.panel { background: #262741; border-radius: 10px; padding: 12px; text-align: center; }
.pname { font-size: 13px; color: #9a9cc0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prec { font-size: 11px; color: #6a6c8f; margin-bottom: 2px; }
.prec .w { color: #90be6d; }
.prec .d { color: #9a9cc0; }
.prec .l { color: #f94144; }
.pscore { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; }
.plines { font-size: 12px; color: #6a6c8f; margin-bottom: 6px; }
.pcombo { font-size: 13px; font-weight: 700; color: #f9c74f; min-height: 17px; }
.pcombo.on { animation: comboPulse .5s ease; }
@keyframes comboPulse {
  0% { transform: scale(1); }
  40% { transform: scale(1.35); }
  100% { transform: scale(1); }
}
#opcv { border-radius: 6px; background: #1a1b2e; transition: filter .3s; }
#opcv.dead { filter: grayscale(1) brightness(.55); }
.oppstatus { font-size: 12px; color: #f94144; min-height: 16px; }
#msg { font-size: 13px; color: #f9c74f; text-align: center; min-height: 34px; }

/* mobile */
@media (max-width: 700px) {
  #game { flex-direction: column; align-items: center; }
  #cv { max-width: min(94vw, 400px); height: auto; }
  .board-wrap { width: fit-content; }
  aside { width: min(94vw, 400px); flex-direction: row; flex-wrap: wrap; gap: 8px; }
  #timer { flex: 1 1 100%; font-size: 26px; }
  .panel { flex: 1; padding: 8px; }
  .pscore { font-size: 22px; }
  #opcv { width: 100%; height: auto; }
  #msg { flex: 1 1 100%; min-height: 20px; }
  #btnLeave { flex: 1 1 100%; }
  #lobby { width: min(320px, 92vw); margin-top: 30px; }
}

/* end overlay */
#endov {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 25, .8);
  display: flex;
  align-items: center;
  justify-content: center;
}
.endbox {
  background: #262741;
  border-radius: 16px;
  padding: 36px 48px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
#endTitle { font-size: 34px; }
#endScores { font-size: 16px; line-height: 1.9; font-variant-numeric: tabular-nums; }
#endScores .win { color: #90be6d; }
#endScores .lose { color: #f94144; }
[hidden] { display: none !important; }

/* tier icons */
.ticon { width: 15px; height: 15px; vertical-align: -3px; margin-right: 3px; }
.sg-tier { margin-left: 4px; font-weight: 700; color: #f9c74f; }

/* prematch intro overlay */
#prematch {
  position: fixed; inset: 0; z-index: 30;
  background: rgba(10, 10, 25, .92);
  display: flex; align-items: center; justify-content: center;
}
.pm-box { display: flex; flex-direction: column; align-items: center; gap: 20px; }
#pmCount { font-size: 64px; font-weight: 800; color: #f9c74f; text-shadow: 0 0 30px rgba(249,199,79,.4); }
.pm-cards { display: flex; align-items: center; gap: 22px; }
.pm-card {
  min-width: 150px; padding: 18px 22px; text-align: center;
  background: #262741; border: 1px solid rgba(255,255,255,.08); border-radius: 14px;
  display: flex; flex-direction: column; align-items: center; gap: 5px;
}
.pm-icon { width: 52px; height: 52px; margin-bottom: 4px; }
.pm-name { font-size: 15px; font-weight: 700; color: #e7e8f6; }
.pm-tier { font-size: 12px; font-weight: 700; color: #f9c74f; }
.pm-rate { font-size: 12px; color: #8b8fb8; font-variant-numeric: tabular-nums; }
.pm-rec { font-size: 12px; font-variant-numeric: tabular-nums; }
.pm-rec .w { color: #90be6d; } .pm-rec .d { color: #9a9cc0; } .pm-rec .l { color: #f94144; }
.pm-vs { font-size: 22px; font-weight: 800; color: #5f6190; }
.pm-hint { font-size: 12px; color: #6a6c8f; }

/* account deletion */
.del-btn { margin-top: 8px; font-size: 11px; padding: 6px 10px; color: #f94144; background: rgba(249,65,68,.08); border: 1px solid rgba(249,65,68,.35); }
.del-btn:hover { background: rgba(249,65,68,.18); }
#delov {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(10, 10, 25, .9);
  display: flex; align-items: center; justify-content: center;
}
.delbox {
  width: min(340px, 92vw); padding: 26px 24px;
  background: #262741; border: 1px solid rgba(249,65,68,.3); border-radius: 14px;
  display: flex; flex-direction: column; gap: 14px;
}
#delWarn { font-size: 13px; line-height: 1.7; color: #e7a0a8; white-space: pre-line; }
#delov input { width: 100%; box-sizing: border-box; }
.del-btns { display: flex; gap: 8px; }
.del-btns button { flex: 1; }
#btnDelOk { background: rgba(249,65,68,.15); border-color: rgba(249,65,68,.45); color: #f94144; font-weight: 700; }
#btnDelOk:disabled { opacity: .35; cursor: default; }
#btnDelOk:not(:disabled):hover { background: rgba(249,65,68,.3); }

/* level / xp */
.stat-group.xp { display: flex; flex-direction: column; gap: 6px; }
.xp-head { font-size: 14px; font-weight: 800; color: #e7e8f6; }
.xp-head .star { color: #f9c74f; }
.xp-bar { height: 7px; border-radius: 99px; background: rgba(255,255,255,.07); overflow: hidden; }
.xp-bar div { height: 100%; border-radius: 99px; background: linear-gradient(90deg, #f3722c, #f9c74f); transition: width .4s; }
.xp-num { font-size: 10px; color: #8b8fb8; font-variant-numeric: tabular-nums; }
.xp-gain { color: #f9c74f; font-weight: 700; }

/* tier info */
.sg-info {
  display: inline-flex; align-items: center; justify-content: center;
  width: 15px; height: 15px; margin-left: 6px; border-radius: 50%;
  font-size: 10px; font-weight: 700; color: #8b8fb8;
  border: 1px solid rgba(255,255,255,.25); cursor: pointer; vertical-align: 2px;
}
.sg-info:hover { color: #e7e8f6; border-color: rgba(255,255,255,.5); }
#tierov {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(10, 10, 25, .9);
  display: flex; align-items: center; justify-content: center;
}
.tierbox {
  width: min(360px, 92vw); max-height: 85vh; overflow-y: auto; padding: 24px;
  background: #262741; border: 1px solid rgba(255,255,255,.1); border-radius: 14px;
  display: flex; flex-direction: column; gap: 14px;
}
#tierTitle { font-size: 17px; font-weight: 800; color: #f9c74f; text-align: center; }
#tierTable { display: flex; flex-direction: column; gap: 4px; }
.ti-row { display: grid; grid-template-columns: 26px 1fr auto; align-items: center; gap: 10px; padding: 5px 8px; border-radius: 7px; }
.ti-row:nth-child(odd) { background: rgba(255,255,255,.025); }
.ti-row img { width: 22px; height: 22px; }
.ti-name { font-size: 12px; font-weight: 700; }
.ti-range { font-size: 11px; color: #8b8fb8; font-variant-numeric: tabular-nums; }
#tierRules { display: flex; flex-direction: column; gap: 5px; font-size: 11px; color: #9a9cc0; line-height: 1.6; border-top: 1px solid rgba(255,255,255,.07); padding-top: 12px; }

#fxbg {
  position: fixed; inset: 0; z-index: -1;
  width: 100vw; height: 100vh; pointer-events: none;
}

#clockBox {
  position: fixed; top: 10px; left: 12px; z-index: 10;
  display: flex; align-items: center; gap: 6px;
}
#srvClock {
  font-size: 11px; color: #6a6c8f; font-variant-numeric: tabular-nums;
  background: rgba(10,10,25,.5); padding: 3px 8px; border-radius: 6px;
}
#btnFx {
  flex: none; padding: 3px 8px; font-size: 10px; font-weight: 400;
  background: rgba(10,10,25,.5); color: #6a6c8f; border-radius: 6px;
}
#btnFx:hover { color: #bfc2e8; background: rgba(20,20,45,.7); }

button.danger { background: #a03540; }
button.danger:hover { background: #c04752; }
.cancel-flash { color: #f94144; font-weight: 600; }

.mini-btn { padding: 6px 10px; font-size: 11px; font-weight: 500; background: #262741; color: #9a9cc0; }
.mini-btn:hover { background: #2e3050; color: #e7e8f6; }
.mini-btn.off { color: #6a6c8f; }

#myCodeRow { display: flex; align-items: center; gap: 8px; }
#myCodeRow #myCode { flex: 1; }
#btnShowCode { flex: none; padding: 4px 10px; font-size: 10px; font-weight: 400; background: rgba(255,255,255,.05); color: #9a9cc0; }
#btnShowCode:hover { color: #e7e8f6; background: rgba(255,255,255,.1); }

#codeov {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(10, 10, 25, .9);
  display: flex; align-items: center; justify-content: center;
}
#codeov[hidden] { display: none; }
#codeWarnT { font-size: 15px; font-weight: 700; color: #f94144; margin-bottom: 10px; }
#codeWarn { font-size: 12px; color: #c9cbe4; line-height: 1.7; white-space: pre-line; margin-bottom: 16px; }

#siteFoot { max-width: 480px; margin: 28px auto 20px; padding: 20px 24px; font-size: 11px; line-height: 1.7; color: #6a6c8f; text-align: center; background: rgba(255,255,255,.03); border: 1px solid rgba(255,255,255,.06); border-radius: 12px; }
#siteFoot .foot-title { font-weight: 800; letter-spacing: 3px; font-size: 13px; color: #8b8fb8; margin-bottom: 10px; }
#siteFoot .foot-tags { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-bottom: 12px; }
#siteFoot .foot-tags span { padding: 3px 10px; border-radius: 99px; background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.08); font-size: 10px; color: #9a9cc0; }
#siteFoot p { margin: 0 0 12px; }
#siteFoot a { color: #6a6c8f; text-decoration: none; }
#siteFoot a:hover { color: #bfc2e8; }
#footTerms, #footCredits { color: #7fb4d8 !important; text-decoration: underline; }
#footTerms:hover, #footCredits:hover { color: #a8d4f0 !important; }
#siteFoot a[href^="mailto:"] { color: #e7e8f6 !important; }
#siteFoot a[href^="mailto:"]:hover { color: #ffffff !important; }

.how-btn { margin-bottom: 8px; font-size: 12px; color: #8b8fb8; background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.08); }
.how-btn:hover { color: #e7e8f6; background: rgba(255,255,255,.09); }
#howov, #flagov {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(10, 10, 25, .9);
  display: flex; align-items: center; justify-content: center;
}
#flagTitle { font-size: 17px; font-weight: 800; color: #f9c74f; text-align: center; }
#howTitle { font-size: 17px; font-weight: 800; color: #f9c74f; text-align: center; }
#howRules { display: flex; flex-direction: column; gap: 7px; font-size: 12px; color: #c8cade; line-height: 1.65; }
