/* Both home entry URLs use the same activation dialog. Keep the inset
   shadow even when the site's light-theme focus reset is active. */
html[data-theme] #activationCode {
  box-shadow: inset 0 2px 7px rgba(0, 0, 0, .26) !important;
}

/* Keep the returned input focusable as soon as the processing panel closes. */
#phase-input:has(#codeInputError:not([hidden])) #activationCode {
  transition-property: background-color, border-color, box-shadow, color;
}

#codeInputError {
  color: #FF3B30;
  font-size: 14px;
  overflow-wrap: anywhere;
}

[data-theme="dark"] #codeInputError {
  color: #ff7770;
}

#codeInputError a {
  color: inherit;
  text-decoration: underline;
}

.redemption-ticket-header,
.redemption-title-mobile,
.redemption-ticket-formats,
.redemption-ticket-stub {
  display: none;
}

@media (min-width: 769px) {
  html.upgrade8-page {
    --desktop-code-dialog-background: #0a1322;
  }

  /* The code and purchase flows share the modal and its progress panel. */
  html[data-theme="dark"] #modalContainer:is(
    .is-input-wide:not(.is-wide),
    .is-purchasing,
    :has(> :is(#phase-preview, #phase-success, #phase-error)[style*="display: flex"])
  ) {
    background: var(--desktop-code-dialog-background, #323232) !important;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}

@media (max-width: 768px) {
  /* The wide preview, result and purchase dialogs keep their own styles. */
  html[data-theme] #authModal .modal-sheet.is-input-wide:not(.is-wide) {
    --redemption-surface: #10141c;
    --redemption-sheen: rgba(86, 156, 255, .13);
    --redemption-ink: #f6f9ff;
    --redemption-muted: #c2cede;
    --redemption-accent: #75b9ff;
    --redemption-stub: #dbe9fb;
    align-self: flex-start;
    margin-block-start: max(12px, env(safe-area-inset-top));
    width: calc(100% - 24px);
    max-width: 470px;
    max-height: calc(100% - 24px);
    max-height: calc(100dvh - max(12px, env(safe-area-inset-top)) - 12px);
    overflow-y: auto;
    padding: 0;
    border: 0 !important;
    border-radius: 18px;
    background: linear-gradient(145deg, var(--redemption-sheen), transparent 52%), var(--redemption-surface) !important;
    color: var(--redemption-ink);
    transform: translateY(-36px) scale(.97);
  }

  html[data-theme="light"] #authModal .modal-sheet.is-input-wide:not(.is-wide) {
    --redemption-surface: #f7faff;
    --redemption-sheen: rgba(86, 156, 255, .12);
    --redemption-ink: #142438;
    --redemption-muted: #3e526b;
    --redemption-accent: #145eae;
    --redemption-stub: #e1edfb;
  }

  html[data-theme] #authModal.active .modal-sheet.is-input-wide:not(.is-wide) {
    clip-path: inset(0 round 18px);
    transform: none;
  }

  #phase-input {
    box-sizing: border-box;
    align-items: stretch;
    padding: 58px 16px 0;
    text-align: left;
  }

  .redemption-ticket-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    margin-inline-end: -16px;
    margin-bottom: 24px;
  }

  .redemption-ticket-brand {
    min-width: 0;
    font-family: "HarmonyOS Sans", sans-serif;
  }

  .redemption-ticket-badge {
    position: relative;
    isolation: isolate;
    padding: 6px 12px 6px 20px;
    background: var(--redemption-accent);
    color: var(--redemption-accent);
    clip-path: polygon(14px 0, 100% 0, 100% 100%, 0 100%);
    font-size: 11px;
    font-weight: 700;
    text-align: center;
  }

  .redemption-ticket-badge::before {
    content: "";
    position: absolute;
    inset: 1px;
    z-index: -1;
    background: var(--redemption-surface);
    clip-path: inherit;
  }

  .redemption-ticket-brand strong {
    font-size: clamp(21px, 7vw, 28px);
    line-height: 1;
  }

  .redemption-title-pc {
    display: none;
  }

  .redemption-title-mobile {
    display: inline;
  }

  #phase-input .phase-input-title {
    box-sizing: border-box;
    margin: 0 0 12px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--redemption-accent);
    color: var(--redemption-ink);
    font-size: clamp(20px, 5.5vw, 26px);
    line-height: 1.3;
    text-align: left;
  }

  #phase-input .phase-input-sub-mobile {
    color: var(--redemption-muted);
    line-height: 1.6;
    text-align: left;
  }

  #phase-input .phase-input-right {
    width: 100%;
    min-width: 0;
  }

  .modal-sheet.is-input-wide #phase-input .phase-input-controls {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(76px, 26%);
    gap: 4px;
    margin-top: 16px;
  }

  #phase-input :is(#activationCode, #btnConfirm) {
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    height: 48px;
    font-size: 14px;
  }

  #phase-input #activationCode:placeholder-shown {
    text-overflow: ellipsis;
  }

  #phase-input .phase-input-desc-pc:has(#codeInputError:not([hidden])) {
    display: flex;
    margin: 12px 0 16px;
  }

  .code-input-format-help {
    display: none;
  }

  .redemption-ticket-formats {
    display: block;
  }

  .redemption-ticket-formats h3 {
    display: flex;
    align-items: center;
    margin: 0 0 8px;
    font-size: 13px;
  }

  .redemption-ticket-formats h3 span {
    padding: 6px 16px 6px 12px;
    color: #fff;
    background: #145eae;
    clip-path: polygon(12px 0, 100% 0, calc(100% - 8px) 100%, 0 100%);
  }

  .redemption-ticket-formats h3::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--redemption-accent);
  }

  .redemption-ticket-formats ul {
    margin: 0 0 18px;
    padding-inline-start: 20px;
    font-size: 13px;
    line-height: 1.8;
  }

  .redemption-ticket-formats li::marker {
    color: var(--redemption-accent);
  }

  .redemption-ticket-formats code {
    font-family: "HarmonyOS Sans", sans-serif;
    overflow-wrap: anywhere;
  }

  .redemption-ticket-stub {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) minmax(24px, 10%);
    align-items: center;
    gap: 8px;
    margin: 0 -16px;
    padding: 11px 16px;
    border-top: 1px dashed #6595c8;
    background: var(--redemption-stub);
    color: #162639;
    font: 700 13px "HarmonyOS Sans", sans-serif;
  }

  .redemption-ticket-stub a {
    padding-inline: 6px;
    border-inline: 1px dashed #8395ac;
    color: #124f9a;
    font-size: clamp(10px, 2.8vw, 12px);
    line-height: 1.45;
    text-align: center;
    overflow-wrap: anywhere;
  }

  .redemption-ticket-barcode {
    height: 21px;
    background: repeating-linear-gradient(90deg, currentColor 0 2px, transparent 2px 4px, currentColor 4px 5px, transparent 5px 8px, currentColor 8px 11px, transparent 11px 13px);
  }
}
