/*
 * "Choose your device" (src/ui/device-selector.js): the first screen of a new player, and Settings > Controls > Device.
 * A computer, or one of the three touch devices (phone, tablet, foldable) that share the touch controls and differ only
 * in the HUD. The look of the TabTibia website (tabtibia.com, user 2026-10-04): the dusk illustration behind an old
 * parchment card framed in wood and gold, Cinzel and Crimson Text in ink, the gold button, the game itself shown on the
 * chosen device.
 */
.device-selector {
  --ds-gold: #e0a93b;
  --ds-text: #3a2414;
  --ds-muted: #6a4a2e;
  --ds-gem: #9c1c1c;
  --ds-line: rgba(160, 120, 60, 0.45);
  --ds-ember: #d9472b;
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  overflow-y: auto;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  color: var(--ds-text);
  font-family: "Crimson Text", Georgia, "Times New Roman", serif;
  /* not the black outline the game gives every text: ink on parchment */
  text-shadow: none;
  background: #0c0a10;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

/* the website's dusk illustration: the castle on its hill (a portrait crop on a phone) */
.ds-backdrop {
  position: fixed;
  inset: 0;
  background: #0c0a10 url("../png/web/dusk.webp") center 38% / cover no-repeat;
}

@media (max-width: 700px) and (orientation: portrait) {
  .ds-backdrop { background-image: url("../png/web/dusk-mobile.webp"); background-position: center top; }
}

.ds-vignette {
  position: fixed;
  inset: 0;
  background: linear-gradient(180deg, rgba(8, 6, 12, 0.3) 0%, rgba(8, 6, 12, 0.12) 35%, rgba(8, 6, 12, 0.62) 100%);
}

/* embers drifting up (DeviceSelector.__addEmbers) */
.ds-embers {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.ds-embers span {
  position: absolute;
  bottom: -12px;
  border-radius: 50%;
  background: radial-gradient(circle, #ffd59a 0%, #f08a3c 45%, rgba(217, 71, 43, 0) 70%);
  opacity: 0;
  animation: ds-ember linear infinite;
}

@keyframes ds-ember {
  0% { transform: translate(0, 0); opacity: 0; }
  12% { opacity: 0.9; }
  100% { transform: translate(var(--ds-drift, 20px), -105vh); opacity: 0; }
}

.ds-panel {
  position: relative;
  width: min(600px, 100%);
  margin: auto;
  padding: 22px 22px 18px;
  text-align: center;
  border: 1px solid #b8955a;
  border-radius: 10px;
  /* old parchment framed in wood and a gold hairline, as the website's cards */
  background: radial-gradient(ellipse at 50% 25%, #fdf4dc 0%, #f4e6c3 55%, #e6cf9f 100%);
  box-shadow: 0 0 0 4px rgba(42, 31, 22, 0.9), 0 0 0 5px rgba(224, 169, 59, 0.6), 0 24px 60px rgba(0, 0, 0, 0.6);
  animation: ds-rise 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes ds-rise {
  from { opacity: 0; transform: translateY(18px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.ds-close {
  position: absolute;
  z-index: 2;
  top: 10px;
  right: 10px;
  width: 36px;
  height: 36px;
  border: 1px solid var(--ds-line);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.4);
  color: var(--ds-muted);
  font-size: 15px;
  cursor: pointer;
}

.ds-close:hover { color: var(--ds-gem); border-color: var(--ds-gem); }

.ds-close[hidden] { display: none; }

.ds-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.ds-emblem {
  width: 60px;
  height: 60px;
  filter: drop-shadow(0 4px 10px rgba(80, 50, 20, 0.35));
}

.ds-wordmark {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  font-family: "Cinzel", "Trajan Pro", "Palatino Linotype", Palatino, Georgia, serif;
  font-size: 25px;
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: 0.05em;
  color: var(--ds-text);
}

.ds-wordmark small {
  margin-top: 3px;
  font-family: "Cinzel", "Trajan Pro", "Palatino Linotype", Palatino, Georgia, serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--ds-gem);
}

.ds-title {
  margin: 16px 0 6px;
  font-family: "Cinzel", "Trajan Pro", "Palatino Linotype", Palatino, Georgia, serif;
  font-size: clamp(22px, 5.8vw, 31px);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ds-text);
}

.ds-subtitle {
  margin: 0;
  font-size: 16px;
  color: var(--ds-muted);
}

/* the stage: the game on the chosen device */
.ds-stage {
  position: relative;
  height: clamp(140px, 30vh, 240px);
  margin: 18px 0 20px;
  perspective: 1100px;
}

.ds-device {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  opacity: 0;
  transform: translateY(12px) scale(0.95);
  transition: opacity 0.35s ease, transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.ds-device.is-active {
  opacity: 1;
  transform: none;
}

.ds-glow {
  position: absolute;
  left: 18%;
  right: 18%;
  bottom: -8px;
  height: 26px;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(80, 50, 20, 0.35), transparent 70%);
  filter: blur(6px);
}

.ds-frame {
  position: relative;
  background: linear-gradient(180deg, #2a2d36, #101116);
  box-shadow: 0 0 0 1.5px rgba(184, 149, 90, 0.9), 0 14px 30px rgba(60, 35, 10, 0.45);
}

/* the glass reflection over every screen */
.ds-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(130deg, rgba(255, 255, 255, 0.13), transparent 38%);
  pointer-events: none;
}

.ds-screen {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #0b0c10;
}

.ds-device-desktop {
  flex-direction: column;
  gap: 0;
}

.ds-monitor {
  height: 80%;
  aspect-ratio: 880 / 570;
  padding: 6px;
  border-radius: 12px;
}

.ds-monitor .ds-screen { border-radius: 6px; }

.ds-monitor-neck {
  width: 34px;
  height: 12%;
  background: linear-gradient(90deg, #17181d, #2f323b, #17181d);
}

.ds-monitor-base {
  width: 120px;
  height: 7px;
  border-radius: 6px 6px 3px 3px;
  background: linear-gradient(180deg, #34373f, #15161b);
  box-shadow: 0 0 0 1px rgba(184, 149, 90, 0.8);
}

.ds-phone {
  padding: 4px;
  border-radius: 16px;
}

.ds-phone .ds-screen { border-radius: 12px; }

.ds-phone-portrait {
  height: 96%;
  aspect-ratio: 260 / 563;
}

.ds-phone-landscape {
  height: 46%;
  aspect-ratio: 560 / 259;
}

/* the camera island */
.ds-phone::before {
  content: "";
  position: absolute;
  z-index: 1;
  top: 8px;
  left: 50%;
  width: 26%;
  height: 5px;
  border-radius: 4px;
  background: #000;
  transform: translateX(-50%);
}

.ds-phone-landscape::before {
  top: 50%;
  left: 8px;
  width: 5px;
  height: 26%;
  transform: translateY(-50%);
}

.ds-tablet {
  height: 92%;
  aspect-ratio: 800 / 556;
  padding: 9px;
  border-radius: 20px;
}

.ds-tablet .ds-screen { border-radius: 10px; }

.ds-fold {
  display: flex;
  height: 92%;
  aspect-ratio: 560 / 661;
  transform-style: preserve-3d;
}

.ds-fold-half {
  flex: 1;
  padding: 4px;
}

.ds-fold-left {
  padding-right: 1px;
  border-radius: 16px 3px 3px 16px;
  transform: rotateY(14deg);
  transform-origin: right center;
}

.ds-fold-right {
  padding-left: 1px;
  border-radius: 3px 16px 16px 3px;
  transform: rotateY(-14deg);
  transform-origin: left center;
}

/* each half shows its half of the same screenshot */
.ds-fold-screen {
  height: 100%;
  background: #0b0c10 url("../png/devices/foldable.jpg") no-repeat;
  background-size: 200% 100%;
}

.ds-fold-left .ds-fold-screen { border-radius: 12px 2px 2px 12px; background-position: left center; }

.ds-fold-right .ds-fold-screen { border-radius: 2px 12px 12px 2px; background-position: right center; }

/* the four devices: a radio group */
.ds-options {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  padding-top: 8px;
}

.ds-option {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 92px;
  padding: 14px 4px 10px;
  border: 1px solid #c9a86b;
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(255, 252, 240, 0.7), rgba(250, 238, 210, 0.45));
  box-shadow: 0 2px 6px rgba(80, 50, 20, 0.12);
  color: var(--ds-text);
  font: inherit;
  font-family: "Cinzel", "Trajan Pro", "Palatino Linotype", Palatino, Georgia, serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.ds-option svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.85;
}

.ds-option:hover {
  transform: translateY(-2px);
  border-color: var(--ds-gold);
}

.ds-option:focus { outline: none; }

.ds-option:focus-visible {
  outline: 2px solid var(--ds-gem);
  outline-offset: 2px;
}

.ds-option[aria-checked="true"] {
  border-color: var(--ds-gem);
  color: var(--ds-gem);
  background: linear-gradient(180deg, rgba(156, 28, 28, 0.12), rgba(156, 28, 28, 0.04));
  box-shadow: 0 0 0 1px rgba(156, 28, 28, 0.45), 0 8px 18px rgba(120, 40, 20, 0.18), inset 0 0 14px rgba(156, 28, 28, 0.08);
}

.ds-option[aria-checked="true"] svg { opacity: 1; stroke: var(--ds-gem); }

/*
 * The game styles every button (css/new.css): on hover a dark texture (png/bg2.png) and a white border. On the
 * parchment that turned the cards and the gold button black ("se pone en negro", user 2026-10-04): here each button
 * keeps its own look, a little lighter on hover
 */
.device-selector .ds-option:hover {
  background-image: linear-gradient(180deg, rgba(255, 250, 234, 0.96), rgba(252, 238, 204, 0.78));
  border: 1px solid var(--ds-gold);
}

.device-selector .ds-option[aria-checked="true"]:hover {
  background-image: linear-gradient(180deg, rgba(156, 28, 28, 0.17), rgba(156, 28, 28, 0.07));
  border: 1px solid var(--ds-gem);
}

.device-selector .ds-continue:hover,
.device-selector .ds-continue:disabled:hover {
  background-image: linear-gradient(180deg, #ffe596 0%, #f4c457 46%, #d9a02f 54%, #b87e1d 100%);
  border: 1px solid #6b4610;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7), inset 0 -2px 0 rgba(90, 55, 10, 0.35), 0 8px 22px rgba(80, 50, 15, 0.4);
}

.device-selector .ds-close:hover {
  background-image: none;
  background-color: rgba(255, 255, 255, 0.6);
  border: 1px solid var(--ds-gem);
}

/* the radio dot under the name */
.ds-radio {
  width: 12px;
  height: 12px;
  border: 1.5px solid rgba(58, 36, 20, 0.4);
  border-radius: 50%;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.ds-option[aria-checked="true"] .ds-radio {
  border-color: var(--ds-gem);
  background: radial-gradient(circle, var(--ds-gem) 0 3px, transparent 3.5px);
  box-shadow: 0 0 6px rgba(156, 28, 28, 0.45);
}

.ds-badge {
  position: absolute;
  top: -9px;
  left: 50%;
  padding: 2px 7px;
  border: 1px solid #8a5d16;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffe596, #e0a93b);
  color: #2b1a06;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.08em;
  white-space: nowrap;
  transform: translateX(-50%);
  box-shadow: 0 2px 6px rgba(120, 80, 20, 0.35);
}

.ds-option:not(.is-suggested) .ds-badge { display: none; }

.ds-summary {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-height: 44px;
  margin: 16px 2px 14px;
  text-align: left;
}

.ds-summary-check {
  display: grid;
  flex: 0 0 22px;
  height: 22px;
  place-items: center;
  border-radius: 50%;
  background: rgba(156, 28, 28, 0.12);
  color: var(--ds-gem);
  font-weight: 800;
}

.ds-summary strong {
  display: block;
  font-size: 17px;
  font-weight: 600;
  color: var(--ds-text);
}

.ds-summary .ds-desc {
  display: block;
  margin-top: 2px;
  font-size: 15px;
  color: var(--ds-muted);
}

.ds-summary .ds-warning {
  display: block;
  margin-top: 4px;
  font-size: 14px;
  color: #a4461a;
}

.ds-summary .ds-warning[hidden] { display: none; }

.ds-continue {
  position: relative;
  overflow: hidden;
  width: 100%;
  min-height: 52px;
  border: 1px solid #6b4610;
  border-radius: 8px;
  color: #2b1a06;
  /* the gold button of the website */
  background: linear-gradient(180deg, #ffe596 0%, #f4c457 46%, #d9a02f 54%, #b87e1d 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7), inset 0 -2px 0 rgba(90, 55, 10, 0.35), 0 8px 20px rgba(80, 50, 15, 0.35);
  font: inherit;
  font-family: "Cinzel", "Trajan Pro", "Palatino Linotype", Palatino, Georgia, serif;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-shadow: 0 1px 0 rgba(255, 238, 180, 0.6);
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease;
}

/* a light sweeping over the button now and then */
.ds-continue::before {
  content: "";
  position: absolute;
  top: 0;
  left: -60%;
  width: 40%;
  height: 100%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.55), transparent);
  transform: skewX(-20deg);
  animation: ds-shine 3.8s ease-in-out 1s infinite;
}

@keyframes ds-shine {
  0%, 60% { left: -60%; }
  100% { left: 130%; }
}

.ds-continue:hover { filter: brightness(1.06); transform: translateY(-1px); }

.ds-continue:active { transform: translateY(1px); }

.ds-continue:focus { outline: none; }

.ds-continue:focus-visible { outline: 2px solid var(--ds-gem); outline-offset: 3px; }

.ds-continue:disabled { filter: grayscale(0.4) brightness(0.9); cursor: progress; }

.ds-arrow {
  display: inline-block;
  margin-left: 10px;
  transition: transform 0.2s ease;
}

.ds-continue:hover .ds-arrow { transform: translateX(4px); }

.ds-note {
  margin: 10px 0 0;
  font-size: 14px;
  font-style: italic;
  color: var(--ds-muted);
}

.ds-note[hidden] { display: none; }

/* a short screen: a smaller head and stage */
@media (max-height: 700px) and (orientation: portrait) {
  .ds-emblem { width: 48px; height: 48px; }

  .ds-wordmark { font-size: 21px; }

  .ds-title { margin-top: 12px; }

  .ds-stage { height: clamp(120px, 26vh, 200px); margin: 14px 0 16px; }

  .ds-option { min-height: 82px; }
}

/* a very short screen (an iPhone SE in Safari): everything fits without scrolling */
@media (max-height: 600px) and (orientation: portrait) {
  .ds-panel { padding-top: 14px; padding-bottom: 12px; }

  .ds-emblem { width: 40px; height: 40px; }

  .ds-wordmark { font-size: 19px; }

  .ds-title { margin-top: 8px; font-size: 20px; }

  .ds-stage { height: 112px; margin: 10px 0 14px; }

  .ds-option { min-height: 70px; padding-top: 10px; gap: 4px; }

  .ds-summary { margin: 12px 2px 10px; }

  .ds-continue { min-height: 48px; }
}

/* a narrow phone: tighter cards */
@media (max-width: 380px) {
  .ds-panel { padding: 18px 14px 14px; }

  .ds-options { gap: 7px; }

  .ds-option { font-size: 10.5px; letter-spacing: 0.03em; }
}

/* a phone held sideways: the device on the left, the choice on the right */
@media (max-height: 520px) and (orientation: landscape) {
  .ds-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: center;
    column-gap: 22px;
    width: min(880px, 100%);
    padding: 14px 18px;
  }

  .ds-emblem { width: 40px; height: 40px; }

  .ds-wordmark { font-size: 19px; }

  .ds-title { margin-top: 8px; font-size: 19px; }

  .ds-subtitle { font-size: 12px; }

  .ds-stage { height: clamp(110px, 40vh, 180px); margin: 12px 0 6px; }

  .ds-option { min-height: 74px; padding-top: 12px; }

  .ds-summary { margin: 12px 2px 10px; }

  .ds-continue { min-height: 46px; }
}

@media (prefers-reduced-motion: reduce) {
  .ds-panel,
  .ds-continue::before,
  .ds-embers span {
    animation: none !important;
  }

  .ds-device,
  .ds-option,
  .ds-continue,
  .ds-arrow {
    transition: none !important;
  }
}
