/**
 * IRAMA styles.
 *
 * Constraints that shaped this file:
 *   - One-handed layouts (design §7). Primary actions sit in the lower third,
 *     within thumb reach; headings sit at the top where nothing needs tapping.
 *   - No reliance on colour alone (§7). Every state that is shown with colour is
 *     also shown with size, shape, or text.
 *   - Reduced motion is honoured both from the OS and from in-app settings.
 *   - Nothing pulses, nudges, badges, or demands attention. There is no red
 *     anywhere in the app except the crisis affordance.
 */

:root {
  --bg: #0d1230;
  --bgDeep: #070a1d;
  --ink: #f3e6c4;
  --inkSoft: #a99f86;
  --accent: #d9a93c;
  --glow: #f5cd69;
  --ring: #3b3f6b;

  --pad: clamp(1.1rem, 5vw, 2rem);
  --radius: 18px;
  --tap: 56px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  overscroll-behavior: none;
}

body {
  background: radial-gradient(ellipse at 50% 30%, var(--bg), var(--bgDeep) 78%);
  color: var(--ink);
  font-family: ui-rounded, 'SF Pro Rounded', -apple-system, BlinkMacSystemFont, 'Segoe UI',
    system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
  user-select: none;
  transition: background 900ms ease;
}

.app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom)
    env(safe-area-inset-left);
}

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: var(--pad);
  gap: 0.9rem;
}

/* Headings top, actions bottom — the one-handed rule. */
.screen__head {
  flex: 0 0 auto;
  padding-top: 0.6rem;
}
.screen__body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1rem;
}
.screen__foot {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding-bottom: 0.4rem;
}

h1 {
  font-size: clamp(1.7rem, 7vw, 2.4rem);
  font-weight: 600;
  letter-spacing: 0.14em;
  margin: 0 0 0.2rem;
}
h2 {
  font-size: 1.15rem;
  font-weight: 600;
  margin: 0;
  letter-spacing: 0.02em;
}
p {
  margin: 0 0 0.7rem;
  color: var(--inkSoft);
  max-width: 34rem;
}
p.lead {
  color: var(--ink);
}
small {
  color: var(--inkSoft);
  font-size: 0.85rem;
  line-height: 1.45;
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  cursor: pointer;
}

.btn {
  min-height: var(--tap);
  padding: 0.9rem 1.3rem;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  width: 100%;
  text-align: left;
  transition: background 160ms ease, transform 160ms ease;
}
.btn:active {
  transform: scale(0.985);
  background: rgba(255, 255, 255, 0.11);
}
.btn--primary {
  background: var(--accent);
  border-color: transparent;
  color: #14100a;
  font-weight: 650;
  justify-content: center;
}
.btn--quiet {
  background: none;
  border-color: rgba(255, 255, 255, 0.12);
  color: var(--inkSoft);
}
.btn--ghost {
  background: none;
  border: 0;
  color: var(--inkSoft);
  justify-content: center;
  font-size: 0.95rem;
}
.btn__sub {
  display: block;
  font-size: 0.82rem;
  font-weight: 400;
  color: var(--inkSoft);
  margin-top: 0.1rem;
}
.btn--primary .btn__sub {
  color: rgba(20, 16, 10, 0.66);
}

/* Crisis affordance. Persistent, never alarming, never hidden. */
.crisis-button {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 0.55rem);
  right: calc(env(safe-area-inset-right) + 0.7rem);
  z-index: 40;
  padding: 0.5rem 0.85rem;
  border-radius: 999px;
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  color: var(--ink);
  background: rgba(190, 70, 60, 0.22);
  border: 1px solid rgba(220, 110, 100, 0.4);
}
.crisis-button:active {
  background: rgba(190, 70, 60, 0.34);
}

.stage {
  display: block;
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  touch-action: none;
}

.stage-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
}

/* Ketuk Gong — one enormous target, no instructions beyond a single line. */
.gong-target {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
}

.list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  min-height: 0;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.045);
  min-height: var(--tap);
}
.row__label {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

/* Switches show state with position AND text, never colour alone. */
.switch {
  flex: 0 0 auto;
  width: 60px;
  height: 34px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.16);
  position: relative;
  transition: background 180ms ease;
}
.switch[aria-checked='true'] {
  background: var(--accent);
}
.switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--ink);
  transition: transform 180ms ease;
}
.switch[aria-checked='true']::after {
  transform: translateX(26px);
  background: #14100a;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.chip {
  padding: 0.55rem 0.9rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.9rem;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}
.chip[aria-pressed='true'] {
  background: var(--accent);
  color: #14100a;
  border-color: transparent;
  font-weight: 600;
}

/* Collection: instruments as gong shapes, never as a progress bar. */
.set-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 0.8rem;
  overflow-y: auto;
  padding-bottom: 1rem;
  min-height: 0;
}
.set-item {
  aspect-ratio: 1;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  background: radial-gradient(circle at 40% 34%, rgba(255, 255, 255, 0.13), transparent 62%),
    rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 0.68rem;
  color: var(--inkSoft);
  text-align: center;
  padding: 0.4rem;
}

.crisis-line {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 1rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  min-height: var(--tap);
  text-decoration: none;
  color: var(--ink);
}
.crisis-line strong {
  font-size: 1.3rem;
  letter-spacing: 0.02em;
}

.hint {
  text-align: center;
  color: var(--inkSoft);
  font-size: 0.88rem;
  letter-spacing: 0.03em;
  min-height: 1.3em;
}

.note-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: var(--accent);
  color: #14100a;
  font-size: 1.6rem;
  font-weight: 650;
  margin: 0 auto;
}

.attribution {
  text-align: center;
  font-size: 0.76rem;
  color: var(--inkSoft);
  opacity: 0.85;
  padding: 0 0.5rem;
}

.fade-in {
  animation: fade 520ms ease both;
}
@keyframes fade {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

/* Reduced motion, from the OS or from settings. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}
html[data-reduced-motion='true'] *,
html[data-reduced-motion='true'] *::before,
html[data-reduced-motion='true'] *::after {
  animation-duration: 0.001ms !important;
  transition-duration: 0.001ms !important;
}

/* Wayang Bayang. Design §3.8 — near-black, brightness capped, no white light. */
html[data-night='true'] body {
  background: #000;
}
html[data-night='true'] .app {
  filter: brightness(0.62);
}
html[data-night='true'] .btn--primary {
  background: #6b5326;
  color: #d8c9a8;
}

@media (min-width: 720px) {
  .screen {
    max-width: 620px;
    margin: 0 auto;
    width: 100%;
  }
}
