:root {
  color-scheme: dark;
  --piece-scale: 1;
  --bg: #070b0c;
  --ink: #f7efe2;
  --muted: #b8aa95;
  --soft: rgba(255, 255, 255, 0.08);
  --line: rgba(255, 255, 255, 0.14);
  --panel: rgba(14, 20, 21, 0.78);
  --panel-solid: #121a1b;
  --panel-2: #1a2626;
  --gold: #f2c66d;
  --gold-2: #b9802f;
  --teal: #58d4bf;
  --red: #ff766d;
  --green: #7bd88f;
  --light-square: #eeeed2;
  --dark-square: #769656;
  --shadow: 0 28px 90px rgba(0, 0, 0, 0.48);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 15% 15%, rgba(88, 212, 191, 0.16), transparent 30%),
    radial-gradient(circle at 82% 20%, rgba(242, 198, 109, 0.15), transparent 26%),
    linear-gradient(135deg, #070b0c 0%, #111816 44%, #090c10 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background-image: linear-gradient(90deg, rgba(7, 11, 12, 0.94), rgba(7, 11, 12, 0.64) 42%, rgba(7, 11, 12, 0.22)), url("assets/chess-hero.png");
  background-size: cover;
  background-position: center;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.75), transparent 78%);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

button:hover {
  transform: translateY(-1px);
  border-color: rgba(242, 198, 109, 0.54);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.shell {
  width: min(1220px, calc(100vw - 36px));
  margin: 0 auto;
  padding: 30px 0;
}

.hidden {
  display: none !important;
}

.auth-view {
  min-height: calc(100vh - 60px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 430px;
  gap: 34px;
  align-items: center;
}

.brand-panel {
  max-width: 720px;
}

.brand-mark {
  width: fit-content;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px 8px 8px;
  margin-bottom: 30px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(14px);
}

.brand-mark span {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #1c1405;
  background: linear-gradient(135deg, var(--gold), #fff0ba);
  font-weight: 900;
}

.brand-mark small {
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.brand-panel h1 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(48px, 7.6vw, 96px);
  line-height: 0.92;
  letter-spacing: 0;
}

.brand-panel p:not(.eyebrow) {
  max-width: 610px;
  color: var(--muted);
  font-size: clamp(18px, 2vw, 22px);
  line-height: 1.55;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--teal);
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
}

.hero-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 30px;
}

.hero-stats span {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.28);
  color: var(--muted);
  backdrop-filter: blur(14px);
}

.hero-stats strong {
  color: var(--gold);
}

.auth-card,
.lobby,
.video-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.auth-card {
  position: relative;
  overflow: hidden;
  padding: 24px;
  display: grid;
  gap: 16px;
}

.auth-card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(135deg, rgba(242, 198, 109, 0.16), transparent 42%);
}

.auth-card > * {
  position: relative;
}

.card-heading h2 {
  margin: 0 0 4px;
  font-size: 26px;
  line-height: 1.1;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 4px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
}

.tab {
  min-height: 42px;
  border-color: transparent;
  background: transparent;
}

.tab.active,
.primary,
.seek {
  color: #1f1605;
  border-color: rgba(255, 244, 196, 0.7);
  background: linear-gradient(135deg, #ffe08a, var(--gold) 48%, #c99135);
  box-shadow: 0 14px 28px rgba(185, 128, 47, 0.22);
  font-weight: 900;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.signup-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.signup-fields label:first-child,
.signup-fields label:nth-child(5) {
  grid-column: 1 / -1;
}

input,
select {
  width: 100%;
  min-height: 46px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 8px;
  background: rgba(3, 7, 8, 0.62);
  color: var(--ink);
  padding: 12px 13px;
  outline: none;
}

input:focus,
select:focus {
  border-color: rgba(88, 212, 191, 0.78);
  box-shadow: 0 0 0 3px rgba(88, 212, 191, 0.12);
}

.password-field {
  position: relative;
  display: block;
}

.password-field input {
  padding-right: 52px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 8px;
  width: 36px;
  height: 36px;
  min-height: 36px;
  display: grid;
  place-items: center;
  transform: translateY(-50%);
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
}

.password-toggle:hover {
  transform: translateY(-50%);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.08);
}

.eye-icon {
  position: relative;
  width: 18px;
  height: 12px;
  display: block;
  border: 2px solid currentColor;
  border-radius: 999px 999px 999px 999px / 80% 80% 80% 80%;
}

.eye-icon::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  transform: translate(-50%, -50%);
}

.password-toggle.is-visible .eye-icon::after {
  content: "";
  position: absolute;
  top: 50%;
  left: -3px;
  width: 24px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  transform: rotate(-38deg);
}

input[type="file"] {
  padding: 10px;
}

.primary,
.seek,
.ghost {
  min-height: 50px;
}

.notice {
  min-height: 22px;
  margin: 0;
  color: var(--red);
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  margin-bottom: 20px;
}

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

.topbar-actions > .logout-button {
  align-self: center;
}

.icon-button {
  width: 50px;
  min-height: 50px;
  display: grid;
  place-items: center;
  padding: 0;
  font-size: 21px;
  font-weight: 900;
}

.nav-action-button,
.logout-button {
  min-height: 50px;
  padding: 0 16px;
  font-weight: 900;
}

#settingsButton {
  color: #1f1605;
  border-color: rgba(255, 244, 196, 0.7);
  background: linear-gradient(135deg, #ffe08a, var(--gold) 48%, #c99135);
  box-shadow: 0 14px 28px rgba(185, 128, 47, 0.22);
}

.topbar h2 {
  margin: 0;
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1;
}

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

.profile {
  min-height: 64px;
  padding: 8px 12px 8px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(16px);
  text-align: left;
}

.profile:hover {
  transform: translateY(-1px);
  border-color: rgba(88, 212, 191, 0.46);
}

.profile img {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(242, 198, 109, 0.52);
}

.profile span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.lobby {
  padding: 20px;
  display: grid;
  gap: 16px;
}

.friend-challenge-panel,
.challenge-box {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.24);
}

.friend-challenge-panel > div:first-child {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.challenge-box {
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
}

.online-friends-list {
  display: grid;
  gap: 8px;
}

.online-friend-row {
  min-height: 58px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  text-align: left;
}

.online-friend-row img {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
}

.muted-line {
  margin: 0;
  color: var(--muted);
}

.seeking-panel {
  display: grid;
  grid-template-columns: minmax(260px, 0.86fr) minmax(360px, 1.14fr);
  gap: 18px;
  align-items: stretch;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(88, 212, 191, 0.1), rgba(242, 198, 109, 0.08)),
    var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.seeking-copy {
  display: flex;
  min-height: 360px;
  flex-direction: column;
  justify-content: center;
  padding: 24px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.22);
}

.seeking-copy h3 {
  margin: 0;
  font-size: clamp(30px, 4vw, 52px);
  line-height: 1;
}

.seeking-copy p:not(.eyebrow) {
  max-width: 420px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.55;
}

.search-pulse {
  display: flex;
  gap: 10px;
  margin: 14px 0 24px;
}

.search-pulse span {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--gold);
  animation: pulse-dot 1.15s ease-in-out infinite;
}

.search-pulse span:nth-child(2) {
  animation-delay: 160ms;
}

.search-pulse span:nth-child(3) {
  animation-delay: 320ms;
}

@keyframes pulse-dot {
  0%, 100% {
    opacity: 0.35;
    transform: translateY(0);
  }

  50% {
    opacity: 1;
    transform: translateY(-5px);
  }
}

.search-visual {
  position: relative;
  min-height: 390px;
  display: grid;
  grid-template-columns: 0.96fr 1.04fr;
  gap: 14px;
}

.preview-board-img {
  align-self: center;
  display: block;
  width: 100%;
  max-width: 430px;
  aspect-ratio: 1;
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
}

.match-card {
  position: relative;
  align-self: center;
  overflow: hidden;
  min-height: 340px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: #070b0c;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.42);
}

.match-card img {
  width: 100%;
  height: 100%;
  min-height: 340px;
  display: block;
  object-fit: cover;
  transition: opacity 150ms ease, transform 240ms ease;
}

.match-card img.is-switching {
  opacity: 0.18;
  transform: scale(1.03);
}

.match-card::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.76), transparent 48%);
}

.match-card-caption {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 14px;
  z-index: 1;
  display: grid;
  gap: 3px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.48);
  backdrop-filter: blur(14px);
}

.match-card-caption strong {
  color: var(--ink);
}

.match-card-caption span {
  color: var(--muted);
  font-size: 13px;
}

.time-controls {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.time-card {
  min-height: 118px;
  padding: 18px;
  text-align: left;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.04)),
    rgba(0, 0, 0, 0.2);
}

.time-card.active {
  border-color: rgba(242, 198, 109, 0.86);
  background:
    linear-gradient(135deg, rgba(242, 198, 109, 0.24), rgba(88, 212, 191, 0.08)),
    rgba(0, 0, 0, 0.24);
}

.time-card strong,
.time-card span {
  display: block;
}

.time-card strong {
  font-size: 34px;
}

.time-card span {
  color: var(--muted);
  margin-top: 10px;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) 310px;
  gap: 18px;
  align-items: start;
}

.video-panel {
  padding: 14px;
  display: grid;
  gap: 12px;
}

.board-wrap {
  min-width: 0;
  display: grid;
  gap: 8px;
}

.board-player {
  width: min(100%, 650px);
  min-height: 58px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(14px);
}

.board-player img {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(242, 198, 109, 0.52);
}

.board-player strong {
  display: flex;
  gap: 6px;
  align-items: center;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.board-player span {
  display: block;
}

.board-player span {
  color: var(--muted);
  font-size: 13px;
}

.board-player .captured-row {
  min-height: 18px;
  overflow: hidden;
  color: rgba(247, 239, 226, 0.74);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hide-captured .captured-row {
  display: none;
}

.board-player strong span {
  display: inline;
  color: var(--ink);
  font-size: 15px;
}

.board-player b {
  color: var(--gold);
  font-size: 24px;
  font-variant-numeric: tabular-nums;
}

.board-meta,
.actions,
.draw-box,
.media-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.board-meta {
  min-height: 42px;
  margin-top: 2px;
  padding: 0 2px;
  color: var(--muted);
  font-weight: 800;
}

.board-meta span:first-child {
  color: var(--ink);
}

.board {
  width: min(100%, 650px);
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  overflow: hidden;
  border: 10px solid #232a22;
  border-radius: 8px;
  background: #232a22;
  box-shadow: 0 26px 70px rgba(0, 0, 0, 0.5), inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.square {
  position: relative;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 0;
  font-family: "Arial Unicode MS", "Segoe UI Symbol", "Noto Sans Symbols 2", "DejaVu Sans", serif;
  font-size: clamp(38px, calc(7vw * var(--piece-scale)), calc(76px * var(--piece-scale)));
  font-weight: 700;
  line-height: 0.9;
  user-select: none;
  text-shadow: 0 3px 7px rgba(0, 0, 0, 0.24);
}

.square:hover {
  transform: none;
}

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

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

body[data-board-theme="blue"] {
  --light-square: #e8edf9;
  --dark-square: #6f87a8;
}

body[data-board-theme="brown"] {
  --light-square: #f0d9b5;
  --dark-square: #b58863;
}

body[data-board-theme="gray"] {
  --light-square: #d8dce3;
  --dark-square: #7d8794;
}

.square.white-piece {
  color: #f8f0dd;
  -webkit-text-stroke: 1.1px #2d2a23;
}

.square.black-piece {
  color: #232323;
  -webkit-text-stroke: 0.7px #050505;
}

.square.selected {
  background: #f6d76f;
  box-shadow: inset 0 0 0 4px rgba(110, 82, 15, 0.42);
}

.square.last-move {
  background: #ced26a;
  box-shadow: inset 0 0 0 4px rgba(255, 243, 119, 0.22);
}

.square.target::after {
  content: "";
  width: 28%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: rgba(30, 48, 35, 0.34);
  box-shadow: 0 0 0 5px rgba(30, 48, 35, 0.08);
}

.board.show-coordinates .square::before,
.board.show-coordinates .square::after {
  position: absolute;
  z-index: 1;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  text-shadow: none;
}

.board.show-coordinates .square[data-file="a"]::before,
.board.show-coordinates .square[data-file="h"]::before {
  content: attr(data-rank);
  top: 5px;
  left: 6px;
}

.board.show-coordinates .square[data-rank="1"]::after,
.board.show-coordinates .square[data-rank="8"]::after {
  content: attr(data-file);
  right: 6px;
  bottom: 5px;
}

.board.show-coordinates .square.light::before,
.board.show-coordinates .square.light::after {
  color: var(--dark-square);
}

.board.show-coordinates .square.dark::before,
.board.show-coordinates .square.dark::after {
  color: var(--light-square);
}

.board.show-coordinates .square.target::after {
  content: "";
  right: auto;
  bottom: auto;
}

.actions {
  margin-top: 14px;
  justify-content: flex-start;
  flex-wrap: wrap;
}

.actions button,
.draw-box button,
.media-actions button {
  min-height: 42px;
  padding: 0 14px;
  font-weight: 800;
}

.danger {
  color: #260b08;
  border-color: rgba(255, 180, 174, 0.55);
  background: linear-gradient(135deg, #ffaaa3, var(--red));
  font-weight: 900;
}

.settings-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(10px);
}

.settings-card {
  width: min(720px, 100%);
  max-height: min(780px, calc(100vh - 48px));
  overflow: auto;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(14, 20, 21, 0.96);
  box-shadow: var(--shadow);
}

.settings-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: start;
  margin-bottom: 18px;
}

.settings-head h2 {
  margin: 0;
  font-size: 34px;
  line-height: 1;
}

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

.toggle-row {
  min-height: 56px;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink);
}

.toggle-row input {
  width: 22px;
  min-height: 22px;
  accent-color: var(--gold);
}

input[type="range"] {
  accent-color: var(--gold);
}

.draw-box {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.28);
}

.video-panel {
  background:
    linear-gradient(180deg, rgba(88, 212, 191, 0.08), transparent 34%),
    var(--panel);
}

.video-tile {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    radial-gradient(circle at center, rgba(88, 212, 191, 0.16), transparent 42%),
    #050708;
  aspect-ratio: 4 / 3;
}

.video-tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.video-tile span {
  position: absolute;
  left: 10px;
  bottom: 10px;
  padding: 6px 9px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.66);
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.media-actions {
  justify-content: stretch;
}

.media-actions button {
  flex: 1;
}

@media (max-width: 960px) {
  body::before {
    background-image: linear-gradient(180deg, rgba(7, 11, 12, 0.96), rgba(7, 11, 12, 0.68)), url("assets/chess-hero.png");
  }

  .auth-view,
  .game-layout,
  .seeking-panel,
  .search-visual {
    grid-template-columns: 1fr;
  }

  .brand-panel {
    padding-top: 24px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .time-controls {
    grid-template-columns: 1fr;
  }

  .seeking-copy {
    min-height: auto;
  }

  .preview-board-img {
    width: min(100%, 420px);
    justify-self: center;
  }

  .video-panel {
    order: 2;
  }
}

@media (max-width: 560px) {
  .shell {
    width: min(100% - 24px, 1220px);
    padding: 18px 0;
  }

  .brand-mark {
    margin-bottom: 22px;
  }

  .hero-stats,
  .actions,
  .draw-box {
    align-items: stretch;
    flex-direction: column;
  }

  .hero-stats span {
    justify-content: center;
  }

  .auth-card,
  .lobby,
  .video-panel {
    padding: 14px;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .settings-card {
    padding: 16px;
  }

  .signup-fields {
    grid-template-columns: 1fr;
  }

  .signup-fields label:first-child,
  .signup-fields label:nth-child(5) {
    grid-column: auto;
  }

  .board {
    border-width: 8px;
  }

  .profile {
    width: 100%;
    border-radius: 8px;
  }
}

.profile-page {
  min-height: 100vh;
  padding: 34px 0;
}

.profile-shell {
  width: min(1120px, calc(100vw - 32px));
  margin: 0 auto;
}

.profile-hero,
.stats-panel,
.game-card,
.review-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.profile-hero {
  display: flex;
  justify-content: space-between;
  gap: 22px;
  align-items: center;
  padding: 22px;
  margin-bottom: 18px;
}

.profile-identity {
  display: flex;
  gap: 16px;
  align-items: center;
}

.profile-identity img {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(242, 198, 109, 0.7);
}

.profile-identity h1 {
  margin: 0 0 6px;
  font-size: clamp(30px, 5vw, 52px);
  line-height: 1;
}

.profile-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(100px, 1fr));
  gap: 10px;
}

.profile-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.profile-facts span {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.22);
  font-size: 12px;
  font-weight: 800;
}

.profile-facts span.is-online {
  color: var(--green);
  border-color: rgba(123, 216, 143, 0.34);
  background: rgba(123, 216, 143, 0.1);
}

.profile-stats span {
  display: grid;
  gap: 4px;
  min-height: 68px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.22);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.profile-stats strong {
  color: var(--ink);
  font-size: 24px;
  text-transform: none;
}

.history-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  gap: 18px;
  align-items: start;
}

.stats-panel {
  padding: 18px;
  margin-bottom: 18px;
}

.stats-panel h2 {
  margin: 0 0 14px;
  font-size: 26px;
}

.stats-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.stats-tabs button {
  min-height: 42px;
  font-weight: 900;
}

.stats-tabs button.active {
  color: #1f1605;
  border-color: rgba(255, 244, 196, 0.7);
  background: linear-gradient(135deg, #ffe08a, var(--gold) 48%, #c99135);
}

.chart-wrap {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.18);
}

.chart-wrap svg {
  width: 100%;
  height: auto;
  display: block;
}

.game-list {
  display: grid;
  gap: 10px;
}

.game-card {
  width: 100%;
  min-height: 82px;
  padding: 12px;
  display: grid;
  grid-template-columns: 82px minmax(180px, 1.3fr) minmax(130px, 0.8fr) minmax(116px, 0.7fr) auto;
  gap: 12px;
  align-items: center;
  text-align: left;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.025)),
    rgba(0, 0, 0, 0.18);
}

.game-card.is-active {
  border-color: rgba(242, 198, 109, 0.74);
}

.game-card h3 {
  margin: 0 0 4px;
  font-size: 18px;
}

.game-card p,
.review-panel p {
  margin: 0;
  color: var(--muted);
}

.result-badge,
.review-chip {
  min-height: 34px;
  display: inline-grid;
  place-items: center;
  padding: 0 12px;
  border-radius: 999px;
  font-weight: 900;
}

.result-badge {
  background: rgba(255, 255, 255, 0.08);
}

.result-badge.win {
  color: var(--green);
  background: rgba(123, 216, 143, 0.12);
}

.result-badge.loss {
  color: var(--red);
  background: rgba(255, 118, 109, 0.12);
}

.result-badge.draw {
  color: var(--gold);
  background: rgba(242, 198, 109, 0.12);
}

.history-player {
  display: flex;
  gap: 12px;
  align-items: center;
  min-width: 0;
}

.history-player img {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.14);
}

.history-details,
.history-rating {
  display: grid;
  gap: 4px;
}

.history-details span,
.history-rating span {
  color: var(--muted);
  font-size: 12px;
}

.history-rating b {
  font-size: 18px;
}

.history-rating b.up {
  color: var(--green);
}

.history-rating b.down {
  color: var(--red);
}

.review-chip {
  color: var(--gold);
  border: 1px solid rgba(242, 198, 109, 0.32);
  background: rgba(242, 198, 109, 0.08);
}

.review-panel {
  position: sticky;
  top: 18px;
  padding: 18px;
}

.review-panel h2 {
  margin: 0 0 10px;
}

.move-record {
  max-height: 420px;
  overflow: auto;
  padding: 14px;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.26);
  color: var(--ink);
  white-space: pre-wrap;
  line-height: 1.6;
}

.empty-history {
  padding: 22px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
}

.friend-add {
  width: min(100%, 440px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 140px;
  gap: 10px;
  align-items: start;
}

.friend-add .notice {
  grid-column: 1 / -1;
}

.friends-grid {
  display: grid;
  gap: 14px;
}

.friends-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 430px);
  gap: 18px;
  align-items: start;
}

.friend-card {
  display: grid;
  grid-template-columns: minmax(220px, 1.1fr) minmax(220px, 0.8fr);
  gap: 16px;
  align-items: start;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.friend-card.is-active {
  border-color: rgba(242, 198, 109, 0.74);
}

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

.friend-main img {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(242, 198, 109, 0.52);
}

.friend-main h2,
.friend-games h3 {
  margin: 0 0 6px;
}

.friend-main p,
.friend-games p {
  margin: 0;
  color: var(--muted);
}

.status-pill {
  width: fit-content;
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.22);
  font-size: 12px;
  font-weight: 900;
}

.status-pill.online {
  color: var(--green);
  border-color: rgba(123, 216, 143, 0.34);
  background: rgba(123, 216, 143, 0.1);
}

.friend-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.friend-stats span {
  display: grid;
  gap: 4px;
  min-height: 66px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.22);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.friend-stats strong {
  color: var(--ink);
  font-size: 22px;
}

.friend-games {
  grid-column: 1 / -1;
  display: grid;
  gap: 8px;
}

.friend-actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.friend-actions button {
  min-height: 38px;
  padding: 0 12px;
  font-weight: 900;
}

.friend-game-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 52px 52px;
  gap: 8px;
  align-items: center;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.18);
  color: var(--muted);
  font-size: 13px;
}

.friend-game-row b.up {
  color: var(--green);
}

.friend-game-row b.down {
  color: var(--red);
}

.message-panel {
  position: sticky;
  top: 18px;
  min-height: 360px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.message-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  margin-bottom: 12px;
}

.message-heading h2 {
  margin: 0;
}

.message-list {
  max-height: 420px;
  overflow: auto;
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.22);
}

.message-bubble {
  width: fit-content;
  max-width: 84%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
}

.message-bubble.mine {
  justify-self: end;
  border-color: rgba(242, 198, 109, 0.34);
  background: rgba(242, 198, 109, 0.14);
}

.message-bubble p {
  margin: 0 0 5px;
}

.message-bubble span {
  color: var(--muted);
  font-size: 11px;
}

.message-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px;
  gap: 8px;
  margin-top: 12px;
}

.edit-profile-card {
  width: min(560px, 100%);
  display: grid;
  gap: 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.edit-profile-hero {
  justify-content: flex-start;
}

@media (max-width: 860px) {
  .history-grid,
  .profile-hero {
    grid-template-columns: 1fr;
  }

  .profile-hero {
    display: grid;
  }

  .game-card {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .result-badge,
  .review-chip {
    width: fit-content;
  }

  .friends-layout,
  .friend-card,
  .friend-add {
    grid-template-columns: 1fr;
  }

  .message-panel {
    position: static;
  }
}

.logout-button {
  min-height: 44px;
  padding: 0 16px;
}
