/* Nền tảng bố cục: một cột giữa màn hình như điện thoại, máy tính bảng thì rộng hơn */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--violet-50);
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 16px;
  line-height: 1.35;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

body {
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.app {
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: stretch;
}

/* Một màn hình. Trên điện thoại chiếm hết, trên màn to thì là một cột 430px ở giữa. */
.screen {
  position: relative;
  width: 100%;
  max-width: 430px;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: calc(env(safe-area-inset-top, 0px) + 20px) 20px calc(env(safe-area-inset-bottom, 0px) + 20px);
  background: var(--bg-lesson);
  overflow: hidden;
  animation: screen-in 360ms cubic-bezier(0.2, 0.8, 0.3, 1) both;
}
/* Màn cũ lùi ra khi chuyển màn (router thêm is-leaving rồi đợi 180ms) */
.screen.is-leaving { animation: screen-out 180ms ease-in both; }

@keyframes screen-in {
  from { opacity: 0; transform: translateY(14px) scale(0.985); }
  to { opacity: 1; transform: none; }
}
@keyframes screen-out {
  from { opacity: 1; transform: none; }
  to { opacity: 0; transform: translateY(-8px) scale(0.99); }
}

@media (prefers-reduced-motion: reduce) {
  .screen, .screen.is-leaving { animation: none; }
}

/* Máy tính bảng nằm ngang: cột rộng hơn, các màn tự chia hai cột qua .split */
@media (min-width: 820px) and (orientation: landscape) {
  .screen { max-width: 1024px; padding-left: 40px; padding-right: 40px; }
  .split { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 40px; align-items: center; flex-grow: 1; }
}

.grow { flex-grow: 1; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 12px; }
.center { display: flex; align-items: center; justify-content: center; }
.hidden { display: none !important; }

h1, h2, h3 { margin: 0; font-family: var(--font-display); font-weight: 800; }
p { margin: 0; }
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; }
input { font: inherit; }
svg { display: block; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 24px);
  transform: translateX(-50%);
  background: var(--violet-800);
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 14px;
  z-index: 50;
}
