:root {
  --bg: #0f1216;
  --panel: #171c22;
  --panel2: #1d2430;
  --text: #e8edf2;
  --muted: #a7b1bd;
  --accent: #4ea1ff;
  --danger: #ff5c5c;
  --good: #4dff88;
  --border: #2b3442;
  --board-light: #263141;
  --board-dark: #1d2736;
  --piece-filter: drop-shadow(0 2px 1px rgba(0,0,0,0.55));
  --overlay: rgba(0,0,0,0.35);
  --ring-bg: rgba(255,255,255,0.18);
  --fog-bg: #2b2f36;
  --fog-border: #0f1115;
  --fog-color: #f6f2ea;
}

.hidden { display: none !important; }

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Apple Color Emoji", "Segoe UI Emoji";
}

body.dragging{
  touch-action: none;
  overflow: hidden;
}

body.light{
  --bg: #e9e3da;
  --panel: #f5f1ea;
  --panel2: #ece5dc;
  --text: #1d2228;
  --muted: #465260;
  --accent: #1f6feb;
  --danger: #d13c3c;
  --good: #0a8f54;
  --border: #c7c0b7;
  --piece-filter: drop-shadow(0 1px 1px rgba(0,0,0,0.35));
  --overlay: rgba(0,0,0,0.22);
  --ring-bg: rgba(0,0,0,0.20);
  --fog-bg: #e9dfcf;
  --fog-border: #b59a73;
  --fog-color: #2b2f36;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar, .matchTopbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

.brandGroup{
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.welcome{
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
  letter-spacing: 0.2px;
}

.topActions{
  display: flex;
  align-items: center;
  gap: 10px;
}

.iconBtn{
  width: 44px;
  height: 44px;
  font-size: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel2);
  color: var(--text);
  cursor: pointer;
}
.iconBtn:hover{ filter: brightness(1.06); }
.iconBtn.hasAvatar{
  padding: 0;
}
.iconBtn .avatarImg{
  width: 100%;
  height: 100%;
  border-radius: 999px;
  object-fit: cover;
}
.gearIcon.hidden{
  display: none;
}

.cookieBanner{
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 2200;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 20px;
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 12px 30px rgba(0,0,0,0.25);
}
.cookieText{
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 720px;
}
.cookieTitle{
  font-weight: 700;
  font-size: 16px;
}
.cookieDesc{
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
}
.note.errorText{
  color: var(--danger);
}
.cookieActions{
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

@media (max-width: 680px){
  .cookieBanner{
    flex-direction: column;
    align-items: flex-start;
  }
  .cookieActions{
    width: 100%;
    justify-content: flex-end;
  }
}

.brand, .matchTitle {
  font-weight: 700;
  letter-spacing: 0.3px;
}

.brand{
  font-size: 22px;
}

.matchTitle{
  font-size: 22px;
}

.brandLink{
  color: var(--text);
  text-decoration: none;
}
.brandLink:hover{
  filter: brightness(1.08);
  text-decoration: none;
}

.endStatus{
  font-weight: 800;
  font-size: 14px;
}
.endStatus.win{ color: var(--good); }
.endStatus.lose{ color: var(--danger); }

.wallet, .walletMini {
  color: var(--muted);
}
.wallet span, .walletMini span { color: var(--text); font-weight: 700; }

.container {
  max-width: 900px;
  margin: 28px auto;
  padding: 0 18px;
}

.buyinRow {
  display: flex;
  gap: 16px;
  margin: 22px 0 16px;
}

.stakeToggle{
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 16px 0 18px;
}

.boardToggle{
  margin-top: 8px;
  margin-bottom: 14px;
}

.centerText{
  text-align: center;
}

.howToRow{
  display: flex;
  justify-content: center;
  margin: -6px 0 16px;
}

.howToList{
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 6px;
}

.howToItem{
  display: flex;
  align-items: center;
  gap: 12px;
}

.howToText{
  flex: 1;
}

.howToTitle{
  font-weight: 800;
  margin-bottom: 4px;
}

.howToDesc{
  color: var(--muted);
  font-size: 13px;
  line-height: 1.3;
}

.howToImg{
  width: 72px;
  height: 56px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel2);
}

@media (max-width: 560px){
  .howToItem{ align-items: flex-start; }
  .howToImg{ width: 64px; height: 48px; }
}

/* Rating */
.starRow{
  display: flex;
  gap: 6px;
  margin: 6px 0 10px;
}
.starBtn{
  width: 38px;
  height: 38px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel2);
  color: var(--muted);
  font-size: 20px;
  cursor: pointer;
}
.starBtn.active{
  color: #f0b429;
  border-color: #f0b429;
  background: rgba(240,180,41,0.12);
}
.starBtn:hover{
  color: #f0b429;
}

.toggleBtn{
  padding: 12px 20px;
  font-size: 18px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}
.toggleBtn.active{
  background: var(--panel2);
  border-color: var(--accent);
}

.stakeGrid{
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.stakeCard{
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.stakeTitle{
  font-weight: 800;
  font-size: 16px;
}
.stakeSub{
  color: var(--muted);
  font-size: 13px;
}

.lobbyModal{
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--overlay);
  z-index: 1000;
}

.timeSelect{
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.timeOption{
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel2);
  color: var(--text);
  cursor: pointer;
}
.timeOption.active{
  border-color: var(--accent);
}
.timeOption .radioDot{
  width: 16px;
  height: 16px;
  border-radius: 999px;
  border: 2px solid var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.timeOption.active .radioDot{
  border-color: var(--accent);
  background: radial-gradient(circle at center, var(--accent) 0 45%, transparent 48%);
}

.stackControl{
  display: flex;
  gap: 6px;
  align-items: center;
}

.stackControl input{
  width: 100%;
  height: 52px;
  font-size: 18px;
  text-align: center;
  border-radius: 10px;
}

.stepBtn{
  height: 44px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel2);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
}
.stepBtn:hover{ filter: brightness(1.06); }

.stackControl .stepBtn{
  width: 48px;
  height: 56px;
}

.lobbyModal .modalTitle{
  font-size: 18px;
}
.lobbyModal .modalSub{
  font-size: 15px;
}
.lobbyModal .timeOption{
  font-size: 15px;
}
.lobbyModal .stakeSub{
  font-size: 14px;
}

.settingsSection{
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}

.settingsTitle{
  font-weight: 800;
  font-size: 16px;
}

.settingsActions{
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.accountRow{
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 12px;
  align-items: center;
}

.avatarCircle{
  width: 56px;
  height: 56px;
  border-radius: 999px;
  background: var(--panel2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 22px;
  overflow: hidden;
}
.avatarCircle.avatarBtn{
  cursor: pointer;
}
.avatarCircle .avatarImg{
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 999px;
}
.avatarInitial{
  font-weight: 900;
  font-size: 22px;
}

.accountInfo{
  display: flex;
  flex-direction: column;
}
.accountNick{
  font-weight: 900;
}
.accountName{
  color: var(--muted);
  font-size: 13px;
}
.accountEmail{
  color: var(--muted);
  font-size: 13px;
}

.settingsList{
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.linkBtn.bigLink{
  font-size: 15px;
  padding: 10px 12px;
}

.settingsRow{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.adminGrid{
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 16px;
}
.adminBan{
  margin: 14px 0 18px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}
.adminCard{
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.4;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.12);
}
.adminMatchList{
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 50vh;
  overflow: auto;
}
.adminMatchItem{
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  background: var(--panel2);
}
.adminMatchNo{
  font-weight: 800;
}
.adminMatchMain{
  font-weight: 700;
}
.adminMatchMeta{
  color: var(--muted);
  font-size: 12px;
}
.adminCard h3{
  margin: 0 0 6px;
  color: var(--text);
  font-size: 14.5px;
  letter-spacing: 0.2px;
}
.adminRow{
  display: flex;
  gap: 10px;
  justify-content: space-between;
  flex-wrap: wrap;
}
.adminChart{
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.barRow{
  display: grid;
  grid-template-columns: 44px 1fr 120px;
  gap: 8px;
  align-items: center;
}
.barValue{
  text-align: right;
  font-weight: 700;
  color: var(--text);
}
.barTrack{
  height: 10px;
  border-radius: 999px;
  background: rgba(0,0,0,0.12);
  overflow: hidden;
}
.barFill{
  height: 100%;
  background: linear-gradient(90deg, #4ea1ff, #7ed3ff);
}
.barLabel{
  color: var(--text);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.adminCard.wide{
  grid-column: span 2;
}

.adminWideRow{
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(2, minmax(240px, 1fr));
  gap: 18px;
}

.adminPage h1{
  margin: 0;
}

.adminHeader{
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.adminSub{
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  margin-top: 2px;
}

.adminSectionTitle{
  font-weight: 900;
  font-size: 13px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--muted);
  margin: 12px 0 8px;
}

.adminNotice{
  margin: 8px 0 12px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  font-size: 13px;
  font-weight: 700;
}
.adminNotice.good{
  color: var(--good);
  border-color: rgba(77,255,136,0.35);
}
.adminNotice.bad{
  color: var(--danger);
  border-color: rgba(255,92,92,0.35);
}

.adminActions{
  margin-top: 10px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
}

@media (max-width: 820px){
  .adminGrid{ grid-template-columns: 1fr; }
  .adminCard.wide{ grid-column: span 1; }
  .barRow{ grid-template-columns: 40px 1fr 100px; }
  .adminWideRow{ grid-template-columns: 1fr; }
  .adminBan{ grid-template-columns: 1fr; }
}

.styleGrid{
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.speedRow{
  display: flex;
  flex-wrap: wrap;
  gap: 64px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.speedSelect{
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.speedOption{
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel2);
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
}
.speedOption.active{
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(78,161,255,0.15);
}

.speedPreviewWrap{
  display: flex;
  align-items: center;
  justify-content: flex-start;
  margin-top: 4px;
}

.speedPreview{
  width: min(60vw, 180px);
  height: auto;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel2);
}

.speedPreview.small{
  width: min(60vw, 180px);
}

.styleOption{
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  justify-content: center;
  padding: 14px 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
}
.styleOption:hover{ filter: brightness(1.04); }
.styleOption.active{
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(78,161,255,0.15);
}

.boardDot{
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: linear-gradient(90deg, var(--swatch-light) 0 50%, var(--swatch-dark) 50% 100%);
}

.pieceSwatch{
  width: 64px;
  height: 44px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel2);
  display: flex;
  align-items: center;
  justify-content: center;
}
.pieceSwatch img{
  width: 34px;
  height: 34px;
  filter: var(--preview-filter);
}

.resetCount{
  color: var(--muted);
  font-size: 13px;
}

.linkBtn{
  background: none;
  border: none;
  text-align: left;
  padding: 4px 0;
  color: var(--text);
  cursor: pointer;
}
.linkBtn:hover{ color: var(--accent); }
.linkBtn.disabled{
  opacity: 0.5;
  pointer-events: none;
}
.dangerText{ color: var(--danger); }

.inputField{
  width: 100%;
  height: 42px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel2);
  color: var(--text);
}

.inputArea{
  height: 150px;
  resize: none;
}

@media (max-width: 640px){
  .stakeGrid{ grid-template-columns: 1fr; }
  .stakeToggle{ flex-wrap: wrap; }
}

.bigBtn {
  flex: 1;
  padding: 18px 16px;
  font-size: 20px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}
.bigBtn:hover { background: var(--panel2); }

.statusBox {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  color: var(--muted);
}

.linksBox { margin-top: 12px; }
.linksTitle { color: var(--text); font-weight: 700; margin-bottom: 10px; }
.links { display: flex; gap: 18px; }
.note { margin-top: 10px; font-size: 13px; color: var(--muted); }

.matchLayout {
  display: grid;
  grid-template-columns: 220px 1fr 220px;
  gap: 14px;
  padding: 14px;
  max-width: 1200px;
  margin: 0 auto;
}

body.replayMode .matchTopbar,
body.replayMode .leftPanel,
body.replayMode .rightPanel,
body.replayMode .bottomLeftButtons,
body.replayMode .mobileControls,
body.replayMode #actionArea,
body.replayMode #mobileDrawer {
  display: none !important;
}

body.replayMode .matchLayout{
  grid-template-columns: 1fr;
  max-width: 760px;
}

body.replayMode .bottomControls{
  justify-content: center;
}

body.replayMode .boardWrap{
  pointer-events: none;
}

.leftPanel, .rightPanel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.potBox, .phaseBox, .stackBox, .messages {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  position: relative;
}

.potBox.hasAuctionInfo{
  padding-right: 140px;
}
.potBox.hasPortraitInfo{
  padding-right: 160px;
}

.potLabel, .stackLabel {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}
.potValue, .stackValue {
  font-size: 26px;
  font-weight: 800;
  margin-top: 6px;
}

.potAuctionInfo{
  position: absolute;
  right: 12px;
  top: 12px;
  margin-top: 0;
  font-size: 13px;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: right;
}

.potAuctionWinner{
  color: var(--text);
  font-weight: 800;
}

.auctionSideInfo{
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.auctionSideTitle{
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
  font-weight: 800;
}

.auctionSideLine{
  color: var(--muted);
  font-size: 13px;
}

.auctionSideWinner{
  color: var(--text);
  font-weight: 800;
  font-size: 13px;
}

.stackBox.own { margin-top: 0; }

.centerPanel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

/* Board always square */
.board {
  --board-size: 8;
  width: min(90vw, 560px);
  aspect-ratio: 1 / 1;
  height: auto;
  display: grid;
  grid-template-columns: repeat(var(--board-size), 1fr);
  grid-auto-rows: 1fr;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--panel2);
  user-select: none;
  -webkit-user-select: none;
  -ms-user-select: none;
}

.square {
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(16px, 3.2vh, 38px);
  user-select: none;
  position: relative;
}

.square.light { background: var(--board-light); }
.square.dark { background: var(--board-dark); }

.square.select {
  outline: 3px solid var(--accent);
  z-index: 1;
}
.square.target::after {
  content: "";
  width: 18%;
  height: 18%;
  border-radius: 999px;
  background: rgba(0,0,0,0.28);
  border: 1px solid rgba(0,0,0,0.35);
  position: absolute;
  mix-blend-mode: multiply;
  z-index: 10;
}

.square.placeTarget::after{
  content: "";
  width: 20%;
  height: 20%;
  border-radius: 999px;
  background: rgba(0,0,0,0.38);
  border: 1px solid rgba(0,0,0,0.45);
  position: absolute;
  mix-blend-mode: multiply;
  z-index: 12;
}

.square.capture::after{
  background: rgba(255,30,30,0.98);
  border-color: rgba(255,40,40,1);
  box-shadow: 0 0 10px rgba(255,60,60,0.95), 0 0 18px rgba(255,90,90,0.8);
  mix-blend-mode: normal;
  z-index: 11;
}

.square.check{
  box-shadow: inset 0 0 0 999px rgba(255,92,92,0.18);
}

.square.checkFlash{
  animation: checkFlash 0.35s ease;
}

@keyframes checkFlash{
  0% { box-shadow: inset 0 0 0 999px rgba(255,92,92,0.45); }
  100% { box-shadow: inset 0 0 0 999px rgba(255,92,92,0.18); }
}

input[type="number"] {
  width: 120px;
  padding: 10px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel2);
  color: var(--text);
}

select.input{
  height: 46px;
  padding: 10px 34px 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background-color: var(--panel2);
  color: var(--text);
  font-size: 15px;
  -webkit-appearance: none;
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 52%,
    calc(100% - 12px) 52%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

.speedCol{
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 210px;
}

.speedCol.modeCol{
  margin-left: 40px;
}

#moveModeSelect{
  margin-left: 0;
  width: 180px;
  max-width: 100%;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] {
  -moz-appearance: textfield;
}

.bottomControls{
  width: min(90vw, 560px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  position: relative;
  z-index: 1001;
}

.bottomLeftButtons {
  display: flex;
  justify-content: flex-start;
  gap: 10px;
  margin-bottom: 0px;
}

.bottomLeftButtons .smallBtn{
  padding: 14px 18px;
  font-size: 15px;
}

.smallBtn, .actionBtn {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel2);
  color: var(--text);
  cursor: pointer;
}
.smallBtn:hover, .actionBtn:hover { filter: brightness(1.06); }
.actionBtn.loading {
  opacity: 0.65;
  cursor: wait;
}

@keyframes btnPulse {
  0% { box-shadow: 0 0 0 rgba(0,0,0,0); transform: translateZ(0); }
  40% { box-shadow: 0 0 0 3px rgba(255,255,255,0.12); transform: scale(0.98); }
  100% { box-shadow: 0 0 0 rgba(0,0,0,0); transform: translateZ(0); }
}

.btnPulse {
  animation: btnPulse 160ms ease-out;
}

@media (prefers-reduced-motion: reduce) {
  .btnPulse { animation: none; }
}

.danger { border-color: rgba(255,92,92,0.6); }
.danger:hover { background: rgba(255,92,92,0.12); }


.messages {
  min-height: 110px;
  color: var(--muted);
  font-size: 14px;
}

.messages .actionInfo{
  gap: 6px;
}

.messages .systemMessage{
  margin-top: 6px;
}
.drawInline{
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.drawInline .actionBtn{
  padding: 6px 10px;
  font-size: 12px;
}

.portraitMessages{
  display: none;
  position: absolute;
  right: 12px;
  top: 12px;
  padding: 0;
  min-height: 0;
  border: none;
  background: transparent;
  text-align: right;
  max-width: 160px;
  font-size: 12px;
}
.portraitMessages .actionInfoLine{
  justify-content: flex-end;
}
.portraitMessages .systemMessage{
  margin-top: 4px;
}
.portraitMessages .drawInline{
  justify-content: flex-end;
}
.potBox.hasAuctionInfo .portraitMessages{
  top: 62px;
}

.badgeGood { color: var(--good); font-weight: 700; }
.badgeBad { color: var(--danger); font-weight: 700; }

/* Auction box */
.auctionBox {
  margin-top: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
}

.auctionHeader {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
}

.auctionTitle {
  font-weight: 800;
  letter-spacing: 0.3px;
}

.auctionRound {
  color: var(--muted);
  font-size: 12px;
}

.auctionPieceRow {
  display: flex;
  gap: 12px;
  align-items: center;
}

.auctionPiece {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
}

.auctionMeta {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.25;
}

.auctionReveal {
  margin-top: 10px;
  color: var(--text);
  font-size: 13px;
}

/* SVG piece images */
.piece {
  width: 86%;
  height: 86%;
  display: block;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  -ms-user-select: none;
  filter: var(--piece-filter);
  position: relative;
  z-index: 3;
}

body[data-piece-style="classic"]{
  --piece-filter: drop-shadow(0 2px 1px rgba(0,0,0,0.55));
}
body[data-piece-style="glyph"]{
  --piece-filter: none;
}
body[data-piece-style="cartoon"]{
  --piece-filter: drop-shadow(0 2px 2px rgba(0,0,0,0.45));
}
body[data-piece-style="shogi"]{
  --piece-filter: drop-shadow(0 1px 1px rgba(0,0,0,0.3));
}

body[data-piece-style="classic"]{
  --fog-bg: #2b2f36;
  --fog-border: #0f1115;
  --fog-color: #f6f2ea;
}
body[data-piece-style="cartoon"]{
  --fog-bg: #2f3238;
  --fog-border: #0f1115;
  --fog-color: #f6f2ea;
}
body[data-piece-style="glyph"]{
  --fog-bg: #2b2f36;
  --fog-border: #0f1115;
  --fog-color: #f6f2ea;
}
body[data-piece-style="shogi"] .fog{
  clip-path: polygon(14% 10%, 86% 10%, 95% 62%, 50% 92%, 5% 62%);
  border-radius: 6px;
}

body.light[data-piece-style="classic"],
body.light[data-piece-style="cartoon"],
body.light[data-piece-style="glyph"]{
  --fog-bg: #e9dfcf;
  --fog-border: #b59a73;
  --fog-color: #2b2f36;
}

body[data-piece-style="classic"]{
  --fog-radius: 10px;
  --fog-font: "Georgia", "Times New Roman", serif;
  --fog-border-w: 2px;
}
body[data-piece-style="cartoon"]{
  --fog-radius: 14px;
  --fog-font: "Trebuchet MS", "Arial Rounded MT Bold", Arial, sans-serif;
  --fog-border-w: 3px;
  --fog-bg: #2f3238;
  --fog-border: #0f1115;
  --fog-color: #f6f2ea;
}
body[data-piece-style="glyph"]{
  --fog-radius: 999px;
  --fog-font: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  --fog-letter-spacing: 1px;
}
body[data-piece-style="shogi"]{
  --fog-font: "Times New Roman", Georgia, serif;
  --fog-border-w: 2px;
}

.fog {
  width: 70%;
  height: 70%;
  border-radius: var(--fog-radius, 12px);
  background: var(--fog-bg);
  border: var(--fog-border-w, 2px) solid var(--fog-border);
  color: var(--fog-color);
  font-size: clamp(20px, 3.8vh, 42px);
  font-weight: 900;
  font-family: var(--fog-font, "Arial Black", Arial, sans-serif);
  letter-spacing: var(--fog-letter-spacing, 0);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 3;
}

/* Countdown panel */
.countdownsBox {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.playerBox{
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px 12px;
  position: relative;
}

#oppReportBtn.reportLink{
  align-self: flex-end;
  padding: 0;
  margin-top: 0;
  font-size: 13px;
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
}
#oppReportBtn.reportLink:hover{
  color: var(--accent);
  text-decoration: underline;
}

.matchPlayerRow{
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.playerInfoBlock{
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1;
}

.playerSide{
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  flex: 0 0 auto;
}

.playerName{
  font-weight: 800;
  letter-spacing: 0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.playerStack{
  font-weight: 800;
  margin-top: 0;
}

.playerTime{
  margin-top: 0;
  color: var(--muted);
  font-size: 16px;
  font-weight: 700;
}

.countdownItem {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.countdownText {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.countdownLabel {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.countdownValue {
  font-size: 14px;
  font-weight: 900;
}

.ring {
  width: 44px;
  height: 44px;
  transform: rotate(-90deg);
}

.ringBg {
  fill: none;
  stroke: var(--ring-bg);
  stroke-width: 6;
}

.ringFg {
  fill: none;
  stroke: var(--accent);
  stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 0 999;
  transition: stroke-dasharray 220ms ease;
}

/* Last move highlight */
.square.lastFrom::before,
.square.lastTo::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.square.lastFrom::before {
  background: rgba(255, 214, 102, 0.18);
  outline: 2px solid rgba(255, 214, 102, 0.45);
  outline-offset: -2px;
  box-shadow: inset 0 0 0 2px rgba(255, 214, 102, 0.22);
}

.square.lastTo::before {
  background: rgba(78, 161, 255, 0.18);
  outline: 2px solid rgba(78, 161, 255, 0.55);
  outline-offset: -2px;
  box-shadow: inset 0 0 0 2px rgba(78, 161, 255, 0.25);
}

/* Right-click marker */
.square.mark::after {
  content: "";
  position: absolute;
  width: 34%;
  height: 34%;
  border-radius: 999px;
  border: 2px solid rgba(255, 92, 92, 0.75);
  background: rgba(255, 92, 92, 0.10);
  box-shadow: 0 2px 0 rgba(0,0,0,0.20);
  pointer-events: none;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 1;
}

.square.target::after { z-index: 1; }

/* ---------- Modals (BOTTOM) ---------- */
body.modalOpen .matchLayout {
  filter: none;
  pointer-events: none;
}

body.modalOpen .bottomControls,
body.modalOpen .historyControls,
body.modalOpen .mobileControls,
body.modalOpen .mobileDrawer,
body.modalOpen .actionBar{
  pointer-events: none;
}

body.modalOpen .bottomControls{
  z-index: 0;
}

.modalOverlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: flex-end;          /* <- unten ausrichten */
  justify-content: center;

  padding: 18px 18px 160px;        /* <- Abstand unten (mehr = höher) */
  background: var(--overlay);   /* leichter */
  backdrop-filter: blur(1px);     /* weniger blur */
  -webkit-backdrop-filter: blur(1px);

  z-index: 999;
}

body.tutorialMode .modalOverlay{
  align-items: center;
  padding-bottom: 18px;
}

body.tutorialMode #auctionModal.modalOverlay,
body.tutorialMode #bettingModal.modalOverlay{
  align-items: center;
  padding-bottom: 18px;
}

@media (max-width: 520px) {
  .modalOverlay { padding-bottom: 160px; }
}

.modalCard {
  width: min(92vw, 460px);
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: 0 12px 50px rgba(0,0,0,0.55);
  padding: 16px;
}

/* Tutorial overlay */
.tutorialOverlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  pointer-events: none;
}

body.tutorialPage{
  overflow-x: hidden;
}

.tutorialHighlight {
  position: absolute;
  border: 2px solid var(--accent);
  border-radius: 12px;
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.45);
  transition: left 140ms ease, top 140ms ease, width 140ms ease, height 140ms ease;
  pointer-events: none;
}

.tutorialCard {
  position: absolute;
  width: min(360px, 86vw);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.25);
  pointer-events: auto;
  transition: opacity 120ms ease;
}

.tutorialCardHidden{
  opacity: 0;
  pointer-events: none;
}

.tutorialTitle {
  font-weight: 700;
  margin-bottom: 6px;
}

.tutorialText {
  font-size: 14px;
  color: var(--text);
  line-height: 1.4;
}

.tutorialActions {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
  gap: 8px;
}

.tutorialArrow {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.tutorialArrow line {
  stroke: var(--accent);
  stroke-width: 2;
}

.tutorialArrow path {
  fill: var(--accent);
}

.square.practiceTarget{
  box-shadow: inset 0 0 0 3px var(--accent), inset 0 0 0 6px rgba(0,0,0,0.25);
}

.betModalCard{
  position: relative;
  padding-bottom: 58px;
}

.modalSideActions{
  position: absolute;
  left: 12px;
  bottom: 12px;
  display: flex;
  gap: 8px;
}

.auctionStackLine{
  margin-top: 6px;
  color: var(--muted);
  font-weight: 700;
}

.auctionWinBanner{
  background: rgba(78,161,255,0.14);
  border: 1px solid rgba(78,161,255,0.45);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 10px;
  box-shadow: 0 0 0 1px rgba(78,161,255,0.15);
  animation: auctionPulse 1.1s ease-in-out infinite;
}

.auctionInfoRow{
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.auctionInfoLine{
  color: var(--muted);
}

.auctionInfoSmall{
  color: var(--muted);
  font-size: 13px;
  margin-top: 6px;
}

@keyframes auctionPulse{
  0%, 100% { box-shadow: 0 0 0 1px rgba(78,161,255,0.15); }
  50% { box-shadow: 0 0 0 4px rgba(78,161,255,0.25); }
}

@media (max-width: 820px) and (orientation: portrait){
  #auctionModal.modalOverlay{
    padding-bottom: 200px;
  }
}

/* ---------- End Modal ---------- */
.endModal{
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--overlay);
  z-index: 1002;
}
.endLayout{
  display: flex;
  align-items: stretch;
  gap: 12px;
  max-width: min(96vw, 820px);
}
.endCard{
  width: min(92vw, 460px);
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: 0 12px 50px rgba(0,0,0,0.55);
  padding: 16px;
}

.adBox{
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel2);
  padding: 12px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  text-align: center;
}

/* Ads disabled (temporary) */
.adBox,
.adBanner,
#adModal {
  display: none !important;
}
.adBox .adLabel{
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
}
.adBox .adBody{
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}
.adSide{
  width: 220px;
  min-height: 180px;
}

.adBanner{
  margin-top: 18px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel2);
  padding: 16px;
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 6px;
}

.adVideo{
  width: min(92vw, 420px);
  height: auto;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel2);
  margin: 8px 0;
}

.spinner{
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 4px solid rgba(0,0,0,0.12);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
  margin: 8px auto;
}

@keyframes spin{
  to { transform: rotate(360deg); }
}
.adBanner.sticky{
  position: fixed;
  left: 14px;
  right: 14px;
  bottom: 12px;
  margin: 0;
  z-index: 200;
}

.hasStickyAd{
  padding-bottom: 130px;
}

@media (max-width: 740px){
  .endLayout{
    flex-direction: column;
    align-items: center;
  }
  .adSide{
    width: min(92vw, 460px);
    min-height: 110px;
  }
}
.endTitle{
  font-weight: 900;
  letter-spacing: 0.2px;
  font-size: 18px;
  margin-bottom: 6px;
}
.endText{
  color: var(--muted);
  font-size: 14px;
  line-height: 1.3;
  margin-bottom: 12px;
}
.endActions{
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.modalTitle {
  font-weight: 900;
  letter-spacing: 0.2px;
  font-size: 16px;
  margin-bottom: 6px;
}

.modalSub {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.3;
  margin-bottom: 12px;
}

.modalActions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  position: relative;
}

.modalActions .centerBtn {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.howToActions{
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}

.howToActions .centerBtn{
  position: static;
  transform: none;
  grid-column: 2;
  justify-self: center;
}

.howToActions #howToClose{
  grid-column: 3;
  justify-self: end;
}

.modalActions input[type="number"] {
  flex: 1;
  min-width: 160px;
}

/* ---------- Auction Slot: SINGLE ICON ---------- */
.slotWindow { display: none; }    /* nur eine Figur sichtbar */
.slotReel { display: none; }

.slotResult {
  font-size: 44px;
  font-weight: 900;
  line-height: 1;
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--panel2);
}

.actionBar{
  width: min(90vw, 560px);
  min-height: 64px;
  margin-top: -4px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 8px;
}

.actionInfo{
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  font-size: 13px;
}

.actionInfoLine{
  color: var(--muted);
}

.actionInfoLine.good{
  color: var(--good);
  font-weight: 800;
}

.actionInfoLine.bad{
  color: var(--bad);
  font-weight: 800;
}

.actionMain{
  width: 100%;
  display: flex;
  justify-content: center;
}

.actionMain .actionsRow{
  width: 100%;
}

.historyControls{
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.historyControls .smallBtn{
  padding: 10px 14px;
  font-size: 16px;
}

.actionsRow{
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.turnNotice{
  color: var(--good);
  font-weight: 800;
}

/* Chat UI */
.chatBox{
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  width: 100%;
}

.chatTitle{
  font-weight: 800;
  margin-bottom: 8px;
}

.chatMessages{
  height: 340px;
  width: 100%;
  overflow: auto;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  font-size: 13px;
  color: var(--text);
}

.chatMsg{
  margin: 6px 0;
  line-height: 1.25;
}

.chatMsg .who{
  color: var(--muted);
  font-weight: 700;
  margin-right: 6px;
}

.chatRow{
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.chatInput{
  flex: 1;
  padding: 10px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel2);
  color: var(--text);
  min-width: 0;
}

#chatSend{
    flex: 0 0 auto;
    white-space: nowrap;
}

@media (max-width: 520px){
  #chatSend{ padding: 10px 10px; }
}

.floatingPiece{
  position: fixed;
  width: 0;
  height: 0;
  pointer-events: none;
  z-index: 9999;
  transform: translate(-50%, -50%);
  transition: left 260ms ease-out, top 260ms ease-out;
  user-select: none;
  -webkit-user-select: none;
  -ms-user-select: none;
}
.floatingPiece img{
  width: 44px;
  height: 44px;
}

.dragPiece{
  position: fixed;
  width: 44px;
  height: 44px;
  pointer-events: none;
  z-index: 9999;
  transform: translate(-50%, -50%);
  user-select: none;
  -webkit-user-select: none;
  -ms-user-select: none;
}

.boardWrap{
  position: relative;
  width: min(90vw, 560px);
  user-select: none;
  -webkit-user-select: none;
  -ms-user-select: none;
  touch-action: none;
  overscroll-behavior: contain;
}
.boardWrap .board{
  width: 100%;
  touch-action: none;
}
.boardWrap .square{
  touch-action: none;
}

.boardWrap.shake{
  animation: boardShake 0.35s ease;
}

@keyframes boardShake{
  0% { transform: translateX(0); }
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
  100% { transform: translateX(0); }
}

.screenShake{
  animation: screenShake 0.18s linear;
}

@keyframes screenShake{
  0% { transform: translateX(0); }
  20% { transform: translateX(-3px); }
  40% { transform: translateX(3px); }
  60% { transform: translateX(-2px); }
  80% { transform: translateX(2px); }
  100% { transform: translateX(0); }
}
.arrowLayer{
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.arrowLine{
  stroke: rgba(255,92,92,0.85);
  stroke-width: 7;
  stroke-linecap: round;
  fill: none;
}
.arrowHead{
  fill: rgba(255,92,92,0.85);
}

#stackPlus{ border-color: rgba(77,255,136,0.45); }
#stackMinus{ border-color: rgba(255,92,92,0.45); }

.mobileControls{
  display: none;
  width: 100%;
  align-items: center;
  gap: 10px;
}

.mobileStack{
  font-weight: 800;
  letter-spacing: 0.2px;
  color: var(--muted);
}

.mobileTime{
  font-weight: 800;
  letter-spacing: 0.4px;
}

.mobileDrawer{
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: fixed;
  left: 12px;
  bottom: 86px;
  width: 190px;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel);
  box-shadow: 0 12px 40px rgba(0,0,0,0.35);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
  z-index: 1201;
}

.mobileDrawer.open{
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.mobileChatHeader{
  display: none;
  align-items: center;
  gap: 8px;
}

.mobileChatTitle{
  font-weight: 800;
  letter-spacing: 0.2px;
}

@media (max-width: 820px) and (orientation: portrait){
  .matchLayout{
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 10px;
  }

  .leftPanel,
  .centerPanel{
    width: min(94vw, 560px);
  }

  .centerPanel{
    position: relative;
  }

  .countdownsBox,
  #youBoxLeft{
    display: none;
  }

  .bottomLeftButtons{
    display: none;
  }

  .bottomControls > .historyControls{
    display: none;
  }

  .bottomControls{
    width: min(94vw, 560px);
  }

  .actionBar{
    width: min(94vw, 560px);
  }

  .boardWrap{
    width: min(94vw, 560px);
  }

  .mobileControls{
    display: flex;
    justify-content: space-between;
  }

  .mobileHistory{
    display: flex;
    gap: 8px;
    margin: 0 auto;
  }

  .rightPanel{
    position: fixed;
    inset: 0;
    padding: 12px;
    background: var(--bg);
    z-index: 1200;
    display: none;
    overflow: auto;
  }

  body.chatOpen{
    overflow: hidden;
  }

  body.chatOpen .rightPanel{
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .mobileChatHeader{
    display: flex;
  }

  .portraitMessages{
    display: block;
  }
}

@media (max-height: 760px) and (orientation: landscape){
  .leftPanel,
  .rightPanel{
    max-height: calc(100vh - 70px);
    overflow: auto;
  }
  .messages{
    min-height: 80px;
  }
  .chatMessages{
    height: clamp(140px, 28vh, 220px);
  }
}

.settingsShell{
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.settingsHeader{
  display: flex;
  gap: 12px;
  align-items: center;
}

.settingsHeaderInfo{
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.settingsNick{
  font-weight: 900;
  font-size: 16px;
}

.settingsName{
  color: var(--muted);
  font-size: 13px;
}

.settingsEmail{
  color: var(--muted);
  font-size: 12px;
}

.settingsBody{
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 14px;
}

.settingsNav{
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.navBtn{
  text-align: left;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel2);
  color: var(--text);
  padding: 10px 12px;
  font-weight: 700;
  cursor: pointer;
}

.navBtn.active{
  background: var(--panel);
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(56, 122, 255, 0.25);
}

.settingsPanel{
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.panelTitle{
  font-weight: 900;
  font-size: 15px;
}

.profileLayout{
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.profileHeader{
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
}

.avatarLarge{
  width: 74px;
  height: 74px;
  font-size: 28px;
}

.profileInfo{
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.profileNick{
  font-weight: 900;
  font-size: 20px;
}

.profileName{
  font-size: 14px;
  color: var(--muted);
}

.profileEmail{
  font-size: 12px;
  color: var(--muted);
}

.profileTabs{
  display: flex;
  gap: 10px;
}

.tabBtn{
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel2);
  color: var(--text);
  padding: 10px 14px;
  font-weight: 800;
  cursor: pointer;
}

.tabBtn.active{
  background: var(--panel);
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(56, 122, 255, 0.25);
}

.tabPanel{
  display: none;
}

.tabPanel.active{
  display: block;
}

.profileCard{
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.profileCardTitle{
  font-weight: 900;
  font-size: 16px;
}

.profileFormRow{
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.profileFormRow .inputField{
  flex: 1;
  min-width: 180px;
}

.profileNote{
  color: var(--muted);
  font-size: 12px;
}

.statsGrid{
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.donutWrap{
  display: flex;
  align-items: center;
  gap: 14px;
}

.donut{
  width: 140px;
  height: 140px;
  border-radius: 999px;
  background: var(--panel);
  position: relative;
  display: grid;
  place-items: center;
}

.donut::after{
  content: "";
  position: absolute;
  inset: 18px;
  background: var(--panel2);
  border-radius: 999px;
  border: 1px solid var(--border);
}

.donutCenter{
  position: relative;
  z-index: 1;
  text-align: center;
  font-weight: 800;
  font-size: 12px;
}

.eloChart{
  width: 100%;
  height: 160px;
  background: var(--panel);
  border-radius: 12px;
  border: 1px solid var(--border);
}

.statBar{
  width: 100%;
  height: 12px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--border);
  overflow: hidden;
}

.statBarFill{
  height: 100%;
  background: var(--accent);
  width: 0%;
}

.statValue{
  font-weight: 800;
  font-size: 13px;
}

.friendsLayout{
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 16px;
}

.friendsColumn{
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sectionTitle{
  font-weight: 900;
  font-size: 14px;
}

.listStack{
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.reqLink{
  color: var(--accent);
  font-weight: 800;
  cursor: pointer;
}

.reqLink:hover{
  text-decoration: underline;
}

.requestsSection{
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.requestsTitle{
  font-weight: 900;
  font-size: 14px;
}

.flagBadge{
  display: inline-block;
  margin-left: 8px;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(231, 76, 60, 0.18);
  color: #ff6b6b;
  font-size: 11px;
  font-weight: 800;
}

.matchesGrid{
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 10px;
}

.matchCard{
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.matchCard.clickable{
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.matchCard.clickable:hover{
  border-color: var(--accent);
  transform: translateY(-1px);
}

.matchNo{
  font-weight: 900;
  font-size: 14px;
}

.matchMeta{
  color: var(--muted);
  font-size: 12px;
}

.timeLow{
  color: var(--danger);
  font-weight: 800;
}

.messages.turnPulse{
  animation: turnPulse 0.55s ease;
  box-shadow: 0 0 0 0 rgba(71, 201, 109, 0.55);
}

@keyframes turnPulse{
  0% { box-shadow: 0 0 0 0 rgba(71, 201, 109, 0.55); }
  70% { box-shadow: 0 0 0 10px rgba(71, 201, 109, 0); }
  100% { box-shadow: 0 0 0 0 rgba(71, 201, 109, 0); }
}

.recentGrid{
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

@media (max-width: 900px){
  .matchesGrid{
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 600px){
  .matchesGrid{
    grid-template-columns: 1fr;
  }
}

.searchRow{
  display: flex;
  gap: 10px;
}

.playerRow{
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel2);
}

.playerInfo{
  display: flex;
  flex-direction: column;
}

.playerNick{
  font-weight: 900;
  font-size: 14px;
}

.playerMeta{
  color: var(--muted);
  font-size: 12px;
}

.playerActions{
  display: flex;
  gap: 8px;
  align-items: center;
}

.stackInputSmall{
  width: 100px;
  height: 38px;
  padding: 6px 8px;
  font-size: 13px;
}

.miniBoardBtn,
.plusBtn{
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  display: grid;
  place-items: center;
}

.miniBoard{
  width: 22px;
  height: 22px;
  border-radius: 4px;
  background:
    linear-gradient(90deg, rgba(255,255,255,0.12) 50%, rgba(0,0,0,0.1) 50%),
    linear-gradient(rgba(255,255,255,0.12) 50%, rgba(0,0,0,0.1) 50%);
  background-size: 8px 8px;
}

.qrWrap{
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
}

.qrImage{
  width: 180px;
  height: 180px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel);
  object-fit: contain;
}

.linkBox{
  word-break: break-all;
  font-size: 12px;
  color: var(--muted);
}

.linkRow{
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.linkRow .linkBox{
  flex: 1;
  min-width: 180px;
}

@media (max-width: 900px){
  .settingsBody{
    grid-template-columns: 1fr;
  }
  .friendsLayout{
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px){
  .profileHeader{
    flex-direction: column;
    align-items: flex-start;
  }
  .profileTabs{
    flex-wrap: wrap;
  }
}
