:root {
  --card-w: 71px;
  --card-h: 96px;
  --gap: 12px;
  --tableau-h: 320px;
  --top-gap: 18px;
  --silver: #c0c0c0;
  --silver-light: #dfdfdf;
  --silver-dark: #808080;
  --navy: #000080;
  --felt: #008000;
  --ui-font: "MS Sans Serif", "Tahoma", "Geneva", "Verdana", sans-serif;
  --card-font: "Times New Roman", "Liberation Serif", "Georgia", serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background: #008080;
  color: #000;
  font-family: var(--ui-font);
  font-size: 11px;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

button {
  font-family: inherit;
  font-size: 11px;
  color: #000;
}

[hidden] {
  display: none !important;
}

.svg-defs {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.desktop {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #008080;
}

.window {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 611px;
  transform: translate(-50%, -50%);
  transform-origin: center center;
  background: var(--silver);
  border: 2px solid;
  border-color: var(--silver-light) #000 #000 var(--silver-light);
  box-shadow:
    inset 1px 1px 0 #fff,
    inset -1px -1px 0 var(--silver-dark),
    3px 3px 0 rgba(0, 0, 0, 0.38);
}

.titlebar {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 2px 3px 2px 4px;
  background: linear-gradient(90deg, #000080 0%, #1084d0 100%);
  color: #fff;
}

.titlebar-icon {
  display: grid;
  place-items: center;
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
}

.titlebar-icon svg {
  width: 13px;
  height: 13px;
  color: #fff;
}

.titlebar-text {
  flex: 1;
  overflow: hidden;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.titlebar-buttons {
  display: flex;
  gap: 2px;
}

.tb-btn {
  display: grid;
  place-items: center;
  width: 16px;
  height: 14px;
  padding: 0;
  line-height: 9px;
  font-size: 11px;
  background: var(--silver);
  border: 1px solid;
  border-color: #fff #000 #000 #fff;
  box-shadow:
    inset 1px 1px 0 var(--silver-light),
    inset -1px -1px 0 var(--silver-dark);
  cursor: default;
}

.tb-btn:active {
  border-color: #000 #fff #fff #000;
  box-shadow: inset 1px 1px 0 var(--silver-dark);
}

.tb-btn.close {
  margin-left: 1px;
}

.menubar {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  height: 22px;
  padding: 1px 2px;
  background: var(--silver);
  border-bottom: 1px solid var(--silver-dark);
}

.menu-title {
  height: 19px;
  padding: 0 7px;
  background: transparent;
  border: 1px solid transparent;
  cursor: default;
}

.menu-title:hover {
  border-color: #fff var(--silver-dark) var(--silver-dark) #fff;
}

.menu-title.open,
.menu-title:active {
  padding-top: 1px;
  background: var(--silver);
  border-color: var(--silver-dark) #fff #fff var(--silver-dark);
}

.menu-popup {
  position: absolute;
  top: 100%;
  z-index: 100;
  min-width: 208px;
  padding: 2px;
  background: var(--silver);
  border: 2px solid;
  border-color: #fff #000 #000 #fff;
  box-shadow:
    inset 1px 1px 0 var(--silver-light),
    inset -1px -1px 0 var(--silver-dark),
    2px 2px 0 rgba(0, 0, 0, 0.28);
}

.menu-item {
  display: flex;
  align-items: center;
  width: 100%;
  height: 20px;
  padding: 0 8px 0 20px;
  background: transparent;
  border: 0;
  text-align: left;
  white-space: nowrap;
  cursor: default;
}

.menu-item:hover {
  background: var(--navy);
  color: #fff;
}

.menu-item .shortcut {
  margin-left: auto;
  padding-left: 26px;
  color: inherit;
  opacity: 0.9;
}

.menu-item.disabled {
  color: var(--silver-dark);
  text-shadow: 1px 1px 0 #fff;
  pointer-events: none;
}

.menu-sep {
  height: 2px;
  margin: 2px 3px;
  border-top: 1px solid var(--silver-dark);
  border-bottom: 1px solid #fff;
}

.game-table {
  position: relative;
  height: 464px;
  padding: 16px 19px 14px;
  background:
    radial-gradient(ellipse at 50% 32%, rgba(255, 255, 255, 0.07), transparent 68%),
    var(--felt);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.25);
  touch-action: none;
}

.top-row {
  display: grid;
  grid-template-columns: var(--card-w) var(--card-w) 1fr repeat(4, var(--card-w));
  gap: var(--gap);
  align-items: start;
  height: var(--card-h);
  margin-bottom: var(--top-gap);
}

.pile {
  position: relative;
  width: var(--card-w);
  height: var(--card-h);
}

.waste {
  overflow: visible;
}

.foundation {
  border-radius: 3px;
}

.tableau {
  display: grid;
  grid-template-columns: repeat(7, var(--card-w));
  gap: var(--gap);
  align-items: start;
  height: var(--tableau-h);
}

.tableau-col {
  position: relative;
  width: var(--card-w);
  height: 100%;
  border-radius: 3px;
}

.tableau-col:empty::after {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  width: var(--card-w);
  height: var(--card-h);
  border: 1px solid rgba(0, 0, 0, 0.28);
  border-radius: 3px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
  pointer-events: none;
}

.card {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--card-w);
  height: var(--card-h);
  overflow: hidden;
  background: #fffef8;
  border: 1px solid #2b2b2b;
  border-radius: 3px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.45);
  font-family: var(--card-font);
  color: #101010;
  transform-origin: 50% 50%;
  will-change: transform;
}

.card.face-up {
  background-color: #fff;
  background-repeat: no-repeat;
  background-size: 100% 100%;
  background-origin: border-box;
  background-clip: border-box;
}

.card.face-down {
  background-color: #08265f;
  background-image: var(--back-img);
  background-repeat: no-repeat;
  background-size: 100% 100%;
  border-color: #001028;
  box-shadow:
    0 1px 0 rgba(0, 0, 0, 0.55),
    inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.card.drag-origin {
  opacity: 0.35;
}

.card.flip-in {
  animation: card-flip 170ms steps(6, end) both;
}

.card.deal {
  animation: card-deal 280ms ease-out both;
  animation-delay: calc(var(--deal-i, 0) * 22ms);
}

@keyframes card-flip {
  from {
    transform: scaleX(0.04);
  }
  to {
    transform: scaleX(1);
  }
}

@keyframes card-deal {
  from {
    transform: translate(var(--dx, 0), var(--dy, 0)) scale(0.96);
    opacity: 0.55;
  }
  to {
    transform: translate(0, 0) scale(1);
    opacity: 1;
  }
}

.suit-ghost {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border: 1px solid rgba(0, 0, 0, 0.3);
  border-radius: 3px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.2);
  pointer-events: none;
}

.suit-ghost svg {
  width: 40px;
  height: 40px;
}

.stock.is-empty::before {
  content: "";
  position: absolute;
  inset: 0;
  border: 1px solid rgba(0, 0, 0, 0.3);
  border-radius: 3px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.stock-empty-icon {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 34px;
  height: 34px;
  transform: translate(-50%, -50%);
  color: rgba(255, 255, 255, 0.45);
  pointer-events: none;
}

.foundation.drop-ok::after {
  content: "";
  position: absolute;
  inset: -2px;
  z-index: 50;
  border: 2px solid #ffe95c;
  border-radius: 4px;
  pointer-events: none;
}

.tableau-col.drop-ok::after {
  content: "";
  position: absolute;
  left: -2px;
  top: calc(var(--drop-top, 0px) - 2px);
  z-index: 50;
  width: calc(var(--card-w) + 4px);
  height: calc(var(--card-h) + 4px);
  border: 2px solid #ffe95c;
  border-radius: 4px;
  pointer-events: none;
}

.fly-layer {
  position: fixed;
  inset: 0;
  z-index: 12000;
  overflow: hidden;
  pointer-events: none;
}

.fly-layer .card {
  position: absolute;
  box-shadow: 1px 2px 0 rgba(0, 0, 0, 0.35);
  transform-origin: top left;
}

.drag-layer {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 9000;
  width: 0;
  height: 0;
  pointer-events: none;
}

.drag-layer .card {
  box-shadow: 2px 3px 0 rgba(0, 0, 0, 0.38);
}

body.is-dragging {
  cursor: grabbing;
}

.statusbar {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 24px;
  padding: 2px 3px;
  background: var(--silver);
  border-top: 1px solid var(--silver-light);
}

.status-pane {
  display: flex;
  align-items: center;
  height: 20px;
  padding: 0 6px;
  overflow: hidden;
  border: 1px solid;
  border-color: var(--silver-dark) #fff #fff var(--silver-dark);
  white-space: nowrap;
}

.status-pane b {
  margin-left: 4px;
  font-weight: 700;
}

.score-pane {
  min-width: 108px;
}

.time-pane {
  min-width: 108px;
}

.message-pane {
  flex: 1;
  color: #303030;
}

.status-btn {
  height: 20px;
  min-width: 58px;
  padding: 0 7px;
  background: var(--silver);
  border: 1px solid;
  border-color: #fff #000 #000 #fff;
  box-shadow:
    inset 1px 1px 0 var(--silver-light),
    inset -1px -1px 0 var(--silver-dark);
  cursor: default;
}

.status-btn:active {
  border-color: #000 #fff #fff #000;
  box-shadow: inset 1px 1px 0 var(--silver-dark);
}

.status-btn:disabled {
  color: var(--silver-dark);
  text-shadow: 1px 1px 0 #fff;
  pointer-events: none;
}

.modal-layer {
  position: fixed;
  inset: 0;
  z-index: 20000;
  display: grid;
  place-items: center;
  padding: 12px;
  background: transparent;
}

.dialog {
  width: 340px;
  max-width: 100%;
  background: var(--silver);
  border: 2px solid;
  border-color: #fff #000 #000 #fff;
  box-shadow:
    inset 1px 1px 0 var(--silver-light),
    inset -1px -1px 0 var(--silver-dark),
    4px 4px 0 rgba(0, 0, 0, 0.4);
}

.dialog.wide {
  width: 500px;
}

.dialog-body {
  max-height: min(72vh, 500px);
  padding: 12px 12px 10px;
  overflow: auto;
  font-size: 11px;
  line-height: 1.45;
}

.dialog-body p {
  margin: 0 0 8px;
}

.dialog-buttons {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 0 12px 12px;
}

.win-btn {
  min-width: 75px;
  height: 23px;
  padding: 0 10px;
  background: var(--silver);
  border: 2px solid;
  border-color: var(--silver-light) #000 #000 var(--silver-light);
  box-shadow:
    inset 1px 1px 0 #fff,
    inset -1px -1px 0 var(--silver-dark);
  cursor: default;
}

.win-btn:active {
  padding-top: 1px;
  border-color: #000 var(--silver-light) var(--silver-light) #000;
  box-shadow: inset 1px 1px 0 var(--silver-dark);
}

.win-btn.primary {
  box-shadow:
    0 0 0 1px #000,
    inset 1px 1px 0 #fff,
    inset -1px -1px 0 var(--silver-dark);
}

fieldset {
  margin: 0 0 10px;
  padding: 5px 8px 7px;
  border: 1px solid var(--silver-dark);
  box-shadow:
    inset 1px 1px 0 #fff,
    inset -1px -1px 0 var(--silver-light);
}

legend {
  padding: 0 3px;
  font-size: 11px;
}

.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 16px;
}

.ctl {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 4px 0;
  cursor: default;
}

.ctl input[type="checkbox"],
.ctl input[type="radio"] {
  position: relative;
  flex: 0 0 auto;
  width: 13px;
  height: 13px;
  margin: 0;
  padding: 0;
  appearance: none;
  -webkit-appearance: none;
  background: #fff;
  border: 1px solid;
  border-color: var(--silver-dark) #fff #fff var(--silver-dark);
  box-shadow: inset 1px 1px 0 #404040;
  border-radius: 0;
}

.ctl input[type="radio"] {
  border-radius: 50%;
}

.ctl input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 2px;
  top: 2px;
  width: 8px;
  height: 4px;
  border-left: 2px solid #000;
  border-bottom: 2px solid #000;
  transform: rotate(-45deg);
}

.ctl input[type="radio"]:checked::after {
  content: "";
  position: absolute;
  inset: 3px;
  background: #000;
  border-radius: 50%;
}

.ctl input:focus-visible,
.win-btn:focus-visible,
.status-btn:focus-visible,
.menu-title:focus-visible,
.menu-item:focus-visible {
  outline: 1px dotted #000;
  outline-offset: -4px;
}

.back-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 3px;
  margin-top: 6px;
}

.back-option {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 3px 1px;
  border: 1px solid transparent;
  cursor: default;
}

.back-option:hover {
  border-color: var(--silver-dark);
  background: #d0ccc4;
}

.back-option input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.back-option img {
  width: 27px;
  height: 37px;
  border: 1px solid #000;
  background: #fff;
  box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.35);
}

.back-option .back-name {
  font-size: 8px;
  line-height: 1.1;
  text-align: center;
}

.back-option:has(input:checked) {
  border-color: #000;
  background: #d0ccc4;
  box-shadow: inset 1px 1px 0 #fff;
}

.rules-list {
  margin: 4px 0 0 18px;
  padding: 0;
}

.rules-list li {
  margin: 0 0 5px;
}

.about-box {
  text-align: center;
}

.about-box .about-icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  margin: 2px auto 8px;
  border: 2px solid;
  border-color: var(--silver-light) #000 #000 var(--silver-light);
  background: #ffffe1;
}

.about-box .about-icon svg {
  width: 30px;
  height: 30px;
}

.about-box .about-title {
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 700;
}

.win-canvas {
  position: absolute;
  inset: 0;
  z-index: 800;
  display: block;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

.game-table.winning .foundation .card {
  visibility: hidden;
}

.account-box {
  margin-top: 10px;
  text-align: left;
}

.account-box fieldset {
  margin-bottom: 0;
}

.field-rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 6px 0;
}

.field-input {
  height: 21px;
  padding: 2px 4px;
  color: #000;
  font: inherit;
  background: #fff;
  border: 1px solid;
  border-color: var(--silver-dark) #fff #fff var(--silver-dark);
  box-shadow: inset 1px 1px 0 #404040;
  user-select: text;
  -webkit-user-select: text;
}

.field-input:focus {
  outline: 1px dotted #000;
  outline-offset: -3px;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.form-note {
  margin: 4px 0;
  color: #303030;
  font-size: 10px;
  line-height: 1.4;
}

.form-error {
  min-height: 12px;
  margin: 4px 0 0;
  color: #a00000;
  font-size: 10px;
  line-height: 1.4;
}

.form-code {
  margin: 4px 0;
  padding: 4px 6px;
  font-family: "Courier New", monospace;
  background: #fff;
  border: 1px solid var(--silver-dark);
}

.link-btn {
  padding: 0;
  color: var(--navy);
  font-size: 10px;
  text-decoration: underline;
  background: none;
  border: 0;
  cursor: pointer;
}

.link-btn:hover {
  color: #0000c0;
}

body.rating-page {
  overflow: auto;
}

.rating-desktop {
  position: relative;
  inset: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  min-height: 100%;
  padding: 24px 16px;
  overflow: visible;
}

.rating-window {
  position: relative;
  left: auto;
  top: auto;
  width: 720px;
  max-width: 100%;
  transform: none;
}

.rating-content {
  padding: 10px 12px 12px;
}

.rating-account {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 6px 8px;
  background: #d4d0c8;
  border: 1px solid var(--silver-dark);
  box-shadow: inset 1px 1px 0 #fff;
}

.rating-account .rating-me {
  flex: 1 1 260px;
}

.rating-account .rating-me b {
  font-weight: 700;
}

.rating-account .field-rows {
  flex-direction: row;
  margin: 0;
}

.rating-account .field-input {
  width: 132px;
}

.rating-account .form-error {
  flex-basis: 100%;
  margin: 0;
}

.rating-offline {
  margin: 0;
  color: #303030;
}

.rating-table-wrap {
  min-height: 260px;
  overflow-x: auto;
  background: #fff;
  border: 1px solid;
  border-color: var(--silver-dark) #fff #fff var(--silver-dark);
  box-shadow: inset 1px 1px 0 #404040;
}

.rating-table {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
  font-size: 11px;
}

.rating-table th {
  position: sticky;
  top: 0;
  padding: 5px 8px;
  color: #303030;
  font-weight: 400;
  text-align: left;
  background: var(--silver);
  border-bottom: 1px solid var(--silver-dark);
  box-shadow: inset 0 1px 0 #fff;
}

.rating-table th[data-sort] {
  padding: 0;
  color: #000;
}

.rating-table th[aria-sort="ascending"],
.rating-table th[aria-sort="descending"] {
  background: #d0ccc4;
}

.sort-btn {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  width: 100%;
  height: 27px;
  padding: 0 8px;
  color: inherit;
  font: inherit;
  text-align: right;
  background: transparent;
  border: 0;
  cursor: pointer;
}

.sort-btn:hover {
  text-decoration: underline;
}

.sort-btn:focus-visible {
  outline: 1px dotted #000;
  outline-offset: -4px;
}

.sort-mark {
  display: inline-block;
  width: 9px;
  font-size: 8px;
  line-height: 1;
  text-align: center;
}

.rating-table td {
  padding: 5px 8px;
  border-bottom: 1px solid #e4e4e4;
}

.rating-table tr.me td {
  background: #ffffc0;
  font-weight: 700;
}

.rating-table th.num,
.rating-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.rating-table th.rank,
.rating-table td.rank {
  width: 46px;
  color: #505050;
  text-align: right;
}

.rating-table td.login {
  font-weight: 700;
}

.rating-empty {
  padding: 30px 20px;
  color: #505050;
  text-align: center;
  line-height: 1.6;
}

.rating-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
}

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

.rating-link {
  color: var(--navy);
  font-size: 11px;
}

.rating-rank {
  color: #303030;
  font-size: 10px;
}
