:root {
  --ink: #111111;
  --paper: #f3f3ef;
  --gray-light: #d6d6d1;
  --gray: #9a9a95;
  --gray-dark: #4a4a47;
  --font-pixel: "Press Start 2P", "Courier New", monospace;
  --font-body: "VT323", "Courier New", monospace;
  --border: 3px solid var(--ink);
  --shadow: 6px 6px 0 var(--ink);
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html,
body {
  height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font-body);
  font-size: 1.5rem;
  line-height: 1.25;
  color: var(--ink);
  background-color: var(--paper);
  background-image: repeating-conic-gradient(var(--gray-light) 0% 25%, var(--paper) 0% 50%);
  background-size: 4px 4px;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

button {
  touch-action: manipulation;
}

.scanlines {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0,
    rgba(0, 0, 0, 0) 2px,
    rgba(0, 0, 0, 0.06) 3px,
    rgba(0, 0, 0, 0) 4px
  );
}

.menubar {
  position: relative;
  z-index: 10;
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.35rem 1rem;
  padding-top: calc(0.35rem + env(safe-area-inset-top, 0px));
  padding-left: max(1rem, env(safe-area-inset-left, 0px));
  padding-right: max(1rem, env(safe-area-inset-right, 0px));
  background: var(--paper);
  border-bottom: var(--border);
  font-size: 1.35rem;
}

.menubar-left,
.menubar-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.menubar-title {
  font-family: var(--font-pixel);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
}

.desktop {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1rem 2.5rem;
  padding-left: max(1rem, env(safe-area-inset-left, 0px));
  padding-right: max(1rem, env(safe-area-inset-right, 0px));
  padding-bottom: max(2.5rem, calc(env(safe-area-inset-bottom, 0px) + 1rem));
}

.window {
  display: flex;
  flex-direction: column;
  width: min(720px, 100%);
  background: var(--paper);
  border: var(--border);
  box-shadow: var(--shadow);
}

.titlebar {
  display: flex;
  flex: none;
  align-items: center;
  gap: 0.75rem;
  padding: 0.4rem 0.6rem;
  border-bottom: var(--border);
  background: repeating-linear-gradient(
    to bottom,
    var(--ink) 0,
    var(--ink) 2px,
    var(--paper) 2px,
    var(--paper) 5px
  );
}

.close-box {
  width: 16px;
  height: 16px;
  flex: none;
  background: var(--paper);
  border: 2px solid var(--ink);
}

.titlebar-text {
  flex: 0 1 auto;
  min-width: 0;
  margin: 0 auto;
  padding: 0.25rem 0.9rem;
  overflow: hidden;
  background: var(--paper);
  font-family: var(--font-pixel);
  font-size: 0.6rem;
  letter-spacing: 0.06em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.titlebar-spacer {
  width: 16px;
  flex: none;
}

.window-body {
  position: relative;
  flex: 1;
  min-height: 400px;
  padding: 2rem 2rem 1.5rem;
}

.screen {
  display: none;
}

.screen.active {
  display: block;
  animation: screen-in 0.35s steps(6) both;
}

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

.heading {
  font-family: var(--font-pixel);
  font-weight: 400;
  font-size: 1.05rem;
  line-height: 1.6;
  letter-spacing: 0.02em;
  margin-bottom: 1.25rem;
  overflow-wrap: break-word;
}

.text {
  font-size: 1.65rem;
  line-height: 1.3;
  color: var(--ink);
  margin-bottom: 1rem;
  overflow-wrap: break-word;
}

.text.big {
  font-size: 2rem;
  line-height: 1.2;
  padding: 0.9rem 1rem;
  margin: 0.5rem 0 1.25rem;
  background: var(--ink);
  color: var(--paper);
}

.tag {
  display: inline-block;
  margin-bottom: 0.9rem;
  padding: 0.15rem 0.6rem;
  border: 2px solid var(--ink);
  font-size: 1.2rem;
  letter-spacing: 0.08em;
}

.ghost {
  visibility: hidden;
}

.cursor::after {
  content: "";
  display: inline-block;
  width: 0.55em;
  height: 1em;
  margin-left: 2px;
  vertical-align: -0.12em;
  background: var(--ink);
  animation: blink 0.7s steps(1) infinite;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

.boot {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding-top: 0.5rem;
}

.boot-icon,
.closing-icon {
  display: grid;
  place-items: center;
  width: 84px;
  height: 84px;
  margin-bottom: 1.5rem;
  border: var(--border);
  background: var(--paper);
  box-shadow: 4px 4px 0 var(--ink);
  font-size: 2.6rem;
}

.boot .heading {
  font-size: 1.2rem;
}

.progress {
  width: min(380px, 100%);
  height: 30px;
  margin-top: 0.75rem;
  padding: 3px;
  border: var(--border);
  background: var(--paper);
}

.progress-fill {
  width: 0;
  height: 100%;
  background: repeating-linear-gradient(
    to right,
    var(--ink) 0,
    var(--ink) 14px,
    var(--paper) 14px,
    var(--paper) 17px
  );
  transition: width 0.45s steps(6);
}

.boot-label {
  margin-top: 0.75rem;
  font-size: 1.3rem;
  color: var(--gray-dark);
  letter-spacing: 0.05em;
}

.card {
  display: flex;
  align-items: flex-start;
  gap: 1.5rem;
}

.card-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 96px;
  height: 96px;
  background: var(--ink);
  color: var(--paper);
  border: var(--border);
  box-shadow: 5px 5px 0 var(--gray);
  font-size: 2.8rem;
}

.card-content {
  flex: 1;
  min-width: 0;
}

.closing {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.signature {
  margin-top: 0.5rem;
  font-size: 2rem;
  letter-spacing: 0.04em;
}

.hopes {
  display: grid;
  gap: 0.75rem;
  list-style: none;
  margin-top: 0.25rem;
}

.hopes li {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  padding: 0.55rem 0.9rem;
  border: 2px solid var(--ink);
  background: var(--paper);
  box-shadow: 3px 3px 0 var(--ink);
  font-size: 1.55rem;
  line-height: 1.25;
}

.hopes li i {
  flex: none;
  margin-top: 0.1rem;
  font-size: 1.2rem;
}

.screen.active .hopes li {
  animation: screen-in 0.35s steps(5) both;
}

.screen.active .hopes li:nth-child(1) {
  animation-delay: 0.3s;
}

.screen.active .hopes li:nth-child(2) {
  animation-delay: 0.6s;
}

.screen.active .hopes li:nth-child(3) {
  animation-delay: 0.9s;
}

.screen.active .hopes li:nth-child(4) {
  animation-delay: 1.2s;
}

.reply-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  margin: 0.5rem 0 1.4rem;
}

.reply-btn.selected {
  background: var(--ink);
  color: var(--paper);
}

.reply-output {
  min-height: 4.4rem;
  padding: 0.8rem 1rem;
  border: var(--border);
  background: var(--gray-light);
  font-size: 1.55rem;
  line-height: 1.25;
}

.reply-output.pop {
  animation: screen-in 0.3s steps(4) both;
}

.controls {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  border-top: var(--border);
  background: var(--paper);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  gap: 0.55rem;
  min-height: 44px;
  padding: 0.45rem 1rem;
  border: var(--border);
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-pixel);
  font-size: 0.62rem;
  letter-spacing: 0.05em;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 4px 4px 0 var(--ink);
  transition: transform 0.08s steps(2), box-shadow 0.08s steps(2);
}

.btn i {
  font-size: 1rem;
}

.btn:active:not(:disabled) {
  transform: translate(4px, 4px);
  box-shadow: 0 0 0 var(--ink);
}

.btn:focus-visible {
  outline: 3px dashed var(--ink);
  outline-offset: 3px;
}

.btn:disabled {
  color: var(--gray);
  border-color: var(--gray);
  box-shadow: 4px 4px 0 var(--gray);
  cursor: not-allowed;
}

.btn-primary {
  background: var(--ink);
  color: var(--paper);
}

.btn-primary:disabled {
  background: var(--gray-light);
  color: var(--gray);
}

.btn.is-hidden {
  visibility: hidden;
}

.dots {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dot {
  width: 12px;
  height: 12px;
  padding: 0;
  border: 2px solid var(--ink);
  background: var(--paper);
  cursor: pointer;
}

.dot.active {
  background: var(--ink);
}

.dot:focus-visible {
  outline: 2px dashed var(--ink);
  outline-offset: 3px;
}

.step-count {
  display: none;
  flex: 1;
  font-size: 1.4rem;
  letter-spacing: 0.06em;
  text-align: center;
}

@media (hover: hover) {
  .btn:hover:not(:disabled) {
    background: var(--gray-light);
  }

  .btn-primary:hover:not(:disabled) {
    background: var(--gray-dark);
  }

  .btn.selected:hover {
    background: var(--gray-dark);
  }
}

@media (max-width: 640px) {
  body {
    font-size: 1.3rem;
  }

  .menubar {
    padding-top: calc(0.3rem + env(safe-area-inset-top, 0px));
    padding-bottom: 0.3rem;
  }

  .desktop {
    align-items: stretch;
    padding-top: 0.9rem;
    padding-left: max(0.75rem, env(safe-area-inset-left, 0px));
    padding-right: max(0.75rem, env(safe-area-inset-right, 0px));
    padding-bottom: max(1.1rem, calc(env(safe-area-inset-bottom, 0px) + 0.6rem));
  }

  .window {
    box-shadow: 4px 4px 0 var(--ink);
  }

  .window-body {
    min-height: 0;
    padding: 1.4rem 1.1rem 1.2rem;
  }

  .heading {
    font-size: 0.85rem;
    margin-bottom: 1rem;
  }

  .boot .heading {
    font-size: 1rem;
  }

  .text {
    font-size: 1.5rem;
  }

  .text.big {
    font-size: 1.75rem;
  }

  .card {
    flex-direction: column;
    gap: 1.1rem;
  }

  .card-icon {
    width: 72px;
    height: 72px;
    font-size: 2.1rem;
    box-shadow: 4px 4px 0 var(--gray);
  }

  .boot-icon,
  .closing-icon {
    width: 72px;
    height: 72px;
    font-size: 2.2rem;
    margin-bottom: 1.2rem;
  }

  .titlebar {
    gap: 0.5rem;
  }

  .titlebar-text {
    padding: 0.25rem 0.6rem;
    font-size: 0.5rem;
  }

  .hopes li {
    font-size: 1.4rem;
  }

  .reply-options {
    flex-direction: column;
    align-items: stretch;
  }

  .reply-btn {
    min-height: 48px;
  }

  .controls {
    gap: 0.5rem;
    padding: 0.7rem 0.8rem;
  }

  .btn {
    padding: 0.4rem 0.8rem;
    gap: 0.45rem;
  }

  .btn span {
    font-size: 0.55rem;
  }

  .dots {
    display: none;
  }

  .step-count {
    display: block;
  }
}

@media (max-width: 380px) {
  .window-body {
    padding: 1.2rem 0.9rem 1rem;
  }

  .heading {
    font-size: 0.78rem;
  }

  .text {
    font-size: 1.4rem;
  }

  .text.big {
    font-size: 1.6rem;
  }

  .btn-back span {
    display: none;
  }

  .btn-back {
    padding: 0.4rem 0.7rem;
  }

  .step-count {
    font-size: 1.25rem;
  }
}

@media (max-height: 520px) and (orientation: landscape) {
  .desktop {
    align-items: flex-start;
    padding-top: 0.75rem;
    padding-bottom: 1rem;
  }

  .window-body {
    min-height: 0;
    padding: 1.1rem 1.4rem 1rem;
  }

  .card {
    flex-direction: row;
    gap: 1.1rem;
  }

  .boot-icon,
  .closing-icon {
    width: 60px;
    height: 60px;
    margin-bottom: 0.8rem;
    font-size: 1.9rem;
  }

  .scanlines {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .screen.active,
  .screen.active .hopes li,
  .reply-output.pop {
    animation: none;
  }

  .cursor::after {
    animation: none;
  }

  .progress-fill {
    transition: none;
  }
}