:root {
  --paper: #d8d1c3;
  --red: #b2212c;
  --green: #7f9c82;
  --amber: #c7a25a;
  --ink: #050607;
  --panel: rgba(7, 8, 9, .72);
  --line: rgba(216, 209, 195, .18);
}

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

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #050607;
  color: var(--paper);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  touch-action: none;
}

button {
  border: 1px solid var(--line);
  color: var(--paper);
  background: rgba(12, 14, 15, .86);
  font: inherit;
  cursor: pointer;
}

#game {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  background: #030405;
}

.vignette,
.grain,
.flash,
.rotate {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.vignette {
  background:
    radial-gradient(circle at 50% 48%, rgba(0, 0, 0, 0) 0 42%, rgba(0, 0, 0, .42) 70%, rgba(0, 0, 0, .92) 100%),
    linear-gradient(to bottom, rgba(0, 0, 0, .18), rgba(0, 0, 0, .4));
  mix-blend-mode: multiply;
}

.grain {
  opacity: .15;
  background-image:
    repeating-radial-gradient(circle at 18% 33%, rgba(255, 255, 255, .16) 0 1px, transparent 1px 4px),
    repeating-linear-gradient(92deg, rgba(255, 255, 255, .08) 0 1px, transparent 1px 5px);
  animation: grain 320ms steps(2) infinite;
}

.flash {
  opacity: 0;
  background: rgba(230, 230, 215, .7);
  transition: opacity 160ms ease;
}

.rotate {
  z-index: 20;
  display: none;
  place-items: center;
  padding: 22px;
  background: rgba(5, 6, 7, .92);
  text-align: center;
}

.rotate div {
  width: min(360px, 86vw);
  padding: 18px;
  border: 1px solid var(--line);
  background: rgba(12, 14, 15, .82);
}

.rotate strong,
.rotate span {
  display: block;
}

.rotate strong {
  font-size: 24px;
}

.rotate span {
  margin-top: 8px;
  color: rgba(216, 209, 195, .72);
}

.boot,
.ending {
  position: fixed;
  inset: 0;
  z-index: 12;
  display: grid;
  place-items: center;
  padding: 22px;
  background:
    linear-gradient(to bottom, rgba(3, 4, 5, .26), rgba(3, 4, 5, .92)),
    radial-gradient(circle at 45% 28%, rgba(148, 157, 148, .13), transparent 30%),
    #050607;
}

.boot__panel,
.ending__panel {
  width: min(520px, 78vw);
  max-width: 78vw;
  padding: 24px;
  border: 1px solid rgba(216, 209, 195, .2);
  background: rgba(5, 6, 7, .74);
  backdrop-filter: blur(14px);
}

.boot__overline,
.label {
  margin: 0;
  color: rgba(216, 209, 195, .6);
  font-size: 11px;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 8px 0 12px;
  font-weight: 760;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(31px, 9.2vw, 62px);
  line-height: .98;
}

h2 {
  font-size: 24px;
}

.boot__copy,
.ending__panel p {
  margin: 0 0 20px;
  color: rgba(216, 209, 195, .78);
  line-height: 1.5;
}

.asset-status {
  margin: -8px 0 12px;
  color: rgba(216, 209, 195, .68);
  font-size: 12px;
}

.primary,
.secondary {
  width: 100%;
  min-height: 50px;
  border-radius: 8px;
  background: #d8d1c3;
  color: #08090a;
  font-weight: 760;
}

.primary:disabled {
  cursor: wait;
  opacity: .62;
}

.secondary {
  margin-top: 12px;
  background: transparent;
  color: var(--paper);
}

.hud {
  position: fixed;
  z-index: 4;
  top: max(12px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left));
  right: auto;
  width: min(410px, 72vw);
  pointer-events: none;
}

.hud__top,
.hud__objective {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.hud__top > div,
.hud__objective {
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--line);
  background: rgba(5, 6, 7, .55);
  backdrop-filter: blur(10px);
}

.hud__top > div {
  flex: 1;
}

.hud strong {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hud__objective {
  margin-top: 8px;
  display: block;
}

.phone {
  position: fixed;
  z-index: 8;
  right: max(14px, env(safe-area-inset-right));
  bottom: calc(86px + env(safe-area-inset-bottom));
  width: min(330px, calc(100vw - 28px));
  height: min(580px, calc(100vh - 126px));
  padding: 14px;
  border: 2px solid #1b1d1f;
  border-radius: 28px;
  background: linear-gradient(145deg, #14171a, #030405);
  box-shadow: 0 30px 90px rgba(0, 0, 0, .72);
  transform: translateY(116%) rotate(2deg);
  transition: transform 260ms ease;
}

.phone.is-open {
  transform: translateY(0) rotate(0);
}

.phone__bar {
  display: flex;
  justify-content: space-between;
  padding: 6px 12px;
  color: rgba(216, 209, 195, .68);
  font-size: 12px;
}

.phone__screen {
  height: calc(100% - 76px);
  overflow: hidden;
  padding: 16px 12px;
  border-radius: 18px;
  background:
    linear-gradient(rgba(255, 255, 255, .03) 50%, rgba(0, 0, 0, .08) 50%) 0 0 / 100% 4px,
    #0a0c0e;
}

.phone h2 {
  margin: 0 0 12px;
  font-size: 18px;
}

.messages {
  height: calc(100% - 36px);
  overflow-y: auto;
  padding-right: 4px;
}

.message {
  width: fit-content;
  max-width: 90%;
  margin: 9px 0;
  padding: 9px 10px;
  border: 1px solid rgba(216, 209, 195, .12);
  border-radius: 8px;
  background: rgba(216, 209, 195, .08);
  color: rgba(245, 240, 229, .92);
  font-size: 13px;
  line-height: 1.35;
}

.message.me {
  margin-left: auto;
  background: rgba(127, 156, 130, .2);
}

.message.bad {
  color: #f2b5b7;
  border-color: rgba(178, 33, 44, .36);
}

.replybar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding-top: 10px;
}

.replybar button,
.actions button {
  min-height: 42px;
  border-radius: 8px;
}

.event-text {
  position: fixed;
  z-index: 7;
  left: 50%;
  bottom: calc(158px + env(safe-area-inset-bottom));
  width: min(520px, calc(100vw - 30px));
  padding: 12px 14px;
  border: 1px solid rgba(216, 209, 195, .2);
  background: rgba(5, 6, 7, .68);
  color: rgba(245, 240, 229, .9);
  text-align: center;
  transform: translate(-50%, 18px);
  opacity: 0;
  transition: opacity 180ms ease, transform 180ms ease;
  pointer-events: none;
}

.event-text.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.controls {
  position: fixed;
  z-index: 5;
  left: max(14px, env(safe-area-inset-left));
  right: auto;
  bottom: max(14px, env(safe-area-inset-bottom));
  width: min(620px, 72vw);
  display: flex;
  justify-content: space-between;
  align-items: end;
  pointer-events: none;
}

.stick {
  width: 112px;
  height: 112px;
  border: 1px solid rgba(216, 209, 195, .16);
  border-radius: 50%;
  background: rgba(5, 6, 7, .35);
  pointer-events: auto;
  touch-action: none;
}

.stick span {
  display: block;
  width: 42px;
  height: 42px;
  margin: 34px;
  border-radius: 50%;
  background: rgba(216, 209, 195, .62);
  transform: translate(var(--dx, 0), var(--dy, 0));
}

.actions {
  display: grid;
  grid-template-columns: repeat(4, 52px);
  gap: 8px;
  pointer-events: auto;
}

.actions button {
  font-size: 22px;
  background: rgba(5, 6, 7, .58);
  backdrop-filter: blur(8px);
}

.ending {
  display: none;
}

.ending.show {
  display: grid;
}

.ending__choices {
  display: grid;
  gap: 8px;
}

.ending__choices button {
  min-height: 48px;
  border-radius: 8px;
}

@keyframes grain {
  from { transform: translate(0, 0); }
  to { transform: translate(-3%, 2%); }
}

@media (min-width: 820px) {
  .hud {
    right: auto;
    width: 410px;
  }

  .controls {
    left: 24px;
    right: 24px;
    width: auto;
    bottom: 24px;
  }
}

@media (orientation: landscape) {
  .boot,
  .ending {
    place-items: center start;
    padding: max(18px, env(safe-area-inset-top)) max(28px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(28px, env(safe-area-inset-left));
  }

  .boot__panel,
  .ending__panel {
    width: min(470px, 42vw);
    max-width: 42vw;
    padding: 20px;
  }

  h1 {
    font-size: clamp(34px, 5.2vw, 62px);
  }

  .boot__copy,
  .ending__panel p {
    font-size: 14px;
    line-height: 1.42;
  }

  .primary,
  .secondary {
    min-height: 44px;
  }

  .hud {
    width: min(460px, 42vw);
  }

  .hud__top {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .hud__top > div,
  .hud__objective {
    padding: 7px 9px;
  }

  .hud strong {
    font-size: 14px;
  }

  .phone {
    top: max(12px, env(safe-area-inset-top));
    right: max(14px, env(safe-area-inset-right));
    bottom: auto;
    width: min(300px, 32vw);
    height: min(360px, calc(100vh - 24px));
    border-radius: 22px;
    transform: translateX(116%) rotate(2deg);
  }

  .phone.is-open {
    transform: translateX(0) rotate(0);
  }

  .phone__screen {
    padding: 12px 10px;
  }

  .message {
    font-size: 12px;
  }

  .event-text {
    bottom: max(18px, env(safe-area-inset-bottom));
    width: min(470px, 48vw);
  }

  .controls {
    left: max(18px, env(safe-area-inset-left));
    right: max(18px, env(safe-area-inset-right));
    bottom: max(16px, env(safe-area-inset-bottom));
    width: auto;
  }

  .stick {
    width: 96px;
    height: 96px;
  }

  .stick span {
    width: 36px;
    height: 36px;
    margin: 30px;
  }

  .actions {
    grid-template-columns: repeat(4, 48px);
  }

  .actions button {
    min-height: 48px;
  }
}

@media (orientation: portrait) and (max-width: 820px) {
  .rotate {
    display: grid;
  }
}
