/*
 * "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. TabTibia's own look: the cave art blurred behind a dark glass panel, gold and ember accents, the game
 * itself shown on the chosen device.
 */
.device-selector {
  --ds-gold: #f2c46d;
  --ds-text: #efe7d5;
  --ds-muted: #a99f8b;
  --ds-line: rgba(242, 196, 109, 0.22);
  --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: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  /* not the black outline the game gives every text: it would hide the gold of the title */
  text-shadow: none;
  background: #07080b;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

.ds-backdrop {
  position: fixed;
  inset: -30px;
  background: url("../png/devices/backdrop.jpg") center / cover no-repeat;
  filter: blur(7px) brightness(0.38) saturate(1.15);
}

.ds-vignette {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 50% 28%, rgba(227, 164, 60, 0.13), transparent 55%),
    radial-gradient(ellipse at 50% 45%, transparent 35%, rgba(4, 5, 8, 0.75) 80%, rgba(3, 4, 6, 0.95) 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 var(--ds-line);
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(22, 24, 32, 0.82), rgba(10, 11, 16, 0.92));
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  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.04);
  color: var(--ds-muted);
  font-size: 15px;
  cursor: pointer;
}

.ds-close:hover { color: var(--ds-text); border-color: rgba(242, 196, 109, 0.5); }

.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 14px rgba(242, 196, 109, 0.25)) drop-shadow(0 4px 10px rgba(0, 0, 0, 0.6));
}

.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: 700;
  line-height: 1.05;
  letter-spacing: 0.05em;
  color: var(--ds-gold);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
}

.ds-wordmark small {
  margin-top: 3px;
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--ds-muted);
}

.ds-title {
  margin: 16px 0 6px;
  font-family: "Cinzel", "Trajan Pro", "Palatino Linotype", Palatino, Georgia, serif;
  font-size: clamp(21px, 5.6vw, 30px);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #f7e6c0;
  background: linear-gradient(180deg, #fff6df 0%, #f2c46d 58%, #c98b2f 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.55));
}

.ds-subtitle {
  margin: 0;
  font-size: 14px;
  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(242, 196, 109, 0.3), transparent 70%);
  filter: blur(6px);
}

.ds-frame {
  position: relative;
  background: linear-gradient(180deg, #2a2d36, #101116);
  box-shadow: 0 0 0 1.5px rgba(242, 196, 109, 0.45), 0 18px 40px rgba(0, 0, 0, 0.6);
}

/* 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(242, 196, 109, 0.35);
}

.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 var(--ds-line);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.02));
  color: var(--ds-text);
  font: inherit;
  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: rgba(242, 196, 109, 0.5);
}

.ds-option:focus { outline: none; }

.ds-option:focus-visible {
  outline: 2px solid var(--ds-gold);
  outline-offset: 2px;
}

.ds-option[aria-checked="true"] {
  border-color: var(--ds-gold);
  color: #fff3d6;
  background: linear-gradient(180deg, rgba(242, 196, 109, 0.17), rgba(242, 196, 109, 0.05));
  box-shadow: 0 0 0 1px rgba(242, 196, 109, 0.35), 0 10px 26px rgba(227, 164, 60, 0.2), inset 0 0 18px rgba(242, 196, 109, 0.12);
}

.ds-option[aria-checked="true"] svg { opacity: 1; stroke: var(--ds-gold); }

/* the radio dot under the name */
.ds-radio {
  width: 12px;
  height: 12px;
  border: 1.5px solid rgba(239, 231, 213, 0.35);
  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-gold);
  background: radial-gradient(circle, var(--ds-gold) 0 3px, transparent 3.5px);
  box-shadow: 0 0 8px rgba(242, 196, 109, 0.6);
}

.ds-badge {
  position: absolute;
  top: -9px;
  left: 50%;
  padding: 2px 7px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--ds-ember), #f08a3c);
  color: #fff;
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: 0.08em;
  white-space: nowrap;
  transform: translateX(-50%);
  box-shadow: 0 2px 8px rgba(217, 71, 43, 0.45);
}

.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(242, 196, 109, 0.15);
  color: var(--ds-gold);
  font-weight: 800;
}

.ds-summary strong {
  display: block;
  font-size: 15px;
  color: #fff3d6;
}

.ds-summary .ds-desc {
  display: block;
  margin-top: 2px;
  font-size: 13px;
  color: var(--ds-muted);
}

.ds-summary .ds-warning {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: #f0a25a;
}

.ds-summary .ds-warning[hidden] { display: none; }

.ds-continue {
  position: relative;
  overflow: hidden;
  width: 100%;
  min-height: 52px;
  border: 0;
  border-radius: 14px;
  color: #2a1806;
  background: linear-gradient(180deg, #ffe3a6 0%, #f2c46d 45%, #d39537 100%);
  box-shadow: 0 10px 28px rgba(227, 164, 60, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.6), inset 0 -2px 0 rgba(120, 70, 15, 0.35);
  font: inherit;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.06em;
  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 #fff3d6; 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: 12px;
  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;
  }
}
