/* =========================================================
   CHESSTRX — INTERFAZ VISUAL DEFINITIVA V2
   Diseño general, bienvenida, tablero y políticas.
========================================================= */

:root {
  --trx-bg-main: #030812;
  --trx-bg-secondary: #071426;
  --trx-panel: rgba(6, 20, 37, 0.88);
  --trx-panel-light: rgba(13, 39, 64, 0.83);
  --trx-border: rgba(0, 234, 255, 0.42);
  --trx-border-soft: rgba(255, 255, 255, 0.09);
  --trx-cyan: #00eaff;
  --trx-cyan-soft: #73f6ff;
  --trx-green: #63ff34;
  --trx-gold: #f5c85b;
  --trx-gold-light: #ffe9a0;
  --trx-red: #ff5364;
  --trx-text: #f8fbff;
  --trx-muted: #9eb0c5;
  --trx-shadow:
    0 18px 55px rgba(0, 0, 0, 0.48),
    0 0 28px rgba(0, 218, 255, 0.07);
}

html {
  color-scheme: dark;
  background: var(--trx-bg-main);
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  color: var(--trx-text);
  background:
    radial-gradient(
      circle at 50% -10%,
      rgba(0, 234, 255, 0.16),
      transparent 38%
    ),
    radial-gradient(
      circle at 0% 45%,
      rgba(0, 100, 255, 0.11),
      transparent 38%
    ),
    linear-gradient(
      180deg,
      #020711 0%,
      #061528 48%,
      #020711 100%
    );
  background-attachment: fixed;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.27;
  background-image:
    linear-gradient(
      rgba(255, 255, 255, 0.018) 1px,
      transparent 1px
    ),
    linear-gradient(
      90deg,
      rgba(255, 255, 255, 0.018) 1px,
      transparent 1px
    );
  background-size: 32px 32px;
  mask-image:
    linear-gradient(
      to bottom,
      rgba(0,0,0,.8),
      transparent
    );
}

.app {
  width: min(100%, 760px);
  margin: 0 auto;
  padding:
    17px
    14px
    max(36px, env(safe-area-inset-bottom));
  box-sizing: border-box;
}

.app > h1 {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  margin: 3px 0 17px;
  padding: 0;
  font-size: 25px;
  line-height: 1;
  letter-spacing: -0.7px;
  text-shadow:
    0 0 17px rgba(0, 234, 255, 0.33);
}

.chesstrx-main-brand-icon {
  display: grid;
  place-items: center;
  width: 43px;
  height: 43px;
  color: #06121e;
  font-size: 24px;
  border-radius: 14px;
  background:
    linear-gradient(
      145deg,
      var(--trx-gold-light),
      var(--trx-gold)
    );
  box-shadow:
    0 8px 22px rgba(245, 200, 91, 0.23);
}

.chesstrx-main-brand-name {
  display: flex;
  flex-direction: column;
  text-align: left;
}

.chesstrx-main-brand-name b {
  color: #ffffff;
  font-size: 25px;
}

.chesstrx-main-brand-name b span {
  color: var(--trx-cyan);
}

.chesstrx-main-brand-name small {
  margin-top: 4px;
  color: var(--trx-muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 2.2px;
  text-transform: uppercase;
}

.timer,
.player-box,
.status,
.moves,
.stats,
.ranking-panel,
#dghLobbyPanel,
#chessRankingPanel {
  border:
    1px solid var(--trx-border) !important;
  background:
    linear-gradient(
      145deg,
      rgba(8, 31, 53, 0.92),
      rgba(2, 12, 24, 0.94)
    ) !important;
  box-shadow: var(--trx-shadow);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.timer {
  margin-bottom: 14px;
  padding: 12px 16px !important;
  border-radius: 17px !important;
  color: var(--trx-muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
}

#gameTimer {
  display: inline-block;
  margin-top: 4px;
  color: var(--trx-cyan);
  font-size: 25px;
  font-weight: 900;
  letter-spacing: 1.6px;
  text-shadow:
    0 0 15px rgba(0, 234, 255, 0.48);
}

.top-info {
  gap: 11px !important;
  margin-bottom: 14px;
}

.player-box {
  position: relative;
  overflow: hidden;
  min-width: 0;
  padding: 15px 10px !important;
  border-radius: 21px !important;
}

.player-box::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 2px;
  background:
    linear-gradient(
      90deg,
      transparent,
      var(--trx-cyan),
      transparent
    );
}

.player-title {
  color: var(--trx-muted) !important;
  font-size: 11px !important;
  font-weight: 900 !important;
  letter-spacing: 1.8px;
}

.player-id {
  overflow: hidden;
  margin-top: 5px;
  color: var(--trx-cyan) !important;
  font-size: clamp(14px, 4vw, 19px) !important;
  font-weight: 900 !important;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-balance {
  margin-top: 8px;
  color: var(--trx-green) !important;
  font-size: clamp(17px, 5vw, 24px) !important;
  font-weight: 900 !important;
  text-shadow:
    0 0 16px rgba(99, 255, 52, 0.22);
}

.status {
  margin: 0 0 18px !important;
  padding: 14px 15px !important;
  border-radius: 19px !important;
  color: #ffffff;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.45;
}

.board-wrap {
  filter:
    drop-shadow(0 17px 27px rgba(0, 0, 0, 0.48))
    drop-shadow(0 0 15px rgba(0, 234, 255, 0.16));
}

#board,
.board {
  overflow: hidden;
  border:
    6px solid var(--trx-cyan) !important;
  border-radius: 25px !important;
  box-shadow:
    0 0 0 2px rgba(255, 255, 255, 0.05),
    0 0 29px rgba(0, 234, 255, 0.38),
    inset 0 0 24px rgba(0, 0, 0, 0.24) !important;
}

.square {
  transition:
    filter 0.12s ease,
    transform 0.12s ease,
    box-shadow 0.12s ease;
}

.square:active {
  filter: brightness(1.12);
}

button {
  min-height: 46px;
  padding: 11px 16px;
  color: #06121d;
  font-size: 14px;
  font-weight: 900;
  border: 0;
  border-radius: 15px;
  cursor: pointer;
  background:
    linear-gradient(
      145deg,
      #8ff9ff,
      #00d9ef
    );
  box-shadow:
    0 9px 22px rgba(0, 218, 239, 0.18);
  transition:
    transform 0.15s ease,
    filter 0.15s ease,
    opacity 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

button:active {
  transform: scale(0.975);
  filter: brightness(0.93);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.47;
  box-shadow: none;
}

button.danger,
#resignBtn {
  color: #ffffff;
  background:
    linear-gradient(
      145deg,
      #ff6879,
      #d72f45
    );
  box-shadow:
    0 9px 22px rgba(215, 47, 69, 0.2);
}

#createBetBtn {
  background:
    linear-gradient(
      145deg,
      var(--trx-gold-light),
      var(--trx-gold)
    );
}

input,
select,
textarea {
  min-height: 47px;
  padding: 10px 13px;
  box-sizing: border-box;
  color: #ffffff;
  font-size: 15px;
  font-weight: 700;
  outline: none;
  border:
    1px solid rgba(0, 234, 255, 0.34);
  border-radius: 14px;
  background: rgba(3, 15, 29, 0.92);
  box-shadow:
    inset 0 2px 7px rgba(0, 0, 0, 0.25);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--trx-cyan);
  box-shadow:
    0 0 0 3px rgba(0, 234, 255, 0.11);
}

.moves,
.stats,
#dghLobbyPanel,
#chessRankingPanel {
  margin-top: 15px !important;
  padding: 16px !important;
  border-radius: 20px !important;
  color: #dbe8f5;
  line-height: 1.55;
}

.available-player-card {
  border:
    1px solid rgba(0, 234, 255, 0.30) !important;
  border-radius: 17px !important;
  background:
    linear-gradient(
      145deg,
      rgba(16, 48, 76, 0.64),
      rgba(3, 17, 31, 0.82)
    ) !important;
  box-shadow:
    0 9px 22px rgba(0, 0, 0, 0.22);
}

.ranking-toggle {
  color: #11100a !important;
  background:
    linear-gradient(
      145deg,
      var(--trx-gold-light),
      var(--trx-gold)
    ) !important;
}

.ranking-player-row {
  border-bottom:
    1px solid rgba(255, 255, 255, 0.07);
}

.ranking-player-row.current-player {
  border:
    1px solid rgba(0, 234, 255, 0.36);
  border-radius: 12px;
  background:
    rgba(0, 234, 255, 0.08);
}

/* =========================================================
   BIENVENIDA FINAL
========================================================= */

#chesstrxWelcomeV1 {
  padding:
    max(17px, env(safe-area-inset-top))
    14px
    max(19px, env(safe-area-inset-bottom)) !important;
  background:
    radial-gradient(
      circle at 50% 0%,
      rgba(0, 234, 255, 0.18),
      transparent 34%
    ),
    radial-gradient(
      circle at 90% 25%,
      rgba(245, 200, 91, 0.14),
      transparent 34%
    ),
    linear-gradient(
      180deg,
      #020610,
      #07172a 53%,
      #020610
    ) !important;
}

.chesstrx-welcome-glow {
  width: 310px !important;
  height: 310px !important;
  background:
    rgba(0, 234, 255, 0.11) !important;
}

.chesstrx-welcome-card {
  width: min(100%, 455px) !important;
  padding: 23px 19px 19px !important;
  border:
    1px solid rgba(0, 234, 255, 0.32) !important;
  border-radius: 29px !important;
  background:
    linear-gradient(
      155deg,
      rgba(12, 35, 57, 0.97),
      rgba(3, 10, 21, 0.99)
    ) !important;
  box-shadow:
    0 30px 75px rgba(0, 0, 0, 0.58),
    0 0 34px rgba(0, 234, 255, 0.10),
    inset 0 1px 0 rgba(255, 255, 255, 0.07) !important;
}

.chesstrx-welcome-card::before {
  height: 3px !important;
  background:
    linear-gradient(
      90deg,
      transparent,
      var(--trx-cyan),
      #ffffff,
      var(--trx-gold),
      transparent
    ) !important;
}

.chesstrx-welcome-logo.chesstrx-user-card-v2 {
  display: flex !important;
  align-items: center;
  width: 100% !important;
  height: auto !important;
  margin: 0 auto 17px !important;
  padding: 12px !important;
  box-sizing: border-box;
  color: #ffffff !important;
  text-align: left;
  border:
    1px solid rgba(0, 234, 255, 0.22) !important;
  border-radius: 20px !important;
  background:
    linear-gradient(
      145deg,
      rgba(0, 234, 255, 0.075),
      rgba(255, 255, 255, 0.025)
    ) !important;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.055) !important;
}

.chesstrx-avatar-ring {
  position: relative;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 66px;
  height: 66px;
  overflow: hidden;
  border:
    2px solid var(--trx-cyan);
  border-radius: 50%;
  background:
    linear-gradient(
      145deg,
      #153651,
      #07121e
    );
  box-shadow:
    0 0 0 4px rgba(0, 234, 255, 0.08),
    0 0 22px rgba(0, 234, 255, 0.23);
}

.chesstrx-avatar-ring img {
  display: none;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chesstrx-avatar-ring.has-photo img {
  display: block;
}

.chesstrx-avatar-ring.has-photo
.chesstrx-avatar-fallback {
  display: none;
}

.chesstrx-avatar-fallback {
  color: var(--trx-cyan-soft);
  font-size: 24px;
  font-weight: 900;
  letter-spacing: -1px;
}

.chesstrx-profile-copy {
  min-width: 0;
  margin-left: 13px;
}

.chesstrx-profile-copy small {
  display: block;
  margin-bottom: 4px;
  color: var(--trx-gold);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 2px;
}

.chesstrx-profile-copy strong {
  display: block;
  overflow: hidden;
  color: #ffffff;
  font-size: 17px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chesstrx-profile-copy span {
  display: block;
  margin-top: 5px;
  color: var(--trx-muted);
  font-size: 10px;
  line-height: 1.3;
}

.chesstrx-welcome-kicker {
  color: var(--trx-gold) !important;
}

.chesstrx-welcome-title {
  font-size: clamp(36px, 10vw, 49px) !important;
  text-shadow:
    0 0 24px rgba(0, 234, 255, 0.13);
}

.chesstrx-welcome-title span {
  color: var(--trx-cyan) !important;
}

.chesstrx-welcome-subtitle {
  margin:
    11px auto
    17px !important;
  color: #bdcadd !important;
}

.chesstrx-welcome-features {
  gap: 8px !important;
  margin-bottom: 17px !important;
}

.chesstrx-welcome-feature {
  min-height: 57px !important;
  border:
    1px solid rgba(0, 234, 255, 0.12) !important;
  background:
    rgba(0, 234, 255, 0.035) !important;
}

.chesstrx-welcome-feature-icon {
  color: var(--trx-gold-light);
  background:
    rgba(245, 200, 91, 0.10) !important;
}

#chesstrxWelcomeEnterV1 {
  color: #04121d !important;
  background:
    linear-gradient(
      135deg,
      #a8fbff 0%,
      #00eaff 52%,
      #00a7c2 100%
    ) !important;
  box-shadow:
    0 13px 30px rgba(0, 218, 255, 0.23),
    inset 0 1px 0 rgba(255, 255, 255, 0.75) !important;
}

.chesstrx-welcome-footer {
  margin: 14px 0 0 !important;
  color: #8291a5 !important;
  font-size: 10px !important;
  line-height: 1.5 !important;
}

.chesstrx-welcome-footer-main {
  margin: 0;
}

.chesstrx-legal-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 9px;
  margin-top: 9px;
}

.chesstrx-legal-link {
  min-height: 0 !important;
  padding: 2px 0 !important;
  color: var(--trx-cyan-soft) !important;
  font-size: 10px !important;
  font-weight: 700 !important;
  text-decoration: underline;
  text-underline-offset: 3px;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

.chesstrx-copyright {
  margin: 10px 0 0;
  color: #58677a;
  font-size: 9px;
  letter-spacing: 0.25px;
}

/* =========================================================
   MODAL DE REGLAS Y POLÍTICAS
========================================================= */

#chesstrxPolicyModalV2 {
  position: fixed;
  inset: 0;
  z-index: 1000000;
  display: none;
  align-items: flex-end;
  justify-content: center;
  padding:
    18px
    14px
    max(18px, env(safe-area-inset-bottom));
  box-sizing: border-box;
  background:
    rgba(0, 4, 10, 0.80);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

#chesstrxPolicyModalV2.is-open {
  display: flex;
}

.chesstrx-policy-dialog {
  width: min(100%, 560px);
  max-height: min(82vh, 720px);
  overflow: hidden;
  color: #ffffff;
  border:
    1px solid rgba(0, 234, 255, 0.38);
  border-radius: 25px;
  background:
    linear-gradient(
      155deg,
      #0a2740,
      #030b16
    );
  box-shadow:
    0 26px 80px rgba(0, 0, 0, 0.7),
    0 0 30px rgba(0, 234, 255, 0.11);
  animation:
    chesstrxPolicyOpenV2
    0.24s
    ease-out;
}

@keyframes chesstrxPolicyOpenV2 {
  from {
    opacity: 0;
    transform: translateY(25px) scale(0.97);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.chesstrx-policy-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 17px 17px 14px;
  border-bottom:
    1px solid rgba(255, 255, 255, 0.08);
}

.chesstrx-policy-header h2 {
  margin: 0;
  color: #ffffff;
  font-size: 19px;
}

#chesstrxPolicyCloseV2 {
  display: grid;
  place-items: center;
  width: 38px;
  min-height: 38px;
  padding: 0;
  color: #ffffff;
  font-size: 22px;
  border:
    1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  background:
    rgba(255, 255, 255, 0.06);
  box-shadow: none;
}

.chesstrx-policy-content {
  max-height: calc(82vh - 75px);
  overflow-y: auto;
  padding: 17px;
  color: #cbd7e5;
  font-size: 14px;
  line-height: 1.65;
}

.chesstrx-policy-content h3 {
  margin: 18px 0 7px;
  color: var(--trx-cyan-soft);
  font-size: 15px;
}

.chesstrx-policy-content h3:first-child {
  margin-top: 0;
}

.chesstrx-policy-content p {
  margin: 0 0 11px;
}

.chesstrx-policy-content ul {
  margin: 7px 0 14px;
  padding-left: 20px;
}

.chesstrx-policy-content li {
  margin-bottom: 8px;
}

.chesstrx-policy-highlight {
  padding: 12px;
  color: #ffffff;
  border:
    1px solid rgba(245, 200, 91, 0.23);
  border-radius: 14px;
  background:
    rgba(245, 200, 91, 0.07);
}

.chesstrx-support-button {
  display: block;
  margin-top: 16px;
  padding: 13px 16px;
  color: #04121d !important;
  font-weight: 900;
  text-align: center;
  text-decoration: none;
  border-radius: 14px;
  background:
    linear-gradient(
      145deg,
      #a8fbff,
      #00dcec
    );
}

/* Pantallas pequeñas */

@media (max-width: 390px) {
  .app {
    padding-left: 10px;
    padding-right: 10px;
  }

  .chesstrx-welcome-card {
    padding:
      19px
      14px
      16px !important;
    border-radius: 24px !important;
  }

  .chesstrx-avatar-ring {
    width: 58px;
    height: 58px;
  }

  .chesstrx-profile-copy strong {
    font-size: 15px;
  }

  .chesstrx-welcome-features {
    gap: 6px !important;
  }

  .chesstrx-welcome-feature {
    padding: 8px 7px !important;
  }

  .chesstrx-welcome-feature strong {
    font-size: 11px !important;
  }

  .chesstrx-welcome-feature small {
    font-size: 9px !important;
  }

  .top-info {
    gap: 7px !important;
  }

  .player-box {
    padding:
      13px
      7px !important;
  }
}
