/* Casino: iPhone-style, light and dark. */

:root {
  color-scheme: light dark;

  --bg: #f2f2f7;
  --card: #ffffff;
  --label: #000000;
  --label-2: #6c6c70;
  --separator: rgba(60, 60, 67, 0.14);
  --fill: rgba(118, 118, 128, 0.12);
  --on-label: #ffffff;
  --up: #0b7a43;
  --down: #c4281c;
  --shadow-sheet: 0 -8px 40px rgba(0, 0, 0, 0.12);

  --radius-card: 22px;
  --radius-control: 16px;
  --gutter: 20px;

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, Roboto, sans-serif;
  --font-round: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --card: #1c1c1e;
    --label: #ffffff;
    --label-2: #98989f;
    --separator: rgba(84, 84, 88, 0.55);
    --fill: rgba(118, 118, 128, 0.24);
    --on-label: #000000;
    --up: #30d158;
    --down: #ff453a;
    --shadow-sheet: none;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--label);
  font: 17px/1.35 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

h1,
h2,
p,
ol,
ul {
  margin: 0;
  padding: 0;
}

ol,
ul {
  list-style: none;
}

button,
input {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--label) 55%, transparent);
  outline-offset: 2px;
}

/* ---------------------------------------------------------------- views */

.view {
  max-width: 480px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 20px) calc(env(safe-area-inset-right) + var(--gutter))
    calc(env(safe-area-inset-bottom) + 40px) calc(env(safe-area-inset-left) + var(--gutter));
  animation: view-in 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

h1 {
  font-size: 34px;
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: -0.02em;
}

h2 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.card {
  background: var(--card);
  border-radius: var(--radius-card);
}

/* ----------------------------------------------------------------- join */

.join {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 36px;
}

.join-head {
  display: grid;
  gap: 12px;
}

/* A poker chip drawn with two rings. */
.chip {
  width: 56px;
  height: 56px;
  margin-bottom: 8px;
  border-radius: 50%;
  border: 5px solid var(--label);
  background: radial-gradient(circle, var(--label) 0 34%, transparent 36%);
}

.lede {
  color: var(--label-2);
  max-width: 32ch;
}

.join-form {
  display: grid;
  gap: 14px;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 3px;
  border-radius: 13px;
  background: var(--fill);
}

.segmented button {
  min-height: 40px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s;
}

.segmented button[aria-selected="true"] {
  background: var(--card);
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

@media (prefers-color-scheme: dark) {
  .segmented button[aria-selected="true"] {
    background: #636366;
    box-shadow: none;
  }
}

.fields {
  overflow: hidden;
}

.fields input {
  display: block;
  width: 100%;
  height: 58px;
  padding: 0 18px;
  border: 0;
  border-radius: 0;
  background: transparent;
  outline-offset: -3px;
}

.fields input + input {
  border-top: 1px solid var(--separator);
}

.fields input::placeholder {
  color: var(--label-2);
}

.pin {
  -webkit-text-security: disc;
}

.hint,
.form-error,
.demo-note {
  font-size: 13px;
  line-height: 1.4;
  color: var(--label-2);
  padding: 0 4px;
}

.form-error {
  color: var(--down);
}

.form-error:empty {
  display: none;
}

.demo-note {
  margin-top: 28px;
}

.join .demo-note {
  margin-top: 0;
}

/* -------------------------------------------------------------- buttons */

.button {
  display: block;
  width: 100%;
  min-height: 56px;
  padding: 0 20px;
  border: 0;
  border-radius: var(--radius-control);
  background: transparent;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.15s;
}

.button:active {
  transform: scale(0.98);
  opacity: 0.7;
}

.button:disabled {
  opacity: 0.5;
}

.button.primary {
  background: var(--label);
  color: var(--on-label);
}

.button.plain {
  font-weight: 500;
}

.button.danger {
  color: var(--down);
}

/* ----------------------------------------------------------------- home */

.home-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 12px;
}

.summary {
  min-height: 1.35em;
  margin: 6px 0 24px;
  color: var(--label-2);
}

.offline {
  margin: -8px 0 20px;
  font-size: 15px;
  color: var(--down);
}

.home h2 {
  margin: 36px 4px 12px;
}

.avatar {
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--fill);
  font: 600 17px/1 var(--font-round);
}

.avatar.me {
  background: var(--label);
  color: var(--on-label);
}

.avatar.large {
  width: 72px;
  height: 72px;
  font-size: 30px;
}

.profile-button {
  width: 44px;
  height: 44px;
  border: 0;
  padding: 0;
  cursor: pointer;
}

.list {
  overflow: hidden;
}

.row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 68px;
  padding: 12px 18px;
  background: var(--card);
}

.row + .row::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  left: 18px;
  border-top: 1px solid var(--separator);
}

.row.empty {
  color: var(--label-2);
  font-size: 15px;
}

.rank {
  flex: none;
  width: 22px;
  font: 600 17px/1 var(--font-round);
  font-variant-numeric: tabular-nums;
  color: var(--label-2);
}

.rank.lead {
  color: var(--label);
}

.who {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 1px;
}

.name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.you,
.note,
time {
  font-size: 14px;
  color: var(--label-2);
}

.score,
.delta {
  font: 600 19px/1.2 var(--font-round);
  font-variant-numeric: tabular-nums;
}

.change {
  flex: none;
  display: grid;
  gap: 1px;
  justify-items: end;
}

.delta {
  font-size: 17px;
}

.delta.up {
  color: var(--up);
}

.delta.down {
  color: var(--down);
}

/* ---------------------------------------------------------------- sheet */

.sheet {
  width: 100%;
  max-width: 480px;
  margin: auto auto 0;
  padding: 10px var(--gutter) calc(env(safe-area-inset-bottom) + 16px);
  border: 0;
  border-radius: 28px 28px 0 0;
  background: var(--card);
  color: var(--label);
  box-shadow: var(--shadow-sheet);
  text-align: center;
}

.sheet[open] {
  display: grid;
  justify-items: center;
  gap: 6px;
  animation: sheet-in 0.42s cubic-bezier(0.2, 0.9, 0.2, 1);
}

.sheet::backdrop {
  background: rgba(0, 0, 0, 0.4);
  animation: fade-in 0.3s;
}

.sheet.closing {
  animation: sheet-out 0.24s ease-in forwards;
}

.sheet.closing::backdrop {
  animation: fade-out 0.24s forwards;
}

.grabber {
  width: 36px;
  height: 5px;
  margin-bottom: 18px;
  border-radius: 3px;
  background: var(--fill);
}

.sheet h2 {
  margin-top: 10px;
  font-size: 22px;
}

.sheet-points {
  margin-bottom: 20px;
  color: var(--label-2);
  font-family: var(--font-round);
}

@keyframes sheet-in {
  from {
    transform: translateY(100%);
  }
}

@keyframes sheet-out {
  to {
    transform: translateY(100%);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

@keyframes fade-out {
  to {
    opacity: 0;
  }
}

/* ---------------------------------------------------------------- toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 28px);
  z-index: 10;
  transform: translateX(-50%);
  max-width: calc(100vw - 40px);
  padding: 12px 18px;
  border-radius: 999px;
  background: var(--label);
  color: var(--on-label);
  font-size: 15px;
  font-weight: 500;
  animation: view-in 0.3s;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after,
  ::backdrop {
    animation: none !important;
    transition: none !important;
  }
}
