:root {
  --bg: #2e3035;
  --card-bg: #1d1e22;
  --paper: #f5eedc;
  --ink: #1b1b1b;
  --red: #c8102e;
  --gold: #ffd23f;
  --muted: #b4b6bc;
  --gap: 10px;
  --head: 56px;
  font-family: "Be Vietnam Pro", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--paper); }
button { font: inherit; cursor: pointer; }

.stage { position: fixed; inset: 0; perspective: 1600px; }
.card {
  position: absolute; inset: 0;
  transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(.2,.7,.2,1);
}
.card.flipped { transform: rotateY(180deg); }
.face {
  position: absolute; inset: 0;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  background: var(--bg);
}
.back { transform: rotateY(180deg); display: flex; flex-direction: column; }

/* front: 2 columns, 5 rows per screen, scroll for the rest */
.front { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 0 var(--gap) var(--gap); }
.top {
  height: var(--head); display: flex; align-items: baseline; justify-content: space-between;
  padding: 16px 4px 0; position: sticky; top: 0; background: var(--bg); z-index: 1;
}
.top h1 { margin: 0; font-size: 18px; font-weight: 800; letter-spacing: .01em; }
.top .sub { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap);
  grid-auto-rows: calc((100dvh - var(--head) - 11 * var(--gap)) / 10);
  max-width: 720px; margin: 0 auto;
}
.tile {
  position: relative; border-radius: 14px; padding: 12px;
  background: var(--card-bg); color: var(--paper); text-align: left;
  border: 2px solid var(--gold);
  display: flex; flex-direction: column; justify-content: center; gap: 2px; padding: 6px 28px 6px 12px;
  box-shadow: 0 2px 0 rgba(0,0,0,.25);
  transition: transform .12s;
}
.tile:active { transform: scale(.97); }
.tile .num { position: absolute; top: 8px; right: 10px; font-size: 12px; font-weight: 800; color: var(--gold); }
.tile .t-en { font-size: clamp(13px, 3.4vw, 18px); font-weight: 800; line-height: 1.1; }
.tile .t-vi { font-size: clamp(11px, 3vw, 15px); color: var(--muted); line-height: 1.15;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* back */
.back-btn {
  align-self: flex-start; margin: 14px; padding: 10px 16px; border-radius: 999px;
  border: 1px solid rgba(245,238,220,.35); background: transparent; color: var(--paper);
  font-weight: 600;
}
.detail {
  flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center;
  text-align: center; padding: 0 14px 12vh; gap: 18px; max-width: 720px; margin: 0 auto; width: 100%;
}
.en { margin: 0; font-size: clamp(18px, 5vw, 26px); font-weight: 600; color: var(--muted); }
.vi { margin: 0; font-size: clamp(34px, 10vw, 64px); font-weight: 800; line-height: 1.15; }
.ph { margin: 0; font-size: clamp(20px, 6vw, 32px); font-style: italic; font-weight: 500; color: var(--muted); }
.vi.long { font-size: clamp(26px, 7.5vw, 46px); }
.ph.long { font-size: clamp(17px, 5vw, 26px); }
.note { margin: 0; font-size: 14px; color: var(--muted); line-height: 1.6; max-width: 34em; }
.note:empty { display: none; }
.syl { transition: color .08s, text-shadow .08s; }
.syl.on { color: var(--gold); text-shadow: 0 0 18px rgba(255,210,63,.45); }
.controls { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-top: 8px; width: 100%; max-width: 520px; }
.controls button {
  padding: 12px 0; border-radius: 10px; font-size: clamp(10px, 2.8vw, 13px); letter-spacing: .01em; border: 2px solid var(--gold); font-weight: 800;
  background: var(--card-bg); color: var(--paper);
}
.controls button.active { background: var(--gold); color: var(--ink); }

/* the hidden face must not take taps */
.card.flipped .front, .card:not(.flipped) .back { pointer-events: none; }
