.demo-stage {
  display: grid;
  place-items: center;
  min-height: 608px;
}

.iphone {
  position: relative;
  zoom: 0.8;
  width: 422px;
  height: 894px;
  padding: 6px;
  border: 1px solid #303030;
  border-radius: 48px;
  background: #111;
  box-shadow:
    0 0 48px rgba(0, 255, 200, 0.14),
    0 0 112px rgba(0, 255, 200, 0.07);
}

.iphone-screen {
  width: 100%;
  height: 100%;
  overflow: hidden;
  border: 1px solid #202020;
  border-radius: 42px;
  background: #000;
  box-shadow: inset 0 0 0 1px #090909;
}

.demo-controls {
  position: absolute;
  top: 853px;
  right: 32px;
  left: 32px;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 36px;
  align-items: center;
  gap: 8px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
  transition: opacity 150ms ease-out, transform 150ms ease-out;
}

.iphone:hover .demo-controls,
.iphone:focus-within .demo-controls {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.demo-controls button {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  padding: 0;
  border: 0;
  background: transparent;
  color: #00ffc8;
  cursor: pointer;
  justify-self: center;
}

.demo-controls button .app-icon { width: 18px; height: 18px; grid-area: 1 / 1; }
.demo-controls button[data-state='pause'] .app-icon:last-child,
.demo-controls button[data-state='play'] .app-icon:first-child { display: none; }

.demo-progress {
  --timeline-progress: 0%;
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  min-width: 0;
  height: 28px;
  margin: 0;
  padding: 0;
  background:
    linear-gradient(to right, #00ffc8 0%, #00ffc8 var(--timeline-progress), #374151 var(--timeline-progress), #374151 100%)
    center / 100% 2px no-repeat;
  cursor: pointer;
}

.demo-progress::-webkit-slider-runnable-track {
  height: 2px;
  border: 0;
  background: transparent;
}

.demo-progress::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 8px;
  height: 8px;
  margin-top: -3px;
  border: 0;
  border-radius: 50%;
  background: #fff;
}

.demo-progress::-moz-range-track {
  height: 2px;
  border: 0;
  background: transparent;
}

.demo-progress::-moz-range-thumb {
  width: 8px;
  height: 8px;
  border: 0;
  border-radius: 50%;
  background: #fff;
}

.demo-progress:focus-visible { outline: 1px solid rgb(255 255 255 / 42%); outline-offset: 2px; }

.demo-time {
  display: grid;
  height: 28px;
  place-items: center;
  justify-self: center;
  width: 36px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.app-screen {
  --surface: #000000;
  --surface-sheet: #111827;
  --surface-row: #0c1219;
  --surface-accent: #1f2937;
  --text-primary: #ffffff;
  --text-secondary: #d1d5db;
  --text-muted: #9ca3af;
  --board-light: #69787d;
  --board-dark: #4c5c66;
  --board-selected: #00d4ff;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --header-slot: 56px;
  --wordmark-size: 30px;
  --clock-size: 15px;
  --clock-height: 24px;
  --capture-height: 26px;
  --board-band-height: 42px;
  --move-row-height: 30px;
  --coach-sheet-travel: 301px;
  position: relative;
  height: 100%;
  background: var(--surface);
  color: var(--text-primary);
  font-size: var(--clock-size);
  line-height: normal;
}

.iphone-island {
  position: absolute;
  top: 7px;
  left: 50%;
  width: 88px;
  height: 19px;
  border-radius: 999px;
  background: #000;
  transform: translateX(-50%);
}

.app-header,
.game-status {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-muted);
  font-weight: 400;
}

.app-header {
  position: absolute;
  top: 47px;
  right: 0;
  left: 0;
  display: grid;
  grid-template-columns: var(--header-slot) minmax(0, 1fr) var(--header-slot);
  height: var(--header-slot);
  padding: 0;
  color: var(--text-secondary);
}

.app-header strong {
  grid-column: 2;
  justify-self: center;
  color: #00ffc8;
  font-size: var(--wordmark-size);
  font-weight: 800;
}

.app-action {
  display: grid;
  width: var(--header-slot);
  height: 100%;
  place-items: center;
}

.app-action:active .app-icon {
  transform: translateY(2px);
  transition-duration: 0ms;
}

.app-icon {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  transition: transform 90ms ease-out;
}

.game-status {
  height: var(--board-band-height);
  padding: 0;
  font-size: var(--clock-size);
}

.game-status span:first-child,
.game-status span:nth-child(2) { color: var(--text-primary); }
.game-status span:last-child { color: var(--text-muted); }

.board-stack {
  position: absolute;
  top: 220px;
  left: 18px;
  width: 370px;
  height: 454px;
}

.app-board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  overflow: hidden;
  position: relative;
  width: 370px;
  height: 370px;
  flex: 0 0 auto;
  aspect-ratio: 1;
  margin: 0;
  background: var(--board-light);
}

.board-square {
  position: relative;
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  background: var(--board-light);
}

.board-square:nth-child(16n + 2),
.board-square:nth-child(16n + 4),
.board-square:nth-child(16n + 6),
.board-square:nth-child(16n + 8),
.board-square:nth-child(16n + 9),
.board-square:nth-child(16n + 11),
.board-square:nth-child(16n + 13),
.board-square:nth-child(16n + 15) {
  background: var(--board-dark);
}

.board-square.last-move-from { background: rgb(0 212 255 / 30%); }
.board-square.last-move-to { background: rgb(0 212 255 / 60%); }
.board-square.coach-lit { background: rgb(177 77 255 / 60%); }
.board-square.coach-lit-around { background: rgb(177 77 255 / 30%); }
.board-square.coach-instead-from { background: rgb(91 255 61 / 30%); }
.board-square.coach-instead-to { background: rgb(91 255 61 / 60%); }

.piece { display: grid; width: 100%; height: 100%; place-items: center; }
.piece-flight {
  position: absolute;
  display: grid;
  width: 46.25px;
  height: 46.25px;
  place-items: center;
  z-index: 1;
}
.piece-lift {
  display: block;
  width: 100%;
  height: 100%;
}
.piece-sprite {
  display: block;
  width: 100%;
  height: 100%;
  background-image: url('/pieces.png');
  background-repeat: no-repeat;
  background-size: 600% 200%;
}
.piece-sprite.pawn { background-position: 0% 0%; }
.piece-sprite.knight { background-position: 20% 0%; }
.piece-sprite.bishop { background-position: 40% 0%; }
.piece-sprite.rook { background-position: 60% 0%; }
.piece-sprite.queen { background-position: 80% 0%; }
.piece-sprite.king { background-position: 100% 0%; }
.piece-sprite.black { background-position-y: 100%; }

.capture-piece {
  display: inline-block;
  width: 22px;
  height: 22px;
  vertical-align: middle;
  background-image: url('/pieces.png');
  background-repeat: no-repeat;
  background-size: 600% 200%;
  background-position: 0% 0%;
}
.capture-piece.knight { background-position-x: 20%; }
.capture-piece.bishop { background-position-x: 40%; }
.capture-piece.rook { background-position-x: 60%; }
.capture-piece.queen { background-position-x: 80%; }
.capture-piece.king { background-position-x: 100%; }
.capture-piece {
  filter:
    drop-shadow(1.5px 0 #000)
    drop-shadow(-1.5px 0 #000)
    drop-shadow(0 1.5px #000)
    drop-shadow(0 -1.5px #000);
}
.capture-piece + .capture-piece { margin-left: -15px; }

.captures {
  position: relative;
  right: 0;
  left: 0;
  box-sizing: border-box;
  height: var(--board-band-height);
  margin: 0;
  padding: 8px 0;
  color: #fff;
  font-family: var(--face);
  font-size: var(--clock-size);
}
.captures > span {
  display: flex;
  height: var(--capture-height);
  width: 100%;
  justify-content: space-between;
}
.capture-side { display: flex; align-items: center; }
.capture-side.opponent { justify-content: flex-end; }
.capture-side b { margin-left: 8px; font-weight: 400; }

.move-list {
  position: absolute;
  top: 674px;
  right: 18px;
  left: 18px;
  color: var(--text-secondary);
  font-family: var(--face);
  font-weight: 400;
  font-size: 17px;
}

.move-list > div {
  display: grid;
  grid-template-columns: 36px 1fr 1fr;
  align-items: center;
  min-height: var(--move-row-height);
  padding: 0;
}

.move-list > div:nth-child(even) { background: var(--surface-row); }
.move-list > div > span {
  color: var(--text-muted);
  padding-right: var(--space-sm);
  text-align: right;
}
.move-list b {
  display: flex;
  align-items: center;
  align-self: stretch;
  padding-left: var(--space-md);
  font-weight: 400;
}
.move-list .selected { background: var(--surface-accent); color: var(--text-primary); }

.coach-area {
  position: absolute;
  top: 559px;
  right: 0;
  bottom: 34px;
  left: 0;
  overflow: hidden;
}

.coach-sheet {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: 16px;
  border-top: 2px solid #374151;
  background: var(--surface-sheet);
  transform: translateY(var(--coach-sheet-travel));
  will-change: transform;
}


.coach-grip {
  align-self: center;
  width: 32px;
  height: 2px;
  background: #374151;
}

.coach-reading {
  flex: 1;
  min-height: 0;
  margin-top: 16px;
  overflow-y: auto;
}
.coach-words { display: grid; gap: 16px; }
.coach-words strong {
  color: #eab308;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.15px;
}
.coach-words p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 400;
  line-height: normal;
}
.coach-words .coach-instead { color: #5bff3d; }

.coach-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 24px;
}
.coach-controls span {
  display: grid;
  height: 44px;
  place-items: center;
  border: 2px solid var(--text-primary);
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 700;
  transition: transform 90ms ease-in;
}
.coach-controls span.pressed { transform: translateY(2px); transition-duration: 0ms; }

.notation-piece {
  display: inline-block;
  width: 20px;
  height: 20px;
  margin-right: 2px;
  background-image: url('/pieces.png');
  background-repeat: no-repeat;
  background-size: 600% 200%;
  background-position: 20% 0%;
}
.notation-piece.bishop { background-position-x: 40%; }

@media (max-width: 700px) {
  .demo-stage { min-height: 0; }
  .iphone { zoom: calc((100vw - 48px) / 422px); }
  .demo-progress::-webkit-slider-thumb {
    width: 16px;
    height: 16px;
    margin-top: -7px;
  }
  .demo-progress::-moz-range-thumb {
    width: 16px;
    height: 16px;
  }
}
