:root {
  --pad: 12px;
  --radius: 18px;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: black;
  overflow: hidden;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  overscroll-behavior: none;
}

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

video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: black;
}

.stage {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

.subs {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: max(40px, env(safe-area-inset-bottom));
  width: min(980px, calc(100vw - 24px));
  padding: 10px 14px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.35);
  color: rgba(255, 255, 255, 0.95);
  font-size: 18px;
  line-height: 1.35;
  text-align: center;
  pointer-events: none;
  z-index: 2;
}

.subs:empty {
  display: none;
}

.subs .hl {
  font-weight: 800;
  text-decoration: underline;
}

/* Simple floating search bar */
.search {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  top: max(12px, env(safe-area-inset-top));
  width: min(900px, calc(100vw - 16px));
  display: flex;
  gap: 10px;
  padding: var(--pad);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(10px);
}

.hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

.hud .search,
.hud .status {
  pointer-events: auto;
}

.status {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  top: calc(max(12px, env(safe-area-inset-top)) + 72px);
  width: min(900px, calc(100vw - 16px));
  color: rgba(255, 255, 255, 0.9);
  font-size: 13px;
  text-align: center;
  padding: 8px 10px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.35);
}

.status:empty {
  display: none;
}

/* Input: mobile-friendly sizes */
.search input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  color: white;
  font-size: 16px; /* prevents iOS zoom */
  line-height: 20px;
  padding: 10px 10px;
  min-width: 0;
  text-align: left;
}

.search input:placeholder-shown {
  text-align: center;
}

/* Button: bigger tap target */
.search button {
  border: none;
  padding: 10px 14px;
  border-radius: 14px;
  font-weight: 700;
  cursor: pointer;
  min-height: 40px;
  white-space: nowrap;
}

.lang {
  display: flex;
  align-items: center;
}

.lang select {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(0, 0, 0, 0.35);
  color: rgba(255, 255, 255, 0.95);
  padding: 10px 12px;
  border-radius: 14px;
  font-weight: 800;
  min-height: 40px;
  cursor: pointer;
}

/* Toast: keep visible above home indicator */
.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: max(80px, env(safe-area-inset-bottom));
  color: white;
  background: rgba(0, 0, 0, 0.55);
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  display: none;
}

/* Small screens: keep it clean */
@media (max-width: 420px) {
  .subs {
    bottom: max(96px, calc(env(safe-area-inset-bottom) + 24px));
    font-size: 16px;
  }

  .search {
    width: calc(100vw - 16px);
    gap: 8px;
    padding: 10px;
    border-radius: 16px;
  }

  .search button {
    padding: 10px 12px;
    border-radius: 12px;
  }

  .lang select {
    padding: 10px 10px;
    border-radius: 12px;
  }
}

.legal {
  position: fixed;
  right: 12px;
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 9999;
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.legal button {
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 12px;
  cursor: pointer;
}

.legal__github {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  text-decoration: none;
}

.legal__github:hover,
.legal__github:focus-visible {
  border-color: rgba(255, 255, 255, 0.28);
}

.legal-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0, 0, 0, 0.7);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.legal-modal.open {
  display: flex;
}

.legal-content {
  width: min(560px, 100%);
  max-height: 80vh;
  overflow: auto;
  background: #111;
  color: #fff;
  border-radius: 18px;
  padding: 18px;
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.legal-content h2 {
  margin: 0 0 10px 0;
  font-size: 16px;
}

.legal-content p {
  margin: 0 0 10px 0;
  font-size: 13px;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.9);
}

.legal-content .close {
  position: absolute;
  top: 10px;
  right: 12px;
  background: transparent;
  border: 0;
  color: #fff;
  font-size: 22px;
  cursor: pointer;
}

.clip-overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: flex-end;
  justify-content: center;
  padding: 20px;
  z-index: 1;
  background: transparent;
  pointer-events: none;
}

.clip-overlay.open {
  display: flex;
}

.clip-overlay__card {
  width: min(520px, calc(100vw - 24px));
  background: rgba(0, 0, 0, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 18px;
  padding: 16px;
  color: #fff;
  text-align: center;
  pointer-events: auto;
}

.clip-overlay__title {
  font-weight: 800;
  font-size: 16px;
}

.clip-overlay__text {
  margin-top: 6px;
  font-size: 13px;
  opacity: 0.9;
}

.clip-overlay__card button {
  margin-top: 12px;
  border: none;
  padding: 10px 14px;
  border-radius: 14px;
  font-weight: 800;
  cursor: pointer;
  min-height: 42px;
}
