/* Internet Reversi — Windows XP presentation.

   The window is the original 547 x 514 game window. Its frame comes from a
   screenshot (assets/frame.png); everything inside the play area is a 1:1
   sprite from the original sprite sheet (assets/sprites/, built by
   tools/extract-sprites.py). Coordinates are in window pixels; children of
   .client-area are offset by the 49px caption + menu bar.

   Images are cached for a day, so every image URL carries ?v=N. After
   regenerating the assets, bump N here and in sprite() in client.js. */

:root {
  --face: #ece9d8;
  --olive-top: #c9d29a;
  --olive-bottom: #a7b67f;
  --ui-scale: 1;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: Tahoma, "MS Shell Dlg", Verdana, sans-serif;
  font-size: 11px;
  color: #000;
}

.desktop {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 35% 20%, rgba(255,255,255,.18), transparent 55%),
    linear-gradient(160deg, #8aa36a 0%, #78935e 45%, #5f7f52 100%);
}

/* Desktop shortcut that reopens the window after Close or Minimize. It
   sits behind the middle of the window (placed by fitWindow), so it only
   shows once the window is gone. */
.desktop-icon {
  position: fixed;
  left: var(--icon-x, 10px);
  top: var(--icon-y, 10px);
  width: 76px;
  padding: 2px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  border: 0;
  background: transparent;
  font: 11px Tahoma, sans-serif;
  color: #fff;
  cursor: default;
  transform: scale(var(--icon-scale, 1));
  transform-origin: 0 0;
}
.desktop-icon-image {
  width: 32px;
  height: 28px;
  background: url('/assets/sprites/zone-globe-32.png?v=2') no-repeat;
}
.desktop-icon-label {
  padding: 0 2px;
  line-height: 13px;
  text-shadow: 1px 1px 1px #000;
}
.desktop-icon:focus { outline: none; }
.desktop-icon.selected .desktop-icon-image { filter: brightness(.7) sepia(1) hue-rotate(180deg) saturate(3); }
.desktop-icon.selected .desktop-icon-label { background: #316ac5; text-shadow: none; }
.desktop-icon:focus-visible .desktop-icon-label { outline: 1px dotted #fff; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Crawlable page content; the XP window itself stays pixel-accurate. */
.site-info {
  position: fixed;
  left: 50%;
  bottom: 4px;
  transform: translateX(-50%);
  z-index: 2;
  width: min(820px, calc(100vw - 24px));
  padding: 6px 12px;
  border: 1px solid #7f7f7f;
  background: rgba(236, 233, 216, .94);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .3);
  font-size: 13px;
  line-height: 1.4;
  text-align: center;
}
.site-info h1,
.site-info p {
  display: inline;
  margin: 0;
  font: inherit;
}

/* Positioned by fitWindow() in client.js on whole device pixels and scaled
   only by whole numbers, so every sprite pixel lands on a screen pixel. */
.reversi-window {
  position: absolute;
  left: var(--window-x, 0);
  top: var(--window-y, 0);
  width: 547px;
  height: 514px;
  background: url('/assets/frame.png?v=2') no-repeat 0 0;
  /* Follows the frame's alpha, so the rounded top corners stay clean. */
  filter: drop-shadow(2px 3px 4px rgba(0,0,0,.4));
  transform: scale(var(--ui-scale));
  transform-origin: 0 0;
  image-rendering: pixelated;
  user-select: none;
}
.reversi-window.smooth { image-rendering: auto; }

/* ---------- caption bar (painted by frame.png) ---------- */
.title-bar {
  height: 28px;
  display: flex;
  align-items: center;
  padding: 0 3px 0 6px;
  color: #fff;
}
.title-icon,
.title-text { opacity: 0; }
.title-text { flex: 1; font-weight: bold; }
/* The caption buttons are painted by frame.png; these transparent buttons
   sit exactly on them and only add the hover and pressed shading. */
.caption-button {
  position: absolute;
  top: 6px;
  width: 21px;
  height: 21px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 3px;
  background: transparent no-repeat;
  cursor: default;
}
.caption-button.minimize { left: 474px; }
.caption-button.maximize { left: 497px; }
.caption-button.close    { left: 520px; }
.caption-button:hover { box-shadow: inset 0 0 0 21px rgba(255, 255, 255, .2); }
.caption-button:active { box-shadow: inset 0 0 0 21px rgba(0, 0, 0, .2); }
.caption-button:focus { outline: none; }
.caption-button:focus-visible { box-shadow: inset 0 0 0 1px #fff; }
.reversi-window.fullscreen .caption-button.maximize {
  background-image: url('/assets/sprites/caption-restore.png?v=2');
}
.reversi-window[hidden] { display: none; }

/* ---------- menu bar (labels painted by frame.png) ---------- */
.menu-bar {
  position: relative;
  height: 21px;
  display: flex;
  align-items: center;
  padding-left: 3px;
  z-index: 20;
}
.menu-item {
  height: 19px;
  padding: 0 8px;
  border: 0;
  background: transparent;
  color: transparent;
  font: inherit;
  cursor: default;
}
.menu-popup {
  position: absolute;
  top: 21px;
  left: 3px;
  min-width: 170px;
  padding: 2px;
  background: #fff;
  border: 1px solid #7f7f7f;
  box-shadow: 2px 2px 4px rgba(0,0,0,.25);
  z-index: 30;
}
.menu-popup[hidden] { display: none; }
.menu-popup button {
  display: block;
  width: 100%;
  padding: 4px 18px 4px 10px;
  text-align: left;
  border: 0;
  background: transparent;
  font: inherit;
  cursor: default;
}
.menu-popup button:hover:not(:disabled) { background: #316ac5; color: #fff; }
.menu-popup button:disabled { color: #aca899; }
.menu-popup hr { border: 0; border-top: 1px solid #d4d0c8; margin: 3px 2px; }

/* ---------- client area ---------- */
.client-area {
  position: absolute;
  left: 0;
  top: 49px;
  width: 547px;
  height: 465px;
}
.game-screen { position: absolute; inset: 0; }

/* Player panels: one sprite per name/status combination. */
.side-panel {
  position: absolute;
  height: 50px;
  background-repeat: no-repeat;
}
.left-panel  { left: 3px;   top: 26px;  width: 115px; background-image: url('/assets/sprites/left-black.png?v=2'); }
.right-panel { left: 427px; top: 285px; width: 116px; background-image: url('/assets/sprites/right-white.png?v=2'); }

.turn-box {
  position: absolute;
  left: 67px;
  top: 161px;
  width: 39px;
  height: 39px;
  background: url('/assets/sprites/turn-black.png?v=2') no-repeat;
}
.turn-box.white { background-image: url('/assets/sprites/turn-white.png?v=2'); }

/* ---------- board: 8 x 8 cells of 37px with 1px grid lines ---------- */
.board {
  position: absolute;
  left: 121px;
  top: 29px;
  width: 303px;
  height: 303px;
  display: grid;
  grid-template-columns: repeat(8, 37px);
  grid-template-rows: repeat(8, 37px);
  gap: 1px;
}
.cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 37px;
  height: 37px;
  padding: 0;
  margin: 0;
  border: 0;
  background: transparent;
  cursor: default;
}
.cell:focus { outline: none; }
.cell:focus-visible::before,
.cell.legal:hover::before {
  content: "";
  position: absolute;
  left: -1px;
  top: -1px;
  width: 39px;
  height: 39px;
  background: url('/assets/sprites/cell-frame.png?v=2') no-repeat;
  pointer-events: none;
  z-index: 1;
}
.cell.legal { cursor: pointer; }
/* Legal squares stay marked while it is your turn. */
.cell.legal::after {
  content: "";
  width: 11px;
  height: 11px;
  background: no-repeat center;
  opacity: .6;
  pointer-events: none;
}
.cell.legal-black::after { background-image: url('/assets/sprites/legal-black.png?v=2'); }
.cell.legal-white::after { background-image: url('/assets/sprites/legal-white.png?v=2'); }
.cell.legal:hover::after { opacity: 1; }

.disc {
  display: block;
  width: 31px;
  height: 31px;
  background: no-repeat;
}
.disc-black { background-image: url('/assets/sprites/disc-black.png?v=2'); }
.disc-white { background-image: url('/assets/sprites/disc-white.png?v=2'); }
.disc.flipping { animation: flip-disc .32s ease-in-out; }
@keyframes flip-disc {
  0% { transform: scaleX(1); }
  50% { transform: scaleX(.12); }
  100% { transform: scaleX(1); }
}

/* ---------- score chips with the original 6 x 8 bitmap digits ---------- */
.score-chip {
  position: absolute;
  top: 337px;
  width: 60px;
  height: 22px;
  background: no-repeat;
}
.chip-white { left: 166px; background-image: url('/assets/sprites/chip-white.png?v=2'); }
.chip-black { left: 318px; background-image: url('/assets/sprites/chip-black.png?v=2'); }
.digits {
  position: absolute;
  left: 35px;
  top: 7px;
  width: 12px;
  height: 8px;
  display: flex;
  justify-content: center;
}
.digits i {
  width: 6px;
  height: 8px;
  background: url('/assets/sprites/digits.png?v=2') no-repeat;
}

/* ---------- resign button: four sprite states + caption ---------- */
.resign-button {
  position: absolute;
  left: 429px;
  top: 228px;
  width: 113px;
  height: 36px;
  padding: 0;
  border: 0;
  background: url('/assets/sprites/resign-normal.png?v=2') no-repeat;
  cursor: default;
}
.resign-caption {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font: 11px Tahoma, sans-serif;
  color: #fff;
}
.resign-caption u { text-underline-offset: 1px; }
.resign-button:hover { background-image: url('/assets/sprites/resign-hover.png?v=2'); }
.resign-button:active { background-image: url('/assets/sprites/resign-pressed.png?v=2'); }
.resign-button:active .resign-caption { transform: translate(1px, 1px); }
.resign-button:disabled { background-image: url('/assets/sprites/resign-disabled.png?v=2'); }
.resign-button:disabled .resign-caption { color: #aca990; transform: none; }
.resign-button:focus { outline: none; }
.resign-button:focus-visible .resign-caption { text-decoration: underline dotted; }

/* ---------- result banner ---------- */
.result-banner {
  position: absolute;
  left: 182px;
  top: 151px;
  width: 180px;
  height: 60px;
  background: url('/assets/sprites/result-blank.png?v=2') no-repeat;
  z-index: 8;
}
.result-banner[hidden] { display: none; }
.result-banner.white { background-image: url('/assets/sprites/result-white.png?v=2'); }
.result-banner.black { background-image: url('/assets/sprites/result-black.png?v=2'); }
.result-banner strong {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font: bold 20px Arial, Helvetica, sans-serif;
  color: #000;
}
/* The White/Black sprites already carry their caption. */
.result-banner.white strong,
.result-banner.black strong { color: transparent; }
.result-close {
  position: absolute;
  right: 0;
  top: 0;
  width: 18px;
  height: 16px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: default;
}
/* Play Again, plus Find New Opponent after an online game. */
.result-actions {
  position: absolute;
  left: -30px;
  top: 66px;
  width: 240px;
  display: flex;
  justify-content: center;
  gap: 6px;
}
.result-actions .xp-button { min-width: 90px; }
.result-actions .xp-button[hidden] { display: none; }

/* ---------- MSN Gaming Zone search screen ---------- */
.lobby-screen {
  position: absolute;
  left: 121px;
  top: 29px;
  width: 303px;
  height: 303px;
  border-radius: 0 15px 0 15px;
  background:
    radial-gradient(ellipse at 50% 38%, rgba(66, 80, 150, .55), transparent 70%),
    rgba(18, 20, 52, .72);
  color: #fff;
  text-align: center;
  z-index: 6;
}
.lobby-screen[hidden] { display: none; }

.zone-brand {
  position: absolute;
  left: 0;
  right: 0;
  top: 14px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
}
.zone-globe {
  width: 46px;
  height: 41px;
  background: url('/assets/sprites/zone-globe.png?v=2') no-repeat;
}
.zone-wordmark {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1;
  font-family: Verdana, Tahoma, sans-serif;
  font-weight: bold;
  text-shadow: 1px 1px 0 #0d1030;
}
.zone-msn { font-size: 13px; font-style: italic; letter-spacing: -.5px; }
.zone-msn sup { font-size: 7px; }
.zone-com { font-size: 19px; color: #ffcc33; letter-spacing: -.5px; }

.lobby-banner {
  position: absolute;
  left: 61px;
  top: 72px;
  width: 180px;
  height: 60px;
  background: url('/assets/sprites/lobby-banner.png?v=2') no-repeat;
}
.lobby-status {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 0 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  line-height: 13px;
  color: #000;
}

/* Four discs flipping in turn while the server looks for an opponent. */
.lobby-spinner {
  position: absolute;
  left: 79px;
  top: 146px;
  display: flex;
  gap: 6px;
}
.lobby-spinner i {
  width: 31px;
  height: 31px;
  background: url('/assets/sprites/disc-black.png?v=2') no-repeat;
  animation: lobby-flip 2.4s steps(1) infinite;
}
.lobby-spinner i:nth-child(2) { animation-delay: .3s; }
.lobby-spinner i:nth-child(3) { animation-delay: .6s; }
.lobby-spinner i:nth-child(4) { animation-delay: .9s; }
@keyframes lobby-flip {
  0%   { background-image: url('/assets/sprites/disc-black.png?v=2'); transform: scaleX(1); }
  12%  { transform: scaleX(.5); }
  16%  { transform: scaleX(.12); }
  20%  { background-image: url('/assets/sprites/disc-white.png?v=2'); transform: scaleX(.5); }
  24%  { transform: scaleX(1); }
  50%  { background-image: url('/assets/sprites/disc-white.png?v=2'); transform: scaleX(1); }
  62%  { transform: scaleX(.5); }
  66%  { transform: scaleX(.12); }
  70%  { background-image: url('/assets/sprites/disc-black.png?v=2'); transform: scaleX(.5); }
  74%  { transform: scaleX(1); }
}
/* Idle (nobody is being searched for, e.g. after the opponent left): no
   spinner, and a Find New Opponent button takes its place. */
.lobby-find {
  position: absolute;
  left: 76px;
  top: 150px;
  width: 151px;
  display: none;
}
.lobby-screen.idle .lobby-find { display: block; }
.lobby-screen.idle .lobby-spinner { display: none; }
.lobby-sub {
  position: absolute;
  left: 20px;
  right: 20px;
  top: 190px;
  margin: 0;
  line-height: 13px;
  color: #e6e8ff;
  text-shadow: 1px 1px 0 #0d1030;
}
.computer-button {
  position: absolute;
  left: 76px;
  top: 222px;
  width: 151px;
}
.lobby-buttons {
  position: absolute;
  left: 0;
  right: 0;
  top: 251px;
  display: flex;
  justify-content: center;
  gap: 7px;
}
.lobby-buttons .xp-button { width: 72px; }
.lobby-copyright {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 7px;
  font-size: 9px;
  color: #b9bde0;
}

/* While searching the board is empty and nothing is clickable. */
.game-screen.waiting .disc,
.game-screen.waiting .digits,
.game-screen.waiting .turn-box { visibility: hidden; }
.game-screen.waiting .cell { pointer-events: none; }
.game-screen.waiting .cell::after { display: none; }
/* The whole chat area (log, phrase box, chat panel; window y=410..510) is
   washed out with the 3D face colour so it reads as disabled. */
.game-screen.waiting::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 361px;
  width: 540px;
  height: 100px;
  background: rgba(236, 233, 216, .65);
  z-index: 45;
}

/* ---------- message log ---------- */
.message-panel {
  position: absolute;
  left: 3px;
  top: 361px;
  width: 375px;
  height: 78px;
  padding: 1px 2px 0 1px;
  overflow: hidden;
  line-height: 13px;
  color: #00f;
  user-select: text;
}
.message-panel div { white-space: pre-wrap; }

/* ---------- chat phrase combo box (sprites from the XP screenshot) ---------- */
.chat-combo {
  position: absolute;
  left: 3px;
  top: 440px;
  width: 375px;
  height: 21px;
  background: url('/assets/sprites/combo-enabled.png?v=2') no-repeat;
}
.chat-combo.disabled { background-image: url('/assets/sprites/combo-disabled.png?v=2'); }
.chat-combo input {
  position: absolute;
  left: 2px;
  top: 2px;
  width: 352px;
  height: 17px;
  margin: 0;
  padding: 0 0 0 4px;
  border: 0;
  background: transparent;
  font: 11px Tahoma, sans-serif;
  color: #000;
  outline: none;
  user-select: text;
}
.chat-combo input::placeholder { color: #000; opacity: 1; }
.chat-combo input:focus::placeholder { color: #aca899; }
.chat-combo.disabled input::placeholder { color: #aca899; }
.combo-arrow {
  position: absolute;
  right: 1px;
  top: 1px;
  width: 18px;
  height: 19px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: default;
}
.combo-arrow:active { box-shadow: inset 1px 1px rgba(0,0,0,.15); }
.combo-list {
  position: absolute;
  left: 0;
  bottom: 21px;
  width: 375px;
  max-height: 260px;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
  background: #fff;
  border: 1px solid #000;
  z-index: 40;
}
.combo-list[hidden] { display: none; }
.combo-list li {
  height: 13px;
  padding: 0 3px;
  line-height: 13px;
  white-space: nowrap;
  cursor: default;
}
.combo-list li:hover,
.combo-list li.active { background: #316ac5; color: #fff; }

/* ---------- chat panel (labels painted by frame.png) ---------- */
.chat-panel { position: absolute; left: 380px; top: 361px; width: 163px; height: 100px; }
.chat-radio {
  position: absolute;
  left: 5px;
  width: 32px;
  height: 15px;
  cursor: default;
}
.radio-on-label  { top: 22px; }
.radio-off-label { top: 40px; }
.chat-radio input { position: absolute; opacity: 0; width: 0; height: 0; margin: 0; }
.radio-face {
  position: absolute;
  left: 1px;
  top: 1px;
  width: 13px;
  height: 13px;
  background: url('/assets/sprites/radio-off.png?v=2') no-repeat;
}
.chat-radio input:checked + .radio-face { background-image: url('/assets/sprites/radio-on.png?v=2'); }
.chat-radio input:focus-visible + .radio-face { outline: 1px dotted #000; outline-offset: 1px; }
.chat-users {
  position: absolute;
  left: 62px;
  top: 0;
  width: 100px;
  padding: 1px 0 0 3px;
  display: flex;
  flex-direction: column;
  line-height: 13px;
  white-space: nowrap;
  overflow: hidden;
}

/* ---------- buttons / dialogs ---------- */
.xp-button {
  height: 23px;
  padding: 0 9px;
  border: 1px solid #003c74;
  border-radius: 3px;
  background: linear-gradient(180deg, #fff 0%, #f4f3ee 40%, #e6e4d9 85%, #d6d0c5 100%);
  font: 11px Tahoma, sans-serif;
  color: #000;
  cursor: default;
}
.xp-button:hover { box-shadow: inset 0 -2px #f8b330, inset 0 2px #fde7ab; }
.xp-button:active { background: linear-gradient(180deg, #e3e2da, #eae8df 70%, #f2f1ea); box-shadow: none; }
.xp-button:focus { outline: none; }
.xp-button:focus-visible { box-shadow: inset 0 0 0 1px #c3d3fd, inset 0 0 0 2px #98b8f4; }

.xp-dialog {
  width: 320px;
  padding: 0;
  border: 1px solid #4f5f38;
  background: var(--face);
  box-shadow: 3px 4px 12px rgba(0,0,0,.4);
  color: #000;
}
.xp-dialog::backdrop { background: rgba(0,0,0,.25); }
.dialog-title {
  height: 26px;
  line-height: 26px;
  padding: 0 8px;
  color: #fff;
  font-weight: bold;
  background: linear-gradient(180deg, var(--olive-top), var(--olive-bottom));
  border-bottom: 1px solid #7e8f5f;
  text-shadow: 1px 1px #5a6a43;
}
.dialog-body { padding: 14px 16px 8px; }
.field-row { display: flex; align-items: center; margin-bottom: 10px; gap: 8px; }
.field-row span { width: 78px; }
.field-row input, .field-row select {
  flex: 1;
  height: 21px;
  border: 1px solid #7f9db9;
  background: #fff;
  font: 11px Tahoma, sans-serif;
  padding: 0 4px;
}
.dialog-buttons { display: flex; justify-content: flex-end; gap: 7px; padding: 6px 14px 14px; }
.dialog-buttons .xp-button { min-width: 75px; }
.info-body { line-height: 17px; min-height: 80px; }
