:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #f5f5f7;
  color: #3f3f42;
  -webkit-tap-highlight-color: transparent;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  background: #f5f5f7;
}

body {
  min-height: 100svh;
  overflow: hidden;
}

button,
input {
  font: inherit;
}

.screen {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  width: 100%;
  min-height: 100svh;
  place-items: center;
  padding: max(24px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  transform-origin: center;
  transition: transform 320ms cubic-bezier(.2, .8, .2, 1);
}

.tip-panel {
  width: 100%;
  max-width: 1480px;
  min-width: 0;
  text-align: center;
}

h1 {
  margin: 0 0 clamp(36px, 8vh, 84px);
  font-size: clamp(42px, 6vw, 78px);
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: -.025em;
}

.choices {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(18px, 2.3vw, 44px);
}

.tip-button {
  min-height: clamp(180px, 26vh, 280px);
  border: 0;
  border-radius: 2px;
  background: #0877f9;
  color: #fff;
  cursor: pointer;
  font-size: clamp(64px, 7vw, 112px);
  font-weight: 300;
  line-height: 1;
  box-shadow: 0 1px 0 rgb(0 0 0 / 8%);
  transition: background 120ms ease, transform 120ms ease, box-shadow 120ms ease;
  touch-action: manipulation;
}

.custom-button {
  grid-column: 1 / -1;
  min-height: clamp(92px, 13vh, 140px);
  font-size: clamp(36px, 4vw, 58px);
  font-weight: 400;
}

.tip-button:active {
  transform: scale(.985);
  background: #0068df;
}

.tip-button:focus-visible,
.flip-button:focus-visible,
.dialog-actions button:focus-visible,
input:focus-visible {
  outline: 4px solid #111;
  outline-offset: 4px;
}

.tip-button.selected {
  background: #075fc4;
  box-shadow: inset 0 0 0 5px rgb(255 255 255 / 75%), 0 5px 18px rgb(0 70 170 / 25%);
}

.confirmation {
  min-height: 1.5em;
  margin: clamp(16px, 2.5vh, 30px) 0 0;
  font-size: clamp(20px, 2.5vw, 34px);
  color: #525257;
}

.flip-button {
  position: fixed;
  right: max(14px, env(safe-area-inset-right));
  bottom: max(14px, env(safe-area-inset-bottom));
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid #d7d7dc;
  border-radius: 999px;
  padding: 10px 15px;
  background: rgb(255 255 255 / 82%);
  color: #3f3f42;
  font-size: 15px;
  box-shadow: 0 3px 16px rgb(0 0 0 / 8%);
  backdrop-filter: blur(12px);
  cursor: pointer;
  justify-self: end;
  touch-action: manipulation;
}

.flip-button > span:first-child {
  font-size: 22px;
  line-height: 1;
}

.custom-dialog {
  width: min(88vw, 420px);
  border: 0;
  border-radius: 20px;
  padding: 0;
  color: #262629;
  box-shadow: 0 24px 80px rgb(0 0 0 / 30%);
}

.custom-dialog::backdrop {
  background: rgb(0 0 0 / 48%);
  backdrop-filter: blur(3px);
}

.custom-dialog form {
  padding: 28px;
}

.custom-dialog h2 {
  margin: 0 0 24px;
  font-size: 26px;
}

.custom-dialog label {
  display: block;
  margin-bottom: 8px;
  font-size: 16px;
}

.input-row {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 30px;
}

.input-row input {
  width: 100%;
  min-width: 0;
  border: 2px solid #c9c9ce;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 30px;
}

.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 26px;
}

.dialog-actions button {
  border: 0;
  border-radius: 12px;
  padding: 13px 16px;
  cursor: pointer;
}

.dialog-actions .secondary {
  background: #ececf0;
  color: #333;
}

.dialog-actions .primary {
  background: #0877f9;
  color: #fff;
}

@media (orientation: portrait) {
  .screen.face-mode {
    transform: rotate(180deg);
  }

  .tip-panel {
    max-width: 720px;
  }

  h1 {
    margin-bottom: clamp(28px, 6vh, 64px);
    font-size: clamp(40px, 11vw, 72px);
  }

  .choices {
    grid-template-columns: 1fr;
    gap: clamp(12px, 2.2vh, 22px);
  }

  .tip-button,
  .custom-button {
    grid-column: auto;
    min-height: clamp(92px, 13vh, 142px);
    font-size: clamp(48px, 15vw, 82px);
  }

  .custom-button {
    font-size: clamp(31px, 8vw, 46px);
  }

  .confirmation {
    margin-top: clamp(10px, 2vh, 20px);
    font-size: clamp(18px, 5vw, 28px);
  }
}

@media (orientation: landscape) and (max-height: 560px) {
  .screen {
    padding-top: max(16px, env(safe-area-inset-top));
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }

  h1 {
    margin-bottom: clamp(18px, 5vh, 32px);
    font-size: clamp(34px, 8vh, 56px);
  }

  .tip-button {
    min-height: clamp(108px, 30vh, 168px);
    font-size: clamp(52px, 14vh, 82px);
  }

  .custom-button {
    min-height: clamp(62px, 15vh, 84px);
    font-size: clamp(27px, 7vh, 42px);
  }

  .confirmation {
    margin-top: 10px;
    font-size: 18px;
  }

  .flip-button {
    display: none;
  }
}

@media (max-height: 640px) and (orientation: portrait) {
  h1 {
    margin-bottom: 18px;
    font-size: 36px;
  }

  .choices {
    gap: 10px;
  }

  .tip-button,
  .custom-button {
    min-height: 78px;
    font-size: 44px;
  }

  .custom-button {
    font-size: 26px;
  }

  .confirmation {
    font-size: 16px;
  }

  .flip-label {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
  }
}
