:root {
  color-scheme: light;
  --paper: #f2efe6;
  --ink: #1e1b17;
  --muted: #70685c;
  --line: rgba(30, 27, 23, 0.16);
  --accent: #cb4f32;
  --good: #2e7456;
  --shadow: 0 26px 70px rgba(45, 35, 22, 0.18);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 12% 8%, rgba(203, 79, 50, 0.15), transparent 28rem),
    linear-gradient(135deg, rgba(30, 27, 23, 0.06) 25%, transparent 25%) 0 0 / 18px 18px,
    var(--paper);
  color: var(--ink);
  font-family: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", Georgia, serif;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  width: min(100%, 460px);
  min-height: 100svh;
  margin: 0 auto;
  padding: calc(18px + var(--safe-top)) 18px calc(22px + var(--safe-bottom));
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 18px;
}

.topbar {
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font: 700 11px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 17px;
  line-height: 1.45;
  font-weight: 700;
}

.stage {
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 14px;
}

.deck-meta,
.gesture-labels {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font: 700 12px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
}

.card-slot {
  position: relative;
  min-height: 470px;
  display: grid;
  place-items: center;
}

.loading-card,
.insight-card {
  width: 100%;
  min-height: min(62svh, 560px);
  border-radius: 8px;
  border: 1px solid rgba(30, 27, 23, 0.18);
  box-shadow: var(--shadow);
}

.loading-card {
  display: grid;
  place-content: center;
  gap: 16px;
  background: rgba(255, 252, 244, 0.64);
  color: var(--muted);
  text-align: center;
}

.loading-card span {
  width: 38px;
  height: 38px;
  margin: 0 auto;
  border: 2px solid rgba(30, 27, 23, 0.16);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.loading-card p {
  margin: 0;
}

.insight-card {
  --card-a: #f4d6af;
  --card-b: #d36b42;
  position: absolute;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  padding: 22px;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 18px;
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0.04)),
    radial-gradient(circle at 20% 10%, rgba(255, 255, 255, 0.76), transparent 22rem),
    linear-gradient(140deg, var(--card-a), var(--card-b));
  color: var(--ink);
  touch-action: none;
  user-select: none;
  will-change: transform;
  transition: transform 180ms ease, opacity 180ms ease;
}

.insight-card.has-image {
  background:
    linear-gradient(160deg, rgba(255, 252, 244, 0.82), rgba(255, 252, 244, 0.32)),
    linear-gradient(0deg, rgba(30, 27, 23, 0.14), rgba(30, 27, 23, 0.14)),
    var(--card-image) center / cover,
    linear-gradient(140deg, var(--card-a), var(--card-b));
}

.insight-card.dragging {
  transition: none;
}

.card-topline {
  display: flex;
  justify-content: space-between;
  min-height: 22px;
  gap: 12px;
  font: 800 12px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
}

.card-topline span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.insight-card h2 {
  margin: 0;
  font-size: clamp(31px, 10vw, 48px);
  line-height: 1;
  letter-spacing: 0;
}

.question {
  align-self: center;
  margin: 0;
  font-size: clamp(22px, 6vw, 30px);
  line-height: 1.35;
  font-weight: 700;
}

.insight-card footer {
  padding-top: 16px;
  border-top: 1px solid rgba(30, 27, 23, 0.18);
}

.insight-card footer span {
  display: block;
  margin-bottom: 7px;
  color: rgba(30, 27, 23, 0.62);
  font: 800 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
}

.insight-card footer p {
  margin: 0;
  font-size: 16px;
  line-height: 1.45;
}

.discard-button {
  position: absolute;
  right: 16px;
  bottom: 16px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  border: 1px solid rgba(30, 27, 23, 0.2);
  border-radius: 999px;
  padding: 10px 14px;
  background: rgba(255, 250, 240, 0.82);
  color: var(--ink);
  font-weight: 700;
  transition: opacity 160ms ease, transform 160ms ease;
}

.insight-card.show-discard .discard-button {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.swipe-stamp {
  position: absolute;
  top: 22px;
  border: 2px solid currentColor;
  border-radius: 6px;
  padding: 8px 10px;
  font: 900 14px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  opacity: 0;
  transform: rotate(-10deg);
}

.stamp-left {
  left: 18px;
  color: var(--accent);
}

.stamp-right {
  right: 18px;
  color: var(--good);
  transform: rotate(10deg);
}

.done-screen,
.login-screen {
  align-self: center;
  animation: rise 260ms ease both;
}

.done-screen h2,
.login-screen h2 {
  margin: 0 0 18px;
  font-size: 52px;
  line-height: 1;
}

.login-form {
  display: grid;
  gap: 12px;
}

.login-form input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 15px 14px;
  background: rgba(255, 252, 244, 0.72);
  color: var(--ink);
  font: 700 16px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
  outline: none;
}

.login-form input:focus {
  border-color: rgba(203, 79, 50, 0.7);
  box-shadow: 0 0 0 3px rgba(203, 79, 50, 0.12);
}

.hand-list {
  display: grid;
  gap: 10px;
}

.hand-card {
  display: block;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 252, 244, 0.66);
  color: inherit;
  text-decoration: none;
}

.hand-card strong {
  display: block;
  margin-bottom: 8px;
  font-size: 18px;
}

.hand-card span {
  color: var(--muted);
  line-height: 1.45;
}

.secondary-button {
  width: 100%;
  margin-top: 16px;
  border: 1px solid var(--ink);
  border-radius: 8px;
  padding: 14px 16px;
  background: var(--ink);
  color: var(--paper);
  font: 800 15px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
}

.toast {
  position: fixed;
  left: 18px;
  right: 18px;
  bottom: calc(16px + var(--safe-bottom));
  z-index: 10;
  max-width: 424px;
  margin: 0 auto;
  padding: 13px 14px;
  border-radius: 8px;
  background: rgba(30, 27, 23, 0.94);
  color: var(--paper);
  font-weight: 700;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.hidden {
  display: none;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
}
