/* Ask & Roll app layout. Colors, type and components come from the design system in /ds.
   Phones get one column; from 700px wide (iPad and up) the setup gets more columns and the game scales up. */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: var(--table); touch-action: manipulation; }
body { margin: 0; min-height: 100vh; min-height: 100dvh; background: var(--table); color: var(--ink); font-family: var(--font-read); overscroll-behavior-y: none; }
#app { --col: 520px; position: relative; min-height: 100vh; min-height: 100dvh; background: var(--table); }
@media (min-width: 700px) { #app { --col: 780px; } }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.boot { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; }
.boot img { width: 88px; height: 88px; animation: boot-bob 1.6s ease-in-out infinite; }
@keyframes boot-bob { 0%, 100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-10px) rotate(4deg); } }
.noscript { padding: 24px 16px; text-align: center; font-size: 16px; line-height: 24px; }
a { color: var(--spark-text); }
a:hover { color: var(--ink); }
a.ar-btn { text-decoration: none; box-sizing: border-box; }
a.ar-btn--spark { color: var(--on-spark); }
a.ar-btn:not(.ar-btn--spark) { color: var(--ink); }

/* ---------- screens */
.screen { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; padding-top: env(safe-area-inset-top, 0px); box-sizing: border-box; }
.bar {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  padding: 14px max(16px, env(safe-area-inset-right, 0px)) 6px max(16px, env(safe-area-inset-left, 0px));
}
/* setup and saved read as a centered column; the game uses the whole screen */
.screen.setup > *, .screen.saved > * { width: 100%; max-width: var(--col); margin-left: auto; margin-right: auto; box-sizing: border-box; }
.brand { margin: 0; font-size: 30px; line-height: 0; flex: none; }
.brand .ar-logo { height: 1em; }
.brand--small { font-size: 26px; }
.bar-title { margin: 0; flex: 1; text-align: center; font-family: var(--font-display); font-weight: 800; font-size: 22px; line-height: 26px; }
.bar-spacer { width: var(--size-tap); flex: none; }
.dock {
  position: sticky; bottom: 0; z-index: 5; display: grid; gap: 10px;
  padding: 18px max(16px, env(safe-area-inset-right, 0px)) calc(18px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  background: linear-gradient(color-mix(in srgb, var(--table) 0%, transparent), var(--table) 26%);
}

/* ---------- setup */
.setup-main { flex: 1; display: flex; flex-direction: column; gap: var(--space-6); padding: 2px max(16px, env(safe-area-inset-right, 0px)) var(--space-4) max(16px, env(safe-area-inset-left, 0px)); }
.intro { margin: 0; font-size: 16px; line-height: 23px; color: var(--ink-muted); }
.block { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.block-title { margin: 0; font-family: var(--font-display); font-weight: 800; font-size: 22px; line-height: 26px; text-wrap: balance; }
.grid-themes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 8px; }
.grid-ages { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 8px; }
.setup-pair { display: flex; flex-direction: column; gap: var(--space-6); }
.cell { min-width: 0; display: flex; }
.cell > * { flex: 1; }
.shake { animation: shake 420ms var(--ease-out); }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-7px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(2px); } }
.hint-text { margin: 0; font-size: 14px; line-height: 20px; color: var(--ink-muted); }
.match { margin: 0; text-align: center; font-size: 15px; line-height: 20px; color: var(--ink-muted); }
.match strong { color: var(--ink); }
.fineprint { margin: 0; text-align: center; font-size: 13px; line-height: 18px; color: var(--ink-muted); }

/* players */
.players { display: grid; gap: 10px; }
.player-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.player {
  display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 4px;
  border-radius: var(--radius-full); background: var(--surface); box-shadow: inset 0 0 0 2px var(--line);
  font-family: var(--font-display); font-weight: 700; font-size: 17px; line-height: 20px; max-width: 100%;
}
.player .ar-avatar { width: 36px; height: 36px; font-size: 16px; }
.player-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player-x {
  -webkit-tap-highlight-color: transparent; appearance: none; border: 0; margin: 0; padding: 0; cursor: pointer;
  width: 40px; height: 40px; flex: none; border-radius: var(--radius-full); display: grid; place-items: center;
  background: transparent; color: var(--ink-muted);
}
.player-x:hover { color: var(--ink); background: var(--surface-sunk); }
.player-x:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.player-x .ar-icon { font-size: 18px; }
.player-add { display: flex; gap: 8px; align-items: center; }
.field {
  flex: 1; min-width: 0; height: 48px; box-sizing: border-box; padding: 0 16px; margin: 0;
  border: 0; border-radius: var(--radius-md); background: var(--surface); color: var(--ink);
  box-shadow: inset 0 0 0 2px var(--line-strong);
  font-family: var(--font-display); font-weight: 700; font-size: 17px; line-height: 20px;
}
.field::placeholder { color: var(--ink-muted); opacity: 1; font-weight: 700; }
.field:focus { outline: none; box-shadow: inset 0 0 0 2px var(--ink), var(--focus-ring); }
.player-add .ar-btn { margin-bottom: 4px; }

/* settings rows */
.settings { display: grid; gap: 12px; }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; }
.setting-label { font-family: var(--font-display); font-weight: 700; font-size: 17px; line-height: 20px; }
.saved-link { justify-content: flex-start; gap: 12px; padding: 0 16px; }
.saved-link > span:nth-child(2) { flex: 1; text-align: left; }
.count-badge { min-width: 28px; height: 28px; padding: 0 8px; box-sizing: border-box; border-radius: var(--radius-full); display: inline-grid; place-items: center; background: var(--surface-sunk); font-size: 15px; }

@media (min-width: 700px) {
  .bar { padding-top: 22px; }
  .brand { font-size: 36px; }
  .intro { font-size: 18px; line-height: 26px; }
  .block-title { font-size: 24px; line-height: 28px; }
  .grid-themes { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 10px; }
  .grid-ages { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px 8px; }
  .setup-pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--space-8); align-items: start; }
  .setup .dock { grid-template-columns: minmax(0, 1fr) minmax(0, 340px); align-items: center; gap: 16px; }
  .setup .dock .match { text-align: left; font-size: 17px; line-height: 22px; }
}

/* ---------- play */
.screen.play { height: 100vh; height: 100dvh; min-height: 0; overflow: hidden; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.turn-row { display: flex; justify-content: center; padding: 4px 16px 0; }
.table { position: relative; flex: 1; min-height: 0; margin-top: 12px; overflow: hidden; box-shadow: inset 0 2px 0 var(--line), inset 0 -2px 0 var(--line); }
.die-wrap { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -44%); display: flex; flex-direction: column; align-items: center; gap: 4px; width: 100%; }
.die-wrap .ar-die-btn, .die-wrap .ar-die-mat, .die-wrap .ar-die-shadow, .die-wrap .ar-twinkle, .die-wrap .hint { transition: opacity 280ms var(--ease-out), transform 280ms var(--ease-out); }
.die-wrap.is-away .ar-die-btn, .die-wrap.is-away .ar-die-mat, .die-wrap.is-away .ar-die-shadow, .die-wrap.is-away .ar-twinkle { opacity: 0; transform: scale(.55); pointer-events: none; }
.die-wrap.is-away .hint { opacity: 0; transform: translateY(10px); }
.hint { margin: 0; padding: 0 16px; font-family: var(--font-display); font-weight: 800; font-size: 30px; line-height: 34px; text-align: center; text-wrap: balance; color: var(--ink); }
.card-stage { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 10px 16px 12px; }
.card-slot { position: relative; z-index: 1; flex: none; }
.card-scale { width: 300px; height: 420px; transform-origin: 0 0; }
.card-scale .ar-card-wrap { width: 300px; }
.tiles { position: relative; z-index: 1; display: flex; justify-content: center; gap: 18px; flex: none; }
/* landscape tablet: the actions stand next to the card, so the card can be taller */
.card-stage.is-row { flex-direction: row; gap: 48px; }
.card-stage.is-row .tiles { flex-direction: column; gap: 22px; }
.glow { position: absolute; left: 50%; top: 42%; width: 420px; height: 420px; margin: -210px 0 0 -210px; border-radius: 9999px; pointer-events: none; background: radial-gradient(closest-side, color-mix(in srgb, var(--gold) 55%, transparent), color-mix(in srgb, var(--gold) 0%, transparent)); }
.pop { position: absolute; z-index: 2; pointer-events: none; }
.card-in { animation: card-in var(--dur-card) var(--ease-out) both; }
.glow { animation: glow 1600ms var(--ease-out) both; }
.pop { animation: pop 1200ms var(--ease-out) both; }
.rise { animation: rise 420ms var(--ease-out) 1000ms both; }
@keyframes card-in {
  0% { transform: translateY(30px) scale(.16) rotate(-16deg); opacity: 0; }
  55% { transform: translateY(-12px) scale(1.06) rotate(3deg); opacity: 1; }
  78% { transform: translateY(3px) scale(.98) rotate(-1deg); }
  100% { transform: none; opacity: 1; }
}
@keyframes glow { 0% { transform: scale(.3); opacity: 0; } 35% { transform: scale(1.1); opacity: 1; } 100% { transform: scale(1); opacity: .5; } }
@keyframes pop { 0% { transform: scale(0) rotate(0deg); opacity: 0; } 30% { transform: scale(1.25) rotate(35deg); opacity: 1; } 100% { transform: translateY(-18px) scale(0) rotate(100deg); opacity: 0; } }
@keyframes rise { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }
.screen.play .dock { position: static; background: none; padding-top: 14px; }
.summary { justify-content: flex-start; gap: 12px; min-height: 60px; padding: 0 16px; }
.summary-text { display: grid; gap: 2px; flex: 1; min-width: 0; text-align: left; }
.summary-text > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.summary-text small { font-family: var(--font-read); font-weight: 400; font-size: 13px; line-height: 16px; color: var(--ink-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dots { display: flex; gap: 4px; flex: none; }
.dots span { width: 12px; height: 12px; border-radius: 9999px; }

@media (min-width: 700px) {
  .screen.play .bar { padding-top: 18px; padding-left: max(24px, env(safe-area-inset-left, 0px)); padding-right: max(24px, env(safe-area-inset-right, 0px)); }
  .brand--small { font-size: 32px; }
  .turn-row { padding-top: 6px; }
  .turn-row .ar-turn { min-height: 64px; font-size: 19px; line-height: 22px; }
  .turn-row .ar-turn > .ar-avatar { width: 50px; height: 50px; font-size: 22px; }
  .turn-row .ar-turn-text small { font-size: 14px; line-height: 18px; }
  .hint { font-size: 40px; line-height: 46px; }
  .glow { width: 640px; height: 640px; margin: -320px 0 0 -320px; }
  .tiles { gap: 28px; }
  .tiles .ar-tile { min-width: 100px; font-size: 17px; line-height: 21px; gap: 8px; }
  .tiles .ar-tile-face { width: 76px; height: 76px; }
  .tiles .ar-tile-face .ar-icon { font-size: 34px; }
  .screen.play .dock { width: 100%; max-width: 600px; margin: 0 auto; box-sizing: border-box; }
}
/* iPad in landscape: logo to the left and the turn pill in the top bar, so the table gets the height */
@media (min-width: 900px) and (orientation: landscape) {
  .screen.play { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto; }
  .screen.play > .bar { grid-row: 1; grid-column: 1 / -1; justify-content: flex-start; padding-bottom: 10px; }
  .screen.play > .bar > :last-child { margin-left: auto; }
  .screen.play > .turn-row { grid-row: 1; grid-column: 2; align-self: center; padding: 8px 0 0; z-index: 2; }
  .screen.play > .table { grid-row: 2; grid-column: 1 / -1; margin-top: 0; }
  .screen.play > .dock { grid-row: 3; grid-column: 1 / -1; }
}

/* ---------- saved */
.saved-main { flex: 1; padding: 8px max(16px, env(safe-area-inset-right, 0px)) calc(24px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); }
.saved-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.saved-item { display: flex; align-items: flex-start; gap: 12px; padding: 12px 6px 12px 12px; border-radius: var(--radius-lg); background: var(--surface); box-shadow: inset 0 0 0 2px var(--line); }
.saved-disc { width: 44px; height: 44px; flex: none; border-radius: var(--radius-full); display: grid; place-items: center; background: var(--cat); color: var(--on-cat); }
.saved-disc .ar-icon { font-size: 24px; }
.saved-body { flex: 1; min-width: 0; display: grid; gap: 4px; padding-top: 2px; }
.saved-q { margin: 0; font-weight: 700; font-size: 18px; line-height: 25px; hyphens: auto; -webkit-hyphens: auto; }
.saved-q2 { margin: 0; font-size: 15px; line-height: 21px; color: var(--ink-muted); }
.saved-meta { margin: 0; font-size: 12px; line-height: 16px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-muted); }
.saved-item .ar-btn { margin: 0; }
.empty { display: grid; justify-items: center; gap: 16px; padding: 48px 8px; text-align: center; }
.empty-mark { width: 72px; height: 72px; opacity: .9; }
.empty p { margin: 0; max-width: 30ch; font-size: 16px; line-height: 24px; color: var(--ink-muted); }
@media (min-width: 700px) {
  .saved-list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .saved-q { font-size: 20px; line-height: 27px; }
}

/* ---------- loading and toast */
.loading { align-items: center; justify-content: center; gap: 16px; padding: 24px 16px; text-align: center; }
.loading-mark { width: 88px; height: 88px; animation: boot-bob 1.6s ease-in-out infinite; }
.loading p { margin: 0; font-size: 16px; line-height: 24px; }
.toast-region { position: fixed; left: 0; right: 0; bottom: calc(108px + env(safe-area-inset-bottom, 0px)); display: flex; justify-content: center; pointer-events: none; z-index: 20; padding: 0 16px; }
.toast {
  max-width: 420px; padding: 12px 18px; border-radius: var(--radius-md); background: var(--ink); color: var(--on-ink);
  font-family: var(--font-display); font-weight: 700; font-size: 16px; line-height: 21px; text-align: center;
  box-shadow: var(--shadow-card); animation: rise 260ms var(--ease-out) both;
}

@media (prefers-reduced-motion: reduce) {
  .card-in, .glow, .pop, .rise, .shake, .boot img, .loading-mark, .toast { animation: none; }
}
