/* ===== BASE ===== */
:root {
  --ui-scale: clamp(0.75, calc(100vw / 1440px), 1);
  --space-xs: clamp(6px, 1vw, 10px);
  --space-sm: clamp(10px, 1.5vw, 16px);
  --space-md: clamp(16px, 2vw, 24px);
  --space-lg: clamp(24px, 3vw, 40px);
  --main-content-lift: clamp(111px, 7.6vw, 123px);
  --selector-polish-lift: clamp(24px, 2vw, 30px);
  --selector-polish-offset: clamp(30px, 2.4vw, 35px);
  --wheel-max: 1008px;
  --main-column-gap: clamp(56px, 4vw, 112px);
}

@font-face {
  font-family: "Fontin";
  src: url("fonts/fontin.otf") format("opentype");
  font-weight: normal;
  font-style: normal;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  height: 100%;
  min-height: 100vh;
  display: block;
  font-family: "Fontin", serif;
  color: #f2f2f2;
  background: #111318 url("images/background.png") center/cover no-repeat;
  background-attachment: fixed;
  overflow-x: hidden;
  overflow-y: auto;
}

html {
  height: 100%;
}

button {
  font-family: inherit;
}

/* ===== LAYOUT ===== */
.wheel-area {
  text-align: center;
}

h1 {
  margin: 0 0 24px;
  font-size: clamp(1rem, 2.2vw, 2.4rem);
  color: #f5e199;
  letter-spacing: 0.08em;
}

.poe2-logo {
  width: clamp(80px, 18vw, 260px);
  height: auto;
}

.game-logo-switcher {
  position: relative;
  width: fit-content;
  flex: 0 0 auto;
  line-height: 0;
}

.game-logo-primary {
  display: block;
  aspect-ratio: 269 / 212;
  object-fit: contain;
  object-position: left top;
}

.game-logo-secondary-link {
  position: absolute;
  top: 100%;
  left: 0;
  width: 48%;
  aspect-ratio: 269 / 212;
  margin-top: 18px;
  cursor: pointer;
  z-index: 20;
  opacity: 0.72;
  transition: opacity 140ms ease, filter 140ms ease, transform 140ms ease;
}

.game-logo-secondary-link:hover,
.game-logo-secondary-link:focus-visible {
  opacity: 1;
  filter: brightness(1.15);
  transform: scale(1.04);
}

.game-logo-secondary-link:focus-visible {
  outline: 2px solid #d6a63f;
  outline-offset: 3px;
}

.game-logo-secondary {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: left top;
}

.yt-banner {
  position: relative;
  width: clamp(180px, 22vw, 320px);
  height: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 0 14px;
  text-decoration: none;
  cursor: pointer;
  z-index: 10;
  transition: filter 150ms ease, transform 150ms ease;
}

.yt-banner:hover {
  filter: brightness(1.15);
  transform: scale(1.03);
}

.yt-banner-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
}

.yt-banner-wolf {
  position: relative;
  height: clamp(32px, 4.5vw, 56px);
  width: auto;
  z-index: 1;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.7));
}

.yt-banner-name {
  position: relative;
  z-index: 1;
  color: #1a0f00;
  font-size: clamp(1rem, 1.9vw, 1.55rem);
  font-weight: bold;
  font-family: "Fontin", serif;
  letter-spacing: 0.05em;
  text-shadow: 0 1px 2px rgba(255, 220, 150, 0.5);
  white-space: nowrap;
}

.yt-banner-yt {
  position: relative;
  z-index: 1;
  height: clamp(18px, 2.5vw, 32px);
  width: auto;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.7));
}

/* ===== WHEEL ===== */
.wheel-pointer {
  --wheel-pointer-size: min(48px, 6.2%);
  --wheel-pointer-offset: calc(var(--wheel-pointer-size) * -1);
  display: block;
  width: var(--wheel-pointer-size);
  height: auto;
  margin: 0;
  position: absolute;
  top: 50%;
  right: var(--wheel-pointer-offset);
  z-index: 3;
  transform: translateY(-50%) rotate(90deg);
  transform-origin: 50% 50%;
  pointer-events: none;
  filter: sepia(0.3) saturate(0.75) brightness(0.8);
}

.wheel-pointer.is-pushed {
  animation: pointerPush 120ms ease-out;
}

.popup-active .wheel-pointer {
  display: none;
}

@keyframes pointerPush {
  0% {
    transform: translateY(-50%) rotate(90deg);
  }

  35% {
    transform: translateY(-50%) rotate(78deg);
  }

  100% {
    transform: translateY(-50%) rotate(90deg);
  }
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  aspect-ratio: 1 / 1;
  max-height: none;
  border-radius: 50%;
  cursor: pointer;
  position: relative;
  z-index: 1;
}

.wheel-container {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  width: min(var(--wheel-max), 65vw, 100%);
  height: min(var(--wheel-max), 65vw, 100%);
  aspect-ratio: 1 / 1;
}

.wheel-ring {
  position: absolute;
  width: 101%;
  height: 101%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 0;
  filter: sepia(0.4) saturate(0.8) brightness(0.85);
}

/* ===== MODAL ===== */
.popup {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  background: rgba(3, 5, 9, 0.9);
  backdrop-filter: blur(4px);
  z-index: 100;
}

.hidden {
  display: none;
}

.popup-content {
  position: relative;
  z-index: 1;
  max-width: min(900px, 95vw);
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: clamp(20px, 4vw, 60px);
  text-align: center;
  border-style: solid;
  border-width: 82px 78px 81px 81px;
  border-image: url("images/window.png") 82 78 81 81 fill / 82px 78px 81px 81px stretch;
  border-radius: 0;
  box-sizing: border-box;
  background: none;
}

.popup-window {
  position: relative;
  width: fit-content;
  max-width: min(900px, 95vw);
  display: flex;
  justify-content: center;
  align-items: center;
  box-sizing: border-box;
}

.popup-window:has(.is-final-popup) {
  max-width: min(1180px, 94vw);
}

.popup-title {
  margin: 0 0 40px;
  color: #f5e199;
  font-size: clamp(1.4rem, 4vw, 3rem);
  line-height: 1.15;
  letter-spacing: 0.04em;
  text-align: center;
}

.popup-portrait {
  display: block;
  width: clamp(100px, 30vw, 180px);
  height: auto;
  object-fit: cover;
  image-rendering: auto;
}

.final-popup-image {
  width: 1000px;
  max-width: calc(100vw - 176px);
  max-height: 40vh;
  height: auto;
  margin: 0 auto;
}

.popup-reminder {
  margin: 34px 0;
  color: rgba(255, 248, 237, 0.78);
  font-size: 2rem;
  line-height: 1.2;
  letter-spacing: 0.04em;
  text-align: center;
}

.popup-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: min(90%, 320px);
  height: clamp(50px, 8vw, 70px);
  min-height: 50px;
  min-width: 120px;
  padding: 0;
  color: #f5e199;
  font-size: clamp(0.9rem, 1.5vw, 1.3rem);
  text-align: center;
  background: none;
  border: none;
  cursor: pointer;
  z-index: 5;
  transition: transform 140ms ease, filter 140ms ease;
}

.popup-button-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  z-index: 0;
  pointer-events: none;
}

.popup-button > span:not(.tooltip-box) {
  position: relative;
  white-space: nowrap;
  z-index: 1;
  pointer-events: none;
}

.popup-button > span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.popup-actions {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  width: 100%;
  flex-wrap: wrap;
  margin-top: var(--space-sm);
}

.popup-content:has(.eliminated-text) {
  min-width: min(560px, 92vw);
  max-width: min(720px, 92vw);
  padding: clamp(26px, 3vw, 40px) clamp(38px, 4vw, 54px);
  justify-content: center;
  overflow: visible;
}

.popup-content:has(.eliminated-text) .popup-title {
  margin: 0 0 clamp(16px, 2vh, 24px);
  font-size: clamp(1.5rem, 3vw, 2.4rem);
}

.popup-content:has(.eliminated-text) .eliminated-text {
  margin-top: 8px;
  font-size: clamp(1.35rem, 2.5vw, 2rem);
}

.popup-content:has(.eliminated-text) .popup-portrait-wrapper {
  margin: 0 0 clamp(16px, 2vh, 22px);
}

.popup-content:has(.eliminated-text) .popup-actions {
  margin-top: 0;
}

.popup-button:hover {
  filter: brightness(1.15);
}

.popup-button:active {
  transform: translateY(3px);
}

.popup-button.hidden {
  display: none;
}

.is-final-popup {
  background-size: 100% 100%;
  width: min(88vw, 1180px);
  max-width: min(88vw, 1180px);
  max-height: 88vh;
  overflow: hidden;
  padding: clamp(26px, 3vw, 46px) clamp(36px, 4vw, 64px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: clamp(14px, 2vh, 24px);
}

.is-final-popup .popup-title {
  font-size: clamp(1.15rem, 2.1vw, 2.25rem);
  margin: 0;
  flex-shrink: 0;
}

.is-final-popup .popup-portrait-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  width: fit-content;
  max-width: 1040px;
  height: min(52vh, 560px);
  max-height: min(52vh, 560px);
  min-height: 0;
  margin: 0;
  flex: 1 1 auto;
  filter: none;
}

.is-final-popup .final-popup-image {
  width: auto;
  max-width: min(100%, 1040px);
  max-height: 100%;
  height: 100%;
  object-fit: contain;
  flex: 0 1 auto;
}

.is-final-popup .popup-reminder {
  font-size: clamp(0.8rem, 1.5vw, 1.8rem);
  margin: 0;
  flex-shrink: 0;
}

.is-final-popup .popup-actions {
  gap: 18px;
  margin-top: 0;
}

.is-final-popup .popup-title,
.is-final-popup .popup-reminder,
.is-final-popup .popup-actions {
  flex-shrink: 0;
}

.is-final-popup .popup-portrait-frame {
  display: none;
}

.popup-portrait-wrapper {
  position: relative;
  display: block;
  width: fit-content;
  margin: var(--space-sm) 0;
  filter: drop-shadow(0 0 10px rgba(255, 236, 190, 0.25));
}

.popup-portrait-frame {
  position: absolute;
  inset: -8px;
  width: calc(100% + 16px);
  height: calc(100% + 16px);
  pointer-events: none;
  z-index: 1;
}

.eliminated-text {
  margin-top: 12px;
  font-size: 2.2rem;
  color: #a11c1c;
  font-weight: bold;
  letter-spacing: 0.08em;
  text-align: center;
  text-shadow: 0 0 6px rgba(160, 0, 0, 0.5);
}

.blood-splatter {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 140px;
  pointer-events: none;
  z-index: 2;
  opacity: 0;
  transition: opacity 0.1s ease;
  transform: translate(-50%, -50%) scale(0.9);
}

.blood-splatter.show {
  opacity: 1;
}

@keyframes screenShake {
  0%   { transform: translate(0, 0); }
  25%  { transform: translate(-10px, 6px); }
  50%  { transform: translate(8px, -6px); }
  75%  { transform: translate(-6px, -4px); }
  100% { transform: translate(0, 0); }
}

.popup-content.shake {
  animation: screenShake 0.2s ease;
}

/* ===== LAYOUT ===== */
body.loading main,
body.loading .poe2-logo,
body.loading .game-logo-secondary-link,
body.loading .yt-banner,
body.loading .restart-button,
body.loading .class-selector-panel {
  filter: blur(6px);
  pointer-events: none;
}

#loader {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 12, 18, 0.5);
  backdrop-filter: blur(6px);
  z-index: 9999;
}

.loader-wheel {
  width: 80px;
  height: 80px;
  border: 4px solid rgba(255, 220, 150, 0.2);
  border-top: 4px solid #d6a63f;
  border-radius: 50%;
  animation: spinLoader 1s linear infinite;
  box-shadow: 0 0 20px rgba(255, 200, 100, 0.4);
}

@keyframes spinLoader {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* ===== TOGGLE ===== */
.mode-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.mode-toggle img {
  width: 50px;
  height: auto;
  cursor: pointer;
  transform: translateY(1px);
  transition: transform 0.15s ease, filter 0.15s ease;
}

.mode-label {
  font-size: calc(1rem * var(--ui-scale));
  color: rgba(245, 225, 153, 0.85);
  letter-spacing: 0.05em;
  min-width: 90px;
  text-align: center;
  opacity: 1;
}

.mode-label.active {
  color: #f5e199;
  font-weight: bold;
  opacity: 1;
}

.mode-label.inactive {
  color: rgba(245, 225, 153, 0.5);
  opacity: 1;
}

.tooltip {
  position: relative;
  display: inline-block;
}

.popup-button.tooltip:not(.hidden) {
  display: inline-flex;
}

.tooltip-box {
  position: absolute;
  bottom: 120%;
  left: 50%;
  padding: 6px 10px;
  color: #e6d3a3;
  font-size: 12px;
  white-space: nowrap;
  background: rgba(0, 0, 0, 0.9);
  border: 1px solid #c9a44b;
  border-radius: 6px;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%);
  transition: opacity 0.2s ease;
  z-index: 10;
}

.mode-label.inactive .tooltip-box {
  opacity: 0;
}

.tooltip:hover .tooltip-box {
  opacity: 1 !important;
}

.mode-toggle img:hover {
  filter: brightness(1.15);
}

.mode-toggle img:active {
  transform: translateY(1px) scale(0.96);
}

.restart-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 160px;
  height: 40px;
  padding: 0;
  color: #f5e199;
  font-size: calc(0.95rem * var(--ui-scale));
  letter-spacing: 0.05em;
  background-color: transparent;
  background-image: url("images/goldbutton.png");
  background-size: 100% 100%;
  background-repeat: no-repeat;
  border: none;
  outline: none;
  cursor: pointer;
  transition: filter 140ms ease, transform 140ms ease;
}

.restart-button:hover {
  filter: brightness(1.15);
}

.restart-button:active {
  transform: scale(0.96);
}

/* ===== CLASS SELECTOR ===== */
.class-selector-panel {
  width: clamp(300px, 26vw, 420px);
  height: auto;
  overflow: visible;
  display: flex;
  flex-direction: column;
  padding: clamp(16px, 2vw, 28px);
  color: #f5e199;
  border-style: solid;
  border-width: 83px 79px 82px 82px;
  border-image: url("images/window.png") 82 78 81 81 fill / 82px 78px 81px 81px stretch;
  box-sizing: border-box;
  background: none;
  z-index: 15;
  transition: opacity 180ms ease, filter 180ms ease;
}

.class-selector-content {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  width: 100%;
  min-height: 0;
}

.class-selector-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0;
  overflow: visible;
  min-height: 0;
  padding-right: 6px;
}

.class-selector-item {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 20px;
  width: 100%;
  padding: 2px 4px;
  color: rgba(255, 248, 237, 0.9);
  font-size: clamp(0.75rem, 1vw, 1.05rem);
  line-height: 1.15;
  text-align: left;
  background: transparent;
  border: 0;
  cursor: pointer;
}

.class-selector-item:hover {
  color: #f5e199;
}

.class-selector-check {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  object-fit: contain;
  transition: transform 120ms ease, filter 120ms ease;
}

.class-selector-item:hover .class-selector-check {
  filter: brightness(1.12);
  transform: scale(1.12);
}

.class-selector-item span {
  min-width: 0;
  white-space: normal;
  word-break: break-word;
}

.class-selector-toggle {
  position: relative;
  align-self: center;
  width: min(80%, 240px);
  min-height: 42px;
  margin-top: 18px;
  padding: 8px 16px;
  color: #f5e199;
  font-size: clamp(0.95rem, 1.2vw, 1.2rem);
  letter-spacing: 0.04em;
  text-shadow: 0 1px 2px rgba(25, 9, 0, 0.85);
  background: url("images/goldbutton.png") center/100% 100% no-repeat;
  border: 0;
  cursor: pointer;
  transition: filter 140ms ease, transform 140ms ease;
}

.class-selector-toggle:hover {
  filter: brightness(1.15);
}

.class-selector-toggle:active {
  transform: translateY(2px);
}

.class-selector-panel.is-locked {
  opacity: 0.46;
  pointer-events: none;
  filter: saturate(0.65);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1200px) {
  :root {
    --wheel-max: 760px;
    --main-column-gap: clamp(32px, 3vw, 48px);
    --main-content-lift: clamp(56px, 6vw, 72px);
    --selector-polish-lift: clamp(12px, 1.5vw, 18px);
    --selector-polish-offset: clamp(12px, 1.5vw, 18px);
  }

  h1 {
    font-size: clamp(1rem, 2vw, 2rem);
    margin-bottom: 18px;
  }

  .class-selector-panel {
    width: clamp(300px, 25vw, 380px);
    height: auto;
    max-height: none;
    overflow: visible;
  }
}

@media (max-width: 992px) {
  :root {
    --wheel-max: 620px;
    --main-column-gap: clamp(20px, 2.5vw, 32px);
    --main-content-lift: clamp(36px, 5vw, 56px);
    --selector-polish-lift: clamp(8px, 1vw, 12px);
    --selector-polish-offset: clamp(8px, 1vw, 12px);
  }

  h1 {
    font-size: clamp(1rem, 2vw, 1.7rem);
    margin-bottom: 14px;
  }

  .class-selector-panel {
    width: clamp(280px, 30vw, 340px);
  }

  .app-footer {
    padding: clamp(6px, 1vh, 12px) clamp(14px, 3vw, 48px);
  }
}

@media (max-height: 800px) {
  .wheel-container {
    width: min(var(--wheel-max), 65vw, calc(100vh - 410px));
    height: min(var(--wheel-max), 65vw, calc(100vh - 410px));
  }

  .class-selector-panel {
    max-height: min(58vh, 420px);
  }

  .class-selector-list {
    overflow-y: auto;
  }

  .class-selector-item {
    font-size: 0.85rem;
    min-height: 20px;
  }

  .class-selector-toggle {
    width: 150px;
    min-height: 36px;
  }
}

@media (min-width: 1201px) and (max-width: 1300px) and (max-height: 760px) {
  :root {
    --main-column-gap: 16px;
    --main-content-lift: clamp(67px, calc(7.1vw - 9px), 81px);
    --selector-polish-lift: 0px;
    --selector-polish-offset: 26px;
  }

  .poe2-logo {
    width: clamp(160px, 14.5vw, 186px);
  }

  h1 {
    font-size: clamp(1.35rem, 2vw, 1.65rem);
    margin-bottom: 12px;
    position: relative;
    top: -20px;
  }

  .wheel-container {
    width: min(485px, 38vw);
    height: min(485px, 38vw);
    top: 22px;
  }

  .class-selector-panel {
    width: 332px;
    max-height: 480px;
    overflow: visible;
    padding: 8px;
  }

  .app-main > :last-child.class-selector-panel {
    top: 17px;
  }

  .class-selector-content {
    gap: 2px;
  }

  .class-selector-list {
    gap: 0;
    overflow: visible;
  }

  .class-selector-item {
    min-height: 11px;
    padding: 0 1px;
    font-size: 0.54rem;
    line-height: 0.9;
  }

  .class-selector-check {
    width: 12px;
    height: 12px;
  }

  .class-selector-toggle {
    width: 116px;
    min-height: 24px;
    margin-top: 4px;
    padding: 3px 8px;
    font-size: 0.72rem;
  }

  .app-footer {
    padding: 5px clamp(16px, 3vw, 38px);
  }

  .yt-banner {
    width: 206px;
    gap: 8px;
    padding: 0 8px;
  }

  .yt-banner-wolf {
    height: 39px;
  }

  .yt-banner-name {
    font-size: 1.06rem;
  }

  .yt-banner-yt {
    height: 22px;
  }

  .mode-toggle {
    gap: 8px;
  }

  .mode-toggle img {
    width: 40px;
  }

  .mode-label {
    min-width: 76px;
    font-size: 0.85rem;
  }

  .restart-button {
    width: 132px;
    height: 34px;
    font-size: 0.82rem;
  }

  .popup-window:has(.is-final-popup) {
    max-width: min(94vw, 1120px);
  }

  .is-final-popup {
    width: min(94vw, 1120px);
    max-width: min(94vw, 1120px);
    max-height: calc(100vh - 24px);
    padding: 14px 30px;
    justify-content: center;
    gap: 8px;
  }

  .is-final-popup .popup-title {
    font-size: 1.35rem;
    line-height: 1.15;
  }

  .is-final-popup .popup-portrait-wrapper {
    max-width: 100%;
    height: min(51vh, 370px);
    max-height: min(51vh, 370px);
    min-height: 0;
    flex: 1 1 auto;
  }

  .is-final-popup .final-popup-image {
    max-width: 100%;
    max-height: 100%;
  }

  .is-final-popup .popup-reminder {
    font-size: 0.95rem;
    line-height: 1.15;
  }

  .is-final-popup .popup-actions {
    gap: 10px;
  }
}

@media (min-width: 1301px) and (max-width: 1499px) and (min-height: 730px) and (max-height: 820px) {
  :root {
    --main-column-gap: 24px;
    --main-content-lift: 100px;
    --selector-polish-offset: 12px;
  }

  h1 {
    position: relative;
    top: -32px;
  }

  .wheel-container {
    width: min(515px, 65vw);
    height: min(515px, 65vw);
    top: 34px;
  }

  .class-selector-panel {
    width: 390px;
    max-height: min(74vh, 570px);
    padding: 0 12px 2px;
  }

  .app-main > :last-child.class-selector-panel {
    top: calc(-1 * var(--selector-polish-lift) + 34px);
  }

  .class-selector-content {
    flex: 1 1 auto;
    gap: 2px;
    height: 100%;
  }

  .class-selector-list {
    flex: 1 1 auto;
    gap: 0;
    overflow: hidden;
  }

  .class-selector-item {
    min-height: 14px;
    padding: 1px 2px;
    font-size: 0.76rem;
    line-height: 1.05;
  }

  .class-selector-check {
    width: 16px;
    height: 16px;
  }

  .class-selector-toggle {
    width: 138px;
    min-height: 32px;
    margin-top: 14px;
    padding: 5px 10px;
    font-size: 0.82rem;
  }

  .yt-banner {
    width: 230px;
    gap: 10px;
    padding: 0 10px;
  }

  .yt-banner-wolf {
    height: 42px;
  }

  .yt-banner-name {
    font-size: 1.12rem;
  }

  .yt-banner-yt {
    height: 24px;
  }
}

@media (min-width: 1800px) and (max-width: 2200px) and (min-height: 1000px) and (max-height: 1200px) {
  h1 {
    position: relative;
    top: -5px;
  }

  .wheel-container {
    width: min(720px, 65vw);
    height: min(720px, 65vw);
    top: 23px;
  }

  .class-selector-panel {
    width: 360px;
    padding: 18px;
  }

  .app-main > :last-child.class-selector-panel {
    top: calc(-1 * var(--selector-polish-lift) + 23px);
  }

  .class-selector-content {
    gap: 8px;
  }

  .class-selector-list {
    gap: 2px;
  }

  .class-selector-item {
    min-height: 17px;
    padding: 1px 3px;
    font-size: 0.82rem;
    line-height: 1.05;
  }

  .class-selector-check {
    width: 18px;
    height: 18px;
  }

  .class-selector-toggle {
    min-height: 34px;
    margin-top: 12px;
    font-size: 0.95rem;
  }
}

@media (min-width: 1500px) and (max-width: 1799px) and (min-height: 840px) and (max-height: 980px) {
  h1 {
    position: relative;
    top: -5px;
  }

  .wheel-container {
    width: min(615px, 65vw);
    height: min(615px, 65vw);
    top: 41px;
  }

  .class-selector-panel {
    width: 360px;
    padding: 14px;
  }

  .app-main > :last-child.class-selector-panel {
    top: calc(-1 * var(--selector-polish-lift) + 41px);
  }

  .class-selector-content {
    gap: 6px;
  }

  .class-selector-list {
    gap: 1px;
  }

  .class-selector-item {
    min-height: 16px;
    padding: 1px 2px;
    font-size: 0.78rem;
    line-height: 1.05;
  }

  .class-selector-check {
    width: 16px;
    height: 16px;
  }
}

@media (min-width: 2201px) and (max-width: 3000px) and (min-height: 1201px) and (max-height: 1600px) {
  h1 {
    position: relative;
    top: -5px;
  }

  .wheel-container {
    top: 5px;
  }

  .app-main > :last-child.class-selector-panel {
    top: calc(-1 * var(--selector-polish-lift) + 5px);
  }
}

@media (max-width: 768px) {
  :root {
    --wheel-max: 360px;
    --main-content-lift: 0px;
    --selector-polish-lift: 0px;
    --selector-polish-offset: 0px;
  }

  h1 {
    font-size: clamp(1rem, 4vw, 1.45rem);
    margin-bottom: 10px;
  }

  .wheel-container {
    width: min(var(--wheel-max), 62vw);
    height: min(var(--wheel-max), 62vw);
  }

  .class-selector-panel {
    width: min(88vw, 420px);
    height: auto;
    max-height: clamp(220px, 28vh, 290px);
    overflow: visible;
  }

  .class-selector-list {
    margin-bottom: 0;
    overflow-y: auto;
  }

  .class-selector-item {
    min-height: 20px;
    font-size: 0.8rem;
  }

  .class-selector-toggle {
    min-height: 36px;
    margin-top: 10px;
  }

  .app-footer {
    padding: 6px clamp(10px, 4vw, 24px);
  }
}

.app {
  height: 100vh;
  min-height: 100vh;
  width: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.app-header {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  width: 100%;
  padding: 20px;
}

.app-main {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  grid-template-rows: auto auto minmax(0, 1fr);
  align-content: start;
  align-items: center;
  column-gap: var(--main-column-gap);
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 0 clamp(12px, 2vw, 80px);
  top: calc(-1 * var(--main-content-lift));
}

.app-footer {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-items: center;
  width: 100vw;
  padding: clamp(8px, 1.5vh, 16px) clamp(20px, 4vw, 80px);
}

.app-main > * {
  position: relative;
  z-index: 1;
}

.app-main > :first-child {
  grid-column: 2;
  justify-self: center;
  display: contents;
}

.app-main h1 {
  grid-column: 2;
  grid-row: 1;
  justify-self: center;
}

.app-main .wheel-container {
  grid-column: 2;
  grid-row: 3;
  align-self: center;
  justify-self: center;
}

.app-main > :last-child {
  grid-column: 3;
  grid-row: 3;
  justify-self: start;
  align-self: center;
  top: calc(-1 * var(--selector-polish-lift));
  margin-left: var(--selector-polish-offset);
}

.app-footer > :nth-child(1) {
  justify-self: start;
}

.app-footer > :nth-child(2) {
  justify-self: center;
}

.app-footer > :nth-child(3) {
  justify-self: end;
}

@media (max-width: 768px) {
  .app-main {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    row-gap: 12px;
    align-items: center;
    justify-content: center;
    top: auto;
  }

  .app-main > :first-child {
    grid-column: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
  }

  .app-main > :last-child {
    grid-column: 1;
    grid-row: auto;
    justify-self: center;
    top: auto;
    margin-left: 0;
    margin-top: 0;
  }

  .app-footer {
    grid-template-columns: 1fr;
    row-gap: 6px;
    justify-items: center;
  }

  .app-footer > :nth-child(1),
  .app-footer > :nth-child(2),
  .app-footer > :nth-child(3) {
    justify-self: center;
  }
}

@media (max-width: 480px) {
  :root {
    --wheel-max: 230px;
  }

  .poe2-logo {
    width: clamp(78px, 28vw, 120px);
  }

  .app-header {
    padding: 12px;
  }

  h1 {
    font-size: clamp(0.95rem, 4.8vw, 1.15rem);
    margin-bottom: 8px;
  }

  canvas {
    width: 100%;
    height: 100%;
  }

  .restart-button {
    width: clamp(130px, 48vw, 190px);
  }

  .yt-banner {
    width: clamp(150px, 58vw, 220px);
    gap: 8px;
  }

  .mode-toggle {
    gap: 8px;
  }

  .mode-toggle img {
    width: 42px;
  }

  .tooltip-box {
    max-width: min(82vw, 280px);
    white-space: normal;
    overflow-wrap: break-word;
  }

  .class-selector-item {
    min-height: 18px;
    font-size: 0.74rem;
    line-height: 1.1;
  }

  .class-selector-check {
    width: 18px;
    height: 18px;
  }

  .class-selector-toggle {
    min-height: 32px;
    margin-top: 6px;
    padding: 6px 12px;
    font-size: 0.9rem;
  }

  .popup-content {
    padding: clamp(16px, 4vw, 40px);
  }

  .popup-reminder {
    font-size: clamp(0.8rem, 3vw, 1.4rem);
    margin: var(--space-xs) 0;
  }
}

@media (max-width: 600px) {
  .popup-actions {
    flex-direction: column;
    gap: 12px;
  }

  .popup-button {
    width: 100%;
    max-width: 260px;
  }
}

@media (max-width: 400px) {
  .popup-content {
    padding: 24px;
  }

  .popup-title {
    font-size: 1.5rem;
  }

  .popup-button {
    width: 100%;
  }
}

@media (max-height: 700px) {
  .class-selector-item {
    font-size: 0.7rem;
    min-height: 18px;
  }
}

.class-selector-panel {
  height: auto;
  overflow: visible;
}

.class-selector-list {
  overflow: visible;
  min-height: 0;
}

.popup-content {
  image-rendering: auto;
  transform: translateZ(0);
  backface-visibility: hidden;
  filter: drop-shadow(0 0 18px rgba(255, 200, 80, 0.25))
          drop-shadow(0 0 40px rgba(255, 180, 50, 0.15));
  overflow: visible;
}

.class-selector-panel {
  image-rendering: auto;
  backface-visibility: hidden;
  border-image-repeat: stretch;
  box-shadow: none !important;
  filter: none !important;
  overflow: visible;
}

@media (max-height: 800px), (max-width: 768px) {
  .class-selector-panel {
    overflow: hidden;
  }

  .class-selector-content {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
  }

  .class-selector-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
  }

  .class-selector-toggle {
    flex: 0 0 auto;
  }
}

@media (max-width: 768px) {
  .class-selector-panel {
    max-height: clamp(240px, 27vh, 300px);
  }
}

@media (max-width: 600px) {
  .app {
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: 100vh;
  }

  .app-header {
    order: 1;
    padding: 28px 0 0 36px;
    justify-content: flex-start;
    overflow: visible;
  }

  .poe2-logo {
    position: static;
    flex: 0 0 auto;
  }

  .game-logo-secondary-link {
    top: 50%;
    left: calc(100% + 14px);
    margin-top: 0;
    transform: translateY(-50%);
  }

  .game-logo-secondary-link:hover,
  .game-logo-secondary-link:focus-visible {
    transform: translateY(-50%) scale(1.04);
  }

  .app-main,
  .app-footer {
    display: contents;
  }

  .wheel-area {
    order: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    padding: 0 10px;
  }

  .wheel-container {
    width: calc(100vw - 32px);
    height: calc(100vw - 32px);
    justify-self: center;
    margin-inline: auto;
  }

  .mode-toggle {
    order: 3;
    align-self: center;
    margin-top: 12px;
  }

  .restart-button {
    order: 4;
    align-self: center;
    width: clamp(116px, 42vw, 165px);
    height: 34px;
    margin-top: 20px;
  }

  .class-selector-panel {
    order: 5;
    align-self: center;
    width: min(75vw, 310px);
    max-height: none;
    overflow: visible;
    padding: clamp(10px, 3vw, 16px) clamp(6px, 2vw, 10px);
    margin-top: 18px;
  }

  .class-selector-content {
    flex: 1 1 auto;
    gap: 8px;
    min-height: 0;
    overflow: visible;
  }

  .class-selector-list {
    flex: 0 0 auto;
    min-height: 0;
    margin-bottom: 0;
    overflow: visible;
  }

  .class-selector-item span {
    flex: 1 1 auto;
    white-space: nowrap;
    word-break: normal;
    overflow-wrap: normal;
  }

  .yt-banner {
    order: 6;
    align-self: center;
    margin-top: auto;
    margin-bottom: 12px;
  }
}

@media (width: 360px) and (height: 740px) {
  .class-selector-list {
    width: calc(100% + 6px);
    margin-left: -6px;
    padding-right: 0;
  }

  .class-selector-item {
    padding-left: 0;
  }
}

@media (max-width: 768px) {
  .is-final-popup {
    height: auto;
    min-height: 0;
  }

  .is-final-popup .popup-portrait-wrapper {
    height: auto;
    max-height: none;
    flex: 0 0 auto;
  }
}
