:root {
  --bg: #0e0f13;
  --bar: #16181e;
  --line: #262a33;
  --text: #eceef2;
  --muted: #8b91a0;
  --accent: #7cc4ff;
  --keep: #5ed39a;
  --drop: #ff7a7a;
  --like: #ff5c7a;
  color-scheme: dark;
}

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

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.3 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", system-ui, sans-serif;
}

body {
  position: fixed;
  inset: 0;
  -webkit-user-select: none;
  user-select: none;
  -webkit-text-size-adjust: 100%;
}

#app {
  position: fixed;
  inset: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

#stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  background: #000;
}

/* Width, height and a scale are set by feed.js (frameFit): a short frame is
   laid out taller and scaled down so games' bottom buttons stay on screen. */
#stage iframe {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  transform-origin: 0 0;
  border: 0;
  display: block;
  background: transparent;
  touch-action: auto;
}

#loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--muted);
  font-size: 17px;
  pointer-events: none;
}

#loading .dots::after {
  content: "…";
  animation: blink 1.2s steps(2, start) infinite;
}

@keyframes blink {
  to {
    visibility: hidden;
  }
}

#notice {
  position: absolute;
  left: 16px;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  padding: 16px 18px;
  border-radius: 14px;
  background: rgba(22, 24, 30, 0.96);
  border: 1px solid var(--line);
  text-align: center;
  font-size: 16px;
}

/* The bar takes only what it needs; the frame gets the rest (#app is 100dvh,
   and the home indicator's inset is padding here, never frame space). */
#bar {
  flex: 0 0 auto;
  padding: 4px 10px calc(6px + env(safe-area-inset-bottom));
  background: var(--bar);
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#credit {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  min-height: 30px;
  white-space: nowrap;
}

#title {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 0 1 auto;
  min-width: 0;
}

.sep {
  color: var(--muted);
}

#maker {
  color: var(--accent);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 0 1 auto;
  min-width: 0;
}

#me {
  flex: 0 0 auto;
  margin-left: auto;
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
}

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#me svg {
  width: 18px;
  height: 18px;
}

#buttons,
#pickbar {
  display: flex;
  gap: 8px;
}

#pickbar {
  align-items: center;
}

#shield {
  position: absolute;
  inset: 0;
  z-index: 3;
}

#pickbar[hidden],
#picknotes[hidden],
#shield[hidden],
#notice[hidden],
#toast[hidden],
#panel[hidden],
#remix-sheet[hidden],
#panel-share[hidden] {
  display: none;
}

#pickinfo {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Pick mode: the automatic check's warnings, visible on the phone (a title
   tooltip never shows on touch). Capped at three lines so the game keeps
   most of the screen. */
#picknotes {
  font-size: 12px;
  line-height: 1.35;
  color: #f0c36b;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  cursor: pointer;
}

/* Tapped: show every warning, scrolling if long. */
#picknotes.open {
  display: block;
  -webkit-line-clamp: unset;
  max-height: 40dvh;
  overflow-y: auto;
  touch-action: pan-y;
}

#reason {
  flex: 0 1 120px;
  min-width: 70px;
  height: 36px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #0c0d11;
  color: var(--text);
  font-size: 16px; /* 16px stops iOS zooming on focus */
  touch-action: manipulation;
  -webkit-user-select: text;
  user-select: text;
}

button,
.tool {
  flex: 1 1 0;
  height: 44px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #1f232b;
  color: var(--text);
  font: inherit;
  font-size: 15px;
  white-space: nowrap;
  touch-action: none; /* a swipe that starts on a button must still reach the bar handler */
  cursor: pointer;
}

button:active,
.tool:active {
  background: #2a2f39;
}

/* The bar's tools: an icon over a small caption. */
.tool {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  height: 46px;
  padding: 0 2px;
  text-decoration: none;
  font-size: 11px;
  line-height: 1.1;
  color: var(--text);
  overflow: hidden;
}

.tool span {
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.tool .emoji {
  font-size: 17px;
  line-height: 20px;
}

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

#next {
  flex-grow: 1.4;
  background: #24344a;
  border-color: #33506f;
}

#like[aria-pressed="true"],
.row-like[aria-pressed="true"] {
  color: var(--like);
}

#like[aria-pressed="true"] .heart,
.row-like[aria-pressed="true"] .heart {
  fill: currentColor;
}

#toast {
  position: absolute;
  left: 50%;
  top: 12px;
  transform: translateX(-50%);
  z-index: 4;
  max-width: calc(100% - 24px);
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(22, 24, 30, 0.96);
  border: 1px solid var(--line);
  font-size: 14px;
  display: flex;
  gap: 8px;
  align-items: center;
}

#toast input {
  min-width: 0;
  width: 60vw;
  height: 32px;
  padding: 0 8px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #0c0d11;
  color: var(--text);
  font-size: 16px;
  touch-action: manipulation;
  -webkit-user-select: text;
  user-select: text;
}

#toast button {
  flex: 0 0 auto;
  height: 32px;
  padding: 0 12px;
}

/* The remix prompt: a sheet from the bottom over the dimmed game and bar.
   Play time stops while it's up. */
#remix-sheet {
  position: absolute;
  inset: 0;
  z-index: 9;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
}

#remix-card {
  width: 100%;
  max-width: 540px;
  max-height: calc(100% - 16px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 14px calc(12px + env(safe-area-inset-bottom));
  background: var(--bar);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 16px 16px 0 0;
}

#remix-title {
  margin: 0;
  font-size: 18px;
}

#remix-help,
#remix-status {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
}

#remix-status:empty {
  display: none;
}

#remix-status.ok {
  color: var(--keep);
}

#remix-text {
  flex: 1 1 auto;
  min-height: 120px;
  height: 260px;
  width: 100%;
  resize: none;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #0c0d11;
  color: var(--text);
  font: inherit;
  font-size: 16px; /* 16px stops iOS zooming if the fallback focuses it */
  line-height: 1.4;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
  -webkit-user-select: text;
  user-select: text;
}

#remix-actions {
  display: flex;
  gap: 8px;
}

#remix-copy {
  flex-grow: 1.6;
  background: #24344a;
  border-color: #33506f;
  font-weight: 600;
}

/* Creator and profile pages: a sheet over the feed. The game underneath stays
   loaded (its play time stops counting while the sheet is up). */
#panel {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  padding-top: env(safe-area-inset-top);
}

#panel-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}

#panel-head button {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  padding: 0;
  display: grid;
  place-items: center;
}

#panel-title {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  font-size: 18px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#panel-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 12px 14px calc(16px + env(safe-area-inset-bottom));
}

#panel-body,
#panel-body * {
  touch-action: pan-y;
}

#panel-body h2 {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 18px 0 8px;
}

#panel-body p {
  margin: 0 0 8px;
  color: var(--muted);
}

.stats {
  display: flex;
  gap: 8px;
}

.stat {
  flex: 1 1 0;
  padding: 10px;
  border-radius: 12px;
  background: var(--bar);
  border: 1px solid var(--line);
}

.stat b {
  display: block;
  font-size: 20px;
}

.stat span {
  font-size: 12px;
  color: var(--muted);
}

.outlink {
  display: inline-block;
  margin: 4px 0 4px;
  color: var(--accent);
  text-decoration: none;
}

.row {
  display: flex;
  gap: 8px;
  align-items: stretch;
  margin-bottom: 8px;
}

.row-play {
  flex: 1 1 auto;
  height: auto;
  min-height: 52px;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  text-align: left;
  white-space: normal;
}

.row-title {
  font-weight: 600;
}

.row-sub {
  font-size: 13px;
  color: var(--muted);
}

.row-like,
.row-act {
  flex: 0 0 52px;
  height: auto;
  display: grid;
  place-items: center;
}

.row-act {
  flex-basis: auto;
  padding: 0 12px;
  font-size: 13px;
}

#pickbar button {
  flex: 0 0 auto;
  height: 36px;
  padding: 0 14px;
}

#keep {
  color: var(--keep);
}

#drop {
  color: var(--drop);
}

#keep.on {
  background: #1d3a2c;
  border-color: var(--keep);
}

#drop.on {
  background: #3d1f22;
  border-color: var(--drop);
}

@media (max-width: 360px) {
  button {
    font-size: 13px;
  }
  .tool {
    font-size: 10px;
  }
  /* Seven tools on a 320px screen: less gap, so every caption fits. */
  #buttons {
    gap: 5px;
  }
  .tool {
    padding: 0;
  }
  #next {
    flex-grow: 1.2;
  }
}
