@font-face {
  font-family: "Kargo Sans";
  src: url("./assets/fonts/IFKargoSans-ExtraLight.woff") format("woff");
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Kargo Sans";
  src: url("./assets/fonts/IFKargoSans-Regular.woff") format("woff");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Kargo Sans";
  src: url("./assets/fonts/IFKargoSans-Medium.woff") format("woff");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Kargo Sans";
  src: url("./assets/fonts/IFKargoSans-Bold.woff") format("woff");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;
  --bg: #ffffff;
  --fg: #000000;
  --fg-muted: #555555;
  --accent: #8f7a4a;
  --accent-hover: #5e5030;
  --accent-fg: #fbfafd;
  font-family: "Kargo Sans", sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body,
#experience {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

body {
  background: #202225;
  color: var(--fg);
}

#experience::after {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  content: "";
  background:
    radial-gradient(circle at 50% 45%, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0) 42%),
    radial-gradient(circle at 50% 52%, rgba(0, 0, 0, 0) 46%, rgba(0, 0, 0, 0.32) 100%);
}

button,
input {
  font: inherit;
}

button,
.site-button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 0 15px;
  border: 1px solid var(--fg);
  border-radius: 6px;
  background: var(--bg);
  color: var(--fg);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.1em;
  line-height: 1;
  text-decoration: none;
  text-transform: uppercase;
  touch-action: manipulation;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease, transform 120ms ease, opacity 120ms ease;
  white-space: nowrap;
}

button:hover,
.site-button:hover {
  background: var(--fg);
  color: var(--bg);
}

button[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-fg);
}

button:disabled {
  cursor: default;
  opacity: 0.42;
}

button:active,
.site-button:active {
  transform: scale(0.98);
}

button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
}

#scene.is-dragging {
  cursor: grabbing;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: var(--bg);
}

.loading-overlay[hidden] {
  display: none !important;
}

.loading-overlay > div,
.title-panel,
.status-panel,
.gesture-panel,
.target-panel,
.language-switch,
.control-dock {
  border: 1px solid var(--fg);
  border-radius: 0;
  background: var(--bg);
  color: var(--fg);
  box-shadow: none;
}

.loading-overlay > div {
  width: min(420px, calc(100vw - 36px));
  padding: 24px;
}

.loading-overlay strong,
.title-panel p,
.status-panel > p {
  margin: 0;
  color: var(--fg-muted);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.loading-overlay p {
  margin: 12px 0;
  color: var(--fg);
}

.loading-overlay span {
  display: block;
  height: 2px;
  overflow: hidden;
  border: 1px solid var(--fg);
}

.loading-overlay i {
  display: block;
  width: 100%;
  height: 100%;
  transform-origin: left;
  animation: loadbar 900ms ease-in-out infinite alternate;
  background: var(--accent);
}

.title-panel,
.status-panel,
.gesture-panel,
.target-panel,
.language-switch,
.control-dock {
  position: fixed;
  z-index: 5;
}

.title-panel {
  top: clamp(16px, 3vw, 32px);
  left: clamp(16px, 3vw, 34px);
  width: min(430px, calc(100vw - 32px));
  padding: 24px;
  pointer-events: none;
}

.title-panel h1 {
  margin: 10px 0 12px;
  font-size: clamp(1.82rem, 3.15vw, 3.28rem);
  font-weight: 300;
  line-height: 0.98;
  letter-spacing: 0;
}

.title-panel span,
.status-panel span {
  color: var(--fg-muted);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.55;
}

.status-panel {
  right: clamp(16px, 3vw, 34px);
  top: clamp(16px, 3vw, 32px);
  width: min(375px, calc(100vw - 32px));
  padding: 20px;
}

.status-panel h2 {
  margin: 10px 0;
  font-size: 1.22rem;
  font-weight: 500;
  line-height: 1.15;
  letter-spacing: 0;
}

.language-switch {
  top: clamp(16px, 3vw, 32px);
  left: 50%;
  display: flex;
  gap: 6px;
  padding: 6px;
  transform: translateX(-50%);
}

.language-switch button {
  min-height: 32px;
  padding: 0 12px;
}

.gesture-panel {
  left: clamp(16px, 3vw, 34px);
  bottom: 94px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(330px, calc(100vw - 32px));
  padding: 14px;
}

.gesture-panel span {
  display: flex;
  min-height: 30px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.16);
  color: var(--fg-muted);
  font-size: 12px;
  line-height: 1.2;
}

.gesture-panel span:last-child {
  border-bottom: 0;
}

.gesture-panel b {
  color: var(--fg);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.target-panel {
  right: clamp(16px, 3vw, 34px);
  bottom: 94px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  width: min(375px, calc(100vw - 32px));
  padding: 12px;
}

.target-panel button {
  width: 100%;
  min-width: 0;
}

.target-panel[hidden] {
  display: none;
}

.free-panel {
  align-items: stretch;
}

.color-wheel {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 11px 0 15px;
  border: 1px solid var(--fg);
  border-radius: 6px;
  background: var(--bg);
  color: var(--fg);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.1em;
  line-height: 1;
  text-transform: uppercase;
}

.color-wheel input {
  width: 34px;
  height: 28px;
  padding: 0;
  border: 1px solid rgba(0, 0, 0, 0.28);
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
}

.color-wheel input:disabled {
  cursor: default;
  opacity: 0.42;
}

.difficulty-menu {
  position: relative;
  display: inline-flex;
}

.difficulty-options {
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  display: grid;
  width: 205px;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--fg);
  background: var(--bg);
}

.difficulty-options[hidden] {
  display: none;
}

.difficulty-options button {
  justify-content: flex-start;
  width: 100%;
}

.control-dock {
  left: 50%;
  bottom: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: auto;
  max-width: calc(100vw - 32px);
  padding: 12px;
  transform: translateX(-50%);
}

#rotateLeftBtn,
#rotateRightBtn {
  min-width: 46px;
  padding-inline: 0;
  font-size: 19px;
  letter-spacing: 0;
}

@media (max-width: 1180px), (max-height: 820px) {
  .title-panel {
    width: min(360px, calc(100vw - 28px));
    padding: 16px;
  }

  .title-panel h1 {
    margin-bottom: 0;
    font-size: clamp(1.55rem, 3vw, 2.35rem);
  }

  .title-panel span {
    display: none;
  }

  .status-panel {
    width: min(340px, calc(100vw - 28px));
    padding: 16px;
  }

  .gesture-panel {
    display: none;
  }
}

@keyframes loadbar {
  from {
    transform: scaleX(0.16);
  }

  to {
    transform: scaleX(0.92);
  }
}

@media (max-width: 920px) {
  .title-panel {
    width: min(370px, calc(100vw - 28px));
    padding: 16px;
  }

  .title-panel span {
    display: none;
  }

  .status-panel {
    top: auto;
    right: 14px;
    bottom: 144px;
    width: min(350px, calc(100vw - 28px));
    padding: 14px;
  }

  .language-switch {
    top: 14px;
    left: auto;
    right: 14px;
    transform: none;
  }

  .gesture-panel {
    display: none;
  }

  .status-panel span {
    display: none;
  }

  .target-panel {
    left: 14px;
    right: auto;
    bottom: 144px;
    width: min(310px, calc(100vw - 28px));
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
    padding: 6px;
  }

  .target-panel button {
    min-height: 32px;
    padding: 0 5px;
    font-size: 8px;
  }

  .control-dock {
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    flex-wrap: wrap;
    gap: 4px;
    justify-content: stretch;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    transform: none;
  }

  .control-dock button,
  .control-dock .site-button {
    min-height: 34px;
    min-width: 0;
    flex: 1 1 calc(20% - 4px);
    padding: 0 5px;
    font-size: 7px;
  }

  .difficulty-menu {
    flex: 1 1 calc(28% - 4px);
  }

  .difficulty-menu > button {
    width: 100%;
  }

  .difficulty-options {
    width: min(240px, 92vw);
  }

  #rotateLeftBtn,
  #rotateRightBtn {
    flex: 0 0 38px;
    font-size: 17px;
  }
}

@media (max-height: 520px) and (orientation: landscape) {
  .title-panel {
    top: 8px;
    left: 8px;
    width: min(250px, calc(100vw - 92px));
    padding: 9px 11px;
  }

  .title-panel h1 {
    margin-top: 4px;
    font-size: 1.12rem;
    line-height: 0.95;
  }

  .title-panel p {
    font-size: 8px;
    letter-spacing: 0.12em;
  }

  .status-panel {
    display: none;
  }

  .language-switch {
    top: 8px;
    right: 8px;
    padding: 5px;
  }

  .language-switch button {
    min-height: 28px;
    padding: 0 8px;
    font-size: 8px;
  }

  .control-dock {
    left: 50%;
    right: auto;
    padding: 7px;
    gap: 5px;
    width: auto;
    max-width: calc(100vw - 16px);
    flex-wrap: nowrap;
    transform: translateX(-50%);
  }

  .control-dock button,
  .control-dock .site-button {
    flex: 0 1 auto;
    min-height: 30px;
    padding: 0 9px;
    font-size: 7px;
  }

  .difficulty-menu {
    flex: 0 1 auto;
  }

  #rotateLeftBtn,
  #rotateRightBtn {
    flex: 0 0 34px;
  }
}

@media (max-width: 620px) {
  .status-panel {
    display: none;
  }

  .target-panel {
    right: 8px;
    bottom: 92px;
    left: 8px;
    width: auto;
  }

  .title-panel {
    left: 12px;
    top: 12px;
    width: min(232px, calc(100vw - 96px));
    padding: 10px 12px;
  }

  .language-switch {
    top: 12px;
    right: 8px;
    bottom: auto;
  }

  .language-switch button {
    min-height: 30px;
    padding: 0 8px;
    font-size: 8px;
  }

  .difficulty-options {
    left: 0;
    right: auto;
    bottom: calc(100% + 6px);
  }

  .title-panel h1 {
    margin: 5px 0 0;
    font-size: 1.28rem;
    line-height: 0.96;
  }

  .title-panel p {
    font-size: 9px;
    letter-spacing: 0.12em;
  }
}
