/* Whiteboard — phone-first. One fixed screen: slim top bar, the court fills
   the middle, a thumb-reach bottom bar. Brand palette from AJH Studio. */
:root {
  --bg: #0B0F1A;
  --surface: #1A1F2E;
  --surface-2: #232a3d;
  --line: rgba(242, 244, 248, 0.08);
  --text: #F2F4F8;
  --muted: #8A93A6;
  --violet: #7B2CFF;
  --cyan: #00E5FF;
  --coral: #FF5C5C;
  --ball: #FF8A1F;
  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;
  --tap: 44px;
}

* { box-sizing: border-box; }
html, body { height: 100%; overscroll-behavior: none; }
body {
  margin: 0;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.4;
  display: flex;
  flex-direction: column;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
}
button, input { font: inherit; color: inherit; }
input { user-select: text; -webkit-user-select: text; }

/* ---------- top bar ---------- */
.top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
  flex: none;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.01em;
  flex: none;
  min-height: var(--tap);
}
.brand-ball {
  width: 20px; height: 20px; border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, #ffb06a 0 12%, transparent 13%),
    var(--ball);
  box-shadow: 0 0 12px rgba(255, 138, 31, 0.55);
}
.brand-name { display: none; }
@media (min-width: 600px) { .brand-name { display: inline; } }

.title {
  flex: 1;
  min-width: 0;
  height: var(--tap);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 12px;
  outline: none;
  font-weight: 500;
  font-size: 16px; /* ≥16px so iOS doesn't zoom the page on focus */
}
.title:focus { border-color: rgba(0, 229, 255, 0.5); }
.title::placeholder { color: var(--muted); }

/* ---------- buttons ---------- */
.btn {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 12px;
  min-height: var(--tap);
  padding: 0 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s, transform .08s, opacity .15s;
  touch-action: manipulation;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.35; cursor: default; }
.btn:disabled:active { transform: none; }
.btn-primary {
  background: linear-gradient(135deg, var(--violet), #3E7BFF 70%, var(--cyan));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 6px 18px rgba(123, 44, 255, 0.35);
}
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); background: var(--surface); }
.btn-ghost.is-on { color: var(--text); border-color: rgba(0, 229, 255, 0.45); background: rgba(0, 229, 255, 0.08); }
.btn-icon {
  width: 52px; height: 52px; padding: 0;
  display: grid; place-items: center;
  font-size: 20px;
  border-radius: 50%;
  background: var(--surface-2);
  flex: none;
}
.btn-more { width: var(--tap); padding: 0; font-size: 22px; letter-spacing: 1px; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; min-height: var(--tap); }
.seg-btn {
  border: 0; background: transparent; color: var(--muted);
  padding: 0 14px; font-weight: 600; cursor: pointer;
  touch-action: manipulation; white-space: nowrap;
}
.seg-btn.is-on { background: var(--surface-2); color: var(--text); }

/* ---------- stage: the court owns everything in the middle ---------- */
.stage {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 4px 8px;
}
.court-wrap { position: relative; width: 100%; height: 100%; display: grid; place-items: center; }
#court {
  display: block;
  border-radius: 14px;
  box-shadow: 0 0 0 1px var(--line), 0 20px 50px rgba(0, 0, 0, 0.45);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
}
#court.is-place { cursor: move; }
.hint {
  position: absolute;
  left: 50%; bottom: 12px;
  transform: translateX(-50%);
  background: rgba(11, 15, 26, 0.88);
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  white-space: nowrap;
  pointer-events: none;
  transition: opacity .3s;
  max-width: calc(100% - 24px);
  overflow: hidden; text-overflow: ellipsis;
}
.hint b { color: var(--cyan); font-weight: 600; }
.hint.is-hidden { opacity: 0; }

/* ---------- bottom bar ---------- */
.bar {
  flex: none;
  padding: 8px 12px calc(10px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: linear-gradient(180deg, transparent, rgba(11, 15, 26, 0.6) 30%);
}
.transport { display: flex; align-items: center; gap: 12px; }
.scrub {
  flex: 1;
  -webkit-appearance: none; appearance: none;
  height: var(--tap); background: transparent; margin: 0;
  touch-action: pan-x;
}
.scrub::-webkit-slider-runnable-track {
  height: 5px; border-radius: 3px;
  background: linear-gradient(90deg, var(--violet), var(--cyan)) no-repeat, var(--surface-2);
  background-size: var(--p, 0%) 100%;
}
.scrub::-moz-range-track { height: 5px; border-radius: 3px; background: var(--surface-2); }
.scrub::-moz-range-progress { height: 5px; border-radius: 3px; background: linear-gradient(90deg, var(--violet), var(--cyan)); }
.scrub::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 22px; height: 22px; border-radius: 50%;
  background: #fff; margin-top: -8.5px;
  box-shadow: 0 0 0 5px rgba(0, 229, 255, 0.2);
}
.scrub::-moz-range-thumb { width: 22px; height: 22px; border: 0; border-radius: 50%; background: #fff; }
.counter { font-variant-numeric: tabular-nums; color: var(--muted); min-width: 44px; text-align: right; font-size: 13px; }

.tools { display: flex; gap: 6px; align-items: center; }
.tools .btn, .tools .seg-btn { padding-left: 10px; padding-right: 10px; font-size: 14px; }
.tools .btn-more { padding: 0; }
.tools .seg, .tools .btn { flex: none; }
@media (max-width: 439px) {
  .tools { gap: 4px; }
  .tools .ico { display: none; }
  .tools .btn, .tools .seg-btn { padding-left: 8px; padding-right: 8px; font-size: 13px; }
  .tools .btn-more { width: 36px; }
}
@media (max-width: 359px) { .tools .btn, .tools .seg-btn { padding-left: 6px; padding-right: 6px; font-size: 12.5px; } }
.tips b { color: var(--text); font-weight: 600; }
.tools .spacer { flex: 1; }

/* ---------- dialogs: bottom sheets on phones, cards on desktop ---------- */
.dlg {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 20px;
  padding: 0;
  width: min(92vw, 460px);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}
.dlg::backdrop { background: rgba(4, 6, 12, 0.7); backdrop-filter: blur(4px); }
.dlg-body { padding: 20px; margin: 0; }
.dlg h2 { margin: 0 0 6px; font-family: var(--font-display); font-size: 22px; }
.muted { color: var(--muted); margin: 0 0 14px; }
.small { font-size: 12.5px; margin: 10px 0 0; }
.dlg-sm { width: min(92vw, 340px); }
.dlg-sm .title { width: 100%; font-size: 22px; text-align: center; font-family: var(--font-display); font-weight: 700; }
.dlg-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 16px; }
.dlg-actions .btn:last-child { margin-left: auto; }
@media (max-width: 599px) {
  .sheet {
    width: 100vw; max-width: none;
    margin: auto 0 0;
    border-radius: 22px 22px 0 0;
    border-bottom: 0;
  }
  .sheet .dlg-body { padding: 18px 18px calc(18px + env(safe-area-inset-bottom)); }
}

.sheet-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0; }
.sheet-label { color: var(--muted); font-weight: 500; }
.sheet-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.tips { margin-top: 16px; line-height: 1.5; }
.credit { color: var(--muted); text-decoration: none; font-size: 12.5px; }
.credit:hover { color: var(--cyan); }

.send-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 4px 0 12px; }
.btn-big {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 14px 10px; white-space: normal; text-align: center; line-height: 1.25;
}
.btn-big small { font-weight: 400; font-size: 12px; opacity: 0.8; }
.big-ico { font-size: 22px; margin-bottom: 4px; }

.link-row { display: flex; gap: 8px; }
.link-row input {
  flex: 1; min-width: 0; height: var(--tap);
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px;
  padding: 0 12px; font-size: 13px; color: var(--muted);
}

.plays-list { list-style: none; margin: 0; padding: 0; max-height: 50vh; overflow: auto; }
.plays-list li { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); }
.plays-list .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.plays-list .when { color: var(--muted); font-size: 12px; }
.plays-list .empty { color: var(--muted); border: 0; }

/* ---------- export overlay ---------- */
.recording {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  background: rgba(4, 6, 12, 0.75);
  backdrop-filter: blur(4px);
}
.recording[hidden] { display: none; }
.recording-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 16px; padding: 18px 20px; width: min(90vw, 360px);
}
.rec-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--coral); animation: blink 1s infinite; flex: none; }
.rec-body { flex: 1; min-width: 0; }
.rec-track { height: 6px; border-radius: 3px; background: var(--surface-2); margin-top: 10px; overflow: hidden; }
.rec-fill { height: 100%; width: 0; border-radius: 3px; background: linear-gradient(90deg, var(--violet), var(--cyan)); transition: width .1s linear; }
@keyframes blink { 50% { opacity: 0.25; } }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(120px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px);
  background: var(--surface-2); border: 1px solid var(--line);
  padding: 10px 16px; border-radius: 999px;
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
  font-size: 14px; z-index: 60;
  max-width: calc(100vw - 32px); text-align: center;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* Off-screen canvas used for video export (kept in the DOM for captureStream). */
.export-canvas { position: fixed; left: -100vw; top: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

@media (prefers-reduced-motion: reduce) {
  .btn, .toast, .hint { transition: none; }
}
