:root {
  --color: #ff5eaa;
  --bg: #1e1a2b;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  background: var(--bg);
  color: #fff;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.screen[hidden] {
  display: none !important;
}

h1 {
  margin: 0 0 8px;
  font-size: 40px;
  background: linear-gradient(90deg, #ff5eaa, #fdbc56, #67db66, #299efe);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ---------- Join ---------- */

#join {
  height: 100%;
  max-width: 420px;
  margin: 0 auto;
  padding: 32px 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  opacity: 0.9;
}

input {
  font: inherit;
  font-size: 22px;
  padding: 12px 14px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  -webkit-user-select: text;
  user-select: text;
}

input:focus {
  outline: none;
  border-color: #ff5eaa;
}

#codeInput {
  text-transform: uppercase;
  letter-spacing: 8px;
  font-weight: bold;
}

button {
  font: inherit;
  border: 0;
  color: #fff;
  cursor: pointer;
}

#join button {
  font-size: 22px;
  font-weight: bold;
  padding: 14px;
  border-radius: 99px;
  background: #ff5eaa;
}

#join button:disabled {
  opacity: 0.5;
}

.error {
  min-height: 1.4em;
  margin: 0;
  color: #ff8a80;
}

.host-link {
  margin: 0;
  font-size: 13px;
  opacity: 0.6;
}

.host-link a {
  color: inherit;
}

#join .install {
  font-size: 15px;
  font-weight: normal;
  padding: 10px;
  background: rgba(255, 255, 255, 0.12);
}

#join .install[hidden] {
  display: none;
}

#link {
  font-size: 13px;
  opacity: 0.8;
}

/* ---------- Pad ---------- */

#pad {
  position: fixed;
  inset: 0;
  background: var(--color);
  touch-action: none;
}

#pad header {
  position: absolute;
  z-index: 2;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: max(10px, env(safe-area-inset-top)) 14px 10px;
  font-weight: bold;
  font-size: 18px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  pointer-events: none;
}

#leave {
  pointer-events: auto;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.25);
  font-size: 16px;
}

.halves {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.halves div {
  display: grid;
  place-items: center;
  font-size: min(30vw, 30vh);
  color: rgba(0, 0, 0, 0.18);
  transition: background 60ms;
}

.halves div:first-child {
  border-right: 2px solid rgba(0, 0, 0, 0.12);
}

.halves div.down {
  background: rgba(0, 0, 0, 0.18);
  color: rgba(255, 255, 255, 0.6);
}

.center {
  position: absolute;
  z-index: 2;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: min(80vw, 420px);
  text-align: center;
  pointer-events: none;
}

#status {
  margin: 0;
  font-size: 22px;
  font-weight: bold;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
}

#status:empty {
  display: none;
}

#status .big {
  display: block;
  font-size: 64px;
}

#action {
  pointer-events: auto;
  font-size: 26px;
  font-weight: bold;
  padding: 18px 40px;
  border-radius: 99px;
  background: var(--bg);
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.3);
}

#action:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.3);
}

#action[hidden] {
  display: none;
}

#toast {
  position: absolute;
  z-index: 3;
  left: 0;
  right: 0;
  bottom: 18%;
  margin: 0;
  text-align: center;
  font-size: 34px;
  font-weight: 900;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
}

#toast.show {
  animation: pop 1.2s ease-out;
}

@keyframes pop {
  0% {
    opacity: 0;
    transform: scale(0.6);
  }
  15% {
    opacity: 1;
    transform: scale(1.1);
  }
  70% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0;
  }
}

#offline {
  position: absolute;
  z-index: 4;
  left: 0;
  right: 0;
  bottom: 0;
  margin: 0;
  padding: 10px max(10px, env(safe-area-inset-bottom));
  text-align: center;
  background: #b3261e;
}

#offline[hidden] {
  display: none;
}

/* ---------- Donation link (after a round) ---------- */

#pad .support {
  pointer-events: auto;
  padding: 8px 16px;
  border-radius: 99px;
  background: rgba(0, 0, 0, 0.22);
  color: #fff;
  font-size: 15px;
  text-decoration: none;
}

#pad .support[hidden] {
  display: none;
}
