/* In-phone Chess — dark green table, green and white board */

.wondalife-phone-screen.is-app:has(.chess-app) {
  background: #08140d;
}
.wondalife-phone-screen.is-app:has(.chess-app) .wondalife-phone-status {
  color: #f5f7f4;
}
.wondalife-phone-screen.is-app:has(.chess-app) .wondalife-phone-signal::before {
  background: #f5f7f4;
  box-shadow: 4px 0 0 #f5f7f4, 8px -2px 0 #f5f7f4, 12px -4px 0 #f5f7f4;
}
.wondalife-phone-screen.is-app:has(.chess-app) .wondalife-phone-battery {
  border-color: #f5f7f4;
}
.wondalife-phone-screen.is-app:has(.chess-app) .wondalife-phone-battery::before,
.wondalife-phone-screen.is-app:has(.chess-app) .wondalife-phone-battery::after {
  background: #f5f7f4;
}
.wondalife-phone-screen.is-app:has(.chess-app) .wondalife-phone-homebar {
  background: rgba(245, 247, 244, 0.35);
}
.wondalife-phone-screen.is-app .wondalife-phone-body:has(.chess-app) {
  padding: 0 0 22px;
  overflow: hidden;
  height: 100%;
}

.chess-app {
  --gold: #f2c94c;
  --sq-light: #f1f4ef;
  --sq-dark: #22ad69;
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding-bottom: 24px;
  background: radial-gradient(120% 70% at 50% 0%, #163524 0%, #0b1d13 55%, #07120c 100%);
  color: #f5f7f4;
  font-family: Poppins, "Segoe UI", system-ui, sans-serif;
  overflow: hidden;
  z-index: 4;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.chess-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

/* Header */
.chess-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px 12px 6px;
  flex-shrink: 0;
}
.chess-head__title {
  min-width: 0;
}
.chess-head h1 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
}
.chess-head__icon {
  display: inline-block;
  width: 1.35em;
  height: 1.55em;
  margin: -0.35em 0 0 -0.15em;
  vertical-align: -0.18em;
  filter: drop-shadow(0 1px 1.5px rgba(0, 0, 0, 0.45));
}
.chess-head p {
  margin: 1px 0 0;
  font-size: 10.5px;
  color: rgba(245, 247, 244, 0.6);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chess-head__actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.chess-x {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.chess-hold {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding: 7px 11px;
  font: 600 10.5px/1 Poppins, "Segoe UI", sans-serif;
  color: #e8f0e9;
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
  touch-action: none;
}
.chess-hold span {
  position: relative;
}
.chess-hold::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, #c62f3d, #e5484d);
  transform: scaleX(0);
  transform-origin: left center;
}
.chess-hold.is-holding::before {
  animation: chess-hold 1.2s linear both;
  animation-delay: var(--hold-delay, 0ms);
}
@keyframes chess-hold {
  to { transform: scaleX(1); }
}
.chess-live {
  font-size: 10.5px;
  font-weight: 600;
  color: #ff8a8a;
}

/* Players */
.chess-players {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 0 10px 6px;
  flex-shrink: 0;
}
.chess-player {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 5px 10px 5px 5px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.06);
  border: 1.5px solid transparent;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.chess-player--right {
  flex-direction: row-reverse;
  padding: 5px 5px 5px 10px;
  text-align: right;
}
.chess-player.is-active {
  border-color: rgba(242, 201, 76, 0.85);
  background: rgba(242, 201, 76, 0.08);
  box-shadow: 0 0 14px rgba(242, 201, 76, 0.18);
}
.chess-player__av {
  --pct: 0;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  padding: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
}
.chess-player.is-active .chess-player__av {
  background: conic-gradient(var(--gold) calc(var(--pct) * 1%), rgba(255, 255, 255, 0.14) 0);
}
.chess-player__av img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 999px;
  object-fit: cover;
  object-position: center top;
  background: linear-gradient(180deg, #dfe9e3, #b8cbbf);
  border: 2px solid #0b1d13;
}
.chess-player__txt {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.chess-player__txt strong {
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chess-player__txt span {
  font-size: 10.5px;
  color: rgba(245, 247, 244, 0.6);
}
.chess-player__txt em {
  font-style: normal;
  color: #ff8a8a;
  font-weight: 600;
}
.chess-bubble {
  position: absolute;
  top: -10px;
  left: 30px;
  z-index: 6;
  font-size: 24px;
  line-height: 1;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.4));
  animation: chess-bubble 2.6s ease-out both;
  pointer-events: none;
}
.chess-player--right .chess-bubble {
  left: auto;
  right: 30px;
}
@keyframes chess-bubble {
  0% { opacity: 0; transform: translateY(8px) scale(0.4); }
  12% { opacity: 1; transform: translateY(-4px) scale(1.15); }
  20% { transform: translateY(-2px) scale(1); }
  80% { opacity: 1; transform: translateY(-8px) scale(1); }
  100% { opacity: 0; transform: translateY(-16px) scale(0.9); }
}

/* Last move + reactions */
.chess-log {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px 4px;
  flex-shrink: 0;
}
.chess-log__line {
  flex: 1;
  min-width: 0;
  border: 0;
  border-radius: 999px;
  padding: 7px 12px;
  background: rgba(255, 255, 255, 0.07);
  color: #e9efe9;
  font: 500 11.5px/1.2 Poppins, "Segoe UI", sans-serif;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
.chess-react {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 17px;
  cursor: pointer;
}
.chess-reacts {
  position: absolute;
  right: 10px;
  top: calc(100% + 2px);
  z-index: 12;
  display: flex;
  gap: 2px;
  padding: 4px;
  border-radius: 999px;
  background: #11291b;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.45);
  animation: chess-pop 0.18s ease-out both;
}
.chess-reacts button {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  font-size: 19px;
  cursor: pointer;
}
.chess-reacts button:hover {
  background: rgba(255, 255, 255, 0.1);
}
@keyframes chess-pop {
  from { opacity: 0; transform: translateY(-4px) scale(0.92); }
  to { opacity: 1; transform: none; }
}

/* Board stage: the board takes the largest square that fits between the two clock rows. */
.chess-stage {
  --board: min(100cqw, 100cqh - 72px);
  flex: 1;
  min-height: 0;
  container-type: size;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 10px;
}
.chess-side {
  width: var(--board);
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.chess-side__end {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
}
.chess-side__cue {
  white-space: nowrap;
}
.chess-caps {
  display: flex;
  align-items: center;
  min-width: 0;
  height: 20px;
}
.chess-cap {
  width: 19px;
  height: 19px;
  margin-right: -7px;
  flex-shrink: 0;
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.35));
}
.chess-cap.chess-pc--b {
  --line: #b9c7bf;
  --detail: #b9c7bf;
}
.chess-cap.is-new-kind {
  margin-left: 6px;
}
.chess-caps b {
  margin-left: 12px;
  font-size: 11px;
  font-weight: 600;
  color: rgba(245, 247, 244, 0.75);
}
.chess-clock {
  min-width: 74px;
  padding: 4px 12px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.32);
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: rgba(245, 247, 244, 0.78);
  font: 600 19px/1.15 Poppins, "Segoe UI", sans-serif;
  font-variant-numeric: tabular-nums;
  text-align: right;
  transition: background 0.2s ease, color 0.2s ease;
}
.chess-clock.is-on {
  background: #fff;
  color: #10231a;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}
.chess-clock.is-on.is-low {
  background: #ffe7a3;
}
.chess-clock.is-critical {
  background: #e5334b;
  color: #fff;
}
.chess-clock.is-on.is-critical {
  background: #e5334b;
  color: #fff;
  animation: chess-critical 1s ease-in-out infinite;
}
@keyframes chess-critical {
  50% { box-shadow: 0 0 0 4px rgba(229, 51, 75, 0.35); }
}

.chess-board {
  position: relative;
  width: var(--board);
  height: var(--board);
  flex-shrink: 0;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  border-radius: 12px;
  box-shadow:
    0 0 0 4px #0c1f15,
    0 0 0 5px rgba(255, 255, 255, 0.07),
    0 14px 30px rgba(0, 0, 0, 0.5);
  touch-action: none;
}
.chess-sq {
  position: relative;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  margin: 0;
  background: var(--sq-light);
  cursor: default;
  font: inherit;
  color: inherit;
}
.chess-sq.is-dark {
  background: var(--sq-dark);
}
.chess-sq:nth-child(1) { border-top-left-radius: 9px; }
.chess-sq:nth-child(8) { border-top-right-radius: 9px; }
.chess-sq:nth-child(57) { border-bottom-left-radius: 9px; }
.chess-sq:nth-child(64) { border-bottom-right-radius: 9px; }
.chess-sq.is-mine {
  cursor: grab;
}
.chess-sq::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
}
.chess-sq.is-last::before {
  background: rgba(255, 220, 80, 0.5);
}
.chess-sq.is-selected::before {
  background: rgba(255, 168, 20, 0.72);
}
.chess-sq.is-check::before {
  background: radial-gradient(circle, rgba(255, 60, 60, 0.95) 0%, rgba(230, 20, 20, 0.6) 40%, rgba(230, 20, 20, 0) 72%);
}
.chess-sq.is-target,
.chess-sq.is-capture {
  cursor: pointer;
}
.chess-sq.is-target::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 30%;
  height: 30%;
  border-radius: 999px;
  transform: translate(-50%, -50%);
  background: rgba(20, 40, 30, 0.22);
  pointer-events: none;
}
.chess-sq.is-dark.is-target::after {
  background: rgba(0, 60, 30, 0.42);
}
.chess-sq.is-capture::after {
  content: "";
  position: absolute;
  inset: 4%;
  border-radius: 999px;
  border: 3.5px solid rgba(20, 40, 30, 0.28);
  pointer-events: none;
}
.chess-sq.is-dark.is-capture::after {
  border-color: rgba(0, 60, 30, 0.5);
}
.chess-sq.is-drop {
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.9);
}
.chess-coord {
  position: absolute;
  z-index: 1;
  font-style: normal;
  font-size: 8.5px;
  font-weight: 700;
  line-height: 1;
  pointer-events: none;
  color: var(--sq-dark);
}
.chess-sq.is-dark .chess-coord {
  color: var(--sq-light);
}
.chess-coord--rank {
  top: 2px;
  left: 3px;
}
.chess-coord--file {
  right: 3px;
  bottom: 2px;
}

/* Pieces */
.chess-pc,
.chess-cap {
  --fill: #fff;
  --line: #1d2026;
  --detail: #1d2026;
}
.chess-pc {
  position: relative;
  z-index: 2;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
  filter: drop-shadow(0 1.5px 0.5px rgba(0, 0, 0, 0.3));
}
.chess-pc--b {
  --fill: #2b2f37;
  --line: #0a0c0f;
  --detail: #e9ecef;
}
.chess-pc.is-sliding {
  z-index: 4;
  animation: chess-slide 0.22s cubic-bezier(0.2, 0.8, 0.3, 1) both;
}
@keyframes chess-slide {
  from { transform: translate(calc(var(--dx) * 100%), calc(var(--dy) * 100%)); }
  to { transform: none; }
}
.chess-pc.is-dragging {
  z-index: 8;
  filter: drop-shadow(0 8px 10px rgba(0, 0, 0, 0.45));
  transition: none;
}

/* Promotion: the four pieces drop down the promotion file */
.chess-promo {
  position: absolute;
  inset: 0;
  z-index: 10;
  border-radius: 12px;
  background: rgba(4, 12, 8, 0.55);
}
.chess-promo__col {
  position: absolute;
  top: 0;
  left: calc(var(--col) * 12.5%);
  width: 12.5%;
  display: flex;
  flex-direction: column;
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.55);
  animation: chess-pop 0.16s ease-out both;
}
.chess-promo__btn {
  aspect-ratio: 1;
  padding: 6%;
  border: 0;
  background: #fff;
  cursor: pointer;
}
.chess-promo__btn:hover {
  background: #e7f6ee;
}
.chess-promo__x {
  height: 26px;
  border: 0;
  background: #eef1ee;
  color: #10231a;
  font-size: 16px;
  cursor: pointer;
}

/* Footer */
.chess-foot {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 6px 12px 4px;
}
.chess-prompt {
  margin: 0;
  font-size: 12px;
  color: rgba(245, 247, 244, 0.72);
  text-align: center;
}
.chess-prompt.is-you {
  color: #fff;
  font-weight: 600;
}
.chess-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
}
.chess-act {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.07);
  color: #e9efe9;
  font: 600 11px/1.2 Poppins, "Segoe UI", sans-serif;
  cursor: pointer;
}
.chess-act:disabled {
  opacity: 0.4;
  cursor: default;
}
.chess-act--go {
  background: #1fb36a;
  border-color: transparent;
  color: #fff;
}
.chess-first {
  flex-shrink: 0;
  margin: 6px 12px 4px;
  padding: 9px 14px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.08);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.chess-first strong {
  font-size: 13px;
  font-weight: 700;
}
.chess-first strong span {
  font-variant-numeric: tabular-nums;
}
.chess-first > span {
  font-size: 10.5px;
  line-height: 1.35;
  color: rgba(245, 247, 244, 0.7);
}
.chess-first.is-you {
  background: #f6c933;
  color: #1c1606;
  box-shadow: 0 6px 18px rgba(246, 201, 51, 0.25);
}
.chess-first.is-you > span {
  color: rgba(28, 22, 6, 0.78);
}

/* Moves sheet */
.chess-sheet {
  position: absolute;
  inset: 0;
  z-index: 16;
  display: flex;
  align-items: flex-end;
  background: rgba(0, 0, 0, 0.45);
}
.chess-sheet__panel {
  width: 100%;
  max-height: 62%;
  display: flex;
  flex-direction: column;
  padding: 10px 14px 28px;
  border-radius: 20px 20px 0 0;
  background: #0f2418;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  animation: chess-sheet 0.22s ease-out both;
}
@keyframes chess-sheet {
  from { transform: translateY(40%); opacity: 0; }
  to { transform: none; opacity: 1; }
}
.chess-sheet__panel header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.chess-sheet__panel h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
}
.chess-sheet__empty {
  margin: 8px 0;
  font-size: 12px;
  color: rgba(245, 247, 244, 0.65);
}
.chess-movelist {
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-y: auto;
  scrollbar-width: thin;
}
.chess-movelist li {
  display: grid;
  grid-template-columns: 34px 1fr 1fr;
  align-items: center;
  padding: 3px 4px;
  border-radius: 8px;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}
.chess-movelist li:nth-child(odd) {
  background: rgba(255, 255, 255, 0.04);
}
.chess-movelist span {
  color: rgba(245, 247, 244, 0.5);
}
.chess-movelist b {
  font-weight: 600;
}
.chess-movelist b.is-last {
  color: var(--gold);
}

/* Result */
.chess-modal {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
}
.chess-modal__panel {
  width: min(100%, 290px);
  padding: 18px 16px 14px;
  border-radius: 24px;
  background: linear-gradient(180deg, #16352a, #0b1d13);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
  text-align: center;
  animation: chess-pop 0.25s ease-out both;
}
.chess-modal__icon {
  display: block;
  width: 54px;
  height: 62px;
  margin: -4px auto 6px;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.45));
}
.chess-modal__panel h2 {
  margin: 0 0 4px;
  font-size: 21px;
  font-weight: 700;
}
.chess-modal__panel p {
  margin: 0 0 12px;
  font-size: 12px;
  line-height: 1.4;
  color: rgba(245, 247, 244, 0.72);
}
.chess-modal__money {
  margin-bottom: 12px;
  padding: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  font-size: 15px;
  font-weight: 600;
}
.chess-modal__money.is-loss {
  background: rgba(150, 50, 50, 0.35);
  color: #ffc9c9;
}
.chess-modal__money.is-win {
  background: rgba(31, 179, 106, 0.22);
  color: #9ff0c4;
}
.chess-btn {
  width: 100%;
  border: 0;
  border-radius: 999px;
  padding: 11px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font: 600 12.5px/1.2 Poppins, "Segoe UI", sans-serif;
  cursor: pointer;
}
.chess-btn--go {
  margin-bottom: 8px;
  background: #1fb36a;
  font-size: 13.5px;
}
.chess-btn--stop {
  margin-bottom: 8px;
  background: linear-gradient(90deg, #c62f3d, #e5484d);
  font-size: 13.5px;
}
.chess-modal__panel .chess-modal__note {
  margin-top: -2px;
  font-size: 11px;
  color: rgba(245, 247, 244, 0.6);
}
.chess-modal__note span {
  color: #ffd166;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.chess-modal__row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.chess-empty {
  padding: 24px;
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  .chess-pc.is-sliding,
  .chess-bubble,
  .chess-clock.is-on.is-critical,
  .chess-sheet__panel,
  .chess-modal__panel {
    animation: none;
  }
}
