:root {
  --bg: #ecebe6;
  --ink: #1a1a1a;
  --muted: #77756f;
  --face: #ffffff;
  --face-ink: #111111;
  --face-muted: #6b6b6b;
  --back: #111111;
  --back-ink: #f2f2f2;
  --edge: transparent;
  --shadow: 0 1px 2px rgb(0 0 0 / .08), 0 12px 32px rgb(0 0 0 / .12);
  --dur: .45s;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161616;
    --ink: #e8e6e1;
    --muted: #8c8a85;
    --face: #f4f3ef;
    --back: #000000;
    --edge: #333333;
    --shadow: 0 12px 32px rgb(0 0 0 / .5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #161616;
  --ink: #e8e6e1;
  --muted: #8c8a85;
  --face: #f4f3ef;
  --back: #000000;
  --edge: #333333;
  --shadow: 0 12px 32px rgb(0 0 0 / .5);
  color-scheme: dark;
}
@media (prefers-reduced-motion: reduce) {
  :root { --dur: 0s; }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Helvetica Neue", Helvetica, Arial, "PingFang TC", "Noto Sans TC", sans-serif;
  -webkit-tap-highlight-color: transparent;
}
main {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding:
    max(20px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
}
header { text-align: center; }
h1 {
  margin: 0;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: .18em;
  text-transform: uppercase;
}
header p { margin: 4px 0 0; font-size: 12px; color: var(--muted); letter-spacing: .3em; }

.stage { perspective: 1400px; }
.card {
  display: block;
  width: min(78vw, 340px, calc((100dvh - 240px) * 0.733));
  min-width: 200px;
  aspect-ratio: 2.75 / 3.75;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}
.card:focus-visible { outline: 2px solid var(--muted); outline-offset: 6px; border-radius: 10px; }
.inner {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform var(--dur) cubic-bezier(.3, .7, .2, 1);
}
.card.flipped .inner { transform: rotateY(180deg); }
.back, .face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  border-radius: 8px;
  box-shadow: var(--shadow);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}
.back {
  justify-content: space-between;
  align-items: center;
  padding: 18% 10% 12%;
  background: var(--back);
  color: var(--back-ink);
  border: 1px solid var(--edge);
  text-align: center;
}
.back-title { font-size: 13px; letter-spacing: .3em; line-height: 1.9; font-weight: 500; }
.back-hint { font-size: 12px; line-height: 1.7; opacity: .55; letter-spacing: .08em; }
.face {
  justify-content: center;
  gap: 1.1em;
  padding: 12%;
  background: var(--face);
  color: var(--face-ink);
  transform: rotateY(180deg);
  text-align: center;
}
.en { font-size: clamp(19px, 5.6vw, 25px); line-height: 1.32; font-weight: 500; white-space: pre-line; text-wrap: balance; }
.zh { font-size: clamp(14px, 3.8vw, 16px); line-height: 1.7; color: var(--face-muted); white-space: pre-line; text-wrap: balance; }
.face.s .en { font-size: clamp(17px, 4.8vw, 21px); }
.face.xs .en { font-size: clamp(15px, 4.1vw, 18px); }
.face.xs .zh { font-size: clamp(13px, 3.4vw, 14px); }
.face.blank .zh { font-size: 12px; opacity: .45; }

.meta {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 32px;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.meta button, .hint button {
  font: inherit;
  color: var(--ink);
  background: none;
  border: 1px solid color-mix(in srgb, var(--ink) 25%, transparent);
  border-radius: 999px;
  padding: 6px 14px;
  cursor: pointer;
}
footer { text-align: center; font-size: 11px; line-height: 1.7; color: var(--muted); }
footer p { margin: 0; }
footer a { color: inherit; }

.hint {
  position: fixed;
  left: max(12px, env(safe-area-inset-left));
  right: max(12px, env(safe-area-inset-right));
  bottom: max(12px, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 12px 12px 16px;
  background: var(--bg);
  color: var(--ink);
  border: 1px solid color-mix(in srgb, var(--ink) 15%, transparent);
  border-radius: 12px;
  box-shadow: var(--shadow);
  font-size: 12px;
  line-height: 1.6;
}
.hint[hidden], .meta [hidden] { display: none; }
.hint p { margin: 0; flex: 1; }
.hint button { border: 0; font-size: 20px; line-height: 1; padding: 4px 8px; }
