/* Sparkwire — synthwave arcade hub. Shares Neon Drift's palette so the whole
   thing reads as one family. */

:root {
  --pink: #ff2e97;
  --cyan: #22e9ff;
  --violet: #a855ff;
  --ink: #07041a;
  --ink-2: #0b0620;
  --panel: #140a2e;
  --panel-2: #1b1040;
  --line: #2a1c56;
  --text: #eae6ff;
  --muted: #9a8fc7;
  --good: #35e08a;
  --warn: #ffcf3f;

  --ui-font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Roboto Mono", monospace;
  --radius: 14px;
  --maxw: 940px;
}

* { box-sizing: border-box; }

/* Touch defaults: kill the iOS tap-flash and the 300ms double-tap delay on
   everything interactive. Brothers are on iPads/iPhones almost exclusively. */
* { -webkit-tap-highlight-color: transparent; }
a, button, input, select, textarea, label, .game-tile, .seg a {
  touch-action: manipulation;
}

html {
  /* Explicit 16px base — anything smaller makes iOS Safari zoom on input focus. */
  font-size: 16px;
  overflow-x: hidden;
}

html, body {
  margin: 0;
  padding: 0;
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(168, 85, 255, 0.22), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(34, 233, 255, 0.12), transparent 55%),
    var(--ink);
  color: var(--text);
  font-family: var(--ui-font);
  min-height: 100%;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2 { line-height: 1.15; }
h2 { font-size: 1.15rem; letter-spacing: 0.02em; text-transform: uppercase; color: var(--muted); }

.muted { color: var(--muted); }
.empty { padding: 1rem 0; }
.warn { color: var(--warn); }

/* -------------------------------------------------------------- top bar --- */
.topbar {
  display: flex; align-items: center; gap: 1rem;
  padding: 0.7rem clamp(0.8rem, 3vw, 1.4rem);
  padding-top: calc(0.7rem + env(safe-area-inset-top, 0px));
  border-bottom: 1px solid var(--line);
  background: rgba(11, 6, 32, 0.82);
  backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 0.45rem; color: var(--text); font-weight: 700; }
.brand:hover { text-decoration: none; }
.brand-mark { color: var(--pink); font-size: 1.15rem; text-shadow: 0 0 12px var(--pink); }
.brand-name { letter-spacing: 0.04em; }
.topnav { display: flex; gap: 0.9rem; margin-left: 0.5rem; font-size: 0.9rem; }
.topnav a { color: var(--muted); }
.topnav a:hover { color: var(--cyan); text-decoration: none; }
.admin-link { color: var(--violet) !important; }
.topnav a {
  display: inline-flex; align-items: center;
  min-height: 44px; padding: 0 0.35rem;
}
.whoami { margin-left: auto; display: flex; align-items: center; gap: 0.5rem; font-size: 0.9rem; }
.who-name { color: var(--cyan); font-family: var(--mono); }
.who-change {
  background: none; border: 0; color: var(--muted); text-decoration: underline;
  cursor: pointer; font-size: 0.85rem;
  min-height: 44px; padding: 0 0.3rem;
}

/* ---------------------------------------------------------------- layout -- */
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 1.4rem clamp(0.8rem, 3vw, 1.4rem) 4rem; }
section { margin-top: 2.2rem; }
.hero { margin-top: 1.4rem; }
.hero h1 { font-size: clamp(1.5rem, 4vw, 2.1rem); margin: 0 0 0.4rem; }
.hero h1 { background: linear-gradient(90deg, var(--cyan), var(--pink)); -webkit-background-clip: text; background-clip: text; color: transparent; }

.card {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
}

/* --------------------------------------------------------------- buttons -- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  background: linear-gradient(90deg, var(--pink), var(--violet));
  color: #fff; border: 0; border-radius: 999px;
  padding: 0.55rem 1.1rem; font-weight: 600; font-size: 0.95rem;
  min-height: 44px; line-height: 1.1;
  cursor: pointer; text-decoration: none;
  box-shadow: 0 0 18px rgba(255, 46, 151, 0.35);
  -webkit-user-select: none; user-select: none;
}
.btn:hover { text-decoration: none; filter: brightness(1.08); }
.btn:active { transform: scale(0.97); filter: brightness(0.92); }
.btn-sm { padding: 0.35rem 0.9rem; font-size: 0.9rem; min-height: 40px; }
.btn-ghost { background: transparent; border: 1px solid var(--line); color: var(--text); box-shadow: none; }
.btn-danger { background: transparent; border: 1px solid var(--pink); color: var(--pink); box-shadow: none; }

/* ---------------------------------------------------------------- arcade -- */
.game-grid {
  display: grid; gap: 0.9rem; margin-top: 0.9rem;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}
.game-tile {
  display: flex; flex-direction: column; overflow: hidden;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel); color: var(--text);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.game-tile:hover {
  text-decoration: none; transform: translateY(-3px);
  box-shadow: 0 0 0 1px var(--accent), 0 10px 30px rgba(0, 0, 0, 0.4);
}
.game-tile:active {
  transform: translateY(-1px) scale(0.99);
  box-shadow: 0 0 0 1px var(--accent), 0 6px 18px rgba(0, 0, 0, 0.4);
}
.game-art {
  aspect-ratio: 16 / 10;
  display: grid; place-items: center;
  background:
    radial-gradient(120px 120px at 30% 30%, color-mix(in srgb, var(--accent) 45%, transparent), transparent),
    linear-gradient(135deg, var(--ink-2), var(--panel-2));
}
.game-art span {
  font-family: var(--mono); font-size: 2.6rem; font-weight: 700;
  color: var(--accent); text-shadow: 0 0 22px var(--accent);
}
.game-info { padding: 0.7rem 0.85rem; display: flex; flex-direction: column; gap: 0.15rem; }
.game-title { font-weight: 700; }
.game-tag { font-size: 0.82rem; color: var(--muted); }

/* ---------------------------------------------------------------- sparks -- */
.sparks-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.filters { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 0.9rem 0; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.seg a {
  display: inline-flex; align-items: center;
  padding: 0.45rem 1rem; min-height: 44px;
  color: var(--muted); font-size: 0.9rem;
}
.seg a:hover { text-decoration: none; color: var(--text); }
.seg a:active { background: var(--panel); }
.seg a.on { background: var(--panel-2); color: var(--cyan); }
.seg.small a { padding: 0.4rem 0.85rem; font-size: 0.85rem; }

.new-spark { display: flex; flex-direction: column; gap: 0.6rem; margin: 1rem 0 1.4rem; }
.new-spark .row { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.new-spark .row.end { justify-content: flex-end; }
input, textarea, select {
  width: 100%; background: var(--ink-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 0.7rem 0.75rem; font-family: inherit;
  font-size: 16px;              /* < 16px makes iOS Safari zoom on focus */
  min-height: 44px;
  accent-color: var(--cyan);
}
textarea { min-height: 88px; }
.new-spark .row select { width: auto; flex: 1 1 40%; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--violet); outline-offset: 1px; }
textarea { resize: vertical; }

.spark-list { display: flex; flex-direction: column; gap: 0.55rem; }
.spark {
  display: flex; gap: 0.8rem; padding: 0.75rem 0.85rem;
  border: 1px solid var(--line); border-radius: 12px; background: var(--panel);
}
.spark.status-shipped { border-color: color-mix(in srgb, var(--good) 45%, var(--line)); }
.spark.status-building { border-color: color-mix(in srgb, var(--cyan) 45%, var(--line)); }

.vote { flex: 0 0 auto; }
.vote-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 3.1rem; min-height: 52px; padding: 0.4rem 0.5rem; gap: 0.1rem;
  background: var(--ink-2); border: 1px solid var(--line); border-radius: 10px;
  color: var(--muted); cursor: pointer; font-family: inherit;
  -webkit-user-select: none; user-select: none;
}
.vote-btn:active { transform: scale(0.94); }
.vote-btn .arrow { font-size: 0.95rem; line-height: 1; }
.vote-btn .count { font-weight: 700; font-size: 0.95rem; color: var(--text); font-family: var(--mono); }
.vote-btn.on { color: var(--pink); border-color: var(--pink); box-shadow: 0 0 12px rgba(255, 46, 151, 0.4); }
.vote-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.spark-body { min-width: 0; flex: 1; }
.spark-title {
  display: inline-block; font-weight: 650; color: var(--text);
  padding: 0.2rem 0; font-size: 1.02rem;
}
.spark-title:hover { color: var(--cyan); }
.spark-title:active { color: var(--cyan); }
.spark-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; margin-top: 0.35rem; font-size: 0.78rem; }
.by { color: var(--muted); }
.chip {
  padding: 0.1rem 0.5rem; border-radius: 999px; font-size: 0.72rem;
  border: 1px solid var(--line); color: var(--muted);
}
.chip.kind-idea { color: var(--violet); border-color: var(--violet); }
.chip.kind-bug { color: var(--pink); border-color: var(--pink); }
.chip.kind-improvement { color: var(--cyan); border-color: var(--cyan); }
.chip.game { color: var(--text); }
.chip.state-building { color: var(--cyan); border-color: var(--cyan); }
.chip.state-shipped { color: var(--good); border-color: var(--good); }
.chip.state-declined { color: var(--muted); }
.status-note { margin: 0.4rem 0 0; font-size: 0.82rem; color: var(--muted); font-style: italic; }
.status-note.big { font-size: 0.95rem; margin-top: 0.8rem; }

/* --------------------------------------------------------------- feed ----- */
.feed-list { list-style: none; padding: 0; margin: 0.8rem 0 0; display: flex; flex-direction: column; gap: 0.5rem; }
.feed-list li { display: flex; align-items: center; gap: 0.5rem; }
.feed-dot { color: var(--good); }

/* --------------------------------------------------------------- detail --- */
.back { display: inline-flex; align-items: center; min-height: 44px; margin: 0.25rem 0 0.75rem; color: var(--muted); }
.feed-list li { min-height: 40px; }
.feed-list a { padding: 0.25rem 0; }
.spark-full-head { display: flex; gap: 1rem; }
.spark-full-head h1 { margin: 0 0 0.3rem; font-size: 1.3rem; }
.spark-text { white-space: normal; line-height: 1.55; }
.admin-status { margin-top: 1rem; padding-top: 1rem; border-top: 1px dashed var(--line); display: flex; flex-direction: column; gap: 0.6rem; }
.radio { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.5rem 0.9rem; min-height: 44px; border: 1px solid var(--line); border-radius: 999px; font-size: 0.9rem; cursor: pointer; }
.radio.on { border-color: var(--cyan); color: var(--cyan); }
.radio input { width: auto; }

.comments { margin-top: 2rem; }
.comment { padding: 0.7rem 0; border-bottom: 1px solid var(--line); }
.comment.admin { background: rgba(168, 85, 255, 0.08); border-radius: 8px; padding: 0.7rem; }
.c-author { font-weight: 650; }
.c-badge { font-size: 0.68rem; color: var(--violet); border: 1px solid var(--violet); border-radius: 999px; padding: 0 0.4rem; }
.c-when { margin-left: 0.5rem; font-size: 0.78rem; }
.comment p { margin: 0.35rem 0 0; }
.comment-form { margin-top: 1rem; display: flex; flex-direction: column; gap: 0.6rem; }

/* --------------------------------------------------------------- play ----- */
.play-stage { --accent: var(--cyan); }
.play-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.6rem; }
.play-name { font-weight: 700; color: var(--accent); }
.play-bar .spacer { margin-left: auto; }
.frame-wrap {
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  box-shadow: 0 0 0 1px var(--accent), 0 0 40px color-mix(in srgb, var(--accent) 30%, transparent);
  background: #000;
}
.game-frame { width: 100%; aspect-ratio: 16 / 10; border: 0; display: block; }
.play-hint { margin-top: 0.6rem; font-size: 0.82rem; }

/* --------------------------------------------------------------- admin ---- */
.admin-table { width: 100%; border-collapse: collapse; margin-top: 1rem; font-size: 0.88rem; }
.admin-table th, .admin-table td { text-align: left; padding: 0.5rem 0.4rem; border-bottom: 1px solid var(--line); }
.inline-status select { width: auto; }

/* --------------------------------------------------------------- modal ---- */
.modal {
  position: fixed; inset: 0; background: rgba(4, 2, 14, 0.7);
  display: grid; place-items: start center; z-index: 50;
  padding: max(1rem, env(safe-area-inset-top)) 1rem 1rem;
  padding-top: 12vh; overflow-y: auto;
}
.modal[hidden] { display: none; }
.modal-card { max-width: 380px; width: 100%; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem; display: flex; flex-direction: column; gap: 0.7rem; }
.modal-card h2 { color: var(--text); text-transform: none; font-size: 1.1rem; margin: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.6rem; }

/* --------------------------------------------------------------- foot ----- */
.foot {
  max-width: var(--maxw); margin: 0 auto; color: var(--muted); font-size: 0.82rem;
  padding: 2rem 1.4rem calc(3rem + env(safe-area-inset-bottom, 0px));
}

.toast {
  position: fixed; left: 50%; bottom: calc(1.2rem + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%) translateY(2rem);
  background: var(--panel-2); border: 1px solid var(--cyan); color: var(--text);
  padding: 0.6rem 1rem; border-radius: 999px; opacity: 0; transition: all 0.25s ease; z-index: 60;
  box-shadow: 0 0 20px rgba(34, 233, 255, 0.4);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Bigger, roomier hit areas on actual touch devices (no fine pointer). */
@media (hover: none) and (pointer: coarse) {
  .new-spark .row select { flex-basis: 100%; }
  .spark { gap: 0.6rem; padding: 0.85rem 0.8rem; }
  .comment-form textarea, .new-spark textarea { min-height: 96px; }
}

@media (max-width: 560px) {
  .topbar { flex-wrap: wrap; gap: 0.5rem 0.9rem; padding-bottom: 0.5rem; }
  .brand { flex: 1 1 auto; }
  .whoami { margin-left: 0; }
  .topnav {
    order: 3; flex-basis: 100%; margin-left: 0;
    justify-content: space-around; gap: 0;
    border-top: 1px solid var(--line); padding-top: 0.2rem;
  }
  .topnav a { flex: 1; justify-content: center; }
  .hero h1 { font-size: clamp(1.4rem, 6vw, 1.8rem); }
  .sparks-head { flex-wrap: wrap; gap: 0.6rem; }
  .sparks-head .btn { width: 100%; }
  .filters { gap: 0.5rem; }
  .game-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  /* Portrait phone: give the game as much height as we can rather than a
     letterboxed strip. Real fullscreen is the "Fullscreen" button. */
  .game-frame { aspect-ratio: auto; height: min(70vh, 560px); }
}
